@fission-ai/openspec 1.13.0 → 1.13.2

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 (113) hide show
  1. package/README.md +16 -4
  2. package/dist/commands/change.js +12 -1
  3. package/dist/commands/config.d.ts +9 -0
  4. package/dist/commands/config.js +161 -22
  5. package/dist/commands/feedback.js +6 -4
  6. package/dist/commands/schema.js +30 -9
  7. package/dist/commands/store.js +5 -2
  8. package/dist/commands/validate.d.ts +7 -0
  9. package/dist/commands/validate.js +63 -1
  10. package/dist/commands/workflow/instructions.js +69 -22
  11. package/dist/commands/workflow/new-change.js +20 -0
  12. package/dist/commands/workflow/shared.d.ts +5 -0
  13. package/dist/commands/workflow/shared.js +8 -0
  14. package/dist/commands/workflow/status.d.ts +5 -1
  15. package/dist/commands/workflow/status.js +42 -5
  16. package/dist/core/archive.js +260 -77
  17. package/dist/core/artifact-graph/outputs.d.ts +1 -1
  18. package/dist/core/artifact-graph/outputs.js +38 -8
  19. package/dist/core/artifact-graph/schema.d.ts +14 -0
  20. package/dist/core/artifact-graph/schema.js +52 -0
  21. package/dist/core/artifact-graph/types.js +12 -1
  22. package/dist/core/change-status-policy.d.ts +14 -0
  23. package/dist/core/change-status-policy.js +14 -6
  24. package/dist/core/command-generation/adapters/continue.js +4 -0
  25. package/dist/core/command-generation/adapters/kilocode.d.ts +1 -1
  26. package/dist/core/command-generation/adapters/kilocode.js +2 -2
  27. package/dist/core/command-generation/generator.js +2 -0
  28. package/dist/core/completion-tip.js +7 -7
  29. package/dist/core/completions/installers/bash-installer.js +15 -7
  30. package/dist/core/completions/installers/shell-quote.d.ts +11 -0
  31. package/dist/core/completions/installers/shell-quote.js +13 -0
  32. package/dist/core/completions/installers/zsh-installer.js +3 -2
  33. package/dist/core/config-schema.d.ts +1 -1
  34. package/dist/core/config.d.ts +16 -0
  35. package/dist/core/config.js +27 -1
  36. package/dist/core/global-config.d.ts +30 -2
  37. package/dist/core/global-config.js +57 -3
  38. package/dist/core/init.js +22 -6
  39. package/dist/core/legacy-cleanup.d.ts +5 -1
  40. package/dist/core/legacy-cleanup.js +207 -14
  41. package/dist/core/list.js +55 -11
  42. package/dist/core/migration.js +6 -1
  43. package/dist/core/parsers/change-parser.d.ts +12 -1
  44. package/dist/core/parsers/change-parser.js +85 -87
  45. package/dist/core/parsers/markdown-parser.js +4 -3
  46. package/dist/core/parsers/requirement-blocks.d.ts +78 -6
  47. package/dist/core/parsers/requirement-blocks.js +155 -38
  48. package/dist/core/parsers/requirement-text.d.ts +13 -2
  49. package/dist/core/parsers/requirement-text.js +34 -7
  50. package/dist/core/parsers/spec-structure.js +4 -1
  51. package/dist/core/project-config.d.ts +9 -1
  52. package/dist/core/project-config.js +11 -2
  53. package/dist/core/references.d.ts +20 -0
  54. package/dist/core/references.js +56 -0
  55. package/dist/core/shared/skill-content-equivalence.js +5 -1
  56. package/dist/core/shared/skill-generation.js +36 -8
  57. package/dist/core/shared/tool-detection.js +9 -3
  58. package/dist/core/specs-apply.d.ts +20 -0
  59. package/dist/core/specs-apply.js +101 -17
  60. package/dist/core/store/git.d.ts +33 -0
  61. package/dist/core/store/git.js +60 -6
  62. package/dist/core/store/operations.d.ts +1 -1
  63. package/dist/core/store/operations.js +32 -10
  64. package/dist/core/store/registry.d.ts +2 -1
  65. package/dist/core/store/registry.js +5 -1
  66. package/dist/core/templates/optional-workflow.d.ts +69 -0
  67. package/dist/core/templates/optional-workflow.js +140 -0
  68. package/dist/core/templates/workflows/apply-change.js +18 -3
  69. package/dist/core/templates/workflows/archive-change.js +70 -21
  70. package/dist/core/templates/workflows/bulk-archive-change.js +85 -21
  71. package/dist/core/templates/workflows/continue-change.js +14 -4
  72. package/dist/core/templates/workflows/explore.js +34 -16
  73. package/dist/core/templates/workflows/ff-change.js +21 -5
  74. package/dist/core/templates/workflows/new-change.js +15 -3
  75. package/dist/core/templates/workflows/onboard.js +76 -41
  76. package/dist/core/templates/workflows/project-root.d.ts +29 -0
  77. package/dist/core/templates/workflows/project-root.js +38 -0
  78. package/dist/core/templates/workflows/propose.js +22 -5
  79. package/dist/core/templates/workflows/sync-specs.js +40 -1
  80. package/dist/core/templates/workflows/update-change.js +66 -27
  81. package/dist/core/templates/workflows/verify-change.js +121 -49
  82. package/dist/core/update.d.ts +12 -0
  83. package/dist/core/update.js +78 -10
  84. package/dist/core/validation/purpose-placeholder.js +24 -9
  85. package/dist/core/validation/task-checkboxes.d.ts +34 -0
  86. package/dist/core/validation/task-checkboxes.js +181 -0
  87. package/dist/core/validation/validator.d.ts +53 -1
  88. package/dist/core/validation/validator.js +160 -45
  89. package/dist/core/version-check.d.ts +14 -7
  90. package/dist/core/version-check.js +63 -17
  91. package/dist/core/worksets.js +6 -4
  92. package/dist/prompts/searchable-multi-select.d.ts +7 -0
  93. package/dist/prompts/searchable-multi-select.js +35 -6
  94. package/dist/telemetry/config.js +14 -2
  95. package/dist/telemetry/index.d.ts +4 -3
  96. package/dist/telemetry/index.js +22 -10
  97. package/dist/telemetry/opt-out.d.ts +17 -0
  98. package/dist/telemetry/opt-out.js +27 -0
  99. package/dist/utils/file-system.js +20 -3
  100. package/dist/utils/line-endings.d.ts +34 -0
  101. package/dist/utils/line-endings.js +46 -0
  102. package/dist/utils/nested-change.d.ts +35 -0
  103. package/dist/utils/nested-change.js +186 -0
  104. package/dist/utils/spec-discovery.d.ts +20 -0
  105. package/dist/utils/spec-discovery.js +59 -0
  106. package/dist/utils/task-progress.d.ts +1 -1
  107. package/dist/utils/task-progress.js +38 -6
  108. package/package.json +5 -5
  109. package/schemas/spec-driven/schema.yaml +18 -3
  110. package/schemas/spec-driven/templates/design.md +2 -0
  111. package/schemas/spec-driven/templates/proposal.md +2 -0
  112. package/schemas/spec-driven/templates/spec.md +2 -0
  113. package/schemas/spec-driven/templates/tasks.md +2 -0
@@ -1,8 +1,21 @@
1
+ import { optionalWorkflow } from '../optional-workflow.js';
1
2
  import { STORE_SELECTION_GUIDANCE } from './store-selection.js';
3
+ import { PROJECT_ROOT_GUARD } from './project-root.js';
4
+ /**
5
+ * The implementation handoff. `apply` is not guaranteed to be installed, so
6
+ * the prompt is resolved at generation time (see optional-workflow.ts) rather
7
+ * than naming a workflow that may not exist.
8
+ *
9
+ * The two surfaces word this differently on purpose (#258): a command-only
10
+ * tool has no conversational agent to ask, so its prompt names a command or
11
+ * the CLI and never invites "ask me to implement".
12
+ */
13
+ const SKILL_APPLY_HANDOFF = optionalWorkflow('apply', 'run `/opsx:apply` or ask me to apply this change', 'ask me to apply this change');
14
+ const COMMAND_APPLY_HANDOFF = optionalWorkflow('apply', 'run `/opsx:apply`', 'run `openspec instructions apply --change "<name>" --json` to get the tasks');
2
15
  export function getOpsxProposeSkillTemplate() {
3
16
  return {
4
17
  name: 'openspec-propose',
5
- description: 'Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.',
18
+ description: 'Propose a new OpenSpec change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation. Also use when the user says "openspec propose" or "opsx propose".',
6
19
  instructions: `Propose a new change - create the change and generate all artifacts in one step.
7
20
 
8
21
  **Planning boundary**: This workflow creates planning artifacts only. The user request that selected or triggered this workflow authorizes planning only, even if it asks to build or fix something. Do not edit project code. After the planning artifacts are complete, stop. Do not start implementation in the same response, even if the initial request asks for it. Wait for a new user request after the artifacts are presented; then start the apply workflow.
@@ -21,6 +34,8 @@ When the user is ready to implement, they must start the apply workflow explicit
21
34
 
22
35
  ${STORE_SELECTION_GUIDANCE}
23
36
 
37
+ ${PROJECT_ROOT_GUARD}
38
+
24
39
  **Input**: The user's request should include a change name (kebab-case) OR a description of what they want to build.
25
40
 
26
41
  **Steps**
@@ -38,7 +53,7 @@ ${STORE_SELECTION_GUIDANCE}
38
53
 
39
54
  2. **Load project context**
40
55
 
41
- Run \`openspec context --json\` from the current working directory (or \`openspec context --json --store "<store-id>"\` when a registered store was explicitly selected). Use the returned \`root.path\` as the authoritative OpenSpec root. If context reports \`no_openspec_root\`, stop without creating or changing any files. Offer \`openspec init\` and wait for the user to request initialization. Do not initialize automatically or run \`openspec new change\`. After initialization, rerun this context check before continuing. For any other context failure, stop and report the error; do not fall back to the current directory or run later OpenSpec commands without the selected store.
56
+ Run \`openspec context --json\` from the current working directory (or \`openspec context --json --store "<store-id>"\` when a registered store was explicitly selected). Use the returned \`root.path\` as the authoritative OpenSpec root. If context reports \`no_openspec_root\`, stop without creating or changing any files and follow the **Project check** above for how this workflow was reached. Offer \`openspec init\` only for an explicit OpenSpec request, and wait for the user to request initialization. Do not initialize automatically or run \`openspec new change\`. After initialization, rerun this context check before continuing. For any other context failure, stop and report the error; do not fall back to the current directory or run later OpenSpec commands without the selected store.
42
57
 
43
58
  Only when context returns a resolved \`root.path\`, read \`<root.path>/openspec/config.yaml\`. Use \`config.yml\` only when \`config.yaml\` does not exist. If neither file exists, continue without project context. Do not fall back to \`config.yml\` if \`config.yaml\` is unreadable or invalid.
44
59
 
@@ -134,7 +149,7 @@ After completing all artifacts, summarize:
134
149
  - Change name and location
135
150
  - List of artifacts created with brief descriptions, plus any conditional artifact you skipped and why
136
151
  - What's ready: "All artifacts needed for implementation are ready."
137
- - Prompt: "The artifacts are ready for review. When you are ready, run \`/opsx:apply\` or ask me to apply this change."
152
+ - Prompt: "The artifacts are ready for review. When you are ready, ${SKILL_APPLY_HANDOFF}."
138
153
 
139
154
  **Artifact Creation Guidelines**
140
155
 
@@ -183,6 +198,8 @@ When the user is ready to implement, they must start the apply workflow explicit
183
198
 
184
199
  ${STORE_SELECTION_GUIDANCE}
185
200
 
201
+ ${PROJECT_ROOT_GUARD}
202
+
186
203
  **Input**: The argument after \`/opsx:propose\` is the change name (kebab-case), OR a description of what the user wants to build.
187
204
 
188
205
  **Steps**
@@ -200,7 +217,7 @@ ${STORE_SELECTION_GUIDANCE}
200
217
 
201
218
  2. **Load project context**
202
219
 
203
- Run \`openspec context --json\` from the current working directory (or \`openspec context --json --store "<store-id>"\` when a registered store was explicitly selected). Use the returned \`root.path\` as the authoritative OpenSpec root. If context reports \`no_openspec_root\`, stop without creating or changing any files. Offer \`openspec init\` and wait for the user to request initialization. Do not initialize automatically or run \`openspec new change\`. After initialization, rerun this context check before continuing. For any other context failure, stop and report the error; do not fall back to the current directory or run later OpenSpec commands without the selected store.
220
+ Run \`openspec context --json\` from the current working directory (or \`openspec context --json --store "<store-id>"\` when a registered store was explicitly selected). Use the returned \`root.path\` as the authoritative OpenSpec root. If context reports \`no_openspec_root\`, stop without creating or changing any files and follow the **Project check** above for how this workflow was reached. Offer \`openspec init\` only for an explicit OpenSpec request, and wait for the user to request initialization. Do not initialize automatically or run \`openspec new change\`. After initialization, rerun this context check before continuing. For any other context failure, stop and report the error; do not fall back to the current directory or run later OpenSpec commands without the selected store.
204
221
 
205
222
  Only when context returns a resolved \`root.path\`, read \`<root.path>/openspec/config.yaml\`. Use \`config.yml\` only when \`config.yaml\` does not exist. If neither file exists, continue without project context. Do not fall back to \`config.yml\` if \`config.yaml\` is unreadable or invalid.
206
223
 
@@ -296,7 +313,7 @@ After completing all artifacts, summarize:
296
313
  - Change name and location
297
314
  - List of artifacts created with brief descriptions, plus any conditional artifact you skipped and why
298
315
  - What's ready: "All artifacts needed for implementation are ready."
299
- - Prompt: "The artifacts are ready for review. When you are ready, run \`/opsx:apply\`."
316
+ - Prompt: "The artifacts are ready for review. When you are ready, ${COMMAND_APPLY_HANDOFF}."
300
317
 
301
318
  **Artifact Creation Guidelines**
302
319
 
@@ -1,14 +1,17 @@
1
1
  import { STORE_SELECTION_GUIDANCE } from './store-selection.js';
2
+ import { PROJECT_ROOT_GUARD } from './project-root.js';
2
3
  export function getSyncSpecsSkillTemplate() {
3
4
  return {
4
5
  name: 'openspec-sync-specs',
5
- 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.',
6
+ description: 'Sync delta specs from an OpenSpec change to main specs. Use when the user wants to update main specs with changes from a delta spec, without archiving the change. Also use when the user says "openspec sync" or "opsx sync".',
6
7
  instructions: `Sync delta specs from a change to main specs.
7
8
 
8
9
  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).
9
10
 
10
11
  ${STORE_SELECTION_GUIDANCE}
11
12
 
13
+ ${PROJECT_ROOT_GUARD}
14
+
12
15
  \`<capability-path>\` is the spec directory relative to \`specs/\` (for example, \`user-auth\` or \`identity/user-auth\`). Preserve the full path from each delta spec when resolving its main spec.
13
16
 
14
17
  **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
@@ -89,6 +92,13 @@ ${STORE_SELECTION_GUIDANCE}
89
92
 
90
93
  b. **Read the main spec** at \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\` (may not exist yet)
91
94
 
95
+ **If it does not exist yet** (a new capability), match what \`openspec archive\` does:
96
+ only ADDED requirements may be applied - step d creates the spec from them.
97
+ MODIFIED and RENAMED have no requirement to act on, so stop the sync for that
98
+ capability and report that its main spec does not exist and only ADDED is allowed
99
+ for a new spec; never invent the missing requirement. REMOVED has nothing to
100
+ remove - skip it and warn.
101
+
92
102
  c. **Apply changes intelligently**:
93
103
 
94
104
  **ADDED Requirements:**
@@ -136,6 +146,14 @@ ${STORE_SELECTION_GUIDANCE}
136
146
  (this is what \`openspec archive\` does; it warns and moves on)
137
147
 
138
148
  d. **Create new main spec** if capability doesn't exist yet:
149
+ - Only when the delta has ADDED requirements to put in it and no MODIFIED or
150
+ RENAMED requirements blocked this capability in step b. Otherwise create nothing
151
+ and leave the specs directory untouched. For a REMOVED-only delta, if the change's
152
+ \`.openspec.yaml\` declares \`retire_capabilities: true\`, report it as already retired
153
+ and continue without recreating the spec. Without that marker, report the sync as blocked:
154
+ \`openspec archive\` rejects it with \`Spec must have at least one requirement\`.
155
+ An empty delta has no operations to sync; report it as blocked too.
156
+ Never write an empty \`## Requirements\` section.
139
157
  - Create \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\`
140
158
  - Add Purpose section: copy the delta's \`## Purpose\` body verbatim when it has one
141
159
  (this is what \`openspec archive\` does); only write a brief TBD placeholder when it does not
@@ -160,6 +178,8 @@ ${STORE_SELECTION_GUIDANCE}
160
178
  **Delta Spec Format Reference**
161
179
 
162
180
  \`\`\`markdown
181
+ # Spec Delta
182
+
163
183
  ## Purpose
164
184
 
165
185
  Only on a delta that introduces a brand-new capability. Seeds the new main spec.
@@ -270,6 +290,8 @@ This is an **agent-driven** operation - you will read delta specs and directly e
270
290
 
271
291
  ${STORE_SELECTION_GUIDANCE}
272
292
 
293
+ ${PROJECT_ROOT_GUARD}
294
+
273
295
  \`<capability-path>\` is the spec directory relative to \`specs/\` (for example, \`user-auth\` or \`identity/user-auth\`). Preserve the full path from each delta spec when resolving its main spec.
274
296
 
275
297
  **Input**: Optionally specify a change name after \`/opsx:sync\` (e.g., \`/opsx:sync add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
@@ -350,6 +372,13 @@ ${STORE_SELECTION_GUIDANCE}
350
372
 
351
373
  b. **Read the main spec** at \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\` (may not exist yet)
352
374
 
375
+ **If it does not exist yet** (a new capability), match what \`openspec archive\` does:
376
+ only ADDED requirements may be applied - step d creates the spec from them.
377
+ MODIFIED and RENAMED have no requirement to act on, so stop the sync for that
378
+ capability and report that its main spec does not exist and only ADDED is allowed
379
+ for a new spec; never invent the missing requirement. REMOVED has nothing to
380
+ remove - skip it and warn.
381
+
353
382
  c. **Apply changes intelligently**:
354
383
 
355
384
  **ADDED Requirements:**
@@ -397,6 +426,14 @@ ${STORE_SELECTION_GUIDANCE}
397
426
  (this is what \`openspec archive\` does; it warns and moves on)
398
427
 
399
428
  d. **Create new main spec** if capability doesn't exist yet:
429
+ - Only when the delta has ADDED requirements to put in it and no MODIFIED or
430
+ RENAMED requirements blocked this capability in step b. Otherwise create nothing
431
+ and leave the specs directory untouched. For a REMOVED-only delta, if the change's
432
+ \`.openspec.yaml\` declares \`retire_capabilities: true\`, report it as already retired
433
+ and continue without recreating the spec. Without that marker, report the sync as blocked:
434
+ \`openspec archive\` rejects it with \`Spec must have at least one requirement\`.
435
+ An empty delta has no operations to sync; report it as blocked too.
436
+ Never write an empty \`## Requirements\` section.
400
437
  - Create \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\`
401
438
  - Add Purpose section: copy the delta's \`## Purpose\` body verbatim when it has one
402
439
  (this is what \`openspec archive\` does); only write a brief TBD placeholder when it does not
@@ -421,6 +458,8 @@ ${STORE_SELECTION_GUIDANCE}
421
458
  **Delta Spec Format Reference**
422
459
 
423
460
  \`\`\`markdown
461
+ # Spec Delta
462
+
424
463
  ## Purpose
425
464
 
426
465
  Only on a delta that introduces a brand-new capability. Seeds the new main spec.
@@ -1,15 +1,38 @@
1
+ import { optionalWorkflow } from '../optional-workflow.js';
1
2
  import { STORE_SELECTION_GUIDANCE } from './store-selection.js';
3
+ import { PROJECT_ROOT_GUARD } from './project-root.js';
4
+ /**
5
+ * Passages that hand off to `/opsx:continue` or `/opsx:new`. Neither workflow
6
+ * is in the `core` profile, so each is authored with a CLI fallback and
7
+ * resolved at generation time (see optional-workflow.ts). Shared by both
8
+ * surfaces below so the skill and the command cannot drift apart.
9
+ */
10
+ const CONTINUE_SCOPE_NOTE = optionalWorkflow('continue', 'This workflow revises artifacts that already exist; `/opsx:continue` is what creates the ones that do not.', 'This workflow revises artifacts that already exist; it never creates missing ones. When an artifact is missing, `openspec status --change "<name>" --json` names the next one and `openspec instructions "<artifact-id>" --change "<name>" --json` explains how to write it.');
11
+ const CONTINUE_CREATE_THEM = optionalWorkflow('continue', 'point the user to `/opsx:continue` to create them', 'point the user to `openspec instructions "<artifact-id>" --change "<name>" --json` for how to create them');
12
+ const CONTINUE_NEXT_STEP = optionalWorkflow('continue', 'suggest `/opsx:continue` to create them', 'run `openspec status --change "<name>" --json` for the next artifact and point the user to `openspec instructions "<artifact-id>" --change "<name>" --json` for how to create it');
13
+ const CONTINUE_DEFERRED = optionalWorkflow('continue', 'Anything deferred to `/opsx:continue` (artifacts with no files yet and status `ready` or `blocked`, never `skipped` artifacts)', 'Anything deferred because it does not exist yet (artifacts with no files and status `ready` or `blocked`, never `skipped` artifacts)');
14
+ const CONTINUE_FRONTIER = optionalWorkflow('continue', "that is `/opsx:continue`'s job", 'creating them is a separate step, outside this workflow');
15
+ /**
16
+ * `apply` and `archive` are in the `core` profile but not guaranteed in a
17
+ * custom one, so their handoffs are resolved the same way.
18
+ */
19
+ const APPLY_DELTA_HANDOFF = optionalWorkflow('apply', 'suggest `/opsx:apply` to carry the delta into code', 'say that the code may need updating and offer to carry the delta into it');
20
+ const APPLY_GUARDRAIL = optionalWorkflow('apply', 'stop and point to `/opsx:apply`', 'stop and say that the revised plan now implies code changes; implementing them is a separate step');
21
+ const ARCHIVE_HANDOFF = optionalWorkflow('archive', 'suggest `/opsx:archive`', 'suggest archiving with `openspec archive "<name>"`');
22
+ const INTENT_CHANGE_GUARDRAIL = optionalWorkflow('new', 'recommend starting fresh with `/opsx:new` (the "Update vs. Start Fresh" heuristic)', 'ask for a distinct unused change name and recommend `openspec new change "<new-change-name>"` instead (the "Update vs. Start Fresh" heuristic)');
2
23
  export function getUpdateChangeSkillTemplate() {
3
24
  return {
4
25
  name: 'openspec-update-change',
5
- description: "Update an OpenSpec change by revising its existing planning artifacts and keeping them coherent with one another. Use when the user wants to revise a change's plan, fold new decisions into it, or reconcile its artifacts after an edit. Never edits code.",
26
+ description: "Update an OpenSpec change by revising its existing planning artifacts and keeping them coherent with one another. Use when the user wants to revise a change's plan, fold new decisions into it, or reconcile its artifacts after an edit. Also use when the user says \"openspec update change\" or \"opsx update\". If the user means the openspec update CLI command, which refreshes generated files, run that command instead. Never edits code.",
6
27
  instructions: `Revise a change's existing planning artifacts and keep them coherent. Never edit code.
7
28
 
8
29
  ${STORE_SELECTION_GUIDANCE}
9
30
 
31
+ ${PROJECT_ROOT_GUARD}
32
+
10
33
  **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
11
34
 
12
- \`/opsx:continue\` is an optional workflow and may not be installed. Before suggesting it anywhere below, verify that it is available. If it is unavailable, \`openspec status --change "<name>" --json\` shows the next artifact and \`openspec instructions "<artifact-id>" --change "<name>" --json\` explains how to create it.
35
+ ${CONTINUE_SCOPE_NOTE}
13
36
 
14
37
  **Steps**
15
38
 
@@ -22,7 +45,6 @@ ${STORE_SELECTION_GUIDANCE}
22
45
 
23
46
  When prompting, present the top 3-4 most recently modified changes as options, showing:
24
47
  - Change name
25
- - Schema (from \`schema\` field if present, otherwise "spec-driven")
26
48
  - Status (e.g., "0/5 tasks", "complete", "no tasks")
27
49
  - How recently it was modified (from \`lastModified\` field)
28
50
 
@@ -50,13 +72,20 @@ ${STORE_SELECTION_GUIDANCE}
50
72
 
51
73
  4. **Read and reconcile**
52
74
  - Read the artifact(s) the request touches and the change's other existing artifacts.
53
- - Apply the requested edit. Then check every other existing artifact against it - in ANY direction: an edit to a later artifact may require revising an earlier one, not only the other way around. Build order is a useful reading order, not a constraint on which artifacts may be revised.
75
+ - Draft the requested edit in the conversation, not in files. Work out exactly what it changes; step 5 owns every write. Then check every other existing artifact against the drafted edit - in ANY direction: an edit to a later artifact may require revising an earlier one, not only the other way around. Build order is a useful reading order, not a constraint on which artifacts may be revised.
54
76
  - Note everything that is now inconsistent, missing, or contradictory.
55
- - Revise only files that already exist (\`existingOutputPaths\`). Do NOT create artifacts that don't exist yet, and do NOT invent new files under a glob artifact - note them and point the user to \`/opsx:continue\` to create them.
56
- - If the change is already coherent, say so and make no edits.
77
+ - Propose revisions to files that already exist (\`existingOutputPaths\`). If an artifact has no existing output files and status \`ready\` or \`blocked\`, note it and ${CONTINUE_CREATE_THEM}. Leave \`skipped\` artifacts untouched; do not treat them as missing or defer them to the continue workflow.
78
+ - A glob artifact (e.g. \`specs/**/*.md\`) is marked \`done\` after at least one file matches, and the continue workflow only handles \`ready\` artifacts. When reconciliation identifies a missing file for a glob artifact whose \`existingOutputPaths\` is non-empty:
79
+ 1. Run \`openspec instructions "<artifact-id>" --change "<name>" --json\` and use its \`instruction\` and \`template\`. Treat \`context\` and \`rules\` as constraints; do not copy them into the file. If instructions report \`skipped: true\`, do not create the file. Read current dependency files from disk; if a required non-skipped dependency is missing, stop and ask the user to restore it first.
80
+ 2. Choose a concrete path inside \`changeRoot\` that matches \`artifactPaths.<id>.outputPath\` and does not already exist. Verify it remains inside \`changeRoot\` after resolving any symlinked parent directories. The glob \`resolvedOutputPath\` is not a valid target.
81
+ 3. Include the new file in step 5's proposed revisions and create it only after the user confirms.
82
+ 4. After confirmation, immediately before creation, refresh status and instructions. Verify the artifact is still in scope, not skipped, and partially populated; repeat the concrete-path checks above.
83
+ 5. Use a create operation that fails if the target already exists. If \`instruction\` delegates creation to another skill or command, invoke it only if it can honor the confirmed path and these guardrails; otherwise stop. If any check fails or the confirmed draft is no longer valid, stop and reconcile with the user rather than replacing existing content or choosing a different path.
84
+ - If the change is already coherent, say so and propose no revisions.
57
85
 
58
86
  5. **Confirm and apply, one artifact at a time**
59
- - Show each proposed revision and why. Write only after the user confirms.
87
+ - This step performs every artifact write in this workflow; no earlier step edits an artifact.
88
+ - Show each proposed revision and why - including the requested edit drafted in step 4. Write only after the user confirms.
60
89
  - If the user rejects a revision, do not write it - leave that artifact unchanged.
61
90
  - When a substantial rewrite is needed, get that artifact's rules and template first:
62
91
  \`\`\`bash
@@ -64,24 +93,25 @@ ${STORE_SELECTION_GUIDANCE}
64
93
  \`\`\`
65
94
 
66
95
  6. **Point to the next step (guidance only - NEVER act on it)**
67
- - Artifacts still missing -> suggest \`/opsx:continue\` to create them.
68
- - Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan; suggest \`/opsx:apply\` to carry the delta into code.
69
- - Everything done and implemented -> suggest \`/opsx:archive\`.
96
+ - Artifacts with empty \`existingOutputPaths\` and status \`ready\` or \`blocked\` -> ${CONTINUE_NEXT_STEP}.
97
+ - Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan; ${APPLY_DELTA_HANDOFF}.
98
+ - Everything done and implemented -> ${ARCHIVE_HANDOFF}.
70
99
 
71
100
  **Output**
72
101
 
73
102
  After each invocation, show:
74
103
  - Which artifacts were revised (and which proposed revisions were rejected)
75
- - Anything deferred to \`/opsx:continue\` (not-yet-created artifacts or files)
104
+ - Any file created under a glob artifact that was already partially populated
105
+ - ${CONTINUE_DEFERRED}
76
106
  - Where the change stands and the recommended next command
77
107
 
78
108
  **Guardrails**
79
- - Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes, stop and point to \`/opsx:apply\`.
109
+ - Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes, ${APPLY_GUARDRAIL}.
80
110
  - Use the artifact ids and paths reported by \`openspec status\`; never branch on hardcoded artifact names.
81
111
  - Edit only the concrete files in \`existingOutputPaths\`; never write to a glob \`resolvedOutputPath\`.
82
- - Do not advance the build frontier: no new artifacts, no new files under glob artifacts - that is \`/opsx:continue\`'s job.
112
+ - Do not advance the build frontier: if an artifact has empty \`existingOutputPaths\` and status \`ready\` or \`blocked\`, ${CONTINUE_FRONTIER}. Leave \`skipped\` artifacts untouched. The only new-file scope is a confirmed concrete path under a glob artifact whose \`existingOutputPaths\` is non-empty.
83
113
  - Confirm every edit with the user before writing.
84
- - If the request changes the change's *intent* rather than refining it, first verify whether the optional \`/opsx:new\` workflow is available. If it is, recommend starting fresh with \`/opsx:new\` (the "Update vs. Start Fresh" heuristic). If it is unavailable, ask for a distinct unused change name and recommend \`openspec new change "<new-change-name>"\` instead.`,
114
+ - If the request changes the change's *intent* rather than refining it, ${INTENT_CHANGE_GUARDRAIL}.`,
85
115
  license: 'MIT',
86
116
  compatibility: 'Requires openspec CLI.',
87
117
  metadata: { author: 'openspec', version: '1.0' },
@@ -97,9 +127,11 @@ export function getOpsxUpdateCommandTemplate() {
97
127
 
98
128
  ${STORE_SELECTION_GUIDANCE}
99
129
 
130
+ ${PROJECT_ROOT_GUARD}
131
+
100
132
  **Input**: Optionally specify a change name after \`/opsx:update\` (e.g., \`/opsx:update add-auth\`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
101
133
 
102
- \`/opsx:continue\` is an optional workflow and may not be installed. Before suggesting it anywhere below, verify that it is available. If it is unavailable, \`openspec status --change "<name>" --json\` shows the next artifact and \`openspec instructions "<artifact-id>" --change "<name>" --json\` explains how to create it.
134
+ ${CONTINUE_SCOPE_NOTE}
103
135
 
104
136
  **Steps**
105
137
 
@@ -112,7 +144,6 @@ ${STORE_SELECTION_GUIDANCE}
112
144
 
113
145
  When prompting, present the top 3-4 most recently modified changes as options, showing:
114
146
  - Change name
115
- - Schema (from \`schema\` field if present, otherwise "spec-driven")
116
147
  - Status (e.g., "0/5 tasks", "complete", "no tasks")
117
148
  - How recently it was modified (from \`lastModified\` field)
118
149
 
@@ -140,13 +171,20 @@ ${STORE_SELECTION_GUIDANCE}
140
171
 
141
172
  4. **Read and reconcile**
142
173
  - Read the artifact(s) the request touches and the change's other existing artifacts.
143
- - Apply the requested edit. Then check every other existing artifact against it - in ANY direction: an edit to a later artifact may require revising an earlier one, not only the other way around. Build order is a useful reading order, not a constraint on which artifacts may be revised.
174
+ - Draft the requested edit in the conversation, not in files. Work out exactly what it changes; step 5 owns every write. Then check every other existing artifact against the drafted edit - in ANY direction: an edit to a later artifact may require revising an earlier one, not only the other way around. Build order is a useful reading order, not a constraint on which artifacts may be revised.
144
175
  - Note everything that is now inconsistent, missing, or contradictory.
145
- - Revise only files that already exist (\`existingOutputPaths\`). Do NOT create artifacts that don't exist yet, and do NOT invent new files under a glob artifact - note them and point the user to \`/opsx:continue\` to create them.
146
- - If the change is already coherent, say so and make no edits.
176
+ - Propose revisions to files that already exist (\`existingOutputPaths\`). If an artifact has no existing output files and status \`ready\` or \`blocked\`, note it and ${CONTINUE_CREATE_THEM}. Leave \`skipped\` artifacts untouched; do not treat them as missing or defer them to the continue workflow.
177
+ - A glob artifact (e.g. \`specs/**/*.md\`) is marked \`done\` after at least one file matches, and the continue workflow only handles \`ready\` artifacts. When reconciliation identifies a missing file for a glob artifact whose \`existingOutputPaths\` is non-empty:
178
+ 1. Run \`openspec instructions "<artifact-id>" --change "<name>" --json\` and use its \`instruction\` and \`template\`. Treat \`context\` and \`rules\` as constraints; do not copy them into the file. If instructions report \`skipped: true\`, do not create the file. Read current dependency files from disk; if a required non-skipped dependency is missing, stop and ask the user to restore it first.
179
+ 2. Choose a concrete path inside \`changeRoot\` that matches \`artifactPaths.<id>.outputPath\` and does not already exist. Verify it remains inside \`changeRoot\` after resolving any symlinked parent directories. The glob \`resolvedOutputPath\` is not a valid target.
180
+ 3. Include the new file in step 5's proposed revisions and create it only after the user confirms.
181
+ 4. After confirmation, immediately before creation, refresh status and instructions. Verify the artifact is still in scope, not skipped, and partially populated; repeat the concrete-path checks above.
182
+ 5. Use a create operation that fails if the target already exists. If \`instruction\` delegates creation to another skill or command, invoke it only if it can honor the confirmed path and these guardrails; otherwise stop. If any check fails or the confirmed draft is no longer valid, stop and reconcile with the user rather than replacing existing content or choosing a different path.
183
+ - If the change is already coherent, say so and propose no revisions.
147
184
 
148
185
  5. **Confirm and apply, one artifact at a time**
149
- - Show each proposed revision and why. Write only after the user confirms.
186
+ - This step performs every artifact write in this workflow; no earlier step edits an artifact.
187
+ - Show each proposed revision and why - including the requested edit drafted in step 4. Write only after the user confirms.
150
188
  - If the user rejects a revision, do not write it - leave that artifact unchanged.
151
189
  - When a substantial rewrite is needed, get that artifact's rules and template first:
152
190
  \`\`\`bash
@@ -154,24 +192,25 @@ ${STORE_SELECTION_GUIDANCE}
154
192
  \`\`\`
155
193
 
156
194
  6. **Point to the next step (guidance only - NEVER act on it)**
157
- - Artifacts still missing -> suggest \`/opsx:continue\` to create them.
158
- - Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan; suggest \`/opsx:apply\` to carry the delta into code.
159
- - Everything done and implemented -> suggest \`/opsx:archive\`.
195
+ - Artifacts with empty \`existingOutputPaths\` and status \`ready\` or \`blocked\` -> ${CONTINUE_NEXT_STEP}.
196
+ - Change already implemented (tasks checked off / already applied) -> the code may no longer match the revised plan; ${APPLY_DELTA_HANDOFF}.
197
+ - Everything done and implemented -> ${ARCHIVE_HANDOFF}.
160
198
 
161
199
  **Output**
162
200
 
163
201
  After each invocation, show:
164
202
  - Which artifacts were revised (and which proposed revisions were rejected)
165
- - Anything deferred to \`/opsx:continue\` (not-yet-created artifacts or files)
203
+ - Any file created under a glob artifact that was already partially populated
204
+ - ${CONTINUE_DEFERRED}
166
205
  - Where the change stands and the recommended next command
167
206
 
168
207
  **Guardrails**
169
- - Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes, stop and point to \`/opsx:apply\`.
208
+ - Planning artifacts only - NEVER edit implementation code. If the revised plan implies code changes, ${APPLY_GUARDRAIL}.
170
209
  - Use the artifact ids and paths reported by \`openspec status\`; never branch on hardcoded artifact names.
171
210
  - Edit only the concrete files in \`existingOutputPaths\`; never write to a glob \`resolvedOutputPath\`.
172
- - Do not advance the build frontier: no new artifacts, no new files under glob artifacts - that is \`/opsx:continue\`'s job.
211
+ - Do not advance the build frontier: if an artifact has empty \`existingOutputPaths\` and status \`ready\` or \`blocked\`, ${CONTINUE_FRONTIER}. Leave \`skipped\` artifacts untouched. The only new-file scope is a confirmed concrete path under a glob artifact whose \`existingOutputPaths\` is non-empty.
173
212
  - Confirm every edit with the user before writing.
174
- - If the request changes the change's *intent* rather than refining it, first verify whether the optional \`/opsx:new\` workflow is available. If it is, recommend starting fresh with \`/opsx:new\` (the "Update vs. Start Fresh" heuristic). If it is unavailable, ask for a distinct unused change name and recommend \`openspec new change "<new-change-name>"\` instead.`
213
+ - If the request changes the change's *intent* rather than refining it, ${INTENT_CHANGE_GUARDRAIL}.`
175
214
  };
176
215
  }
177
216
  //# sourceMappingURL=update-change.js.map