@kunlv/atdc 1.0.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 (222) hide show
  1. package/AGENTS.md +58 -0
  2. package/GO.md +245 -0
  3. package/bin/add-command.py +144 -0
  4. package/bin/atdc.js +460 -0
  5. package/bin/cls.js +98 -0
  6. package/central/link.sh +60 -0
  7. package/central/ticket_center_server/.handoffs/TASK-238389_QYinVipLimit.md +128 -0
  8. package/central/ticket_center_server/.test_plans/TASK-227254-SupportMembership-self-test-plan.md +566 -0
  9. package/central/ticket_center_server/.test_plans/task-238389-qyin-vip-limit-self-test-plan.md +210 -0
  10. package/commands/claude/atd.md +3 -0
  11. package/commands/claude/atdc/1-spec.md +5 -0
  12. package/commands/claude/atdc/1-update.md +5 -0
  13. package/commands/claude/atdc/2-qa.md +3 -0
  14. package/commands/claude/atdc/3-impl-skip-spec.md +5 -0
  15. package/commands/claude/atdc/3-impl.md +3 -0
  16. package/commands/claude/atdc/4-verify.md +3 -0
  17. package/commands/claude/atdc/5-done.md +3 -0
  18. package/commands/claude/atdc/add-command.md +4 -0
  19. package/commands/claude/atdc/add-to-hc.md +3 -0
  20. package/commands/claude/atdc/analysis-cls-log.md +4 -0
  21. package/commands/claude/atdc/article.md +6 -0
  22. package/commands/claude/atdc/bugfix.md +4 -0
  23. package/commands/claude/atdc/code-simplifier.md +8 -0
  24. package/commands/claude/atdc/commit.md +4 -0
  25. package/commands/claude/atdc/compound.md +5 -0
  26. package/commands/claude/atdc/context.md +3 -0
  27. package/commands/claude/atdc/diagnose.md +8 -0
  28. package/commands/claude/atdc/git-guardrails.md +18 -0
  29. package/commands/claude/atdc/grill-with-docs.md +8 -0
  30. package/commands/claude/atdc/handoff.md +8 -0
  31. package/commands/claude/atdc/health.md +3 -0
  32. package/commands/claude/atdc/learn.md +4 -0
  33. package/commands/claude/atdc/review.md +10 -0
  34. package/commands/claude/atdc/search.md +4 -0
  35. package/commands/claude/atdc/strategy.md +3 -0
  36. package/commands/claude/atdc/table2xlsx.md +4 -0
  37. package/commands/claude/atdc/test-plan.md +5 -0
  38. package/commands/claude/atdc/travel-planner.md +4 -0
  39. package/commands/claude/atdc/xlsx2sql-insert.md +4 -0
  40. package/commands/claude/atdc/xlsx2sql-update.md +4 -0
  41. package/commands/claude/atdc/zoom-out.md +8 -0
  42. package/commands/codex/atdc/SKILL.md +8 -0
  43. package/commands/codex/atdc-1-spec/SKILL.md +8 -0
  44. package/commands/codex/atdc-1-update/SKILL.md +8 -0
  45. package/commands/codex/atdc-2-qa/SKILL.md +8 -0
  46. package/commands/codex/atdc-3-impl/SKILL.md +8 -0
  47. package/commands/codex/atdc-3-impl-skip-spec/SKILL.md +8 -0
  48. package/commands/codex/atdc-4-verify/SKILL.md +8 -0
  49. package/commands/codex/atdc-5-done/SKILL.md +8 -0
  50. package/commands/codex/atdc-add-command/SKILL.md +7 -0
  51. package/commands/codex/atdc-add-to-hc/SKILL.md +8 -0
  52. package/commands/codex/atdc-analysis-cls-log/SKILL.md +5 -0
  53. package/commands/codex/atdc-article/SKILL.md +8 -0
  54. package/commands/codex/atdc-bugfix/SKILL.md +5 -0
  55. package/commands/codex/atdc-code-simplifier/SKILL.md +7 -0
  56. package/commands/codex/atdc-commit/SKILL.md +7 -0
  57. package/commands/codex/atdc-compound/SKILL.md +8 -0
  58. package/commands/codex/atdc-context/SKILL.md +8 -0
  59. package/commands/codex/atdc-diagnose/SKILL.md +9 -0
  60. package/commands/codex/atdc-git-guardrails/SKILL.md +19 -0
  61. package/commands/codex/atdc-grill-with-docs/SKILL.md +9 -0
  62. package/commands/codex/atdc-handoff/SKILL.md +9 -0
  63. package/commands/codex/atdc-health/SKILL.md +8 -0
  64. package/commands/codex/atdc-learn/SKILL.md +7 -0
  65. package/commands/codex/atdc-review/SKILL.md +49 -0
  66. package/commands/codex/atdc-search/SKILL.md +5 -0
  67. package/commands/codex/atdc-strategy/SKILL.md +8 -0
  68. package/commands/codex/atdc-table2xlsx/SKILL.md +8 -0
  69. package/commands/codex/atdc-test-plan/SKILL.md +13 -0
  70. package/commands/codex/atdc-travel-planner/SKILL.md +7 -0
  71. package/commands/codex/atdc-xlsx2sql-insert/SKILL.md +8 -0
  72. package/commands/codex/atdc-xlsx2sql-update/SKILL.md +8 -0
  73. package/commands/codex/atdc-zoom-out/SKILL.md +9 -0
  74. package/commands/cursor/atdc/SKILL.md +8 -0
  75. package/commands/cursor/atdc-1-spec/SKILL.md +8 -0
  76. package/commands/cursor/atdc-1-update/SKILL.md +8 -0
  77. package/commands/cursor/atdc-2-qa/SKILL.md +8 -0
  78. package/commands/cursor/atdc-3-impl/SKILL.md +8 -0
  79. package/commands/cursor/atdc-3-impl-skip-spec/SKILL.md +8 -0
  80. package/commands/cursor/atdc-4-verify/SKILL.md +8 -0
  81. package/commands/cursor/atdc-5-done/SKILL.md +8 -0
  82. package/commands/cursor/atdc-add-command/SKILL.md +7 -0
  83. package/commands/cursor/atdc-add-to-hc/SKILL.md +8 -0
  84. package/commands/cursor/atdc-analysis-cls-log/SKILL.md +5 -0
  85. package/commands/cursor/atdc-article/SKILL.md +8 -0
  86. package/commands/cursor/atdc-bugfix/SKILL.md +5 -0
  87. package/commands/cursor/atdc-code-simplifier/SKILL.md +7 -0
  88. package/commands/cursor/atdc-commit/SKILL.md +7 -0
  89. package/commands/cursor/atdc-compound/SKILL.md +8 -0
  90. package/commands/cursor/atdc-context/SKILL.md +8 -0
  91. package/commands/cursor/atdc-diagnose/SKILL.md +8 -0
  92. package/commands/cursor/atdc-git-guardrails/SKILL.md +18 -0
  93. package/commands/cursor/atdc-grill-with-docs/SKILL.md +8 -0
  94. package/commands/cursor/atdc-handoff/SKILL.md +8 -0
  95. package/commands/cursor/atdc-health/SKILL.md +8 -0
  96. package/commands/cursor/atdc-learn/SKILL.md +7 -0
  97. package/commands/cursor/atdc-review/SKILL.md +49 -0
  98. package/commands/cursor/atdc-search/SKILL.md +5 -0
  99. package/commands/cursor/atdc-strategy/SKILL.md +8 -0
  100. package/commands/cursor/atdc-table2xlsx/SKILL.md +8 -0
  101. package/commands/cursor/atdc-test-plan/SKILL.md +7 -0
  102. package/commands/cursor/atdc-travel-planner/SKILL.md +7 -0
  103. package/commands/cursor/atdc-xlsx2sql-insert/SKILL.md +8 -0
  104. package/commands/cursor/atdc-xlsx2sql-update/SKILL.md +8 -0
  105. package/commands/cursor/atdc-zoom-out/SKILL.md +8 -0
  106. package/commands/opencode/atd.md +6 -0
  107. package/commands/opencode/atdc/1-spec.md +8 -0
  108. package/commands/opencode/atdc/1-update.md +8 -0
  109. package/commands/opencode/atdc/2-qa.md +6 -0
  110. package/commands/opencode/atdc/3-impl-skip-spec.md +8 -0
  111. package/commands/opencode/atdc/3-impl.md +6 -0
  112. package/commands/opencode/atdc/4-verify.md +6 -0
  113. package/commands/opencode/atdc/5-done.md +6 -0
  114. package/commands/opencode/atdc/add-command.md +6 -0
  115. package/commands/opencode/atdc/add-to-hc.md +6 -0
  116. package/commands/opencode/atdc/analysis-cls-log.md +6 -0
  117. package/commands/opencode/atdc/article.md +6 -0
  118. package/commands/opencode/atdc/bugfix.md +6 -0
  119. package/commands/opencode/atdc/code-simplifier.md +8 -0
  120. package/commands/opencode/atdc/commit.md +6 -0
  121. package/commands/opencode/atdc/compound.md +8 -0
  122. package/commands/opencode/atdc/context.md +6 -0
  123. package/commands/opencode/atdc/diagnose.md +8 -0
  124. package/commands/opencode/atdc/git-guardrails.md +18 -0
  125. package/commands/opencode/atdc/grill-with-docs.md +8 -0
  126. package/commands/opencode/atdc/handoff.md +8 -0
  127. package/commands/opencode/atdc/health.md +6 -0
  128. package/commands/opencode/atdc/learn.md +6 -0
  129. package/commands/opencode/atdc/review.md +7 -0
  130. package/commands/opencode/atdc/search.md +6 -0
  131. package/commands/opencode/atdc/strategy.md +6 -0
  132. package/commands/opencode/atdc/table2xlsx.md +6 -0
  133. package/commands/opencode/atdc/test-plan.md +6 -0
  134. package/commands/opencode/atdc/travel-planner.md +6 -0
  135. package/commands/opencode/atdc/xlsx2sql-insert.md +6 -0
  136. package/commands/opencode/atdc/xlsx2sql-update.md +6 -0
  137. package/commands/opencode/atdc/zoom-out.md +8 -0
  138. package/config/cls-defaults.json +19 -0
  139. package/hooks/atd-archive.sh +86 -0
  140. package/hooks/atd-state.sh +165 -0
  141. package/hooks/evidence-hook.sh +88 -0
  142. package/hooks/evidence-log.sh +54 -0
  143. package/hooks/guardrails.sh +65 -0
  144. package/hooks/handoff-compress.sh +104 -0
  145. package/hooks/phase-guard.sh +134 -0
  146. package/hooks/phase-write-guard.sh +96 -0
  147. package/hooks/ponytail-fix.sh +179 -0
  148. package/hooks/ponytail-guard.sh +66 -0
  149. package/hooks/ponytail-scan.sh +62 -0
  150. package/install.sh +276 -0
  151. package/package.json +20 -0
  152. package/packages/cls/bin/cls.js +146 -0
  153. package/packages/cls/config/defaults.json +17 -0
  154. package/packages/cls/mcp/server.js +142 -0
  155. package/packages/cls/package.json +29 -0
  156. package/packages/cls/scripts/postinstall.js +19 -0
  157. package/packages/cls/src/client.js +262 -0
  158. package/prompts/1-spec.md +271 -0
  159. package/prompts/1-update.md +198 -0
  160. package/prompts/2-qa.md +164 -0
  161. package/prompts/3-impl-bugfix.md +271 -0
  162. package/prompts/3-impl.md +419 -0
  163. package/prompts/4-verify.md +160 -0
  164. package/prompts/5-done.md +227 -0
  165. package/prompts/6-article.md +571 -0
  166. package/prompts/X-add-command.md +60 -0
  167. package/prompts/X-add-to-hc.md +178 -0
  168. package/prompts/X-analysis-cls-log.md +68 -0
  169. package/prompts/X-bugfix.md +10 -0
  170. package/prompts/X-code-simplifier.md +38 -0
  171. package/prompts/X-commit.md +116 -0
  172. package/prompts/X-compound.md +188 -0
  173. package/prompts/X-context-scan.md +101 -0
  174. package/prompts/X-diagnose.md +116 -0
  175. package/prompts/X-grill-with-docs.md +120 -0
  176. package/prompts/X-handoff.md +80 -0
  177. package/prompts/X-health.md +78 -0
  178. package/prompts/X-learn.md +151 -0
  179. package/prompts/X-review.md +417 -0
  180. package/prompts/X-search.md +74 -0
  181. package/prompts/X-strategy.md +95 -0
  182. package/prompts/X-table2xlsx.md +46 -0
  183. package/prompts/X-test-plan.md +436 -0
  184. package/prompts/X-travel-planner.md +22 -0
  185. package/prompts/X-xlsx2sql-insert.md +34 -0
  186. package/prompts/X-xlsx2sql-update.md +40 -0
  187. package/prompts/X-zoom-out.md +119 -0
  188. package/reference/diagnose-loop.md +66 -0
  189. package/reference/gates.md +90 -0
  190. package/reference/git-guardrails.md +71 -0
  191. package/reference/guards.md +275 -0
  192. package/reference/learn.md +100 -0
  193. package/reference/memory.md +190 -0
  194. package/reference/risk.md +74 -0
  195. package/reference/tdd.md +40 -0
  196. package/scripts/svg2png.js +46 -0
  197. package/src/cls/client.js +244 -0
  198. package/src/constants.js +49 -0
  199. package/src/evidence/ai-draft-metrics.js +157 -0
  200. package/src/evidence/canvas.js +184 -0
  201. package/src/evidence/index.js +98 -0
  202. package/src/evidence/sink-events.js +165 -0
  203. package/src/evidence/stage-timing.js +112 -0
  204. package/src/installers/claude.js +79 -0
  205. package/src/installers/codex.js +62 -0
  206. package/src/installers/opencode.js +72 -0
  207. package/src/manifest/ponytail-patterns.json +185 -0
  208. package/src/mcp/cls-mcp-server.js +142 -0
  209. package/src/utils.js +79 -0
  210. package/src/validators/state-validate.js +123 -0
  211. package/templates/.phase-state.json +13 -0
  212. package/templates/adr.md +62 -0
  213. package/templates/changelog.md +21 -0
  214. package/templates/concepts.md +35 -0
  215. package/templates/design.md +47 -0
  216. package/templates/handoff.md +64 -0
  217. package/templates/learn-skill.md +43 -0
  218. package/templates/progress.json +17 -0
  219. package/templates/proposal.md +29 -0
  220. package/templates/solution.md +36 -0
  221. package/templates/strategy.md +39 -0
  222. package/templates/tasks.md +41 -0
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: atd-diagnose
3
+ description: >
4
+ Structured debugging loop for hard bugs and performance regressions.
5
+ Reproduce → minimise → hypothesise → instrument → fix → regression-test.
6
+ Use when: "debug this", "diagnose", bug report, code that keeps failing,
7
+ or when 3-impl TDD/C3 fails ≥2 times.
8
+ argument-hint: "What's the bug or unexpected behavior?"
9
+ ---
10
+
11
+ # prompts/X-diagnose · 结构化调试
12
+
13
+ 横向命令,任意时刻可触发:`/atdc:diagnose <问题描述>`
14
+ 也可由 `3-impl` 的 TDD 失败 / C3 验证失败自动切入。
15
+
16
+ ---
17
+
18
+ ## Phase 1:复现(Reproduce)
19
+
20
+ **目标**:把问题变成可重复的复现步骤。
21
+
22
+ 1. 询问用户:bug 的具体表现?触发操作?是否 100% 复现?
23
+ 2. 如无法复现 → 分析错误堆栈 / 日志 / 监控数据
24
+ 3. 输出:**一条可执行的复现命令或操作步骤**,任何人执行都能看到相同错误
25
+
26
+ ```
27
+ 📋 复现步骤:
28
+ <命令或操作序列>
29
+ 预期:<期望行为>
30
+ 实际:<错误行为>
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Phase 2:最小化(Minimise)
36
+
37
+ **目标**:剥离无关因素,定位最小触发条件。
38
+
39
+ - 二分法注释/删除代码,逐步缩小范围
40
+ - 替换外部依赖为 mock / fake / stub
41
+ - 检查是否为环境差异(Node 版本、OS、配置、时区)
42
+ - 检查是否为数据差异(特定输入值、边界数据)
43
+
44
+ 输出:**最小复现用例**(≤ 50 行代码 / ≤ 5 步操作)
45
+
46
+ ---
47
+
48
+ ## Phase 3:假设(Hypothesise)
49
+
50
+ **目标**:基于最小用例,枚举所有可能的根因。
51
+
52
+ 指令:
53
+ - 列出 ≥ 3 个可能根因,按概率排序
54
+ - 每个假设写出「如果为真,应该看到什么现象」
55
+ - 选出最可能的一个作为优先验证目标
56
+
57
+ ```
58
+ 🔬 假设列表(按概率排序):
59
+ 1. <假设>(概率:高/中/低)
60
+ 预测:如果为真 → <可观测现象>
61
+ 2. <假设>(概率:高/中/低)
62
+ 预测:如果为真 → <可观测现象>
63
+ ...
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Phase 4:插桩(Instrument)
69
+
70
+ **目标**:用日志/断点/工具验证假设。
71
+
72
+ 指令:
73
+ - 在关键路径插入 console.log / debugger / 监控埋点
74
+ - 运行 Phase 1 的复现用例,收集输出
75
+ - 对比输出与 Phase 3 的预测
76
+
77
+ 优先验证概率最高的假设;若被否定则验证下一个。
78
+
79
+ ---
80
+
81
+ ## Phase 5:修复(Fix)
82
+
83
+ **目标**:确认根因后,用最小改动修复。
84
+
85
+ 约束:
86
+ - 修复必须通过 Phase 1 的复现用例
87
+ - 不得引入新依赖(除非确有必要且记录在案)
88
+ - 如修复涉及多文件 → 先检查 blast radius
89
+
90
+ ---
91
+
92
+ ## Phase 6:回归测试(Regression-test)
93
+
94
+ **目标**:确保修复不改坏现有功能。
95
+
96
+ 1. 为本次 bug 写回归测试(Intent: "防止 <bug描述> 再次出现")
97
+ 2. 运行全量相关测试套件
98
+ 3. 用 `codegraph_impact` 检查受影响流程
99
+
100
+ ---
101
+
102
+ ## 硬约束
103
+
104
+ - 任何 Phase 不通过 → 回到上一 Phase,最多循环 3 次
105
+ - 3 次后仍未解决 → 输出「调试报告」:已排除假设、剩余假设、建议下一步
106
+ - **不得跳过 Phase 2(最小化)直接写修复**
107
+ - 不得引入 `// TODO` 或临时 workaround(除非用户明确同意)
108
+
109
+ ---
110
+
111
+ ## 衔接 3-impl
112
+
113
+ 当由 `3-impl` 自动切入时:
114
+ - Phase 1 的「复现步骤」从失败的测试命令/错误输出中提取
115
+ - 不询问用户,直接从已有信息开始
116
+ - Phase 5 修复后自动回到 `3-impl` 的当前步骤继续
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: atd-grill-with-docs
3
+ description: >
4
+ Grilling session that challenges your plan against existing domain model,
5
+ sharpens terminology, and updates CONTEXT.md + ADRs inline as decisions
6
+ crystallise. Use when user wants to stress-test a plan, build shared
7
+ language with AI, or after 1-spec/2-qa when there are decisions to persist.
8
+ argument-hint: "What plan or proposal do you want to grill?"
9
+ ---
10
+
11
+ # prompts/X-grill-with-docs · 深度拷问 + 文档沉淀
12
+
13
+ 横向命令:`/atdc:grill-with-docs [<change-name>]`
14
+ 也由 `1-spec Phase 3` 和 `2-qa Step 6` 自动建议触发。
15
+
16
+ 与 `2-qa` 的区别:2-qa 重在找漏洞,grill-with-docs 重在**建立共享语言并持久化**。
17
+
18
+ ---
19
+
20
+ ## Step 0:前置检查
21
+
22
+ ```bash
23
+ # 确认 CONTEXT.md 存在
24
+ cat CONTEXT.md 2>/dev/null || echo "[CONTEXT.md 不存在,将创建]"
25
+
26
+ # 确认 docs/adr/ 目录
27
+ ls docs/adr/ 2>/dev/null || echo "[docs/adr/ 不存在,将创建]"
28
+
29
+ # 确认当前 change(如有)
30
+ ls openspec/changes/ 2>/dev/null | grep -v archive
31
+ ```
32
+
33
+ 无 CONTEXT.md → 先用 `X-context-scan` 生成基础版本再继续。
34
+ 无 docs/adr/ → 创建目录。
35
+
36
+ ---
37
+
38
+ ## Step 1:读取当前领域知识
39
+
40
+ 从 CONTEXT.md 提取并内化:
41
+
42
+ ```bash
43
+ grep -E "^## |^- " CONTEXT.md 2>/dev/null
44
+ ```
45
+
46
+ 重点关注:
47
+ - **领域词汇表**:现有术语定义
48
+ - **模块边界**:哪些模块负责什么
49
+ - **已知约束**:性能/兼容性/依赖限制
50
+ - **ADR 摘要**:已有架构决策
51
+
52
+ ---
53
+
54
+ ## Step 2:对照拷问
55
+
56
+ 按以下维度逐条拷问,每次一条,等用户回答:
57
+
58
+ ### 2a. 术语一致性
59
+ - 方案中使用的术语是否与 CONTEXT.md 一致?
60
+ - 是否有歧义术语需要精确定义?
61
+ - 示例:方案说「订单状态变更」→ CONTEXT.md 定义的状态机是否覆盖?
62
+
63
+ ### 2b. 模块边界
64
+ - 方案涉及的功能是否落在正确的模块边界内?
65
+ - 是否有跨边界操作(模块 A 直接操作模块 B 的内部数据)?
66
+ - 是否需要新增模块 / 拆分现有模块?
67
+
68
+ ### 2c. 与已有架构决策的一致性
69
+ - 方案是否违反现有 ADR?
70
+ - 如果是 → 是需要推翻旧决策(生成新 ADR),还是需要调整方案?
71
+
72
+ ### 2d. 隐性约束
73
+ - 方案是否依赖了某些未在 CONTEXT.md 中声明的假设?
74
+ - 这些假设是否应该记录为约束?
75
+
76
+ ---
77
+
78
+ ## Step 3:更新 CONTEXT.md
79
+
80
+ 拷问过程中发现的术语澄清和约束,实时追加到 CONTEXT.md:
81
+
82
+ - **术语澄清** → 追加到「领域词汇表」段
83
+ - **模块边界调整** → 更新「模块结构」段
84
+ - **新约束** → 追加到「已知约束」段
85
+ - **隐性假设揭示** → 追加到「关键假设」段
86
+
87
+ ---
88
+
89
+ ## Step 4:生成 ADR(重大决策时)
90
+
91
+ 以下情况生成 `docs/adr/<序号>-<标题>.md`:
92
+
93
+ | 触发条件 | 示例 |
94
+ |---------|------|
95
+ | 推翻了已有 ADR | ADR-003 选择了 Redis,本次改为本地缓存 |
96
+ | 在多个可行方案中做了取舍 | A 方案 vs B 方案,选 A 因为... |
97
+ | 引入了新的技术依赖 | 引入消息队列处理异步任务 |
98
+ | 改变了核心领域模型 | 将「用户」和「账户」拆分为两个聚合 |
99
+
100
+ ADR 格式参考 `templates/adr.md`。
101
+
102
+ ---
103
+
104
+ ## Step 5:输出总结
105
+
106
+ ```
107
+ 🔍 Grill-with-Docs 完成 — <change-name 或 主题>
108
+
109
+ ### 术语澄清(已更新 CONTEXT.md)
110
+ - <术语>:<精确定义>
111
+
112
+ ### 架构决策(已生成 ADR)
113
+ - docs/adr/<序号>-<标题>.md
114
+
115
+ ### 模块边界调整
116
+ - <调整内容>
117
+
118
+ ### 未解决项
119
+ - <拷问中未能闭环的问题>
120
+ ```
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: atd-handoff
3
+ description: >
4
+ Compact the current conversation or change context into a handoff document
5
+ for another agent or human to pick up. Use when user wants to hand off
6
+ work, or after archiving a change (5-done Step 3.5).
7
+ argument-hint: "Which change or topic should the handoff cover?"
8
+ ---
9
+
10
+ # prompts/X-handoff · 会话交接
11
+
12
+ 横向命令:`/atdc:handoff [<change-name>]`
13
+ 也由 `5-done Step 3.5` 自动建议触发。
14
+
15
+ ---
16
+
17
+ ## Step 1:确认交接范围
18
+
19
+ - 指定了 change-name → 从 `openspec/changes/archive/<name>/` 或 `openspec/changes/<name>/` 读取
20
+ - 未指定 → 从当前会话上下文提取(当前讨论的功能/bug/决策)
21
+
22
+ ---
23
+
24
+ ## Step 2:收集交接信息
25
+
26
+ ```bash
27
+ # 从 change 目录提取
28
+ grep -E "^## |^- " openspec/changes/<name>/proposal.md 2>/dev/null
29
+ grep -E "^## |^- " openspec/changes/<name>/design.md 2>/dev/null
30
+
31
+ # 从 memory 提取相关条目
32
+ _PROJ=$(basename "$(git worktree list 2>/dev/null | head -1 | awk '{print $1}')" 2>/dev/null || basename "$PWD")
33
+ grep "<change-name>" ~/.atdc/memory/$_PROJ/.memory.md 2>/dev/null
34
+ ```
35
+
36
+ ---
37
+
38
+ ## Step 3:生成交接文档
39
+
40
+ 按 `templates/handoff.md` 格式生成 `.handoffs/<change-name>.md`:
41
+
42
+ > `.handoffs/` 通过 `~/atdc/central/link.sh` 自动软链到主仓库,所有分支+worktree 共享,不入 git。
43
+
44
+ ### 必须包含
45
+
46
+ - **做了什么**:Why + What,一句话说清动机和结果(不要 How)
47
+ - **关键决策**:选了哪个方案,排除了什么,为什么
48
+ - **受影响模块**:变更涉及的文件和模块清单
49
+ - **未解决问题**:暴露但未修复的技术债、待验证的假设
50
+ - **下一步**:接手的人/Agent 应该从哪里开始
51
+
52
+ ### 可选包含
53
+
54
+ - **测试状态**:哪些已覆盖,哪些有缺口
55
+ - **回滚风险**:如果出问题,回滚的步骤和风险
56
+ - **相关资源**:ADR 引用、监控面板、相关 Issue
57
+
58
+ ---
59
+
60
+ ## Step 4:输出
61
+
62
+ ```
63
+ 📋 交接文档已生成:.handoffs/<change-name>.md
64
+
65
+ 内容摘要:
66
+ - 做了什么:<一句话>
67
+ - 关键决策(<N> 条):<第一条摘要>
68
+ - 受影响模块:<N> 个
69
+ - 未解决问题:<N> 个
70
+
71
+ 💡 下一次会话开始时,Agent 可读取此文件快速恢复上下文。
72
+ ```
73
+
74
+ ---
75
+
76
+ ## 衔接 5-done
77
+
78
+ 当由 `5-done Step 3.5` 触发时:
79
+ - 范围自动确定为当前归档的 change
80
+ - 生成完毕后回到 5-done Step 4 继续
@@ -0,0 +1,78 @@
1
+ # prompts/X-health · 项目健康巡检
2
+
3
+ 横向命令,任意时刻可触发:`@atdc/GO.md health`
4
+
5
+ ---
6
+
7
+ ## 检查项
8
+
9
+ ### 1. 活跃 change 状态
10
+
11
+ ```bash
12
+ ls openspec/changes/ | grep -v archive
13
+ ```
14
+
15
+ 每个活跃 change 检查:
16
+ - 是否有 `.progress.json`(有无断点)
17
+ - proposal.md / design.md / tasks.md 是否齐全
18
+ - 最后更新时间(超过 7 天未动的标记为"僵尸 change")
19
+
20
+ ### 2. 记忆文件健康
21
+
22
+ ```bash
23
+ _PROJ=$(basename "$(git worktree list 2>/dev/null | head -1 | awk '{print $1}')" 2>/dev/null || basename "$PWD")
24
+ grep -c "^## " ~/.atdc/memory/$_PROJ/.memory.md 2>/dev/null || echo 0
25
+ ```
26
+
27
+ - 条目数超过 20 → 提示需要裁剪
28
+ - 文件不存在 → 提示首次建立
29
+
30
+ ### 3. 野代码检测
31
+
32
+ ```bash
33
+ git diff --name-only main HEAD 2>/dev/null || git diff --name-only master HEAD 2>/dev/null
34
+ ```
35
+
36
+ 对比当前变更文件 vs 所有活跃 change 的追溯矩阵,识别无主变更。
37
+
38
+ ### 4. spec 覆盖率
39
+
40
+ 检查 `openspec/specs/` 主目录下是否有孤立模块(有 spec 但无对应 change 或代码)。
41
+
42
+ ### 5. 图引擎健康
43
+
44
+ ```bash
45
+ # CRG(code-review-graph)状态
46
+ ~/.claude/scripts/link-crg.sh 2>/dev/null || true
47
+ ls .code-review-graph/graph.db 2>/dev/null && echo "✓ CRG 图存在" || echo "⚠️ CRG 未初始化"
48
+
49
+ # CodeGraph 状态
50
+ ls .codegraph/ 2>/dev/null && echo "✓ CodeGraph 已索引" || echo "⚠️ CodeGraph 未初始化(运行 codegraph init -i)"
51
+ ```
52
+
53
+ 如 CRG 图不存在或为空,提示:
54
+ ```
55
+ build_or_update_graph_tool(full_rebuild=true)
56
+ ```
57
+
58
+ ---
59
+
60
+ ## 输出报告
61
+
62
+ ```
63
+ 🏥 项目健康报告 — <项目名> — <日期>
64
+
65
+ 活跃 change:
66
+ ✅ <name> 进行中(Task N/M)
67
+ ⚠️ <name> 僵尸(超过 7 天未更新)
68
+
69
+ 记忆文件:N 条(<正常/建议裁剪>)
70
+
71
+ 野代码:<文件列表 / 无>
72
+
73
+ 图引擎:
74
+ CRG:<N 节点 / M 边 / 未初始化>
75
+ CodeGraph:<已索引 / 未初始化>
76
+
77
+ 建议下一步:<具体操作>
78
+ ```
@@ -0,0 +1,151 @@
1
+ # prompts/X-learn · self-learning → atd 桥接
2
+
3
+ 横向命令,手动触发或由其他阶段自动调用。
4
+
5
+ ---
6
+
7
+ ## 🔴 Step -1:规则加载
8
+
9
+ ```
10
+ Read @atdc/reference/learn.md → self-learning → atd 桥接协议(promotion rule + triage 路由)
11
+ ```
12
+
13
+ > 核心协议见 `@atdc/reference/learn.md`
14
+
15
+ ---
16
+
17
+ ## Phase 0:判断触发模式
18
+
19
+ - **无参数 / 手动触发** → Phase 1(扫描当前 session 的 golden path)
20
+ - **`--auto`(由 4-verify / 5-done 自动调用)** → Phase 2(静默检测 + 自动路由)
21
+
22
+ ---
23
+
24
+ ## Phase 1:手动扫描当前 session
25
+
26
+ 回顾当前对话历史,识别值得沉淀的路径:
27
+
28
+ 1. **搜索信号**:
29
+ - 重试了 2 次以上的操作
30
+ - 用户纠正过的错误
31
+ - 非显而易见的命令/配置
32
+ - 刚发现的 project-specific fact(DB 连接方式、部署命令等)
33
+ 2. **列出候选**:最多 3 条,每条一句话描述
34
+ 3. **交互确认**:让用户选择要沉淀哪条,跳过哪些
35
+
36
+ 输出格式:
37
+ ```
38
+ 🔍 检测到以下 golden path 候选:
39
+
40
+ 1. <路径描述>(重试了 N 次,排除过 M 个方案)
41
+ 2. <路径描述>
42
+
43
+ 选择:输入编号沉淀,或 "all" 全部,"skip" 跳过。
44
+ ```
45
+
46
+ 确认后进入 Phase 3。
47
+
48
+ ---
49
+
50
+ ## Phase 2:静默自动检测
51
+
52
+ 由 4-verify.md / 5-done.md 调用时,不交互,直接检测:
53
+
54
+ 1. 检查当前 change 的 `.progress.json`,看 `failedAt` / `failedReason` 是否有记录
55
+ 2. 检查本次 session 是否涉及超过 2 次尝试的操作
56
+ 3. 如有 → 按 promotion rule 判断是否可晋升
57
+ 4. 满足 → 自动路由(不询问);不满足 → 写 memory note
58
+
59
+ ### 2a. Triage 路由
60
+
61
+ ```
62
+ 检测到候选 → 判断类型
63
+
64
+ ├─ 单事实 / 一行纠正
65
+ │ └─→ 追加到 .memory.md(⚠️ gotcha)
66
+
67
+ ├─ 失败模式 + 死路(满足 .errors-log 条件)
68
+ │ └─→ 追加到 .errors-log.md
69
+ │ + .memory.md 加交叉引用简记
70
+
71
+ └─ 满足 promotion rule 3 条
72
+ └─→ 进入 Phase 3(生成 atd 命令)
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Phase 3:生成 atd 命令
78
+
79
+ 当满足 promotion rule 全 3 条时:
80
+
81
+ ### 3a. 确定命令名
82
+
83
+ 从路径描述中提取 kebab-case 名称,格式:`learn-<domain>-<action>`
84
+ 例:`learn-db-connect`、`learn-deploy-staging`、`learn-kugo-sign`
85
+
86
+ ### 3b. Dedup
87
+
88
+ 检查是否已有同名或相似命令:
89
+ ```bash
90
+ ls ~/atdc/commands/opencode/atd/ | grep -i "<keyword>"
91
+ ```
92
+
93
+ 已有 → 更新现有 prompt(追加 "What didn't work" section)
94
+ 没有 → 新建
95
+
96
+ ### 3c. 调用 add-command.py
97
+
98
+ ```bash
99
+ python3 ~/atdc/bin/add-command.py <name> \
100
+ "<描述>" \
101
+ "learn-<name>、记住<name>、<name>怎么搞" \
102
+ --from-learn \
103
+ --failure "<named failure pattern>" \
104
+ --dead-end "<ruled-out approach>"
105
+ ```
106
+
107
+ `--from-learn` flag 会让 add-command.py 使用 `templates/learn-skill.md` 模板,
108
+ 自动填充 "What didn't work" 和 "失败模式" section。
109
+
110
+ ### 3d. 写记忆
111
+
112
+ ```bash
113
+ # 写入 .memory.md(🧠 learned-skill 类型)
114
+ # 写入 .errors-log.md(如果涉及失败模式)
115
+ ```
116
+
117
+ ### 3e. 输出结果
118
+
119
+ ```
120
+ ✅ 已从本次 session 沉淀 skill
121
+
122
+ 新命令:/atdc:<name>
123
+ 触发词:learn-<name>、记住<name>
124
+ 提示词:prompts/X-<name>.md
125
+
126
+ 记忆写入:~/.atdc/memory/<项目>/.memory.md
127
+ 失败记录:~/.atdc/memory/<项目>/.errors-log.md(如有)
128
+
129
+ 下次 session 启动时,Agent 可通过触发词直接调用此 skill。
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Phase 4:仅写记忆(不晋升 skill)
135
+
136
+ 不满足 promotion rule 时的降级处理:
137
+
138
+ ```bash
139
+ _PROJ=$(basename "$(git worktree list 2>/dev/null | head -1 | awk '{print $1}')" 2>/dev/null || basename "$PWD")
140
+ MEMORY_DIR="$HOME/.atdc/memory/$_PROJ"
141
+ mkdir -p "$MEMORY_DIR"
142
+ cat >> "$MEMORY_DIR/.memory.md" << EOF
143
+
144
+ ## ⚠️ [$(date +%Y-%m-%d)] <简短描述> | ~100t
145
+ done: <一句话>
146
+ gotcha: <发现的坑 / 非显而易见的点>
147
+ note: <未晋升原因:缺少 passing check / 缺少命名失败模式 / 缺少排除死路>
148
+ EOF
149
+ ```
150
+
151
+ 未晋升原因记录在 `note:` 字段,供后续 `/atd compound` 扫描时提示用户补充验证后晋升。