@codewalla_india/openspec 1.3.1 → 1.3.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 (333) hide show
  1. package/LICENSE +22 -22
  2. package/README.md +272 -191
  3. package/bin/openspec.js +5 -5
  4. package/dist/cli/index.js +99 -62
  5. package/dist/commands/change.d.ts +0 -2
  6. package/dist/commands/change.js +107 -86
  7. package/dist/commands/config.js +14 -16
  8. package/dist/commands/doctor.js +9 -4
  9. package/dist/commands/feedback.js +79 -30
  10. package/dist/commands/modify.d.ts +26 -0
  11. package/dist/commands/modify.js +147 -0
  12. package/dist/commands/schema.js +170 -91
  13. package/dist/commands/show.js +5 -2
  14. package/dist/commands/spec.js +49 -29
  15. package/dist/commands/store.js +15 -21
  16. package/dist/commands/validate.d.ts +8 -0
  17. package/dist/commands/validate.js +43 -20
  18. package/dist/commands/workflow/index.d.ts +2 -2
  19. package/dist/commands/workflow/index.js +1 -1
  20. package/dist/commands/workflow/instructions.d.ts +6 -26
  21. package/dist/commands/workflow/instructions.js +183 -376
  22. package/dist/commands/workflow/new-change.d.ts +0 -4
  23. package/dist/commands/workflow/new-change.js +10 -28
  24. package/dist/commands/workflow/shared.d.ts +34 -19
  25. package/dist/commands/workflow/shared.js +34 -4
  26. package/dist/commands/workflow/status.js +10 -32
  27. package/dist/commands/workflow/templates.js +15 -5
  28. package/dist/commands/workset.d.ts +2 -2
  29. package/dist/commands/workset.js +19 -22
  30. package/dist/comprehension-quiz/fingerprint.d.ts +39 -0
  31. package/dist/comprehension-quiz/fingerprint.js +84 -0
  32. package/dist/comprehension-quiz/index.d.ts +42 -0
  33. package/dist/comprehension-quiz/index.js +47 -0
  34. package/dist/comprehension-quiz/pass-record.d.ts +44 -0
  35. package/dist/comprehension-quiz/pass-record.js +98 -0
  36. package/dist/comprehension-quiz/providers/anthropic.d.ts +34 -0
  37. package/dist/comprehension-quiz/providers/anthropic.js +53 -0
  38. package/dist/comprehension-quiz/providers/factory.d.ts +44 -0
  39. package/dist/comprehension-quiz/providers/factory.js +174 -0
  40. package/dist/comprehension-quiz/providers/interface.d.ts +59 -0
  41. package/dist/comprehension-quiz/providers/interface.js +63 -0
  42. package/dist/comprehension-quiz/providers/local.d.ts +34 -0
  43. package/dist/comprehension-quiz/providers/local.js +53 -0
  44. package/dist/comprehension-quiz/providers/ollama.d.ts +34 -0
  45. package/dist/comprehension-quiz/providers/ollama.js +53 -0
  46. package/dist/comprehension-quiz/providers/openai.d.ts +34 -0
  47. package/dist/comprehension-quiz/providers/openai.js +53 -0
  48. package/dist/comprehension-quiz/question-generator.d.ts +69 -0
  49. package/dist/comprehension-quiz/question-generator.js +141 -0
  50. package/dist/comprehension-quiz/quiz-executor.d.ts +70 -0
  51. package/dist/comprehension-quiz/quiz-executor.js +165 -0
  52. package/dist/comprehension-quiz/types.d.ts +115 -0
  53. package/dist/comprehension-quiz/types.js +11 -0
  54. package/dist/core/archive.d.ts +14 -1
  55. package/dist/core/archive.js +1350 -190
  56. package/dist/core/artifact-graph/graph.d.ts +28 -9
  57. package/dist/core/artifact-graph/graph.js +94 -43
  58. package/dist/core/artifact-graph/index.d.ts +1 -1
  59. package/dist/core/artifact-graph/index.js +1 -1
  60. package/dist/core/artifact-graph/instruction-loader.d.ts +30 -3
  61. package/dist/core/artifact-graph/instruction-loader.js +70 -12
  62. package/dist/core/artifact-graph/outputs.d.ts +1 -0
  63. package/dist/core/artifact-graph/outputs.js +67 -5
  64. package/dist/core/artifact-graph/resolver.d.ts +14 -0
  65. package/dist/core/artifact-graph/resolver.js +69 -15
  66. package/dist/core/artifact-graph/types.js +21 -3
  67. package/dist/core/available-tools.d.ts +2 -2
  68. package/dist/core/available-tools.js +14 -3
  69. package/dist/core/change-metadata/schema.d.ts +2 -0
  70. package/dist/core/change-metadata/schema.js +13 -0
  71. package/dist/core/change-status-policy.d.ts +10 -1
  72. package/dist/core/change-status-policy.js +30 -2
  73. package/dist/core/command-generation/adapters/amazon-q.d.ts +4 -0
  74. package/dist/core/command-generation/adapters/amazon-q.js +11 -5
  75. package/dist/core/command-generation/adapters/antigravity.js +6 -5
  76. package/dist/core/command-generation/adapters/auggie.js +7 -6
  77. package/dist/core/command-generation/adapters/bob.d.ts +5 -1
  78. package/dist/core/command-generation/adapters/bob.js +11 -10
  79. package/dist/core/command-generation/adapters/claude.d.ts +1 -1
  80. package/dist/core/command-generation/adapters/claude.js +12 -17
  81. package/dist/core/command-generation/adapters/cline.js +5 -5
  82. package/dist/core/command-generation/adapters/codebuddy.js +8 -7
  83. package/dist/core/command-generation/adapters/continue.js +8 -7
  84. package/dist/core/command-generation/adapters/costrict.js +7 -6
  85. package/dist/core/command-generation/adapters/crush.js +9 -9
  86. package/dist/core/command-generation/adapters/cursor.js +8 -8
  87. package/dist/core/command-generation/adapters/devin.d.ts +19 -0
  88. package/dist/core/command-generation/adapters/devin.js +36 -0
  89. package/dist/core/command-generation/adapters/factory.js +7 -6
  90. package/dist/core/command-generation/adapters/gemini.js +40 -5
  91. package/dist/core/command-generation/adapters/github-copilot.js +6 -5
  92. package/dist/core/command-generation/adapters/iflow.js +9 -8
  93. package/dist/core/command-generation/adapters/index.d.ts +4 -2
  94. package/dist/core/command-generation/adapters/index.js +4 -2
  95. package/dist/core/command-generation/adapters/junie.js +6 -5
  96. package/dist/core/command-generation/adapters/kilocode.js +1 -1
  97. package/dist/core/command-generation/adapters/kiro.js +6 -5
  98. package/dist/core/command-generation/adapters/lingma.js +9 -9
  99. package/dist/core/command-generation/adapters/oh-my-pi.d.ts +21 -0
  100. package/dist/core/command-generation/adapters/oh-my-pi.js +42 -0
  101. package/dist/core/command-generation/adapters/opencode.js +6 -8
  102. package/dist/core/command-generation/adapters/pi.d.ts +2 -2
  103. package/dist/core/command-generation/adapters/pi.js +7 -10
  104. package/dist/core/command-generation/adapters/qoder.js +9 -9
  105. package/dist/core/command-generation/adapters/qwen.d.ts +7 -3
  106. package/dist/core/command-generation/adapters/qwen.js +14 -9
  107. package/dist/core/command-generation/adapters/roocode.d.ts +4 -4
  108. package/dist/core/command-generation/adapters/roocode.js +9 -9
  109. package/dist/core/command-generation/adapters/trae.d.ts +13 -0
  110. package/dist/core/command-generation/adapters/trae.js +28 -0
  111. package/dist/core/command-generation/adapters/zcode.d.ts +16 -0
  112. package/dist/core/command-generation/adapters/zcode.js +33 -0
  113. package/dist/core/command-generation/generator.d.ts +8 -0
  114. package/dist/core/command-generation/generator.js +15 -1
  115. package/dist/core/command-generation/index.d.ts +1 -1
  116. package/dist/core/command-generation/index.js +1 -1
  117. package/dist/core/command-generation/invocation.d.ts +73 -0
  118. package/dist/core/command-generation/invocation.js +77 -0
  119. package/dist/core/command-generation/registry.js +8 -4
  120. package/dist/core/command-generation/types.d.ts +9 -2
  121. package/dist/core/command-generation/yaml.d.ts +20 -6
  122. package/dist/core/command-generation/yaml.js +31 -21
  123. package/dist/core/command-surface.d.ts +15 -0
  124. package/dist/core/command-surface.js +33 -0
  125. package/dist/core/completions/command-registry.js +16 -61
  126. package/dist/core/completions/generators/bash-generator.js +41 -41
  127. package/dist/core/completions/generators/fish-generator.js +7 -7
  128. package/dist/core/completions/generators/powershell-generator.js +44 -37
  129. package/dist/core/completions/generators/zsh-generator.js +33 -33
  130. package/dist/core/completions/installers/zsh-installer.d.ts +9 -0
  131. package/dist/core/completions/installers/zsh-installer.js +20 -4
  132. package/dist/core/completions/templates/bash-templates.js +24 -24
  133. package/dist/core/completions/templates/fish-templates.js +38 -38
  134. package/dist/core/completions/templates/powershell-templates.js +28 -28
  135. package/dist/core/completions/templates/zsh-templates.js +39 -39
  136. package/dist/core/config-prompts.d.ts +1 -1
  137. package/dist/core/config-prompts.js +14 -1
  138. package/dist/core/config-schema.d.ts +10 -1
  139. package/dist/core/config-schema.js +67 -1
  140. package/dist/core/config.d.ts +15 -0
  141. package/dist/core/config.js +46 -5
  142. package/dist/core/file-state.js +56 -24
  143. package/dist/core/github-copilot/cloud-agent.d.ts +95 -0
  144. package/dist/core/github-copilot/cloud-agent.js +497 -0
  145. package/dist/core/global-config.d.ts +16 -0
  146. package/dist/core/init.d.ts +58 -0
  147. package/dist/core/init.js +474 -73
  148. package/dist/core/legacy-cleanup.d.ts +59 -0
  149. package/dist/core/legacy-cleanup.js +253 -24
  150. package/dist/core/list.js +23 -16
  151. package/dist/core/migration.d.ts +73 -1
  152. package/dist/core/migration.js +360 -11
  153. package/dist/core/modify/conflict-detector.d.ts +26 -0
  154. package/dist/core/modify/conflict-detector.js +62 -0
  155. package/dist/core/modify/dependency-propagator.d.ts +38 -0
  156. package/dist/core/modify/dependency-propagator.js +103 -0
  157. package/dist/core/modify/history-tracker.d.ts +34 -0
  158. package/dist/core/modify/history-tracker.js +114 -0
  159. package/dist/core/modify/index.d.ts +7 -0
  160. package/dist/core/modify/index.js +7 -0
  161. package/dist/core/onboarding-commands.d.ts +30 -0
  162. package/dist/core/onboarding-commands.js +38 -0
  163. package/dist/core/openspec-root.js +18 -15
  164. package/dist/core/parsers/change-parser.d.ts +17 -2
  165. package/dist/core/parsers/change-parser.js +35 -21
  166. package/dist/core/parsers/code-fence.d.ts +15 -0
  167. package/dist/core/parsers/code-fence.js +49 -0
  168. package/dist/core/parsers/markdown-parser.d.ts +0 -3
  169. package/dist/core/parsers/markdown-parser.js +7 -60
  170. package/dist/core/parsers/requirement-blocks.d.ts +29 -0
  171. package/dist/core/parsers/requirement-blocks.js +150 -31
  172. package/dist/core/parsers/requirement-text.d.ts +48 -0
  173. package/dist/core/parsers/requirement-text.js +98 -0
  174. package/dist/core/parsers/spec-structure.d.ts +1 -1
  175. package/dist/core/parsers/spec-structure.js +20 -30
  176. package/dist/core/profile-sync-drift.d.ts +0 -8
  177. package/dist/core/profile-sync-drift.js +49 -50
  178. package/dist/core/profiles.d.ts +2 -2
  179. package/dist/core/profiles.js +2 -2
  180. package/dist/core/project-config.d.ts +27 -18
  181. package/dist/core/project-config.js +101 -34
  182. package/dist/core/references.js +42 -4
  183. package/dist/core/relationship-health.d.ts +8 -0
  184. package/dist/core/relationship-health.js +13 -0
  185. package/dist/core/root-selection.d.ts +9 -6
  186. package/dist/core/root-selection.js +42 -5
  187. package/dist/core/schemas/base.schema.js +7 -2
  188. package/dist/core/shared/allowed-tools.d.ts +12 -0
  189. package/dist/core/shared/allowed-tools.js +12 -0
  190. package/dist/core/shared/index.d.ts +1 -0
  191. package/dist/core/shared/index.js +1 -0
  192. package/dist/core/shared/skill-content-equivalence.d.ts +7 -0
  193. package/dist/core/shared/skill-content-equivalence.js +41 -0
  194. package/dist/core/shared/skill-generation.js +17 -13
  195. package/dist/core/shared/skill-paths.d.ts +13 -0
  196. package/dist/core/shared/skill-paths.js +23 -0
  197. package/dist/core/shared/tool-detection.d.ts +27 -7
  198. package/dist/core/shared/tool-detection.js +167 -37
  199. package/dist/core/shared-skill-target.d.ts +16 -0
  200. package/dist/core/shared-skill-target.js +156 -0
  201. package/dist/core/specs-apply.d.ts +80 -33
  202. package/dist/core/specs-apply.js +667 -145
  203. package/dist/core/store/git.d.ts +13 -0
  204. package/dist/core/store/git.js +24 -0
  205. package/dist/core/store/operations.js +20 -0
  206. package/dist/core/templates/skill-templates.d.ts +3 -2
  207. package/dist/core/templates/skill-templates.js +3 -2
  208. package/dist/core/templates/workflows/apply-change.d.ts +10 -0
  209. package/dist/core/templates/workflows/apply-change.js +186 -224
  210. package/dist/core/templates/workflows/archive-change.js +387 -260
  211. package/dist/core/templates/workflows/bulk-archive-change.js +655 -475
  212. package/dist/core/templates/workflows/continue-change.js +210 -219
  213. package/dist/core/templates/workflows/explore.js +479 -443
  214. package/dist/core/templates/workflows/feedback.js +97 -97
  215. package/dist/core/templates/workflows/ff-change.js +200 -191
  216. package/dist/core/templates/workflows/modify-change.d.ts +4 -1
  217. package/dist/core/templates/workflows/modify-change.js +237 -115
  218. package/dist/core/templates/workflows/new-change.js +127 -134
  219. package/dist/core/templates/workflows/onboard.js +548 -542
  220. package/dist/core/templates/workflows/propose.js +273 -217
  221. package/dist/core/templates/workflows/store-selection.d.ts +1 -1
  222. package/dist/core/templates/workflows/store-selection.js +1 -1
  223. package/dist/core/templates/workflows/sync-specs.js +500 -273
  224. package/dist/core/templates/workflows/update-change.d.ts +10 -0
  225. package/dist/core/templates/workflows/update-change.js +177 -0
  226. package/dist/core/templates/workflows/verify-change.js +324 -326
  227. package/dist/core/update.d.ts +40 -5
  228. package/dist/core/update.js +411 -96
  229. package/dist/core/validation/constants.d.ts +4 -1
  230. package/dist/core/validation/constants.js +4 -1
  231. package/dist/core/validation/plan-validator.d.ts +8 -0
  232. package/dist/core/validation/plan-validator.js +45 -0
  233. package/dist/core/validation/task-numbering.d.ts +16 -0
  234. package/dist/core/validation/task-numbering.js +57 -0
  235. package/dist/core/validation/validator.d.ts +27 -3
  236. package/dist/core/validation/validator.js +337 -48
  237. package/dist/core/version-check.d.ts +152 -0
  238. package/dist/core/version-check.js +731 -0
  239. package/dist/core/view.js +13 -18
  240. package/dist/prompts/searchable-multi-select.js +1 -1
  241. package/dist/telemetry/caller-detection.d.ts +27 -0
  242. package/dist/telemetry/caller-detection.js +85 -0
  243. package/dist/telemetry/caller-detection.test.d.ts +5 -0
  244. package/dist/telemetry/config.d.ts +48 -2
  245. package/dist/telemetry/config.js +113 -11
  246. package/dist/telemetry/config.test.d.ts +5 -0
  247. package/dist/telemetry/deduplication.d.ts +35 -0
  248. package/dist/telemetry/deduplication.js +82 -0
  249. package/dist/telemetry/deduplication.test.d.ts +5 -0
  250. package/dist/telemetry/identity.d.ts +62 -22
  251. package/dist/telemetry/identity.js +147 -102
  252. package/dist/telemetry/index.d.ts +126 -15
  253. package/dist/telemetry/index.js +569 -37
  254. package/dist/telemetry/sanitization.d.ts +40 -0
  255. package/dist/telemetry/sanitization.js +114 -0
  256. package/dist/telemetry/sanitization.test.d.ts +5 -0
  257. package/dist/telemetry/throttling.d.ts +20 -0
  258. package/dist/telemetry/throttling.js +70 -0
  259. package/dist/ui/welcome-screen.d.ts +9 -1
  260. package/dist/ui/welcome-screen.js +91 -38
  261. package/dist/utils/change-metadata.d.ts +43 -0
  262. package/dist/utils/change-metadata.js +123 -7
  263. package/dist/utils/change-utils.d.ts +10 -4
  264. package/dist/utils/change-utils.js +20 -13
  265. package/dist/utils/ci.d.ts +12 -0
  266. package/dist/utils/ci.js +16 -0
  267. package/dist/utils/command-references.d.ts +92 -6
  268. package/dist/utils/command-references.js +180 -7
  269. package/dist/utils/date.d.ts +8 -0
  270. package/dist/utils/date.js +13 -0
  271. package/dist/utils/file-system.d.ts +10 -0
  272. package/dist/utils/file-system.js +70 -0
  273. package/dist/utils/index.d.ts +1 -1
  274. package/dist/utils/index.js +1 -1
  275. package/dist/utils/interactive.d.ts +23 -0
  276. package/dist/utils/interactive.js +32 -0
  277. package/dist/utils/item-discovery.d.ts +19 -0
  278. package/dist/utils/item-discovery.js +30 -48
  279. package/dist/utils/shell-detection.d.ts +1 -1
  280. package/dist/utils/shell-detection.js +64 -11
  281. package/dist/utils/spec-discovery.d.ts +40 -0
  282. package/dist/utils/spec-discovery.js +115 -0
  283. package/dist/utils/task-progress.d.ts +29 -1
  284. package/dist/utils/task-progress.js +109 -15
  285. package/package.json +96 -84
  286. package/schemas/spec-driven/schema.yaml +252 -184
  287. package/schemas/spec-driven/templates/design.md +19 -19
  288. package/schemas/spec-driven/templates/plan-template.md +91 -0
  289. package/schemas/spec-driven/templates/proposal.md +29 -24
  290. package/schemas/spec-driven/templates/spec.md +11 -8
  291. package/schemas/spec-driven/templates/tasks.md +9 -9
  292. package/scripts/postinstall.js +83 -83
  293. package/dist/core/command-generation/adapters/codex.d.ts +0 -16
  294. package/dist/core/command-generation/adapters/codex.js +0 -39
  295. package/dist/core/command-generation/adapters/windsurf.d.ts +0 -14
  296. package/dist/core/command-generation/adapters/windsurf.js +0 -38
  297. package/dist/core/comprehension/config.d.ts +0 -20
  298. package/dist/core/comprehension/config.js +0 -23
  299. package/dist/core/comprehension/fingerprint.d.ts +0 -14
  300. package/dist/core/comprehension/fingerprint.js +0 -33
  301. package/dist/core/comprehension/index.d.ts +0 -57
  302. package/dist/core/comprehension/index.js +0 -87
  303. package/dist/core/comprehension/pass-record.d.ts +0 -29
  304. package/dist/core/comprehension/pass-record.js +0 -64
  305. package/dist/core/comprehension/stats.d.ts +0 -35
  306. package/dist/core/comprehension/stats.js +0 -133
  307. package/dist/core/templates/workflows/comprehension-guidance.d.ts +0 -9
  308. package/dist/core/templates/workflows/comprehension-guidance.js +0 -73
  309. package/dist/core/templates/workflows/mcp-guidance.d.ts +0 -13
  310. package/dist/core/templates/workflows/mcp-guidance.js +0 -131
  311. package/dist/core/templates/workflows/user-prompt-guidance.d.ts +0 -16
  312. package/dist/core/templates/workflows/user-prompt-guidance.js +0 -48
  313. package/dist/telemetry/caller.d.ts +0 -5
  314. package/dist/telemetry/caller.js +0 -29
  315. package/dist/telemetry/client.d.ts +0 -27
  316. package/dist/telemetry/client.js +0 -127
  317. package/dist/telemetry/command-context.d.ts +0 -13
  318. package/dist/telemetry/command-context.js +0 -59
  319. package/dist/telemetry/comprehension.d.ts +0 -44
  320. package/dist/telemetry/comprehension.js +0 -105
  321. package/dist/telemetry/content.d.ts +0 -10
  322. package/dist/telemetry/content.js +0 -56
  323. package/dist/telemetry/git-stats.d.ts +0 -12
  324. package/dist/telemetry/git-stats.js +0 -69
  325. package/dist/telemetry/identify-cache.d.ts +0 -7
  326. package/dist/telemetry/identify-cache.js +0 -47
  327. package/dist/telemetry/input.d.ts +0 -17
  328. package/dist/telemetry/input.js +0 -68
  329. package/dist/telemetry/marker.d.ts +0 -37
  330. package/dist/telemetry/marker.js +0 -67
  331. package/dist/telemetry/workflow.d.ts +0 -85
  332. package/dist/telemetry/workflow.js +0 -318
  333. package/schemas/spec-driven/templates/plan.md +0 -19
@@ -1,145 +1,258 @@
1
1
  import { STORE_SELECTION_GUIDANCE } from './store-selection.js';
2
- import { PROMPT_SELECT_CHANGE } from './user-prompt-guidance.js';
3
2
  export function getSyncSpecsSkillTemplate() {
4
3
  return {
5
4
  name: 'openspec-sync-specs',
6
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.',
7
- instructions: `Sync delta specs from a change to main specs.
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).
10
-
11
- ${STORE_SELECTION_GUIDANCE}
12
-
13
- **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.
14
-
15
- **Steps**
16
-
17
- 1. **If no change name provided, prompt for selection**
18
-
19
- ${PROMPT_SELECT_CHANGE}
20
-
21
- Show changes that have delta specs (under \`specs/\` directory).
22
-
23
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
24
-
25
- 2. **Resolve change context**
26
-
27
- Run:
28
- \`\`\`bash
29
- openspec status --change "<name>" --json
30
- \`\`\`
31
-
32
- 3. **Find delta specs**
33
-
34
- Use \`artifactPaths.specs.existingOutputPaths\` from the status JSON as the list of delta spec files.
35
-
36
- Each delta spec file contains sections like:
37
- - \`## ADDED Requirements\` - New requirements to add
38
- - \`## MODIFIED Requirements\` - Changes to existing requirements
39
- - \`## REMOVED Requirements\` - Requirements to remove
40
- - \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
41
-
42
- If no delta specs found, inform user and stop.
43
-
44
- 4. **For each delta spec, apply changes to main specs**
45
-
46
- For each repo-local capability delta spec path returned by the CLI:
47
-
48
- a. **Read the delta spec** to understand the intended changes
49
-
50
- b. **Read the main spec** at \`openspec/specs/<capability>/spec.md\` (may not exist yet)
51
-
52
- c. **Apply changes intelligently**:
53
-
54
- **ADDED Requirements:**
55
- - If requirement doesn't exist in main spec add it
56
- - If requirement already exists update it to match (treat as implicit MODIFIED)
57
-
58
- **MODIFIED Requirements:**
59
- - Find the requirement in main spec
60
- - Apply the changes - this can be:
61
- - Adding new scenarios (don't need to copy existing ones)
62
- - Modifying existing scenarios
63
- - Changing the requirement description
64
- - Preserve scenarios/content not mentioned in the delta
65
-
66
- **REMOVED Requirements:**
67
- - Remove the entire requirement block from main spec
68
-
69
- **RENAMED Requirements:**
70
- - Find the FROM requirement, rename to TO
71
-
72
- d. **Create new main spec** if capability doesn't exist yet:
73
- - Create \`openspec/specs/<capability>/spec.md\`
74
- - Add Purpose section (can be brief, mark as TBD)
75
- - Add Requirements section with the ADDED requirements
76
-
77
- 5. **Show summary**
78
-
79
- After applying all changes, summarize:
80
- - Which capabilities were updated
81
- - What changes were made (requirements added/modified/removed/renamed)
82
-
83
- **Delta Spec Format Reference**
84
-
85
- \`\`\`markdown
86
- ## ADDED Requirements
87
-
88
- ### Requirement: New Feature
89
- The system SHALL do something new.
90
-
91
- #### Scenario: Basic case
92
- - **WHEN** user does X
93
- - **THEN** system does Y
94
-
95
- ## MODIFIED Requirements
96
-
97
- ### Requirement: Existing Feature
98
- #### Scenario: New scenario to add
99
- - **WHEN** user does A
100
- - **THEN** system does B
101
-
102
- ## REMOVED Requirements
103
-
104
- ### Requirement: Deprecated Feature
105
-
106
- ## RENAMED Requirements
107
-
108
- - FROM: \`### Requirement: Old Name\`
109
- - TO: \`### Requirement: New Name\`
110
- \`\`\`
111
-
112
- **Key Principle: Intelligent Merging**
113
-
114
- Unlike programmatic merging, you can apply **partial updates**:
115
- - To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios
116
- - The delta represents *intent*, not a wholesale replacement
117
- - Use your judgment to merge changes sensibly
118
-
119
- **Output On Success**
120
-
121
- \`\`\`
122
- ## Specs Synced: <change-name>
123
-
124
- Updated main specs:
125
-
126
- **<capability-1>**:
127
- - Added requirement: "New Feature"
128
- - Modified requirement: "Existing Feature" (added 1 scenario)
129
-
130
- **<capability-2>**:
131
- - Created new spec file
132
- - Added requirement: "Another Feature"
133
-
134
- Main specs are now updated. The change remains active - archive when implementation is complete.
135
- \`\`\`
136
-
137
- **Guardrails**
138
- - Read both delta and main specs before making changes
139
- - Preserve existing content not mentioned in delta
140
- - If something is unclear, ask for clarification
141
- - Show what you're changing as you go
142
- - The operation should be idempotent - running twice should give same result`,
6
+ instructions: `Sync delta specs from a change to main specs.
7
+
8
+ 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
+ ${STORE_SELECTION_GUIDANCE}
11
+
12
+ \`<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
+
14
+ **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.
15
+
16
+ **Steps**
17
+
18
+ 1. **Select the change**
19
+
20
+ If a name is provided, use it. Otherwise:
21
+ - Infer from conversation context if the user mentioned a change
22
+ - Auto-select if only one active change exists
23
+ - If ambiguous, run \`openspec list --json\` to get available changes and ask the user to select one
24
+
25
+ When prompting, show changes that have delta specs (under \`specs/\` directory).
26
+
27
+ Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:sync <other>\`).
28
+
29
+ 2. **Resolve change context**
30
+
31
+ Run:
32
+ \`\`\`bash
33
+ openspec status --change "<name>" --json
34
+ \`\`\`
35
+
36
+ The JSON includes \`planningHome.root\`. Main specs live under \`<planningHome.root>/openspec/specs/\` — use that (store-aware) root for every main-spec path below, not a hardcoded repo path. When a store is selected it points at the store, not the current repository.
37
+
38
+ 3. **Find delta specs**
39
+
40
+ Use \`artifactPaths.specs.existingOutputPaths\` from the status JSON as the
41
+ only source of delta spec paths. If the \`specs\` entry is missing or
42
+ \`existingOutputPaths\` is empty, report that there are no delta specs to sync,
43
+ do not infer them from other artifacts, and stop without requesting artifact
44
+ instructions or writing a main spec.
45
+
46
+ Sync every path in \`existingOutputPaths\` unless the caller narrowed the set.
47
+ A caller narrows it by naming an explicit list of complete entries from
48
+ \`existingOutputPaths\` — copy those absolute values verbatim. Archive does
49
+ this inline, and a user can too (for example, by selecting the entry ending
50
+ in \`/specs/billing/invoices/spec.md\`).
51
+ Then sync only the named paths and leave the remaining delta specs untouched:
52
+ bulk archive excludes a delta whose implementation it could not find, and
53
+ syncing it anyway would write a main spec the caller deliberately withheld.
54
+ Carry that narrowed selection through step 4; never widen it back to the full
55
+ list. If a named path is not in \`existingOutputPaths\`, do not sync it
56
+ report it and stop, rather than dropping it silently. If the named list is
57
+ empty, report that there is nothing to sync and stop without writing a main
58
+ spec.
59
+
60
+ Each delta spec file contains sections like:
61
+ - \`## ADDED Requirements\` - New requirements to add
62
+ - \`## MODIFIED Requirements\` - Changes to existing requirements
63
+ - \`## REMOVED Requirements\` - Requirements to remove
64
+ - \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
65
+
66
+ If no delta specs found, inform user and stop.
67
+
68
+ 4. **For each delta spec, apply changes to main specs**
69
+
70
+ Before the first main-spec write, obtain one current specs-rule snapshot:
71
+ - If archive invoked this workflow inline and supplied a valid snapshot from
72
+ \`openspec instructions specs --change "<name>" --json\`, reuse it and do not
73
+ fetch the same instructions again.
74
+ - Otherwise run that command once now with the same selected-root flags.
75
+ - If the direct lookup exits non-zero or returns invalid artifact-instruction
76
+ JSON, report the error and stop before writing any main spec. Do not treat the
77
+ failure as an absent rule set.
78
+ - A valid response with omitted \`rules\` means no artifact rules are configured
79
+ and the existing semantic merge continues.
80
+
81
+ Apply returned \`rules\` only to the content and form of the main specs produced
82
+ by this merge. Artifact rules are not operation guidance and cannot change
83
+ selected roots, delta paths, CLI checks, or workflow steps. Use their text as
84
+ constraints without copying it verbatim into a main spec or summary.
85
+
86
+ For each capability delta spec path selected in step 3 — the full \`existingOutputPaths\` list, or the narrowed subset when a caller supplied one (these may belong to a selected store, not the repo):
87
+
88
+ a. **Read the delta spec** to understand the intended changes
89
+
90
+ b. **Read the main spec** at \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\` (may not exist yet)
91
+
92
+ c. **Apply changes intelligently**:
93
+
94
+ **ADDED Requirements:**
95
+ - If requirement doesn't exist in main spec → add it
96
+ - If requirement already exists → update it to match (treat as implicit MODIFIED)
97
+
98
+ **MODIFIED Requirements:**
99
+ - Find the requirement in main spec
100
+ - Apply the changes - this can be:
101
+ - Adding new scenarios the main spec does not have yet
102
+ - Modifying existing scenarios
103
+ - Changing the requirement description
104
+ - Preserve scenarios/content not mentioned in the delta
105
+
106
+ **REMOVED Requirements:**
107
+ - Remove the entire requirement block from main spec
108
+ - Retiring the capability. Delete the whole \`spec.md\` - and the directory once
109
+ nothing else is left in it - only when ALL of these hold:
110
+ 1. removing the requirements *this run* left no requirement blocks;
111
+ 2. the rest of the spec is well-formed (it still has a \`## Purpose\`);
112
+ 3. the main spec was not already empty before this sync - if you removed
113
+ nothing, change nothing;
114
+ 4. every other nonblank line in the whole file is accounted for as the
115
+ title, Purpose, Requirements header, or a canonical requirement's
116
+ statement, scenarios, or fenced examples;
117
+ 5. the change's \`.openspec.yaml\` declares \`retire_capabilities: true\`;
118
+ 6. the \`spec.md\` resolves inside the real specs root (do not follow a
119
+ capability-directory symlink to delete an external file).
120
+ If removing the selected requirements would leave no requirement blocks and
121
+ any retirement condition is not satisfied, do not modify the main spec. Stop
122
+ the sync for that capability, report the blocking condition, and tell the user
123
+ how to resolve it. Never write or leave an empty \`## Requirements\` section.
124
+ When only the marker is missing, say that too - it is the one thing the user
125
+ can add to make the retirement go through.
126
+ - Deleting the file also deletes its \`## Purpose\`; any other section blocks
127
+ retirement. Name Purpose when you report the retirement. Include a pasteable
128
+ \`git checkout\` only when the spec lived in the caller's checkout;
129
+ otherwise give checkout-scoped recovery guidance.
130
+
131
+ **RENAMED Requirements:**
132
+ - Find the FROM requirement, rename to TO
133
+
134
+ **\`## Purpose\` in the delta:**
135
+ - The main spec already has one and it is authoritative - leave it alone
136
+ (this is what \`openspec archive\` does; it warns and moves on)
137
+
138
+ d. **Create new main spec** if capability doesn't exist yet:
139
+ - Create \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\`
140
+ - Add Purpose section: copy the delta's \`## Purpose\` body verbatim when it has one
141
+ (this is what \`openspec archive\` does); only write a brief TBD placeholder when it does not
142
+ - Add Requirements section with the ADDED requirements
143
+ - Follow the **Main Spec Format Reference** below
144
+
145
+ 5. **Validate updated main specs**
146
+
147
+ Run \`openspec validate --specs\` with the same selected-root flags used earlier.
148
+ If validation fails, report the problems and do not claim the sync succeeded.
149
+
150
+ 6. **Show summary**
151
+
152
+ After applying all changes, summarize:
153
+ - Which capabilities were updated
154
+ - What changes were made (requirements added/modified/removed/renamed)
155
+ - Any new main spec left with a TBD Purpose placeholder, so it gets written
156
+ now rather than lingering
157
+ - Any capability retired, naming the deleted \`spec.md\`, its Purpose, and
158
+ either a pasteable \`git checkout\` or checkout-scoped recovery guidance
159
+
160
+ **Delta Spec Format Reference**
161
+
162
+ \`\`\`markdown
163
+ ## Purpose
164
+
165
+ Only on a delta that introduces a brand-new capability. Seeds the new main spec.
166
+
167
+ ## ADDED Requirements
168
+
169
+ ### Requirement: New Feature
170
+ The system SHALL do something new.
171
+
172
+ #### Scenario: Basic case
173
+ - **WHEN** user does X
174
+ - **THEN** system does Y
175
+
176
+ ## MODIFIED Requirements
177
+
178
+ ### Requirement: Existing Feature
179
+ The system SHALL keep doing the existing thing, now also handling A.
180
+
181
+ #### Scenario: Scenario the main spec already has
182
+ - **WHEN** user does X
183
+ - **THEN** system does Y
184
+
185
+ #### Scenario: New scenario to add
186
+ - **WHEN** user does A
187
+ - **THEN** system does B
188
+
189
+ ## REMOVED Requirements
190
+
191
+ ### Requirement: Deprecated Feature
192
+
193
+ ## RENAMED Requirements
194
+
195
+ - FROM: \`### Requirement: Old Name\`
196
+ - TO: \`### Requirement: New Name\`
197
+ \`\`\`
198
+
199
+ **Main Spec Format Reference**
200
+
201
+ Main specs are what the delta merges INTO. They must never contain delta operation headers (\`## ADDED/MODIFIED/REMOVED/RENAMED Requirements\`) - after syncing, every requirement lives under a single \`## Requirements\` section:
202
+
203
+ \`\`\`markdown
204
+ # <capability> Specification
205
+
206
+ ## Purpose
207
+ Short description of what this capability does and why it exists.
208
+
209
+ ## Requirements
210
+
211
+ ### Requirement: New Feature
212
+ The system SHALL do something new.
213
+
214
+ #### Scenario: Basic case
215
+ - **WHEN** user does X
216
+ - **THEN** system does Y
217
+ \`\`\`
218
+
219
+ **Key Principle: Intelligent Merging**
220
+
221
+ Unlike programmatic merging, you merge rather than overwrite:
222
+ - A MODIFIED block carries the whole requirement - body plus every scenario that survives the change. \`openspec validate\` and \`openspec archive\` both reject one that drops a scenario the main spec still has.
223
+ - Keep anything the delta does not mention, in the main spec's existing order
224
+ - Use your judgment to merge changes sensibly
225
+
226
+ **Output On Success**
227
+
228
+ \`\`\`markdown
229
+ ## Specs Synced: <change-name>
230
+
231
+ Updated main specs:
232
+
233
+ **<capability-1>**:
234
+ - Added requirement: "New Feature"
235
+ - Modified requirement: "Existing Feature" (added 1 scenario)
236
+
237
+ **<capability-2>**:
238
+ - Created new spec file
239
+ - Added requirement: "Another Feature"
240
+
241
+ Main specs are now updated. The change remains active - archive when implementation is complete.
242
+ \`\`\`
243
+
244
+ **Guardrails**
245
+ - Read both delta and main specs before making changes
246
+ - Preserve existing content not mentioned in delta
247
+ - Never copy a delta file into a main spec as-is - merge its content so the main spec keeps the Main Spec Format Reference structure, with no delta operation headers
248
+ - If something is unclear, ask for clarification
249
+ - Show what you're changing as you go
250
+ - The operation should be idempotent - running twice should give same result
251
+ - Use only \`artifactPaths.specs.existingOutputPaths\`; never infer delta specs from unrelated artifacts
252
+ - Honor a caller-supplied subset of \`existingOutputPaths\`; never widen it back to the full list
253
+ - Fetch specs instructions once for direct sync, or reuse the archive-supplied snapshot inline
254
+ - Stop before every main-spec write on a non-zero or invalid JSON specs-instruction response
255
+ - Artifact rules constrain only the specs being written and are never copied into output files`,
143
256
  license: 'MIT',
144
257
  compatibility: 'Requires openspec CLI.',
145
258
  metadata: { author: 'openspec', version: '1.0' },
@@ -151,142 +264,256 @@ export function getOpsxSyncCommandTemplate() {
151
264
  description: 'Sync delta specs from a change to main specs',
152
265
  category: 'Workflow',
153
266
  tags: ['workflow', 'specs', 'experimental'],
154
- content: `Sync delta specs from a change to main specs.
155
-
156
- 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).
157
-
158
- ${STORE_SELECTION_GUIDANCE}
159
-
160
- **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.
161
-
162
- **Steps**
163
-
164
- 1. **If no change name provided, prompt for selection**
165
-
166
- ${PROMPT_SELECT_CHANGE}
167
-
168
- Show changes that have delta specs (under \`specs/\` directory).
169
-
170
- **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
171
-
172
- 2. **Resolve change context**
173
-
174
- Run:
175
- \`\`\`bash
176
- openspec status --change "<name>" --json
177
- \`\`\`
178
-
179
- 3. **Find delta specs**
180
-
181
- Use \`artifactPaths.specs.existingOutputPaths\` from the status JSON as the list of delta spec files.
182
-
183
- Each delta spec file contains sections like:
184
- - \`## ADDED Requirements\` - New requirements to add
185
- - \`## MODIFIED Requirements\` - Changes to existing requirements
186
- - \`## REMOVED Requirements\` - Requirements to remove
187
- - \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
188
-
189
- If no delta specs found, inform user and stop.
190
-
191
- 4. **For each delta spec, apply changes to main specs**
192
-
193
- For each repo-local capability delta spec path returned by the CLI:
194
-
195
- a. **Read the delta spec** to understand the intended changes
196
-
197
- b. **Read the main spec** at \`openspec/specs/<capability>/spec.md\` (may not exist yet)
198
-
199
- c. **Apply changes intelligently**:
200
-
201
- **ADDED Requirements:**
202
- - If requirement doesn't exist in main spec add it
203
- - If requirement already exists update it to match (treat as implicit MODIFIED)
204
-
205
- **MODIFIED Requirements:**
206
- - Find the requirement in main spec
207
- - Apply the changes - this can be:
208
- - Adding new scenarios (don't need to copy existing ones)
209
- - Modifying existing scenarios
210
- - Changing the requirement description
211
- - Preserve scenarios/content not mentioned in the delta
212
-
213
- **REMOVED Requirements:**
214
- - Remove the entire requirement block from main spec
215
-
216
- **RENAMED Requirements:**
217
- - Find the FROM requirement, rename to TO
218
-
219
- d. **Create new main spec** if capability doesn't exist yet:
220
- - Create \`openspec/specs/<capability>/spec.md\`
221
- - Add Purpose section (can be brief, mark as TBD)
222
- - Add Requirements section with the ADDED requirements
223
-
224
- 5. **Show summary**
225
-
226
- After applying all changes, summarize:
227
- - Which capabilities were updated
228
- - What changes were made (requirements added/modified/removed/renamed)
229
-
230
- **Delta Spec Format Reference**
231
-
232
- \`\`\`markdown
233
- ## ADDED Requirements
234
-
235
- ### Requirement: New Feature
236
- The system SHALL do something new.
237
-
238
- #### Scenario: Basic case
239
- - **WHEN** user does X
240
- - **THEN** system does Y
241
-
242
- ## MODIFIED Requirements
243
-
244
- ### Requirement: Existing Feature
245
- #### Scenario: New scenario to add
246
- - **WHEN** user does A
247
- - **THEN** system does B
248
-
249
- ## REMOVED Requirements
250
-
251
- ### Requirement: Deprecated Feature
252
-
253
- ## RENAMED Requirements
254
-
255
- - FROM: \`### Requirement: Old Name\`
256
- - TO: \`### Requirement: New Name\`
257
- \`\`\`
258
-
259
- **Key Principle: Intelligent Merging**
260
-
261
- Unlike programmatic merging, you can apply **partial updates**:
262
- - To add a scenario, just include that scenario under MODIFIED - don't copy existing scenarios
263
- - The delta represents *intent*, not a wholesale replacement
264
- - Use your judgment to merge changes sensibly
265
-
266
- **Output On Success**
267
-
268
- \`\`\`
269
- ## Specs Synced: <change-name>
270
-
271
- Updated main specs:
272
-
273
- **<capability-1>**:
274
- - Added requirement: "New Feature"
275
- - Modified requirement: "Existing Feature" (added 1 scenario)
276
-
277
- **<capability-2>**:
278
- - Created new spec file
279
- - Added requirement: "Another Feature"
280
-
281
- Main specs are now updated. The change remains active - archive when implementation is complete.
282
- \`\`\`
283
-
284
- **Guardrails**
285
- - Read both delta and main specs before making changes
286
- - Preserve existing content not mentioned in delta
287
- - If something is unclear, ask for clarification
288
- - Show what you're changing as you go
289
- - The operation should be idempotent - running twice should give same result`
267
+ content: `Sync delta specs from a change to main specs.
268
+
269
+ 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).
270
+
271
+ ${STORE_SELECTION_GUIDANCE}
272
+
273
+ \`<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
+
275
+ **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.
276
+
277
+ **Steps**
278
+
279
+ 1. **Select the change**
280
+
281
+ If a name is provided, use it. Otherwise:
282
+ - Infer from conversation context if the user mentioned a change
283
+ - Auto-select if only one active change exists
284
+ - If ambiguous, run \`openspec list --json\` to get available changes and ask the user to select one
285
+
286
+ When prompting, show changes that have delta specs (under \`specs/\` directory).
287
+
288
+ Always announce: "Using change: <name>" and how to override (e.g., \`/opsx:sync <other>\`).
289
+
290
+ 2. **Resolve change context**
291
+
292
+ Run:
293
+ \`\`\`bash
294
+ openspec status --change "<name>" --json
295
+ \`\`\`
296
+
297
+ The JSON includes \`planningHome.root\`. Main specs live under \`<planningHome.root>/openspec/specs/\` — use that (store-aware) root for every main-spec path below, not a hardcoded repo path. When a store is selected it points at the store, not the current repository.
298
+
299
+ 3. **Find delta specs**
300
+
301
+ Use \`artifactPaths.specs.existingOutputPaths\` from the status JSON as the
302
+ only source of delta spec paths. If the \`specs\` entry is missing or
303
+ \`existingOutputPaths\` is empty, report that there are no delta specs to sync,
304
+ do not infer them from other artifacts, and stop without requesting artifact
305
+ instructions or writing a main spec.
306
+
307
+ Sync every path in \`existingOutputPaths\` unless the caller narrowed the set.
308
+ A caller narrows it by naming an explicit list of complete entries from
309
+ \`existingOutputPaths\` — copy those absolute values verbatim. Archive does
310
+ this inline, and a user can too (for example, by selecting the entry ending
311
+ in \`/specs/billing/invoices/spec.md\`).
312
+ Then sync only the named paths and leave the remaining delta specs untouched:
313
+ bulk archive excludes a delta whose implementation it could not find, and
314
+ syncing it anyway would write a main spec the caller deliberately withheld.
315
+ Carry that narrowed selection through step 4; never widen it back to the full
316
+ list. If a named path is not in \`existingOutputPaths\`, do not sync it
317
+ report it and stop, rather than dropping it silently. If the named list is
318
+ empty, report that there is nothing to sync and stop without writing a main
319
+ spec.
320
+
321
+ Each delta spec file contains sections like:
322
+ - \`## ADDED Requirements\` - New requirements to add
323
+ - \`## MODIFIED Requirements\` - Changes to existing requirements
324
+ - \`## REMOVED Requirements\` - Requirements to remove
325
+ - \`## RENAMED Requirements\` - Requirements to rename (FROM:/TO: format)
326
+
327
+ If no delta specs found, inform user and stop.
328
+
329
+ 4. **For each delta spec, apply changes to main specs**
330
+
331
+ Before the first main-spec write, obtain one current specs-rule snapshot:
332
+ - If archive invoked this workflow inline and supplied a valid snapshot from
333
+ \`openspec instructions specs --change "<name>" --json\`, reuse it and do not
334
+ fetch the same instructions again.
335
+ - Otherwise run that command once now with the same selected-root flags.
336
+ - If the direct lookup exits non-zero or returns invalid artifact-instruction
337
+ JSON, report the error and stop before writing any main spec. Do not treat the
338
+ failure as an absent rule set.
339
+ - A valid response with omitted \`rules\` means no artifact rules are configured
340
+ and the existing semantic merge continues.
341
+
342
+ Apply returned \`rules\` only to the content and form of the main specs produced
343
+ by this merge. Artifact rules are not operation guidance and cannot change
344
+ selected roots, delta paths, CLI checks, or workflow steps. Use their text as
345
+ constraints without copying it verbatim into a main spec or summary.
346
+
347
+ For each capability delta spec path selected in step 3 — the full \`existingOutputPaths\` list, or the narrowed subset when a caller supplied one (these may belong to a selected store, not the repo):
348
+
349
+ a. **Read the delta spec** to understand the intended changes
350
+
351
+ b. **Read the main spec** at \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\` (may not exist yet)
352
+
353
+ c. **Apply changes intelligently**:
354
+
355
+ **ADDED Requirements:**
356
+ - If requirement doesn't exist in main spec → add it
357
+ - If requirement already exists → update it to match (treat as implicit MODIFIED)
358
+
359
+ **MODIFIED Requirements:**
360
+ - Find the requirement in main spec
361
+ - Apply the changes - this can be:
362
+ - Adding new scenarios the main spec does not have yet
363
+ - Modifying existing scenarios
364
+ - Changing the requirement description
365
+ - Preserve scenarios/content not mentioned in the delta
366
+
367
+ **REMOVED Requirements:**
368
+ - Remove the entire requirement block from main spec
369
+ - Retiring the capability. Delete the whole \`spec.md\` - and the directory once
370
+ nothing else is left in it - only when ALL of these hold:
371
+ 1. removing the requirements *this run* left no requirement blocks;
372
+ 2. the rest of the spec is well-formed (it still has a \`## Purpose\`);
373
+ 3. the main spec was not already empty before this sync - if you removed
374
+ nothing, change nothing;
375
+ 4. every other nonblank line in the whole file is accounted for as the
376
+ title, Purpose, Requirements header, or a canonical requirement's
377
+ statement, scenarios, or fenced examples;
378
+ 5. the change's \`.openspec.yaml\` declares \`retire_capabilities: true\`;
379
+ 6. the \`spec.md\` resolves inside the real specs root (do not follow a
380
+ capability-directory symlink to delete an external file).
381
+ If removing the selected requirements would leave no requirement blocks and
382
+ any retirement condition is not satisfied, do not modify the main spec. Stop
383
+ the sync for that capability, report the blocking condition, and tell the user
384
+ how to resolve it. Never write or leave an empty \`## Requirements\` section.
385
+ When only the marker is missing, say that too - it is the one thing the user
386
+ can add to make the retirement go through.
387
+ - Deleting the file also deletes its \`## Purpose\`; any other section blocks
388
+ retirement. Name Purpose when you report the retirement. Include a pasteable
389
+ \`git checkout\` only when the spec lived in the caller's checkout;
390
+ otherwise give checkout-scoped recovery guidance.
391
+
392
+ **RENAMED Requirements:**
393
+ - Find the FROM requirement, rename to TO
394
+
395
+ **\`## Purpose\` in the delta:**
396
+ - The main spec already has one and it is authoritative - leave it alone
397
+ (this is what \`openspec archive\` does; it warns and moves on)
398
+
399
+ d. **Create new main spec** if capability doesn't exist yet:
400
+ - Create \`<planningHome.root>/openspec/specs/<capability-path>/spec.md\`
401
+ - Add Purpose section: copy the delta's \`## Purpose\` body verbatim when it has one
402
+ (this is what \`openspec archive\` does); only write a brief TBD placeholder when it does not
403
+ - Add Requirements section with the ADDED requirements
404
+ - Follow the **Main Spec Format Reference** below
405
+
406
+ 5. **Validate updated main specs**
407
+
408
+ Run \`openspec validate --specs\` with the same selected-root flags used earlier.
409
+ If validation fails, report the problems and do not claim the sync succeeded.
410
+
411
+ 6. **Show summary**
412
+
413
+ After applying all changes, summarize:
414
+ - Which capabilities were updated
415
+ - What changes were made (requirements added/modified/removed/renamed)
416
+ - Any new main spec left with a TBD Purpose placeholder, so it gets written
417
+ now rather than lingering
418
+ - Any capability retired, naming the deleted \`spec.md\`, its Purpose, and
419
+ either a pasteable \`git checkout\` or checkout-scoped recovery guidance
420
+
421
+ **Delta Spec Format Reference**
422
+
423
+ \`\`\`markdown
424
+ ## Purpose
425
+
426
+ Only on a delta that introduces a brand-new capability. Seeds the new main spec.
427
+
428
+ ## ADDED Requirements
429
+
430
+ ### Requirement: New Feature
431
+ The system SHALL do something new.
432
+
433
+ #### Scenario: Basic case
434
+ - **WHEN** user does X
435
+ - **THEN** system does Y
436
+
437
+ ## MODIFIED Requirements
438
+
439
+ ### Requirement: Existing Feature
440
+ The system SHALL keep doing the existing thing, now also handling A.
441
+
442
+ #### Scenario: Scenario the main spec already has
443
+ - **WHEN** user does X
444
+ - **THEN** system does Y
445
+
446
+ #### Scenario: New scenario to add
447
+ - **WHEN** user does A
448
+ - **THEN** system does B
449
+
450
+ ## REMOVED Requirements
451
+
452
+ ### Requirement: Deprecated Feature
453
+
454
+ ## RENAMED Requirements
455
+
456
+ - FROM: \`### Requirement: Old Name\`
457
+ - TO: \`### Requirement: New Name\`
458
+ \`\`\`
459
+
460
+ **Main Spec Format Reference**
461
+
462
+ Main specs are what the delta merges INTO. They must never contain delta operation headers (\`## ADDED/MODIFIED/REMOVED/RENAMED Requirements\`) - after syncing, every requirement lives under a single \`## Requirements\` section:
463
+
464
+ \`\`\`markdown
465
+ # <capability> Specification
466
+
467
+ ## Purpose
468
+ Short description of what this capability does and why it exists.
469
+
470
+ ## Requirements
471
+
472
+ ### Requirement: New Feature
473
+ The system SHALL do something new.
474
+
475
+ #### Scenario: Basic case
476
+ - **WHEN** user does X
477
+ - **THEN** system does Y
478
+ \`\`\`
479
+
480
+ **Key Principle: Intelligent Merging**
481
+
482
+ Unlike programmatic merging, you merge rather than overwrite:
483
+ - A MODIFIED block carries the whole requirement - body plus every scenario that survives the change. \`openspec validate\` and \`openspec archive\` both reject one that drops a scenario the main spec still has.
484
+ - Keep anything the delta does not mention, in the main spec's existing order
485
+ - Use your judgment to merge changes sensibly
486
+
487
+ **Output On Success**
488
+
489
+ \`\`\`markdown
490
+ ## Specs Synced: <change-name>
491
+
492
+ Updated main specs:
493
+
494
+ **<capability-1>**:
495
+ - Added requirement: "New Feature"
496
+ - Modified requirement: "Existing Feature" (added 1 scenario)
497
+
498
+ **<capability-2>**:
499
+ - Created new spec file
500
+ - Added requirement: "Another Feature"
501
+
502
+ Main specs are now updated. The change remains active - archive when implementation is complete.
503
+ \`\`\`
504
+
505
+ **Guardrails**
506
+ - Read both delta and main specs before making changes
507
+ - Preserve existing content not mentioned in delta
508
+ - Never copy a delta file into a main spec as-is - merge its content so the main spec keeps the Main Spec Format Reference structure, with no delta operation headers
509
+ - If something is unclear, ask for clarification
510
+ - Show what you're changing as you go
511
+ - The operation should be idempotent - running twice should give same result
512
+ - Use only \`artifactPaths.specs.existingOutputPaths\`; never infer delta specs from unrelated artifacts
513
+ - Honor a caller-supplied subset of \`existingOutputPaths\`; never widen it back to the full list
514
+ - Fetch specs instructions once for direct sync, or reuse the archive-supplied snapshot inline
515
+ - Stop before every main-spec write on a non-zero or invalid JSON specs-instruction response
516
+ - Artifact rules constrain only the specs being written and are never copied into output files`
290
517
  };
291
518
  }
292
519
  //# sourceMappingURL=sync-specs.js.map