calc-mcp-server 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/.claude/commands/opsx/apply.md +152 -0
  2. package/.claude/commands/opsx/archive.md +157 -0
  3. package/.claude/commands/opsx/bulk-archive.md +242 -0
  4. package/.claude/commands/opsx/continue.md +114 -0
  5. package/.claude/commands/opsx/explore.md +174 -0
  6. package/.claude/commands/opsx/ff.md +94 -0
  7. package/.claude/commands/opsx/new.md +69 -0
  8. package/.claude/commands/opsx/onboard.md +534 -0
  9. package/.claude/commands/opsx/sync.md +134 -0
  10. package/.claude/commands/opsx/verify.md +164 -0
  11. package/.claude/settings.local.json +8 -0
  12. package/.claude/skills/npm-publish/SKILL.md +164 -0
  13. package/.claude/skills/openspec-apply-change/SKILL.md +156 -0
  14. package/.claude/skills/openspec-archive-change/SKILL.md +161 -0
  15. package/.claude/skills/openspec-bulk-archive-change/SKILL.md +246 -0
  16. package/.claude/skills/openspec-continue-change/SKILL.md +118 -0
  17. package/.claude/skills/openspec-explore/SKILL.md +289 -0
  18. package/.claude/skills/openspec-ff-change/SKILL.md +101 -0
  19. package/.claude/skills/openspec-new-change/SKILL.md +74 -0
  20. package/.claude/skills/openspec-onboard/SKILL.md +538 -0
  21. package/.claude/skills/openspec-sync-specs/SKILL.md +138 -0
  22. package/.claude/skills/openspec-verify-change/SKILL.md +168 -0
  23. package/CLAUDE.md +92 -0
  24. package/README.md +319 -0
  25. package/build/engines/decimal.d.ts +10 -0
  26. package/build/engines/decimal.d.ts.map +1 -0
  27. package/build/engines/decimal.js +61 -0
  28. package/build/engines/decimal.js.map +1 -0
  29. package/build/engines/programmer.d.ts +18 -0
  30. package/build/engines/programmer.d.ts.map +1 -0
  31. package/build/engines/programmer.js +103 -0
  32. package/build/engines/programmer.js.map +1 -0
  33. package/build/errors/handler.d.ts +10 -0
  34. package/build/errors/handler.d.ts.map +1 -0
  35. package/build/errors/handler.js +37 -0
  36. package/build/errors/handler.js.map +1 -0
  37. package/build/errors/types.d.ts +25 -0
  38. package/build/errors/types.d.ts.map +1 -0
  39. package/build/errors/types.js +2 -0
  40. package/build/errors/types.js.map +1 -0
  41. package/build/index.d.ts +3 -0
  42. package/build/index.d.ts.map +1 -0
  43. package/build/index.js +16 -0
  44. package/build/index.js.map +1 -0
  45. package/build/mcp/server.d.ts +3 -0
  46. package/build/mcp/server.d.ts.map +1 -0
  47. package/build/mcp/server.js +270 -0
  48. package/build/mcp/server.js.map +1 -0
  49. package/build/mcp/tools/ascii.d.ts +11 -0
  50. package/build/mcp/tools/ascii.d.ts.map +1 -0
  51. package/build/mcp/tools/ascii.js +93 -0
  52. package/build/mcp/tools/ascii.js.map +1 -0
  53. package/build/mcp/tools/basic.d.ts +6 -0
  54. package/build/mcp/tools/basic.d.ts.map +1 -0
  55. package/build/mcp/tools/basic.js +34 -0
  56. package/build/mcp/tools/basic.js.map +1 -0
  57. package/build/mcp/tools/conversion.d.ts +8 -0
  58. package/build/mcp/tools/conversion.d.ts.map +1 -0
  59. package/build/mcp/tools/conversion.js +81 -0
  60. package/build/mcp/tools/conversion.js.map +1 -0
  61. package/build/mcp/tools/programmer.d.ts +6 -0
  62. package/build/mcp/tools/programmer.d.ts.map +1 -0
  63. package/build/mcp/tools/programmer.js +29 -0
  64. package/build/mcp/tools/programmer.js.map +1 -0
  65. package/build/parser/ast.d.ts +47 -0
  66. package/build/parser/ast.d.ts.map +1 -0
  67. package/build/parser/ast.js +2 -0
  68. package/build/parser/ast.js.map +1 -0
  69. package/build/parser/lexer.d.ts +24 -0
  70. package/build/parser/lexer.d.ts.map +1 -0
  71. package/build/parser/lexer.js +168 -0
  72. package/build/parser/lexer.js.map +1 -0
  73. package/build/parser/parser.d.ts +14 -0
  74. package/build/parser/parser.d.ts.map +1 -0
  75. package/build/parser/parser.js +115 -0
  76. package/build/parser/parser.js.map +1 -0
  77. package/docs/plans/2025-02-24-mcp-calculator-design.md +344 -0
  78. package/docs/plans/2025-02-24-mcp-calculator-implementation.md +2626 -0
  79. package/openspec/changes/archive/2026-02-24-simplify-ascii-tools/.openspec.yaml +2 -0
  80. package/openspec/changes/archive/2026-02-24-simplify-ascii-tools/design.md +46 -0
  81. package/openspec/changes/archive/2026-02-24-simplify-ascii-tools/proposal.md +21 -0
  82. package/openspec/changes/archive/2026-02-24-simplify-ascii-tools/specs/ascii-conversion/spec.md +22 -0
  83. package/openspec/changes/archive/2026-02-24-simplify-ascii-tools/tasks.md +24 -0
  84. package/openspec/config.yaml +20 -0
  85. package/openspec/specs/ascii-conversion/spec.md +43 -0
  86. package/package.json +40 -0
  87. package/src/engines/decimal.ts +69 -0
  88. package/src/engines/programmer.ts +112 -0
  89. package/src/errors/handler.ts +55 -0
  90. package/src/errors/types.ts +37 -0
  91. package/src/index.ts +20 -0
  92. package/src/mcp/server.ts +287 -0
  93. package/src/mcp/tools/ascii.ts +116 -0
  94. package/src/mcp/tools/basic.ts +44 -0
  95. package/src/mcp/tools/conversion.ts +95 -0
  96. package/src/mcp/tools/programmer.ts +36 -0
  97. package/src/parser/ast.ts +51 -0
  98. package/src/parser/lexer.ts +216 -0
  99. package/src/parser/parser.ts +154 -0
  100. package/test/integration/ascii.test.ts +450 -0
  101. package/test/integration/basic-calculate.test.ts +272 -0
  102. package/test/integration/conversion.test.ts +357 -0
  103. package/test/integration/programmer-calculate.test.ts +363 -0
  104. package/test/unit/decimal-engine.test.ts +134 -0
  105. package/test/unit/error-handler.test.ts +173 -0
  106. package/test/unit/lexer.test.ts +176 -0
  107. package/test/unit/parser.test.ts +197 -0
  108. package/test/unit/programmer-engine.test.ts +234 -0
  109. package/tsconfig.json +20 -0
  110. package/vitest.config.ts +13 -0
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: openspec-ff-change
3
+ description: 快速创建 OpenSpec 产物。当用户想要快速创建实施所需的所有产物而不必单独逐步完成时使用。
4
+ license: MIT
5
+ compatibility: Requires openspec CLI.
6
+ metadata:
7
+ author: openspec
8
+ version: "1.0"
9
+ generatedBy: "1.1.1"
10
+ ---
11
+
12
+ 快速创建产物 - 一次性生成开始实施所需的一切。
13
+
14
+ **输入**:用户的请求应包含变更名称(kebab-case)或他们想要构建的内容的描述。
15
+
16
+ **步骤**
17
+
18
+ 1. **如果没有提供明确的输入,询问他们想要构建什么**
19
+
20
+ 使用 **AskUserQuestion 工具**(开放式,无预设选项)询问:
21
+ > "你想进行什么变更?描述你想构建或修复的内容。"
22
+
23
+ 从他们的描述中,得出一个 kebab-case 名称(例如,"增加用户认证" → `add-user-auth`)。
24
+
25
+ **重要**:在不了解用户想要构建什么之前,不要继续。
26
+
27
+ 2. **创建变更目录**
28
+ ```bash
29
+ openspec new change "<name>"
30
+ ```
31
+ 这将在 `openspec/changes/<name>/` 下创建一个脚手架变更。
32
+
33
+ 3. **获取产物构建顺序**
34
+ ```bash
35
+ openspec status --change "<name>" --json
36
+ ```
37
+ 解析 JSON 以获取:
38
+ - `applyRequires`:实施前所需的产物 ID 数组(例如,`["tasks"]`)
39
+ - `artifacts`:所有产物及其状态和依赖关系的列表
40
+
41
+ 4. **按顺序创建产物直到准备好实施**
42
+
43
+ 使用 **TodoWrite 工具** 跟踪产物的进度。
44
+
45
+ 按依赖顺序循环产物(没有待处理依赖的产物优先):
46
+
47
+ a. **对于每个 `ready`(依赖已满足)的产物**:
48
+ - 获取指令:
49
+ ```bash
50
+ openspec instructions <artifact-id> --change "<name>" --json
51
+ ```
52
+ - 指令 JSON 包括:
53
+ - `context`:项目背景(给你的约束 - 不要包含在输出中)
54
+ - `rules`:产物特定规则(给你的约束 - 不要包含在输出中)
55
+ - `template`:用于输出文件的结构
56
+ - `instruction`:此产物类型的 Schema 特定指导
57
+ - `outputPath`:写入产物的位置
58
+ - `dependencies`:已完成的产物,用于阅读上下文
59
+ - 阅读任何已完成的依赖文件以获取上下文
60
+ - 使用 `template` 作为结构创建产物文件
61
+ - 应用 `context` 和 `rules` 作为约束 - 但不要将它们复制到文件中
62
+ - 显示简要进度:"✓ Created <artifact-id>"
63
+
64
+ b. **继续直到所有 `applyRequires` 产物都完成**
65
+ - 创建每个产物后,重新运行 `openspec status --change "<name>" --json`
66
+ - 检查 `applyRequires` 中的每个产物 ID 是否在产物数组中具有 `status: "done"`
67
+ - 当所有 `applyRequires` 产物都完成时停止
68
+
69
+ c. **如果产物需要用户输入**(上下文不清楚):
70
+ - 使用 **AskUserQuestion 工具** 澄清
71
+ - 然后继续创建
72
+
73
+ 5. **显示最终状态**
74
+ ```bash
75
+ openspec status --change "<name>"
76
+ ```
77
+
78
+ **输出**
79
+
80
+ 完成所有产物后,总结:
81
+ - 变更名称和位置
82
+ - 已创建产物的列表及简要描述
83
+ - 准备就绪:"所有产物已创建!准备实施。"
84
+ - 提示:"运行 `/opsx:apply` 或让我实施以开始处理任务。"
85
+
86
+ **产物创建指南**
87
+
88
+ - 遵循每个产物类型的 `openspec instructions` 中的 `instruction` 字段
89
+ - Schema 定义了每个产物应包含的内容 - 遵循它
90
+ - 在创建新产物之前阅读依赖产物以获取上下文
91
+ - 使用 `template` 作为起点,根据上下文填充
92
+ - **重要**:`context` 和 `rules` 是给你的约束,不是文件内容
93
+ - 不要将 `<context>`, `<rules>`, `<project_context>` 块复制到产物中
94
+ - 这些指导你写什么,但绝不应出现在输出中
95
+
96
+ **护栏**
97
+ - 创建实施所需的所有产物(由 Schema 的 `apply.requires` 定义)
98
+ - 在创建新产物之前始终阅读依赖产物
99
+ - 如果上下文严重不清楚,询问用户 - 但倾向于做出合理的决定以保持势头
100
+ - 如果具有该名称的变更已存在,询问用户是否要继续该变更或创建一个新的
101
+ - 在继续下一个之前,验证每个产物文件在写入后是否存在
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: openspec-new-change
3
+ description: 使用实验性产物工作流开始一个新的 OpenSpec 变更。当用户想要以结构化的分步方法创建新功能、修复或修改时使用。
4
+ license: MIT
5
+ compatibility: Requires openspec CLI.
6
+ metadata:
7
+ author: openspec
8
+ version: "1.0"
9
+ generatedBy: "1.1.1"
10
+ ---
11
+
12
+ 使用实验性产物驱动方法开始一个新的变更。
13
+
14
+ **输入**:用户的请求应包含变更名称(kebab-case)或他们想要构建的内容的描述。
15
+
16
+ **步骤**
17
+
18
+ 1. **如果没有提供明确的输入,询问他们想要构建什么**
19
+
20
+ 使用 **AskUserQuestion 工具**(开放式,无预设选项)询问:
21
+ > "你想进行什么变更?描述你想构建或修复的内容。"
22
+
23
+ 从他们的描述中,得出一个 kebab-case 名称(例如,"增加用户认证" → `add-user-auth`)。
24
+
25
+ **重要**:在不了解用户想要构建什么之前,不要继续。
26
+
27
+ 2. **确定工作流 Schema**
28
+
29
+ 使用默认 Schema(省略 `--schema`),除非用户明确请求不同的工作流。
30
+
31
+ **仅在用户提及时使用不同的 Schema:**
32
+ - 特定的 Schema 名称 → 使用 `--schema <name>`
33
+ - "显示工作流" 或 "什么工作流" → 运行 `openspec schemas --json` 并让他们选择
34
+
35
+ **否则**:省略 `--schema` 以使用默认值。
36
+
37
+ 3. **创建变更目录**
38
+ ```bash
39
+ openspec new change "<name>"
40
+ ```
41
+ 仅在用户请求特定工作流时添加 `--schema <name>`。
42
+ 这将在 `openspec/changes/<name>/` 下创建一个使用所选 Schema 的脚手架变更。
43
+
44
+ 4. **显示产物状态**
45
+ ```bash
46
+ openspec status --change "<name>"
47
+ ```
48
+ 这显示了哪些产物需要创建,哪些已就绪(依赖关系已满足)。
49
+
50
+ 5. **获取第一个产物的指令**
51
+ 第一个产物取决于 Schema(例如,spec-driven 的 `proposal`)。
52
+ 检查状态输出,找到第一个状态为 "ready" 的产物。
53
+ ```bash
54
+ openspec instructions <first-artifact-id> --change "<name>"
55
+ ```
56
+ 这输出创建第一个产物的模板和上下文。
57
+
58
+ 6. **停止并等待用户指示**
59
+
60
+ **输出**
61
+
62
+ 完成步骤后,总结:
63
+ - 变更名称和位置
64
+ - 正在使用的 Schema/工作流及其产物序列
65
+ - 当前状态(0/N 产物完成)
66
+ - 第一个产物的模板
67
+ - 提示:"准备好创建第一个产物了吗?只需描述这个变更的内容,我会起草它,或者你可以让我继续。"
68
+
69
+ **护栏**
70
+ - 不要创建任何产物 - 仅显示指令
71
+ - 不要超越显示第一个产物模板
72
+ - 如果名称无效(不是 kebab-case),要求一个有效名称
73
+ - 如果具有该名称的变更已存在,建议继续该变更
74
+ - 如果使用非默认工作流,传递 --schema
@@ -0,0 +1,538 @@
1
+ ---
2
+ name: openspec-onboard
3
+ description: Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
4
+ license: MIT
5
+ compatibility: Requires openspec CLI.
6
+ metadata:
7
+ author: openspec
8
+ version: "1.0"
9
+ generatedBy: "1.1.1"
10
+ ---
11
+
12
+ Guide the user through their first complete OpenSpec workflow cycle. This is a teaching experience—you'll do real work in their codebase while explaining each step.
13
+
14
+ ---
15
+
16
+ ## Preflight
17
+
18
+ Before starting, check if the OpenSpec CLI is installed:
19
+
20
+ ```bash
21
+ # Unix/macOS
22
+ openspec --version 2>&1 || echo "CLI_NOT_INSTALLED"
23
+ # Windows (PowerShell)
24
+ # if (Get-Command openspec -ErrorAction SilentlyContinue) { openspec --version } else { echo "CLI_NOT_INSTALLED" }
25
+ ```
26
+
27
+ **If CLI not installed:**
28
+ > OpenSpec CLI is not installed. Install it first, then come back to `/opsx:onboard`.
29
+
30
+ Stop here if not installed.
31
+
32
+ ---
33
+
34
+ ## Phase 1: Welcome
35
+
36
+ Display:
37
+
38
+ ```
39
+ ## Welcome to OpenSpec!
40
+
41
+ I'll walk you through a complete change cycle—from idea to implementation—using a real task in your codebase. Along the way, you'll learn the workflow by doing it.
42
+
43
+ **What we'll do:**
44
+ 1. Pick a small, real task in your codebase
45
+ 2. Explore the problem briefly
46
+ 3. Create a change (the container for our work)
47
+ 4. Build the artifacts: proposal → specs → design → tasks
48
+ 5. Implement the tasks
49
+ 6. Archive the completed change
50
+
51
+ **Time:** ~15-20 minutes
52
+
53
+ Let's start by finding something to work on.
54
+ ```
55
+
56
+ ---
57
+
58
+ ## Phase 2: Task Selection
59
+
60
+ ### Codebase Analysis
61
+
62
+ Scan the codebase for small improvement opportunities. Look for:
63
+
64
+ 1. **TODO/FIXME comments** - Search for `TODO`, `FIXME`, `HACK`, `XXX` in code files
65
+ 2. **Missing error handling** - `catch` blocks that swallow errors, risky operations without try-catch
66
+ 3. **Functions without tests** - Cross-reference `src/` with test directories
67
+ 4. **Type issues** - `any` types in TypeScript files (`: any`, `as any`)
68
+ 5. **Debug artifacts** - `console.log`, `console.debug`, `debugger` statements in non-debug code
69
+ 6. **Missing validation** - User input handlers without validation
70
+
71
+ Also check recent git activity:
72
+ ```bash
73
+ # Unix/macOS
74
+ git log --oneline -10 2>/dev/null || echo "No git history"
75
+ # Windows (PowerShell)
76
+ # git log --oneline -10 2>$null; if ($LASTEXITCODE -ne 0) { echo "No git history" }
77
+ ```
78
+
79
+ ### Present Suggestions
80
+
81
+ From your analysis, present 3-4 specific suggestions:
82
+
83
+ ```
84
+ ## Task Suggestions
85
+
86
+ Based on scanning your codebase, here are some good starter tasks:
87
+
88
+ **1. [Most promising task]**
89
+ Location: `src/path/to/file.ts:42`
90
+ Scope: ~1-2 files, ~20-30 lines
91
+ Why it's good: [brief reason]
92
+
93
+ **2. [Second task]**
94
+ Location: `src/another/file.ts`
95
+ Scope: ~1 file, ~15 lines
96
+ Why it's good: [brief reason]
97
+
98
+ **3. [Third task]**
99
+ Location: [location]
100
+ Scope: [estimate]
101
+ Why it's good: [brief reason]
102
+
103
+ **4. Something else?**
104
+ Tell me what you'd like to work on.
105
+
106
+ Which task interests you? (Pick a number or describe your own)
107
+ ```
108
+
109
+ **If nothing found:** Fall back to asking what the user wants to build:
110
+ > I didn't find obvious quick wins in your codebase. What's something small you've been meaning to add or fix?
111
+
112
+ ### Scope Guardrail
113
+
114
+ If the user picks or describes something too large (major feature, multi-day work):
115
+
116
+ ```
117
+ That's a valuable task, but it's probably larger than ideal for your first OpenSpec run-through.
118
+
119
+ For learning the workflow, smaller is better—it lets you see the full cycle without getting stuck in implementation details.
120
+
121
+ **Options:**
122
+ 1. **Slice it smaller** - What's the smallest useful piece of [their task]? Maybe just [specific slice]?
123
+ 2. **Pick something else** - One of the other suggestions, or a different small task?
124
+ 3. **Do it anyway** - If you really want to tackle this, we can. Just know it'll take longer.
125
+
126
+ What would you prefer?
127
+ ```
128
+
129
+ Let the user override if they insist—this is a soft guardrail.
130
+
131
+ ---
132
+
133
+ ## Phase 3: Explore Demo
134
+
135
+ Once a task is selected, briefly demonstrate explore mode:
136
+
137
+ ```
138
+ Before we create a change, let me quickly show you **explore mode**—it's how you think through problems before committing to a direction.
139
+ ```
140
+
141
+ Spend 1-2 minutes investigating the relevant code:
142
+ - Read the file(s) involved
143
+ - Draw a quick ASCII diagram if it helps
144
+ - Note any considerations
145
+
146
+ ```
147
+ ## Quick Exploration
148
+
149
+ [Your brief analysis—what you found, any considerations]
150
+
151
+ ┌─────────────────────────────────────────┐
152
+ │ [Optional: ASCII diagram if helpful] │
153
+ └─────────────────────────────────────────┘
154
+
155
+ Explore mode (`/opsx:explore`) is for this kind of thinking—investigating before implementing. You can use it anytime you need to think through a problem.
156
+
157
+ Now let's create a change to hold our work.
158
+ ```
159
+
160
+ **PAUSE** - Wait for user acknowledgment before proceeding.
161
+
162
+ ---
163
+
164
+ ## Phase 4: Create the Change
165
+
166
+ **EXPLAIN:**
167
+ ```
168
+ ## Creating a Change
169
+
170
+ A "change" in OpenSpec is a container for all the thinking and planning around a piece of work. It lives in `openspec/changes/<name>/` and holds your artifacts—proposal, specs, design, tasks.
171
+
172
+ Let me create one for our task.
173
+ ```
174
+
175
+ **DO:** Create the change with a derived kebab-case name:
176
+ ```bash
177
+ openspec new change "<derived-name>"
178
+ ```
179
+
180
+ **SHOW:**
181
+ ```
182
+ Created: `openspec/changes/<name>/`
183
+
184
+ The folder structure:
185
+ ```
186
+ openspec/changes/<name>/
187
+ ├── proposal.md ← Why we're doing this (empty, we'll fill it)
188
+ ├── design.md ← How we'll build it (empty)
189
+ ├── specs/ ← Detailed requirements (empty)
190
+ └── tasks.md ← Implementation checklist (empty)
191
+ ```
192
+
193
+ Now let's fill in the first artifact—the proposal.
194
+ ```
195
+
196
+ ---
197
+
198
+ ## Phase 5: Proposal
199
+
200
+ **EXPLAIN:**
201
+ ```
202
+ ## The Proposal
203
+
204
+ The proposal captures **why** we're making this change and **what** it involves at a high level. It's the "elevator pitch" for the work.
205
+
206
+ I'll draft one based on our task.
207
+ ```
208
+
209
+ **DO:** Draft the proposal content (don't save yet):
210
+
211
+ ```
212
+ Here's a draft proposal:
213
+
214
+ ---
215
+
216
+ ## Why
217
+
218
+ [1-2 sentences explaining the problem/opportunity]
219
+
220
+ ## What Changes
221
+
222
+ [Bullet points of what will be different]
223
+
224
+ ## Capabilities
225
+
226
+ ### New Capabilities
227
+ - `<capability-name>`: [brief description]
228
+
229
+ ### Modified Capabilities
230
+ <!-- If modifying existing behavior -->
231
+
232
+ ## Impact
233
+
234
+ - `src/path/to/file.ts`: [what changes]
235
+ - [other files if applicable]
236
+
237
+ ---
238
+
239
+ Does this capture the intent? I can adjust before we save it.
240
+ ```
241
+
242
+ **PAUSE** - Wait for user approval/feedback.
243
+
244
+ After approval, save the proposal:
245
+ ```bash
246
+ openspec instructions proposal --change "<name>" --json
247
+ ```
248
+ Then write the content to `openspec/changes/<name>/proposal.md`.
249
+
250
+ ```
251
+ Proposal saved. This is your "why" document—you can always come back and refine it as understanding evolves.
252
+
253
+ Next up: specs.
254
+ ```
255
+
256
+ ---
257
+
258
+ ## Phase 6: Specs
259
+
260
+ **EXPLAIN:**
261
+ ```
262
+ ## Specs
263
+
264
+ Specs define **what** we're building in precise, testable terms. They use a requirement/scenario format that makes expected behavior crystal clear.
265
+
266
+ For a small task like this, we might only need one spec file.
267
+ ```
268
+
269
+ **DO:** Create the spec file:
270
+ ```bash
271
+ # Unix/macOS
272
+ mkdir -p openspec/changes/<name>/specs/<capability-name>
273
+ # Windows (PowerShell)
274
+ # New-Item -ItemType Directory -Force -Path "openspec/changes/<name>/specs/<capability-name>"
275
+ ```
276
+
277
+ Draft the spec content:
278
+
279
+ ```
280
+ Here's the spec:
281
+
282
+ ---
283
+
284
+ ## ADDED Requirements
285
+
286
+ ### Requirement: <Name>
287
+
288
+ <Description of what the system should do>
289
+
290
+ #### Scenario: <Scenario name>
291
+
292
+ - **WHEN** <trigger condition>
293
+ - **THEN** <expected outcome>
294
+ - **AND** <additional outcome if needed>
295
+
296
+ ---
297
+
298
+ This format—WHEN/THEN/AND—makes requirements testable. You can literally read them as test cases.
299
+ ```
300
+
301
+ Save to `openspec/changes/<name>/specs/<capability>/spec.md`.
302
+
303
+ ---
304
+
305
+ ## Phase 7: Design
306
+
307
+ **EXPLAIN:**
308
+ ```
309
+ ## Design
310
+
311
+ The design captures **how** we'll build it—technical decisions, tradeoffs, approach.
312
+
313
+ For small changes, this might be brief. That's fine—not every change needs deep design discussion.
314
+ ```
315
+
316
+ **DO:** Draft design.md:
317
+
318
+ ```
319
+ Here's the design:
320
+
321
+ ---
322
+
323
+ ## Context
324
+
325
+ [Brief context about the current state]
326
+
327
+ ## Goals / Non-Goals
328
+
329
+ **Goals:**
330
+ - [What we're trying to achieve]
331
+
332
+ **Non-Goals:**
333
+ - [What's explicitly out of scope]
334
+
335
+ ## Decisions
336
+
337
+ ### Decision 1: [Key decision]
338
+
339
+ [Explanation of approach and rationale]
340
+
341
+ ---
342
+
343
+ For a small task, this captures the key decisions without over-engineering.
344
+ ```
345
+
346
+ Save to `openspec/changes/<name>/design.md`.
347
+
348
+ ---
349
+
350
+ ## Phase 8: Tasks
351
+
352
+ **EXPLAIN:**
353
+ ```
354
+ ## Tasks
355
+
356
+ Finally, we break the work into implementation tasks—checkboxes that drive the apply phase.
357
+
358
+ These should be small, clear, and in logical order.
359
+ ```
360
+
361
+ **DO:** Generate tasks based on specs and design:
362
+
363
+ ```
364
+ Here are the implementation tasks:
365
+
366
+ ---
367
+
368
+ ## 1. [Category or file]
369
+
370
+ - [ ] 1.1 [Specific task]
371
+ - [ ] 1.2 [Specific task]
372
+
373
+ ## 2. Verify
374
+
375
+ - [ ] 2.1 [Verification step]
376
+
377
+ ---
378
+
379
+ Each checkbox becomes a unit of work in the apply phase. Ready to implement?
380
+ ```
381
+
382
+ **PAUSE** - Wait for user to confirm they're ready to implement.
383
+
384
+ Save to `openspec/changes/<name>/tasks.md`.
385
+
386
+ ---
387
+
388
+ ## Phase 9: Apply (Implementation)
389
+
390
+ **EXPLAIN:**
391
+ ```
392
+ ## Implementation
393
+
394
+ Now we implement each task, checking them off as we go. I'll announce each one and occasionally note how the specs/design informed the approach.
395
+ ```
396
+
397
+ **DO:** For each task:
398
+
399
+ 1. Announce: "Working on task N: [description]"
400
+ 2. Implement the change in the codebase
401
+ 3. Reference specs/design naturally: "The spec says X, so I'm doing Y"
402
+ 4. Mark complete in tasks.md: `- [ ]` → `- [x]`
403
+ 5. Brief status: "✓ Task N complete"
404
+
405
+ Keep narration light—don't over-explain every line of code.
406
+
407
+ After all tasks:
408
+
409
+ ```
410
+ ## Implementation Complete
411
+
412
+ All tasks done:
413
+ - [x] Task 1
414
+ - [x] Task 2
415
+ - [x] ...
416
+
417
+ The change is implemented! One more step—let's archive it.
418
+ ```
419
+
420
+ ---
421
+
422
+ ## Phase 10: Archive
423
+
424
+ **EXPLAIN:**
425
+ ```
426
+ ## Archiving
427
+
428
+ When a change is complete, we archive it. This moves it from `openspec/changes/` to `openspec/changes/archive/YYYY-MM-DD-<name>/`.
429
+
430
+ Archived changes become your project's decision history—you can always find them later to understand why something was built a certain way.
431
+ ```
432
+
433
+ **DO:**
434
+ ```bash
435
+ openspec archive "<name>"
436
+ ```
437
+
438
+ **SHOW:**
439
+ ```
440
+ Archived to: `openspec/changes/archive/YYYY-MM-DD-<name>/`
441
+
442
+ The change is now part of your project's history. The code is in your codebase, the decision record is preserved.
443
+ ```
444
+
445
+ ---
446
+
447
+ ## Phase 11: Recap & Next Steps
448
+
449
+ ```
450
+ ## Congratulations!
451
+
452
+ You just completed a full OpenSpec cycle:
453
+
454
+ 1. **Explore** - Thought through the problem
455
+ 2. **New** - Created a change container
456
+ 3. **Proposal** - Captured WHY
457
+ 4. **Specs** - Defined WHAT in detail
458
+ 5. **Design** - Decided HOW
459
+ 6. **Tasks** - Broke it into steps
460
+ 7. **Apply** - Implemented the work
461
+ 8. **Archive** - Preserved the record
462
+
463
+ This same rhythm works for any size change—a small fix or a major feature.
464
+
465
+ ---
466
+
467
+ ## Command Reference
468
+
469
+ | Command | What it does |
470
+ |---------|--------------|
471
+ | `/opsx:explore` | Think through problems before/during work |
472
+ | `/opsx:new` | Start a new change, step through artifacts |
473
+ | `/opsx:ff` | Fast-forward: create all artifacts at once |
474
+ | `/opsx:continue` | Continue working on an existing change |
475
+ | `/opsx:apply` | Implement tasks from a change |
476
+ | `/opsx:verify` | Verify implementation matches artifacts |
477
+ | `/opsx:archive` | Archive a completed change |
478
+
479
+ ---
480
+
481
+ ## What's Next?
482
+
483
+ Try `/opsx:new` or `/opsx:ff` on something you actually want to build. You've got the rhythm now!
484
+ ```
485
+
486
+ ---
487
+
488
+ ## Graceful Exit Handling
489
+
490
+ ### User wants to stop mid-way
491
+
492
+ If the user says they need to stop, want to pause, or seem disengaged:
493
+
494
+ ```
495
+ No problem! Your change is saved at `openspec/changes/<name>/`.
496
+
497
+ To pick up where we left off later:
498
+ - `/opsx:continue <name>` - Resume artifact creation
499
+ - `/opsx:apply <name>` - Jump to implementation (if tasks exist)
500
+
501
+ The work won't be lost. Come back whenever you're ready.
502
+ ```
503
+
504
+ Exit gracefully without pressure.
505
+
506
+ ### User just wants command reference
507
+
508
+ If the user says they just want to see the commands or skip the tutorial:
509
+
510
+ ```
511
+ ## OpenSpec Quick Reference
512
+
513
+ | Command | What it does |
514
+ |---------|--------------|
515
+ | `/opsx:explore` | Think through problems (no code changes) |
516
+ | `/opsx:new <name>` | Start a new change, step by step |
517
+ | `/opsx:ff <name>` | Fast-forward: all artifacts at once |
518
+ | `/opsx:continue <name>` | Continue an existing change |
519
+ | `/opsx:apply <name>` | Implement tasks |
520
+ | `/opsx:verify <name>` | Verify implementation |
521
+ | `/opsx:archive <name>` | Archive when done |
522
+
523
+ Try `/opsx:new` to start your first change, or `/opsx:ff` if you want to move fast.
524
+ ```
525
+
526
+ Exit gracefully.
527
+
528
+ ---
529
+
530
+ ## Guardrails
531
+
532
+ - **Follow the EXPLAIN → DO → SHOW → PAUSE pattern** at key transitions (after explore, after proposal draft, after tasks, after archive)
533
+ - **Keep narration light** during implementation—teach without lecturing
534
+ - **Don't skip phases** even if the change is small—the goal is teaching the workflow
535
+ - **Pause for acknowledgment** at marked points, but don't over-pause
536
+ - **Handle exits gracefully**—never pressure the user to continue
537
+ - **Use real codebase tasks**—don't simulate or use fake examples
538
+ - **Adjust scope gently**—guide toward smaller tasks but respect user choice