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,246 @@
1
+ ---
2
+ name: openspec-bulk-archive-change
3
+ description: Archive multiple completed changes at once. Use when archiving several parallel changes.
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
+ Archive multiple completed changes in a single operation.
13
+
14
+ This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.
15
+
16
+ **Input**: None required (prompts for selection)
17
+
18
+ **Steps**
19
+
20
+ 1. **Get active changes**
21
+
22
+ Run `openspec list --json` to get all active changes.
23
+
24
+ If no active changes exist, inform user and stop.
25
+
26
+ 2. **Prompt for change selection**
27
+
28
+ Use **AskUserQuestion tool** with multi-select to let user choose changes:
29
+ - Show each change with its schema
30
+ - Include an option for "All changes"
31
+ - Allow any number of selections (1+ works, 2+ is the typical use case)
32
+
33
+ **IMPORTANT**: Do NOT auto-select. Always let the user choose.
34
+
35
+ 3. **Batch validation - gather status for all selected changes**
36
+
37
+ For each selected change, collect:
38
+
39
+ a. **Artifact status** - Run `openspec status --change "<name>" --json`
40
+ - Parse `schemaName` and `artifacts` list
41
+ - Note which artifacts are `done` vs other states
42
+
43
+ b. **Task completion** - Read `openspec/changes/<name>/tasks.md`
44
+ - Count `- [ ]` (incomplete) vs `- [x]` (complete)
45
+ - If no tasks file exists, note as "No tasks"
46
+
47
+ c. **Delta specs** - Check `openspec/changes/<name>/specs/` directory
48
+ - List which capability specs exist
49
+ - For each, extract requirement names (lines matching `### Requirement: <name>`)
50
+
51
+ 4. **Detect spec conflicts**
52
+
53
+ Build a map of `capability -> [changes that touch it]`:
54
+
55
+ ```
56
+ auth -> [change-a, change-b] <- CONFLICT (2+ changes)
57
+ api -> [change-c] <- OK (only 1 change)
58
+ ```
59
+
60
+ A conflict exists when 2+ selected changes have delta specs for the same capability.
61
+
62
+ 5. **Resolve conflicts agentically**
63
+
64
+ **For each conflict**, investigate the codebase:
65
+
66
+ a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify
67
+
68
+ b. **Search the codebase** for implementation evidence:
69
+ - Look for code implementing requirements from each delta spec
70
+ - Check for related files, functions, or tests
71
+
72
+ c. **Determine resolution**:
73
+ - If only one change is actually implemented -> sync that one's specs
74
+ - If both implemented -> apply in chronological order (older first, newer overwrites)
75
+ - If neither implemented -> skip spec sync, warn user
76
+
77
+ d. **Record resolution** for each conflict:
78
+ - Which change's specs to apply
79
+ - In what order (if both)
80
+ - Rationale (what was found in codebase)
81
+
82
+ 6. **Show consolidated status table**
83
+
84
+ Display a table summarizing all changes:
85
+
86
+ ```
87
+ | Change | Artifacts | Tasks | Specs | Conflicts | Status |
88
+ |---------------------|-----------|-------|---------|-----------|--------|
89
+ | schema-management | Done | 5/5 | 2 delta | None | Ready |
90
+ | project-config | Done | 3/3 | 1 delta | None | Ready |
91
+ | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* |
92
+ | add-verify-skill | 1 left | 2/5 | None | None | Warn |
93
+ ```
94
+
95
+ For conflicts, show the resolution:
96
+ ```
97
+ * Conflict resolution:
98
+ - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order)
99
+ ```
100
+
101
+ For incomplete changes, show warnings:
102
+ ```
103
+ Warnings:
104
+ - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks
105
+ ```
106
+
107
+ 7. **Confirm batch operation**
108
+
109
+ Use **AskUserQuestion tool** with a single confirmation:
110
+
111
+ - "Archive N changes?" with options based on status
112
+ - Options might include:
113
+ - "Archive all N changes"
114
+ - "Archive only N ready changes (skip incomplete)"
115
+ - "Cancel"
116
+
117
+ If there are incomplete changes, make clear they'll be archived with warnings.
118
+
119
+ 8. **Execute archive for each confirmed change**
120
+
121
+ Process changes in the determined order (respecting conflict resolution):
122
+
123
+ a. **Sync specs** if delta specs exist:
124
+ - Use the openspec-sync-specs approach (agent-driven intelligent merge)
125
+ - For conflicts, apply in resolved order
126
+ - Track if sync was done
127
+
128
+ b. **Perform the archive**:
129
+ ```bash
130
+ mkdir -p openspec/changes/archive
131
+ mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
132
+ ```
133
+
134
+ c. **Track outcome** for each change:
135
+ - Success: archived successfully
136
+ - Failed: error during archive (record error)
137
+ - Skipped: user chose not to archive (if applicable)
138
+
139
+ 9. **Display summary**
140
+
141
+ Show final results:
142
+
143
+ ```
144
+ ## Bulk Archive Complete
145
+
146
+ Archived 3 changes:
147
+ - schema-management-cli -> archive/2026-01-19-schema-management-cli/
148
+ - project-config -> archive/2026-01-19-project-config/
149
+ - add-oauth -> archive/2026-01-19-add-oauth/
150
+
151
+ Skipped 1 change:
152
+ - add-verify-skill (user chose not to archive incomplete)
153
+
154
+ Spec sync summary:
155
+ - 4 delta specs synced to main specs
156
+ - 1 conflict resolved (auth: applied both in chronological order)
157
+ ```
158
+
159
+ If any failures:
160
+ ```
161
+ Failed 1 change:
162
+ - some-change: Archive directory already exists
163
+ ```
164
+
165
+ **Conflict Resolution Examples**
166
+
167
+ Example 1: Only one implemented
168
+ ```
169
+ Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt]
170
+
171
+ Checking add-oauth:
172
+ - Delta adds "OAuth Provider Integration" requirement
173
+ - Searching codebase... found src/auth/oauth.ts implementing OAuth flow
174
+
175
+ Checking add-jwt:
176
+ - Delta adds "JWT Token Handling" requirement
177
+ - Searching codebase... no JWT implementation found
178
+
179
+ Resolution: Only add-oauth is implemented. Will sync add-oauth specs only.
180
+ ```
181
+
182
+ Example 2: Both implemented
183
+ ```
184
+ Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql]
185
+
186
+ Checking add-rest-api (created 2026-01-10):
187
+ - Delta adds "REST Endpoints" requirement
188
+ - Searching codebase... found src/api/rest.ts
189
+
190
+ Checking add-graphql (created 2026-01-15):
191
+ - Delta adds "GraphQL Schema" requirement
192
+ - Searching codebase... found src/api/graphql.ts
193
+
194
+ Resolution: Both implemented. Will apply add-rest-api specs first,
195
+ then add-graphql specs (chronological order, newer takes precedence).
196
+ ```
197
+
198
+ **Output On Success**
199
+
200
+ ```
201
+ ## Bulk Archive Complete
202
+
203
+ Archived N changes:
204
+ - <change-1> -> archive/YYYY-MM-DD-<change-1>/
205
+ - <change-2> -> archive/YYYY-MM-DD-<change-2>/
206
+
207
+ Spec sync summary:
208
+ - N delta specs synced to main specs
209
+ - No conflicts (or: M conflicts resolved)
210
+ ```
211
+
212
+ **Output On Partial Success**
213
+
214
+ ```
215
+ ## Bulk Archive Complete (partial)
216
+
217
+ Archived N changes:
218
+ - <change-1> -> archive/YYYY-MM-DD-<change-1>/
219
+
220
+ Skipped M changes:
221
+ - <change-2> (user chose not to archive incomplete)
222
+
223
+ Failed K changes:
224
+ - <change-3>: Archive directory already exists
225
+ ```
226
+
227
+ **Output When No Changes**
228
+
229
+ ```
230
+ ## No Changes to Archive
231
+
232
+ No active changes found. Use `/opsx:new` to create a new change.
233
+ ```
234
+
235
+ **Guardrails**
236
+ - Allow any number of changes (1+ is fine, 2+ is the typical use case)
237
+ - Always prompt for selection, never auto-select
238
+ - Detect spec conflicts early and resolve by checking codebase
239
+ - When both changes are implemented, apply specs in chronological order
240
+ - Skip spec sync only when implementation is missing (warn user)
241
+ - Show clear per-change status before confirming
242
+ - Use single confirmation for entire batch
243
+ - Track and report all outcomes (success/skip/fail)
244
+ - Preserve .openspec.yaml when moving to archive
245
+ - Archive directory target uses current date: YYYY-MM-DD-<name>
246
+ - If archive target exists, fail that change but continue with others
@@ -0,0 +1,118 @@
1
+ ---
2
+ name: openspec-continue-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
+ **输入**:可选择指定变更名称。如果省略,检查是否可以从对话上下文中推断。如果模糊或不明确,必须提示可用的变更。
15
+
16
+ **步骤**
17
+
18
+ 1. **如果没有提供变更名称,提示选择**
19
+
20
+ 运行 `openspec list --json` 以获取按最近修改排序的可用变更。然后使用 **AskUserQuestion 工具** 让用户选择要处理哪个变更。
21
+
22
+ 提供前 3-4 个最近修改的变更作为选项,显示:
23
+ - 变更名称
24
+ - Schema(如果有 `schema` 字段,否则为 "spec-driven")
25
+ - 状态(例如,"0/5 tasks", "complete", "no tasks")
26
+ - 最近修改时间(来自 `lastModified` 字段)
27
+
28
+ 将最近修改的变更标记为 "(Recommended)",因为这很可能是用户想要继续的。
29
+
30
+ **重要**:不要猜测或自动选择变更。始终让用户选择。
31
+
32
+ 2. **检查当前状态**
33
+ ```bash
34
+ openspec status --change "<name>" --json
35
+ ```
36
+ 解析 JSON 以了解当前状态。响应包括:
37
+ - `schemaName`:正在使用的工作流 Schema(例如,"spec-driven")
38
+ - `artifacts`:产物数组及其状态("done", "ready", "blocked")
39
+ - `isComplete`:指示是否所有产物都已完成的布尔值
40
+
41
+ 3. **根据状态行动**:
42
+
43
+ ---
44
+
45
+ **如果所有产物都已完成 (`isComplete: true`)**:
46
+ - 祝贺用户
47
+ - 显示最终状态,包括使用的 Schema
48
+ - 建议:"所有产物已创建!你现在可以实施此变更或将其归档。"
49
+ - 停止
50
+
51
+ ---
52
+
53
+ **如果有产物准备创建**(状态显示有 `status: "ready"` 的产物):
54
+ - 从状态输出中选择第一个 `status: "ready"` 的产物
55
+ - 获取其指令:
56
+ ```bash
57
+ openspec instructions <artifact-id> --change "<name>" --json
58
+ ```
59
+ - 解析 JSON。关键字段是:
60
+ - `context`:项目背景(给你的约束 - 不要包含在输出中)
61
+ - `rules`:产物特定规则(给你的约束 - 不要包含在输出中)
62
+ - `template`:用于输出文件的结构
63
+ - `instruction`:Schema 特定的指导
64
+ - `outputPath`:写入产物的位置
65
+ - `dependencies`:已完成的产物,用于阅读上下文
66
+ - **创建产物文件**:
67
+ - 阅读任何已完成的依赖文件以获取上下文
68
+ - 使用 `template` 作为结构 - 填充其部分
69
+ - 应用 `context` 和 `rules` 作为约束 - 但不要将它们复制到文件中
70
+ - 写入指令中指定的输出路径
71
+ - 显示已创建的内容以及现在解锁的内容
72
+ - 在创建一个产物后停止
73
+
74
+ ---
75
+
76
+ **如果没有产物准备好(全部阻塞)**:
77
+ - 这在有效 Schema 中不应发生
78
+ - 显示状态并建议检查问题
79
+
80
+ 4. **创建产物后,显示进度**
81
+ ```bash
82
+ openspec status --change "<name>"
83
+ ```
84
+
85
+ **输出**
86
+
87
+ 每次调用后,显示:
88
+ - 创建了哪个产物
89
+ - 正在使用的 Schema 工作流
90
+ - 当前进度(N/M 完成)
91
+ - 现在解锁了哪些产物
92
+ - 提示:"想要继续吗?只需让我继续或告诉我下一步做什么。"
93
+
94
+ **产物创建指南**
95
+
96
+ 产物类型及其用途取决于 Schema。使用指令输出中的 `instruction` 字段来了解要创建什么。
97
+
98
+ 常见产物模式:
99
+
100
+ **spec-driven schema** (proposal → specs → design → tasks):
101
+ - **proposal.md**:如果不清楚,询问用户关于变更的信息。填写 Why, What Changes, Capabilities, Impact。
102
+ - Capabilities 部分至关重要 - 列出的每个 capability 都需要一个 spec 文件。
103
+ - **specs/<capability>/spec.md**:为 proposal 的 Capabilities 部分中列出的每个 capability 创建一个 spec(使用 capability 名称,而不是变更名称)。
104
+ - **design.md**:记录技术决策、架构和实施方法。
105
+ - **tasks.md**:将实施分解为带复选框的任务。
106
+
107
+ 对于其他 Schema,遵循 CLI 输出中的 `instruction` 字段。
108
+
109
+ **护栏**
110
+ - 每次调用创建一个产物
111
+ - 在创建新产物之前,始终阅读依赖产物
112
+ - 绝不跳过产物或乱序创建
113
+ - 如果上下文不清楚,在创建之前询问用户
114
+ - 在标记进度之前,验证写入后产物文件是否存在
115
+ - 使用 Schema 的产物序列,不要假设特定的产物名称
116
+ - **重要**:`context` 和 `rules` 是给你的约束,不是文件内容
117
+ - 不要将 `<context>`, `<rules>`, `<project_context>` 块复制到产物中
118
+ - 这些指导你写什么,但绝不应出现在输出中
@@ -0,0 +1,289 @@
1
+ ---
2
+ name: openspec-explore
3
+ description: 进入探索模式——一个用于探索想法、调查问题和澄清需求的思考伙伴。当用户想要在变更之前或期间思考某些事情时使用。
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
+ **重要:探索模式用于思考,而非实施。** 你可以阅读文件、搜索代码和调查代码库,但你绝不能编写代码或实施功能。如果用户要求你实施某事,请提醒他们先退出探索模式(例如,使用 `/opsx:new` 或 `/opsx:ff` 开始一个变更)。如果用户要求,你可以创建 OpenSpec 产物(提案、设计、规范)——这是捕捉思考,而不是实施。
15
+
16
+ **这是一种姿态,而不是工作流。** 没有固定的步骤,没有要求的顺序,没有强制的输出。你是帮助用户探索的思考伙伴。
17
+
18
+ ---
19
+
20
+ ## 姿态
21
+
22
+ - **好奇而非指令性** - 提出自然涌现的问题,不要照本宣科
23
+ - **开放话题而非审问** - 展示多个有趣的方向,让用户跟随共鸣之处。不要强迫他们通过单一的问题路径。
24
+ - **可视化** - 当有助于通过 ASCII 图表澄清思路时,请大量使用
25
+ - **适应性** - 跟随有趣的线索,当新信息出现时进行调整
26
+ - **耐心** - 不要急于下结论,让问题的形状自然显现
27
+ - **脚踏实地** - 在相关时探索实际的代码库,不仅仅是理论化
28
+
29
+ ---
30
+
31
+ ## 你可能做的事情
32
+
33
+ 根据用户提出的内容,你可能会:
34
+
35
+ **探索问题空间**
36
+ - 提出从他们所说内容中涌现的澄清性问题
37
+ - 挑战假设
38
+ - 重新构建问题
39
+ - 寻找类比
40
+
41
+ **调查代码库**
42
+ - 绘制与讨论相关的现有架构图
43
+ - 寻找集成点
44
+ - 识别已在使用的模式
45
+ - 揭示隐藏的复杂性
46
+
47
+ **比较选项**
48
+ - 头脑风暴多种方法
49
+ - 建立比较表
50
+ - 勾勒权衡
51
+ - 推荐路径(如果被问及)
52
+
53
+ **可视化**
54
+ ```
55
+ ┌─────────────────────────────────────────┐
56
+ │ 大量使用 ASCII 图表 │
57
+ ├─────────────────────────────────────────┤
58
+ │ │
59
+ │ ┌────────┐ ┌────────┐ │
60
+ │ │ 状态 │────────▶│ 状态 │ │
61
+ │ │ A │ │ B │ │
62
+ │ └────────┘ └────────┘ │
63
+ │ │
64
+ │ 系统图、状态机、数据流、架构草图、 │
65
+ │ 依赖图、比较表 │
66
+ │ │
67
+ └─────────────────────────────────────────┘
68
+ ```
69
+
70
+ **揭示风险和未知数**
71
+ - 识别可能出错的地方
72
+ - 发现理解上的差距
73
+ - 建议探针(spikes)或调查
74
+
75
+ ---
76
+
77
+ ## OpenSpec 意识
78
+
79
+ 你拥有 OpenSpec 系统的完整上下文。自然地使用它,不要强迫。
80
+
81
+ ### 检查上下文
82
+
83
+ 开始时,快速检查已存在的内容:
84
+ ```bash
85
+ openspec list --json
86
+ ```
87
+
88
+ 这会告诉你:
89
+ - 是否有活跃的变更
90
+ - 它们的名称、Schema 和状态
91
+ - 用户可能正在处理的内容
92
+
93
+ ### 当没有变更存在时
94
+
95
+ 自由思考。当见解具体化时,你可以提供:
96
+
97
+ - "这感觉足够扎实,可以开始一个变更了。要我创建一个吗?"
98
+ → 可以过渡到 `/opsx:new` 或 `/opsx:ff`
99
+ - 或者继续探索 - 没有正式化的压力
100
+
101
+ ### 当变更存在时
102
+
103
+ 如果用户提到变更或你检测到相关变更:
104
+
105
+ 1. **阅读现有产物以获取上下文**
106
+ - `openspec/changes/<name>/proposal.md`
107
+ - `openspec/changes/<name>/design.md`
108
+ - `openspec/changes/<name>/tasks.md`
109
+ - 等等。
110
+
111
+ 2. **在对话中自然地引用它们**
112
+ - "你的设计提到使用 Redis,但我们刚意识到 SQLite 更合适..."
113
+ - "提案将此范围限定为高级用户,但我们现在考虑面向所有人..."
114
+
115
+ 3. **当做出决定时提议捕捉**
116
+
117
+ | 见解类型 | 捕捉位置 |
118
+ |----------|----------|
119
+ | 发现新需求 | `specs/<capability>/spec.md` |
120
+ | 需求变更 | `specs/<capability>/spec.md` |
121
+ | 做出设计决定 | `design.md` |
122
+ | 范围变更 | `proposal.md` |
123
+ | 识别新工作 | `tasks.md` |
124
+ | 假设失效 | 相关产物 |
125
+
126
+ 示例提议:
127
+ - "这是一个设计决定。要把它记录在 design.md 中吗?"
128
+ - "这是一个新需求。要把它添加到规范中吗?"
129
+ - "这改变了范围。要更新提案吗?"
130
+
131
+ 4. **用户决定** - 提议并继续。不要施压。不要自动捕捉。
132
+
133
+ ---
134
+
135
+ ## 你不必做的事情
136
+
137
+ - 遵循脚本
138
+ - 每次都问同样的问题
139
+ - 产生特定的产物
140
+ - 得出结论
141
+ - 如果离题有价值,不必保持在主题上
142
+ - 简短(这是思考时间)
143
+
144
+ ---
145
+
146
+ ## 处理不同的入口点
147
+
148
+ **用户带来一个模糊的想法:**
149
+ ```
150
+ 用户:我在考虑添加实时协作
151
+
152
+ 你:实时协作是一个很大的空间。让我想想...
153
+
154
+ 协作谱系
155
+ ════════════════════════════════════════════
156
+
157
+ 感知 协调 同步
158
+ │ │ │
159
+ ▼ ▼ ▼
160
+ ┌────────┐ ┌────────┐ ┌────────┐
161
+ │ 在场 │ │ 光标 │ │ CRDT │
162
+ │ "3人 │ │ 多选 │ │无冲突 │
163
+ │ 在线" │ │ │ │ │
164
+ └────────┘ └────────┘ └────────┘
165
+ │ │ │
166
+ 琐碎 中等 复杂
167
+
168
+ 你的想法在哪里?
169
+ ```
170
+
171
+ **用户带来一个具体的问题:**
172
+ ```
173
+ 用户:认证系统一团糟
174
+
175
+ 你:[阅读代码库]
176
+
177
+ ┌─────────────────────────────────────────────┐
178
+ │ 当前认证流程 │
179
+ └─────────────────────────────────────────────┘
180
+
181
+ ┌─────────────┼─────────────┐
182
+ ▼ ▼ ▼
183
+ ┌─────────┐ ┌─────────┐ ┌─────────┐
184
+ │ Google │ │ GitHub │ │ Email │
185
+ │ OAuth │ │ OAuth │ │ Magic │
186
+ └────┬────┘ └────┬────┘ └────┬────┘
187
+ │ │ │
188
+ └─────────────┼─────────────┘
189
+
190
+ ┌───────────┐
191
+ │ 会话 │
192
+ └─────┬─────┘
193
+
194
+
195
+ ┌───────────┐
196
+ │ 权限 │
197
+ └───────────┘
198
+
199
+ 我看到三个纠结之处。哪个最紧迫?
200
+ ```
201
+
202
+ **用户在实施中途卡住:**
203
+ ```
204
+ 用户:/opsx:explore add-auth-system
205
+ OAuth 集成比预期的要复杂
206
+
207
+ 你:[阅读变更产物]
208
+
209
+ 你在任务 4:"实施 OAuth 流程"
210
+
211
+ 让我追踪一下涉及的内容...
212
+
213
+ [绘制图表,探索选项,建议路径]
214
+
215
+ 想要更新设计以反映这一点吗?
216
+ 或者添加一个探针任务来调查?
217
+ ```
218
+
219
+ **用户想要比较选项:**
220
+ ```
221
+ 用户:我们应该用 Postgres 还是 SQLite?
222
+
223
+ 你:通用的答案很无聊。上下文是什么?
224
+
225
+ 用户:一个跟踪本地开发环境的 CLI 工具
226
+
227
+ 你:那改变了一切。
228
+
229
+ ┌─────────────────────────────────────────────────┐
230
+ │ CLI 工具数据存储 │
231
+ └─────────────────────────────────────────────────┘
232
+
233
+ 关键约束:
234
+ • 无后台运行
235
+ • 必须离线工作
236
+ • 单用户
237
+
238
+ SQLite Postgres
239
+ 部署 嵌入式 ✓ 需要服务器 ✗
240
+ 离线 是 ✓ 否 ✗
241
+ 单文件 是 ✓ 否 ✗
242
+
243
+ SQLite。毫无疑问。
244
+
245
+ 除非... 有同步组件吗?
246
+ ```
247
+
248
+ ---
249
+
250
+ ## 结束发现
251
+
252
+ 没有强制的结束。发现可能会:
253
+
254
+ - **流入行动**:"准备好开始了吗? /opsx:new 或 /opsx:ff"
255
+ - **导致产物更新**:"已用这些决定更新 design.md"
256
+ - **仅提供清晰度**:用户得到了他们需要的,继续前进
257
+ - **稍后继续**:"我们可以随时继续"
258
+
259
+ 当感觉事情具体化时,你可以总结:
260
+
261
+ ```
262
+ ## 我们弄清楚了什么
263
+
264
+ **问题**:[具体化的理解]
265
+
266
+ **方法**:[如果出现了一个]
267
+
268
+ **未决问题**:[如果还有]
269
+
270
+ **下一步**(如果准备好了):
271
+ - 创建变更:/opsx:new <name>
272
+ - 快进到任务:/opsx:ff <name>
273
+ - 继续探索:继续交谈
274
+ ```
275
+
276
+ 但这个总结是可选的。有时思考本身就是价值。
277
+
278
+ ---
279
+
280
+ ## 护栏
281
+
282
+ - **不要实施** - 绝不编写代码或实施功能。创建 OpenSpec 产物是可以的,编写应用程序代码是不行的。
283
+ - **不要假装理解** - 如果某事不清楚,深入挖掘
284
+ - **不要匆忙** - 发现是思考时间,不是任务时间
285
+ - **不要强迫结构** - 让模式自然显现
286
+ - **不要自动捕捉** - 提议保存见解,不要直接做
287
+ - **做可视化** - 一张好图胜过千言万语
288
+ - **做探索代码库** - 将讨论建立在现实基础上
289
+ - **做质疑假设** - 包括用户的和你自己的