@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.
- package/dist/cli/index.js +7 -1
- package/dist/commands/artifact-workflow.d.ts +17 -0
- package/dist/commands/artifact-workflow.js +818 -0
- package/dist/commands/validate.d.ts +1 -0
- package/dist/commands/validate.js +3 -3
- package/dist/core/archive.d.ts +0 -5
- package/dist/core/archive.js +4 -257
- package/dist/core/artifact-graph/graph.d.ts +56 -0
- package/dist/core/artifact-graph/graph.js +141 -0
- package/dist/core/artifact-graph/index.d.ts +7 -0
- package/dist/core/artifact-graph/index.js +13 -0
- package/dist/core/artifact-graph/instruction-loader.d.ts +130 -0
- package/dist/core/artifact-graph/instruction-loader.js +173 -0
- package/dist/core/artifact-graph/resolver.d.ts +61 -0
- package/dist/core/artifact-graph/resolver.js +187 -0
- package/dist/core/artifact-graph/schema.d.ts +13 -0
- package/dist/core/artifact-graph/schema.js +108 -0
- package/dist/core/artifact-graph/state.d.ts +12 -0
- package/dist/core/artifact-graph/state.js +54 -0
- package/dist/core/artifact-graph/types.d.ts +45 -0
- package/dist/core/artifact-graph/types.js +43 -0
- package/dist/core/converters/json-converter.js +2 -1
- package/dist/core/global-config.d.ts +10 -0
- package/dist/core/global-config.js +28 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/list.d.ts +6 -1
- package/dist/core/list.js +88 -6
- package/dist/core/specs-apply.d.ts +73 -0
- package/dist/core/specs-apply.js +384 -0
- package/dist/core/templates/skill-templates.d.ts +76 -0
- package/dist/core/templates/skill-templates.js +1472 -0
- package/dist/core/update.js +1 -1
- package/dist/core/validation/validator.js +2 -1
- package/dist/core/view.js +28 -8
- package/dist/utils/change-metadata.d.ts +47 -0
- package/dist/utils/change-metadata.js +130 -0
- package/dist/utils/change-utils.d.ts +51 -0
- package/dist/utils/change-utils.js +100 -0
- package/dist/utils/file-system.d.ts +5 -0
- package/dist/utils/file-system.js +7 -0
- package/dist/utils/index.d.ts +3 -1
- package/dist/utils/index.js +4 -1
- package/dist/utils/interactive.d.ts +7 -2
- package/dist/utils/interactive.js +9 -1
- package/package.json +4 -1
- package/schemas/spec-driven/schema.yaml +148 -0
- package/schemas/spec-driven/templates/design.md +19 -0
- package/schemas/spec-driven/templates/proposal.md +23 -0
- package/schemas/spec-driven/templates/spec.md +8 -0
- package/schemas/spec-driven/templates/tasks.md +9 -0
- package/schemas/tdd/schema.yaml +213 -0
- package/schemas/tdd/templates/docs.md +15 -0
- package/schemas/tdd/templates/implementation.md +11 -0
- package/schemas/tdd/templates/spec.md +11 -0
- package/schemas/tdd/templates/test.md +11 -0
|
@@ -0,0 +1,1472 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Skill Templates
|
|
3
|
+
*
|
|
4
|
+
* Templates for generating Agent Skills compatible with:
|
|
5
|
+
* - Claude Code
|
|
6
|
+
* - Cursor (Settings → Rules → Import Settings)
|
|
7
|
+
* - Windsurf
|
|
8
|
+
* - Other Agent Skills-compatible editors
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Template for openspec-new-change skill
|
|
12
|
+
* Based on /opsx:new command
|
|
13
|
+
*/
|
|
14
|
+
export function getNewChangeSkillTemplate() {
|
|
15
|
+
return {
|
|
16
|
+
name: 'openspec-new-change',
|
|
17
|
+
description: 'Start a new OpenSpec change using the experimental artifact workflow. Use when the user wants to create a new feature, fix, or modification with a structured step-by-step approach.',
|
|
18
|
+
instructions: `Start a new change using the experimental artifact-driven approach.
|
|
19
|
+
|
|
20
|
+
**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
|
|
21
|
+
|
|
22
|
+
**Steps**
|
|
23
|
+
|
|
24
|
+
1. **If no clear input provided, ask what they want to build**
|
|
25
|
+
|
|
26
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
27
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
28
|
+
|
|
29
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
|
|
30
|
+
|
|
31
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
32
|
+
|
|
33
|
+
2. **Select a workflow schema**
|
|
34
|
+
|
|
35
|
+
Run \`openspec schemas --json\` to get available schemas with descriptions.
|
|
36
|
+
|
|
37
|
+
Use the **AskUserQuestion tool** to let the user choose a workflow:
|
|
38
|
+
- Present each schema with its description
|
|
39
|
+
- Mark \`spec-driven\` as "(default)" if it's available
|
|
40
|
+
- Example options: "spec-driven - proposal → specs → design → tasks (default)", "tdd - tests → implementation → docs"
|
|
41
|
+
|
|
42
|
+
If user doesn't have a preference, default to \`spec-driven\`.
|
|
43
|
+
|
|
44
|
+
3. **Create the change directory**
|
|
45
|
+
\`\`\`bash
|
|
46
|
+
openspec new change "<name>" --schema "<selected-schema>"
|
|
47
|
+
\`\`\`
|
|
48
|
+
This creates a scaffolded change at \`openspec/changes/<name>/\` with the selected schema.
|
|
49
|
+
|
|
50
|
+
4. **Show the artifact status**
|
|
51
|
+
\`\`\`bash
|
|
52
|
+
openspec status --change "<name>"
|
|
53
|
+
\`\`\`
|
|
54
|
+
This shows which artifacts need to be created and which are ready (dependencies satisfied).
|
|
55
|
+
|
|
56
|
+
5. **Get instructions for the first artifact**
|
|
57
|
+
The first artifact depends on the schema (e.g., \`proposal\` for spec-driven, \`spec\` for tdd).
|
|
58
|
+
Check the status output to find the first artifact with status "ready".
|
|
59
|
+
\`\`\`bash
|
|
60
|
+
openspec instructions <first-artifact-id> --change "<name>"
|
|
61
|
+
\`\`\`
|
|
62
|
+
This outputs the template and context for creating the first artifact.
|
|
63
|
+
|
|
64
|
+
6. **STOP and wait for user direction**
|
|
65
|
+
|
|
66
|
+
**Output**
|
|
67
|
+
|
|
68
|
+
After completing the steps, summarize:
|
|
69
|
+
- Change name and location
|
|
70
|
+
- Selected schema/workflow and its artifact sequence
|
|
71
|
+
- Current status (0/N artifacts complete)
|
|
72
|
+
- The template for the first artifact
|
|
73
|
+
- Prompt: "Ready to create the first artifact? Just describe what this change is about and I'll draft it, or ask me to continue."
|
|
74
|
+
|
|
75
|
+
**Guardrails**
|
|
76
|
+
- Do NOT create any artifacts yet - just show the instructions
|
|
77
|
+
- Do NOT advance beyond showing the first artifact template
|
|
78
|
+
- If the name is invalid (not kebab-case), ask for a valid name
|
|
79
|
+
- If a change with that name already exists, suggest continuing that change instead
|
|
80
|
+
- Always pass --schema to preserve the user's workflow choice`
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Template for openspec-continue-change skill
|
|
85
|
+
* Based on /opsx:continue command
|
|
86
|
+
*/
|
|
87
|
+
export function getContinueChangeSkillTemplate() {
|
|
88
|
+
return {
|
|
89
|
+
name: 'openspec-continue-change',
|
|
90
|
+
description: 'Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow.',
|
|
91
|
+
instructions: `Continue working on a change by creating the next artifact.
|
|
92
|
+
|
|
93
|
+
**Input**: Optionally specify a change name. If omitted, MUST prompt for available changes.
|
|
94
|
+
|
|
95
|
+
**Steps**
|
|
96
|
+
|
|
97
|
+
1. **If no change name provided, prompt for selection**
|
|
98
|
+
|
|
99
|
+
Run \`openspec list --json\` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on.
|
|
100
|
+
|
|
101
|
+
Present the top 3-4 most recently modified changes as options, showing:
|
|
102
|
+
- Change name
|
|
103
|
+
- Schema (from \`schema\` field if present, otherwise "spec-driven")
|
|
104
|
+
- Status (e.g., "0/5 tasks", "complete", "no tasks")
|
|
105
|
+
- How recently it was modified (from \`lastModified\` field)
|
|
106
|
+
|
|
107
|
+
Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue.
|
|
108
|
+
|
|
109
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
110
|
+
|
|
111
|
+
2. **Check current status**
|
|
112
|
+
\`\`\`bash
|
|
113
|
+
openspec status --change "<name>" --json
|
|
114
|
+
\`\`\`
|
|
115
|
+
Parse the JSON to understand current state. The response includes:
|
|
116
|
+
- \`schemaName\`: The workflow schema being used (e.g., "spec-driven", "tdd")
|
|
117
|
+
- \`artifacts\`: Array of artifacts with their status ("done", "ready", "blocked")
|
|
118
|
+
- \`isComplete\`: Boolean indicating if all artifacts are complete
|
|
119
|
+
|
|
120
|
+
3. **Act based on status**:
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
**If all artifacts are complete (\`isComplete: true\`)**:
|
|
125
|
+
- Congratulate the user
|
|
126
|
+
- Show final status including the schema used
|
|
127
|
+
- Suggest: "All artifacts created! You can now implement this change or archive it."
|
|
128
|
+
- STOP
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
**If artifacts are ready to create** (status shows artifacts with \`status: "ready"\`):
|
|
133
|
+
- Pick the FIRST artifact with \`status: "ready"\` from the status output
|
|
134
|
+
- Get its instructions:
|
|
135
|
+
\`\`\`bash
|
|
136
|
+
openspec instructions <artifact-id> --change "<name>" --json
|
|
137
|
+
\`\`\`
|
|
138
|
+
- Parse the JSON to get template, dependencies, and what it unlocks
|
|
139
|
+
- **Create the artifact file** using the template as a starting point:
|
|
140
|
+
- Read any completed dependency files for context
|
|
141
|
+
- Fill in the template based on context and user's goals
|
|
142
|
+
- Write to the output path specified in instructions
|
|
143
|
+
- Show what was created and what's now unlocked
|
|
144
|
+
- STOP after creating ONE artifact
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
**If no artifacts are ready (all blocked)**:
|
|
149
|
+
- This shouldn't happen with a valid schema
|
|
150
|
+
- Show status and suggest checking for issues
|
|
151
|
+
|
|
152
|
+
4. **After creating an artifact, show progress**
|
|
153
|
+
\`\`\`bash
|
|
154
|
+
openspec status --change "<name>"
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
**Output**
|
|
158
|
+
|
|
159
|
+
After each invocation, show:
|
|
160
|
+
- Which artifact was created
|
|
161
|
+
- Schema workflow being used
|
|
162
|
+
- Current progress (N/M complete)
|
|
163
|
+
- What artifacts are now unlocked
|
|
164
|
+
- Prompt: "Want to continue? Just ask me to continue or tell me what to do next."
|
|
165
|
+
|
|
166
|
+
**Artifact Creation Guidelines**
|
|
167
|
+
|
|
168
|
+
The artifact types and their purpose depend on the schema. Use the \`instruction\` field from the instructions output to understand what to create.
|
|
169
|
+
|
|
170
|
+
Common artifact patterns:
|
|
171
|
+
|
|
172
|
+
**spec-driven schema** (proposal → specs → design → tasks):
|
|
173
|
+
- **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact.
|
|
174
|
+
- The Capabilities section is critical - each capability listed will need a spec file.
|
|
175
|
+
- **specs/*.md**: Create one spec per capability listed in the proposal.
|
|
176
|
+
- **design.md**: Document technical decisions, architecture, and implementation approach.
|
|
177
|
+
- **tasks.md**: Break down implementation into checkboxed tasks.
|
|
178
|
+
|
|
179
|
+
**tdd schema** (spec → tests → implementation → docs):
|
|
180
|
+
- **spec.md**: Feature specification defining what to build.
|
|
181
|
+
- **tests/*.test.ts**: Write tests BEFORE implementation (TDD red phase).
|
|
182
|
+
- **src/*.ts**: Implement to make tests pass (TDD green phase).
|
|
183
|
+
- **docs/*.md**: Document the implemented feature.
|
|
184
|
+
|
|
185
|
+
For other schemas, follow the \`instruction\` field from the CLI output.
|
|
186
|
+
|
|
187
|
+
**Guardrails**
|
|
188
|
+
- Create ONE artifact per invocation
|
|
189
|
+
- Always read dependency artifacts before creating a new one
|
|
190
|
+
- Never skip artifacts or create out of order
|
|
191
|
+
- If context is unclear, ask the user before creating
|
|
192
|
+
- Verify the artifact file exists after writing before marking progress
|
|
193
|
+
- Use the schema's artifact sequence, don't assume specific artifact names`
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Template for openspec-apply-change skill
|
|
198
|
+
* For implementing tasks from a completed (or in-progress) change
|
|
199
|
+
*/
|
|
200
|
+
export function getApplyChangeSkillTemplate() {
|
|
201
|
+
return {
|
|
202
|
+
name: 'openspec-apply-change',
|
|
203
|
+
description: 'Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.',
|
|
204
|
+
instructions: `Implement tasks from an OpenSpec change.
|
|
205
|
+
|
|
206
|
+
**Input**: Optionally specify a change name. If omitted, MUST prompt for available changes.
|
|
207
|
+
|
|
208
|
+
**Steps**
|
|
209
|
+
|
|
210
|
+
1. **If no change name provided, prompt for selection**
|
|
211
|
+
|
|
212
|
+
Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
213
|
+
|
|
214
|
+
Show changes that are implementation-ready (have tasks artifact).
|
|
215
|
+
Include the schema used for each change if available.
|
|
216
|
+
Mark changes with incomplete tasks as "(In Progress)".
|
|
217
|
+
|
|
218
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
219
|
+
|
|
220
|
+
2. **Check status to understand the schema**
|
|
221
|
+
\`\`\`bash
|
|
222
|
+
openspec status --change "<name>" --json
|
|
223
|
+
\`\`\`
|
|
224
|
+
Parse the JSON to understand:
|
|
225
|
+
- \`schemaName\`: The workflow being used (e.g., "spec-driven", "tdd")
|
|
226
|
+
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
|
227
|
+
|
|
228
|
+
3. **Get apply instructions**
|
|
229
|
+
|
|
230
|
+
\`\`\`bash
|
|
231
|
+
openspec instructions apply --change "<name>" --json
|
|
232
|
+
\`\`\`
|
|
233
|
+
|
|
234
|
+
This returns:
|
|
235
|
+
- Context file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
|
|
236
|
+
- Progress (total, complete, remaining)
|
|
237
|
+
- Task list with status
|
|
238
|
+
- Dynamic instruction based on current state
|
|
239
|
+
|
|
240
|
+
**Handle states:**
|
|
241
|
+
- If \`state: "blocked"\` (missing artifacts): show message, suggest using openspec-continue-change
|
|
242
|
+
- If \`state: "all_done"\`: congratulate, suggest archive
|
|
243
|
+
- Otherwise: proceed to implementation
|
|
244
|
+
|
|
245
|
+
4. **Read context files**
|
|
246
|
+
|
|
247
|
+
Read the files listed in \`contextFiles\` from the apply instructions output.
|
|
248
|
+
The files depend on the schema being used:
|
|
249
|
+
- **spec-driven**: proposal, specs, design, tasks
|
|
250
|
+
- **tdd**: spec, tests, implementation, docs
|
|
251
|
+
- Other schemas: follow the contextFiles from CLI output
|
|
252
|
+
|
|
253
|
+
5. **Show current progress**
|
|
254
|
+
|
|
255
|
+
Display:
|
|
256
|
+
- Schema being used
|
|
257
|
+
- Progress: "N/M tasks complete"
|
|
258
|
+
- Remaining tasks overview
|
|
259
|
+
- Dynamic instruction from CLI
|
|
260
|
+
|
|
261
|
+
6. **Implement tasks (loop until done or blocked)**
|
|
262
|
+
|
|
263
|
+
For each pending task:
|
|
264
|
+
- Show which task is being worked on
|
|
265
|
+
- Make the code changes required
|
|
266
|
+
- Keep changes minimal and focused
|
|
267
|
+
- Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
|
|
268
|
+
- Continue to next task
|
|
269
|
+
|
|
270
|
+
**Pause if:**
|
|
271
|
+
- Task is unclear → ask for clarification
|
|
272
|
+
- Implementation reveals a design issue → suggest updating artifacts
|
|
273
|
+
- Error or blocker encountered → report and wait for guidance
|
|
274
|
+
- User interrupts
|
|
275
|
+
|
|
276
|
+
7. **On completion or pause, show status**
|
|
277
|
+
|
|
278
|
+
Display:
|
|
279
|
+
- Tasks completed this session
|
|
280
|
+
- Overall progress: "N/M tasks complete"
|
|
281
|
+
- If all done: suggest archive
|
|
282
|
+
- If paused: explain why and wait for guidance
|
|
283
|
+
|
|
284
|
+
**Output During Implementation**
|
|
285
|
+
|
|
286
|
+
\`\`\`
|
|
287
|
+
## Implementing: <change-name> (schema: <schema-name>)
|
|
288
|
+
|
|
289
|
+
Working on task 3/7: <task description>
|
|
290
|
+
[...implementation happening...]
|
|
291
|
+
✓ Task complete
|
|
292
|
+
|
|
293
|
+
Working on task 4/7: <task description>
|
|
294
|
+
[...implementation happening...]
|
|
295
|
+
✓ Task complete
|
|
296
|
+
\`\`\`
|
|
297
|
+
|
|
298
|
+
**Output On Completion**
|
|
299
|
+
|
|
300
|
+
\`\`\`
|
|
301
|
+
## Implementation Complete
|
|
302
|
+
|
|
303
|
+
**Change:** <change-name>
|
|
304
|
+
**Schema:** <schema-name>
|
|
305
|
+
**Progress:** 7/7 tasks complete ✓
|
|
306
|
+
|
|
307
|
+
### Completed This Session
|
|
308
|
+
- [x] Task 1
|
|
309
|
+
- [x] Task 2
|
|
310
|
+
...
|
|
311
|
+
|
|
312
|
+
All tasks complete! Ready to archive this change.
|
|
313
|
+
\`\`\`
|
|
314
|
+
|
|
315
|
+
**Output On Pause (Issue Encountered)**
|
|
316
|
+
|
|
317
|
+
\`\`\`
|
|
318
|
+
## Implementation Paused
|
|
319
|
+
|
|
320
|
+
**Change:** <change-name>
|
|
321
|
+
**Schema:** <schema-name>
|
|
322
|
+
**Progress:** 4/7 tasks complete
|
|
323
|
+
|
|
324
|
+
### Issue Encountered
|
|
325
|
+
<description of the issue>
|
|
326
|
+
|
|
327
|
+
**Options:**
|
|
328
|
+
1. <option 1>
|
|
329
|
+
2. <option 2>
|
|
330
|
+
3. Other approach
|
|
331
|
+
|
|
332
|
+
What would you like to do?
|
|
333
|
+
\`\`\`
|
|
334
|
+
|
|
335
|
+
**Guardrails**
|
|
336
|
+
- Keep going through tasks until done or blocked
|
|
337
|
+
- Always read context files before starting (from the apply instructions output)
|
|
338
|
+
- If task is ambiguous, pause and ask before implementing
|
|
339
|
+
- If implementation reveals issues, pause and suggest artifact updates
|
|
340
|
+
- Keep code changes minimal and scoped to each task
|
|
341
|
+
- Update task checkbox immediately after completing each task
|
|
342
|
+
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
343
|
+
- Use contextFiles from CLI output, don't assume specific file names
|
|
344
|
+
|
|
345
|
+
**Fluid Workflow Integration**
|
|
346
|
+
|
|
347
|
+
This skill supports the "actions on a change" model:
|
|
348
|
+
|
|
349
|
+
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
|
350
|
+
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly`
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Template for openspec-ff-change skill
|
|
355
|
+
* Fast-forward through artifact creation
|
|
356
|
+
*/
|
|
357
|
+
export function getFfChangeSkillTemplate() {
|
|
358
|
+
return {
|
|
359
|
+
name: 'openspec-ff-change',
|
|
360
|
+
description: 'Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.',
|
|
361
|
+
instructions: `Fast-forward through artifact creation - generate everything needed to start implementation in one go.
|
|
362
|
+
|
|
363
|
+
**Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
|
|
364
|
+
|
|
365
|
+
**Steps**
|
|
366
|
+
|
|
367
|
+
1. **If no clear input provided, ask what they want to build**
|
|
368
|
+
|
|
369
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
370
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
371
|
+
|
|
372
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
|
|
373
|
+
|
|
374
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
375
|
+
|
|
376
|
+
2. **Create the change directory**
|
|
377
|
+
\`\`\`bash
|
|
378
|
+
openspec new change "<name>"
|
|
379
|
+
\`\`\`
|
|
380
|
+
This creates a scaffolded change at \`openspec/changes/<name>/\`.
|
|
381
|
+
|
|
382
|
+
3. **Get the artifact build order**
|
|
383
|
+
\`\`\`bash
|
|
384
|
+
openspec status --change "<name>" --json
|
|
385
|
+
\`\`\`
|
|
386
|
+
Parse the JSON to get:
|
|
387
|
+
- \`applyRequires\`: array of artifact IDs needed before implementation (e.g., \`["tasks"]\`)
|
|
388
|
+
- \`artifacts\`: list of all artifacts with their status and dependencies
|
|
389
|
+
|
|
390
|
+
4. **Create artifacts in sequence until apply-ready**
|
|
391
|
+
|
|
392
|
+
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
393
|
+
|
|
394
|
+
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
395
|
+
|
|
396
|
+
a. **For each artifact that is \`ready\` (dependencies satisfied)**:
|
|
397
|
+
- Get instructions:
|
|
398
|
+
\`\`\`bash
|
|
399
|
+
openspec instructions <artifact-id> --change "<name>" --json
|
|
400
|
+
\`\`\`
|
|
401
|
+
- The instructions JSON includes:
|
|
402
|
+
- \`template\`: The template content to use
|
|
403
|
+
- \`instruction\`: Schema-specific guidance for this artifact type
|
|
404
|
+
- \`outputPath\`: Where to write the artifact
|
|
405
|
+
- \`dependencies\`: Completed artifacts to read for context
|
|
406
|
+
- Read any completed dependency files for context
|
|
407
|
+
- Create the artifact file following the schema's \`instruction\`
|
|
408
|
+
- Show brief progress: "✓ Created <artifact-id>"
|
|
409
|
+
|
|
410
|
+
b. **Continue until all \`applyRequires\` artifacts are complete**
|
|
411
|
+
- After creating each artifact, re-run \`openspec status --change "<name>" --json\`
|
|
412
|
+
- Check if every artifact ID in \`applyRequires\` has \`status: "done"\` in the artifacts array
|
|
413
|
+
- Stop when all \`applyRequires\` artifacts are done
|
|
414
|
+
|
|
415
|
+
c. **If an artifact requires user input** (unclear context):
|
|
416
|
+
- Use **AskUserQuestion tool** to clarify
|
|
417
|
+
- Then continue with creation
|
|
418
|
+
|
|
419
|
+
5. **Show final status**
|
|
420
|
+
\`\`\`bash
|
|
421
|
+
openspec status --change "<name>"
|
|
422
|
+
\`\`\`
|
|
423
|
+
|
|
424
|
+
**Output**
|
|
425
|
+
|
|
426
|
+
After completing all artifacts, summarize:
|
|
427
|
+
- Change name and location
|
|
428
|
+
- List of artifacts created with brief descriptions
|
|
429
|
+
- What's ready: "All artifacts created! Ready for implementation."
|
|
430
|
+
- Prompt: "Run \`/opsx:apply\` or ask me to implement to start working on the tasks."
|
|
431
|
+
|
|
432
|
+
**Artifact Creation Guidelines**
|
|
433
|
+
|
|
434
|
+
- Follow the \`instruction\` field from \`openspec instructions\` for each artifact type
|
|
435
|
+
- The schema defines what each artifact should contain - follow it
|
|
436
|
+
- Read dependency artifacts for context before creating new ones
|
|
437
|
+
- Use the \`template\` as a starting point, filling in based on context
|
|
438
|
+
|
|
439
|
+
**Guardrails**
|
|
440
|
+
- Create ALL artifacts needed for implementation (as defined by schema's \`apply.requires\`)
|
|
441
|
+
- Always read dependency artifacts before creating a new one
|
|
442
|
+
- If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
|
|
443
|
+
- If a change with that name already exists, suggest continuing that change instead
|
|
444
|
+
- Verify each artifact file exists after writing before proceeding to next`
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Template for openspec-sync-specs skill
|
|
449
|
+
* For syncing delta specs from a change to main specs (agent-driven)
|
|
450
|
+
*/
|
|
451
|
+
export function getSyncSpecsSkillTemplate() {
|
|
452
|
+
return {
|
|
453
|
+
name: 'openspec-sync-specs',
|
|
454
|
+
description: 'Sync delta specs from a change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change.',
|
|
455
|
+
instructions: `Sync delta specs from a change to main specs.
|
|
456
|
+
|
|
457
|
+
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
|
|
458
|
+
|
|
459
|
+
**Input**: Optionally specify a change name. If omitted, MUST prompt for available changes.
|
|
460
|
+
|
|
461
|
+
**Steps**
|
|
462
|
+
|
|
463
|
+
1. **If no change name provided, prompt for selection**
|
|
464
|
+
|
|
465
|
+
Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
466
|
+
|
|
467
|
+
Show changes that have delta specs (under \`specs/\` directory).
|
|
468
|
+
|
|
469
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
470
|
+
|
|
471
|
+
2. **Find delta specs**
|
|
472
|
+
|
|
473
|
+
Look for delta spec files in \`openspec/changes/<name>/specs/*/spec.md\`.
|
|
474
|
+
|
|
475
|
+
Each delta spec file contains sections like:
|
|
476
|
+
- \`## ADDED Requirements\` - New requirements to add
|
|
477
|
+
- \`## MODIFIED Requirements\` - Changes to existing requirements
|
|
478
|
+
- \`## REMOVED Requirements\` - Requirements to remove
|
|
479
|
+
- \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
|
|
480
|
+
|
|
481
|
+
If no delta specs found, inform user and stop.
|
|
482
|
+
|
|
483
|
+
3. **For each delta spec, apply changes to main specs**
|
|
484
|
+
|
|
485
|
+
For each capability with a delta spec at \`openspec/changes/<name>/specs/<capability>/spec.md\`:
|
|
486
|
+
|
|
487
|
+
a. **Read the delta spec** to understand the intended changes
|
|
488
|
+
|
|
489
|
+
b. **Read the main spec** at \`openspec/specs/<capability>/spec.md\` (may not exist yet)
|
|
490
|
+
|
|
491
|
+
c. **Apply changes intelligently**:
|
|
492
|
+
|
|
493
|
+
**ADDED Requirements:**
|
|
494
|
+
- If requirement doesn't exist in main spec → add it
|
|
495
|
+
- If requirement already exists → update it to match (treat as implicit MODIFIED)
|
|
496
|
+
|
|
497
|
+
**MODIFIED Requirements:**
|
|
498
|
+
- Find the requirement in main spec
|
|
499
|
+
- Apply the changes - this can be:
|
|
500
|
+
- Adding new scenarios (don't need to copy existing ones)
|
|
501
|
+
- Modifying existing scenarios
|
|
502
|
+
- Changing the requirement description
|
|
503
|
+
- Preserve scenarios/content not mentioned in the delta
|
|
504
|
+
|
|
505
|
+
**REMOVED Requirements:**
|
|
506
|
+
- Remove the entire requirement block from main spec
|
|
507
|
+
|
|
508
|
+
**RENAMED Requirements:**
|
|
509
|
+
- Find the FROM requirement, rename to TO
|
|
510
|
+
|
|
511
|
+
d. **Create new main spec** if capability doesn't exist yet:
|
|
512
|
+
- Create \`openspec/specs/<capability>/spec.md\`
|
|
513
|
+
- Add Purpose section (can be brief, mark as TBD)
|
|
514
|
+
- Add Requirements section with the ADDED requirements
|
|
515
|
+
|
|
516
|
+
4. **Show summary**
|
|
517
|
+
|
|
518
|
+
After applying all changes, summarize:
|
|
519
|
+
- Which capabilities were updated
|
|
520
|
+
- What changes were made (requirements added/modified/removed/renamed)
|
|
521
|
+
|
|
522
|
+
**Delta Spec Format Reference**
|
|
523
|
+
|
|
524
|
+
\`\`\`markdown
|
|
525
|
+
## ADDED Requirements
|
|
526
|
+
|
|
527
|
+
### Requirement: New Feature
|
|
528
|
+
The system SHALL do something new.
|
|
529
|
+
|
|
530
|
+
#### Scenario: Basic case
|
|
531
|
+
- **WHEN** user does X
|
|
532
|
+
- **THEN** system does Y
|
|
533
|
+
|
|
534
|
+
## MODIFIED Requirements
|
|
535
|
+
|
|
536
|
+
### Requirement: Existing Feature
|
|
537
|
+
#### Scenario: New scenario to add
|
|
538
|
+
- **WHEN** user does A
|
|
539
|
+
- **THEN** system does B
|
|
540
|
+
|
|
541
|
+
## REMOVED Requirements
|
|
542
|
+
|
|
543
|
+
### Requirement: Deprecated Feature
|
|
544
|
+
|
|
545
|
+
## RENAMED Requirements
|
|
546
|
+
|
|
547
|
+
- FROM: \`### Requirement: Old Name\`
|
|
548
|
+
- TO: \`### Requirement: New Name\`
|
|
549
|
+
\`\`\`
|
|
550
|
+
|
|
551
|
+
**Key Principle: Intelligent Merging**
|
|
552
|
+
|
|
553
|
+
Unlike programmatic merging, you can apply **partial updates**:
|
|
554
|
+
- To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios
|
|
555
|
+
- The delta represents *intent*, not a wholesale replacement
|
|
556
|
+
- Use your judgment to merge changes sensibly
|
|
557
|
+
|
|
558
|
+
**Output On Success**
|
|
559
|
+
|
|
560
|
+
\`\`\`
|
|
561
|
+
## Specs Synced: <change-name>
|
|
562
|
+
|
|
563
|
+
Updated main specs:
|
|
564
|
+
|
|
565
|
+
**<capability-1>**:
|
|
566
|
+
- Added requirement: "New Feature"
|
|
567
|
+
- Modified requirement: "Existing Feature" (added 1 scenario)
|
|
568
|
+
|
|
569
|
+
**<capability-2>**:
|
|
570
|
+
- Created new spec file
|
|
571
|
+
- Added requirement: "Another Feature"
|
|
572
|
+
|
|
573
|
+
Main specs are now updated. The change remains active - archive when implementation is complete.
|
|
574
|
+
\`\`\`
|
|
575
|
+
|
|
576
|
+
**Guardrails**
|
|
577
|
+
- Read both delta and main specs before making changes
|
|
578
|
+
- Preserve existing content not mentioned in delta
|
|
579
|
+
- If something is unclear, ask for clarification
|
|
580
|
+
- Show what you're changing as you go
|
|
581
|
+
- The operation should be idempotent - running twice should give same result`
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Template for /opsx:new slash command
|
|
586
|
+
*/
|
|
587
|
+
export function getOpsxNewCommandTemplate() {
|
|
588
|
+
return {
|
|
589
|
+
name: 'OPSX: New',
|
|
590
|
+
description: 'Start a new change using the experimental artifact workflow (OPSX)',
|
|
591
|
+
category: 'Workflow',
|
|
592
|
+
tags: ['workflow', 'artifacts', 'experimental'],
|
|
593
|
+
content: `Start a new change using the experimental artifact-driven approach.
|
|
594
|
+
|
|
595
|
+
**Input**: The argument after \`/opsx:new\` is the change name (kebab-case), OR a description of what the user wants to build.
|
|
596
|
+
|
|
597
|
+
**Steps**
|
|
598
|
+
|
|
599
|
+
1. **If no input provided, ask what they want to build**
|
|
600
|
+
|
|
601
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
602
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
603
|
+
|
|
604
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
|
|
605
|
+
|
|
606
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
607
|
+
|
|
608
|
+
2. **Select a workflow schema**
|
|
609
|
+
|
|
610
|
+
Run \`openspec schemas --json\` to get available schemas with descriptions.
|
|
611
|
+
|
|
612
|
+
Use the **AskUserQuestion tool** to let the user choose a workflow:
|
|
613
|
+
- Present each schema with its description
|
|
614
|
+
- Mark \`spec-driven\` as "(default)" if it's available
|
|
615
|
+
- Example options: "spec-driven - proposal → specs → design → tasks (default)", "tdd - tests → implementation → docs"
|
|
616
|
+
|
|
617
|
+
If user doesn't have a preference, default to \`spec-driven\`.
|
|
618
|
+
|
|
619
|
+
3. **Create the change directory**
|
|
620
|
+
\`\`\`bash
|
|
621
|
+
openspec new change "<name>" --schema "<selected-schema>"
|
|
622
|
+
\`\`\`
|
|
623
|
+
This creates a scaffolded change at \`openspec/changes/<name>/\` with the selected schema.
|
|
624
|
+
|
|
625
|
+
4. **Show the artifact status**
|
|
626
|
+
\`\`\`bash
|
|
627
|
+
openspec status --change "<name>"
|
|
628
|
+
\`\`\`
|
|
629
|
+
This shows which artifacts need to be created and which are ready (dependencies satisfied).
|
|
630
|
+
|
|
631
|
+
5. **Get instructions for the first artifact**
|
|
632
|
+
The first artifact depends on the schema. Check the status output to find the first artifact with status "ready".
|
|
633
|
+
\`\`\`bash
|
|
634
|
+
openspec instructions <first-artifact-id> --change "<name>"
|
|
635
|
+
\`\`\`
|
|
636
|
+
This outputs the template and context for creating the first artifact.
|
|
637
|
+
|
|
638
|
+
6. **STOP and wait for user direction**
|
|
639
|
+
|
|
640
|
+
**Output**
|
|
641
|
+
|
|
642
|
+
After completing the steps, summarize:
|
|
643
|
+
- Change name and location
|
|
644
|
+
- Selected schema/workflow and its artifact sequence
|
|
645
|
+
- Current status (0/N artifacts complete)
|
|
646
|
+
- The template for the first artifact
|
|
647
|
+
- Prompt: "Ready to create the first artifact? Run \`/opsx:continue\` or just describe what this change is about and I'll draft it."
|
|
648
|
+
|
|
649
|
+
**Guardrails**
|
|
650
|
+
- Do NOT create any artifacts yet - just show the instructions
|
|
651
|
+
- Do NOT advance beyond showing the first artifact template
|
|
652
|
+
- If the name is invalid (not kebab-case), ask for a valid name
|
|
653
|
+
- If a change with that name already exists, suggest using \`/opsx:continue\` instead
|
|
654
|
+
- Always pass --schema to preserve the user's workflow choice`
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Template for /opsx:continue slash command
|
|
659
|
+
*/
|
|
660
|
+
export function getOpsxContinueCommandTemplate() {
|
|
661
|
+
return {
|
|
662
|
+
name: 'OPSX: Continue',
|
|
663
|
+
description: 'Continue working on a change - create the next artifact (Experimental)',
|
|
664
|
+
category: 'Workflow',
|
|
665
|
+
tags: ['workflow', 'artifacts', 'experimental'],
|
|
666
|
+
content: `Continue working on a change by creating the next artifact.
|
|
667
|
+
|
|
668
|
+
**Input**: Optionally specify \`--change <name>\` after \`/opsx:continue\`. If omitted, MUST prompt for available changes.
|
|
669
|
+
|
|
670
|
+
**Steps**
|
|
671
|
+
|
|
672
|
+
1. **If no change name provided, prompt for selection**
|
|
673
|
+
|
|
674
|
+
Run \`openspec list --json\` to get available changes sorted by most recently modified. Then use the **AskUserQuestion tool** to let the user select which change to work on.
|
|
675
|
+
|
|
676
|
+
Present the top 3-4 most recently modified changes as options, showing:
|
|
677
|
+
- Change name
|
|
678
|
+
- Schema (from \`schema\` field if present, otherwise "spec-driven")
|
|
679
|
+
- Status (e.g., "0/5 tasks", "complete", "no tasks")
|
|
680
|
+
- How recently it was modified (from \`lastModified\` field)
|
|
681
|
+
|
|
682
|
+
Mark the most recently modified change as "(Recommended)" since it's likely what the user wants to continue.
|
|
683
|
+
|
|
684
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
685
|
+
|
|
686
|
+
2. **Check current status**
|
|
687
|
+
\`\`\`bash
|
|
688
|
+
openspec status --change "<name>" --json
|
|
689
|
+
\`\`\`
|
|
690
|
+
Parse the JSON to understand current state. The response includes:
|
|
691
|
+
- \`schemaName\`: The workflow schema being used (e.g., "spec-driven", "tdd")
|
|
692
|
+
- \`artifacts\`: Array of artifacts with their status ("done", "ready", "blocked")
|
|
693
|
+
- \`isComplete\`: Boolean indicating if all artifacts are complete
|
|
694
|
+
|
|
695
|
+
3. **Act based on status**:
|
|
696
|
+
|
|
697
|
+
---
|
|
698
|
+
|
|
699
|
+
**If all artifacts are complete (\`isComplete: true\`)**:
|
|
700
|
+
- Congratulate the user
|
|
701
|
+
- Show final status including the schema used
|
|
702
|
+
- Suggest: "All artifacts created! You can now implement this change or archive it."
|
|
703
|
+
- STOP
|
|
704
|
+
|
|
705
|
+
---
|
|
706
|
+
|
|
707
|
+
**If artifacts are ready to create** (status shows artifacts with \`status: "ready"\`):
|
|
708
|
+
- Pick the FIRST artifact with \`status: "ready"\` from the status output
|
|
709
|
+
- Get its instructions:
|
|
710
|
+
\`\`\`bash
|
|
711
|
+
openspec instructions <artifact-id> --change "<name>" --json
|
|
712
|
+
\`\`\`
|
|
713
|
+
- Parse the JSON to get template, dependencies, and what it unlocks
|
|
714
|
+
- **Create the artifact file** using the template as a starting point:
|
|
715
|
+
- Read any completed dependency files for context
|
|
716
|
+
- Fill in the template based on context and user's goals
|
|
717
|
+
- Write to the output path specified in instructions
|
|
718
|
+
- Show what was created and what's now unlocked
|
|
719
|
+
- STOP after creating ONE artifact
|
|
720
|
+
|
|
721
|
+
---
|
|
722
|
+
|
|
723
|
+
**If no artifacts are ready (all blocked)**:
|
|
724
|
+
- This shouldn't happen with a valid schema
|
|
725
|
+
- Show status and suggest checking for issues
|
|
726
|
+
|
|
727
|
+
4. **After creating an artifact, show progress**
|
|
728
|
+
\`\`\`bash
|
|
729
|
+
openspec status --change "<name>"
|
|
730
|
+
\`\`\`
|
|
731
|
+
|
|
732
|
+
**Output**
|
|
733
|
+
|
|
734
|
+
After each invocation, show:
|
|
735
|
+
- Which artifact was created
|
|
736
|
+
- Schema workflow being used
|
|
737
|
+
- Current progress (N/M complete)
|
|
738
|
+
- What artifacts are now unlocked
|
|
739
|
+
- Prompt: "Run \`/opsx:continue\` to create the next artifact"
|
|
740
|
+
|
|
741
|
+
**Artifact Creation Guidelines**
|
|
742
|
+
|
|
743
|
+
The artifact types and their purpose depend on the schema. Use the \`instruction\` field from the instructions output to understand what to create.
|
|
744
|
+
|
|
745
|
+
Common artifact patterns:
|
|
746
|
+
|
|
747
|
+
**spec-driven schema** (proposal → specs → design → tasks):
|
|
748
|
+
- **proposal.md**: Ask user about the change if not clear. Fill in Why, What Changes, Capabilities, Impact.
|
|
749
|
+
- The Capabilities section is critical - each capability listed will need a spec file.
|
|
750
|
+
- **specs/*.md**: Create one spec per capability listed in the proposal.
|
|
751
|
+
- **design.md**: Document technical decisions, architecture, and implementation approach.
|
|
752
|
+
- **tasks.md**: Break down implementation into checkboxed tasks.
|
|
753
|
+
|
|
754
|
+
**tdd schema** (spec → tests → implementation → docs):
|
|
755
|
+
- **spec.md**: Feature specification defining what to build.
|
|
756
|
+
- **tests/*.test.ts**: Write tests BEFORE implementation (TDD red phase).
|
|
757
|
+
- **src/*.ts**: Implement to make tests pass (TDD green phase).
|
|
758
|
+
- **docs/*.md**: Document the implemented feature.
|
|
759
|
+
|
|
760
|
+
For other schemas, follow the \`instruction\` field from the CLI output.
|
|
761
|
+
|
|
762
|
+
**Guardrails**
|
|
763
|
+
- Create ONE artifact per invocation
|
|
764
|
+
- Always read dependency artifacts before creating a new one
|
|
765
|
+
- Never skip artifacts or create out of order
|
|
766
|
+
- If context is unclear, ask the user before creating
|
|
767
|
+
- Verify the artifact file exists after writing before marking progress
|
|
768
|
+
- Use the schema's artifact sequence, don't assume specific artifact names`
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Template for /opsx:apply slash command
|
|
773
|
+
*/
|
|
774
|
+
export function getOpsxApplyCommandTemplate() {
|
|
775
|
+
return {
|
|
776
|
+
name: 'OPSX: Apply',
|
|
777
|
+
description: 'Implement tasks from an OpenSpec change (Experimental)',
|
|
778
|
+
category: 'Workflow',
|
|
779
|
+
tags: ['workflow', 'artifacts', 'experimental'],
|
|
780
|
+
content: `Implement tasks from an OpenSpec change.
|
|
781
|
+
|
|
782
|
+
**Input**: Optionally specify \`--change <name>\` after \`/opsx:apply\`. If omitted, MUST prompt for available changes.
|
|
783
|
+
|
|
784
|
+
**Steps**
|
|
785
|
+
|
|
786
|
+
1. **If no change name provided, prompt for selection**
|
|
787
|
+
|
|
788
|
+
Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
789
|
+
|
|
790
|
+
Show changes that are implementation-ready (have tasks artifact).
|
|
791
|
+
Include the schema used for each change if available.
|
|
792
|
+
Mark changes with incomplete tasks as "(In Progress)".
|
|
793
|
+
|
|
794
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
795
|
+
|
|
796
|
+
2. **Check status to understand the schema**
|
|
797
|
+
\`\`\`bash
|
|
798
|
+
openspec status --change "<name>" --json
|
|
799
|
+
\`\`\`
|
|
800
|
+
Parse the JSON to understand:
|
|
801
|
+
- \`schemaName\`: The workflow being used (e.g., "spec-driven", "tdd")
|
|
802
|
+
- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
|
|
803
|
+
|
|
804
|
+
3. **Get apply instructions**
|
|
805
|
+
|
|
806
|
+
\`\`\`bash
|
|
807
|
+
openspec instructions apply --change "<name>" --json
|
|
808
|
+
\`\`\`
|
|
809
|
+
|
|
810
|
+
This returns:
|
|
811
|
+
- Context file paths (varies by schema)
|
|
812
|
+
- Progress (total, complete, remaining)
|
|
813
|
+
- Task list with status
|
|
814
|
+
- Dynamic instruction based on current state
|
|
815
|
+
|
|
816
|
+
**Handle states:**
|
|
817
|
+
- If \`state: "blocked"\` (missing artifacts): show message, suggest using \`/opsx:continue\`
|
|
818
|
+
- If \`state: "all_done"\`: congratulate, suggest archive
|
|
819
|
+
- Otherwise: proceed to implementation
|
|
820
|
+
|
|
821
|
+
4. **Read context files**
|
|
822
|
+
|
|
823
|
+
Read the files listed in \`contextFiles\` from the apply instructions output.
|
|
824
|
+
The files depend on the schema being used:
|
|
825
|
+
- **spec-driven**: proposal, specs, design, tasks
|
|
826
|
+
- **tdd**: spec, tests, implementation, docs
|
|
827
|
+
- Other schemas: follow the contextFiles from CLI output
|
|
828
|
+
|
|
829
|
+
5. **Show current progress**
|
|
830
|
+
|
|
831
|
+
Display:
|
|
832
|
+
- Schema being used
|
|
833
|
+
- Progress: "N/M tasks complete"
|
|
834
|
+
- Remaining tasks overview
|
|
835
|
+
- Dynamic instruction from CLI
|
|
836
|
+
|
|
837
|
+
6. **Implement tasks (loop until done or blocked)**
|
|
838
|
+
|
|
839
|
+
For each pending task:
|
|
840
|
+
- Show which task is being worked on
|
|
841
|
+
- Make the code changes required
|
|
842
|
+
- Keep changes minimal and focused
|
|
843
|
+
- Mark task complete in the tasks file: \`- [ ]\` → \`- [x]\`
|
|
844
|
+
- Continue to next task
|
|
845
|
+
|
|
846
|
+
**Pause if:**
|
|
847
|
+
- Task is unclear → ask for clarification
|
|
848
|
+
- Implementation reveals a design issue → suggest updating artifacts
|
|
849
|
+
- Error or blocker encountered → report and wait for guidance
|
|
850
|
+
- User interrupts
|
|
851
|
+
|
|
852
|
+
7. **On completion or pause, show status**
|
|
853
|
+
|
|
854
|
+
Display:
|
|
855
|
+
- Tasks completed this session
|
|
856
|
+
- Overall progress: "N/M tasks complete"
|
|
857
|
+
- If all done: suggest archive
|
|
858
|
+
- If paused: explain why and wait for guidance
|
|
859
|
+
|
|
860
|
+
**Output During Implementation**
|
|
861
|
+
|
|
862
|
+
\`\`\`
|
|
863
|
+
## Implementing: <change-name> (schema: <schema-name>)
|
|
864
|
+
|
|
865
|
+
Working on task 3/7: <task description>
|
|
866
|
+
[...implementation happening...]
|
|
867
|
+
✓ Task complete
|
|
868
|
+
|
|
869
|
+
Working on task 4/7: <task description>
|
|
870
|
+
[...implementation happening...]
|
|
871
|
+
✓ Task complete
|
|
872
|
+
\`\`\`
|
|
873
|
+
|
|
874
|
+
**Output On Completion**
|
|
875
|
+
|
|
876
|
+
\`\`\`
|
|
877
|
+
## Implementation Complete
|
|
878
|
+
|
|
879
|
+
**Change:** <change-name>
|
|
880
|
+
**Schema:** <schema-name>
|
|
881
|
+
**Progress:** 7/7 tasks complete ✓
|
|
882
|
+
|
|
883
|
+
### Completed This Session
|
|
884
|
+
- [x] Task 1
|
|
885
|
+
- [x] Task 2
|
|
886
|
+
...
|
|
887
|
+
|
|
888
|
+
All tasks complete! Ready to archive this change.
|
|
889
|
+
\`\`\`
|
|
890
|
+
|
|
891
|
+
**Output On Pause (Issue Encountered)**
|
|
892
|
+
|
|
893
|
+
\`\`\`
|
|
894
|
+
## Implementation Paused
|
|
895
|
+
|
|
896
|
+
**Change:** <change-name>
|
|
897
|
+
**Schema:** <schema-name>
|
|
898
|
+
**Progress:** 4/7 tasks complete
|
|
899
|
+
|
|
900
|
+
### Issue Encountered
|
|
901
|
+
<description of the issue>
|
|
902
|
+
|
|
903
|
+
**Options:**
|
|
904
|
+
1. <option 1>
|
|
905
|
+
2. <option 2>
|
|
906
|
+
3. Other approach
|
|
907
|
+
|
|
908
|
+
What would you like to do?
|
|
909
|
+
\`\`\`
|
|
910
|
+
|
|
911
|
+
**Guardrails**
|
|
912
|
+
- Keep going through tasks until done or blocked
|
|
913
|
+
- Always read context files before starting (from the apply instructions output)
|
|
914
|
+
- If task is ambiguous, pause and ask before implementing
|
|
915
|
+
- If implementation reveals issues, pause and suggest artifact updates
|
|
916
|
+
- Keep code changes minimal and scoped to each task
|
|
917
|
+
- Update task checkbox immediately after completing each task
|
|
918
|
+
- Pause on errors, blockers, or unclear requirements - don't guess
|
|
919
|
+
- Use contextFiles from CLI output, don't assume specific file names
|
|
920
|
+
|
|
921
|
+
**Fluid Workflow Integration**
|
|
922
|
+
|
|
923
|
+
This skill supports the "actions on a change" model:
|
|
924
|
+
|
|
925
|
+
- **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
|
|
926
|
+
- **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly`
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Template for /opsx:ff slash command
|
|
931
|
+
*/
|
|
932
|
+
export function getOpsxFfCommandTemplate() {
|
|
933
|
+
return {
|
|
934
|
+
name: 'OPSX: Fast Forward',
|
|
935
|
+
description: 'Create a change and generate all artifacts needed for implementation in one go',
|
|
936
|
+
category: 'Workflow',
|
|
937
|
+
tags: ['workflow', 'artifacts', 'experimental'],
|
|
938
|
+
content: `Fast-forward through artifact creation - generate everything needed to start implementation.
|
|
939
|
+
|
|
940
|
+
**Input**: The argument after \`/opsx:ff\` is the change name (kebab-case), OR a description of what the user wants to build.
|
|
941
|
+
|
|
942
|
+
**Steps**
|
|
943
|
+
|
|
944
|
+
1. **If no input provided, ask what they want to build**
|
|
945
|
+
|
|
946
|
+
Use the **AskUserQuestion tool** (open-ended, no preset options) to ask:
|
|
947
|
+
> "What change do you want to work on? Describe what you want to build or fix."
|
|
948
|
+
|
|
949
|
+
From their description, derive a kebab-case name (e.g., "add user authentication" → \`add-user-auth\`).
|
|
950
|
+
|
|
951
|
+
**IMPORTANT**: Do NOT proceed without understanding what the user wants to build.
|
|
952
|
+
|
|
953
|
+
2. **Create the change directory**
|
|
954
|
+
\`\`\`bash
|
|
955
|
+
openspec new change "<name>"
|
|
956
|
+
\`\`\`
|
|
957
|
+
This creates a scaffolded change at \`openspec/changes/<name>/\`.
|
|
958
|
+
|
|
959
|
+
3. **Get the artifact build order**
|
|
960
|
+
\`\`\`bash
|
|
961
|
+
openspec status --change "<name>" --json
|
|
962
|
+
\`\`\`
|
|
963
|
+
Parse the JSON to get:
|
|
964
|
+
- \`applyRequires\`: array of artifact IDs needed before implementation (e.g., \`["tasks"]\`)
|
|
965
|
+
- \`artifacts\`: list of all artifacts with their status and dependencies
|
|
966
|
+
|
|
967
|
+
4. **Create artifacts in sequence until apply-ready**
|
|
968
|
+
|
|
969
|
+
Use the **TodoWrite tool** to track progress through the artifacts.
|
|
970
|
+
|
|
971
|
+
Loop through artifacts in dependency order (artifacts with no pending dependencies first):
|
|
972
|
+
|
|
973
|
+
a. **For each artifact that is \`ready\` (dependencies satisfied)**:
|
|
974
|
+
- Get instructions:
|
|
975
|
+
\`\`\`bash
|
|
976
|
+
openspec instructions <artifact-id> --change "<name>" --json
|
|
977
|
+
\`\`\`
|
|
978
|
+
- The instructions JSON includes:
|
|
979
|
+
- \`template\`: The template content to use
|
|
980
|
+
- \`instruction\`: Schema-specific guidance for this artifact type
|
|
981
|
+
- \`outputPath\`: Where to write the artifact
|
|
982
|
+
- \`dependencies\`: Completed artifacts to read for context
|
|
983
|
+
- Read any completed dependency files for context
|
|
984
|
+
- Create the artifact file following the schema's \`instruction\`
|
|
985
|
+
- Show brief progress: "✓ Created <artifact-id>"
|
|
986
|
+
|
|
987
|
+
b. **Continue until all \`applyRequires\` artifacts are complete**
|
|
988
|
+
- After creating each artifact, re-run \`openspec status --change "<name>" --json\`
|
|
989
|
+
- Check if every artifact ID in \`applyRequires\` has \`status: "done"\` in the artifacts array
|
|
990
|
+
- Stop when all \`applyRequires\` artifacts are done
|
|
991
|
+
|
|
992
|
+
c. **If an artifact requires user input** (unclear context):
|
|
993
|
+
- Use **AskUserQuestion tool** to clarify
|
|
994
|
+
- Then continue with creation
|
|
995
|
+
|
|
996
|
+
5. **Show final status**
|
|
997
|
+
\`\`\`bash
|
|
998
|
+
openspec status --change "<name>"
|
|
999
|
+
\`\`\`
|
|
1000
|
+
|
|
1001
|
+
**Output**
|
|
1002
|
+
|
|
1003
|
+
After completing all artifacts, summarize:
|
|
1004
|
+
- Change name and location
|
|
1005
|
+
- List of artifacts created with brief descriptions
|
|
1006
|
+
- What's ready: "All artifacts created! Ready for implementation."
|
|
1007
|
+
- Prompt: "Run \`/opsx:apply\` to start implementing."
|
|
1008
|
+
|
|
1009
|
+
**Artifact Creation Guidelines**
|
|
1010
|
+
|
|
1011
|
+
- Follow the \`instruction\` field from \`openspec instructions\` for each artifact type
|
|
1012
|
+
- The schema defines what each artifact should contain - follow it
|
|
1013
|
+
- Read dependency artifacts for context before creating new ones
|
|
1014
|
+
- Use the \`template\` as a starting point, filling in based on context
|
|
1015
|
+
|
|
1016
|
+
**Guardrails**
|
|
1017
|
+
- Create ALL artifacts needed for implementation (as defined by schema's \`apply.requires\`)
|
|
1018
|
+
- Always read dependency artifacts before creating a new one
|
|
1019
|
+
- If context is critically unclear, ask the user - but prefer making reasonable decisions to keep momentum
|
|
1020
|
+
- If a change with that name already exists, ask if user wants to continue it or create a new one
|
|
1021
|
+
- Verify each artifact file exists after writing before proceeding to next`
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Template for openspec-archive-change skill
|
|
1026
|
+
* For archiving completed changes in the experimental workflow
|
|
1027
|
+
*/
|
|
1028
|
+
export function getArchiveChangeSkillTemplate() {
|
|
1029
|
+
return {
|
|
1030
|
+
name: 'openspec-archive-change',
|
|
1031
|
+
description: 'Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.',
|
|
1032
|
+
instructions: `Archive a completed change in the experimental workflow.
|
|
1033
|
+
|
|
1034
|
+
**Input**: Optionally specify a change name. If omitted, MUST prompt for available changes.
|
|
1035
|
+
|
|
1036
|
+
**Steps**
|
|
1037
|
+
|
|
1038
|
+
1. **If no change name provided, prompt for selection**
|
|
1039
|
+
|
|
1040
|
+
Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
1041
|
+
|
|
1042
|
+
Show only active changes (not already archived).
|
|
1043
|
+
Include the schema used for each change if available.
|
|
1044
|
+
|
|
1045
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
1046
|
+
|
|
1047
|
+
2. **Check artifact completion status**
|
|
1048
|
+
|
|
1049
|
+
Run \`openspec status --change "<name>" --json\` to check artifact completion.
|
|
1050
|
+
|
|
1051
|
+
Parse the JSON to understand:
|
|
1052
|
+
- \`schemaName\`: The workflow being used
|
|
1053
|
+
- \`artifacts\`: List of artifacts with their status (\`done\` or other)
|
|
1054
|
+
|
|
1055
|
+
**If any artifacts are not \`done\`:**
|
|
1056
|
+
- Display warning listing incomplete artifacts
|
|
1057
|
+
- Use **AskUserQuestion tool** to confirm user wants to proceed
|
|
1058
|
+
- Proceed if user confirms
|
|
1059
|
+
|
|
1060
|
+
3. **Check task completion status**
|
|
1061
|
+
|
|
1062
|
+
Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
|
|
1063
|
+
|
|
1064
|
+
Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
|
|
1065
|
+
|
|
1066
|
+
**If incomplete tasks found:**
|
|
1067
|
+
- Display warning showing count of incomplete tasks
|
|
1068
|
+
- Use **AskUserQuestion tool** to confirm user wants to proceed
|
|
1069
|
+
- Proceed if user confirms
|
|
1070
|
+
|
|
1071
|
+
**If no tasks file exists:** Proceed without task-related warning.
|
|
1072
|
+
|
|
1073
|
+
4. **Check if delta specs need syncing**
|
|
1074
|
+
|
|
1075
|
+
Check if \`specs/\` directory exists in the change with spec files.
|
|
1076
|
+
|
|
1077
|
+
**If delta specs exist, perform a quick sync check:**
|
|
1078
|
+
|
|
1079
|
+
a. **For each delta spec** at \`openspec/changes/<name>/specs/<capability>/spec.md\`:
|
|
1080
|
+
- Extract requirement names (lines matching \`### Requirement: <name>\`)
|
|
1081
|
+
- Note which sections exist (ADDED, MODIFIED, REMOVED)
|
|
1082
|
+
|
|
1083
|
+
b. **Check corresponding main spec** at \`openspec/specs/<capability>/spec.md\`:
|
|
1084
|
+
- If main spec doesn't exist → needs sync
|
|
1085
|
+
- If main spec exists, check if ADDED requirement names appear in it
|
|
1086
|
+
- If any ADDED requirements are missing from main spec → needs sync
|
|
1087
|
+
|
|
1088
|
+
c. **Report findings:**
|
|
1089
|
+
|
|
1090
|
+
**If sync needed:**
|
|
1091
|
+
\`\`\`
|
|
1092
|
+
⚠️ Delta specs may not be synced:
|
|
1093
|
+
- specs/auth/spec.md → Main spec missing requirement "Token Refresh"
|
|
1094
|
+
- specs/api/spec.md → Main spec doesn't exist yet
|
|
1095
|
+
|
|
1096
|
+
Would you like to sync now before archiving?
|
|
1097
|
+
\`\`\`
|
|
1098
|
+
- Use **AskUserQuestion tool** with options: "Sync now", "Archive without syncing"
|
|
1099
|
+
- If user chooses sync, execute /opsx:sync logic (use the openspec-sync-specs skill)
|
|
1100
|
+
|
|
1101
|
+
**If already synced (all requirements found):**
|
|
1102
|
+
- Proceed without prompting (specs appear to be in sync)
|
|
1103
|
+
|
|
1104
|
+
**If no delta specs exist:** Proceed without sync-related checks.
|
|
1105
|
+
|
|
1106
|
+
5. **Perform the archive**
|
|
1107
|
+
|
|
1108
|
+
Create the archive directory if it doesn't exist:
|
|
1109
|
+
\`\`\`bash
|
|
1110
|
+
mkdir -p openspec/changes/archive
|
|
1111
|
+
\`\`\`
|
|
1112
|
+
|
|
1113
|
+
Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
|
|
1114
|
+
|
|
1115
|
+
**Check if target already exists:**
|
|
1116
|
+
- If yes: Fail with error, suggest renaming existing archive or using different date
|
|
1117
|
+
- If no: Move the change directory to archive
|
|
1118
|
+
|
|
1119
|
+
\`\`\`bash
|
|
1120
|
+
mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
|
|
1121
|
+
\`\`\`
|
|
1122
|
+
|
|
1123
|
+
6. **Display summary**
|
|
1124
|
+
|
|
1125
|
+
Show archive completion summary including:
|
|
1126
|
+
- Change name
|
|
1127
|
+
- Schema that was used
|
|
1128
|
+
- Archive location
|
|
1129
|
+
- Whether specs were synced (if applicable)
|
|
1130
|
+
- Note about any warnings (incomplete artifacts/tasks)
|
|
1131
|
+
|
|
1132
|
+
**Output On Success**
|
|
1133
|
+
|
|
1134
|
+
\`\`\`
|
|
1135
|
+
## Archive Complete
|
|
1136
|
+
|
|
1137
|
+
**Change:** <change-name>
|
|
1138
|
+
**Schema:** <schema-name>
|
|
1139
|
+
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
|
|
1140
|
+
**Specs:** ✓ Synced to main specs (or "No delta specs" or "⚠️ Not synced")
|
|
1141
|
+
|
|
1142
|
+
All artifacts complete. All tasks complete.
|
|
1143
|
+
\`\`\`
|
|
1144
|
+
|
|
1145
|
+
**Guardrails**
|
|
1146
|
+
- Always prompt for change selection if not provided
|
|
1147
|
+
- Use artifact graph (openspec status --json) for completion checking
|
|
1148
|
+
- Don't block archive on warnings - just inform and confirm
|
|
1149
|
+
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
|
|
1150
|
+
- Show clear summary of what happened
|
|
1151
|
+
- If sync is requested, use openspec-sync-specs approach (agent-driven)
|
|
1152
|
+
- Quick sync check: look for requirement names in delta specs, verify they exist in main specs`
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Template for /opsx:sync slash command
|
|
1157
|
+
*/
|
|
1158
|
+
export function getOpsxSyncCommandTemplate() {
|
|
1159
|
+
return {
|
|
1160
|
+
name: 'OPSX: Sync',
|
|
1161
|
+
description: 'Sync delta specs from a change to main specs',
|
|
1162
|
+
category: 'Workflow',
|
|
1163
|
+
tags: ['workflow', 'specs', 'experimental'],
|
|
1164
|
+
content: `Sync delta specs from a change to main specs.
|
|
1165
|
+
|
|
1166
|
+
This is an **agent-driven** operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
|
|
1167
|
+
|
|
1168
|
+
**Input**: Optionally specify \`--change <name>\` after \`/opsx:sync\`. If omitted, MUST prompt for available changes.
|
|
1169
|
+
|
|
1170
|
+
**Steps**
|
|
1171
|
+
|
|
1172
|
+
1. **If no change name provided, prompt for selection**
|
|
1173
|
+
|
|
1174
|
+
Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
1175
|
+
|
|
1176
|
+
Show changes that have delta specs (under \`specs/\` directory).
|
|
1177
|
+
|
|
1178
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
1179
|
+
|
|
1180
|
+
2. **Find delta specs**
|
|
1181
|
+
|
|
1182
|
+
Look for delta spec files in \`openspec/changes/<name>/specs/*/spec.md\`.
|
|
1183
|
+
|
|
1184
|
+
Each delta spec file contains sections like:
|
|
1185
|
+
- \`## ADDED Requirements\` - New requirements to add
|
|
1186
|
+
- \`## MODIFIED Requirements\` - Changes to existing requirements
|
|
1187
|
+
- \`## REMOVED Requirements\` - Requirements to remove
|
|
1188
|
+
- \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
|
|
1189
|
+
|
|
1190
|
+
If no delta specs found, inform user and stop.
|
|
1191
|
+
|
|
1192
|
+
3. **For each delta spec, apply changes to main specs**
|
|
1193
|
+
|
|
1194
|
+
For each capability with a delta spec at \`openspec/changes/<name>/specs/<capability>/spec.md\`:
|
|
1195
|
+
|
|
1196
|
+
a. **Read the delta spec** to understand the intended changes
|
|
1197
|
+
|
|
1198
|
+
b. **Read the main spec** at \`openspec/specs/<capability>/spec.md\` (may not exist yet)
|
|
1199
|
+
|
|
1200
|
+
c. **Apply changes intelligently**:
|
|
1201
|
+
|
|
1202
|
+
**ADDED Requirements:**
|
|
1203
|
+
- If requirement doesn't exist in main spec → add it
|
|
1204
|
+
- If requirement already exists → update it to match (treat as implicit MODIFIED)
|
|
1205
|
+
|
|
1206
|
+
**MODIFIED Requirements:**
|
|
1207
|
+
- Find the requirement in main spec
|
|
1208
|
+
- Apply the changes - this can be:
|
|
1209
|
+
- Adding new scenarios (don't need to copy existing ones)
|
|
1210
|
+
- Modifying existing scenarios
|
|
1211
|
+
- Changing the requirement description
|
|
1212
|
+
- Preserve scenarios/content not mentioned in the delta
|
|
1213
|
+
|
|
1214
|
+
**REMOVED Requirements:**
|
|
1215
|
+
- Remove the entire requirement block from main spec
|
|
1216
|
+
|
|
1217
|
+
**RENAMED Requirements:**
|
|
1218
|
+
- Find the FROM requirement, rename to TO
|
|
1219
|
+
|
|
1220
|
+
d. **Create new main spec** if capability doesn't exist yet:
|
|
1221
|
+
- Create \`openspec/specs/<capability>/spec.md\`
|
|
1222
|
+
- Add Purpose section (can be brief, mark as TBD)
|
|
1223
|
+
- Add Requirements section with the ADDED requirements
|
|
1224
|
+
|
|
1225
|
+
4. **Show summary**
|
|
1226
|
+
|
|
1227
|
+
After applying all changes, summarize:
|
|
1228
|
+
- Which capabilities were updated
|
|
1229
|
+
- What changes were made (requirements added/modified/removed/renamed)
|
|
1230
|
+
|
|
1231
|
+
**Delta Spec Format Reference**
|
|
1232
|
+
|
|
1233
|
+
\`\`\`markdown
|
|
1234
|
+
## ADDED Requirements
|
|
1235
|
+
|
|
1236
|
+
### Requirement: New Feature
|
|
1237
|
+
The system SHALL do something new.
|
|
1238
|
+
|
|
1239
|
+
#### Scenario: Basic case
|
|
1240
|
+
- **WHEN** user does X
|
|
1241
|
+
- **THEN** system does Y
|
|
1242
|
+
|
|
1243
|
+
## MODIFIED Requirements
|
|
1244
|
+
|
|
1245
|
+
### Requirement: Existing Feature
|
|
1246
|
+
#### Scenario: New scenario to add
|
|
1247
|
+
- **WHEN** user does A
|
|
1248
|
+
- **THEN** system does B
|
|
1249
|
+
|
|
1250
|
+
## REMOVED Requirements
|
|
1251
|
+
|
|
1252
|
+
### Requirement: Deprecated Feature
|
|
1253
|
+
|
|
1254
|
+
## RENAMED Requirements
|
|
1255
|
+
|
|
1256
|
+
- FROM: \`### Requirement: Old Name\`
|
|
1257
|
+
- TO: \`### Requirement: New Name\`
|
|
1258
|
+
\`\`\`
|
|
1259
|
+
|
|
1260
|
+
**Key Principle: Intelligent Merging**
|
|
1261
|
+
|
|
1262
|
+
Unlike programmatic merging, you can apply **partial updates**:
|
|
1263
|
+
- To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios
|
|
1264
|
+
- The delta represents *intent*, not a wholesale replacement
|
|
1265
|
+
- Use your judgment to merge changes sensibly
|
|
1266
|
+
|
|
1267
|
+
**Output On Success**
|
|
1268
|
+
|
|
1269
|
+
\`\`\`
|
|
1270
|
+
## Specs Synced: <change-name>
|
|
1271
|
+
|
|
1272
|
+
Updated main specs:
|
|
1273
|
+
|
|
1274
|
+
**<capability-1>**:
|
|
1275
|
+
- Added requirement: "New Feature"
|
|
1276
|
+
- Modified requirement: "Existing Feature" (added 1 scenario)
|
|
1277
|
+
|
|
1278
|
+
**<capability-2>**:
|
|
1279
|
+
- Created new spec file
|
|
1280
|
+
- Added requirement: "Another Feature"
|
|
1281
|
+
|
|
1282
|
+
Main specs are now updated. The change remains active - archive when implementation is complete.
|
|
1283
|
+
\`\`\`
|
|
1284
|
+
|
|
1285
|
+
**Guardrails**
|
|
1286
|
+
- Read both delta and main specs before making changes
|
|
1287
|
+
- Preserve existing content not mentioned in delta
|
|
1288
|
+
- If something is unclear, ask for clarification
|
|
1289
|
+
- Show what you're changing as you go
|
|
1290
|
+
- The operation should be idempotent - running twice should give same result`
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Template for /opsx:archive slash command
|
|
1295
|
+
*/
|
|
1296
|
+
export function getOpsxArchiveCommandTemplate() {
|
|
1297
|
+
return {
|
|
1298
|
+
name: 'OPSX: Archive',
|
|
1299
|
+
description: 'Archive a completed change in the experimental workflow',
|
|
1300
|
+
category: 'Workflow',
|
|
1301
|
+
tags: ['workflow', 'archive', 'experimental'],
|
|
1302
|
+
content: `Archive a completed change in the experimental workflow.
|
|
1303
|
+
|
|
1304
|
+
**Input**: Optionally specify \`--change <name>\` after \`/opsx:archive\`. If omitted, MUST prompt for available changes.
|
|
1305
|
+
|
|
1306
|
+
**Steps**
|
|
1307
|
+
|
|
1308
|
+
1. **If no change name provided, prompt for selection**
|
|
1309
|
+
|
|
1310
|
+
Run \`openspec list --json\` to get available changes. Use the **AskUserQuestion tool** to let the user select.
|
|
1311
|
+
|
|
1312
|
+
Show only active changes (not already archived).
|
|
1313
|
+
Include the schema used for each change if available.
|
|
1314
|
+
|
|
1315
|
+
**IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
|
|
1316
|
+
|
|
1317
|
+
2. **Check artifact completion status**
|
|
1318
|
+
|
|
1319
|
+
Run \`openspec status --change "<name>" --json\` to check artifact completion.
|
|
1320
|
+
|
|
1321
|
+
Parse the JSON to understand:
|
|
1322
|
+
- \`schemaName\`: The workflow being used
|
|
1323
|
+
- \`artifacts\`: List of artifacts with their status (\`done\` or other)
|
|
1324
|
+
|
|
1325
|
+
**If any artifacts are not \`done\`:**
|
|
1326
|
+
- Display warning listing incomplete artifacts
|
|
1327
|
+
- Prompt user for confirmation to continue
|
|
1328
|
+
- Proceed if user confirms
|
|
1329
|
+
|
|
1330
|
+
3. **Check task completion status**
|
|
1331
|
+
|
|
1332
|
+
Read the tasks file (typically \`tasks.md\`) to check for incomplete tasks.
|
|
1333
|
+
|
|
1334
|
+
Count tasks marked with \`- [ ]\` (incomplete) vs \`- [x]\` (complete).
|
|
1335
|
+
|
|
1336
|
+
**If incomplete tasks found:**
|
|
1337
|
+
- Display warning showing count of incomplete tasks
|
|
1338
|
+
- Prompt user for confirmation to continue
|
|
1339
|
+
- Proceed if user confirms
|
|
1340
|
+
|
|
1341
|
+
**If no tasks file exists:** Proceed without task-related warning.
|
|
1342
|
+
|
|
1343
|
+
4. **Check if delta specs need syncing**
|
|
1344
|
+
|
|
1345
|
+
Check if \`specs/\` directory exists in the change with spec files.
|
|
1346
|
+
|
|
1347
|
+
**If delta specs exist, perform a quick sync check:**
|
|
1348
|
+
|
|
1349
|
+
a. **For each delta spec** at \`openspec/changes/<name>/specs/<capability>/spec.md\`:
|
|
1350
|
+
- Extract requirement names (lines matching \`### Requirement: <name>\`)
|
|
1351
|
+
- Note which sections exist (ADDED, MODIFIED, REMOVED)
|
|
1352
|
+
|
|
1353
|
+
b. **Check corresponding main spec** at \`openspec/specs/<capability>/spec.md\`:
|
|
1354
|
+
- If main spec doesn't exist → needs sync
|
|
1355
|
+
- If main spec exists, check if ADDED requirement names appear in it
|
|
1356
|
+
- If any ADDED requirements are missing from main spec → needs sync
|
|
1357
|
+
|
|
1358
|
+
c. **Report findings:**
|
|
1359
|
+
|
|
1360
|
+
**If sync needed:**
|
|
1361
|
+
\`\`\`
|
|
1362
|
+
⚠️ Delta specs may not be synced:
|
|
1363
|
+
- specs/auth/spec.md → Main spec missing requirement "Token Refresh"
|
|
1364
|
+
- specs/api/spec.md → Main spec doesn't exist yet
|
|
1365
|
+
|
|
1366
|
+
Would you like to sync now before archiving?
|
|
1367
|
+
\`\`\`
|
|
1368
|
+
- Use **AskUserQuestion tool** with options: "Sync now", "Archive without syncing"
|
|
1369
|
+
- If user chooses sync, execute \`/opsx:sync\` logic
|
|
1370
|
+
|
|
1371
|
+
**If already synced (all requirements found):**
|
|
1372
|
+
- Proceed without prompting (specs appear to be in sync)
|
|
1373
|
+
|
|
1374
|
+
**If no delta specs exist:** Proceed without sync-related checks.
|
|
1375
|
+
|
|
1376
|
+
5. **Perform the archive**
|
|
1377
|
+
|
|
1378
|
+
Create the archive directory if it doesn't exist:
|
|
1379
|
+
\`\`\`bash
|
|
1380
|
+
mkdir -p openspec/changes/archive
|
|
1381
|
+
\`\`\`
|
|
1382
|
+
|
|
1383
|
+
Generate target name using current date: \`YYYY-MM-DD-<change-name>\`
|
|
1384
|
+
|
|
1385
|
+
**Check if target already exists:**
|
|
1386
|
+
- If yes: Fail with error, suggest renaming existing archive or using different date
|
|
1387
|
+
- If no: Move the change directory to archive
|
|
1388
|
+
|
|
1389
|
+
\`\`\`bash
|
|
1390
|
+
mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
|
|
1391
|
+
\`\`\`
|
|
1392
|
+
|
|
1393
|
+
6. **Display summary**
|
|
1394
|
+
|
|
1395
|
+
Show archive completion summary including:
|
|
1396
|
+
- Change name
|
|
1397
|
+
- Schema that was used
|
|
1398
|
+
- Archive location
|
|
1399
|
+
- Spec sync status (synced / not synced / no delta specs)
|
|
1400
|
+
- Note about any warnings (incomplete artifacts/tasks)
|
|
1401
|
+
|
|
1402
|
+
**Output On Success**
|
|
1403
|
+
|
|
1404
|
+
\`\`\`
|
|
1405
|
+
## Archive Complete
|
|
1406
|
+
|
|
1407
|
+
**Change:** <change-name>
|
|
1408
|
+
**Schema:** <schema-name>
|
|
1409
|
+
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
|
|
1410
|
+
**Specs:** ✓ Synced to main specs
|
|
1411
|
+
|
|
1412
|
+
All artifacts complete. All tasks complete.
|
|
1413
|
+
\`\`\`
|
|
1414
|
+
|
|
1415
|
+
**Output On Success (No Delta Specs)**
|
|
1416
|
+
|
|
1417
|
+
\`\`\`
|
|
1418
|
+
## Archive Complete
|
|
1419
|
+
|
|
1420
|
+
**Change:** <change-name>
|
|
1421
|
+
**Schema:** <schema-name>
|
|
1422
|
+
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
|
|
1423
|
+
**Specs:** No delta specs
|
|
1424
|
+
|
|
1425
|
+
All artifacts complete. All tasks complete.
|
|
1426
|
+
\`\`\`
|
|
1427
|
+
|
|
1428
|
+
**Output On Success With Warnings**
|
|
1429
|
+
|
|
1430
|
+
\`\`\`
|
|
1431
|
+
## Archive Complete (with warnings)
|
|
1432
|
+
|
|
1433
|
+
**Change:** <change-name>
|
|
1434
|
+
**Schema:** <schema-name>
|
|
1435
|
+
**Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
|
|
1436
|
+
**Specs:** ⚠️ Not synced
|
|
1437
|
+
|
|
1438
|
+
**Warnings:**
|
|
1439
|
+
- Archived with 2 incomplete artifacts
|
|
1440
|
+
- Archived with 3 incomplete tasks
|
|
1441
|
+
- Delta specs were not synced (user chose to skip)
|
|
1442
|
+
|
|
1443
|
+
Review the archive if this was not intentional.
|
|
1444
|
+
\`\`\`
|
|
1445
|
+
|
|
1446
|
+
**Output On Error (Archive Exists)**
|
|
1447
|
+
|
|
1448
|
+
\`\`\`
|
|
1449
|
+
## Archive Failed
|
|
1450
|
+
|
|
1451
|
+
**Change:** <change-name>
|
|
1452
|
+
**Target:** openspec/changes/archive/YYYY-MM-DD-<name>/
|
|
1453
|
+
|
|
1454
|
+
Target archive directory already exists.
|
|
1455
|
+
|
|
1456
|
+
**Options:**
|
|
1457
|
+
1. Rename the existing archive
|
|
1458
|
+
2. Delete the existing archive if it's a duplicate
|
|
1459
|
+
3. Wait until a different date to archive
|
|
1460
|
+
\`\`\`
|
|
1461
|
+
|
|
1462
|
+
**Guardrails**
|
|
1463
|
+
- Always prompt for change selection if not provided
|
|
1464
|
+
- Use artifact graph (openspec status --json) for completion checking
|
|
1465
|
+
- Don't block archive on warnings - just inform and confirm
|
|
1466
|
+
- Preserve .openspec.yaml when moving to archive (it moves with the directory)
|
|
1467
|
+
- Quick sync check: look for requirement names in delta specs, verify they exist in main specs
|
|
1468
|
+
- Show clear summary of what happened
|
|
1469
|
+
- If sync is requested, use /opsx:sync approach (agent-driven)`
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
//# sourceMappingURL=skill-templates.js.map
|