mirror of
https://github.com/Fission-AI/OpenSpec.git
synced 2026-09-14 20:16:53 +08:00
5.3 KiB
5.3 KiB
Implementation Tasks
1. Change Command: Interactive Validation Selection
- 1.1 Add
--no-interactiveflag tochange validateinsrc/cli/index.ts - 1.2 Implement interactivity gate respecting TTY and
OPEN_SPEC_INTERACTIVE=0insrc/commands/change.ts - 1.3 When no
[change-name]is provided and interactivity is allowed, prompt with a list of active changes (excludearchive/) and validate the selected one - 1.4 Preserve current non-interactive fallback: print available change IDs and hint, set
process.exitCode = 1 - 1.5 Tests: add coverage for interactive and non-interactive flows
- Added
test/commands/change.interactive-validate.test.ts
- Added
2. Spec Command: Interactive Validation Selection
- 2.1 Make
spec validateaccept optional[spec-id]insrc/commands/spec.tsregistration - 2.2 Add
--no-interactiveflag tospec validate - 2.3 Implement interactivity gate respecting TTY and
OPEN_SPEC_INTERACTIVE=0 - 2.4 When no
[spec-id]provided and interactivity allowed, prompt to select fromopenspec/specs/*/spec.mdand validate the selected spec - 2.5 Preserve current non-interactive fallback when no spec-id and no interactivity: print existing error and exit code non-zero
- 2.6 Tests: add coverage for interactive and non-interactive flows
- Added
test/commands/spec.interactive-validate.test.ts
- Added
3. New Top-level validate Command
- 3.1 Add
validatecommand insrc/cli/index.ts- Options:
--all,--changes,--specs,--type <change|spec>,--strict,--json,--no-interactive - Usage:
openspec validate [item-name]
- Options:
- 3.2 Create
src/commands/validate.tsimplementing:- 3.2.1 Interactive selector when no args (choices: All, Changes, Specs, Specific item)
- 3.2.2 Non-interactive fallback with helpful hint and exit code 1
- 3.2.3 Direct item validation with automatic type detection
- 3.2.4 Ambiguity error when name exists as both change and spec; suggest
--typeor subcommands - 3.2.5 Unknown item handling with nearest-match suggestions
- 3.2.6 Bulk validation for
--all,--changes,--specs(excludeopenspec/changes/archive/) - 3.2.7 Respect
--strictand--jsonoptions; JSON shape per spec - 3.2.8 Exit with code 1 if any validation fails
- 3.2.9 Bounded concurrency (default 4–8) for bulk validation
- 3.2.10 Progress indication during bulk runs (current item, running counts)
4. Utilities and Shared Helpers
- 4.1 Add
src/utils/interactive.tswithisInteractive(stdin: NodeJS.ReadStream, noInteractiveFlag?: boolean): boolean- Considers:
process.stdin.isTTY,--no-interactive,OPEN_SPEC_INTERACTIVE=0
- Considers:
- 4.2 Add
src/utils/item-discovery.tswith:getActiveChangeIds(root = process.cwd()): Promise<string[]>(excludearchive/)getSpecIds(root = process.cwd()): Promise<string[]>(folders withspec.md)
- 4.3 Optional:
src/utils/concurrency.tshelper for bounded parallelism - 4.4 Reuse
src/core/validation/validator.tsfor item validation
5. JSON Output (Bulk Validation)
- 5.1 Implement JSON schema:
items: Array<{ id: string, type: "change"|"spec", valid: boolean, issues: Issue[], durationMs: number }>summary: { totals: { items: number, passed: number, failed: number }, byType: { change?: { items: number, passed: number, failed: number }, spec?: { items: number, passed: number, failed: number } } }version: "1.0"
- 5.2 Ensure process exit code is 1 if any
items[].valid === false - 5.3 Tests for JSON shape (keys, types, counts) and exit code behavior
- Added
test/commands/validate.test.ts
- Added
6. Progress and UX
- 6.1 Use
oraor minimal console progress to show current item and running counts - 6.2 Keep output stable in
--jsonmode (no extra logs to stdout; use stderr for progress if needed) - 6.3 Ensure responsiveness with concurrency limits
7. Tests
- 7.1 Add top-level validate tests:
test/commands/validate.test.ts- Includes non-interactive hint, --all JSON, --specs with concurrency, ambiguity error
- 7.2 Add unit tests for
isInteractiveand item discovery helpers - 7.3 Extend existing change/spec command tests to cover interactive
validate- Added
test/commands/change.interactive-validate.test.ts,test/commands/spec.interactive-validate.test.ts
- Added
8. CLI Help and Docs
- 8.1 Update command descriptions/options in
src/cli/index.ts - 8.2 Verify help output includes
validatecommand and flags - 8.3 Ensure existing specs under
openspec/changes/bulk-validation-interactive-selection/specs/*remain satisfied
9. Non-functional
- 9.1 Code style and types: explicit types for exported APIs; avoid
any - 9.2 No linter errors; stable formatting; avoid unrelated refactors
- 9.3 Maintain existing behavior for unaffected commands
10. Acceptance Criteria Mapping
- AC-1:
openspec change validateinteractive selection when no arg (TTY only; respects--no-interactive/env) — matches cli-change spec - AC-2:
openspec spec validateinteractive selection when no arg (TTY only; respects--no-interactive/env) — matches cli-spec spec - AC-3: New
openspec validatesupports interactive selection, bulk/filtered validation, JSON schema, progress, concurrency, exit codes — matches cli-validate spec