add-coder 0.3.26 → 0.3.28

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 (323) hide show
  1. package/README.md +282 -155
  2. package/dist/index.js +481 -209
  3. package/package.json +15 -4
  4. package/templates/.add-coder-src-hash.json +186 -185
  5. package/templates/adapters/claude/hooks/doc-format-guard.ts +32 -0
  6. package/templates/adapters/claude/hooks/lib/claude-env.ts +7 -0
  7. package/templates/adapters/claude/hooks/notification.ts +24 -0
  8. package/templates/adapters/claude/hooks/permission-denied.ts +33 -0
  9. package/templates/adapters/claude/hooks/permission-gate.ts +12 -0
  10. package/templates/adapters/claude/hooks/post-tool-failure.ts +4 -0
  11. package/templates/adapters/claude/hooks/post-tool-use.ts +17 -0
  12. package/templates/adapters/claude/hooks/pre-compact.ts +10 -0
  13. package/templates/adapters/claude/hooks/pre-tool-use.ts +81 -0
  14. package/templates/adapters/claude/hooks/prompt-submit.ts +82 -0
  15. package/templates/adapters/claude/hooks/review-checklist.ts +4 -0
  16. package/templates/adapters/claude/hooks/session-end.ts +10 -0
  17. package/templates/adapters/claude/hooks/session-start.ts +24 -0
  18. package/templates/adapters/claude/hooks/stop-check.ts +15 -0
  19. package/templates/adapters/claude/hooks/stop-failure.ts +34 -0
  20. package/templates/adapters/claude/hooks/subagent-guard.ts +25 -0
  21. package/templates/adapters/claude/hooks/subagent-stop.ts +12 -0
  22. package/templates/adapters/claude/settings.json +13 -13
  23. package/templates/adapters/codex/config.toml.example +12 -0
  24. package/templates/adapters/codex/hooks/doc-format-guard.ts +30 -0
  25. package/templates/adapters/codex/hooks/notification.ts +26 -0
  26. package/templates/adapters/codex/hooks/permission-gate.ts +15 -0
  27. package/templates/adapters/codex/hooks/post-tool-failure.ts +14 -0
  28. package/templates/adapters/codex/hooks/post-tool-use.ts +85 -0
  29. package/templates/adapters/codex/hooks/pre-compact.ts +20 -0
  30. package/templates/adapters/codex/hooks/pre-tool-use.ts +141 -0
  31. package/templates/adapters/codex/hooks/prompt-submit.ts +38 -0
  32. package/templates/adapters/codex/hooks/review-checklist.ts +5 -0
  33. package/templates/adapters/codex/hooks/session-end.ts +19 -0
  34. package/templates/adapters/codex/hooks/session-start.ts +45 -0
  35. package/templates/adapters/codex/hooks/stop-check.ts +59 -0
  36. package/templates/adapters/codex/hooks/subagent-guard.ts +22 -0
  37. package/templates/adapters/codex/hooks/subagent-stop.ts +20 -0
  38. package/templates/adapters/codex/hooks.json +67 -1
  39. package/templates/adapters/qoder/hooks/doc-format-guard.ts +34 -0
  40. package/templates/adapters/qoder/hooks/lib/context-inject.ts +61 -0
  41. package/templates/adapters/qoder/hooks/lib/qoder-env.ts +23 -0
  42. package/templates/adapters/qoder/hooks/lib/review-checklist.ts +5 -0
  43. package/templates/adapters/qoder/hooks/notification.ts +34 -0
  44. package/templates/adapters/qoder/hooks/permission-gate.ts +26 -0
  45. package/templates/adapters/qoder/hooks/post-tool-failure.ts +30 -0
  46. package/templates/adapters/qoder/hooks/post-tool-use.ts +32 -0
  47. package/templates/adapters/qoder/hooks/pre-compact.ts +16 -0
  48. package/templates/adapters/qoder/hooks/pre-tool-use.ts +112 -0
  49. package/templates/adapters/qoder/hooks/prompt-submit.ts +66 -0
  50. package/templates/adapters/qoder/hooks/review-checklist.ts +24 -0
  51. package/templates/adapters/qoder/hooks/session-end.ts +27 -0
  52. package/templates/adapters/qoder/hooks/session-start.ts +83 -0
  53. package/templates/adapters/qoder/hooks/stop-check.ts +69 -0
  54. package/templates/adapters/qoder/hooks/subagent-guard.ts +16 -0
  55. package/templates/adapters/qoder/hooks/subagent-stop.ts +33 -0
  56. package/templates/adapters/qoder/settings.json +13 -13
  57. package/templates/adapters/trae/hooks/doc-format-guard.ts +30 -0
  58. package/templates/adapters/trae/hooks/notification.ts +22 -0
  59. package/templates/adapters/trae/hooks/permission-gate.ts +15 -0
  60. package/templates/adapters/trae/hooks/post-tool-failure.ts +14 -0
  61. package/templates/adapters/trae/hooks/post-tool-use.ts +24 -0
  62. package/templates/adapters/trae/hooks/pre-compact.ts +15 -0
  63. package/templates/adapters/trae/hooks/pre-tool-use.ts +40 -0
  64. package/templates/adapters/trae/hooks/prompt-submit.ts +29 -0
  65. package/templates/adapters/trae/hooks/review-checklist.ts +5 -0
  66. package/templates/adapters/trae/hooks/session-end.ts +16 -0
  67. package/templates/adapters/trae/hooks/session-start.ts +15 -0
  68. package/templates/adapters/trae/hooks/stop-check.ts +20 -0
  69. package/templates/adapters/trae/hooks/subagent-guard.ts +22 -0
  70. package/templates/adapters/trae/hooks/subagent-stop.ts +15 -0
  71. package/templates/adapters/trae/hooks.json +1 -1
  72. package/templates/adapters/vscode/hooks/doc-format-guard.ts +27 -0
  73. package/templates/adapters/vscode/hooks/notification.ts +22 -0
  74. package/templates/adapters/vscode/hooks/permission-gate.ts +15 -0
  75. package/templates/adapters/vscode/hooks/post-tool-failure.ts +32 -0
  76. package/templates/adapters/vscode/hooks/post-tool-use.ts +25 -0
  77. package/templates/adapters/vscode/hooks/pre-compact.ts +15 -0
  78. package/templates/adapters/vscode/hooks/pre-tool-use.ts +78 -0
  79. package/templates/adapters/vscode/hooks/prompt-submit.ts +74 -0
  80. package/templates/adapters/vscode/hooks/review-checklist.ts +5 -0
  81. package/templates/adapters/vscode/hooks/session-end.ts +16 -0
  82. package/templates/adapters/vscode/hooks/session-start.ts +24 -0
  83. package/templates/adapters/vscode/hooks/stop-check.ts +21 -0
  84. package/templates/adapters/vscode/hooks/subagent-guard.ts +21 -0
  85. package/templates/adapters/vscode/hooks/subagent-stop.ts +15 -0
  86. package/templates/core/docs/ADD-governance-claude-code.md +4 -4
  87. package/templates/core/docs/ADD-governance-codex.md +6 -6
  88. package/templates/core/docs/ADD-governance-qoder-cn.md +5 -5
  89. package/templates/core/docs/ADD-governance-trae.md +3 -3
  90. package/templates/core/docs/ADD-governance-vscode-copilot.md +22 -23
  91. package/templates/core/governance/audit-bridge.ts +47 -0
  92. package/templates/core/governance/common.ts +299 -0
  93. package/templates/core/governance/context-inject.ts +53 -0
  94. package/templates/core/governance/doc-format-guard.ts +440 -0
  95. package/templates/core/governance/notification-router.ts +62 -0
  96. package/templates/core/governance/notify.ts +66 -0
  97. package/templates/core/governance/permission-gate-router.ts +42 -0
  98. package/templates/core/governance/post-tool-failure-router.ts +56 -0
  99. package/templates/core/governance/post-tool-router.ts +212 -0
  100. package/templates/core/governance/pre-compact-guard.ts +41 -0
  101. package/templates/core/governance/pre-tool-guard.ts +309 -0
  102. package/templates/core/governance/preload-templates.ts +241 -0
  103. package/templates/core/governance/prompt-router.ts +222 -0
  104. package/templates/core/governance/review-checklist-guard.ts +186 -0
  105. package/templates/core/governance/rules.ts +720 -0
  106. package/templates/core/governance/session-end.ts +88 -0
  107. package/templates/core/governance/session-start-guard.ts +99 -0
  108. package/templates/core/governance/state-detect.ts +6 -0
  109. package/templates/core/governance/stop-router.ts +140 -0
  110. package/templates/core/governance/subagent-guard-router.ts +35 -0
  111. package/templates/core/governance/subagent-stop-router.ts +93 -0
  112. package/templates/core/governance/subagent-stop.ts +75 -0
  113. package/templates/core/governance/vocabulary.ts +109 -0
  114. package/templates/core/hooks/doc-format-guard.ts +21 -0
  115. package/templates/core/hooks/notification.ts +11 -0
  116. package/templates/core/hooks/permission-gate.ts +7 -0
  117. package/templates/core/hooks/post-tool-failure.ts +7 -0
  118. package/templates/core/hooks/post-tool-use.ts +23 -0
  119. package/templates/core/hooks/pre-compact.ts +9 -0
  120. package/templates/core/hooks/pre-tool-use.ts +30 -0
  121. package/templates/core/hooks/prompt-submit.ts +11 -0
  122. package/templates/core/hooks/review-checklist.ts +4 -0
  123. package/templates/core/hooks/session-end.ts +10 -0
  124. package/templates/core/hooks/session-start.ts +9 -0
  125. package/templates/core/hooks/stop-check.ts +14 -0
  126. package/templates/core/hooks/subagent-guard.ts +8 -0
  127. package/templates/core/hooks/subagent-stop.ts +9 -0
  128. package/templates/core/prisma/add.prisma +140 -82
  129. package/templates/core/rules/project_rules.md +27 -24
  130. package/templates/core/scripts/db-ensure.sh +8 -0
  131. package/templates/core/scripts/gen-plan-index.sh +4 -15
  132. package/templates/core/scripts/mcp-server/notifications/hitl.ts +9 -1
  133. package/templates/core/scripts/mcp-server/notifications/hook.ts +25 -9
  134. package/templates/core/scripts/mcp-server/resources/hitl-approval-widget.ts +34 -0
  135. package/templates/core/scripts/mcp-server/resources/hook-events-report.ts +14 -2
  136. package/templates/core/scripts/mcp-server/resources/index.ts +2 -0
  137. package/templates/core/scripts/mcp-server/sampling/review.ts +25 -10
  138. package/templates/core/scripts/mcp-server/shared/db-types.ts +33 -8
  139. package/templates/core/scripts/mcp-server/shared/dps-scoring.strategy.ts +1 -1
  140. package/templates/core/scripts/mcp-server/shared/env.ts +28 -8
  141. package/templates/core/scripts/mcp-server/shared/fs.ts +3 -0
  142. package/templates/core/scripts/mcp-server/shared/hitl-interaction.strategy.ts +2 -3
  143. package/templates/core/scripts/mcp-server/shared/hitl-lifecycle-mutation.ts +129 -0
  144. package/templates/core/scripts/mcp-server/shared/hitl-proposal-mutation.ts +98 -0
  145. package/templates/core/scripts/mcp-server/shared/hitl-ui.ts +3 -0
  146. package/templates/core/scripts/mcp-server/shared/plan-lifecycle-events.ts +62 -0
  147. package/templates/core/scripts/mcp-server/shared/plan-lifecycle-mutation.ts +78 -0
  148. package/templates/core/scripts/mcp-server/shared/plan-lifecycle-subscriber.ts +145 -0
  149. package/templates/core/scripts/mcp-server/shared/plan-lifecycle.ts +153 -0
  150. package/templates/core/scripts/mcp-server/shared/plan-round-events.ts +56 -0
  151. package/templates/core/scripts/mcp-server/shared/plan-round-mutation.ts +143 -0
  152. package/templates/core/scripts/mcp-server/shared/plan-round-store.ts +47 -0
  153. package/templates/core/scripts/mcp-server/shared/plan-round-subscriber.ts +99 -0
  154. package/templates/core/scripts/mcp-server/shared/plan-status-store.ts +37 -0
  155. package/templates/core/scripts/mcp-server/shared/plan-tracking-mutation.ts +71 -0
  156. package/templates/core/scripts/mcp-server/shared/prisma.ts +12 -6
  157. package/templates/core/scripts/mcp-server/shared/project-root-strategy.ts +1 -2
  158. package/templates/core/scripts/mcp-server/shared/quant-recheck.strategy.ts +16 -0
  159. package/templates/core/scripts/mcp-server/shared/redact.ts +28 -0
  160. package/templates/core/scripts/mcp-server/shared/response.ts +3 -2
  161. package/templates/core/scripts/mcp-server/shared/runtime-context.ts +77 -0
  162. package/templates/core/scripts/mcp-server/shared/schema-topology.ts +159 -0
  163. package/templates/core/scripts/mcp-server/tools/audit.ts +49 -7
  164. package/templates/core/scripts/mcp-server/tools/context.ts +117 -121
  165. package/templates/core/scripts/mcp-server/tools/contract.ts +34 -9
  166. package/templates/core/scripts/mcp-server/tools/gateway/check_add_route_status.ts +50 -3
  167. package/templates/core/scripts/mcp-server/tools/gateway/check_doc_similarity.ts +218 -0
  168. package/templates/core/scripts/mcp-server/tools/gateway/check_dps.ts +22 -7
  169. package/templates/core/scripts/mcp-server/tools/gateway/check_rahs.ts +86 -4
  170. package/templates/core/scripts/mcp-server/tools/gateway/check_spec_sync.ts +19 -6
  171. package/templates/core/scripts/mcp-server/tools/gateway/index.ts +2 -0
  172. package/templates/core/scripts/mcp-server/tools/hitl.ts +160 -75
  173. package/templates/core/scripts/mcp-server/tools/hook-event-report.ts +9 -2
  174. package/templates/core/scripts/mcp-server/tools/index.ts +69 -3
  175. package/templates/core/scripts/mcp-server/tools/plan.ts +152 -17
  176. package/templates/core/scripts/mcp-server/tools/review.ts +44 -15
  177. package/templates/core/scripts/mcp-server.ts +60 -1
  178. package/templates/core/scripts/plan-status-bridge.ts +26 -0
  179. package/templates/core/skills/add-paradigm/SKILL.md +2 -2
  180. package/templates/core/templates/add-route-template.schema.json +24 -56
  181. package/templates/core/templates/collab-contract-template.md +1 -1
  182. package/templates/core/templates/handoff-multi-round-template.schema.json +48 -0
  183. package/templates/core/templates/handoff-single-round-template.schema.json +92 -0
  184. package/templates/core/templates/handoff-single-round.schema.json +1 -1
  185. package/templates/core/templates/hitl-approval-widget.html +222 -37
  186. package/templates/core/templates/spec-template.schema.json +9 -46
  187. package/templates/core/templates/standard-plan-template.schema.json +1 -1
  188. package/templates/core/templates/tasks-template.schema.json +13 -54
  189. package/templates/adapters/claude/hooks/doc-format-guard.sh +0 -202
  190. package/templates/adapters/claude/hooks/lib/common.sh +0 -261
  191. package/templates/adapters/claude/hooks/lib/context-inject.sh +0 -96
  192. package/templates/adapters/claude/hooks/lib/notify.sh +0 -34
  193. package/templates/adapters/claude/hooks/lib/preload-templates.sh +0 -187
  194. package/templates/adapters/claude/hooks/lib/session-end.sh +0 -76
  195. package/templates/adapters/claude/hooks/lib/state-detect.sh +0 -117
  196. package/templates/adapters/claude/hooks/lib/subagent-stop.sh +0 -90
  197. package/templates/adapters/claude/hooks/lib/vocabulary.sh +0 -56
  198. package/templates/adapters/claude/hooks/notification.sh +0 -45
  199. package/templates/adapters/claude/hooks/permission-denied.sh +0 -42
  200. package/templates/adapters/claude/hooks/permission-gate.sh +0 -18
  201. package/templates/adapters/claude/hooks/post-tool-failure.sh +0 -10
  202. package/templates/adapters/claude/hooks/post-tool-use.sh +0 -35
  203. package/templates/adapters/claude/hooks/pre-compact.sh +0 -37
  204. package/templates/adapters/claude/hooks/pre-tool-use.sh +0 -153
  205. package/templates/adapters/claude/hooks/prompt-submit.sh +0 -99
  206. package/templates/adapters/claude/hooks/review-checklist.sh +0 -10
  207. package/templates/adapters/claude/hooks/session-end.sh +0 -21
  208. package/templates/adapters/claude/hooks/session-start.sh +0 -36
  209. package/templates/adapters/claude/hooks/stop-check.sh +0 -45
  210. package/templates/adapters/claude/hooks/stop-failure.sh +0 -44
  211. package/templates/adapters/claude/hooks/subagent-guard.sh +0 -36
  212. package/templates/adapters/claude/hooks/subagent-stop.sh +0 -20
  213. package/templates/adapters/codex/hooks/doc-format-guard.sh +0 -261
  214. package/templates/adapters/codex/hooks/lib/common.sh +0 -261
  215. package/templates/adapters/codex/hooks/lib/context-inject.sh +0 -96
  216. package/templates/adapters/codex/hooks/lib/notify.sh +0 -34
  217. package/templates/adapters/codex/hooks/lib/preload-templates.sh +0 -187
  218. package/templates/adapters/codex/hooks/lib/session-end.sh +0 -76
  219. package/templates/adapters/codex/hooks/lib/state-detect.sh +0 -117
  220. package/templates/adapters/codex/hooks/lib/subagent-stop.sh +0 -90
  221. package/templates/adapters/codex/hooks/lib/vocabulary.sh +0 -56
  222. package/templates/adapters/codex/hooks/notification.sh +0 -45
  223. package/templates/adapters/codex/hooks/permission-gate.sh +0 -18
  224. package/templates/adapters/codex/hooks/post-tool-failure.sh +0 -10
  225. package/templates/adapters/codex/hooks/post-tool-use.sh +0 -138
  226. package/templates/adapters/codex/hooks/pre-compact.sh +0 -37
  227. package/templates/adapters/codex/hooks/pre-tool-use.sh +0 -217
  228. package/templates/adapters/codex/hooks/prompt-submit.sh +0 -87
  229. package/templates/adapters/codex/hooks/review-checklist.sh +0 -10
  230. package/templates/adapters/codex/hooks/session-end.sh +0 -38
  231. package/templates/adapters/codex/hooks/session-start.sh +0 -53
  232. package/templates/adapters/codex/hooks/stop-check.sh +0 -45
  233. package/templates/adapters/codex/hooks/subagent-guard.sh +0 -15
  234. package/templates/adapters/codex/hooks/subagent-stop.sh +0 -47
  235. package/templates/adapters/qoder/hooks/doc-format-guard.sh +0 -260
  236. package/templates/adapters/qoder/hooks/lib/common.sh +0 -261
  237. package/templates/adapters/qoder/hooks/lib/context-inject.sh +0 -96
  238. package/templates/adapters/qoder/hooks/lib/notify.sh +0 -34
  239. package/templates/adapters/qoder/hooks/lib/preload-templates.sh +0 -187
  240. package/templates/adapters/qoder/hooks/lib/session-end.sh +0 -76
  241. package/templates/adapters/qoder/hooks/lib/state-detect.sh +0 -117
  242. package/templates/adapters/qoder/hooks/lib/subagent-stop.sh +0 -90
  243. package/templates/adapters/qoder/hooks/lib/vocabulary.sh +0 -56
  244. package/templates/adapters/qoder/hooks/notification.sh +0 -25
  245. package/templates/adapters/qoder/hooks/permission-gate.sh +0 -8
  246. package/templates/adapters/qoder/hooks/post-tool-failure.sh +0 -8
  247. package/templates/adapters/qoder/hooks/post-tool-use.sh +0 -121
  248. package/templates/adapters/qoder/hooks/pre-compact.sh +0 -37
  249. package/templates/adapters/qoder/hooks/pre-tool-use.sh +0 -154
  250. package/templates/adapters/qoder/hooks/prompt-submit.sh +0 -96
  251. package/templates/adapters/qoder/hooks/review-checklist.sh +0 -157
  252. package/templates/adapters/qoder/hooks/session-end.sh +0 -24
  253. package/templates/adapters/qoder/hooks/session-start.sh +0 -45
  254. package/templates/adapters/qoder/hooks/stop-check.sh +0 -48
  255. package/templates/adapters/qoder/hooks/subagent-guard.sh +0 -27
  256. package/templates/adapters/qoder/hooks/subagent-stop.sh +0 -26
  257. package/templates/adapters/trae/hooks/doc-format-guard.sh +0 -261
  258. package/templates/adapters/trae/hooks/lib/common.sh +0 -261
  259. package/templates/adapters/trae/hooks/lib/context-inject.sh +0 -96
  260. package/templates/adapters/trae/hooks/lib/notify.sh +0 -34
  261. package/templates/adapters/trae/hooks/lib/preload-templates.sh +0 -187
  262. package/templates/adapters/trae/hooks/lib/session-end.sh +0 -76
  263. package/templates/adapters/trae/hooks/lib/state-detect.sh +0 -117
  264. package/templates/adapters/trae/hooks/lib/subagent-stop.sh +0 -90
  265. package/templates/adapters/trae/hooks/lib/vocabulary.sh +0 -56
  266. package/templates/adapters/trae/hooks/notification.sh +0 -45
  267. package/templates/adapters/trae/hooks/permission-gate.sh +0 -18
  268. package/templates/adapters/trae/hooks/post-tool-failure.sh +0 -10
  269. package/templates/adapters/trae/hooks/post-tool-use.sh +0 -138
  270. package/templates/adapters/trae/hooks/pre-compact.sh +0 -37
  271. package/templates/adapters/trae/hooks/pre-tool-use.sh +0 -217
  272. package/templates/adapters/trae/hooks/prompt-submit.sh +0 -87
  273. package/templates/adapters/trae/hooks/review-checklist.sh +0 -10
  274. package/templates/adapters/trae/hooks/session-end.sh +0 -38
  275. package/templates/adapters/trae/hooks/session-start.sh +0 -53
  276. package/templates/adapters/trae/hooks/stop-check.sh +0 -45
  277. package/templates/adapters/trae/hooks/subagent-guard.sh +0 -15
  278. package/templates/adapters/trae/hooks/subagent-stop.sh +0 -47
  279. package/templates/adapters/vscode/hooks/doc-format-guard.sh +0 -201
  280. package/templates/adapters/vscode/hooks/lib/common.sh +0 -261
  281. package/templates/adapters/vscode/hooks/lib/context-inject.sh +0 -96
  282. package/templates/adapters/vscode/hooks/lib/notify.sh +0 -34
  283. package/templates/adapters/vscode/hooks/lib/preload-templates.sh +0 -187
  284. package/templates/adapters/vscode/hooks/lib/session-end.sh +0 -76
  285. package/templates/adapters/vscode/hooks/lib/state-detect.sh +0 -117
  286. package/templates/adapters/vscode/hooks/lib/subagent-stop.sh +0 -90
  287. package/templates/adapters/vscode/hooks/lib/vocabulary.sh +0 -56
  288. package/templates/adapters/vscode/hooks/notification.sh +0 -45
  289. package/templates/adapters/vscode/hooks/permission-gate.sh +0 -18
  290. package/templates/adapters/vscode/hooks/post-tool-failure.sh +0 -28
  291. package/templates/adapters/vscode/hooks/post-tool-use.sh +0 -35
  292. package/templates/adapters/vscode/hooks/pre-compact.sh +0 -37
  293. package/templates/adapters/vscode/hooks/pre-tool-use.sh +0 -153
  294. package/templates/adapters/vscode/hooks/prompt-submit.sh +0 -99
  295. package/templates/adapters/vscode/hooks/review-checklist.sh +0 -10
  296. package/templates/adapters/vscode/hooks/session-end.sh +0 -13
  297. package/templates/adapters/vscode/hooks/session-start.sh +0 -35
  298. package/templates/adapters/vscode/hooks/stop-check.sh +0 -53
  299. package/templates/adapters/vscode/hooks/subagent-guard.sh +0 -37
  300. package/templates/adapters/vscode/hooks/subagent-stop.sh +0 -12
  301. package/templates/core/hooks/doc-format-guard.sh +0 -261
  302. package/templates/core/hooks/lib/common.sh +0 -261
  303. package/templates/core/hooks/lib/context-inject.sh +0 -96
  304. package/templates/core/hooks/lib/notify.sh +0 -34
  305. package/templates/core/hooks/lib/preload-templates.sh +0 -187
  306. package/templates/core/hooks/lib/session-end.sh +0 -76
  307. package/templates/core/hooks/lib/state-detect.sh +0 -117
  308. package/templates/core/hooks/lib/subagent-stop.sh +0 -90
  309. package/templates/core/hooks/lib/vocabulary.sh +0 -56
  310. package/templates/core/hooks/notification.sh +0 -45
  311. package/templates/core/hooks/permission-gate.sh +0 -18
  312. package/templates/core/hooks/post-tool-failure.sh +0 -10
  313. package/templates/core/hooks/post-tool-use.sh +0 -138
  314. package/templates/core/hooks/pre-compact.sh +0 -37
  315. package/templates/core/hooks/pre-tool-use.sh +0 -217
  316. package/templates/core/hooks/prompt-submit.sh +0 -87
  317. package/templates/core/hooks/review-checklist.sh +0 -10
  318. package/templates/core/hooks/session-end.sh +0 -38
  319. package/templates/core/hooks/session-start.sh +0 -53
  320. package/templates/core/hooks/stop-check.sh +0 -45
  321. package/templates/core/hooks/subagent-guard.sh +0 -15
  322. package/templates/core/hooks/subagent-stop.sh +0 -47
  323. package/templates/shared/hooks-lib/common.sh +0 -22
@@ -0,0 +1,720 @@
1
+ // ═══════════════════════════════════════════════════════════════
2
+ // rules.ts — Hook 规则常量(_generated,勿手改本文件)
3
+ // 真源: src/caijuehub/hook-*.toml ×5(guard/doc/context/event/protocol)
4
+ // 生成器: scripts/hook-rules-gen.ts(hook-bake 烘焙前自动调用)
5
+ // 消费方式: hook 源码 import "./rules.js"(bundle 内联,产物零依赖)
6
+ // ═══════════════════════════════════════════════════════════════
7
+
8
+ // ── GENERATED BEGIN(真源: src/caijuehub/hook-*.toml)──
9
+ export const guard = {
10
+ "detectors": [
11
+ {
12
+ "id": "dangerous-command",
13
+ "regex": "rm\\s+-rf\\s+/|DROP\\s+TABLE|git\\s+push\\s+--force|mkfs\\.|dd\\s+if=",
14
+ "flags": "i",
15
+ "reason": "危险命令已被阻止",
16
+ "stderr": "⛔ 危险命令已被阻止: {{cmd}}\n"
17
+ },
18
+ {
19
+ "id": "script-interpreter",
20
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(python3?|node|ruby|perl|php)(\\s|$)",
21
+ "reason": "禁止通过脚本解释器直接修改文件。请使用 Write 或 SearchReplace 工具操作文件。",
22
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过脚本解释器直接修改文件。\n\n python/node/ruby/perl/php 可在脚本中写入任意文件,绕过:\n · Plan 关联检查(哪个文件属于哪个 ADD Plan?)\n · doc-format-guard(章节/占位符/禁止词校验)\n · 审计追踪(agentAudit 无法感知 Bash 内部的文件变更)\n\n → 请改用 Write 或 SearchReplace 工具操作文件。\n → 如需运行构建/测试脚本,使用 npx/pnpm/npm 命令。\n"
23
+ },
24
+ {
25
+ "id": "sed-in-place",
26
+ "regex": "(^|[;&|][ \\t]*)sed[ \\t]+([^;&|]*[ \\t])?(-[A-Za-z]*i[^ \\t;&|]*|--in-place(=[^ \\t;&|]*)?)([ \\t;&|]|$)",
27
+ "reason": "禁止通过 sed -i 直接编辑文件。请使用 SearchReplace 工具。",
28
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过 sed -i 原地编辑文件。\n\n sed -i 直接写入文件,绕过 IDE 工具层的所有校验。\n → 请改用 SearchReplace 工具。\n"
29
+ },
30
+ {
31
+ "id": "redirect",
32
+ "regex": "[>]{1,2}\\s+\\S",
33
+ "reason": "禁止通过重定向写入文件。请使用 Write 工具。",
34
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过重定向(>/>>)写入文件。\n\n 重定向写入绕过 IDE 工具层,变更无法追踪。\n → 请改用 Write 工具。\n"
35
+ },
36
+ {
37
+ "id": "tee-dd",
38
+ "regex": "\\btee\\b|\\bdd\\b.*of=",
39
+ "reason": "禁止通过 tee/dd 写入文件。请使用 Write 或 SearchReplace 工具。",
40
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过 tee/dd 写入文件。\n\n → 请改用 Write 或 SearchReplace 工具。\n"
41
+ },
42
+ {
43
+ "id": "cp-mv-touch",
44
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(cp|mv|touch)\\b",
45
+ "reason": "禁止通过 cp/mv/touch 操作文件。请使用 Write 或 SearchReplace 工具。",
46
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过 cp/mv/touch 操作文件。\n\n → 请改用 Write 或 SearchReplace 工具。\n"
47
+ }
48
+ ],
49
+ "adapters": {
50
+ "trae": [
51
+ "script-interpreter",
52
+ "sed-in-place",
53
+ "redirect",
54
+ "tee-dd",
55
+ "cp-mv-touch"
56
+ ]
57
+ },
58
+ "adapter_detectors": [
59
+ {
60
+ "adapter": "trae",
61
+ "id": "dangerous-command",
62
+ "regex": "rm\\s+-rf\\s+/|DROP\\s+TABLE|git\\s+push\\s+--force|mkfs\\.|dd\\s+if=",
63
+ "flags": "i",
64
+ "reason": "危险命令已被阻止",
65
+ "stderr": "⛔ 危险命令已被阻止: {{cmd}}\n"
66
+ },
67
+ {
68
+ "adapter": "trae",
69
+ "id": "script-interpreter",
70
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(python3?|node|ruby|perl|php)(\\s|$)",
71
+ "reason": "禁止通过脚本解释器直接修改文件。请使用 Write 或 SearchReplace 工具操作文件。",
72
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过脚本解释器直接修改文件。\n\n python/node/ruby/perl/php 可在脚本中写入任意文件,绕过:\n · Plan 关联检查(哪个文件属于哪个 ADD Plan?)\n · doc-format-guard(章节/占位符/禁止词校验)\n · 审计追踪(agentAudit 无法感知 Bash 内部的文件变更)\n\n → 请改用 Write 或 SearchReplace 工具操作文件。\n → 如需运行构建/测试脚本,使用 npx/pnpm/npm 命令。\n"
73
+ },
74
+ {
75
+ "adapter": "trae",
76
+ "id": "sed-in-place",
77
+ "regex": "(^|[;&|]\\s*)sed\\s+([^;&|]*\\s)?(-[a-zA-Z]*i[^;&|]*|--in-place(=[^;&|]*)?)([\\s;&|]|$)",
78
+ "reason": "禁止通过 sed -i 直接编辑文件。请使用 SearchReplace 工具。",
79
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过 sed -i 原地编辑文件。\n\n sed -i 直接写入文件,绕过 IDE 工具层的所有校验。\n → 请改用 SearchReplace 工具。\n"
80
+ },
81
+ {
82
+ "adapter": "trae",
83
+ "id": "redirect",
84
+ "regex": "[>]{1,2}\\s+\\S",
85
+ "reason": "禁止通过重定向写入文件。请使用 Write 工具。",
86
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过重定向(>/>>)写入文件。\n\n 重定向写入绕过 IDE 工具层,变更无法追踪。\n → 请改用 Write 工具。\n"
87
+ },
88
+ {
89
+ "adapter": "trae",
90
+ "id": "tee-dd",
91
+ "regex": "\\btee\\b|\\bdd\\b.*of=",
92
+ "reason": "禁止通过 tee/dd 写入文件。请使用 Write 或 SearchReplace 工具。",
93
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过 tee/dd 写入文件。\n\n → 请改用 Write 或 SearchReplace 工具。\n"
94
+ },
95
+ {
96
+ "adapter": "trae",
97
+ "id": "cp-mv-touch",
98
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(cp|mv|touch)\\b",
99
+ "reason": "禁止通过 cp/mv/touch 操作文件。请使用 Write 或 SearchReplace 工具。",
100
+ "stderr": "⛔ [ADD PreToolUse §A] 阻断: 禁止通过 cp/mv/touch 操作文件。\n\n → 请改用 Write 或 SearchReplace 工具。\n"
101
+ },
102
+ {
103
+ "adapter": "claude",
104
+ "id": "dangerous-command",
105
+ "regex": "rm\\s+-rf\\s+/|DROP\\s+TABLE|git\\s+push\\s+--force|mkfs\\.|dd\\s+if=",
106
+ "flags": "i",
107
+ "reason": "危险命令已被阻止",
108
+ "stderr": "⛔ 危险命令已被阻止: {{cmd}}\n"
109
+ },
110
+ {
111
+ "adapter": "claude",
112
+ "id": "terminal-write",
113
+ "regex": "(cat|echo|tee|sed\\s+-i|awk|printf|cp|mv|dd|touch)\\s*.*([>]{1,2}|[|]\\s*tee|<<)",
114
+ "flags": "",
115
+ "reason": "禁止通过终端直接写文件",
116
+ "stderr": "⛔ 禁止通过终端命令直接写文件: {{cmd}}。请使用 Write/Edit/SearchReplace 工具。\n"
117
+ },
118
+ {
119
+ "adapter": "claude",
120
+ "id": "cp-mv-touch",
121
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(cp|mv|touch)\\b",
122
+ "flags": "",
123
+ "reason": "禁止通过 cp/mv/touch 操作文件",
124
+ "stderr": "⛔ 禁止通过 cp/mv/touch 操作文件: {{cmd}}。请使用 Write 或 SearchReplace 工具。\n"
125
+ },
126
+ {
127
+ "adapter": "claude",
128
+ "id": "script-interpreter",
129
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(python3?|node|ruby|perl|php)(\\s|$)",
130
+ "flags": "",
131
+ "reason": "禁止通过脚本解释器直接修改文件",
132
+ "stderr": "⛔ 禁止通过脚本解释器直接写文件: {{cmd}}。请使用 Write 或 SearchReplace 工具。\n"
133
+ },
134
+ {
135
+ "adapter": "qoder",
136
+ "id": "dangerous-command",
137
+ "regex": "rm\\s+-rf\\s+/|DROP\\s+TABLE|git\\s+push\\s+--force|mkfs\\.|dd\\s+if=",
138
+ "flags": "i",
139
+ "reason": "危险命令已被阻止",
140
+ "stderr": "⛔ 危险命令已被阻止: {{cmd}}\n"
141
+ },
142
+ {
143
+ "adapter": "qoder",
144
+ "id": "terminal-write",
145
+ "regex": "(cat|echo|tee|sed\\s+-i|awk|printf|cp|mv|dd|touch)\\s*.*([>]{1,2}|[|]\\s*tee|<<)",
146
+ "flags": "",
147
+ "reason": "禁止通过终端直接写文件",
148
+ "stderr": "⛔ 禁止通过终端命令直接写文件: {{cmd}}。请使用 Write/Edit/SearchReplace 工具。\n"
149
+ },
150
+ {
151
+ "adapter": "qoder",
152
+ "id": "cp-mv-touch",
153
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(cp|mv|touch)\\b",
154
+ "flags": "",
155
+ "reason": "禁止通过 cp/mv/touch 操作文件",
156
+ "stderr": "⛔ 禁止通过 cp/mv/touch 操作文件: {{cmd}}。请使用 Write 或 SearchReplace 工具。\n"
157
+ },
158
+ {
159
+ "adapter": "qoder",
160
+ "id": "script-interpreter",
161
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(python3?|node|ruby|perl|php)(\\s|$)",
162
+ "flags": "",
163
+ "reason": "禁止通过脚本解释器直接修改文件",
164
+ "stderr": "⛔ 禁止通过脚本解释器直接写文件: {{cmd}}。请使用 Write 或 SearchReplace 工具。\n"
165
+ },
166
+ {
167
+ "adapter": "codex",
168
+ "id": "dangerous-command",
169
+ "regex": "rm\\s+-rf\\s+/|DROP\\s+TABLE|git\\s+push\\s+--force|mkfs\\.|dd\\s+if=",
170
+ "flags": "i",
171
+ "reason": "危险命令已被阻止;请使用 apply_patch。"
172
+ },
173
+ {
174
+ "adapter": "codex",
175
+ "id": "script-interpreter",
176
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(python3?|node|ruby|perl|php)(\\s|$)",
177
+ "reason": "禁止通过脚本解释器直接修改文件;请使用 apply_patch。"
178
+ },
179
+ {
180
+ "adapter": "codex",
181
+ "id": "sed-in-place",
182
+ "regex": "(^|[;&|]\\s*)sed\\s+([^;&|]*\\s)?(-[a-zA-Z]*i[^;&|]*|--in-place(=[^;&|]*)?)([\\s;&|]|$)",
183
+ "reason": "禁止通过 sed -i 直接编辑文件;请使用 apply_patch。"
184
+ },
185
+ {
186
+ "adapter": "codex",
187
+ "id": "redirect",
188
+ "regex": "[>]{1,2}\\s+\\S",
189
+ "reason": "禁止通过重定向写入文件;请使用 apply_patch。"
190
+ },
191
+ {
192
+ "adapter": "codex",
193
+ "id": "tee-dd",
194
+ "regex": "\\btee\\b|\\bdd\\b.*of=",
195
+ "reason": "禁止通过 tee/dd 写入文件;请使用 apply_patch。"
196
+ },
197
+ {
198
+ "adapter": "codex",
199
+ "id": "cp-mv-touch",
200
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(cp|mv|touch)\\b",
201
+ "reason": "禁止通过 cp/mv/touch 改变文件;请使用 apply_patch。"
202
+ },
203
+ {
204
+ "adapter": "vscode",
205
+ "id": "dangerous-command",
206
+ "regex": "rm\\s+-rf\\s+/|DROP\\s+TABLE|git\\s+push\\s+--force|mkfs\\.|dd\\s+if=",
207
+ "flags": "i",
208
+ "reason": "危险命令已被阻止",
209
+ "stderr": "⛔ 危险命令已被阻止: {{cmd}}\n"
210
+ },
211
+ {
212
+ "adapter": "vscode",
213
+ "id": "terminal-write",
214
+ "regex": "(cat|echo|tee|sed\\s+-i|awk|printf|cp|mv|dd|touch)\\s*.*([>]{1,2}|[|]\\s*tee|<<)",
215
+ "flags": "",
216
+ "reason": "禁止通过终端直接写文件",
217
+ "stderr": "⛔ 禁止通过终端命令直接写文件: {{cmd}}。请使用 Write/Edit/SearchReplace 工具。\n"
218
+ },
219
+ {
220
+ "adapter": "vscode",
221
+ "id": "cp-mv-touch",
222
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(cp|mv|touch)\\b",
223
+ "flags": "",
224
+ "reason": "禁止通过 cp/mv/touch 操作文件",
225
+ "stderr": "⛔ 禁止通过 cp/mv/touch 操作文件: {{cmd}}。请使用 Write 或 SearchReplace 工具。\n"
226
+ },
227
+ {
228
+ "adapter": "vscode",
229
+ "id": "script-interpreter",
230
+ "regex": "(^|;|\\|\\||&&|\\|)\\s*(python3?|node|ruby|perl|php)(\\s|$)",
231
+ "flags": "",
232
+ "reason": "禁止通过脚本解释器直接修改文件",
233
+ "stderr": "⛔ 禁止通过脚本解释器直接写文件: {{cmd}}。请使用 Write 或 SearchReplace 工具。\n"
234
+ }
235
+ ],
236
+ "sensitive_files": {
237
+ "regex": "(^|\\/)\\.env$|(^|\\/)\\.env\\.production$|(^|\\/)\\.env\\.local$|credentials|secrets",
238
+ "deny_reason": "敏感文件受保护"
239
+ },
240
+ "template_hints": [
241
+ {
242
+ "pattern": "plan-v\\d",
243
+ "message": "💡 [ADD PreToolUse] 写入 Plan → 模板: standard-plan-template.md(标准)或 simple-plan-template.md(≤3文件)"
244
+ },
245
+ {
246
+ "pattern": "add-route",
247
+ "message": "💡 [ADD PreToolUse] 写入 ADD Route → 模板: add-route-template.md"
248
+ },
249
+ {
250
+ "pattern": "handoff",
251
+ "message": "💡 [ADD PreToolUse] 写入 Handoff → 模板: handoff-single-round-template.md(单轮)或 handoff-multi-round-template.md(多轮)"
252
+ }
253
+ ],
254
+ "thresholds": {
255
+ "large_file_bytes": 2000
256
+ },
257
+ "hitl_exemptions": {
258
+ "suffixes": [
259
+ "-handoff",
260
+ "-runtime"
261
+ ]
262
+ }
263
+ } as const;
264
+
265
+ export const doc = {
266
+ "token_rules": [
267
+ {
268
+ "template": "add-route-template-heavyweight.md",
269
+ "tokens": [
270
+ "add-route",
271
+ "heavy"
272
+ ]
273
+ },
274
+ {
275
+ "template": "add-route-template.md",
276
+ "tokens": [
277
+ "add-route"
278
+ ]
279
+ },
280
+ {
281
+ "template": "hitl-template.md",
282
+ "tokens": [
283
+ "hitl"
284
+ ]
285
+ },
286
+ {
287
+ "template": "",
288
+ "tokens": [
289
+ "handoff"
290
+ ]
291
+ },
292
+ {
293
+ "template": "checklist-template.md",
294
+ "tokens": [
295
+ "checklist"
296
+ ]
297
+ },
298
+ {
299
+ "template": "fix-verification-template.md",
300
+ "tokens": [
301
+ "fix-verif"
302
+ ]
303
+ },
304
+ {
305
+ "template": "runtime-report-template.md",
306
+ "tokens": [
307
+ "report",
308
+ "runtime"
309
+ ]
310
+ },
311
+ {
312
+ "template": "report-template.md",
313
+ "tokens": [
314
+ "report"
315
+ ]
316
+ },
317
+ {
318
+ "template": "tasks-template.md",
319
+ "tokens": [
320
+ "tasks"
321
+ ]
322
+ },
323
+ {
324
+ "template": "spec-template.md",
325
+ "tokens": [
326
+ "spec"
327
+ ]
328
+ },
329
+ {
330
+ "template": "standard-plan-template.md",
331
+ "tokens": [
332
+ "plan"
333
+ ]
334
+ }
335
+ ],
336
+ "content_rules": [
337
+ {
338
+ "marker": "## PLAN 元信息",
339
+ "template": "standard-plan-template.md"
340
+ },
341
+ {
342
+ "marker": "## 一、Plan 概述",
343
+ "template": "simple-plan-template.md"
344
+ },
345
+ {
346
+ "marker": "## 四、Handoff",
347
+ "template": "simple-plan-template.md"
348
+ },
349
+ {
350
+ "marker": "## Review 元信息",
351
+ "template": "review-template.md",
352
+ "sub_markers": [
353
+ {
354
+ "marker": "运行时验证",
355
+ "template": "review-runtime-template.md"
356
+ },
357
+ {
358
+ "marker": "跨仓库格式契约",
359
+ "template": "review-implementation-template.md"
360
+ }
361
+ ]
362
+ },
363
+ {
364
+ "marker": "## Why",
365
+ "template": "spec-template.md"
366
+ },
367
+ {
368
+ "marker": "## Preconditions",
369
+ "template": "tasks-template.md"
370
+ },
371
+ {
372
+ "marker": "审计链(证据→devlog→checklist)",
373
+ "template": "checklist-template.md"
374
+ }
375
+ ],
376
+ "adapter_content_rules": [
377
+ {
378
+ "adapter": "claude",
379
+ "marker": "## 四、Handoff",
380
+ "template": "simple-standard-plan-template.md"
381
+ },
382
+ {
383
+ "adapter": "claude",
384
+ "marker": "## PLAN 元信息",
385
+ "template": "standard-plan-template.md"
386
+ },
387
+ {
388
+ "adapter": "claude",
389
+ "marker": "## 一、Plan 概述",
390
+ "template": "simple-plan-template.md"
391
+ },
392
+ {
393
+ "adapter": "claude",
394
+ "marker": "## Review 元信息",
395
+ "template": "review-template.md",
396
+ "sub_markers": [
397
+ {
398
+ "marker": "运行时验证",
399
+ "template": "review-runtime-template.md"
400
+ },
401
+ {
402
+ "marker": "跨仓库格式契约",
403
+ "template": "review-implementation-template.md"
404
+ }
405
+ ]
406
+ },
407
+ {
408
+ "adapter": "claude",
409
+ "marker": "## Why",
410
+ "template": "spec-template.md"
411
+ },
412
+ {
413
+ "adapter": "claude",
414
+ "marker": "## Preconditions",
415
+ "template": "tasks-template.md"
416
+ },
417
+ {
418
+ "adapter": "claude",
419
+ "marker": "审计链(证据→devlog→checklist)",
420
+ "template": "checklist-template.md"
421
+ }
422
+ ],
423
+ "handoff": {
424
+ "marker_multi": "## 全局元信息",
425
+ "marker_single": "## 1. 交接前状态"
426
+ },
427
+ "fallback_rules": [
428
+ {
429
+ "template": "add-route-template-heavyweight.md",
430
+ "tokens": [
431
+ "add-route",
432
+ "heavy"
433
+ ]
434
+ },
435
+ {
436
+ "template": "add-route-template.md",
437
+ "tokens": [
438
+ "add-route"
439
+ ]
440
+ },
441
+ {
442
+ "template": "standard-plan-template.md",
443
+ "tokens": [
444
+ "plan"
445
+ ]
446
+ },
447
+ {
448
+ "template": "tasks-template.md",
449
+ "tokens": [
450
+ "tasks"
451
+ ]
452
+ },
453
+ {
454
+ "template": "spec-template.md",
455
+ "tokens": [
456
+ "spec"
457
+ ]
458
+ },
459
+ {
460
+ "template": "checklist-template.md",
461
+ "tokens": [
462
+ "checklist"
463
+ ]
464
+ },
465
+ {
466
+ "template": "runtime-report-template.md",
467
+ "tokens": [
468
+ "report",
469
+ "runtime"
470
+ ]
471
+ },
472
+ {
473
+ "template": "report-template.md",
474
+ "tokens": [
475
+ "report"
476
+ ]
477
+ },
478
+ {
479
+ "template": "fix-verification-template.md",
480
+ "tokens": [
481
+ "fix-verif"
482
+ ]
483
+ },
484
+ {
485
+ "template": "hitl-template.md",
486
+ "tokens": [
487
+ "hitl"
488
+ ]
489
+ }
490
+ ],
491
+ "incremental": {
492
+ "regex": "~~.+~~|→|\\[\\d{4}-\\d{2}-\\d{2}\\s+修订"
493
+ },
494
+ "anti_cheat": {
495
+ "max_file_count": 3,
496
+ "fuzzy_file_regex": "等\\s*\\d*\\s*个文件|等\\s*若干",
497
+ "fuzzy_decision_regex": "等\\s*若干\\s*(决策|方案|设计)",
498
+ "forbidden_heading": "## 三、架构设计"
499
+ }
500
+ } as const;
501
+
502
+ export const context = {
503
+ "quadrants": [
504
+ {
505
+ "id": "no_add_no_dev",
506
+ "consumed": false,
507
+ "text": "[ADD Stop] 无活跃 Plan,无代码改动。正常结束。"
508
+ },
509
+ {
510
+ "id": "no_add_has_dev",
511
+ "consumed": true,
512
+ "text": "[ADD Stop] ⚠️ 检测到代码修改但无活跃 ADD Plan。\n\nPlan 不是\"文档开销\"——它是代码治理的基础设施。跳过 Plan 的后果:\n · 没有 add-route → 每次改动无法追溯到具体 Task\n · 没有 tasks.md → 后续 AI Session 不知道改了哪些文件\n · 没有 handoff → 交接时上下文全丢,只能靠 git log 猜\n\n你必须立即补救,二选一:\n\n方案 A — 补 ADD 流程(招安):\n Step 0: 读 .qoder/templates/plan-template.md → 生成 Plan → .qoder/plans/{today}/{keyword}-plan-v1.md\n 生成 add-route → check_dps ≥ {{dpsPass}}\n Step 1: 扩展 AgentAuditPhase(如需要)\n Step 2: 确认 agentAudit() 通道\n Step 3: 将已写代码关联到 tasks.md\n 完成后可正常停止。\n\n方案 B — 补不上则回滚:\n 如果改动太复杂无法追溯生成 Plan,则:\n ① git diff 确认改动范围\n ② 仅对已确认属于本轮的文件生成反向 apply_patch\n ③ 无法安全确认改动所有权时停止,并请求用户决定\n\n无论选 A 还是 B,完成后告诉用户下次执行 session-init 恢复上下文。\n"
513
+ },
514
+ {
515
+ "id": "has_add_no_dev",
516
+ "consumed": false,
517
+ "text": "[ADD Stop] ADD 流程进行中 ({{info}}),本次无代码改动。下次继续时执行 session-init 恢复上下文。"
518
+ },
519
+ {
520
+ "id": "has_add_dev_step02",
521
+ "consumed": false,
522
+ "text": "[ADD Stop] ADD Step 0-2: 文档先行/审计准备阶段。无需验收闭环。下一步: 进入 Step 3 代码实现。"
523
+ },
524
+ {
525
+ "id": "has_add_dev_step3",
526
+ "consumed": false,
527
+ "text": "[ADD Stop] ADD Step 3: 代码实现进行中 ({{info}})。完成后进入 Step 3.5 实现审查。"
528
+ },
529
+ {
530
+ "id": "has_add_dev_unclosed",
531
+ "consumed": true,
532
+ "text": "[ADD Stop] ⚠️ 代码已完成但验收未闭环:\n{{info}}\n\n请依次执行(不要等下次会话):\n ① Write devlog → handoff 同目录 devlog-{plan}-v{n}.md\n 格式: # Devlog: {plan}\\n 日期 / Plan / 轮次 / 本轮改了什么 / 验收结果 / 遗留项 / 架构回看\n ② Edit handoff → 更新 §验证标准 全部 [x] + 补充审计 ID\n ★ 同步: checklist 有新 cuid → handoff ADD-7 表必须对应新增行\n ★ Step 0 准入: handoff + add-route + Specs 三元组缺一不可,缺则回退 Step 0.5\n ③ Read docs/ → 回看架构文档确认一致性\n ④ Edit add-route → 勾选对应 Step [x]\n\n以上全部完成后 Agent 才能停止。\n\n下次恢复: 读 handoff → 查同目录 devlog-*.md → query_audit_logs\n"
533
+ },
534
+ {
535
+ "id": "has_add_dev_closed",
536
+ "consumed": false,
537
+ "text": "[ADD Stop] ✅ 验收闭环: add-route全部[x], devlog已记录, handoff已更新。验收幂等——重复触发不覆盖已有结论。"
538
+ }
539
+ ],
540
+ "adapter_quadrants": [
541
+ {
542
+ "adapter": "qoder",
543
+ "id": "has_add_dev_unclosed",
544
+ "text": "[ADD Stop] ⚠️ 代码已完成但验收未闭环:\n{{info}}\n\n请依次执行(不要等下次会话):\n ① Write devlog → handoff 同目录 devlog-{plan}-v{n}.md\n 格式: # Devlog: {plan}\\n 日期 / Plan / 轮次 / 本轮改了什么 / 验收结果 / 遗留项 / 架构回看\n ② Edit handoff → 更新 §验证标准 全部 [x] + 补充审计 ID\n ★ 同步: checklist 有新 cuid → handoff ADD-7 表必须对应新增行\n ★ Step 0 准入: handoff + add-route + Specs 三元组缺一不可,缺则回退 Step 0.5\n ③ Read docs/ → 回看架构文档确认一致性\n ④ Edit add-route → 勾选对应 Step [x]\n\n以上全部完成后 Agent 才能停止。\n\n下次恢复: 读 handoff → 查同目录 devlog-*.md → query_audit_logs\n"
545
+ }
546
+ ],
547
+ "templates": {
548
+ "priority_order": [
549
+ "simple-plan-template.md",
550
+ "spec-template.md",
551
+ "tasks-template.md",
552
+ "checklist-template.md",
553
+ "review-template.md",
554
+ "standard-plan-template.md",
555
+ "add-route-template-heavyweight.md",
556
+ "add-route-template.md",
557
+ "handoff-single-round-template.md",
558
+ "handoff-multi-round-template.md"
559
+ ],
560
+ "descriptions": {
561
+ "simple-plan-template.md": "需求方案(简单版):六节结构,元信息+背景+方案+架构+实施+验收",
562
+ "spec-template.md": "功能规格:Why/What Changes/Impact/WHEN-THEN Requirements",
563
+ "tasks-template.md": "任务拆分:Phase→Task→SubTask层级",
564
+ "checklist-template.md": "验收清单:[T]编译期+[R]运行时+ADD规则合规",
565
+ "review-template.md": "方案审查(ADD-9):问题复现+方案对比+决策结论+影响评估",
566
+ "standard-plan-template.md": "需求方案(标准版):PLAN元信息+背景+方案+架构+实施Task+验收+关联文档",
567
+ "add-route-template-heavyweight.md": "ADD执行路线图(重型):每Step验证并更新状态+spec_sync交叉校验",
568
+ "add-route-template.md": "ADD执行路线图(轻量):标准Step产出检查",
569
+ "handoff-single-round-template.md": "单轮交接:9章节(含恢复上下文审计查询)",
570
+ "handoff-multi-round-template.md": "多轮交接:全局拓扑+每轮13子章节+收敛规则+启动模板"
571
+ }
572
+ },
573
+ "pretool": {
574
+ "text": "[ADD PreToolUse] 当前 Plan: {{plan}},轮次: {{round}}。\n本次写入应属于 ADD Step 3 代码实现阶段。\n完成后执行 record_dev_operation 记录审计。"
575
+ }
576
+ } as const;
577
+
578
+ export const event = {
579
+ "file": {
580
+ "path": "{magicDir}/reports/hook-events.jsonl",
581
+ "rotate_bytes": 262144,
582
+ "total_bytes": 524288,
583
+ "note": "MCP Server 宕机不丢事件,重启后从文件恢复消费"
584
+ },
585
+ "schema": {
586
+ "fields": [
587
+ "ts",
588
+ "hook",
589
+ "decision",
590
+ "cmd",
591
+ "reason",
592
+ "planKeyword",
593
+ "planStatus"
594
+ ],
595
+ "ts_format": "date -u +%Y-%m-%dT%H:%M:%SZ",
596
+ "extra_fields": [
597
+ "anchor_hit",
598
+ "struct_score",
599
+ "override"
600
+ ]
601
+ },
602
+ "daily": {
603
+ "warn_threshold": 10
604
+ }
605
+ } as const;
606
+
607
+ export const protocol = {
608
+ "exit_codes": {
609
+ "pass": 0,
610
+ "block": 2,
611
+ "note": "冒烟校验: 产物退出码 ∈ {0,2}(其余为非预期,需修复)"
612
+ },
613
+ "output": {
614
+ "stdout_json_only": true,
615
+ "stderr_human_text": true,
616
+ "field_separator": "::",
617
+ "magic_dir_resolution": "注入优先 → 物理位置推导 → failClosed(禁止猜测 adapter 名)"
618
+ },
619
+ "adapters": {
620
+ "claude": {
621
+ "stdout_form": "plain-text",
622
+ "project_dir_env": "CLAUDE_PROJECT_DIR",
623
+ "magic_dir": ".claude",
624
+ "handlerTypes": [
625
+ "command",
626
+ "mcp_tool"
627
+ ]
628
+ },
629
+ "qoder": {
630
+ "stdout_form": "json",
631
+ "project_dir_env": "QODER_PROJECT_DIR",
632
+ "magic_dir": ".qoder",
633
+ "handlerTypes": [
634
+ "command",
635
+ "http"
636
+ ]
637
+ },
638
+ "codex": {
639
+ "stdout_form": "systemMessage",
640
+ "project_dir_env": "git-toplevel",
641
+ "magic_dir": ".codex",
642
+ "handlerTypes": [
643
+ "command"
644
+ ]
645
+ },
646
+ "vscode": {
647
+ "stdout_form": "plain-text",
648
+ "project_dir_env": "PWD",
649
+ "magic_dir": ".vscode",
650
+ "handlerTypes": [
651
+ "command"
652
+ ]
653
+ },
654
+ "trae": {
655
+ "stdout_form": "plain-text",
656
+ "project_dir_env": "PWD",
657
+ "magic_dir": ".trae",
658
+ "handlerTypes": [
659
+ "command"
660
+ ]
661
+ }
662
+ },
663
+ "event_outputs": {
664
+ "qoder": {
665
+ "SessionStart": "additionalContext",
666
+ "UserPromptSubmit": "additionalContext",
667
+ "PreToolUse": "permissionDecision",
668
+ "Stop": "additionalContext",
669
+ "PostToolUse": "feedback",
670
+ "SubagentStart": "additionalContext",
671
+ "SubagentStop": "additionalContext",
672
+ "PostToolUseFailure": "text",
673
+ "PermissionRequest": "text",
674
+ "SessionEnd": "text",
675
+ "PreCompact": "text",
676
+ "Notification": "text"
677
+ },
678
+ "claude": {
679
+ "SessionStart": "additionalContext",
680
+ "UserPromptSubmit": "additionalContext",
681
+ "PreToolUse": "permissionDecision",
682
+ "Stop": "text",
683
+ "PostToolUse": "feedback",
684
+ "SubagentStart": "text",
685
+ "SubagentStop": "text",
686
+ "PostToolUseFailure": "text",
687
+ "PermissionRequest": "text",
688
+ "SessionEnd": "text",
689
+ "PreCompact": "text",
690
+ "Notification": "text"
691
+ },
692
+ "codex": {
693
+ "Stop": "systemMessage",
694
+ "PostToolUse": "text"
695
+ },
696
+ "vscode": {
697
+ "PostToolUse": "text"
698
+ },
699
+ "trae": {
700
+ "PostToolUse": "text"
701
+ }
702
+ },
703
+ "core": {
704
+ "stdout_form": "json",
705
+ "magic_dir": ".add",
706
+ "note": "core 入口协议 = qoder 同构参考实现;adapter 仅保留本表声明的私有差异"
707
+ },
708
+ "adapter_defaults": {
709
+ "magic_dir_fallback": ".qoder",
710
+ "probe_magic_dirs": [
711
+ ".claude",
712
+ ".qoder",
713
+ ".vscode",
714
+ ".add",
715
+ ".trae",
716
+ ".codex"
717
+ ]
718
+ }
719
+ } as const;
720
+ // ── GENERATED END ──