@modus-ai/modus 0.2.5 → 0.2.7

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 (49) hide show
  1. package/README.md +62 -45
  2. package/dist/commands/init.d.ts.map +1 -1
  3. package/dist/commands/init.js +37 -6
  4. package/dist/commands/init.js.map +1 -1
  5. package/dist/generators/claude.js +1 -1
  6. package/dist/generators/claude.js.map +1 -1
  7. package/dist/generators/codebuddy.d.ts.map +1 -1
  8. package/dist/generators/codebuddy.js +3 -1
  9. package/dist/generators/codebuddy.js.map +1 -1
  10. package/dist/generators/codex.d.ts +10 -0
  11. package/dist/generators/codex.d.ts.map +1 -0
  12. package/dist/generators/codex.js +178 -0
  13. package/dist/generators/codex.js.map +1 -0
  14. package/dist/generators/cursor.d.ts.map +1 -1
  15. package/dist/generators/cursor.js +36 -7
  16. package/dist/generators/cursor.js.map +1 -1
  17. package/dist/generators/custom.d.ts +55 -0
  18. package/dist/generators/custom.d.ts.map +1 -0
  19. package/dist/generators/custom.js +166 -0
  20. package/dist/generators/custom.js.map +1 -0
  21. package/dist/generators/index.d.ts +1 -0
  22. package/dist/generators/index.d.ts.map +1 -1
  23. package/dist/generators/index.js +10 -0
  24. package/dist/generators/index.js.map +1 -1
  25. package/dist/utils/config.d.ts +6 -1
  26. package/dist/utils/config.d.ts.map +1 -1
  27. package/dist/utils/config.js.map +1 -1
  28. package/package.json +1 -1
  29. package/schemas/harness-schema.yaml +178 -53
  30. package/templates/agents/modus-analyst.md +1 -1
  31. package/templates/commands/auto.md +61 -27
  32. package/templates/commands/harness.md +94 -34
  33. package/templates/commands/init.md +43 -10
  34. package/templates/commands/modus.md +55 -28
  35. package/templates/commands/plan.md +60 -18
  36. package/templates/commands/spec.md +69 -25
  37. package/templates/commands/upgrade.md +54 -0
  38. package/templates/commands/vibe.md +55 -5
  39. package/templates/knowledge-catalog.md +23 -10
  40. package/templates/skills/modus-agents/analyst/SKILL.md +11 -12
  41. package/templates/skills/modus-agents/developer/SKILL.md +14 -12
  42. package/templates/skills/modus-agents/reviewer/SKILL.md +50 -23
  43. package/templates/skills/modus-auto/SKILL.md +580 -123
  44. package/templates/skills/modus-design-brief/SKILL.md +17 -9
  45. package/templates/skills/modus-harness/SKILL.md +95 -96
  46. package/templates/skills/modus-init/SKILL.md +403 -188
  47. package/templates/skills/modus-plan/SKILL.md +16 -5
  48. package/templates/skills/modus-platform/SKILL.md +271 -0
  49. package/templates/skills/modus-vibe/SKILL.md +285 -187
@@ -1,59 +1,393 @@
1
1
  ---
2
2
  name: modus-auto
3
- description: Use this skill when executing /modus:auto command. Reads a TAPD Story URL, scores it across 4 dimensions (complexity/risk/clarity/contract-impact), recommends the best Modus mode (vibe/plan/spec/harness), presents reasoning, waits for human mode selection, then auto-launches the chosen mode with context pre-filled. Trigger on /modus:auto command.
3
+ description: Use this skill when executing /modus:auto command. Reads a TAPD Story URL (or manual input), scores it across 4 dimensions (complexity/risk/clarity/contract-impact), recommends the best Modus mode (vibe/plan/spec/harness) using Cursor-style mode routing + Swarm-style context handoff, presents reasoning, then launches the chosen mode with full context pre-filled. In Codex environment: single-shot decision with auto-execution (no interactive wait). Trigger on /modus:auto command.
4
4
  allowed-tools: Read, Write, Glob, Bash
5
5
  disable: false
6
6
  ---
7
7
 
8
- # modus-auto(智能模式推荐)
8
+ # modus-auto(智能模式路由)
9
9
 
10
- **触发条件:** 用户运行 `/modus:auto [TAPD Story URL]` 时使用此 Skill。
10
+ **触发条件:** 用户运行 `/modus:auto [TAPD URL 或需求描述]` 时使用此 Skill。
11
11
 
12
- ## 职责
12
+ ---
13
+
14
+ ## 设计理念
15
+
16
+ ### 业界借鉴
17
+
18
+ **1. Cursor 三模式路由(Ask / Plan / Agent)**
19
+
20
+ 参照 Cursor 的模式设计哲学:根据任务特征自动选择交互深度。
21
+ - `Ask(只问不改)` → 对应 `vibe`(直接编码,轻量)
22
+ - `Plan(先规划再执行)` → 对应 `plan` / `spec`
23
+ - `Agent(全自动执行)` → 对应 `harness`
24
+
25
+ Cursor 设计核心:**模式切换有理由,每次推荐都附带简短的切换原因**,降低用户心智负担。本 Skill 完全复用此理念。
26
+
27
+ **2. OpenAI Swarm 的 Agent Handoff + Context 透传**
28
+
29
+ 参照 Swarm 的 `Handoff` 机制:当 auto 决定路由到某个模式时,不仅仅传递 URL,而是构造一个**完整的结构化上下文包(Context Bundle)**,使目标模式无需重复读取 TAPD,直接进入执行阶段。
30
+
31
+ ```
32
+ Context Bundle = {
33
+ story_id, story_title, story_desc, acceptance_criteria,
34
+ domains[], scores{}, recommended_mode, skip_clarify: true
35
+ }
36
+ ```
37
+
38
+ **3. LangGraph 的条件边路由可视化**
39
+
40
+ 输出时展示类似 LangGraph Conditional Edge 的决策路径,让用户看到每个维度如何影响最终路由:
41
+
42
+ ```
43
+ [TAPD Story] → [四维评分] → {复杂度=中,风险=低,契约=有} → [spec]
44
+ ```
45
+
46
+ **4. GitHub Copilot Workspace 的多步规划流程**
47
+
48
+ 参照 Copilot Workspace 在给出建议前先「理解意图 → 分解任务 → 确认方案」的三段式流程,auto 在路由前同样先做意图提取,确保传给目标模式的 Context Bundle 足够准确,避免目标模式从零开始理解需求。
13
49
 
14
- 读取 TAPD Story 内容,从四个维度评分,推荐最合适的 Modus 模式(vibe/plan/spec/harness),展示推荐理由和备选对比,等待用户选择,确认参数后自动透传 TAPD 内容启动所选模式。
50
+ **5. Linear / Jira AI 的上下文感知 Issue 路由**
51
+
52
+ 参照 Linear AI 根据 issue 类型、优先级、关联标签自动分配处理流程的理念,auto 的四维评分矩阵等效于 issue 的 label 系统,不同 label 组合触发不同工作流。
53
+
54
+ ---
55
+
56
+ ## 参数参考(完整列表)
57
+
58
+ ```
59
+ /modus:auto [tapd-url 或需求描述] [参数]
60
+
61
+ 输入来源:
62
+ --story <id> 接受纯 Story ID(不含完整 URL),如 --story 1234567890
63
+ --skip-tapd 跳过 TAPD MCP 读取,进入手动粘贴模式(离线场景)
64
+ --context <file> 注入额外上下文文件(需求截图、设计文档路径等,如 --context design.md)
65
+ --resume 从上次中断的 auto 会话恢复(断点续跑,读取上次评分缓存)
66
+
67
+ 分析控制:
68
+ --domain <name> 预先指定业务域(跳过域识别步骤,如 --domain biz-order)
69
+ --explain 在评分输出中附上每个维度的详细判定依据说明
70
+ --scores-only 仅输出四维评分表,不继续路由(供 CI/脚本消费)
71
+ --show-scores 展示四维评分详情及权重计算过程(比 --explain 更简洁)
72
+
73
+ 执行控制:
74
+ --force <mode> 强制指定模式(vibe|plan|spec|harness),跳过推荐评分直接启动
75
+ --no-confirm 跳过二次确认,评分完成后直接启动推荐模式(Codex/CI 场景用)
76
+ --dry-run 仅输出推荐结果和路由路径,不启动任何命令
77
+ --preview 预览推荐模式的产物目录结构,不执行任何命令
78
+ --timeout <n> TAPD MCP 调用超时(秒),默认 10
79
+ --no-cache 强制重新读取 TAPD,跳过本地缓存
80
+
81
+ 项目与格式:
82
+ --project <name> 指定项目(多项目 workspace 必填,如 --project my-service)
83
+ --template <style> 输出样式:minimal(仅结论)| standard(默认)| verbose(含完整推理)
84
+ --output <format> 结果输出格式(terminal默认 | markdown | json,json 供工具链消费)
85
+ --lang <zh|en> 响应语言,默认 zh(中文)
86
+
87
+ 调试:
88
+ --verbose 输出完整评分推理过程(每个维度的判定理由)
89
+ --budget <tokens> 限制 Skill 加载的上下文量(默认 3000 tokens,省 token 时用)
90
+ --help 显示完整帮助(中文),列出所有参数和用法示例
91
+ ```
92
+
93
+ ### 参数组合示例
94
+
95
+ ```bash
96
+ # 最常用:直接分析 TAPD Story
97
+ /modus:auto https://tapd.cn/company/stories/view/1234567890
98
+
99
+ # 使用纯 Story ID(不需要完整 URL)
100
+ /modus:auto --story 1234567890
101
+
102
+ # 看评分细节 + 每维度判定说明
103
+ /modus:auto https://tapd.cn/.../1234 --show-scores --explain
104
+
105
+ # 强制跳过评分,直接 harness
106
+ /modus:auto https://tapd.cn/.../1234 --force harness
107
+
108
+ # 不带 URL,手动描述需求(Codex 常用)
109
+ /modus:auto 新增批量导出接口,支持按条件筛选,返回 Excel
110
+
111
+ # CI/全自动场景:只输出评分,不路由
112
+ /modus:auto https://tapd.cn/.../1234 --scores-only --output json
113
+
114
+ # CI/全自动场景:不等用户确认
115
+ /modus:auto https://tapd.cn/.../1234 --no-confirm
116
+
117
+ # 预览推荐模式会产出哪些文件,不实际执行
118
+ /modus:auto https://tapd.cn/.../1234 --preview
119
+
120
+ # 导出 JSON 供外部工具读取
121
+ /modus:auto https://tapd.cn/.../1234 --dry-run --output json
122
+
123
+ # 离线场景(无 TAPD 访问)
124
+ /modus:auto --skip-tapd
125
+
126
+ # 注入需求截图/设计文档
127
+ /modus:auto https://tapd.cn/.../1234 --context docs/api-design.md
128
+
129
+ # 多项目工作区
130
+ /modus:auto https://tapd.cn/.../1234 --project my-service
131
+
132
+ # 恢复上次中断的 auto 会话
133
+ /modus:auto --resume
134
+
135
+ # 简洁输出(仅结论,适合快速决策)
136
+ /modus:auto https://tapd.cn/.../1234 --template minimal
137
+
138
+ # 强制重读 TAPD(Story 内容有更新时)
139
+ /modus:auto https://tapd.cn/.../1234 --no-cache
140
+ ```
141
+
142
+ ---
143
+
144
+ ## --help 响应模板
145
+
146
+ 当用户运行 `/modus:auto --help` 时,输出以下内容:
147
+
148
+ ```
149
+ Modus Auto — 智能模式路由工具
150
+ 版本:3.3.0
151
+
152
+ 用途:
153
+ 不确定该用哪个 Modus 命令时,首选此命令。
154
+ 读取 TAPD Story(或手动描述需求),从四个维度评分,自动推荐最适合
155
+ 的执行模式(vibe/plan/spec/harness),确认后透传上下文直接启动。
156
+
157
+ 设计参照:
158
+ · Cursor Ask/Plan/Agent 三模式路由理念(模式切换有理由)
159
+ · OpenAI Swarm 的 Context Bundle 透传机制(无缝 Handoff)
160
+ · LangGraph 的条件边决策可视化(路由过程透明可追溯)
161
+ · GitHub Copilot Workspace 的意图理解→任务分解三段式流程
162
+ · Linear AI 的上下文感知 Issue 路由(标签组合触发工作流)
163
+
164
+ 语法:
165
+ /modus:auto [tapd-url 或需求描述] [参数]
166
+
167
+ 输入来源:
168
+ --story <id> 接受纯 Story ID,如 --story 1234567890
169
+ --skip-tapd 跳过 TAPD 读取,手动输入需求
170
+ --context <file> 注入额外上下文文件(设计文档/截图)
171
+ --resume 从上次中断的 auto 会话恢复
172
+
173
+ 分析控制:
174
+ --domain <name> 预指定业务域(如 biz-order/biz-payment),跳过识别
175
+ --explain 在评分中附上每维度详细判定依据
176
+ --scores-only 仅输出评分表,不路由(CI 脚本用)
177
+ --show-scores 显示评分详情及计算过程
178
+
179
+ 执行控制:
180
+ --force <mode> 强制指定模式(vibe|plan|spec|harness),跳过评分
181
+ --no-confirm 不等待确认,直接执行推荐模式
182
+ --dry-run 只推荐不执行
183
+ --preview 预览推荐模式的产物目录,不执行
184
+ --timeout <n> TAPD MCP 调用超时秒数(默认 10)
185
+ --no-cache 强制重读 TAPD,跳过缓存
186
+
187
+ 项目与格式:
188
+ --project <name> 指定项目(多项目时使用)
189
+ --template <style> 输出样式:minimal | standard | verbose
190
+ --output <format> 输出格式(terminal|markdown|json)
191
+ --lang <zh|en> 响应语言(默认 zh)
192
+
193
+ 调试:
194
+ --verbose 输出完整推理过程(含每维度理由)
195
+ --budget <tokens> 限制上下文加载量(默认 3000)
196
+ --help 显示本帮助
197
+
198
+ 四种模式说明(行业框架对照):
199
+ vibe → 直接编码,适合低风险、单文件、bug fix
200
+ 类比:GitHub Copilot 内联补全 — 有把握直接写
201
+ plan → 先规划再执行,适合明确中等需求
202
+ 类比:Cursor Plan 模式 — 先只读扫描确认方案,再动手
203
+ spec → 规范驱动开发,适合接口契约变更、高风险需求
204
+ 类比:OpenAPI Spec + BDD(Cucumber)— 先定契约和验收场景
205
+ harness → 全自动双Loop流水线,适合模糊复杂需求
206
+ 类比:GitHub Actions CI/CD — 多 SubAgent 串并行全托管
207
+
208
+ 快速决策口诀:
209
+ 改一个文件?→ vibe
210
+ 需求清楚但要规划?→ plan
211
+ 有接口变更或高风险?→ spec
212
+ 需求模糊或要全自动?→ harness
213
+
214
+ 示例:
215
+ /modus:auto https://tapd.cn/company/stories/view/1234567890
216
+ /modus:auto --story 1234567890 --domain biz-order
217
+ /modus:auto 新增批量导出接口 --explain
218
+ /modus:auto https://tapd.cn/.../1234 --force spec --no-confirm
219
+ /modus:auto --skip-tapd --verbose
220
+ /modus:auto https://tapd.cn/.../1234 --scores-only --output json
221
+ /modus:auto --resume
222
+
223
+ 更多文档:modus/knowledge-catalog.md
224
+ ```
15
225
 
16
226
  ---
17
227
 
18
228
  ## 执行流程
19
229
 
20
- ### Step 1:读取 TAPD Story
230
+ ### 平台检测(首步)
231
+
232
+ 在执行任何流程前,检测当前运行平台(优先级从高到低):
233
+
234
+ ```
235
+ 检测顺序:
236
+ 1. 环境变量 OPENAI_CODEX=1 或 CODEX_ENV=true → Codex 路径
237
+ 2. 存在 AGENTS.md 且运行环境为非交互式终端 → Codex 路径
238
+ 3. 用户 prompt 包含 Codex 触发关键词(见下方列表) → Codex 路径
239
+ 4. 无 AskUser 工具可用(最终兜底) → Codex 路径
240
+ 5. 以上均不满足 → 标准交互路径
241
+
242
+ Codex 自然语言触发关键词(无需 /modus:auto 命令格式):
243
+ 中文:开始开发、帮我分析这个需求、这个 Story 用哪个模式、全自动跑一遍、
244
+ 帮我路由、分析需求然后开发、选个模式
245
+ 英文:analyze this story, start development, which mode should I use,
246
+ auto route, run full pipeline, pick a mode for this
247
+ ```
248
+
249
+ ---
250
+
251
+ ### 🤖 Codex 单次执行路径(Step 0-C)
252
+
253
+ > Codex 环境特点:无交互等待、无 AskUser、可能无 TAPD MCP、自然语言触发
254
+
255
+ **0-C-1:上下文读取(含降级处理)**
256
+
257
+ ```python
258
+ # 1. 尝试读取 TAPD Story(失败则优雅降级)
259
+ try:
260
+ story = tapd_mcp.get_story(story_id)
261
+ except MCP_UNAVAILABLE:
262
+ story = extract_from_natural_language(user_input)
263
+ note = "⚠️ TAPD MCP 不可用,基于描述文本进行评分"
264
+
265
+ # 2. 尝试读取知识目录(文件系统不可用时跳过)
266
+ try:
267
+ catalog = read("modus/knowledge-catalog.md")
268
+ # v3.2 路径:modus/knowledge/biz-*/SKILL.md(唯一权威)
269
+ except FILESYSTEM_UNAVAILABLE:
270
+ catalog = None
271
+ note += " | 文件系统不可用,跳过 Skill 加载,基于 Story 文本评分"
272
+ ```
273
+
274
+ **0-C-2:自动评分 + 单次决策**
275
+
276
+ 直接完成四维评分,不等待用户输入,输出推荐结果并**立即启动**推荐模式:
277
+
278
+ ```
279
+ [Codex 模式] 自动分析中...
280
+ ─────────────────────────────
281
+ 复杂度: 中等 — 涉及 2 个业务域
282
+ 风险: 低 — 纯新增功能
283
+ 明确度: 高 — 验收标准完整
284
+ 契约: 有 — 新增 POST /api/v1/xxx/export
285
+
286
+ 决策路径:中等复杂 + 有接口契约 → spec
287
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
288
+ 自动启动 /modus:spec(Codex 模式,跳过确认)
289
+ ```
290
+
291
+ **0-C-3:Context Bundle 透传**
292
+
293
+ 构造结构化上下文包传递给目标模式:
294
+
295
+ ```yaml
296
+ context_bundle:
297
+ story_id: "1234567890"
298
+ story_title: "{Story 标题}"
299
+ domains: ["{domain}"]
300
+ domain_skill_path: "modus/knowledge/{domain}/SKILL.md" # v3.2 路径
301
+ scores: {complexity: 2, risk: 1, clarity: 3, contract: 1}
302
+ recommended_mode: "spec"
303
+ skip_clarify: true
304
+ from_auto: true
305
+ platform: "codex"
306
+ filesystem_available: false
307
+ ```
308
+
309
+ **0-C-4:结构化 JSON 日志输出(--output json 时)**
310
+
311
+ ```json
312
+ {
313
+ "mode": "codex",
314
+ "story_id": "1234567890",
315
+ "story_title": "{Story 标题}",
316
+ "scores": {"complexity": 2, "risk": 1, "clarity": 3, "contract": 1},
317
+ "recommended": "spec",
318
+ "reason": "有接口契约变更,建议规范驱动开发",
319
+ "domains": ["{domain}"],
320
+ "context_bundle_path": null,
321
+ "auto_launched": true,
322
+ "tapd_available": true,
323
+ "filesystem_available": false
324
+ }
325
+ ```
326
+
327
+ ---
328
+
329
+ ### 📋 标准交互路径(Step 1-7)
330
+
331
+ #### Step 1:读取 TAPD Story
21
332
 
22
333
  通过 TAPD MCP 读取 Story 内容:
23
334
 
24
335
  ```bash
25
- # URL 提取 story-id,调用 TAPD MCP 获取内容
26
- story_id = extract_from_url(tapd_url)
336
+ story_id = extract_from_url(tapd_url) # 支持完整 URL
337
+ #
338
+ story_id = args["--story"] # 支持纯 ID(--story 1234567890)
27
339
  story = tapd_mcp.get_story(story_id)
28
340
  ```
29
341
 
30
- 提取以下字段:
31
- - 标题、描述、验收标准
32
- - 优先级、预估工时
33
- - 涉及模块(从标题/描述中判断)
34
- - 迭代/Sprint 信息
342
+ 提取字段:标题、描述、验收标准、优先级、预估工时、涉及模块、迭代信息。
343
+
344
+ TAPD MCP 不可用,提示:
345
+ ```
346
+ ⚠️ TAPD MCP 不可用,请粘贴 Story 内容(以 ---END--- 结束):
347
+ ```
348
+
349
+ 若用户带 `--skip-tapd` 参数,直接进入手动输入模式。
350
+
351
+ 若用户直接描述需求(非 URL),从自然语言中提取关键信息,继续执行。
35
352
 
36
- TAPD MCP 不可用,提示用户手动粘贴 Story 内容,继续执行。
353
+ 若用户带 `--resume`,尝试读取上次会话缓存:
354
+ ```bash
355
+ cache = read(".modus-auto-cache.yaml")
356
+ if cache.valid:
357
+ 跳过 Step 1-3,直接从 Step 4 路由决策继续
358
+ ```
37
359
 
38
- ### Step 2:读取知识目录
360
+ #### Step 2:读取知识目录
39
361
 
40
- 读取 `modus/knowledge-catalog.md`,了解可用的业务 Skill 及其成熟度。用于判断哪些域已有充足上下文。
362
+ 读取 `modus/knowledge-catalog.md`:
363
+
364
+ ```
365
+ 知识库路径(v3.2 Single Source of Truth):
366
+ modus/knowledge/biz-*/SKILL.md ← Layer 2 业务域(唯一权威,v3.1+ 迁移后)
367
+ modus/knowledge/_tech-wiki/SKILL.md
368
+ modus/knowledge/_conventions/SKILL.md
369
+
370
+ ⚠️ 注意(v3.1+ 变更):业务域 Skill 已迁移至 modus/knowledge/biz-*/SKILL.md,
371
+ .codebuddy/skills/modus-biz-* 为引用桩,不含实际内容,请勿从旧路径读取。
372
+ ```
41
373
 
42
- ### Step 3:四维评分
374
+ 若用户指定了 `--domain <name>`,跳过自动域识别,直接加载对应 Skill。
43
375
 
44
- Story 内容进行结构化分析,输出每个维度的评分:
376
+ 若用户指定了 `--budget <tokens>`,按限额裁剪 Skill 加载量。
45
377
 
46
- #### 维度一:复杂度 (Complexity)
378
+ #### Step 3:四维评分
379
+
380
+ 对 Story 进行结构化评分:
381
+
382
+ ##### 维度一:复杂度 (Complexity)
47
383
 
48
384
  | 分值 | 判定条件 |
49
385
  |------|----------|
50
386
  | 低 (1) | 单文件修改、bug fix、文案/配置调整 |
51
387
  | 中 (2) | 1-2 个业务域、5 个以内文件变更、新增接口但无架构变化 |
52
- | 高 (3) | 跨 3+ 个域、需新建数据表、涉及消息队列/异步流程 |
53
-
54
- 判断依据:Story 描述中的关键词("新增表"、"重构"、"接入 MQ"、涉及文件数估算)
388
+ | 高 (3) | 跨 3+ 个域、需新建数据表、涉及消息队列/异步流程/数据迁移 |
55
389
 
56
- #### 维度二:风险 (Risk)
390
+ ##### 维度二:风险 (Risk)
57
391
 
58
392
  | 分值 | 判定条件 |
59
393
  |------|----------|
@@ -61,9 +395,7 @@ story = tapd_mcp.get_story(story_id)
61
395
  | 中 (2) | 修改已有接口或业务逻辑,影响单一模块 |
62
396
  | 高 (3) | 涉及支付/权限/多租户隔离/金额计算/数据迁移/接口废弃 |
63
397
 
64
- #### 维度三:需求明确度 (Clarity)
65
-
66
- > ⚠️ **刻度方向与复杂度/风险相反**:分值越高 = 需求越清晰(好)。判定树中「明确度=低」触发 harness,「明确度=高」支持 plan,方向勿与其他维度混淆。
398
+ ##### 维度三:需求明确度 (Clarity)
67
399
 
68
400
  | 分值 | 判定条件 |
69
401
  |------|----------|
@@ -71,155 +403,280 @@ story = tapd_mcp.get_story(story_id)
71
403
  | 中 (2) | 有基本描述,部分细节待确认 |
72
404
  | 低 (1) | 描述模糊、无验收标准、需大量澄清 |
73
405
 
74
- #### 维度四:接口契约影响 (Contract Impact)
406
+ ##### 维度四:接口契约影响 (Contract Impact)
75
407
 
76
408
  | 分值 | 判定条件 |
77
409
  |------|----------|
78
410
  | 无 (0) | 纯内部逻辑,不影响对外接口 |
79
411
  | 有 (1) | 新增接口、修改现有接口签名/返回值、废弃接口 |
80
412
 
81
- ### Step 4:判定推荐模式
82
-
83
- 根据四维评分,按以下判定树确定推荐模式:
84
-
413
+ 若用户带 `--explain`,对每个维度输出判定依据:
414
+ ```
415
+ 复杂度=中(2):涉及单域,预估变更 4 个文件,无新建表,
416
+ 关键词命中:「新增接口」「按条件筛选」
85
417
  ```
86
- 复杂度=低 且 风险=低 且 接口契约影响=无
87
- → 推荐 vibe(直接编码,无需文档)
88
418
 
89
- 复杂度=低/中 且 明确度=高 且 接口契约影响=无
90
- → 推荐 plan(功能规划,有 proposal+design+tasks)
419
+ 若用户带 `--scores-only`,输出评分表后直接结束,不继续路由。
91
420
 
92
- 任意维度满足以下任一:
93
- - 接口契约影响=有
94
- - 风险=高
95
- - 需要可测试的验收标准
96
- → 推荐 spec(规范驱动,含 delta specs + GIVEN/WHEN/THEN)
421
+ #### Step 4:路由决策(LangGraph 条件边)
97
422
 
98
- 以下情况推荐 harness:
99
- - 明确度=低(需求不清晰,AI 自动分析更可靠)
100
- - 复杂度=高 且 风险=高
101
- - 用户希望全自动从需求到部署
102
- → 推荐 harness(双 Loop 全自动流程)
423
+ 根据四维评分,按以下决策树路由:
103
424
 
104
- **优先级规则(多条件同时满足时):**
105
- harness > spec > plan > vibe
106
- 即:若 harness 条件与 spec 条件同时满足,推荐 harness;
107
- 若 spec 条件与 plan 条件同时满足,推荐 spec;以此类推。
108
- 向用户展示次优选项以供参考。
425
+ ```
426
+ ┌─ TAPD Story / 需求描述 ─┐
427
+
428
+ [四维评分引擎]
429
+ C=复杂度 R=风险 Cl=明确度 I=契约
430
+
431
+ ┌───────────┼───────────┬──────────────┐
432
+ ▼ ▼ ▼ ▼
433
+ C=低,R=低 Cl=高,无I I=有或R=高 Cl=低或
434
+ 且无I 且中低复杂 需可测规格 C=高且R=高
435
+ │ │ │ │
436
+ vibe plan spec harness
437
+ 直接编码 先规划 规范驱动 全自动流水线
109
438
  ```
110
439
 
111
- ### Step 5:展示推荐与对比
440
+ **判定规则(优先级从高到低):**
112
441
 
113
- **输出格式:**
442
+ ```
443
+ 1. 明确度=低(Cl=1)且 复杂度=高(C=3) → harness
444
+ 2. 接口契约=有(I=1) → spec
445
+ 3. 风险=高(R=3) → spec
446
+ 4. 明确度=低(Cl=1) → harness
447
+ 5. 复杂度=低(C=1)且 风险=低(R=1) → vibe
448
+ 6. 明确度=高(Cl=3)且 契约=无(I=0) → plan
449
+ 7. 其他情况 → plan(默认安全选择)
450
+ ```
451
+
452
+ 若用户带 `--force <mode>`,跳过以上判定,直接路由到指定模式。
114
453
 
454
+ 若用户带 `--preview`,路由完成后输出产物目录预览,然后停止:
455
+ ```
456
+ 预览:/modus:spec 将在以下路径生成产物
457
+ modus/stories/{id}/spec/
458
+ ├── .modus-state.yaml
459
+ ├── delta/{domain}.md
460
+ ├── design.md
461
+ ├── design-brief.md
462
+ └── tasks.md
463
+ (--preview 模式:不执行任何命令)
115
464
  ```
116
- 📊 需求分析结果 — {Story 标题}
117
- ─────────────────────────────────────────
118
- 复杂度: {低/中/高} — {一句话理由}
119
- 风险: {低/中/高} — {一句话理由}
120
- 需求明确度: {低/中/高} — {一句话理由}
121
- 接口契约: {无/有} — {一句话理由}
122
465
 
123
- 🎯 推荐模式:/modus:{mode}
124
- 理由:{2-3 句话说明为何这个模式最合适}
466
+ 若用户带 `--dry-run`,输出推荐结果后停止,不启动任何命令。
125
467
 
126
- 📋 其他选项对比:
127
- plan — {适用场景,以及为何当前需求不优先选它}
128
- spec — {适用场景,以及为何当前需求不优先选它}
129
- harness — {适用场景,以及为何当前需求不优先选它}
130
- vibe — {适用场景,以及为何当前需求不优先选它}
468
+ #### Step 5:展示推荐与对比(Cursor 风格 + 行业框架名词)
131
469
 
132
- 请选择要使用的模式:
133
- A. /modus:vibe 直接编码
134
- B. /modus:plan — 功能规划 ← 推荐
135
- C. /modus:spec — 规范驱动开发
136
- D. /modus:harness — 全自动 Harness
470
+ ```
471
+ 📊 需求路由分析 {Story 标题}
472
+ ══════════════════════════════════════════════════════
473
+ 决策路径:[TAPD] → [评分] → {C=中,R=低,Cl=高,I=有} → [spec]
474
+
475
+ 维度评分:
476
+ 复杂度 ████░░ 中等(2/3) — {判定理由}
477
+ 风险 ██░░░░ 低 (1/3) — {判定理由}
478
+ 明确度 ██████ 高 (3/3) — {判定理由}
479
+ 契约 ██████ 有 (1/1) — {涉及接口}
480
+
481
+ 🎯 推荐:/modus:spec
482
+ 理由:{2-3 句话说明推荐原因}
483
+
484
+ 📋 模式对比(行业框架对照):
485
+ vibe ✗ {不推荐原因}
486
+ 类比:GitHub Copilot 内联补全 — 适合单文件、有把握的小改动
487
+ plan △ {可用但非最优原因}
488
+ 类比:Cursor Plan 模式 — 先只读扫描确认方案,再动手修改
489
+ spec ✓ 推荐 — {推荐原因}
490
+ 类比:OpenAPI Spec + BDD(Cucumber GIVEN/WHEN/THEN)
491
+ harness △ {可用但过重原因}
492
+ 类比:GitHub Actions CI/CD — 多 SubAgent 串并行全托管
493
+
494
+ 请选择模式:
495
+ A. /modus:vibe — 直接编码(快,类比 Copilot inline edit)
496
+ B. /modus:plan — 先规划后执行(均衡,类比 Cursor Plan 模式)
497
+ C. /modus:spec — 规范驱动开发 ← 推荐(类比 OpenAPI Spec + BDD)
498
+ D. /modus:harness — 全自动 Harness(重,类比 GitHub Actions pipeline)
499
+
500
+ 或输入 --force <mode> 强制指定
137
501
  ```
138
502
 
139
- ⏸️ **等待用户选择**
503
+ ⏸️ **等待用户选择**(Codex 模式跳过此步)
140
504
 
141
- ### Step 6:二次确认窗口
505
+ #### Step 6:参数确认窗口
142
506
 
143
- 用户选择模式后,展示参数确认窗口:
507
+ 用户选择后,展示参数确认(Swarm 风格):
144
508
 
145
- **若选择 vibe:**
509
+ **→ vibe:**
146
510
  ```
147
- 确认参数:
148
- 任务描述: {从 Story 标题/描述提取的一句话任务描述}
149
- 涉及业务域: {自动判断的域列表}
511
+ 确认启动 /modus:vibe
512
+ 任务描述: {从 Story 标题+描述生成的一句话任务}
513
+ 业务域: {domain} [draft]
514
+ 上下文: 已加载 Story 摘要({token数} tokens)
150
515
 
151
516
  直接开始编码?[Y/n]
152
517
  ```
153
518
 
154
- **若选择 plan:**
519
+ **→ plan:**
520
+ ```
521
+ 确认启动 /modus:plan
522
+ Story 摘要: {标题 + 核心需求}
523
+ 业务域: {domain} [draft]
524
+ 产物路径: modus/stories/{id}/plan.md ← v3.2 统一路由
525
+ 快速模式(--quick,跳过设计文档): [y/N]
526
+
527
+ 确认?[Y/n]
155
528
  ```
156
- 确认参数:
157
- 需求描述: {从 Story 内容生成的 plan prompt}
158
- 涉及域: {order, payment}
159
- 是否快速模式(跳过 design.md): [y/N]
160
529
 
161
- 确认后将启动 /modus:plan,输入以上描述。[Y/n]
530
+ **→ spec:**
531
+ ```
532
+ 确认启动 /modus:spec
533
+ Story URL: {原始 URL}
534
+ 业务域: {domain} [draft]
535
+ 规格级别: Full(因有接口契约变更)/ 可加 --lite 降级
536
+ 产物路径: modus/stories/{id}/spec/ ← v3.2 统一路由
537
+ 验收标准: 已提取 {n} 条,将作为 Scenario 输入
538
+
539
+ 确认?[Y/n]
162
540
  ```
163
541
 
164
- **若选择 spec:**
542
+ **→ harness:**
543
+ ```
544
+ 确认启动 /modus:harness
545
+ Story URL: {原始 URL}
546
+ 产物路径: modus/stories/{id}/harness/ ← v3.2 统一路由
547
+ 跳过阶段: 无(如需跳过:--skip [agents])
548
+
549
+ ⚠️ Harness 将全自动执行多个 SubAgent,预计耗时较长。
550
+ 确认?[Y/n]
165
551
  ```
166
- 确认参数:
167
- 需求描述: {从 Story 内容生成的 spec prompt}
168
- 涉及域: {order}
169
- 规格级别: Full(因为涉及接口契约变更)/ Lite(--lite flag)
170
552
 
171
- 确认后将启动 /modus:spec,输入以上描述。[Y/n]
553
+ ⏸️ **等待用户确认**(带 `--no-confirm` 则跳过)
554
+
555
+ #### Step 7:Context Bundle 透传 + 启动
556
+
557
+ ```yaml
558
+ context_bundle:
559
+ story_id: "{id}"
560
+ story_title: "{title}"
561
+ story_desc: "{desc_summary}"
562
+ acceptance_criteria: ["{ac1}", "{ac2}"]
563
+ domains: ["{domain}"]
564
+ domain_skill_paths: # v3.2 路径(唯一权威)
565
+ - "modus/knowledge/{domain}/SKILL.md"
566
+ domain_skills_loaded: true
567
+ scores:
568
+ complexity: 2
569
+ risk: 1
570
+ clarity: 3
571
+ contract: 1
572
+ recommended_mode: "spec"
573
+ user_selected_mode: "spec"
574
+ skip_clarify: true
575
+ from_auto: true
576
+ platform: "cursor" # cursor | codex | claude | codebuddy
172
577
  ```
173
578
 
174
- **若选择 harness:**
579
+ 启动各模式时的行为:
580
+ - **vibe**:透传任务描述 + 业务域,跳过域识别步骤
581
+ - **plan**:透传 Story 摘要 + 验收标准,跳过 Step 3 澄清阶段
582
+ - **spec**:透传验收标准作为 Scenario 参考,跳过 TAPD 重读
583
+ - **harness**:透传完整 URL,harness 内部自行处理(无需 bundle)
584
+
585
+ ---
586
+
587
+ ## 产物路径规范(v3.2)
588
+
589
+ ```
590
+ 有 --story [id]:
591
+ modus/stories/{id}/plan.md # plan 产物
592
+ modus/stories/{id}/spec/ # spec 产物目录
593
+ modus/stories/{id}/harness/ # harness 产物目录
594
+
595
+ 无 --story(自动推断 feature 名):
596
+ modus/local/{feature-name}/plan.md
597
+ modus/local/{feature-name}/spec/
175
598
  ```
176
- 确认参数:
177
- TAPD Story URL: {原始 URL}
178
- 将直接透传给 /modus:harness
179
599
 
180
- 确认?[Y/n]
600
+ > **v3.2 变更说明**:废弃 `modus/plans/active/{id}/`,统一使用 `modus/stories/{id}/`。
601
+
602
+ ---
603
+
604
+ ## 无 TAPD URL 时的处理
605
+
606
+ 若用户直接运行 `/modus:auto`(不带任何参数),提示:
607
+
181
608
  ```
609
+ Modus Auto — 请提供需求来源:
610
+
611
+ 方式 1:TAPD Story URL
612
+ /modus:auto https://tapd.cn/company/stories/view/1234567890
182
613
 
183
- ⏸️ **等待用户确认**
614
+ 方式 2:纯 Story ID
615
+ /modus:auto --story 1234567890
184
616
 
185
- ### Step 7:启动所选模式
617
+ 方式 3:自然语言描述
618
+ /modus:auto 新增批量导出接口,支持按条件筛选,返回 Excel
186
619
 
187
- 用户确认后,根据选择自动触发对应模式:
620
+ 方式 4:手动粘贴 Story 内容(离线)
621
+ /modus:auto --skip-tapd
188
622
 
189
- - **vibe**:以已整理的任务描述调用 `/modus:vibe`,上下文包含 Story 摘要
190
- - **plan**:以整理好的 prompt 调用 `/modus:plan`,在 prompt 末尾附加标记 `[AUTO_MODE: questions_confirmed]` 和答案摘要(格式见下),modus-plan Step 3 识别到此标记后跳过交互式澄清阶段:
191
- ```
192
- [AUTO_MODE: questions_confirmed]
193
- 已确认的关键信息:
194
- - 业务域: {domain}
195
- - 核心目标: {一句话目标}
196
- - 技术约束: {列表,若用户在 Step 6 中补充了约束}
197
- ```
198
- - **spec**:以整理好的 prompt 调用 `/modus:spec`,携带 Story 验收标准作为 Scenario 参考输入
199
- - **harness**:直接调用 `/modus:harness {tapd_url}`
623
+ 不知道选哪个模式?直接输入需求,auto 帮你判断。
624
+ 查看帮助:/modus:auto --help
625
+ ```
200
626
 
201
627
  ---
202
628
 
203
- ## 四维评分快速参考卡
629
+ ## 快速参考卡
204
630
 
205
- | 模式 | 适用场景 | 不适合场景 |
206
- |------|----------|-----------|
207
- | `vibe` | 单文件改动、低风险 bug fix | 需要文档沉淀的功能 |
208
- | `plan` | 明确需求、中等复杂度、无接口契约变更 | 需要可测试规格、高风险 |
209
- | `spec` | 接口变更、高风险、需要 GIVEN/WHEN/THEN 验收 | 简单 bug fix、模糊需求 |
210
- | `harness` | 模糊需求、高复杂高风险、需要全自动流程 | 紧急小改动 |
631
+ | 模式 | 行业框架对照 | 适用场景 | 不适合场景 |
632
+ |------|------------|---------|-----------|
633
+ | `vibe` | GitHub Copilot inline edit | 单文件、低风险 bug fix | 有接口契约变更 |
634
+ | `plan` | Cursor Plan 模式(先只读规划) | 明确需求、中等复杂、无契约 | 高风险、需 GIVEN/WHEN/THEN |
635
+ | `spec` | OpenAPI Spec + BDD(Cucumber) | 接口变更、高风险、需验收规格 | 简单 bug fix、模糊需求 |
636
+ | `harness` | GitHub Actions CI/CD pipeline | 模糊需求、高复杂高风险、全自动 | 紧急小改动、已明确方案 |
637
+
638
+ **快速决策口诀:**
639
+ ```
640
+ 改一个文件?→ vibe
641
+ 需求清楚但要规划?→ plan
642
+ 有接口变更或高风险?→ spec
643
+ 需求模糊或要全自动?→ harness
644
+ ```
211
645
 
212
646
  ---
213
647
 
214
- ## TAPD URL 时的处理
648
+ ## Codex 平台注意事项
215
649
 
216
- 若用户直接运行 `/modus:auto`(不带 URL),提示:
650
+ - **无交互等待**:所有 `⏸️ 等待用户` 步骤跳过,直接走推荐模式
651
+ - **TAPD MCP 降级**:MCP 不可用时从自然语言描述提取信息,继续执行
652
+ - **自然语言触发**:无需 `/modus:auto` 命令格式,识别「开始开发」「分析需求」等关键词自动触发
653
+ - **--no-confirm 默认生效**:Codex 环境视同携带此参数
654
+ - **文件系统降级**:文件系统不可用时跳过 Skill 加载,仅基于 Story 文本评分,Context Bundle 不写文件
655
+ - **结构化日志**:`--output json` 时输出完整 JSON,便于在 Codex 日志中机器解析
656
+ - **Context Bundle 路径**:使用 `modus/knowledge/biz-*/SKILL.md`(v3.2 唯一权威路径),不读旧路径
217
657
 
218
- ```
219
- 请提供 TAPD Story URL,例如:
220
- /modus:auto https://tapd.cn/company/stories/view/1234567890
658
+ ---
221
659
 
222
- 或粘贴 Story 内容(以 ---END--- 结束输入):
223
- ```
660
+ ## 下游命令优化建议(行业框架参照)
661
+
662
+ > 本节为 plan/spec SKILL 的优化方向建议,供后续迭代参考。
663
+
664
+ ### /modus:plan 参照 Cursor Plan 模式的优化方向
665
+
666
+ Cursor Plan 模式的核心理念:**先只读扫描确认方案,用户批准后再执行修改**,确保不产生意外改动。
667
+
668
+ 建议对 `modus-plan` SKILL 的增强:
669
+ - 增加 `--pause-on-risk` 参数:检测到影响现有接口时暂停,等待人工确认再继续
670
+ - `plan.md` 中增加「**修改影响范围**」章节:列出将被修改的文件 + 方法签名,类比 Cursor diff preview
671
+ - 增加 `--read-only-check`:生成 plan 前先做只读扫描,确认涉及文件存在且格式符合预期
672
+ - 增加 `--checkpoint` 参数:每完成一个 Sprint 产出物后暂停等待确认
673
+
674
+ ### /modus:spec 参照 OpenAPI Spec + BDD 的优化方向
675
+
676
+ OpenAPI Specification 和 Cucumber BDD 的核心理念:**接口即契约,场景即测试,规格与实现双向绑定**。
224
677
 
225
- 接受手动粘贴的 Story 内容,跳过 MCP 读取,直接进入 Step 3 分析。
678
+ 建议对 `modus-spec` SKILL 的增强:
679
+ - delta spec 的 `### Requirement` 命名统一为 **operationId 风格**(动词+名词,如 `BatchExportItem`),对齐 OpenAPI `operationId` 规范
680
+ - 增加 `--openapi-export` 参数:从 delta spec 自动生成 OpenAPI 3.0 YAML stub
681
+ - 增加 `--gherkin-export` 参数:将 GIVEN/WHEN/THEN 导出为 Cucumber `.feature` 格式
682
+ - 增加 `--schema-validate` 参数:对 delta spec 中定义的请求/响应结构做 JSON Schema 校验