-
Notifications
You must be signed in to change notification settings - Fork 999
proposal: add artifact workflow CLI commands (Slice 4) #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
39645d9
44ca42f
ac8f6d2
a91adbd
17016d5
f874720
9eb2241
4f47bd2
acdce5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| ## Context | ||
|
|
||
| Slice 4 of the artifact workflow POC. The core functionality (ArtifactGraph, InstructionLoader, change-utils) is complete. This slice adds CLI commands to expose the artifact workflow to users. | ||
|
|
||
| **Key constraint**: This is experimental. Commands must be isolated for easy removal if the feature doesn't work out. | ||
|
|
||
| ## Goals / Non-Goals | ||
|
|
||
| - **Goals:** | ||
| - Expose artifact workflow status and instructions via CLI | ||
| - Provide fluid UX with top-level verb commands | ||
| - Support both human-readable and JSON output | ||
| - Enable agents to programmatically query workflow state | ||
| - Keep implementation isolated for easy removal | ||
|
|
||
| - **Non-Goals:** | ||
| - Interactive artifact creation wizards (future work) | ||
| - Schema management commands (deferred) | ||
| - Auto-detection of active change (CLI is deterministic, agents infer) | ||
|
|
||
| ## Decisions | ||
|
|
||
| ### Command Structure: Top-Level Verbs | ||
|
|
||
| Commands are top-level for maximum fluidity: | ||
|
|
||
| ``` | ||
| openspec status --change <id> | ||
| openspec next --change <id> | ||
| openspec instructions <artifact> --change <id> | ||
| openspec templates [--schema <name>] | ||
| openspec new change <name> | ||
| ``` | ||
|
|
||
| **Rationale:** | ||
| - Most fluid UX - fewest keystrokes | ||
| - Commands are unique enough to avoid conflicts | ||
| - Simple mental model for users | ||
|
|
||
| **Trade-off accepted:** Slight namespace pollution, but commands are distinct and can be removed cleanly. | ||
|
|
||
| ### Experimental Isolation | ||
|
|
||
| All artifact workflow commands are implemented in a single file: | ||
|
|
||
| ``` | ||
| src/commands/artifact-workflow.ts | ||
| ``` | ||
|
|
||
| **To remove the feature:** | ||
| 1. Delete `src/commands/artifact-workflow.ts` | ||
| 2. Remove ~5 lines from `src/cli/index.ts` | ||
|
|
||
| No other files touched, no risk to stable functionality. | ||
|
|
||
| ### Deterministic CLI with Explicit `--change` | ||
|
|
||
| All change-specific commands require `--change <id>`: | ||
|
|
||
| ```bash | ||
| openspec status --change add-auth # explicit, works | ||
| openspec status # error: missing --change | ||
| ``` | ||
|
|
||
| **Rationale:** | ||
| - CLI is pure, testable, no hidden state | ||
| - Agents infer change from conversation and pass explicitly | ||
| - No config file tracking "active change" | ||
| - Consistent with POC design philosophy | ||
|
|
||
| ### New Change Command Structure | ||
|
|
||
| Creating changes uses explicit subcommand: | ||
|
|
||
| ```bash | ||
| openspec new change add-feature | ||
| ``` | ||
|
|
||
| **Rationale:** | ||
| - `openspec new <name>` is ambiguous (new what?) | ||
| - `openspec new change <name>` is clear and extensible | ||
| - Can add `openspec new spec <name>` later if needed | ||
|
|
||
| ### Output Formats | ||
|
|
||
| - **Default**: Human-readable text with visual indicators | ||
| - Status: `[x]` done, `[ ]` ready, `[-]` blocked | ||
| - Colors: green (done), yellow (ready), red (blocked) | ||
| - **JSON** (`--json`): Machine-readable for scripts and agents | ||
|
|
||
| ### Error Handling | ||
|
|
||
| - Missing `--change`: Error listing available changes | ||
| - Unknown change: Error with suggestion | ||
| - Unknown artifact: Error listing valid artifacts | ||
| - Missing schema: Error with schema resolution details | ||
|
|
||
| ## Risks / Trade-offs | ||
|
|
||
| | Risk | Mitigation | | ||
| |------|------------| | ||
| | Top-level commands pollute namespace | Commands are distinct; isolated for easy removal | | ||
| | `status` confused with git | Context (`--change`) makes it clear | | ||
| | Feature doesn't work out | Single file deletion removes everything | | ||
|
|
||
| ## Implementation Notes | ||
|
|
||
| - All commands in `src/commands/artifact-workflow.ts` | ||
| - Imports from `src/core/artifact-graph/` for all operations | ||
| - Uses `getActiveChangeIds()` from `item-discovery.ts` for change listing | ||
| - Follows existing CLI patterns (ora spinners, commander.js options) | ||
| - Help text marks commands as "Experimental" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| ## Why | ||
|
|
||
| The ArtifactGraph (Slice 1) and InstructionLoader (Slice 3) provide programmatic APIs for artifact-based workflow management. Users currently have no CLI interface to: | ||
| - See artifact completion status for a change | ||
| - Discover what artifacts are ready to create | ||
| - Get enriched instructions for creating artifacts | ||
| - Create new changes with proper validation | ||
|
|
||
| This proposal adds CLI commands that expose the artifact workflow functionality to users and agents. | ||
|
|
||
| ## What Changes | ||
|
|
||
| - **NEW**: `openspec status --change <id>` shows artifact completion state | ||
| - **NEW**: `openspec next --change <id>` shows artifacts ready to create | ||
| - **NEW**: `openspec instructions <artifact> --change <id>` outputs enriched template | ||
| - **NEW**: `openspec templates [--schema <name>]` shows resolved template paths | ||
| - **NEW**: `openspec new change <name>` creates a new change directory | ||
|
|
||
| All commands are top-level for fluid UX. They integrate with existing core modules: | ||
| - Uses `loadChangeContext()`, `formatChangeStatus()`, `generateInstructions()` from instruction-loader | ||
| - Uses `ArtifactGraph`, `detectCompleted()` from artifact-graph | ||
| - Uses `createChange()`, `validateChangeName()` from change-utils | ||
|
|
||
| **Experimental isolation**: All commands are implemented in a single file (`src/commands/artifact-workflow.ts`) for easy removal if the feature doesn't work out. Help text marks them as experimental. | ||
|
|
||
| ## Impact | ||
|
|
||
| - Affected specs: NEW `cli-artifact-workflow` capability | ||
| - Affected code: | ||
| - `src/cli/index.ts` - register new commands | ||
| - `src/commands/artifact-workflow.ts` - new command implementations | ||
| - No changes to existing commands or specs | ||
| - Builds on completed Slice 1, 2, and 3 implementations | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| # cli-artifact-workflow Specification | ||
|
|
||
| ## Purpose | ||
| CLI commands for artifact workflow operations, exposing the artifact graph and instruction loader functionality to users and agents. Commands are top-level for fluid UX and implemented in isolation for easy removal. | ||
|
|
||
| ## ADDED Requirements | ||
|
|
||
| ### Requirement: Status Command | ||
| The system SHALL display artifact completion status for a change. | ||
|
|
||
| #### Scenario: Show status with all states | ||
| - **WHEN** user runs `openspec status --change <id>` | ||
| - **THEN** the system displays each artifact with status indicator: | ||
| - `[x]` for completed artifacts | ||
| - `[ ]` for ready artifacts | ||
| - `[-]` for blocked artifacts (with missing dependencies listed) | ||
|
|
||
| #### Scenario: Status shows completion summary | ||
| - **WHEN** user runs `openspec status --change <id>` | ||
| - **THEN** output includes completion percentage and count (e.g., "2/4 artifacts complete") | ||
|
|
||
| #### Scenario: Status JSON output | ||
| - **WHEN** user runs `openspec status --change <id> --json` | ||
| - **THEN** the system outputs JSON with changeName, schemaName, isComplete, and artifacts array | ||
|
|
||
| #### Scenario: Missing change parameter | ||
| - **WHEN** user runs `openspec status` without `--change` | ||
| - **THEN** the system displays an error with list of available changes | ||
|
|
||
| #### Scenario: Unknown change | ||
| - **WHEN** user runs `openspec status --change unknown-id` | ||
| - **THEN** the system displays an error indicating the change does not exist | ||
|
|
||
| ### Requirement: Next Command | ||
| The system SHALL show which artifacts are ready to be created. | ||
|
|
||
| #### Scenario: Show ready artifacts | ||
| - **WHEN** user runs `openspec next --change <id>` | ||
| - **THEN** the system lists artifacts whose dependencies are all satisfied | ||
|
|
||
| #### Scenario: No artifacts ready | ||
| - **WHEN** all artifacts are either completed or blocked | ||
| - **THEN** the system indicates no artifacts are ready (with explanation) | ||
|
|
||
| #### Scenario: All artifacts complete | ||
| - **WHEN** all artifacts in the change are completed | ||
| - **THEN** the system indicates the change is complete | ||
|
|
||
| #### Scenario: Next JSON output | ||
| - **WHEN** user runs `openspec next --change <id> --json` | ||
| - **THEN** the system outputs JSON array of ready artifact IDs | ||
|
|
||
| ### Requirement: Instructions Command | ||
| The system SHALL output enriched instructions for creating an artifact. | ||
|
|
||
| #### Scenario: Show enriched instructions | ||
| - **WHEN** user runs `openspec instructions <artifact> --change <id>` | ||
| - **THEN** the system outputs: | ||
| - Artifact metadata (ID, output path, description) | ||
| - Template content | ||
| - Dependency status (done/missing) | ||
| - Unlocked artifacts (what becomes available after completion) | ||
|
|
||
| #### Scenario: Instructions JSON output | ||
| - **WHEN** user runs `openspec instructions <artifact> --change <id> --json` | ||
| - **THEN** the system outputs JSON matching ArtifactInstructions interface | ||
|
|
||
| #### Scenario: Unknown artifact | ||
| - **WHEN** user runs `openspec instructions unknown-artifact --change <id>` | ||
| - **THEN** the system displays an error listing valid artifact IDs for the schema | ||
|
|
||
| #### Scenario: Artifact with unmet dependencies | ||
| - **WHEN** user requests instructions for a blocked artifact | ||
| - **THEN** the system displays instructions with a warning about missing dependencies | ||
|
|
||
| ### Requirement: Templates Command | ||
| The system SHALL show resolved template paths for all artifacts in a schema. | ||
|
|
||
| #### Scenario: List template paths with default schema | ||
| - **WHEN** user runs `openspec templates` | ||
| - **THEN** the system displays each artifact with its resolved template path using the default schema | ||
|
|
||
| #### Scenario: List template paths with custom schema | ||
| - **WHEN** user runs `openspec templates --schema tdd` | ||
| - **THEN** the system displays template paths for the specified schema | ||
|
|
||
| #### Scenario: Templates JSON output | ||
| - **WHEN** user runs `openspec templates --json` | ||
| - **THEN** the system outputs JSON mapping artifact IDs to template paths | ||
|
|
||
| #### Scenario: Template resolution source | ||
| - **WHEN** displaying template paths | ||
| - **THEN** the system indicates whether each template is from user override or package built-in | ||
|
|
||
| ### Requirement: New Change Command | ||
| The system SHALL create new change directories with validation. | ||
|
|
||
| #### Scenario: Create valid change | ||
| - **WHEN** user runs `openspec new change add-feature` | ||
| - **THEN** the system creates `openspec/changes/add-feature/` directory | ||
|
|
||
| #### Scenario: Invalid change name | ||
| - **WHEN** user runs `openspec new change "Add Feature"` with invalid name | ||
| - **THEN** the system displays validation error with guidance | ||
|
|
||
| #### Scenario: Duplicate change name | ||
| - **WHEN** user runs `openspec new change existing-change` for an existing change | ||
| - **THEN** the system displays an error indicating the change already exists | ||
|
|
||
| #### Scenario: Create with description | ||
| - **WHEN** user runs `openspec new change add-feature --description "Add new feature"` | ||
| - **THEN** the system creates the change directory with description in README.md | ||
|
|
||
| ### Requirement: Schema Selection | ||
| The system SHALL support custom schema selection for workflow commands. | ||
|
|
||
| #### Scenario: Default schema | ||
| - **WHEN** user runs workflow commands without `--schema` | ||
| - **THEN** the system uses the "spec-driven" schema | ||
|
|
||
| #### Scenario: Custom schema | ||
| - **WHEN** user runs `openspec status --change <id> --schema tdd` | ||
| - **THEN** the system uses the specified schema for artifact graph | ||
|
|
||
| #### Scenario: Unknown schema | ||
| - **WHEN** user specifies an unknown schema | ||
| - **THEN** the system displays an error listing available schemas | ||
|
Comment on lines
+114
to
+127
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find openspec/changes/add-artifact-workflow-cli -type f -name "*.md" | head -20Repository: Fission-AI/OpenSpec Length of output: 292 🏁 Script executed: cat -n openspec/changes/add-artifact-workflow-cli/design.md | head -50Repository: Fission-AI/OpenSpec Length of output: 1914 🏁 Script executed: cat -n openspec/changes/add-artifact-workflow-cli/proposal.md | head -50Repository: Fission-AI/OpenSpec Length of output: 1973 🏁 Script executed: cat -n openspec/changes/add-artifact-workflow-cli/design.md | tail -50Repository: Fission-AI/OpenSpec Length of output: 2011 🏁 Script executed: cat -n openspec/changes/add-artifact-workflow-cli/proposal.mdRepository: Fission-AI/OpenSpec Length of output: 1973 🏁 Script executed: wc -l openspec/changes/add-artifact-workflow-cli/specs/cli-workflow/spec.mdRepository: Fission-AI/OpenSpec Length of output: 136 🏁 Script executed: cat -n openspec/changes/add-artifact-workflow-cli/specs/cli-workflow/spec.md | head -130Repository: Fission-AI/OpenSpec Length of output: 6419 Schema Selection requirement introduces scope not defined in design/proposal documents. The "Schema Selection" requirement (lines 114-127) specifies
The spec introduces new behavior not previously approved. Clarify whether |
||
|
|
||
| ### Requirement: Output Formatting | ||
| The system SHALL provide consistent output formatting. | ||
|
|
||
| #### Scenario: Color output | ||
| - **WHEN** terminal supports colors | ||
| - **THEN** status indicators use colors: green (done), yellow (ready), red (blocked) | ||
|
|
||
| #### Scenario: No color output | ||
| - **WHEN** `--no-color` flag is used or NO_COLOR environment variable is set | ||
| - **THEN** output uses text-only indicators without ANSI colors | ||
|
|
||
| #### Scenario: Progress indication | ||
| - **WHEN** loading change state takes time | ||
| - **THEN** the system displays a spinner during loading | ||
|
|
||
| ### Requirement: Experimental Isolation | ||
| The system SHALL implement artifact workflow commands in isolation for easy removal. | ||
|
|
||
| #### Scenario: Single file implementation | ||
| - **WHEN** artifact workflow feature is implemented | ||
| - **THEN** all commands are in `src/commands/artifact-workflow.ts` | ||
|
|
||
| #### Scenario: Help text marking | ||
|
Comment on lines
+144
to
+151
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Experimental Isolation requirement is incomplete without help text content. Line 152–153 state that help text "SHALL indicate the command is experimental," but the requirement does not specify the exact help text string or where it appears in the implementation. This leaves ambiguity for developers about compliance. Add a clarifying scenario defining the exact help text format: 🔎 Proposed addition #### Scenario: Help text marking
- **WHEN** user runs `--help` on any artifact workflow command
- **THEN** help text indicates the command is experimental
+
+#### Scenario: Help text format
+- **WHEN** user runs `openspec status --help`
+- **THEN** help text includes prefix or footer marking: "(Experimental)" or similar clear indicatorBased on coding guidelines, each scenario should be concrete enough for implementation; this adds the needed specificity. |
||
| - **WHEN** user runs `--help` on any artifact workflow command | ||
| - **THEN** help text indicates the command is experimental | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| ## 1. Core Command Implementation | ||
|
|
||
| - [x] 1.1 Create `src/commands/artifact-workflow.ts` with all commands | ||
| - [x] 1.2 Implement `status` command with text output | ||
| - [x] 1.3 Implement `next` command with text output | ||
| - [x] 1.4 Implement `instructions` command with text output | ||
| - [x] 1.5 Implement `templates` command with text output | ||
| - [x] 1.6 Implement `new change` subcommand using createChange() | ||
|
|
||
| ## 2. CLI Registration | ||
|
|
||
| - [x] 2.1 Register `status` command in `src/cli/index.ts` | ||
| - [x] 2.2 Register `next` command in `src/cli/index.ts` | ||
| - [x] 2.3 Register `instructions` command in `src/cli/index.ts` | ||
| - [x] 2.4 Register `templates` command in `src/cli/index.ts` | ||
| - [x] 2.5 Register `new` command group with `change` subcommand | ||
|
|
||
| ## 3. Output Formatting | ||
|
|
||
| - [x] 3.1 Add `--json` flag support to all commands | ||
| - [x] 3.2 Add color-coded status indicators (done/ready/blocked) | ||
| - [x] 3.3 Add progress spinner for loading operations | ||
| - [x] 3.4 Support `--no-color` flag | ||
|
|
||
| ## 4. Error Handling | ||
|
|
||
| - [x] 4.1 Handle missing `--change` parameter with helpful error | ||
| - [x] 4.2 Handle unknown change names with list of available changes | ||
| - [x] 4.3 Handle unknown artifact names with valid options | ||
| - [x] 4.4 Handle schema resolution errors | ||
|
|
||
| ## 5. Options and Flags | ||
|
|
||
| - [x] 5.1 Add `--schema` option for custom schema selection | ||
| - [x] 5.2 Add `--description` option to `new change` command | ||
| - [x] 5.3 Ensure options follow existing CLI patterns | ||
|
|
||
| ## 6. Testing | ||
|
|
||
| - [x] 6.1 Add smoke tests for each command | ||
| - [x] 6.2 Test error cases (missing change, unknown artifact) | ||
| - [x] 6.3 Test JSON output format | ||
| - [x] 6.4 Test with different schemas | ||
|
|
||
| ## 7. Documentation | ||
|
|
||
| - [x] 7.1 Add help text for all commands marked as "Experimental" | ||
| - [ ] 7.2 Update AGENTS.md with new commands (post-archive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix redundant "CLI interface" phrase.
Line 3 uses the redundant phrase "no CLI interface to:" which should be simplified to "no CLI to:" since CLI already means "command-line interface."
🔎 Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[style] ~3-~3: This phrase is redundant (‘I’ stands for ‘interface’). Use simply “CLI”.
Context: ...low management. Users currently have no CLI interface to: - See artifact completion status fo...
(ACRONYM_TAUTOLOGY)
🤖 Prompt for AI Agents