@fission-ai/openspec 0.17.1 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/cli/index.js +7 -1
  2. package/dist/commands/artifact-workflow.d.ts +17 -0
  3. package/dist/commands/artifact-workflow.js +818 -0
  4. package/dist/commands/validate.d.ts +1 -0
  5. package/dist/commands/validate.js +3 -3
  6. package/dist/core/archive.d.ts +0 -5
  7. package/dist/core/archive.js +4 -257
  8. package/dist/core/artifact-graph/graph.d.ts +56 -0
  9. package/dist/core/artifact-graph/graph.js +141 -0
  10. package/dist/core/artifact-graph/index.d.ts +7 -0
  11. package/dist/core/artifact-graph/index.js +13 -0
  12. package/dist/core/artifact-graph/instruction-loader.d.ts +130 -0
  13. package/dist/core/artifact-graph/instruction-loader.js +173 -0
  14. package/dist/core/artifact-graph/resolver.d.ts +61 -0
  15. package/dist/core/artifact-graph/resolver.js +187 -0
  16. package/dist/core/artifact-graph/schema.d.ts +13 -0
  17. package/dist/core/artifact-graph/schema.js +108 -0
  18. package/dist/core/artifact-graph/state.d.ts +12 -0
  19. package/dist/core/artifact-graph/state.js +54 -0
  20. package/dist/core/artifact-graph/types.d.ts +45 -0
  21. package/dist/core/artifact-graph/types.js +43 -0
  22. package/dist/core/converters/json-converter.js +2 -1
  23. package/dist/core/global-config.d.ts +10 -0
  24. package/dist/core/global-config.js +28 -0
  25. package/dist/core/index.d.ts +1 -1
  26. package/dist/core/index.js +1 -1
  27. package/dist/core/list.d.ts +6 -1
  28. package/dist/core/list.js +88 -6
  29. package/dist/core/specs-apply.d.ts +73 -0
  30. package/dist/core/specs-apply.js +384 -0
  31. package/dist/core/templates/skill-templates.d.ts +76 -0
  32. package/dist/core/templates/skill-templates.js +1472 -0
  33. package/dist/core/update.js +1 -1
  34. package/dist/core/validation/validator.js +2 -1
  35. package/dist/core/view.js +28 -8
  36. package/dist/utils/change-metadata.d.ts +47 -0
  37. package/dist/utils/change-metadata.js +130 -0
  38. package/dist/utils/change-utils.d.ts +51 -0
  39. package/dist/utils/change-utils.js +100 -0
  40. package/dist/utils/file-system.d.ts +5 -0
  41. package/dist/utils/file-system.js +7 -0
  42. package/dist/utils/index.d.ts +3 -1
  43. package/dist/utils/index.js +4 -1
  44. package/dist/utils/interactive.d.ts +7 -2
  45. package/dist/utils/interactive.js +9 -1
  46. package/package.json +4 -1
  47. package/schemas/spec-driven/schema.yaml +148 -0
  48. package/schemas/spec-driven/templates/design.md +19 -0
  49. package/schemas/spec-driven/templates/proposal.md +23 -0
  50. package/schemas/spec-driven/templates/spec.md +8 -0
  51. package/schemas/spec-driven/templates/tasks.md +9 -0
  52. package/schemas/tdd/schema.yaml +213 -0
  53. package/schemas/tdd/templates/docs.md +15 -0
  54. package/schemas/tdd/templates/implementation.md +11 -0
  55. package/schemas/tdd/templates/spec.md +11 -0
  56. package/schemas/tdd/templates/test.md +11 -0
@@ -0,0 +1,148 @@
1
+ name: spec-driven
2
+ version: 1
3
+ description: Default OpenSpec workflow - proposal → specs → design → tasks
4
+ artifacts:
5
+ - id: proposal
6
+ generates: proposal.md
7
+ description: Initial proposal document outlining the change
8
+ template: proposal.md
9
+ instruction: |
10
+ Create the proposal document that establishes WHY this change is needed.
11
+
12
+ Sections:
13
+ - **Why**: 1-2 sentences on the problem or opportunity. What problem does this solve? Why now?
14
+ - **What Changes**: Bullet list of changes. Be specific about new capabilities, modifications, or removals. Mark breaking changes with **BREAKING**.
15
+ - **Capabilities**: Identify which specs will be created or modified:
16
+ - **New Capabilities**: List capabilities being introduced. Each becomes a new `specs/<name>/spec.md`. Use kebab-case names (e.g., `user-auth`, `data-export`).
17
+ - **Modified Capabilities**: List existing capabilities whose REQUIREMENTS are changing. Only include if spec-level behavior changes (not just implementation details). Each needs a delta spec file. Check `openspec/specs/` for existing spec names. Leave empty if no requirement changes.
18
+ - **Impact**: Affected code, APIs, dependencies, or systems.
19
+
20
+ IMPORTANT: The Capabilities section is critical. It creates the contract between
21
+ proposal and specs phases. Research existing specs before filling this in.
22
+ Each capability listed here will need a corresponding spec file.
23
+
24
+ Keep it concise (1-2 pages). Focus on the "why" not the "how" -
25
+ implementation details belong in design.md.
26
+
27
+ This is the foundation - specs, design, and tasks all build on this.
28
+ requires: []
29
+
30
+ - id: specs
31
+ generates: "specs/**/*.md"
32
+ description: Detailed specifications for the change
33
+ template: spec.md
34
+ instruction: |
35
+ Create specification files that define WHAT the system should do.
36
+
37
+ Create one spec file per capability/feature area in specs/<name>/spec.md.
38
+
39
+ Delta operations (use ## headers):
40
+ - **ADDED Requirements**: New capabilities
41
+ - **MODIFIED Requirements**: Changed behavior - MUST include full updated content
42
+ - **REMOVED Requirements**: Deprecated features - MUST include **Reason** and **Migration**
43
+ - **RENAMED Requirements**: Name changes only - use FROM:/TO: format
44
+
45
+ Format requirements:
46
+ - Each requirement: `### Requirement: <name>` followed by description
47
+ - Use SHALL/MUST for normative requirements (avoid should/may)
48
+ - Each scenario: `#### Scenario: <name>` with WHEN/THEN format
49
+ - **CRITICAL**: Scenarios MUST use exactly 4 hashtags (`####`). Using 3 hashtags or bullets will fail silently.
50
+ - Every requirement MUST have at least one scenario.
51
+
52
+ MODIFIED requirements workflow:
53
+ 1. Locate the existing requirement in openspec/specs/<capability>/spec.md
54
+ 2. Copy the ENTIRE requirement block (from `### Requirement:` through all scenarios)
55
+ 3. Paste under `## MODIFIED Requirements` and edit to reflect new behavior
56
+ 4. Ensure header text matches exactly (whitespace-insensitive)
57
+
58
+ Common pitfall: Using MODIFIED with partial content loses detail at archive time.
59
+ If adding new concerns without changing existing behavior, use ADDED instead.
60
+
61
+ Example:
62
+ ```
63
+ ## ADDED Requirements
64
+
65
+ ### Requirement: User can export data
66
+ The system SHALL allow users to export their data in CSV format.
67
+
68
+ #### Scenario: Successful export
69
+ - **WHEN** user clicks "Export" button
70
+ - **THEN** system downloads a CSV file with all user data
71
+
72
+ ## REMOVED Requirements
73
+
74
+ ### Requirement: Legacy export
75
+ **Reason**: Replaced by new export system
76
+ **Migration**: Use new export endpoint at /api/v2/export
77
+ ```
78
+
79
+ Specs should be testable - each scenario is a potential test case.
80
+ requires:
81
+ - proposal
82
+
83
+ - id: design
84
+ generates: design.md
85
+ description: Technical design document with implementation details
86
+ template: design.md
87
+ instruction: |
88
+ Create the design document that explains HOW to implement the change.
89
+
90
+ When to include design.md (create only if any apply):
91
+ - Cross-cutting change (multiple services/modules) or new architectural pattern
92
+ - New external dependency or significant data model changes
93
+ - Security, performance, or migration complexity
94
+ - Ambiguity that benefits from technical decisions before coding
95
+
96
+ Sections:
97
+ - **Context**: Background, current state, constraints, stakeholders
98
+ - **Goals / Non-Goals**: What this design achieves and explicitly excludes
99
+ - **Decisions**: Key technical choices with rationale (why X over Y?). Include alternatives considered for each decision.
100
+ - **Risks / Trade-offs**: Known limitations, things that could go wrong. Format: [Risk] → Mitigation
101
+ - **Migration Plan**: Steps to deploy, rollback strategy (if applicable)
102
+ - **Open Questions**: Outstanding decisions or unknowns to resolve
103
+
104
+ Focus on architecture and approach, not line-by-line implementation.
105
+ Reference the proposal for motivation and specs for requirements.
106
+
107
+ Good design docs explain the "why" behind technical decisions.
108
+ requires:
109
+ - proposal
110
+
111
+ - id: tasks
112
+ generates: tasks.md
113
+ description: Implementation tasks derived from specs and design
114
+ template: tasks.md
115
+ instruction: |
116
+ Create the task list that breaks down the implementation work.
117
+
118
+ Guidelines:
119
+ - Group related tasks under ## numbered headings
120
+ - Each task is a checkbox: - [ ] X.Y Task description
121
+ - Tasks should be small enough to complete in one session
122
+ - Order tasks by dependency (what must be done first?)
123
+
124
+ Example:
125
+ ```
126
+ ## 1. Setup
127
+
128
+ - [ ] 1.1 Create new module structure
129
+ - [ ] 1.2 Add dependencies to package.json
130
+
131
+ ## 2. Core Implementation
132
+
133
+ - [ ] 2.1 Implement data export function
134
+ - [ ] 2.2 Add CSV formatting utilities
135
+ ```
136
+
137
+ Reference specs for what needs to be built, design for how to build it.
138
+ Each task should be verifiable - you know when it's done.
139
+ requires:
140
+ - specs
141
+ - design
142
+
143
+ apply:
144
+ requires: [tasks]
145
+ tracks: tasks.md
146
+ instruction: |
147
+ Read context files, work through pending tasks, mark complete as you go.
148
+ Pause if you hit blockers or need clarification.
@@ -0,0 +1,19 @@
1
+ ## Context
2
+
3
+ <!-- Background and current state -->
4
+
5
+ ## Goals / Non-Goals
6
+
7
+ **Goals:**
8
+ <!-- What this design aims to achieve -->
9
+
10
+ **Non-Goals:**
11
+ <!-- What is explicitly out of scope -->
12
+
13
+ ## Decisions
14
+
15
+ <!-- Key design decisions and rationale -->
16
+
17
+ ## Risks / Trade-offs
18
+
19
+ <!-- Known risks and trade-offs -->
@@ -0,0 +1,23 @@
1
+ ## Why
2
+
3
+ <!-- Explain the motivation for this change. What problem does this solve? Why now? -->
4
+
5
+ ## What Changes
6
+
7
+ <!-- Describe what will change. Be specific about new capabilities, modifications, or removals. -->
8
+
9
+ ## Capabilities
10
+
11
+ ### New Capabilities
12
+ <!-- Capabilities being introduced. Replace <name> with kebab-case identifier (e.g., user-auth, data-export, api-rate-limiting). Each creates specs/<name>/spec.md -->
13
+ - `<name>`: <brief description of what this capability covers>
14
+
15
+ ### Modified Capabilities
16
+ <!-- Existing capabilities whose REQUIREMENTS are changing (not just implementation).
17
+ Only list here if spec-level behavior changes. Each needs a delta spec file.
18
+ Use existing spec names from openspec/specs/. Leave empty if no requirement changes. -->
19
+ - `<existing-name>`: <what requirement is changing>
20
+
21
+ ## Impact
22
+
23
+ <!-- Affected code, APIs, dependencies, systems -->
@@ -0,0 +1,8 @@
1
+ ## ADDED Requirements
2
+
3
+ ### Requirement: <!-- requirement name -->
4
+ <!-- requirement text -->
5
+
6
+ #### Scenario: <!-- scenario name -->
7
+ - **WHEN** <!-- condition -->
8
+ - **THEN** <!-- expected outcome -->
@@ -0,0 +1,9 @@
1
+ ## 1. <!-- Task Group Name -->
2
+
3
+ - [ ] 1.1 <!-- Task description -->
4
+ - [ ] 1.2 <!-- Task description -->
5
+
6
+ ## 2. <!-- Task Group Name -->
7
+
8
+ - [ ] 2.1 <!-- Task description -->
9
+ - [ ] 2.2 <!-- Task description -->
@@ -0,0 +1,213 @@
1
+ name: tdd
2
+ version: 1
3
+ description: Test-driven development workflow - tests → implementation → docs
4
+ artifacts:
5
+ - id: spec
6
+ generates: spec.md
7
+ description: Feature specification defining requirements
8
+ template: spec.md
9
+ instruction: |
10
+ Create the feature specification that defines WHAT to build.
11
+
12
+ Sections:
13
+ - **Feature**: Name and high-level description of the feature's purpose and user value
14
+ - **Requirements**: List of specific requirements. Use SHALL/MUST for normative language.
15
+ - **Acceptance Criteria**: Testable criteria in WHEN/THEN format
16
+
17
+ Format requirements:
18
+ - Each requirement should be specific and testable
19
+ - Use `#### Scenario: <name>` with WHEN/THEN format for acceptance criteria
20
+ - Define edge cases and error scenarios explicitly
21
+ - Every requirement MUST have at least one scenario
22
+
23
+ Example:
24
+ ```
25
+ ## Feature: User Authentication
26
+
27
+ Users can securely log into the application.
28
+
29
+ ## Requirements
30
+
31
+ ### Requirement: Password validation
32
+ The system SHALL validate passwords meet minimum security requirements.
33
+
34
+ #### Scenario: Valid password accepted
35
+ - **WHEN** password has 8+ chars, uppercase, lowercase, and number
36
+ - **THEN** password is accepted
37
+
38
+ #### Scenario: Weak password rejected
39
+ - **WHEN** password is less than 8 characters
40
+ - **THEN** system displays "Password too short" error
41
+ ```
42
+
43
+ This spec drives test creation - each scenario becomes a test case.
44
+ requires: []
45
+
46
+ - id: tests
47
+ generates: "tests/*.test.ts"
48
+ description: Test files written before implementation
49
+ template: test.md
50
+ instruction: |
51
+ Write tests BEFORE implementation (TDD red phase).
52
+
53
+ File naming:
54
+ - Create test files as `tests/<feature>.test.ts`
55
+ - One test file per feature/capability
56
+ - Use descriptive names matching the spec
57
+
58
+ Test structure:
59
+ - Use Given/When/Then format matching spec scenarios
60
+ - Group related tests with `describe()` blocks
61
+ - Each scenario from spec becomes at least one `it()` test
62
+
63
+ Coverage requirements:
64
+ - Cover each requirement from the spec
65
+ - Include happy path (success cases)
66
+ - Include edge cases (boundary conditions)
67
+ - Include error scenarios (invalid input, failures)
68
+ - Tests should fail initially (no implementation yet)
69
+
70
+ Example:
71
+ ```typescript
72
+ describe('Password validation', () => {
73
+ it('accepts valid password with all requirements', () => {
74
+ // GIVEN a password meeting all requirements
75
+ const password = 'SecurePass1';
76
+ // WHEN validating
77
+ const result = validatePassword(password);
78
+ // THEN it should be accepted
79
+ expect(result.valid).toBe(true);
80
+ });
81
+
82
+ it('rejects password shorter than 8 characters', () => {
83
+ // GIVEN a short password
84
+ const password = 'Short1';
85
+ // WHEN validating
86
+ const result = validatePassword(password);
87
+ // THEN it should be rejected with message
88
+ expect(result.valid).toBe(false);
89
+ expect(result.error).toBe('Password too short');
90
+ });
91
+ });
92
+ ```
93
+
94
+ Follow the spec requirements exactly - tests verify the spec.
95
+ requires:
96
+ - spec
97
+
98
+ - id: implementation
99
+ generates: "src/*.ts"
100
+ description: Implementation code to pass the tests
101
+ template: implementation.md
102
+ instruction: |
103
+ Implement the feature to make tests pass (TDD green phase).
104
+
105
+ TDD workflow:
106
+ 1. Run tests - confirm they fail (red)
107
+ 2. Write minimal code to pass ONE test
108
+ 3. Run tests - confirm that test passes (green)
109
+ 4. Refactor if needed while keeping tests green
110
+ 5. Repeat for next failing test
111
+
112
+ Implementation guidelines:
113
+ - Write minimal code to pass each test - no more, no less
114
+ - Run tests frequently to verify progress
115
+ - Keep functions small and focused
116
+ - Use clear, descriptive names
117
+
118
+ Code organization:
119
+ - Create source files in `src/<feature>.ts`
120
+ - Export public API clearly
121
+ - Keep implementation details private
122
+ - Add JSDoc comments for public functions
123
+
124
+ Example structure:
125
+ ```typescript
126
+ /**
127
+ * Validates a password meets security requirements.
128
+ * @param password - The password to validate
129
+ * @returns Validation result with valid flag and optional error
130
+ */
131
+ export function validatePassword(password: string): ValidationResult {
132
+ if (password.length < 8) {
133
+ return { valid: false, error: 'Password too short' };
134
+ }
135
+ // ... additional checks
136
+ return { valid: true };
137
+ }
138
+ ```
139
+
140
+ Don't over-engineer - implement only what tests require.
141
+ requires:
142
+ - tests
143
+
144
+ - id: docs
145
+ generates: "docs/*.md"
146
+ description: Documentation for the implemented feature
147
+ template: docs.md
148
+ instruction: |
149
+ Document the implemented feature.
150
+
151
+ Sections:
152
+ - **Overview**: What the feature does and why it exists (1-2 paragraphs)
153
+ - **Getting Started**: Quick start guide to use the feature immediately
154
+ - **Examples**: Code examples showing common use cases
155
+ - **Reference**: Detailed API documentation, configuration options
156
+
157
+ Guidelines:
158
+ - Write for the user, not the developer
159
+ - Start with the most common use case
160
+ - Include copy-pasteable code examples
161
+ - Document all configuration options with defaults
162
+ - Note any limitations, edge cases, or gotchas
163
+ - Link to related features or specs
164
+
165
+ Example structure:
166
+ ```markdown
167
+ ## Overview
168
+
169
+ Password validation ensures user passwords meet security requirements
170
+ before account creation or password changes.
171
+
172
+ ## Getting Started
173
+
174
+ Import and use the validation function:
175
+
176
+ ```typescript
177
+ import { validatePassword } from './password';
178
+
179
+ const result = validatePassword('MySecurePass1');
180
+ if (!result.valid) {
181
+ console.error(result.error);
182
+ }
183
+ ```
184
+
185
+ ## Examples
186
+
187
+ ### Basic validation
188
+ ...
189
+
190
+ ### Custom error handling
191
+ ...
192
+
193
+ ## Reference
194
+
195
+ ### validatePassword(password)
196
+
197
+ | Parameter | Type | Description |
198
+ |-----------|------|-------------|
199
+ | password | string | The password to validate |
200
+
201
+ **Returns**: `{ valid: boolean, error?: string }`
202
+ ```
203
+
204
+ Reference the spec for requirements, implementation for details.
205
+ requires:
206
+ - implementation
207
+
208
+ apply:
209
+ requires: [tests]
210
+ tracks: null
211
+ instruction: |
212
+ Run tests to see failures. Implement minimal code to pass each test.
213
+ Refactor while keeping tests green.
@@ -0,0 +1,15 @@
1
+ ## Overview
2
+
3
+ <!-- Feature overview -->
4
+
5
+ ## Getting Started
6
+
7
+ <!-- Quick start guide -->
8
+
9
+ ## Examples
10
+
11
+ <!-- Code examples -->
12
+
13
+ ## Reference
14
+
15
+ <!-- API reference or additional details -->
@@ -0,0 +1,11 @@
1
+ ## Implementation Notes
2
+
3
+ <!-- Technical implementation details -->
4
+
5
+ ## API
6
+
7
+ <!-- Public API documentation -->
8
+
9
+ ## Usage
10
+
11
+ <!-- Usage examples -->
@@ -0,0 +1,11 @@
1
+ ## Feature: <!-- feature name -->
2
+
3
+ <!-- Feature description -->
4
+
5
+ ## Requirements
6
+
7
+ <!-- List of requirements -->
8
+
9
+ ## Acceptance Criteria
10
+
11
+ <!-- List of acceptance criteria -->
@@ -0,0 +1,11 @@
1
+ ## Test Plan
2
+
3
+ <!-- Describe the testing strategy -->
4
+
5
+ ## Test Cases
6
+
7
+ ### <!-- Test case name -->
8
+
9
+ - **Given:** <!-- preconditions -->
10
+ - **When:** <!-- action -->
11
+ - **Then:** <!-- expected result -->