@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,417 @@
1
+ # prompts/X-review · 代码级 Review
2
+
3
+ 横向命令,基于 **CRG (code-review-graph)** + **CodeGraph** 双图引擎进行精准代码 review。
4
+
5
+ ---
6
+
7
+ ## 目标
8
+
9
+ 不是 review 全部代码,而是 review **变更的 blast radius**:只读受影响的文件,只查受影响的测试,只追踪受影响的用户流程。
10
+
11
+ ---
12
+
13
+ ## Phase 0:判断子模式
14
+
15
+ 检查参数:
16
+
17
+ | 参数 | 模式 | 执行 |
18
+ | ------- | ------------ | ------------------------------- |
19
+ | 无参数 | 全量 review | Phase 1 → 2(含2d慢查)→ 3 → 4 → 5 → 6 |
20
+ | `delta` | 仅变更 review | Phase 1 → 2(含2d慢查)→ 5 → 6 |
21
+ | `pr` | PR/分支 review | Phase 1(base=master)→ 2(含2d慢查)→ 5 → 6 |
22
+ | `gaps` | 仅测试缺口 | Phase 1 → 3 → 6 |
23
+ | `flows` | 仅受影响流程 | Phase 1 → 4 → 6 |
24
+ | `arch` | 架构健康检查 | Phase 1 → 4b → 6 |
25
+ | `crg` | CRG 深度分析 | Phase 1 → 2b → 3b → 4c → 6 |
26
+
27
+ ---
28
+
29
+ ## Phase 1:检测变更文件 + 图状态
30
+
31
+ ### 1a. PR 模式:合并 origin/master 最新代码(仅 `pr` 模式)
32
+
33
+ 对于 `pr` 模式分支 review,必须先确保要 review 的分支已包含 `origin/master` 最新代码,避免 review 出与 master 无差异的冗余内容:
34
+
35
+ ```bash
36
+ git fetch origin master && git merge origin/master --no-edit
37
+ ```
38
+
39
+ > 此步骤必须在任何 diff 检测之前执行。
40
+
41
+ ### 1b. 确保图数据目录就绪
42
+
43
+ ```bash
44
+ ~/.claude/scripts/link-crg.sh
45
+ ```
46
+
47
+ 脚本自动处理:
48
+ - 主仓库 → 保持真实目录
49
+ - worktree → 软链到主仓库的 `.code-review-graph/`
50
+ - 已有软链 → 跳过(幂等)
51
+
52
+ ### 1c. 检查图状态
53
+
54
+ ```
55
+ get_minimal_context_tool(task="code review")
56
+ ```
57
+
58
+ 如果返回 "Last updated: never" 或节点数为 0:
59
+ ```
60
+ build_or_update_graph_tool(full_rebuild=true)
61
+ ```
62
+
63
+ ### 1d. 检测变更文件
64
+
65
+ **优先使用 CRG**:
66
+ ```
67
+ detect_changes_tool(
68
+ base="HEAD~1", # delta 模式
69
+ // base="origin/master", # pr 模式
70
+ detail_level="standard"
71
+ )
72
+ ```
73
+
74
+ CRG 返回:
75
+ - 变更文件列表(自动从 git diff 获取)
76
+ - 每个文件的**风险评分**
77
+ - 受影响的函数列表
78
+ - **优先级排序**(高风险在前)
79
+
80
+ 如果 CRG 不可用(图未构建),回退到 git diff:
81
+ ```bash
82
+ git diff --name-only HEAD~1 # delta
83
+ git diff --name-only master...HEAD # pr
84
+ git diff --name-only HEAD # 工作区
85
+ ```
86
+
87
+ 无变更文件 → 输出"无变更,无需 review"并退出。
88
+
89
+ ### 1e. Ponytail Review(可选,推荐执行)
90
+
91
+ ```bash
92
+ # 在 CRG review 基础上,叠加 Ponytail 模式检查
93
+ atdc ponytail scan --diff 2>/dev/null || echo "[Ponytail review skipped]"
94
+ ```
95
+
96
+ > Ponytail 检查结果合并到最终 review 报告:
97
+ > - 发现新模式 → 列为 "过度工程化风险" 项
98
+ > - 无发现 → 标注 "Ponytail clean"
99
+
100
+ ---
101
+
102
+ ## Phase 2:Risk Score — 风险评分
103
+
104
+ ### 2a. CRG 风险评分(首选)
105
+
106
+ CRG 的 `detect_changes_tool` 已内置风险评分。直接使用其输出:
107
+
108
+ ```
109
+ get_review_context_tool(
110
+ include_source=true,
111
+ max_lines_per_file=200,
112
+ max_depth=2
113
+ )
114
+ ```
115
+
116
+ 返回:
117
+ - 变更函数的源码片段
118
+ - 影响半径(哪些函数/文件受影响)
119
+ - 社区结构(是否跨模块)
120
+ - 建议的 review 优先级
121
+
122
+ ### 2b. 逐符号 blast radius(补充深度)
123
+
124
+ 对 CRG 标记为**高风险**的符号,用 CodeGraph 深挖:
125
+
126
+ ```
127
+ codegraph_impact "<SymbolName>" depth=2
128
+ ```
129
+
130
+ 收集:
131
+ - **影响深度**:blast radius 涉及几跳
132
+ - **影响广度**:受影响的调用方数量
133
+ - **跨模块**:是否跨越了不同的目录/包
134
+
135
+ ### 2c. 综合风险评分
136
+
137
+ 结合 CRG 风险评分和 CodeGraph blast radius:
138
+
139
+ | 维度 | 低风险 (1分) | 中风险 (2分) | 高风险 (3分) |
140
+ |------|-------------|-------------|-------------|
141
+ | CRG 风险 | low | medium | high |
142
+ | 影响广度 | ≤3 个调用方 | 4-10 个 | >10 个 |
143
+ | 跨模块 | 无 | 2 个模块 | ≥3 个模块 |
144
+ | 测试覆盖 | 变更函数全部有测试 | 部分有测试 | 多数无测试 |
145
+ | 变更类型 | 新增/日志/配置 | 修改逻辑 | 改签名/删代码 |
146
+
147
+ **总分** = 各维度之和(5-15 分)
148
+
149
+ **风险等级**:
150
+ - 5-8 分 → 🟢 低风险:增量验证即可
151
+ - 9-11 分 → 🟡 中风险:需关注,review 重点
152
+ - 12-15 分 → 🔴 高风险:必须全量测试 + 人工确认
153
+
154
+ ---
155
+
156
+ ## Phase 2d:慢查校验 — DB 索引与 SQL 分析
157
+
158
+ ### 触发条件
159
+
160
+ 检查变更代码中是否包含 DB 操作:
161
+ - GORM 原生 SQL:`Raw()`, `Exec()`
162
+ - GORM 链式查询:`Table()`, `Where()`, `Select()`, `Scan()`, `Find()`, `Create()`, `Update()`, `Delete()`
163
+ - 包含 `FROM`, `JOIN`, `WHERE`, `INSERT`, `UPDATE`, `DELETE` 等 SQL 关键字
164
+ - 引用 `commonModel.GetSlaveDBConn()` 或 `GetDBConn()`
165
+
166
+ **若未检测到 DB 操作 → 跳过此步骤,标注 "无 DB 操作"。**
167
+
168
+ ### 检测到 DB 操作时
169
+
170
+ **暂停**并向用户请求表结构:
171
+
172
+ ```
173
+ 检测到以下 SQL 查询,需要分析慢查风险,请提供对应表的建表 DDL:
174
+
175
+ 1. models/ticket/celebrity.go — FindSingerPerfDetailsByCelebrityIDsSlave
176
+ 涉及表: ticket_performance_celebrity, ticket_performance
177
+
178
+ 2. models/ticket/celebrity.go — CountSingerPerfByCelebrityIDsSlave
179
+ 涉及表: ticket_performance_celebrity, ticket_performance
180
+
181
+ 3. models/ticket/show.go — FindShowTimesByPerformanceIDsSlave
182
+ 涉及表: ticket_show
183
+
184
+ 请提供以上表的 `CREATE TABLE` 语句。
185
+ ```
186
+
187
+ ### 用户提供 DDL 后
188
+
189
+ 对每条 SQL 逐句分析索引命中情况:
190
+
191
+ 1. 列出 WHERE / JOIN / ORDER BY 条件
192
+ 2. 匹配表上的索引
193
+ 3. 标注:✅ 走索引 / ⚠️ 部分覆盖 / ❌ 无索引 → filesort / temp table
194
+ 4. 给出 EXPLAIN 预估(Using index / Using temporary / Using filesort)
195
+ 5. 汇总风险等级和缓存缓解
196
+
197
+ **输出格式**:
198
+
199
+ ```
200
+ ### Query N: <函数名>
201
+
202
+ 索引命中分析:
203
+ | 条件 | 索引 | 说明 |
204
+ |------|------|------|
205
+ | ... | idx_xxx ✅ | ... |
206
+ | ... | ⚠️ 无索引 | ... |
207
+
208
+ EXPLAIN 预估: Using index condition; Using filesort
209
+
210
+ 慢查风险: 🟢 低 / 🟡 中 / 🔴 高
211
+ 缓解: Redis 缓存 / LIMIT 等
212
+
213
+ ---
214
+
215
+ ### 慢查总评
216
+ | Query | 风险 | 原因 | 缓解 |
217
+ |-------|------|------|------|
218
+ | ... | ... | ... | ... |
219
+ ```
220
+
221
+ ## Phase 3:Test Gaps — 测试缺口检测
222
+
223
+ ### 3a. CRG 测试缺口(首选)
224
+
225
+ ```
226
+ get_knowledge_gaps_tool()
227
+ ```
228
+
229
+ CRG 自动检测:
230
+ - 孤立节点(断连的代码)
231
+ - 瘦弱社区(< 3 成员)
232
+ - **未测试的热点**(高度连接但无测试覆盖的节点)
233
+ - 单文件社区
234
+
235
+ ### 3b. 逐函数覆盖检查(补充)
236
+
237
+ 对变更文件中的关键函数,用 CodeGraph 精确验证:
238
+
239
+ ```
240
+ codegraph_callers "<FunctionName>"
241
+ ```
242
+
243
+ 检查返回的调用方中是否有测试文件:
244
+
245
+ - **有测试调用方** → ✅ 已覆盖
246
+ - **无测试调用方** → ❌ 测试缺口
247
+
248
+ ### 3c. CRG 结构化测试查询
249
+
250
+ ```
251
+ query_graph_tool(pattern="tests_for", target="<SymbolName>")
252
+ ```
253
+
254
+ 输出:
255
+ ```
256
+ 📊 测试覆盖情况
257
+
258
+ ✅ 已覆盖:N 个函数
259
+ ❌ 未覆盖:M 个函数
260
+
261
+ | 函数 | 文件 | 调用方数 | 测试状态 | CRG 覆盖 |
262
+ |------|------|---------|---------|---------|
263
+ | loginHandler | auth.go | 3 | ✅ TestLoginHandler | ✅ |
264
+ | validateToken | token.go | 0 | ❌ 无测试 | ❌ hotspot |
265
+ ```
266
+
267
+ ---
268
+
269
+ ## Phase 4:Affected Flows — 受影响流程追踪
270
+
271
+ ### 4a. CRG 受影响流程(首选)
272
+
273
+ ```
274
+ get_affected_flows_tool(changed_files=["..."])
275
+ ```
276
+
277
+ CRG 直接返回:
278
+ - 受影响的执行流列表
279
+ - 每个流的入口点和关键步骤
280
+ - 流的文件覆盖范围
281
+
282
+ ### 4b. 架构健康检查(`arch` 模式)
283
+
284
+ ```
285
+ get_architecture_overview_tool(detail_level="minimal")
286
+ get_bridge_nodes_tool(top_n=10)
287
+ get_hub_nodes_tool(top_n=10)
288
+ get_surprising_connections_tool(top_n=15)
289
+ ```
290
+
291
+ 输出:
292
+ - 模块耦合度分析
293
+ - 桥接节点(断连风险点)
294
+ - 枢纽节点(高影响变更点)
295
+ - 异常耦合(跨模块的意外依赖)
296
+
297
+ ### 4c. CodeGraph 端到端追踪(补充深度)
298
+
299
+ 对 CRG 标记的高风险流,用 CodeGraph 追踪完整调用链:
300
+
301
+ ```
302
+ codegraph_trace from="<HandlerName>" to="<关键下游>"
303
+ ```
304
+
305
+ ### 4d. 映射用户流程
306
+
307
+ 综合 CRG + CodeGraph 结果,映射到用户可理解的流程:
308
+
309
+ ```
310
+ 🔄 受影响的用户流程
311
+
312
+ | 流程 | 入口函数 | 变更影响点 | 风险 | 数据源 |
313
+ |------|---------|-----------|------|--------|
314
+ | 用户登录 | POST /login | token 验证逻辑变更 | 🟡 中 | CRG+CG |
315
+ | 密码重置 | POST /reset | 共用 validateToken | 🟡 中 | CRG |
316
+ | 用户注册 | POST /register | 无直接影响 | 🟢 低 | CG |
317
+ ```
318
+
319
+ ---
320
+
321
+ ## Phase 5:获取 Review 上下文(CRG 专用)
322
+
323
+ 此 Phase 在 `crg` 深度模式下执行,利用 CRG 的 token 高效特性获取完整上下文:
324
+
325
+ ```
326
+ get_review_context_tool(
327
+ include_source=true,
328
+ max_lines_per_file=300,
329
+ max_depth=2,
330
+ detail_level="standard"
331
+ )
332
+ ```
333
+
334
+ CRG 自动聚合:
335
+ - 变更文件 → 受影响函数 → 源码片段 → 社区归属 → 测试状态
336
+
337
+ 一次调用替代多次 Read + grep,token 消耗降低 60-80%。
338
+
339
+ ---
340
+
341
+ ## Phase 6:输出 Review 报告
342
+
343
+ ```
344
+ 📋 Code Review 报告
345
+
346
+ ## 变更概要
347
+ - 变更文件:N 个
348
+ - 变更函数:M 个
349
+ - 风险等级:🔴 高 / 🟡 中 / 🟢 低
350
+ - 图引擎:CRG (5458 nodes) + CodeGraph
351
+
352
+ ## Risk Score: <分数>/15
353
+ <风险评分详情>
354
+
355
+ ## Blast Radius
356
+ <受影响的文件和函数列表,标注 CRG 社区归属>
357
+
358
+ ## 测试覆盖
359
+ - 已覆盖:N 个 ✅
360
+ - 未覆盖:M 个 ❌
361
+ - CRG 热点:K 个 ⚠️
362
+ <缺口详情>
363
+
364
+ ## 受影响流程
365
+ <流程列表及风险>
366
+
367
+ ## 架构洞察(如有异常耦合或桥接风险)
368
+ <surprising connections + bridge nodes>
369
+
370
+ ## 建议行动
371
+ 1. <针对高风险项的建议>
372
+ 2. <针对测试缺口的建议>
373
+ 3. <针对受影响流程的验证建议>
374
+ 4. <针对架构耦合的优化建议>
375
+ ```
376
+
377
+ 报告**必须**保存到项目根目录的 `docs/report/` 下,命名规则:
378
+ ```
379
+ docs/report/code-review-<分支名或change号>-<YYYY-MM-DD>.md
380
+ ```
381
+
382
+ 示例:
383
+ - `docs/report/code-review-TASK-231233-getMultiPerfBySingerId-2026-06-23.md`
384
+ - `docs/report/code-review-fix-token-idor-2026-06-23.md`
385
+
386
+ > 命名前缀固定为 `code-review-`,日期为 review 执行当天的日期。
387
+ > 不再保存到 `openspec/changes/` 下,4-verify 改为从 `docs/report/` 查找最近的 review 报告。
388
+
389
+ ---
390
+
391
+ ## 工具选择速查表
392
+
393
+ | 场景 | CRG 工具 | CodeGraph 工具 |
394
+ |------|---------|---------------|
395
+ | 变更检测 | `detect_changes_tool` | — |
396
+ | Review 上下文 | `get_review_context_tool` | — |
397
+ | Blast radius | `get_impact_radius_tool` | `codegraph_impact` |
398
+ | 受影响流程 | `get_affected_flows_tool` | `codegraph_trace` |
399
+ | 测试覆盖 | `query_graph_tool(tests_for)` | `codegraph_callers` |
400
+ | 符号搜索 | `semantic_search_nodes_tool` | `codegraph_search` |
401
+ | 架构分析 | `get_architecture_overview_tool` | — |
402
+ | 异常耦合 | `get_surprising_connections_tool` | — |
403
+ | 死代码 | `refactor_tool(dead_code)` | — |
404
+ | 大函数 | `find_large_functions_tool` | — |
405
+ | 符号详情 | `query_graph_tool(file_summary)` | `codegraph_node` |
406
+ | 图状态 | `get_minimal_context_tool` | `codegraph_status` |
407
+
408
+ **原则**:CRG 适合 review/架构/变更分析场景;CodeGraph 适合单符号精确查询和端到端 trace。两者互补,不互斥。
409
+
410
+ ---
411
+
412
+ ## 与其他阶段的联动
413
+
414
+ - **4-verify**:自动检测是否有 review 报告,有则引用风险评分决定验证严格度
415
+ - **2-qa**:受影响流程分析作为质疑的新维度
416
+ - **3-impl**:执行中可随时调用 `/atd review gaps` 检查当前任务的测试覆盖
417
+ - **flow health**:`arch` 模式的架构洞察作为健康巡检的输入
@@ -0,0 +1,74 @@
1
+ # prompts/X-search · Semble 代码搜索
2
+
3
+ 横向命令,任意时刻可触发:`/atdc:search <query>`
4
+
5
+ ---
6
+
7
+ ## 用途
8
+
9
+ - 用自然语言描述功能 → 找到对应代码实现
10
+ - 查找相似的实现模式(替代 grep -rn 的正则匹配)
11
+ - Ponytail B5 L2-L5 检测加速(找项目内已有实现)
12
+
13
+ ## 降级链
14
+
15
+ ```
16
+ Semble MCP(首选,原生工具调用)→ Semble CLI → CodeGraph → grep
17
+ ```
18
+
19
+ - Semble 可用:返回语义匹配的代码片段,无需 Read 文件
20
+ - Semble 不可用:降级到 CodeGraph 结构化搜索
21
+ - CodeGraph 无结果:降级到 grep(最后兜底)
22
+
23
+ ---
24
+
25
+ ## 搜索模式
26
+
27
+ ### 语义搜索(search)
28
+
29
+ 用自然语言或符号名搜索代码:
30
+
31
+ ```bash
32
+ # 自然语言查询
33
+ semble search "authentication flow" . --top-k 5
34
+ semble search "whitelist filter pattern" . --top-k 5
35
+
36
+ # 符号/标识符查询(Semble 自动识别并加权词法匹配)
37
+ semble search "BuildWhitelistExcludeSet" . --top-k 5
38
+ ```
39
+
40
+ MCP 模式:直接调用 `mcp__semble__search` 工具(参数:query, repo_path, top_k)
41
+
42
+ ### 相似代码发现(find-related)
43
+
44
+ 给定已知位置(文件路径 + 行号),找到语义相似的代码:
45
+
46
+ ```bash
47
+ semble find-related src/auth.py 42 .
48
+ ```
49
+
50
+ MCP 模式:直接调用 `mcp__semble__find_related` 工具
51
+
52
+ ---
53
+
54
+ ## 常用场景
55
+
56
+ | 场景 | 命令 |
57
+ |------|------|
58
+ | Ponytail L2 | `semble search "slices.Contains" .` → 检查是否已有 stdlib 用法 |
59
+ | Ponytail L3 | `semble search "cenkalti backoff retry" .` → 检查 go.mod 依赖用法 |
60
+ | Ponytail L4 | `semble search "callRPC pattern" .` → 找项目已有 RPC 调用模式 |
61
+ | Ponytail L6 | `semble search "filter by whitelist" .` → 检测 ≥3 处相似代码 |
62
+ | R5 blast radius | `semble find-related <file> <line> .` → 找到语义相似但无直接调用的代码 |
63
+
64
+ ---
65
+
66
+ ## 优先级规则
67
+
68
+ ```
69
+ 1. 找"怎么做" → Semble search(语义理解,直接返回代码)
70
+ 2. 找"谁调用了 X" → CodeGraph callers(结构化精确查询)
71
+ 3. 找"X 会影响到什么" → codegraph_impact(调用边追踪)
72
+ 4. 找语义相似但结构无关的代码 → Semble find_related(补影响分析盲区)
73
+ 5. 纯文本/正则匹配 → grep(最后兜底)
74
+ ```
@@ -0,0 +1,95 @@
1
+ # prompts/X-strategy · 产品策略锚点
2
+
3
+ 横向命令,创建或更新 `STRATEGY.md`。
4
+
5
+ ---
6
+
7
+ ## 目标
8
+
9
+ 生成/维护项目根目录的 `STRATEGY.md` — 一个短小精悍的策略锚点文档,让后续所有 brainstorm、plan、impl 有统一的方向约束。
10
+
11
+ ---
12
+
13
+ ## Phase 0:判断状态
14
+
15
+ ```bash
16
+ cat STRATEGY.md 2>/dev/null && echo "---EXISTS---" || echo "---NOT_FOUND---"
17
+ ```
18
+
19
+ - **不存在** → Phase 1(首次创建)
20
+ - **存在 + 用户指定了某节** → Phase 2(定向更新指定节)
21
+ - **存在 + 无指定** → Phase 3(全局审视更新)
22
+
23
+ ---
24
+
25
+ ## Phase 1:首次创建(交互式问答)
26
+
27
+ 逐一提问,每次只问一个问题,用 `AskUserQuestion` 或文字等待回答:
28
+
29
+ 1. **Target Problem**:这个产品解决什么问题?为谁解决?(一句话)
30
+ 2. **Approach**:用什么方式解决?核心机制是什么?
31
+ 3. **Persona**:目标用户是谁?他们的角色、场景、技术水平?
32
+ 4. **Key Metrics**:怎么衡量成功?1-3 个关键指标(名称 + 含义)
33
+ 5. **Tracks**:当前在推进哪些工作轨道?按优先级排(每条 1-2 行)
34
+ 6. **Out of Scope**:当前明确不做的事?
35
+
36
+ 问完后参考 `@atdc/templates/strategy.md` 生成 `STRATEGY.md`。
37
+
38
+ **原则**:
39
+ - 推 weak answers,不放过模糊回答
40
+ - 短即是优势。添加章节的成本比看起来高,push back expansion
41
+ - 策略是锚点不是计划。Features 归 proposal,排期归 issue tracker
42
+
43
+ ---
44
+
45
+ ## Phase 2:定向更新
46
+
47
+ 用户指定了某个 section(如 `strategy metrics` 或 `strategy approach`):
48
+
49
+ 1. 读取当前 `STRATEGY.md`
50
+ 2. 只针对指定节提问(1-2 个问题)
51
+ 3. 更新该节,保留其余内容不变
52
+ 4. 输出 diff 让用户确认
53
+
54
+ ---
55
+
56
+ ## Phase 3:全局审视更新
57
+
58
+ 无特定 section 指定,且 STRATEGY.md 已存在:
59
+
60
+ 1. 读取当前 `STRATEGY.md`
61
+ 2. 逐节审视,标记 stale 或 weak 的部分:
62
+ - **Stale**:与当前实际方向明显不符
63
+ - **Weak**:模糊、过于宽泛、缺少量化指标
64
+ 3. 输出审视结果:
65
+
66
+ ```
67
+ 📊 STRATEGY.md 审视结果:
68
+
69
+ | 节 | 状态 | 建议 |
70
+ |----|------|------|
71
+ | Target Problem | ✓ | 保持 |
72
+ | Approach | ⚠ | <为什么 weak,建议怎么改> |
73
+ | Metrics | ⚠ | <缺少什么指标> |
74
+ | Tracks | 🔴 | <明显过时,需要更新> |
75
+
76
+ 需要更新哪些节?(可多选,或说 "全部")
77
+ ```
78
+
79
+ 4. 用户选择后,只更新选中的节
80
+ 5. 更新 `STRATEGY.md` 的 "上次更新" 日期
81
+
82
+ ---
83
+
84
+ ## Phase 4:完成
85
+
86
+ 输出:
87
+
88
+ ```
89
+ ✅ STRATEGY.md 已更新
90
+
91
+ <简要说明更新了什么>
92
+
93
+ 后续 1-spec(需求澄清)和 brainstorm 将自动读取此文件作为方向约束。
94
+ 可随时重新运行 /atd strategy 更新。
95
+ ```
@@ -0,0 +1,46 @@
1
+ # prompts/X-table2xlsx · DDL → Excel 模板
2
+
3
+ 横向命令,任意时刻可触发:`/atdc:table2xlsx <schema.sql>`
4
+
5
+ ---
6
+
7
+ ## 执行步骤
8
+
9
+ ### 1. 确定输入
10
+
11
+ 检查用户提供的参数:
12
+ - 如果提供了 DDL 文件路径 → 直接使用
13
+ - 如果用户粘贴了 DDL 内容 → 写入临时文件 `/tmp/atd_table2xlsx_ddl.sql`
14
+
15
+ ### 2. 调用工具
16
+
17
+ ```bash
18
+ # 文件输入
19
+ ${ATDC_DIR}/tools/table2xlsx <ddl_file> -o <output_file>
20
+
21
+ # stdin 输入
22
+ cat <ddl_file> | ${ATDC_DIR}/tools/table2xlsx -o <output_file>
23
+ ```
24
+
25
+ ### 3. 输出
26
+
27
+ - 默认输出到当前目录的 `{table_name}_template.xlsx`
28
+ - 用户可用 `-o` 指定输出路径
29
+
30
+ ### 4. 错误处理
31
+
32
+ | 错误 | 处理 |
33
+ |------|------|
34
+ | 文件不存在 | 提示用户提供正确路径 |
35
+ | 非 CREATE TABLE DDL | 提示"未找到 CREATE TABLE 语句" |
36
+ | openpyxl 未安装 | `pip install openpyxl` |
37
+
38
+ ### 5. 使用示例
39
+
40
+ ```bash
41
+ # AI 执行
42
+ /atdc:table2xlsx schema.sql
43
+
44
+ # 等价于
45
+ ${ATDC_DIR}/tools/table2xlsx schema.sql -o membership_product_sku_template.xlsx
46
+ ```