@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
package/AGENTS.md ADDED
@@ -0,0 +1,58 @@
1
+ # atdc · Agent 指令
2
+
3
+ ## 新增命令规则(MUST 遵循)
4
+
5
+ 当需要新增 `/atd:<name>` 命令时,SHALL 使用生成脚本,禁止手动创建文件:
6
+
7
+ ```bash
8
+ python3 ~/atdc/bin/add-command.py <name> "<描述>" "<触发词1>、<触发词2>"
9
+ ```
10
+
11
+ 示例:
12
+ ```bash
13
+ python3 ~/atdc/bin/add-command.py my-tool "我的工具" "my-tool、我的工具、/atdc:my-tool"
14
+ ```
15
+
16
+ 脚本自动完成:
17
+ - ✅ 4 端命令文件(OpenCode / Claude / Codex / Cursor)
18
+ - ✅ prompts/X-<name>.md 提示词模板
19
+ - ✅ install.sh 技能列表注册
20
+ - ✅ `~/.agents/skills/` 符号链接
21
+
22
+ 随后运行 `bash ~/atdc/install.sh` 完成安装。
23
+
24
+ ## 各端命令格式
25
+
26
+ | 平台 | 路径 | 特点 |
27
+ |------|------|------|
28
+ | OpenCode | `commands/opencode/atd/<name>.md` | YAML frontmatter + `$ARGUMENTS` |
29
+ | Claude Code | `commands/claude/atd/<name>.md` | 纯文本 + `$ARGUMENTS` |
30
+ | Codex | `commands/codex/atd-<name>/SKILL.md` | YAML frontmatter + `触发词` |
31
+ | **Cursor** | `commands/cursor/atd-<name>/SKILL.md` | YAML frontmatter + `触发词`,**禁止 `$ARGUMENTS`** |
32
+
33
+ ## Cursor 特殊规则
34
+
35
+ 1. **必须含触发词**:`description` 中必须包含 `触发词:xxx、xxx。`
36
+ 2. **禁止 `$ARGUMENTS`**:Cursor 不支持此变量
37
+ 3. **全局注册**:通过 `~/.agents/skills/` 符号链接(与 Codex 共享)
38
+ 4. **项目级 `~/.cursor/skills/`** 无效,必须用 `~/.agents/skills/`
39
+
40
+ ## 新增工具规则
41
+
42
+ 工具置于 `tools/<name>`(可执行脚本),符号链接到 `~/bin/<name>`。
43
+
44
+ Respond terse like smart caveman. All technical substance stay. Only fluff die.
45
+
46
+ Rules:
47
+ - Drop: articles (a/an/the), filler (just/really/basically), pleasantries, hedging
48
+ - Fragments OK. Short synonyms. Technical terms exact. Code unchanged.
49
+ - Pattern: [thing] [action] [reason]. [next step].
50
+ - Not: "Sure! I'd be happy to help you with that."
51
+ - Yes: "Bug in auth middleware. Fix:"
52
+
53
+ Switch level: /caveman lite|full|ultra|wenyan
54
+ Stop: "stop caveman" or "normal mode"
55
+
56
+ Auto-Clarity: drop caveman for security warnings, irreversible actions, user confused. Resume after.
57
+
58
+ Boundaries: code/commits/PRs written normal.
package/GO.md ADDED
@@ -0,0 +1,245 @@
1
+ # atdc · 统一入口
2
+
3
+ 任何 AI 终端均可用:`@atdc/GO.md "<你的需求>"`
4
+
5
+ > **Token 规则**
6
+ > 1. Shell 输出压缩由 RTK 处理(`rtk init -g --opencode`),无需手动过滤
7
+ > 2. 查符号优先双图引擎:CRG(`detect_changes` / `get_review_context` / `query_graph`)用于 review/架构场景,CodeGraph(`codegraph_search` / `codegraph_callers` / `codegraph_context`)用于单符号查询/trace 场景
8
+ > 3. 大文件读取消耗 context,优先 `ctx_execute_file` 或 `sed -n 'N,Mp'` 定位
9
+ > 4. 记忆格式精简:每条 5-8 行 caveman 格式,禁止逐条 bullet 展开
10
+
11
+ ---
12
+
13
+ ## Step 0:恢复上下文(每次必须执行)
14
+
15
+ ### 0a. 恢复项目记忆(渐进式披露)
16
+
17
+ > 不再 cat 全量 .memory.md。改用**索引先行,按需拉取**:索引 ~400 token,详情 ~100-200 token/条。
18
+
19
+ ```bash
20
+ _PROJ=$(basename "$(git worktree list 2>/dev/null | head -1 | awk '{print $1}')" 2>/dev/null || basename "$PWD")
21
+ MEMFILE="$HOME/.atdc/memory/$_PROJ/.memory.md"
22
+
23
+ if [ -f "$MEMFILE" ]; then
24
+ COUNT=$(grep -c "^## " "$MEMFILE" 2>/dev/null || echo 0)
25
+ echo "## 📋 项目记忆索引(共 $COUNT 条,显示最近 20)"
26
+ echo ""
27
+ grep "^## " "$MEMFILE" | tail -20 | awk '{
28
+ # 提取类型图标(## 后的前 4 个字符含 emoji+空格)
29
+ icon = substr($0, 4, 3)
30
+ # 去掉图标后的内容
31
+ rest = substr($0, 7)
32
+ printf "| %s | %s\n", icon, rest
33
+ }'
34
+ echo ""
35
+ echo "💡 渐进式披露:上方为记忆索引。用 Read 工具读取具体条目(~100-200 token/条)。"
36
+ echo " 优先拉取:🔴 bugfix ⚠️ gotcha 🟤 decision ⚖️ tradeoff"
37
+ echo " 相关时拉取:🟢 feature 🟡 refactor 🟣 discovery"
38
+ else
39
+ echo "[无历史记忆]"
40
+ fi
41
+ ```
42
+
43
+ ### 0b. 确保链接目录就绪
44
+
45
+ ```bash
46
+ bash ~/atdc/central/link.sh 2>/dev/null || true
47
+ ```
48
+
49
+ > `.code-review-graph` `.codegraph` `.hc` `.test_plans` `.handoffs` `.evidence` — 统一软链管理。
50
+ > 主仓库存真目录,worktree 自动软链,已有链接跳过(幂等)。
51
+ > 新增目录:编辑 `~/atdc/central/link.sh` 的 DIRS 数组。
52
+
53
+ ### 0b.5 Semble 代码搜索引擎检测
54
+
55
+ ```bash
56
+ command -v semble >/dev/null 2>&1 && echo "✓ Semble 可用" || echo "💡 Semble 未安装。安装: uv tool install semble && semble install --agent opencode --type mcp --yes"
57
+ ```
58
+
59
+ > Semble 为代码语义搜索引擎,3-impl 中的 Ponytail B5 / R5 blast radius 检查可用其加速。
60
+ > 未安装不影响任何现有功能,仅 fallback 到 CodeGraph/grep。
61
+
62
+ ### 0c. Ponytail 模式扫描(静默,无 Go 项目则跳过)
63
+
64
+ ```bash
65
+ # 自动检测项目是否有 Go 模型目录
66
+ if [ -d "models/" ] || [ -d "service/" ]; then
67
+ echo "⚡ Ponytail 模式扫描…" && atdc ponytail scan --warn 2>/dev/null || true
68
+ else
69
+ echo "[非 Go 项目,跳过 Ponytail 扫描]"
70
+ fi
71
+ ```
72
+
73
+ > 扫描结果仅作参考,不影响流程。发现 P0/P1 模式会在后续 3-impl 中被 guard 拦截。
74
+
75
+ ### 0d. Learning 感知层(静默注入)
76
+
77
+ > 注入 self-learning detection prompt,使 Agent 在工作过程中具备"识别 golden path"的背景感知能力。
78
+ > 不执行任何操作,仅让 Agent 知道:遇到以下信号时,应自动触发 learning harvest。
79
+
80
+ ```
81
+ 🔄 Learning 感知已激活(self-learning background awareness)
82
+
83
+ 检测信号(任一触发即自动 harvest,无需用户指令):
84
+ - 操作重试 ≥2 次后才成功
85
+ - 用户纠正过的错误路径
86
+ - 非显而易见的命令/配置/连接方式
87
+ - 刚发现的 project-specific fact
88
+ - 用户说"记住这个"、"沉淀为技能"、"下次别再问"
89
+
90
+ Triage 规则(见 reference/learn.md):
91
+ - 单事实 → .memory.md (⚠️ gotcha)
92
+ - 失败模式 + 死路 → .errors-log.md
93
+ - 满足 promotion rule 3 条 → 自动生成 /atdc:learn 命令
94
+
95
+ 手动触发:/atdc:learn 或 "记住这个"
96
+ ```
97
+
98
+ ### 0e. Rule Loading Protocol(强制)
99
+
100
+ > 🔴 任何阶段 prompt 在被加载后,MUST 先 Read 其关联的 reference 规则文件。
101
+ > 以下引用不是"建议阅读",是"不读不得执行":
102
+
103
+ | 阶段 | MUST Read(不得跳过) |
104
+ |------|---------------------|
105
+ | 1-spec | `reference/risk.md`(Phase 3 复杂度评估时) |
106
+ | 3-impl | `reference/guards.md` + `reference/gates.md` + `reference/tdd.md` + `reference/risk.md` |
107
+ | 4-verify | `reference/risk.md` |
108
+ | 5-done | `reference/memory.md` |
109
+ | X-learn | `reference/learn.md` |
110
+
111
+ > 规则文件中的 MUST / HARD STOP / 禁止 等关键词具有强制执行效力。
112
+ > 看到 `@atdc/reference/x.md` = Read 指令,不是 markdown 链接。
113
+
114
+ ---
115
+
116
+ ## Step 1:检测项目状态
117
+
118
+ ```bash
119
+ # 有无活跃 change
120
+ ls openspec/changes/ 2>/dev/null | grep -v archive | grep -v "^$"
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Step 2:路由
126
+
127
+ 根据用户输入 + 项目状态,选择路由:
128
+
129
+ ### 有活跃 change 时
130
+
131
+ ```
132
+ 检查 .phase-state.json → 判断 mode + 当前阶段 → 路由到对应 prompt
133
+ ```
134
+
135
+ | 条件 | 路由到 |
136
+ |------|--------|
137
+ | `mode=bugfix` | `@atdc/prompts/3-impl-bugfix.md`(Bugfix 5-Phase 流程) |
138
+ | 1-spec 未完成 | `@atdc/prompts/1-spec.md` |
139
+ | 等待执行(C1 已过) | `@atdc/prompts/3-impl.md` |
140
+ | 等待 C3 验证 | `@atdc/prompts/4-verify.md` |
141
+ | 等待归档 | `@atdc/prompts/5-done.md` |
142
+ | 用户说"执行"/"run" | `@atdc/prompts/3-impl.md` |
143
+
144
+ ### 无活跃 change 时
145
+
146
+ | 用户输入意图 | 路由到 |
147
+ |------------|--------|
148
+ | 模糊需求:"我想…"/"有个想法"/"brainstorm" | `@atdc/prompts/1-spec.md`(brainstorm 模式) |
149
+ | 明确需求描述 | `@atdc/prompts/1-spec.md` |
150
+ | `3-impl --skip-spec` / "需求清楚直接实现"/"跳过规格" | `@atdc/prompts/3-impl.md`(跳过 propose) |
151
+ | `health` / "健康检查" | `@atdc/prompts/X-health.md` |
152
+ | `context` / "扫描项目" | `@atdc/prompts/X-context-scan.md` |
153
+
154
+ ### 横向命令(任何时候均可触发)
155
+
156
+ | 输入 | 路由到 |
157
+ |------|--------|
158
+ | `strategy` / `看看策略` / `更新策略` | `@atdc/prompts/X-strategy.md` |
159
+ | `compound` / `沉淀知识` / `沉淀一下` | `@atdc/prompts/X-compound.md` |
160
+ | `review` / `review一下` / `代码审查` | `@atdc/prompts/X-review.md` |
161
+ | `health` / `健康检查` | `@atdc/prompts/X-health.md` |
162
+ | `context` / `扫描项目` | `@atdc/prompts/X-context-scan.md` |
163
+ | `2-qa` / `质疑一下` | `@atdc/prompts/2-qa.md` |
164
+ | `1-update` / "变更需求"/"更新需求" | `@atdc/prompts/1-update.md` |
165
+ | `article` / `生成文章` / `写文章` | `@atdc/prompts/6-article.md` |
166
+ | `diagnose` / `诊断` / `debug` / `调试` | `@atdc/prompts/X-diagnose.md` |
167
+ | `grill-with-docs` / `深度拷问` / `沉淀文档` | `@atdc/prompts/X-grill-with-docs.md` |
168
+ | `code-simplifier` / `simplify` / `简化代码` / `代码简化` | `@atdc/prompts/X-code-simplifier.md` |
169
+ | `test-plan` / `自测计划` / `自测方案` / `生成自测` / `生成自测计划` | `@atdc/prompts/X-test-plan.md` |
170
+ | `zoom-out` / `全景分析` / `看全局` | `@atdc/prompts/X-zoom-out.md` |
171
+ | `handoff` / `交接` / `生成交接` | `@atdc/prompts/X-handoff.md` |
172
+ | `add-to-hc` / `加接口` / `添加 hc` | `@atdc/prompts/X-add-to-hc.md` |
173
+ | `git-guardrails` / `git防护` | `@atdc/commands/opencode/atd/git-guardrails.md` |
174
+ | `learn` / `记住这个` / `沉淀为技能` | `@atdc/prompts/X-learn.md` |
175
+ | `search` / `搜代码` / `找代码` | `@atdc/prompts/X-search.md` |
176
+ | `commit` / `提交信息` / `写commit` | `@atdc/prompts/X-commit.md` |
177
+ | `table2xlsx` / `生成模板` / `DDL转Excel` | `@atdc/prompts/X-table2xlsx.md` |
178
+ | `xlsx2sql-insert` / `Excel转SQL` | `@atdc/prompts/X-xlsx2sql-insert.md` |
179
+ | `xlsx2sql-update` / `Excel转UPDATE` | `@atdc/prompts/X-xlsx2sql-update.md` |
180
+ | `travel-planner` / `旅行攻略` | `@atdc/prompts/X-travel-planner.md` |
181
+ | `add-command` / `新增命令` | `@atdc/prompts/X-add-command.md` |
182
+ | `bugfix` / `修Bug` / `bugfix` | `@atdc/prompts/3-impl-bugfix.md` |
183
+ | `evidence` / `events` / `timing` / `metrics` / `canvas` / `看板` | CLI: `atdc evidence <sub>` |
184
+
185
+ ---
186
+
187
+ ## Step 3:宣布路由结果
188
+
189
+ 输出一行,说明路由到哪个阶段,原因是什么,然后直接执行。无需等待用户确认。
190
+
191
+ 示例:
192
+ > 检测到活跃 change `add-notification`,阶段为执行中(Task 2/5 完成),继续执行 → `3-impl.md`
193
+
194
+ ---
195
+
196
+ ## 目录说明
197
+
198
+ ```
199
+ atdc/
200
+ ├── GO.md ← 你现在读的这个文件
201
+ ├── prompts/
202
+ │ ├── 1-spec.md ← 1-spec:需求澄清 + 规格生成(含 brainstorm 模式)
203
+ │ ├── 1-update.md ← 1-update:需求变更(更新已有 change 的文档)
204
+ │ ├── 2-qa.md ← 2-qa:规格质疑检验(C1 前或独立触发)
205
+ │ ├── 3-impl.md ← 3-impl:执行(含双模式路由 + 全部质量门禁)
206
+ │ ├── 4-verify.md ← 4-verify:C3 验证
207
+ │ ├── 5-done.md ← 5-done:归档 + 写记忆
208
+ │ ├── X-strategy.md ← 横向:产品策略锚点(STRATEGY.md 创建/更新)
209
+ │ ├── X-code-simplifier.md ← 横向:代码简化(基于 code-simplifier skill)
210
+ │ ├── X-test-plan.md ← 横向:自测计划生成(文档 + 集成测试代码)
211
+ │ ├── X-compound.md ← 横向:知识沉淀(docs/solutions/ + CONCEPTS.md)
212
+ │ ├── X-review.md ← 横向:代码级 review(blast radius + 风险评分 + 测试缺口)
213
+ │ ├── X-health.md ← 横向:项目健康巡检
214
+ │ └── X-context-scan.md ← 横向:首次入场扫描,生成项目全景
215
+ │ ├── X-learn.md ← 横向:self-learning 桥接(session→golden path→skill)
216
+ │ ├── X-commit.md ← 横向:Git Commit Message 生成
217
+ │ ├── X-add-command.md ← 横向:新增 atd 命令
218
+ │ ├── X-table2xlsx.md ← 横向:DDL→Excel 模板
219
+ │ ├── X-xlsx2sql-insert.md ← 横向:Excel→INSERT SQL
220
+ │ ├── X-xlsx2sql-update.md ← 横向:Excel→UPDATE SQL
221
+ │ ├── X-travel-planner.md ← 横向:旅行规划助手
222
+ │ └── X-add-to-hc.md ← 横向:添加 API 到 .hc 测试
223
+ ├── reference/
224
+ │ ├── guards.md ← R1-R6 硬性拦截规则 + B5 沿用抽象
225
+ │ ├── gates.md ← Gate 1-4 质量门禁详细规则
226
+ │ ├── tdd.md ← TDD 约束(红/绿/重构循环)
227
+ │ ├── memory.md ← 跨 session 记忆协议
228
+ │ ├── learn.md ← self-learning → atd 桥接协议
229
+ │ ├── diagnose-loop.md ← 结构化调试循环
230
+ │ ├── risk.md ← 风险评分算法
231
+ │ └── git-guardrails.md ← Git 安全防护
232
+ └── templates/
233
+ ├── proposal.md ← change 提案模板
234
+ ├── design.md ← 技术设计模板
235
+ ├── tasks.md ← 任务清单模板
236
+ ├── strategy.md ← 产品策略模板(STRATEGY.md)
237
+ ├── solution.md ← 知识沉淀模板(docs/solutions/)
238
+ ├── concepts.md ← 领域词汇表模板(CONCEPTS.md)
239
+ ├── changelog.md ← 需求变更记录模板
240
+ ├── progress.json ← 执行进度模板
241
+ ├── .phase-state.json ← 阶段状态模板(runtime)
242
+ ├── adr.md ← 架构决策记录模板
243
+ ├── handoff.md ← 交接文档模板
244
+ └── learn-skill.md ← self-learning 生成 skill 模板
245
+ ```
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ atdc 命令生成器 — 一键创建跨 4 端的新命令
4
+
5
+ 用法:
6
+ python3 add-command.py <name> <desc> <trigger_words> [--prompt X-xxx]
7
+
8
+ 示例:
9
+ python3 add-command.py my-cmd "我的命令描述" "my-cmd、我的命令"
10
+ python3 add-command.py table2xlsx "DDL→Excel" "table2xlsx、生成模板" --prompt X-table2xlsx
11
+ """
12
+
13
+ import os, sys, argparse
14
+
15
+ ATD = os.path.expanduser("~/atdc")
16
+
17
+ TEMPLATES = {
18
+ "opencode": """---
19
+ description: {desc},跳过自动路由
20
+ ---
21
+ 用 Read 工具读取 ${ATDC_DIR}/prompts/{prompt}.md,然后直接开始执行。
22
+
23
+ $ARGUMENTS
24
+ """,
25
+ "claude": """用 Read 工具读取 ${ATDC_DIR}/prompts/{prompt}.md,然后直接开始执行。
26
+ 跳过 GO.md 路由。
27
+
28
+ $ARGUMENTS
29
+ """,
30
+ "codex": """---
31
+ name: atd:{name}
32
+ description: {desc}。触发词:{triggers}。
33
+ ---
34
+ 用 Read 工具读取 `${ATDC_DIR}/prompts/{prompt}.md`,然后直接开始执行。
35
+ """,
36
+ "cursor": """---
37
+ name: atd:{name}
38
+ description: {desc}。触发词:{triggers}。
39
+ ---
40
+ 用 Read 工具读取 `${ATDC_DIR}/prompts/{prompt}.md`,然后直接开始执行。
41
+ """,
42
+ }
43
+
44
+ PATHS = {
45
+ "opencode": f"{ATD}/commands/opencode/atd/{{name}}.md",
46
+ "claude": f"{ATD}/commands/claude/atd/{{name}}.md",
47
+ "codex": f"{ATD}/commands/codex/atd-{{name}}/SKILL.md",
48
+ "cursor": f"{ATD}/commands/cursor/atd-{{name}}/SKILL.md",
49
+ }
50
+
51
+ def add_command(name, desc, triggers, prompt=None, short_desc=None, from_learn=False, failure=None, dead_end=None):
52
+ if prompt is None:
53
+ prompt = f"X-{name}"
54
+ if short_desc is None:
55
+ short_desc = desc[:30]
56
+
57
+ for platform, tmpl in TEMPLATES.items():
58
+ path = PATHS[platform].format(name=name)
59
+ os.makedirs(os.path.dirname(path), exist_ok=True)
60
+ content = tmpl.format(name=name, desc=desc, triggers=triggers,
61
+ prompt=prompt, short_desc=short_desc)
62
+ with open(path, "w") as f:
63
+ f.write(content)
64
+ print(f" ✓ {platform:10s} {path}")
65
+
66
+ # create prompt template
67
+ prompt_path = f"{ATD}/prompts/{prompt}.md"
68
+ if not os.path.exists(prompt_path):
69
+ os.makedirs(os.path.dirname(prompt_path), exist_ok=True)
70
+ if from_learn:
71
+ with open(prompt_path, "w") as f:
72
+ f.write(f"# prompts/{prompt} · {short_desc}\n\n")
73
+ f.write(f"横向命令,任意时刻可触发:`/atdc:{name} <args>`\n\n")
74
+ f.write(f"> 🧠 Auto-harvested by self-learning\n\n")
75
+ f.write("---\n\n")
76
+ if failure:
77
+ f.write(f"## 失败模式\n\n")
78
+ f.write(f"**这个 skill 避免的诊断**:`{failure}`\n\n")
79
+ f.write("## 执行步骤\n\n")
80
+ f.write("### 1. 确定输入\n\n")
81
+ f.write("### 2. 执行\n\n")
82
+ f.write("---\n\n")
83
+ if dead_end:
84
+ f.write(f"## What didn't work\n\n")
85
+ f.write(f"- `{dead_end}`:被排除\n\n")
86
+ f.write("## 验证方式\n\n")
87
+ f.write("`<passing check — 什么命令/测试验证了这个路径>`\n\n")
88
+ else:
89
+ with open(prompt_path, "w") as f:
90
+ f.write(f"# prompts/{prompt} · {short_desc}\n\n")
91
+ f.write(f"横向命令,任意时刻可触发:`/atdc:{name} <args>`\n\n")
92
+ f.write("## 执行步骤\n\n")
93
+ f.write("### 1. 确定输入\n\n")
94
+ f.write("### 2. 执行\n\n")
95
+ print(f" ✓ prompt {prompt_path}")
96
+
97
+ # update install.sh skill list
98
+ install_sh = f"{ATD}/install.sh"
99
+ with open(install_sh) as f:
100
+ content = f.read()
101
+
102
+ skill_name = f"atd-{name}"
103
+ marker = "for skill in atd "
104
+ if marker in content and skill_name not in content:
105
+ # Find the "for skill in" line and add the new skill
106
+ lines = content.split("\n")
107
+ for i, line in enumerate(lines):
108
+ if "for skill in atd " in line and skill_name not in line:
109
+ # Insert before the "do" keyword
110
+ j = line.rfind("; do")
111
+ if j < 0:
112
+ continue
113
+ lines[i] = line[:j] + f" {skill_name}" + line[j:]
114
+ break
115
+ with open(install_sh, "w") as f:
116
+ f.write("\n".join(lines))
117
+ print(f" ✓ install.sh {skill_name} 已注册")
118
+ else:
119
+ print(f" - install.sh {skill_name} 已存在或无需更新")
120
+
121
+ # create agents/skills symlink
122
+ agents_skill = os.path.expanduser(f"~/.agents/skills/{skill_name}")
123
+ target = f"{ATD}/commands/codex/{skill_name}"
124
+ if not os.path.islink(agents_skill):
125
+ os.symlink(target, agents_skill)
126
+ print(f" ✓ symlink {agents_skill} -> {target}")
127
+
128
+ print(f"\n✅ 命令 /atdc:{name} 已创建(4 端 + prompt + install.sh + symlink)")
129
+ print(f" 重启各终端 Ctrl+C 重进即可使用。")
130
+
131
+
132
+ if __name__ == "__main__":
133
+ p = argparse.ArgumentParser(description="atdc 命令生成器")
134
+ p.add_argument("name", help="命令名 (kebab-case, 如 my-cmd)")
135
+ p.add_argument("desc", help="命令描述")
136
+ p.add_argument("triggers", help="触发词 (逗号分隔, 如 'cmd、命令')")
137
+ p.add_argument("--prompt", help="prompt 文件名 (默认 X-<name>)")
138
+ p.add_argument("--short", help="简短描述 (body 结尾句)")
139
+ p.add_argument("--from-learn", action="store_true", help="从 self-learning harvest 生成(使用 learn-skill 模板)")
140
+ p.add_argument("--failure", help="这个 skill 避免/诊断的失败模式")
141
+ p.add_argument("--dead-end", help="被排除的死路方案")
142
+ args = p.parse_args()
143
+ add_command(args.name, args.desc, args.triggers, args.prompt, args.short,
144
+ from_learn=args.from_learn, failure=args.failure, dead_end=args.dead_end)