agentic-flow-kit 1.8.7 → 2.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 (936) hide show
  1. package/README.md +113 -148
  2. package/bin/flow-kit.mjs +5 -2
  3. package/locales/en/installer.json +25 -0
  4. package/locales/en/overrides/.agents/commands/deploy.md +52 -0
  5. package/locales/en/overrides/.agents/commands/maintain.md +76 -0
  6. package/locales/en/overrides/.agents/commands/new-task.md +89 -0
  7. package/locales/en/overrides/.agents/commands/pipeline-run.md +56 -0
  8. package/locales/en/overrides/.agents/commands/pr-review.md +30 -0
  9. package/locales/en/overrides/.agents/commands/review.md +93 -0
  10. package/locales/en/overrides/.agents/commands/stages.md +256 -0
  11. package/locales/en/overrides/.agents/notes/pr-review-cost-discipline.md +48 -0
  12. package/locales/en/overrides/.agents/notes/process-order-rule.md +21 -0
  13. package/locales/en/overrides/.agents/notes/runtime-env.local.example.md +21 -0
  14. package/locales/en/overrides/.agents/pipelines/_TEMPLATE.md +75 -0
  15. package/locales/en/overrides/.agents/pipelines/pipeline-closing.md +28 -0
  16. package/locales/en/overrides/.agents/roles/implementer.md +28 -0
  17. package/locales/en/overrides/.agents/roles/independent-reviewer.md +39 -0
  18. package/locales/en/overrides/.agents/roles/pr-adjudicator.md +27 -0
  19. package/locales/en/overrides/.agents/roles/pr-finder.md +51 -0
  20. package/locales/en/overrides/.agents/roles/pr-verifier.md +44 -0
  21. package/locales/en/overrides/.agents/roles/ui-verifier.md +22 -0
  22. package/locales/en/overrides/.agents/roles/wiki-compiler.md +47 -0
  23. package/locales/en/overrides/.agents/skills/arena/SKILL.md +50 -0
  24. package/locales/en/overrides/.agents/skills/autonomous-run/SKILL.md +45 -0
  25. package/locales/en/overrides/.agents/skills/blast-radius/SKILL.md +53 -0
  26. package/locales/en/overrides/.agents/skills/csharp-quality-gates/SKILL.md +109 -0
  27. package/locales/en/overrides/.agents/skills/dev-tour/SKILL.md +98 -0
  28. package/locales/en/overrides/.agents/skills/dream/SKILL.md +63 -0
  29. package/locales/en/overrides/.agents/skills/eval/SKILL.md +42 -0
  30. package/locales/en/overrides/.agents/skills/interrogate/SKILL.md +49 -0
  31. package/locales/en/overrides/.agents/skills/number-vetting/SKILL.md +35 -0
  32. package/locales/en/overrides/.agents/skills/page-refactor/SKILL.md +192 -0
  33. package/locales/en/overrides/.agents/skills/papercut-fix/SKILL.md +92 -0
  34. package/locales/en/overrides/.agents/skills/pause-safely/SKILL.md +31 -0
  35. package/locales/en/overrides/.agents/skills/perf/SKILL.md +42 -0
  36. package/locales/en/overrides/.agents/skills/review-method/SKILL.md +92 -0
  37. package/locales/en/overrides/.agents/skills/session-resume/SKILL.md +69 -0
  38. package/locales/en/overrides/.agents/skills/shipyard-workflow-closeout/SKILL.md +109 -0
  39. package/locales/en/overrides/.agents/skills/show-me-your-work/SKILL.md +57 -0
  40. package/locales/en/overrides/.agents/skills/tfs-pr/SKILL.md +95 -0
  41. package/locales/en/overrides/.agents/skills/verify-ui/SKILL.md +116 -0
  42. package/locales/en/overrides/.agents/skills/visual-parity/SKILL.md +35 -0
  43. package/locales/en/overrides/.agents/skills/why/SKILL.md +56 -0
  44. package/locales/en/overrides/.agents/skills/wiki/SKILL.md +53 -0
  45. package/locales/en/overrides/.claude/agents/implementer.md +9 -0
  46. package/locales/en/overrides/.claude/agents/independent-reviewer.md +10 -0
  47. package/locales/en/overrides/.claude/agents/pr-adjudicator.md +10 -0
  48. package/locales/en/overrides/.claude/agents/pr-finder.md +10 -0
  49. package/locales/en/overrides/.claude/agents/pr-verifier.md +10 -0
  50. package/locales/en/overrides/.claude/agents/ui-verifier.md +10 -0
  51. package/locales/en/overrides/.claude/agents/wiki-compiler.md +10 -0
  52. package/locales/en/overrides/.claude/commands/wf-deploy.md +8 -0
  53. package/locales/en/overrides/.claude/commands/wf-maintain.md +8 -0
  54. package/locales/en/overrides/.claude/commands/wf-new-task.md +8 -0
  55. package/locales/en/overrides/.claude/commands/wf-pipeline-run.md +8 -0
  56. package/locales/en/overrides/.claude/commands/wf-pr-review.md +8 -0
  57. package/locales/en/overrides/.claude/commands/wf-review.md +8 -0
  58. package/locales/en/overrides/.claude/commands/wf-stages.md +8 -0
  59. package/locales/en/overrides/.cline/agents/implementer.yml +13 -0
  60. package/locales/en/overrides/.cline/agents/independent-reviewer.yml +11 -0
  61. package/locales/en/overrides/.cline/agents/pr-adjudicator.yml +11 -0
  62. package/locales/en/overrides/.cline/agents/pr-finder.yml +11 -0
  63. package/locales/en/overrides/.cline/agents/pr-verifier.yml +11 -0
  64. package/locales/en/overrides/.cline/agents/ui-verifier.yml +8 -0
  65. package/locales/en/overrides/.cline/agents/wiki-compiler.yml +14 -0
  66. package/locales/en/overrides/.cline/workflows/wf-deploy.md +8 -0
  67. package/locales/en/overrides/.cline/workflows/wf-maintain.md +8 -0
  68. package/locales/en/overrides/.cline/workflows/wf-new-task.md +8 -0
  69. package/locales/en/overrides/.cline/workflows/wf-pipeline-run.md +8 -0
  70. package/locales/en/overrides/.cline/workflows/wf-pr-review.md +8 -0
  71. package/locales/en/overrides/.cline/workflows/wf-review.md +8 -0
  72. package/locales/en/overrides/.cline/workflows/wf-stages.md +8 -0
  73. package/locales/en/overrides/.codebuddy/CODEBUDDY.md +7 -0
  74. package/locales/en/overrides/.codebuddy/agents/implementer.md +9 -0
  75. package/locales/en/overrides/.codebuddy/agents/independent-reviewer.md +10 -0
  76. package/locales/en/overrides/.codebuddy/agents/pr-adjudicator.md +10 -0
  77. package/locales/en/overrides/.codebuddy/agents/pr-finder.md +10 -0
  78. package/locales/en/overrides/.codebuddy/agents/pr-verifier.md +10 -0
  79. package/locales/en/overrides/.codebuddy/agents/ui-verifier.md +11 -0
  80. package/locales/en/overrides/.codebuddy/agents/wiki-compiler.md +10 -0
  81. package/locales/en/overrides/.codebuddy/commands/wf-deploy.md +8 -0
  82. package/locales/en/overrides/.codebuddy/commands/wf-maintain.md +8 -0
  83. package/locales/en/overrides/.codebuddy/commands/wf-new-task.md +8 -0
  84. package/locales/en/overrides/.codebuddy/commands/wf-pipeline-run.md +8 -0
  85. package/locales/en/overrides/.codebuddy/commands/wf-pr-review.md +8 -0
  86. package/locales/en/overrides/.codebuddy/commands/wf-review.md +8 -0
  87. package/locales/en/overrides/.codebuddy/commands/wf-stages.md +8 -0
  88. package/locales/en/overrides/.codebuddy/rules/backend-scope.md +5 -0
  89. package/locales/en/overrides/.codebuddy/rules/frontend-scope.md +5 -0
  90. package/locales/en/overrides/.codebuddy/skills/tfs-pr/SKILL.md +6 -0
  91. package/locales/en/overrides/.commandcode/agents/implementer.md +10 -0
  92. package/locales/en/overrides/.commandcode/agents/independent-reviewer.md +9 -0
  93. package/locales/en/overrides/.commandcode/agents/pr-adjudicator.md +9 -0
  94. package/locales/en/overrides/.commandcode/agents/pr-finder.md +9 -0
  95. package/locales/en/overrides/.commandcode/agents/pr-verifier.md +9 -0
  96. package/locales/en/overrides/.commandcode/agents/ui-verifier.md +10 -0
  97. package/locales/en/overrides/.commandcode/agents/wiki-compiler.md +10 -0
  98. package/locales/en/overrides/.commandcode/commands/wf-deploy.md +7 -0
  99. package/locales/en/overrides/.commandcode/commands/wf-maintain.md +7 -0
  100. package/locales/en/overrides/.commandcode/commands/wf-new-task.md +7 -0
  101. package/locales/en/overrides/.commandcode/commands/wf-pipeline-run.md +7 -0
  102. package/locales/en/overrides/.commandcode/commands/wf-pr-review.md +7 -0
  103. package/locales/en/overrides/.commandcode/commands/wf-review.md +7 -0
  104. package/locales/en/overrides/.commandcode/commands/wf-stages.md +7 -0
  105. package/locales/en/overrides/.opencode/agents/implementer.md +51 -0
  106. package/locales/en/overrides/.opencode/agents/independent-reviewer.md +18 -0
  107. package/locales/en/overrides/.opencode/agents/pr-adjudicator.md +18 -0
  108. package/locales/en/overrides/.opencode/agents/pr-finder.md +18 -0
  109. package/locales/en/overrides/.opencode/agents/pr-verifier.md +18 -0
  110. package/locales/en/overrides/.opencode/agents/ui-verifier.md +45 -0
  111. package/locales/en/overrides/.opencode/agents/wiki-compiler.md +51 -0
  112. package/locales/en/overrides/.opencode/commands/wf-deploy.md +7 -0
  113. package/locales/en/overrides/.opencode/commands/wf-maintain.md +7 -0
  114. package/locales/en/overrides/.opencode/commands/wf-new-task.md +7 -0
  115. package/locales/en/overrides/.opencode/commands/wf-pipeline-run.md +7 -0
  116. package/locales/en/overrides/.opencode/commands/wf-pr-review.md +7 -0
  117. package/locales/en/overrides/.opencode/commands/wf-review.md +7 -0
  118. package/locales/en/overrides/.opencode/commands/wf-stages.md +7 -0
  119. package/locales/en/overrides/.pi/agents/implementer.md +11 -0
  120. package/locales/en/overrides/.pi/agents/independent-reviewer.md +12 -0
  121. package/locales/en/overrides/.pi/agents/pr-adjudicator.md +12 -0
  122. package/locales/en/overrides/.pi/agents/pr-finder.md +11 -0
  123. package/locales/en/overrides/.pi/agents/pr-verifier.md +11 -0
  124. package/locales/en/overrides/.pi/agents/ui-verifier.md +11 -0
  125. package/locales/en/overrides/.pi/agents/wiki-compiler.md +11 -0
  126. package/locales/en/overrides/.qoder/agents/implementer.md +9 -0
  127. package/locales/en/overrides/.qoder/agents/independent-reviewer.md +10 -0
  128. package/locales/en/overrides/.qoder/agents/pr-adjudicator.md +10 -0
  129. package/locales/en/overrides/.qoder/agents/pr-finder.md +10 -0
  130. package/locales/en/overrides/.qoder/agents/pr-verifier.md +10 -0
  131. package/locales/en/overrides/.qoder/agents/ui-verifier.md +10 -0
  132. package/locales/en/overrides/.qoder/agents/wiki-compiler.md +10 -0
  133. package/locales/en/overrides/.qoder/commands/wf-deploy.md +8 -0
  134. package/locales/en/overrides/.qoder/commands/wf-maintain.md +8 -0
  135. package/locales/en/overrides/.qoder/commands/wf-new-task.md +8 -0
  136. package/locales/en/overrides/.qoder/commands/wf-pipeline-run.md +8 -0
  137. package/locales/en/overrides/.qoder/commands/wf-pr-review.md +8 -0
  138. package/locales/en/overrides/.qoder/commands/wf-review.md +8 -0
  139. package/locales/en/overrides/.qoder/commands/wf-stages.md +8 -0
  140. package/locales/en/overrides/.qwen/agents/implementer.md +10 -0
  141. package/locales/en/overrides/.qwen/agents/independent-reviewer.md +10 -0
  142. package/locales/en/overrides/.qwen/agents/pr-adjudicator.md +10 -0
  143. package/locales/en/overrides/.qwen/agents/pr-finder.md +10 -0
  144. package/locales/en/overrides/.qwen/agents/pr-verifier.md +10 -0
  145. package/locales/en/overrides/.qwen/agents/ui-verifier.md +10 -0
  146. package/locales/en/overrides/.qwen/agents/wiki-compiler.md +13 -0
  147. package/locales/en/overrides/.qwen/commands/wf-deploy.md +7 -0
  148. package/locales/en/overrides/.qwen/commands/wf-maintain.md +7 -0
  149. package/locales/en/overrides/.qwen/commands/wf-new-task.md +7 -0
  150. package/locales/en/overrides/.qwen/commands/wf-pipeline-run.md +7 -0
  151. package/locales/en/overrides/.qwen/commands/wf-pr-review.md +7 -0
  152. package/locales/en/overrides/.qwen/commands/wf-review.md +7 -0
  153. package/locales/en/overrides/.qwen/commands/wf-stages.md +7 -0
  154. package/locales/en/overrides/.trae/agents/implementer.md +9 -0
  155. package/locales/en/overrides/.trae/agents/independent-reviewer.md +10 -0
  156. package/locales/en/overrides/.trae/agents/pr-adjudicator.md +10 -0
  157. package/locales/en/overrides/.trae/agents/pr-finder.md +10 -0
  158. package/locales/en/overrides/.trae/agents/pr-verifier.md +10 -0
  159. package/locales/en/overrides/.trae/agents/ui-verifier.md +10 -0
  160. package/locales/en/overrides/.trae/agents/wiki-compiler.md +10 -0
  161. package/locales/en/overrides/.trae/commands/wf-deploy.md +8 -0
  162. package/locales/en/overrides/.trae/commands/wf-maintain.md +8 -0
  163. package/locales/en/overrides/.trae/commands/wf-new-task.md +8 -0
  164. package/locales/en/overrides/.trae/commands/wf-pipeline-run.md +8 -0
  165. package/locales/en/overrides/.trae/commands/wf-pr-review.md +8 -0
  166. package/locales/en/overrides/.trae/commands/wf-review.md +8 -0
  167. package/locales/en/overrides/.trae/commands/wf-stages.md +8 -0
  168. package/locales/en/overrides/.trae/rules/backend-scope.md +5 -0
  169. package/locales/en/overrides/.trae/rules/frontend-scope.md +5 -0
  170. package/locales/en/overrides/.zcode/agents/implementer.md +8 -0
  171. package/locales/en/overrides/.zcode/agents/independent-reviewer.md +8 -0
  172. package/locales/en/overrides/.zcode/agents/ui-verifier.md +8 -0
  173. package/locales/en/overrides/.zcode/agents/wiki-compiler.md +8 -0
  174. package/locales/en/overrides/AGENTS.md +52 -0
  175. package/locales/en/overrides/CLAUDE.md +20 -0
  176. package/locales/en/overrides/wiki/INDEX.md +33 -0
  177. package/locales/en/overrides/wiki/drafts-archive/README.md +6 -0
  178. package/locales/en/overrides/wiki//346/225/260/346/215/256/347/273/264/346/212/244/README.md +22 -0
  179. package/locales/en/overrides/wiki//347/237/245/350/257/206/346/262/211/346/267/200/346/200/273/350/247/210.html +230 -0
  180. package/locales/en/overrides/workflow/INDEX.md +13 -0
  181. package/locales/en/overrides/workflow/README.md +67 -0
  182. package/locales/en/overrides/workflow/archive/README.md +3 -0
  183. package/locales/en/overrides/workflow/delegations.md +4 -0
  184. package/locales/en/overrides/workflow/effective-policy.md +4 -0
  185. package/locales/en/overrides/workflow/gate-cost.md +4 -0
  186. package/locales/en/overrides/workflow/incidents/_TEMPLATE.md +49 -0
  187. package/locales/en/overrides/workflow/intents/_TEMPLATE.md +43 -0
  188. package/locales/en/overrides/workflow/metrics.md +4 -0
  189. package/locales/en/overrides/workflow/papercuts.md +3 -0
  190. package/locales/en/overrides/workflow/plans/_TEMPLATE.md +47 -0
  191. package/locales/en/overrides/workflow/regression-checklist.md +3 -0
  192. package/locales/en/overrides/workflow/specs/_TEMPLATE.md +86 -0
  193. package/locales/en/overrides/workflow/verify-evidence.md +4 -0
  194. package/locales/zh-CN/installer.json +25 -0
  195. package/package.json +23 -36
  196. package/schemas/install-manifest.schema.json +24 -0
  197. package/schemas/project-profile.schema.json +28 -0
  198. package/src/cli/args.mjs +41 -0
  199. package/src/cli/main.mjs +72 -0
  200. package/src/commands/add-host.mjs +29 -0
  201. package/src/commands/doctor.mjs +80 -0
  202. package/src/commands/install.mjs +149 -0
  203. package/src/commands/upgrade.mjs +30 -0
  204. package/src/git/config.mjs +61 -0
  205. package/src/hosts/registry.mjs +26 -0
  206. package/src/i18n.mjs +32 -0
  207. package/src/install/apply.mjs +124 -0
  208. package/src/install/manifest.mjs +40 -0
  209. package/src/install/plan.mjs +83 -0
  210. package/src/render/tokens.mjs +58 -0
  211. package/templates/engine/.agents/board/dev-tour.html +1940 -0
  212. package/templates/engine/.agents/board/index.html +835 -0
  213. package/templates/engine/.agents/commands/deploy.md +52 -0
  214. package/templates/engine/.agents/commands/maintain.md +76 -0
  215. package/templates/engine/.agents/commands/new-task.md +89 -0
  216. package/templates/engine/.agents/commands/pipeline-run.md +56 -0
  217. package/templates/engine/.agents/commands/pr-review.md +30 -0
  218. package/templates/engine/.agents/commands/review.md +93 -0
  219. package/templates/engine/.agents/commands/stages.md +256 -0
  220. package/templates/engine/.agents/config/commit-msg-rules.json +7 -0
  221. package/templates/engine/.agents/config/engine.json +11 -0
  222. package/templates/engine/.agents/config/gate-budgets.json +5 -0
  223. package/templates/engine/.agents/config/mechanism-registry.md +62 -0
  224. package/templates/engine/.agents/config/model-roles.json +26 -0
  225. package/templates/engine/.agents/config/model-roles.local.example.json +7 -0
  226. package/templates/engine/.agents/config/pr-review.json +67 -0
  227. package/templates/engine/.agents/config/principles.md +32 -0
  228. package/templates/engine/.agents/config/workflow-enums.txt +25 -0
  229. package/templates/engine/.agents/hooks/check-architecture.mjs +168 -0
  230. package/templates/engine/.agents/hooks/check-audit-fields.mjs +56 -0
  231. package/templates/engine/.agents/hooks/check-commit-plan-ref.mjs +84 -0
  232. package/templates/engine/.agents/hooks/check-confirm-order.mjs +281 -0
  233. package/templates/engine/.agents/hooks/check-delete-guard.mjs +63 -0
  234. package/templates/engine/.agents/hooks/check-notify-guard.mjs +55 -0
  235. package/templates/engine/.agents/hooks/commit-check.cjs +208 -0
  236. package/templates/engine/.agents/hooks/gates.json +33 -0
  237. package/templates/engine/.agents/hooks/local-pre-commit.mjs +27 -0
  238. package/templates/engine/.agents/hooks/pre-shell-check.cjs +361 -0
  239. package/templates/engine/.agents/hooks/pre-write-check.cjs +220 -0
  240. package/templates/engine/.agents/notes/gate-diet.md +75 -0
  241. package/templates/engine/.agents/notes/pr-review-cost-discipline.md +48 -0
  242. package/templates/engine/.agents/notes/process-order-rule.md +21 -0
  243. package/templates/engine/.agents/notes/runtime-env.local.example.md +21 -0
  244. package/templates/engine/.agents/pipelines/_TEMPLATE.md +75 -0
  245. package/templates/engine/.agents/pipelines/pipeline-closing.md +28 -0
  246. package/templates/engine/.agents/pipelines//347/244/272/344/276/213-/345/271/266/350/241/214/345/256/236/347/216/260/350/257/204/345/256/241.md +16 -0
  247. package/templates/engine/.agents/roles/implementer.md +28 -0
  248. package/templates/engine/.agents/roles/independent-reviewer.md +39 -0
  249. package/templates/engine/.agents/roles/pr-adjudicator.md +27 -0
  250. package/templates/engine/.agents/roles/pr-finder.md +51 -0
  251. package/templates/engine/.agents/roles/pr-verifier.md +44 -0
  252. package/templates/engine/.agents/roles/ui-verifier.md +22 -0
  253. package/templates/engine/.agents/roles/wiki-compiler.md +47 -0
  254. package/templates/engine/.agents/scripts/agg-delegations.mjs +439 -0
  255. package/templates/engine/.agents/scripts/agg-judgments.mjs +301 -0
  256. package/templates/engine/.agents/scripts/agg-kb-usage.mjs +196 -0
  257. package/templates/engine/.agents/scripts/append-compensation.mjs +109 -0
  258. package/templates/engine/.agents/scripts/archive-sweep.mjs +229 -0
  259. package/templates/engine/.agents/scripts/auto-tour.mjs +77 -0
  260. package/templates/engine/.agents/scripts/board-port.mjs +17 -0
  261. package/templates/engine/.agents/scripts/check-doc-body-drift.mjs +102 -0
  262. package/templates/engine/.agents/scripts/check-engine-artifacts.mjs +54 -0
  263. package/templates/engine/.agents/scripts/check-hook-wiring.mjs +75 -0
  264. package/templates/engine/.agents/scripts/check-lane-surface.mjs +393 -0
  265. package/templates/engine/.agents/scripts/check-ledger-doc-presence.mjs +71 -0
  266. package/templates/engine/.agents/scripts/check-ledger-invariant.mjs +873 -0
  267. package/templates/engine/.agents/scripts/check-local-gate-config.mjs +95 -0
  268. package/templates/engine/.agents/scripts/check-local-gates.mjs +248 -0
  269. package/templates/engine/.agents/scripts/check-loop-kit.mjs +550 -0
  270. package/templates/engine/.agents/scripts/check-loop-rev-semantics.mjs +59 -0
  271. package/templates/engine/.agents/scripts/check-loop-sections/s01-pairing.mjs +116 -0
  272. package/templates/engine/.agents/scripts/check-loop-sections/s03x-regr-evidence.mjs +38 -0
  273. package/templates/engine/.agents/scripts/check-loop-sections/s08-acceptance.mjs +130 -0
  274. package/templates/engine/.agents/scripts/check-loop-sections/s15-fingerprint.mjs +152 -0
  275. package/templates/engine/.agents/scripts/check-loop-sections/s23-convergence-audit.mjs +182 -0
  276. package/templates/engine/.agents/scripts/check-loop-sections/s29-regr-enforcer.mjs +69 -0
  277. package/templates/engine/.agents/scripts/check-loop.mjs +131 -0
  278. package/templates/engine/.agents/scripts/check-regression-consistency.mjs +252 -0
  279. package/templates/engine/.agents/scripts/check-schema-residue.mjs +144 -0
  280. package/templates/engine/.agents/scripts/check-scope-range.mjs +156 -0
  281. package/templates/engine/.agents/scripts/check-scope.mjs +121 -0
  282. package/templates/engine/.agents/scripts/check-scripts-syntax.mjs +138 -0
  283. package/templates/engine/.agents/scripts/check-secrets-lite.mjs +239 -0
  284. package/templates/engine/.agents/scripts/check-secrets.mjs +104 -0
  285. package/templates/engine/.agents/scripts/check-test-impact-map.mjs +107 -0
  286. package/templates/engine/.agents/scripts/ci-assert-frontend-deps.mjs +42 -0
  287. package/templates/engine/.agents/scripts/ci-commit-hygiene.mjs +86 -0
  288. package/templates/engine/.agents/scripts/ci-install-gitleaks.mjs +75 -0
  289. package/templates/engine/.agents/scripts/ci-push-before.mjs +49 -0
  290. package/templates/engine/.agents/scripts/closeout.mjs +127 -0
  291. package/templates/engine/.agents/scripts/compact-ledgers.mjs +70 -0
  292. package/templates/engine/.agents/scripts/confirm-doc.mjs +737 -0
  293. package/templates/engine/.agents/scripts/delegation-presence.mjs +38 -0
  294. package/templates/engine/.agents/scripts/dev-tour-model.mjs +1398 -0
  295. package/templates/engine/.agents/scripts/dream-run.mjs +283 -0
  296. package/templates/engine/.agents/scripts/ensure-board.mjs +187 -0
  297. package/templates/engine/.agents/scripts/failure-attribution.mjs +11 -0
  298. package/templates/engine/.agents/scripts/fill-intent.mjs +60 -0
  299. package/templates/engine/.agents/scripts/fill-plan.mjs +105 -0
  300. package/templates/engine/.agents/scripts/fill-spec.mjs +72 -0
  301. package/templates/engine/.agents/scripts/gen-dev-tour.mjs +191 -0
  302. package/templates/engine/.agents/scripts/gen-effective-policy.mjs +113 -0
  303. package/templates/engine/.agents/scripts/gen-engine-map.mjs +292 -0
  304. package/templates/engine/.agents/scripts/gen-narrative-claims.mjs +275 -0
  305. package/templates/engine/.agents/scripts/gen-verify-evidence.mjs +115 -0
  306. package/templates/engine/.agents/scripts/gen-wiki-board.mjs +221 -0
  307. package/templates/engine/.agents/scripts/gen-workflow-index.mjs +201 -0
  308. package/templates/engine/.agents/scripts/gen-workflow-metrics.mjs +692 -0
  309. package/templates/engine/.agents/scripts/git-merge-jsonl.mjs +62 -0
  310. package/templates/engine/.agents/scripts/judgment-ledger.mjs +68 -0
  311. package/templates/engine/.agents/scripts/kb-cache-evict.mjs +50 -0
  312. package/templates/engine/.agents/scripts/kb-search.mjs +423 -0
  313. package/templates/engine/.agents/scripts/lane-surface-audit.mjs +145 -0
  314. package/templates/engine/.agents/scripts/ledger-loader.mjs +77 -0
  315. package/templates/engine/.agents/scripts/ledger-shards.mjs +346 -0
  316. package/templates/engine/.agents/scripts/metrics-core.mjs +131 -0
  317. package/templates/engine/.agents/scripts/pipeline-run.mjs +964 -0
  318. package/templates/engine/.agents/scripts/policy.mjs +250 -0
  319. package/templates/engine/.agents/scripts/pr-create.mjs +54 -0
  320. package/templates/engine/.agents/scripts/pr-review.mjs +1551 -0
  321. package/templates/engine/.agents/scripts/quote-grounding.mjs +233 -0
  322. package/templates/engine/.agents/scripts/regen-ledgers.mjs +59 -0
  323. package/templates/engine/.agents/scripts/rewrite-file.mjs +135 -0
  324. package/templates/engine/.agents/scripts/rule-budget.mjs +246 -0
  325. package/templates/engine/.agents/scripts/stage-gates.mjs +812 -0
  326. package/templates/engine/.agents/scripts/test-impact-lib.mjs +451 -0
  327. package/templates/engine/.agents/scripts/test-impact.mjs +105 -0
  328. package/templates/engine/.agents/scripts/trust-mode.mjs +130 -0
  329. package/templates/engine/.agents/scripts/verify-scope.mjs +163 -0
  330. package/templates/engine/.agents/scripts/verify-wiki-consistency.mjs +264 -0
  331. package/templates/engine/.agents/scripts/verify.mjs +847 -0
  332. package/templates/engine/.agents/scripts/warn-format.mjs +57 -0
  333. package/templates/engine/.agents/scripts/wf-journal.mjs +230 -0
  334. package/templates/engine/.agents/scripts/workflow-board-server.mjs +696 -0
  335. package/templates/engine/.agents/scripts/workflow-enums.mjs +70 -0
  336. package/templates/engine/.agents/scripts/workflows-check.mjs +260 -0
  337. package/templates/engine/.agents/settings.json +33 -0
  338. package/templates/engine/.agents/skills/arena/SKILL.md +50 -0
  339. package/templates/engine/.agents/skills/autonomous-run/SKILL.md +45 -0
  340. package/templates/engine/.agents/skills/blast-radius/SKILL.md +53 -0
  341. package/templates/engine/.agents/skills/csharp-quality-gates/SKILL.md +109 -0
  342. package/templates/engine/.agents/skills/csharp-quality-gates/scripts/quality-gates.mjs +430 -0
  343. package/templates/engine/.agents/skills/dev-tour/SKILL.md +98 -0
  344. package/templates/engine/.agents/skills/dream/SKILL.md +63 -0
  345. package/templates/engine/.agents/skills/eval/SKILL.md +42 -0
  346. package/templates/engine/.agents/skills/eval/scripts/eval-score.mjs +59 -0
  347. package/templates/engine/.agents/skills/interrogate/SKILL.md +49 -0
  348. package/templates/engine/.agents/skills/interrogate/scripts/interrogate-plan.mjs +72 -0
  349. package/templates/engine/.agents/skills/number-vetting/SKILL.md +35 -0
  350. package/templates/engine/.agents/skills/page-refactor/SKILL.md +192 -0
  351. package/templates/engine/.agents/skills/page-refactor/references/templates.md +989 -0
  352. package/templates/engine/.agents/skills/papercut-fix/SKILL.md +92 -0
  353. package/templates/engine/.agents/skills/papercut-fix/references/response-template.md +81 -0
  354. package/templates/engine/.agents/skills/pause-safely/SKILL.md +31 -0
  355. package/templates/engine/.agents/skills/perf/SKILL.md +42 -0
  356. package/templates/engine/.agents/skills/review-method/SKILL.md +92 -0
  357. package/templates/engine/.agents/skills/review-method/golden-set.md +61 -0
  358. package/templates/engine/.agents/skills/session-resume/SKILL.md +69 -0
  359. package/templates/engine/.agents/skills/session-resume/scripts/worktree-audit.mjs +110 -0
  360. package/templates/engine/.agents/skills/shipyard-workflow-closeout/SKILL.md +109 -0
  361. package/templates/engine/.agents/skills/show-me-your-work/SKILL.md +57 -0
  362. package/templates/engine/.agents/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
  363. package/templates/engine/.agents/skills/show-me-your-work/scripts/decision-log.mjs +24 -0
  364. package/templates/engine/.agents/skills/tfs-pr/SKILL.md +95 -0
  365. package/templates/engine/.agents/skills/tfs-pr/scripts/tfs-pr.mjs +947 -0
  366. package/templates/engine/.agents/skills/verify-ui/SKILL.md +116 -0
  367. package/templates/engine/.agents/skills/verify-ui/features/.gitkeep +0 -0
  368. package/templates/engine/.agents/skills/verify-ui/scripts/gen-verify-feature.mjs +114 -0
  369. package/templates/engine/.agents/skills/visual-parity/SKILL.md +35 -0
  370. package/templates/engine/.agents/skills/why/SKILL.md +56 -0
  371. package/templates/engine/.agents/skills/why/scripts/why-evidence.mjs +74 -0
  372. package/templates/engine/.agents/skills/wiki/SKILL.md +53 -0
  373. package/templates/engine/.agents/tests/auto-tour.test.mjs +82 -0
  374. package/templates/engine/.agents/tests/dev-tour-model.test.mjs +452 -0
  375. package/templates/engine/.agents/tests/fill-plan-lite.test.mjs +46 -0
  376. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-bare-mid-path.md +14 -0
  377. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-bare-mid-path.model.json +179 -0
  378. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-fake-path-guard.md +21 -0
  379. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-fake-path-guard.model.json +194 -0
  380. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-h3-batches.md +20 -0
  381. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-h3-batches.model.json +207 -0
  382. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-issues.md +24 -0
  383. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-issues.model.json +225 -0
  384. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-l1-single-file.md +15 -0
  385. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-l1-single-file.model.json +160 -0
  386. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-layer-word-unique.md +29 -0
  387. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-layer-word-unique.model.json +266 -0
  388. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-layers-fallback.md +17 -0
  389. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-layers-fallback.model.json +207 -0
  390. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-numbered-steps.md +39 -0
  391. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-numbered-steps.model.json +359 -0
  392. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-path-guess.md +16 -0
  393. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-path-guess.model.json +131 -0
  394. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-table-rows.md +29 -0
  395. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-table-rows.model.json +190 -0
  396. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-task-checkboxes.md +39 -0
  397. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-task-checkboxes.model.json +362 -0
  398. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-union-label.md +24 -0
  399. package/templates/engine/.agents/tests/fixtures/dev-tour/plan-union-label.model.json +224 -0
  400. package/templates/engine/.agents/tests/tools/gen-synthetic-plan.mjs +108 -0
  401. package/templates/git/.gitattributes +22 -0
  402. package/templates/git/.githooks/commit-msg +72 -0
  403. package/templates/git/.githooks/post-commit +62 -0
  404. package/templates/git/.githooks/pre-commit +197 -0
  405. package/templates/git/.githooks/pre-merge-commit +28 -0
  406. package/templates/git/.githooks/pre-push +201 -0
  407. package/templates/git/.gitignore.engine +11 -0
  408. package/templates/hosts/claude/CLAUDE.md +55 -0
  409. package/templates/hosts/claude/agents/implementer.md +7 -0
  410. package/templates/hosts/claude/agents/independent-reviewer.md +8 -0
  411. package/templates/hosts/claude/agents/pr-adjudicator.md +8 -0
  412. package/templates/hosts/claude/agents/pr-finder.md +8 -0
  413. package/templates/hosts/claude/agents/pr-verifier.md +8 -0
  414. package/templates/hosts/claude/agents/ui-verifier.md +8 -0
  415. package/templates/hosts/claude/agents/wiki-compiler.md +8 -0
  416. package/templates/hosts/claude/commands/wf-deploy.md +10 -0
  417. package/templates/hosts/claude/commands/wf-maintain.md +10 -0
  418. package/templates/hosts/claude/commands/wf-new-task.md +10 -0
  419. package/templates/hosts/claude/commands/wf-pipeline-run.md +10 -0
  420. package/templates/hosts/claude/commands/wf-pr-review.md +10 -0
  421. package/templates/hosts/claude/commands/wf-review.md +10 -0
  422. package/templates/hosts/claude/commands/wf-stages.md +10 -0
  423. package/templates/hosts/claude/settings.json +57 -0
  424. package/templates/hosts/cline/agents/implementer.yml +15 -0
  425. package/templates/hosts/cline/agents/independent-reviewer.yml +20 -0
  426. package/templates/hosts/cline/agents/pr-adjudicator.yml +18 -0
  427. package/templates/hosts/cline/agents/pr-finder.yml +19 -0
  428. package/templates/hosts/cline/agents/pr-verifier.yml +18 -0
  429. package/templates/hosts/cline/agents/ui-verifier.yml +17 -0
  430. package/templates/hosts/cline/agents/wiki-compiler.yml +20 -0
  431. package/templates/hosts/cline/hooks/PreToolUse.cjs +260 -0
  432. package/templates/hosts/cline/workflows/wf-deploy.md +8 -0
  433. package/templates/hosts/cline/workflows/wf-maintain.md +8 -0
  434. package/templates/hosts/cline/workflows/wf-new-task.md +8 -0
  435. package/templates/hosts/cline/workflows/wf-pipeline-run.md +8 -0
  436. package/templates/hosts/cline/workflows/wf-pr-review.md +8 -0
  437. package/templates/hosts/cline/workflows/wf-review.md +8 -0
  438. package/templates/hosts/cline/workflows/wf-stages.md +8 -0
  439. package/templates/hosts/codebuddy/CODEBUDDY.md +7 -0
  440. package/templates/hosts/codebuddy/agents/implementer.md +9 -0
  441. package/templates/hosts/codebuddy/agents/independent-reviewer.md +10 -0
  442. package/templates/hosts/codebuddy/agents/pr-adjudicator.md +10 -0
  443. package/templates/hosts/codebuddy/agents/pr-finder.md +10 -0
  444. package/templates/hosts/codebuddy/agents/pr-verifier.md +10 -0
  445. package/templates/hosts/codebuddy/agents/ui-verifier.md +11 -0
  446. package/templates/hosts/codebuddy/agents/wiki-compiler.md +10 -0
  447. package/templates/hosts/codebuddy/commands/wf-deploy.md +10 -0
  448. package/templates/hosts/codebuddy/commands/wf-maintain.md +10 -0
  449. package/templates/hosts/codebuddy/commands/wf-new-task.md +10 -0
  450. package/templates/hosts/codebuddy/commands/wf-pipeline-run.md +10 -0
  451. package/templates/hosts/codebuddy/commands/wf-pr-review.md +10 -0
  452. package/templates/hosts/codebuddy/commands/wf-review.md +10 -0
  453. package/templates/hosts/codebuddy/commands/wf-stages.md +10 -0
  454. package/templates/hosts/codebuddy/rules/backend-scope.md +5 -0
  455. package/templates/hosts/codebuddy/rules/frontend-scope.md +5 -0
  456. package/templates/hosts/codebuddy/settings.json +31 -0
  457. package/templates/hosts/codebuddy/skills/tfs-pr/SKILL.md +6 -0
  458. package/templates/hosts/commandcode/agents/implementer.md +10 -0
  459. package/templates/hosts/commandcode/agents/independent-reviewer.md +9 -0
  460. package/templates/hosts/commandcode/agents/pr-adjudicator.md +9 -0
  461. package/templates/hosts/commandcode/agents/pr-finder.md +9 -0
  462. package/templates/hosts/commandcode/agents/pr-verifier.md +9 -0
  463. package/templates/hosts/commandcode/agents/ui-verifier.md +11 -0
  464. package/templates/hosts/commandcode/agents/wiki-compiler.md +10 -0
  465. package/templates/hosts/commandcode/commands/wf-deploy.md +9 -0
  466. package/templates/hosts/commandcode/commands/wf-maintain.md +9 -0
  467. package/templates/hosts/commandcode/commands/wf-new-task.md +9 -0
  468. package/templates/hosts/commandcode/commands/wf-pipeline-run.md +9 -0
  469. package/templates/hosts/commandcode/commands/wf-pr-review.md +9 -0
  470. package/templates/hosts/commandcode/commands/wf-review.md +9 -0
  471. package/templates/hosts/commandcode/commands/wf-stages.md +9 -0
  472. package/templates/hosts/commandcode/settings.json +59 -0
  473. package/templates/hosts/opencode/agents/implementer.md +51 -0
  474. package/templates/hosts/opencode/agents/independent-reviewer.md +18 -0
  475. package/templates/hosts/opencode/agents/pr-adjudicator.md +18 -0
  476. package/templates/hosts/opencode/agents/pr-finder.md +18 -0
  477. package/templates/hosts/opencode/agents/pr-verifier.md +18 -0
  478. package/templates/hosts/opencode/agents/ui-verifier.md +45 -0
  479. package/templates/hosts/opencode/agents/wiki-compiler.md +51 -0
  480. package/templates/hosts/opencode/commands/wf-deploy.md +7 -0
  481. package/templates/hosts/opencode/commands/wf-maintain.md +7 -0
  482. package/templates/hosts/opencode/commands/wf-new-task.md +7 -0
  483. package/templates/hosts/opencode/commands/wf-pipeline-run.md +7 -0
  484. package/templates/hosts/opencode/commands/wf-pr-review.md +7 -0
  485. package/templates/hosts/opencode/commands/wf-review.md +7 -0
  486. package/templates/hosts/opencode/commands/wf-stages.md +7 -0
  487. package/templates/hosts/pi/agents/implementer.md +10 -0
  488. package/templates/hosts/pi/agents/independent-reviewer.md +11 -0
  489. package/templates/hosts/pi/agents/pr-adjudicator.md +11 -0
  490. package/templates/hosts/pi/agents/pr-finder.md +10 -0
  491. package/templates/hosts/pi/agents/pr-verifier.md +10 -0
  492. package/templates/hosts/pi/agents/ui-verifier.md +10 -0
  493. package/templates/hosts/pi/agents/wiki-compiler.md +10 -0
  494. package/templates/hosts/pi/extensions/lib/gates-core.cjs +196 -0
  495. package/templates/hosts/pi/extensions/shipyard-gates.ts +95 -0
  496. package/templates/hosts/pi/settings.json +5 -0
  497. package/templates/hosts/qoder/agents/implementer.md +9 -0
  498. package/templates/hosts/qoder/agents/independent-reviewer.md +10 -0
  499. package/templates/hosts/qoder/agents/pr-adjudicator.md +10 -0
  500. package/templates/hosts/qoder/agents/pr-finder.md +10 -0
  501. package/templates/hosts/qoder/agents/pr-verifier.md +10 -0
  502. package/templates/hosts/qoder/agents/ui-verifier.md +10 -0
  503. package/templates/hosts/qoder/agents/wiki-compiler.md +10 -0
  504. package/templates/hosts/qoder/commands/wf-deploy.md +8 -0
  505. package/templates/hosts/qoder/commands/wf-maintain.md +8 -0
  506. package/templates/hosts/qoder/commands/wf-new-task.md +8 -0
  507. package/templates/hosts/qoder/commands/wf-pipeline-run.md +8 -0
  508. package/templates/hosts/qoder/commands/wf-pr-review.md +8 -0
  509. package/templates/hosts/qoder/commands/wf-review.md +8 -0
  510. package/templates/hosts/qoder/commands/wf-stages.md +8 -0
  511. package/templates/hosts/qoder/settings.json +63 -0
  512. package/templates/hosts/qwen/agents/implementer.md +8 -0
  513. package/templates/hosts/qwen/agents/independent-reviewer.md +8 -0
  514. package/templates/hosts/qwen/agents/pr-adjudicator.md +8 -0
  515. package/templates/hosts/qwen/agents/pr-finder.md +8 -0
  516. package/templates/hosts/qwen/agents/pr-verifier.md +8 -0
  517. package/templates/hosts/qwen/agents/ui-verifier.md +8 -0
  518. package/templates/hosts/qwen/agents/wiki-compiler.md +11 -0
  519. package/templates/hosts/qwen/commands/wf-deploy.md +9 -0
  520. package/templates/hosts/qwen/commands/wf-maintain.md +9 -0
  521. package/templates/hosts/qwen/commands/wf-new-task.md +9 -0
  522. package/templates/hosts/qwen/commands/wf-pipeline-run.md +9 -0
  523. package/templates/hosts/qwen/commands/wf-pr-review.md +9 -0
  524. package/templates/hosts/qwen/commands/wf-review.md +9 -0
  525. package/templates/hosts/qwen/commands/wf-stages.md +9 -0
  526. package/templates/hosts/qwen/settings.json +59 -0
  527. package/templates/hosts/trae/agents/implementer.md +9 -0
  528. package/templates/hosts/trae/agents/independent-reviewer.md +10 -0
  529. package/templates/hosts/trae/agents/pr-adjudicator.md +10 -0
  530. package/templates/hosts/trae/agents/pr-finder.md +10 -0
  531. package/templates/hosts/trae/agents/pr-verifier.md +10 -0
  532. package/templates/hosts/trae/agents/ui-verifier.md +10 -0
  533. package/templates/hosts/trae/agents/wiki-compiler.md +10 -0
  534. package/templates/hosts/trae/commands/wf-deploy.md +8 -0
  535. package/templates/hosts/trae/commands/wf-maintain.md +8 -0
  536. package/templates/hosts/trae/commands/wf-new-task.md +8 -0
  537. package/templates/hosts/trae/commands/wf-pipeline-run.md +8 -0
  538. package/templates/hosts/trae/commands/wf-pr-review.md +8 -0
  539. package/templates/hosts/trae/commands/wf-review.md +8 -0
  540. package/templates/hosts/trae/commands/wf-stages.md +8 -0
  541. package/templates/hosts/trae/hooks.json +17 -0
  542. package/templates/hosts/trae/rules/backend-scope.md +5 -0
  543. package/templates/hosts/trae/rules/frontend-scope.md +5 -0
  544. package/templates/hosts/zcode/agents/implementer.md +8 -0
  545. package/templates/hosts/zcode/agents/independent-reviewer.md +8 -0
  546. package/templates/hosts/zcode/agents/ui-verifier.md +8 -0
  547. package/templates/hosts/zcode/agents/wiki-compiler.md +8 -0
  548. package/templates/hosts/zcode/config.json +31 -0
  549. package/templates/hosts/zcode/workflows/code-review.dwf.ts +428 -0
  550. package/templates/hosts/zcode/workflows/fullchain-flow-test.dwf.ts +898 -0
  551. package/templates/profiles/dotnet/.agents/config/lane-surfaces.txt +33 -0
  552. package/templates/profiles/dotnet/.agents/config/rule-budgets.txt +84 -0
  553. package/templates/profiles/dotnet/.agents/config/test-impact-map.json +590 -0
  554. package/templates/profiles/dotnet/.agents/config/workflow-modules.txt +18 -0
  555. package/templates/profiles/dotnet/.agents/hooks/commit-check.config.json +18 -0
  556. package/templates/profiles/dotnet/.agents/hooks/delete-guard-allowlist.txt +28 -0
  557. package/templates/profiles/dotnet/.agents/notes/runtime-env.md +178 -0
  558. package/templates/profiles/dotnet/AGENTS.md +52 -0
  559. package/templates/profiles/empty/.agents/config/lane-surfaces.txt +12 -0
  560. package/templates/profiles/empty/.agents/config/rule-budgets.txt +3 -0
  561. package/templates/profiles/empty/.agents/config/test-impact-map.json +8 -0
  562. package/templates/profiles/empty/.agents/config/workflow-modules.txt +2 -0
  563. package/templates/profiles/empty/.agents/hooks/commit-check.config.json +5 -0
  564. package/templates/profiles/empty/.agents/hooks/delete-guard-allowlist.txt +2 -0
  565. package/templates/profiles/empty/.agents/notes/runtime-env.md +44 -0
  566. package/templates/profiles/empty/AGENTS.md +52 -0
  567. package/templates/profiles/node/.agents/config/lane-surfaces.txt +12 -0
  568. package/templates/profiles/node/.agents/config/rule-budgets.txt +3 -0
  569. package/templates/profiles/node/.agents/config/test-impact-map.json +8 -0
  570. package/templates/profiles/node/.agents/config/workflow-modules.txt +2 -0
  571. package/templates/profiles/node/.agents/hooks/commit-check.config.json +5 -0
  572. package/templates/profiles/node/.agents/hooks/delete-guard-allowlist.txt +2 -0
  573. package/templates/profiles/node/.agents/notes/runtime-env.md +44 -0
  574. package/templates/profiles/node/AGENTS.md +52 -0
  575. package/templates/scaffold/wiki/INDEX.md +33 -0
  576. package/templates/scaffold/wiki/drafts-archive/README.md +7 -0
  577. package/templates/scaffold/wiki//344/272/247/345/223/201/351/234/200/346/261/202/.gitkeep +0 -0
  578. package/templates/scaffold/wiki//345/274/200/345/217/221/346/226/271/346/241/210/.gitkeep +0 -0
  579. package/templates/scaffold/wiki//346/225/260/346/215/256/347/273/264/346/212/244/README.md +22 -0
  580. package/templates/scaffold/wiki//346/265/213/350/257/225/346/212/245/345/221/212/.gitkeep +0 -0
  581. package/templates/scaffold/wiki//347/224/250/346/210/267/345/212/237/350/203/275/.gitkeep +0 -0
  582. package/templates/scaffold/wiki//347/237/245/350/257/206/346/262/211/346/267/200/346/200/273/350/247/210.html +230 -0
  583. package/templates/scaffold/wiki//351/241/271/347/233/256/350/247/204/350/214/203/.gitkeep +0 -0
  584. package/templates/scaffold/workflow/INDEX.md +13 -0
  585. package/templates/scaffold/workflow/README.md +67 -0
  586. package/templates/scaffold/workflow/archive/README.md +3 -0
  587. package/templates/scaffold/workflow/delegations.d/.gitkeep +0 -0
  588. package/templates/scaffold/workflow/delegations.md +4 -0
  589. package/templates/scaffold/workflow/effective-policy.md +4 -0
  590. package/templates/scaffold/workflow/evidence/.gitkeep +0 -0
  591. package/templates/scaffold/workflow/gate-cost.md +4 -0
  592. package/templates/scaffold/workflow/gate-metrics.d/.gitkeep +0 -0
  593. package/templates/scaffold/workflow/incidents/_TEMPLATE.md +49 -0
  594. package/templates/scaffold/workflow/intents/_TEMPLATE.md +43 -0
  595. package/templates/scaffold/workflow/metrics.md +4 -0
  596. package/templates/scaffold/workflow/papercuts.d/.gitkeep +0 -0
  597. package/templates/scaffold/workflow/papercuts.md +3 -0
  598. package/templates/scaffold/workflow/plans/_TEMPLATE.md +47 -0
  599. package/templates/scaffold/workflow/regression-checklist.d/.gitkeep +0 -0
  600. package/templates/scaffold/workflow/regression-checklist.md +3 -0
  601. package/templates/scaffold/workflow/research/.gitkeep +0 -0
  602. package/templates/scaffold/workflow/reviews.d/.gitkeep +0 -0
  603. package/templates/scaffold/workflow/specs/_TEMPLATE.md +87 -0
  604. package/templates/scaffold/workflow/verify-evidence/.gitkeep +0 -0
  605. package/templates/scaffold/workflow/verify-evidence.md +4 -0
  606. package/LICENSE +0 -21
  607. package/modules/gates/README.md +0 -25
  608. package/modules/gates/dotnet-ca/README.md +0 -24
  609. package/modules/gates/dotnet-ca/check-architecture.sh +0 -150
  610. package/modules/gates/dotnet-ca/local-pre-commit.line +0 -1
  611. package/modules/gates/generated-readonly/README.md +0 -13
  612. package/modules/gates/generated-readonly/check-generated.mjs +0 -61
  613. package/modules/gates/generated-readonly/local-pre-commit.line +0 -1
  614. package/modules/gates/node-layer/README.md +0 -9
  615. package/modules/gates/node-layer/check-node-layer.mjs +0 -29
  616. package/modules/gates/node-layer/local-pre-commit.line +0 -1
  617. package/modules/gates/py-import/README.md +0 -9
  618. package/modules/gates/py-import/check-py-import.mjs +0 -30
  619. package/modules/gates/py-import/local-pre-commit.line +0 -1
  620. package/modules/gates/test-protect/README.md +0 -23
  621. package/modules/gates/test-protect/check-test-protect.mjs +0 -64
  622. package/modules/gates/test-protect/local-pre-commit.line +0 -1
  623. package/modules/hosts/README.md +0 -57
  624. package/modules/hosts/claude/agents/implementer.md +0 -51
  625. package/modules/hosts/claude/agents/independent-reviewer.md +0 -49
  626. package/modules/hosts/claude/agents/ui-verifier.md +0 -48
  627. package/modules/hosts/claude/commands/wf-build.md +0 -69
  628. package/modules/hosts/claude/commands/wf-deploy.md +0 -58
  629. package/modules/hosts/claude/commands/wf-design.md +0 -49
  630. package/modules/hosts/claude/commands/wf-gate-checklist.md +0 -77
  631. package/modules/hosts/claude/commands/wf-maintain.md +0 -76
  632. package/modules/hosts/claude/commands/wf-new-task.md +0 -102
  633. package/modules/hosts/claude/commands/wf-pipeline-run.md +0 -35
  634. package/modules/hosts/claude/commands/wf-plan.md +0 -40
  635. package/modules/hosts/claude/commands/wf-review.md +0 -49
  636. package/modules/hosts/claude/commands/wf-sync-hosts.md +0 -64
  637. package/modules/hosts/claude/commands/wf-test.md +0 -68
  638. package/modules/hosts/codex/agents/implementer.md +0 -51
  639. package/modules/hosts/codex/agents/independent-reviewer.md +0 -49
  640. package/modules/hosts/codex/agents/ui-verifier.md +0 -48
  641. package/modules/hosts/codex/commands/wf-build.md +0 -69
  642. package/modules/hosts/codex/commands/wf-deploy.md +0 -58
  643. package/modules/hosts/codex/commands/wf-design.md +0 -49
  644. package/modules/hosts/codex/commands/wf-gate-checklist.md +0 -77
  645. package/modules/hosts/codex/commands/wf-maintain.md +0 -76
  646. package/modules/hosts/codex/commands/wf-new-task.md +0 -102
  647. package/modules/hosts/codex/commands/wf-pipeline-run.md +0 -35
  648. package/modules/hosts/codex/commands/wf-plan.md +0 -40
  649. package/modules/hosts/codex/commands/wf-review.md +0 -49
  650. package/modules/hosts/codex/commands/wf-sync-hosts.md +0 -64
  651. package/modules/hosts/codex/commands/wf-test.md +0 -68
  652. package/modules/hosts/codex/skills/flow-kit/SKILL.md +0 -14
  653. package/modules/hosts/cursor/agents/implementer.md +0 -51
  654. package/modules/hosts/cursor/agents/independent-reviewer.md +0 -49
  655. package/modules/hosts/cursor/agents/ui-verifier.md +0 -48
  656. package/modules/hosts/cursor/commands/wf-build.md +0 -69
  657. package/modules/hosts/cursor/commands/wf-deploy.md +0 -58
  658. package/modules/hosts/cursor/commands/wf-design.md +0 -49
  659. package/modules/hosts/cursor/commands/wf-gate-checklist.md +0 -77
  660. package/modules/hosts/cursor/commands/wf-maintain.md +0 -76
  661. package/modules/hosts/cursor/commands/wf-new-task.md +0 -102
  662. package/modules/hosts/cursor/commands/wf-pipeline-run.md +0 -35
  663. package/modules/hosts/cursor/commands/wf-plan.md +0 -40
  664. package/modules/hosts/cursor/commands/wf-review.md +0 -49
  665. package/modules/hosts/cursor/commands/wf-sync-hosts.md +0 -64
  666. package/modules/hosts/cursor/commands/wf-test.md +0 -68
  667. package/modules/hosts/omp/agents/implementer.md +0 -52
  668. package/modules/hosts/omp/agents/independent-reviewer.md +0 -50
  669. package/modules/hosts/omp/agents/ui-verifier.md +0 -49
  670. package/modules/hosts/opencode/agents/implementer.md +0 -59
  671. package/modules/hosts/opencode/agents/independent-reviewer.md +0 -53
  672. package/modules/hosts/opencode/agents/ui-verifier.md +0 -52
  673. package/modules/hosts/opencode/commands/wf-build.md +0 -69
  674. package/modules/hosts/opencode/commands/wf-deploy.md +0 -58
  675. package/modules/hosts/opencode/commands/wf-design.md +0 -49
  676. package/modules/hosts/opencode/commands/wf-gate-checklist.md +0 -77
  677. package/modules/hosts/opencode/commands/wf-maintain.md +0 -76
  678. package/modules/hosts/opencode/commands/wf-new-task.md +0 -102
  679. package/modules/hosts/opencode/commands/wf-pipeline-run.md +0 -35
  680. package/modules/hosts/opencode/commands/wf-plan.md +0 -40
  681. package/modules/hosts/opencode/commands/wf-review.md +0 -49
  682. package/modules/hosts/opencode/commands/wf-sync-hosts.md +0 -64
  683. package/modules/hosts/opencode/commands/wf-test.md +0 -68
  684. package/modules/hosts/trae/agents/implementer.md +0 -52
  685. package/modules/hosts/trae/agents/independent-reviewer.md +0 -51
  686. package/modules/hosts/trae/agents/ui-verifier.md +0 -50
  687. package/modules/hosts/trae/commands/wf-build.md +0 -70
  688. package/modules/hosts/trae/commands/wf-deploy.md +0 -59
  689. package/modules/hosts/trae/commands/wf-design.md +0 -50
  690. package/modules/hosts/trae/commands/wf-gate-checklist.md +0 -78
  691. package/modules/hosts/trae/commands/wf-maintain.md +0 -77
  692. package/modules/hosts/trae/commands/wf-new-task.md +0 -103
  693. package/modules/hosts/trae/commands/wf-pipeline-run.md +0 -36
  694. package/modules/hosts/trae/commands/wf-plan.md +0 -41
  695. package/modules/hosts/trae/commands/wf-review.md +0 -50
  696. package/modules/hosts/trae/commands/wf-sync-hosts.md +0 -65
  697. package/modules/hosts/trae/commands/wf-test.md +0 -69
  698. package/modules/hosts/trae/hooks/post-edit-check.cjs +0 -98
  699. package/modules/hosts/trae/hooks/pre-shell-check.cjs +0 -192
  700. package/modules/hosts/trae/hooks/resolve-shell.cjs +0 -30
  701. package/modules/hosts/trae/hooks.json +0 -29
  702. package/modules/hosts/trae/rules/beautify-input-chinese.md +0 -6
  703. package/modules/hosts/trae/rules/git-commit-message.md +0 -10
  704. package/modules/hosts/trae/rules/project-workflow.md +0 -14
  705. package/modules/hosts/zcode/agents/implementer.md +0 -51
  706. package/modules/hosts/zcode/agents/independent-reviewer.md +0 -49
  707. package/modules/hosts/zcode/agents/ui-verifier.md +0 -48
  708. package/src/add-gate.mjs +0 -116
  709. package/src/add-gate.test.mjs +0 -103
  710. package/src/add-host.mjs +0 -68
  711. package/src/cli.mjs +0 -169
  712. package/src/doctor.mjs +0 -629
  713. package/src/executor.mjs +0 -262
  714. package/src/executor.test.mjs +0 -295
  715. package/src/fresh-init.test.mjs +0 -64
  716. package/src/gate-dotnet-ca.test.mjs +0 -124
  717. package/src/gates.test.mjs +0 -143
  718. package/src/init.mjs +0 -382
  719. package/src/init.test.mjs +0 -163
  720. package/src/instance-ref.test.mjs +0 -62
  721. package/src/jscpd-drift.test.mjs +0 -145
  722. package/src/pack.test.mjs +0 -24
  723. package/src/profiles.mjs +0 -183
  724. package/src/render.mjs +0 -132
  725. package/src/rule-budget.test.mjs +0 -103
  726. package/src/run-tests.mjs +0 -56
  727. package/src/stack-profile.test.mjs +0 -95
  728. package/src/sync-hosts.mjs +0 -257
  729. package/src/sync-hosts.test.mjs +0 -291
  730. package/src/sync.mjs +0 -228
  731. package/src/sync.test.mjs +0 -452
  732. package/src/trae-hooks.test.mjs +0 -127
  733. package/src/validate.mjs +0 -77
  734. package/src/validate.test.mjs +0 -95
  735. package/templates/.gitattributes +0 -17
  736. package/templates/AGENTS.md +0 -58
  737. package/templates/_agents/board/index.html +0 -676
  738. package/templates/_agents/commands/build.md +0 -84
  739. package/templates/_agents/commands/deploy.md +0 -66
  740. package/templates/_agents/commands/design.md +0 -63
  741. package/templates/_agents/commands/gate-checklist.md +0 -91
  742. package/templates/_agents/commands/maintain.md +0 -90
  743. package/templates/_agents/commands/new-task.md +0 -110
  744. package/templates/_agents/commands/pipeline-run.md +0 -43
  745. package/templates/_agents/commands/plan.md +0 -48
  746. package/templates/_agents/commands/review.md +0 -62
  747. package/templates/_agents/commands/sync-hosts.md +0 -77
  748. package/templates/_agents/commands/test.md +0 -87
  749. package/templates/_agents/control-surfaces.txt +0 -53
  750. package/templates/_agents/engine-lock.json +0 -342
  751. package/templates/_agents/hooks/check-index-incremental.mjs +0 -48
  752. package/templates/_agents/hooks/check-pairing-incremental.mjs +0 -66
  753. package/templates/_agents/hooks/check-wiki-ledger.mjs +0 -30
  754. package/templates/_agents/hooks/commit-check.cjs +0 -193
  755. package/templates/_agents/hooks/local-pre-commit +0 -6
  756. package/templates/_agents/lane-surfaces.txt +0 -17
  757. package/templates/_agents/level-hints.txt +0 -30
  758. package/templates/_agents/loop/papercut-debt/DESIGN.md +0 -112
  759. package/templates/_agents/mechanism-registry.md +0 -35
  760. package/templates/_agents/metric-claims.txt +0 -81
  761. package/templates/_agents/notes/engine-internals.md +0 -17
  762. package/templates/_agents/notes/runtime-env.md +0 -18
  763. package/templates/_agents/roles/implementer.md +0 -47
  764. package/templates/_agents/roles/independent-reviewer.md +0 -45
  765. package/templates/_agents/roles/ui-verifier.md +0 -44
  766. package/templates/_agents/rule-budgets.txt +0 -20
  767. package/templates/_agents/scripts/agg-delegations.cjs +0 -302
  768. package/templates/_agents/scripts/agg-delegations.test.mjs +0 -282
  769. package/templates/_agents/scripts/agg-gate-stats.mjs +0 -113
  770. package/templates/_agents/scripts/agg-gate-stats.test.mjs +0 -95
  771. package/templates/_agents/scripts/agg-judgments.mjs +0 -156
  772. package/templates/_agents/scripts/agg-judgments.test.mjs +0 -93
  773. package/templates/_agents/scripts/archive-sweep.mjs +0 -235
  774. package/templates/_agents/scripts/archive-sweep.test.mjs +0 -129
  775. package/templates/_agents/scripts/check-attribution.mjs +0 -37
  776. package/templates/_agents/scripts/check-convergence.mjs +0 -124
  777. package/templates/_agents/scripts/check-engine-integrity.mjs +0 -220
  778. package/templates/_agents/scripts/check-engine-integrity.test.mjs +0 -215
  779. package/templates/_agents/scripts/check-funnel.mjs +0 -56
  780. package/templates/_agents/scripts/check-hygiene.mjs +0 -167
  781. package/templates/_agents/scripts/check-hygiene.test.mjs +0 -182
  782. package/templates/_agents/scripts/check-index-incremental.test.mjs +0 -73
  783. package/templates/_agents/scripts/check-lane-surface.mjs +0 -238
  784. package/templates/_agents/scripts/check-lane-surface.test.mjs +0 -302
  785. package/templates/_agents/scripts/check-ledger-invariant.mjs +0 -586
  786. package/templates/_agents/scripts/check-ledger-invariant.test.mjs +0 -639
  787. package/templates/_agents/scripts/check-loop-rev.test.mjs +0 -336
  788. package/templates/_agents/scripts/check-loop-unit.test.mjs +0 -103
  789. package/templates/_agents/scripts/check-loop.mjs +0 -1987
  790. package/templates/_agents/scripts/check-loop.sh +0 -6
  791. package/templates/_agents/scripts/check-loop.test.mjs +0 -3912
  792. package/templates/_agents/scripts/check-metric-claims.mjs +0 -277
  793. package/templates/_agents/scripts/check-prejudgment.mjs +0 -64
  794. package/templates/_agents/scripts/check-registry.mjs +0 -45
  795. package/templates/_agents/scripts/check-scope.mjs +0 -96
  796. package/templates/_agents/scripts/check-scope.test.mjs +0 -99
  797. package/templates/_agents/scripts/check-scripts-syntax.mjs +0 -84
  798. package/templates/_agents/scripts/check-scripts-syntax.test.mjs +0 -72
  799. package/templates/_agents/scripts/check-spec-verif.mjs +0 -47
  800. package/templates/_agents/scripts/check-stage-index.mjs +0 -40
  801. package/templates/_agents/scripts/check-stage-index.test.mjs +0 -77
  802. package/templates/_agents/scripts/closeout-l1.mjs +0 -217
  803. package/templates/_agents/scripts/closeout-l1.test.mjs +0 -105
  804. package/templates/_agents/scripts/commit-check-trigger.test.mjs +0 -205
  805. package/templates/_agents/scripts/compact-ledgers.mjs +0 -97
  806. package/templates/_agents/scripts/compact-ledgers.test.mjs +0 -162
  807. package/templates/_agents/scripts/confirm-doc.mjs +0 -610
  808. package/templates/_agents/scripts/confirm-doc.test.mjs +0 -1119
  809. package/templates/_agents/scripts/doctor.test.mjs +0 -770
  810. package/templates/_agents/scripts/draft-sediment.mjs +0 -178
  811. package/templates/_agents/scripts/draft-sediment.test.mjs +0 -272
  812. package/templates/_agents/scripts/edit-face-check.mjs +0 -109
  813. package/templates/_agents/scripts/edit-face-check.test.mjs +0 -99
  814. package/templates/_agents/scripts/ensure-board.mjs +0 -185
  815. package/templates/_agents/scripts/fill-intent.mjs +0 -91
  816. package/templates/_agents/scripts/fill-intent.test.mjs +0 -113
  817. package/templates/_agents/scripts/fill-plan.mjs +0 -79
  818. package/templates/_agents/scripts/fill-plan.test.mjs +0 -224
  819. package/templates/_agents/scripts/fill-spec.mjs +0 -70
  820. package/templates/_agents/scripts/fill-spec.test.mjs +0 -266
  821. package/templates/_agents/scripts/fixture-scripts.mjs +0 -153
  822. package/templates/_agents/scripts/fixture-scripts.test.mjs +0 -112
  823. package/templates/_agents/scripts/gate-checklist.mjs +0 -209
  824. package/templates/_agents/scripts/gate-checklist.test.mjs +0 -201
  825. package/templates/_agents/scripts/gate-seg.mjs +0 -54
  826. package/templates/_agents/scripts/gate-seg.test.mjs +0 -112
  827. package/templates/_agents/scripts/gen-effective-policy.mjs +0 -107
  828. package/templates/_agents/scripts/gen-effective-policy.test.mjs +0 -100
  829. package/templates/_agents/scripts/gen-verify-evidence.mjs +0 -107
  830. package/templates/_agents/scripts/gen-verify-evidence.test.mjs +0 -84
  831. package/templates/_agents/scripts/gen-wiki-board.mjs +0 -276
  832. package/templates/_agents/scripts/gen-wiki-board.test.mjs +0 -249
  833. package/templates/_agents/scripts/gen-workflow-dashboard.mjs +0 -251
  834. package/templates/_agents/scripts/gen-workflow-dashboard.test.mjs +0 -188
  835. package/templates/_agents/scripts/gen-workflow-index.mjs +0 -201
  836. package/templates/_agents/scripts/gen-workflow-index.test.mjs +0 -152
  837. package/templates/_agents/scripts/gen-workflow-metrics.mjs +0 -466
  838. package/templates/_agents/scripts/gen-workflow-metrics.test.mjs +0 -343
  839. package/templates/_agents/scripts/git-merge-jsonl.mjs +0 -63
  840. package/templates/_agents/scripts/git-merge-jsonl.test.mjs +0 -125
  841. package/templates/_agents/scripts/judgment-ledger.mjs +0 -65
  842. package/templates/_agents/scripts/judgment-ledger.test.mjs +0 -129
  843. package/templates/_agents/scripts/kb-cache-evict.mjs +0 -50
  844. package/templates/_agents/scripts/kb-cache-evict.test.mjs +0 -104
  845. package/templates/_agents/scripts/kb-search.mjs +0 -413
  846. package/templates/_agents/scripts/kb-search.test.mjs +0 -299
  847. package/templates/_agents/scripts/lane-surface-audit.mjs +0 -143
  848. package/templates/_agents/scripts/lane-surface-audit.test.mjs +0 -93
  849. package/templates/_agents/scripts/ledger-doc-chain.test.mjs +0 -166
  850. package/templates/_agents/scripts/ledger-loader.mjs +0 -108
  851. package/templates/_agents/scripts/ledger-loader.test.mjs +0 -131
  852. package/templates/_agents/scripts/ledger-prune.mjs +0 -96
  853. package/templates/_agents/scripts/ledger-prune.test.mjs +0 -120
  854. package/templates/_agents/scripts/ledger-shards.mjs +0 -344
  855. package/templates/_agents/scripts/ledger-shards.test.mjs +0 -356
  856. package/templates/_agents/scripts/ledger-ts-monotonic.test.mjs +0 -135
  857. package/templates/_agents/scripts/level-criteria.mjs +0 -231
  858. package/templates/_agents/scripts/level-criteria.test.mjs +0 -281
  859. package/templates/_agents/scripts/mechanism-retire-watch.mjs +0 -183
  860. package/templates/_agents/scripts/mechanism-retire-watch.test.mjs +0 -114
  861. package/templates/_agents/scripts/papercut-debt-controller.mjs +0 -141
  862. package/templates/_agents/scripts/papercut-debt-controller.test.mjs +0 -127
  863. package/templates/_agents/scripts/papercut-debt-sensor.mjs +0 -170
  864. package/templates/_agents/scripts/papercut-debt-sensor.test.mjs +0 -146
  865. package/templates/_agents/scripts/pipeline-run-docs.mjs +0 -76
  866. package/templates/_agents/scripts/pipeline-run-run.mjs +0 -63
  867. package/templates/_agents/scripts/pipeline-run.mjs +0 -867
  868. package/templates/_agents/scripts/pipeline-run.test.mjs +0 -517
  869. package/templates/_agents/scripts/policy.mjs +0 -281
  870. package/templates/_agents/scripts/pre-push.test.mjs +0 -105
  871. package/templates/_agents/scripts/resolve-merge-conflicts.mjs +0 -110
  872. package/templates/_agents/scripts/resolve-merge-conflicts.test.mjs +0 -87
  873. package/templates/_agents/scripts/rewrite-file.mjs +0 -133
  874. package/templates/_agents/scripts/rewrite-file.test.mjs +0 -148
  875. package/templates/_agents/scripts/rule-budget.mjs +0 -96
  876. package/templates/_agents/scripts/rule-budget.test.mjs +0 -118
  877. package/templates/_agents/scripts/run-tests.mjs +0 -99
  878. package/templates/_agents/scripts/run-tests.test.mjs +0 -105
  879. package/templates/_agents/scripts/solidify-task.mjs +0 -109
  880. package/templates/_agents/scripts/solidify-task.test.mjs +0 -129
  881. package/templates/_agents/scripts/stage-gates.mjs +0 -343
  882. package/templates/_agents/scripts/stage-gates.test.mjs +0 -105
  883. package/templates/_agents/scripts/trust-mode.mjs +0 -67
  884. package/templates/_agents/scripts/trust-mode.test.mjs +0 -110
  885. package/templates/_agents/scripts/verify-wiki-consistency.mjs +0 -253
  886. package/templates/_agents/scripts/verify-wiki-consistency.test.mjs +0 -123
  887. package/templates/_agents/scripts/verify.mjs +0 -345
  888. package/templates/_agents/scripts/verify.test.mjs +0 -373
  889. package/templates/_agents/scripts/wf-journal.mjs +0 -231
  890. package/templates/_agents/scripts/wf-journal.test.mjs +0 -216
  891. package/templates/_agents/scripts/wiki-search.mjs +0 -19
  892. package/templates/_agents/scripts/wiki-search.test.mjs +0 -57
  893. package/templates/_agents/scripts/workflow-board-server.mjs +0 -393
  894. package/templates/_agents/scripts/workflow-board-server.test.mjs +0 -201
  895. package/templates/_agents/scripts/workflow-enums.mjs +0 -70
  896. package/templates/_agents/scripts/workflow-enums.test.mjs +0 -118
  897. package/templates/_agents/scripts/workflows-check.mjs +0 -260
  898. package/templates/_agents/scripts/workflows-check.test.mjs +0 -278
  899. package/templates/_agents/scripts-test-exempt.txt +0 -16
  900. package/templates/_agents/skills/papercut-fix/SKILL.md +0 -60
  901. package/templates/_agents/skills/papercut-fix/references/response-template.md +0 -81
  902. package/templates/_agents/skills/review-method/SKILL.md +0 -58
  903. package/templates/_agents/skills/verify-ui/SKILL.md +0 -61
  904. package/templates/_agents/skills/wiki/SKILL.md +0 -106
  905. package/templates/_agents/workflow-enums.txt +0 -26
  906. package/templates/_agents/workflow-modules.txt +0 -11
  907. package/templates/_agents/workflows/_TEMPLATE.md +0 -75
  908. package/templates/_agents/workflows/pipeline-closing.md +0 -28
  909. package/templates/_agents/workflows//347/244/272/344/276/213-/345/271/266/350/241/214/345/256/236/347/216/260/350/257/204/345/256/241.md +0 -16
  910. package/templates/_githooks/commit-msg +0 -17
  911. package/templates/_githooks/post-commit +0 -10
  912. package/templates/_githooks/pre-commit +0 -126
  913. package/templates/_githooks/pre-merge-commit +0 -29
  914. package/templates/_githooks/pre-push +0 -136
  915. package/templates/_github/workflows/kit-ci.yml +0 -49
  916. package/templates/wiki/INDEX.md +0 -73
  917. package/templates/wiki/drafts-archive/README.md +0 -3
  918. package/templates/wiki//344/272/247/345/223/201/351/234/200/346/261/202/README.md +0 -3
  919. package/templates/wiki//345/274/200/345/217/221/346/226/271/346/241/210/README.md +0 -3
  920. package/templates/wiki//346/225/260/346/215/256/347/273/264/346/212/244/README.md +0 -3
  921. package/templates/wiki//346/265/213/350/257/225/346/212/245/345/221/212/README.md +0 -3
  922. package/templates/wiki//347/224/250/346/210/267/345/212/237/350/203/275/README.md +0 -3
  923. package/templates/wiki//347/237/245/350/257/206/346/262/211/346/267/200/346/200/273/350/247/210.html +0 -77
  924. package/templates/wiki//351/241/271/347/233/256/350/247/204/350/214/203/README.md +0 -3
  925. package/templates/wiki//351/241/271/347/233/256/350/256/241/345/210/222/README.md +0 -3
  926. package/templates/workflow/README.md +0 -91
  927. package/templates/workflow/delegations.md +0 -29
  928. package/templates/workflow/incidents/_TEMPLATE.md +0 -51
  929. package/templates/workflow/intents/_TEMPLATE.md +0 -51
  930. package/templates/workflow/papercuts.md +0 -9
  931. package/templates/workflow/plans/_TEMPLATE.md +0 -47
  932. package/templates/workflow/regression-checklist.md +0 -23
  933. package/templates/workflow/specs/_TEMPLATE.md +0 -80
  934. /package/templates/{_agents → engine/.agents}/board/marked.min.js +0 -0
  935. /package/templates/{_agents/workflows → engine/.agents/pipelines}/steps//347/244/272/344/276/213-/351/203/250/347/275/262/351/252/214/350/257/201.md" +0 -0
  936. /package/templates/{_agents → engine/.agents}/scripts/git-core.mjs +0 -0
@@ -1,867 +0,0 @@
1
- #!/usr/bin/env node
2
- // pipeline-run — 跨宿主全自动闭环执行器(2026-10-02 pipeline-run 立法)
3
- // 用途:把六阶段闭环的确定性部分代码化为状态机——start/next/status/watch/abort 五子命令;
4
- // AI 槽位经工单协议交宿主执行,人件门到点即停、next --delegated "<原话>" 逐份过 confirm-doc。
5
- // 红线:绝不 spawn AI 会话 / 零依赖 / git 永不 --no-verify / 永不伪造原话 / 永不直改文档状态(唯一入口 confirm-doc)。
6
- // 契约:工单协议 + run 事件流 schema 见 spec §功能行为(宿主面契约,变更须走变更流程)。
7
- // 存储:.agents/cache/pipeline-runs/<runId>.json(gitignored 缓存态,非权威——workflow/ 文档 + confirmations.jsonl 是唯一真相源)。
8
- // 注入(测试钩子,spec §测试注入契约):PIPELINE_RUN_ROOT(仓库根,默认 cwd)/
9
- // PIPELINE_RUN_BIN(门脚本目录,默认 <root>/.agents/scripts)/ PIPELINE_RUN_GIT_BIN(git 命令前缀,空格分隔,默认 "git")/
10
- // PIPELINE_RUN_TODAY(文档日期锚定,默认当天——测试固定日期消除时钟依赖,2026-10-03 实证:测试硬编码日期跨日即红)。
11
- // npm 不直接调用——测试门统一走 verify.mjs(其内部自跑 npm test)。
12
- // 用法:
13
- // node .agents/scripts/pipeline-run.mjs start "<需求原文>" [--hint "kind=require level=L1 module=wiki"]
14
- // node .agents/scripts/pipeline-run.mjs next [--run <id>] [--triage "kind=|level=|module=|topic="] [--delegated "<原话>"] [--files "a,b"]
15
- // node .agents/scripts/pipeline-run.mjs status [--run <id>] [--adopt] [--json]
16
- // node .agents/scripts/pipeline-run.mjs watch [--run <id>] [--interval 2]
17
- // node .agents/scripts/pipeline-run.mjs abort --run <id> [--to superseded|cancelled] [--delegated "<原话>"]
18
- // 测试:node templates/_agents/scripts/pipeline-run.test.mjs(夹具假门 + 假 git,不触真实仓库)
19
- import fs from 'node:fs';
20
- import path from 'node:path';
21
- import { spawnSync } from 'node:child_process';
22
-
23
- const KINDS = ['require', 'fix', 'verify', 'review', 'deploy'];
24
- const LEVELS = ['L1', 'L2', 'L3']; // L0 已退役(2026-10-13 自源仓收敛系列 1 回灌)——级别三档,L1 = 一份 plan 即入口
25
- const TERMINAL = ['done', 'superseded', 'cancelled', 'closed'];
26
- const FIX_CAP = 3;
27
- const GIT_NEVER_FLAGS = ['--no-verify', '-n']; // 不变量:任何 git 调用不得携带(防御性断言,正常路径不会拼出)
28
-
29
- function fail(msg, code = 1) { console.error('❌ ' + msg); process.exit(code); }
30
-
31
-
32
- import { nowIso, today, ctxEnv, moduleList, loadRun, saveRun, emit, latestRunId, newRunId } from './pipeline-run-run.mjs';
33
- import { fmGet, placeholdersIn, sectionBody, validateDraftContent, closeoutComplete, summarizeDoc } from './pipeline-run-docs.mjs';
34
- // 拆分(2026-10-08 engine-quality-batch):文档纯函数层 / run 存储层迁出本文件(判据注释随函数迁走,
35
- // 对外导出面经下行 re-export 保持不变——stageBar/parseKV 仍在本文件);本文件 = CLI 编排层 + 状态机。
36
- export { placeholdersIn, validateDraftContent, closeoutComplete } from './pipeline-run-docs.mjs';
37
-
38
- // ── 门执行(唯一子进程出口;记录真实退出码) ──────────────────────────
39
- function runNode(ctx, run, script, args) {
40
- const scriptPath = path.join(ctx.bin, script);
41
- const cmd = `node .agents/scripts/${script} ${args.join(' ')}`;
42
- const t0 = Date.now();
43
- // PIPELINE_RUN_ID 注入(2026-10-07 verify-evidence 复核 P2-1):verify.mjs 绿行据此绑定 runId
44
- //(对质链与 run 事件流同源,docsCommit 格式已含同一 runId)——spec「pipeline-run 路径自动绑定」落点
45
- const p = spawnSync(process.execPath, [scriptPath, ...args], { cwd: ctx.root, encoding: 'utf8', windowsHide: true, env: { ...process.env, PIPELINE_RUN_ID: run.runId } });
46
- const ms = Date.now() - t0;
47
- const exit = p.status ?? 1;
48
- emit(run, { type: 'gate', cmd, exit, ms });
49
- return { exit, stdout: p.stdout || '', stderr: p.stderr || '' };
50
- }
51
-
52
- function runGit(ctx, run, args) {
53
- if (args.some((a) => GIT_NEVER_FLAGS.includes(a))) fail('不变量破坏:git 调用携带禁用旗标', 1);
54
- const cmd = `git ${args.join(' ')}`;
55
- const t0 = Date.now();
56
- const p = spawnSync(ctx.gitPrefix[0], [...ctx.gitPrefix.slice(1), ...args], { cwd: ctx.root, encoding: 'utf8', windowsHide: true });
57
- const ms = Date.now() - t0;
58
- const exit = p.status ?? 1;
59
- emit(run, { type: 'gate', cmd, exit, ms });
60
- return { exit, stdout: p.stdout || '', stderr: p.stderr || '' };
61
- }
62
-
63
- // ── 文档读取/校验 ──────────────────────────────────────────────────────
64
- function readDoc(ctx, rel) {
65
- try { return fs.readFileSync(path.join(ctx.root, rel), 'utf8'); } catch { return null; }
66
- }
67
- function docState(ctx, rel) { const t = readDoc(ctx, rel); return t ? fmGet(t, '状态') : null; }
68
-
69
-
70
- // ── 工单构建 ───────────────────────────────────────────────────────────
71
- function wo(run, o) {
72
- const order = { id: (run.events.filter((e) => e.type === 'work-order').length + 1), ...o };
73
- return order;
74
- }
75
- function issueWO(ctx, run, order, nextStage) {
76
- run.workOrder = order;
77
- run.stopType = 'work-order';
78
- run.stage = nextStage;
79
- emit(run, { type: 'work-order', id: order.id, kind: order.kind });
80
- emit(run, { type: 'stop', stopType: 'work-order', workOrderId: order.id });
81
- saveRun(ctx, run);
82
- printRun(ctx, run);
83
- process.exit(0);
84
- }
85
- function stopConfirm(ctx, run, docRel, points, ledger) {
86
- run.workOrder = null;
87
- run.stopType = 'await-confirm';
88
- run.awaitConfirm = { doc: docRel, points, ledger: !!ledger };
89
- emit(run, { type: 'stop', stopType: 'await-confirm', doc: docRel });
90
- saveRun(ctx, run);
91
- printRun(ctx, run);
92
- process.exit(0);
93
- }
94
- function stopGateFail(ctx, run, stage, problems) {
95
- run.workOrder = null;
96
- run.stopType = 'gate-fail';
97
- run.stage = stage;
98
- run.gateFail = { stage, problems };
99
- emit(run, { type: 'stop', stopType: 'gate-fail', stage });
100
- saveRun(ctx, run);
101
- printRun(ctx, run, problems);
102
- process.exit(2);
103
- }
104
- function stopDone(ctx, run) {
105
- run.workOrder = null;
106
- run.stopType = 'done';
107
- run.stage = 'done';
108
- emit(run, { type: 'done' });
109
- emit(run, { type: 'stop', stopType: 'done' });
110
- saveRun(ctx, run);
111
- printRun(ctx, run);
112
- process.exit(0);
113
- }
114
-
115
- // ── 输出(人类可读 + 机器标记) ────────────────────────────────────────
116
- export function stageBar(run) {
117
- const s = run.stage;
118
- const mk = (name, pos) => (pos === 'cur' ? '[●' + name + ']' : pos === 'past' ? '[✓' + name + ']' : '[…' + name + ']');
119
- const seq = run.triage?.kind === 'verify' ? [['Verify', s === 'verify' || s === 'done']]
120
- : run.triage?.kind === 'review' ? [['Review', s === 'review-only' || s === 'done']]
121
- : run.triage?.kind === 'deploy' ? [['Checklist', ['deploy-check', 'deploy-prep'].includes(s)], ['Authorize', s === 'deploy-await' || s === 'done']]
122
- : [['Plan', ['intent-fill', 'intent-draft', 'intent-confirm', 'incident-fill', 'incident-draft', 'incident-confirm', 'triage'].includes(s)],
123
- ['Design', ['spec-fill', 'spec-draft', 'spec-review', 'spec-confirm'].includes(s)],
124
- ['Build', ['plan-fill', 'plan-draft', 'plan-confirm', 'changes-confirm', 'implement', 'fix', 'changes-verify'].includes(s)],
125
- ['Test', ['verify', 'review', 'closeout', 'done-confirm', 'incident-fixed-confirm', 'incident-closed-confirm', 'direct-commit'].includes(s) || s === 'done']];
126
- const curIdx = seq.findIndex(([, cur]) => cur);
127
- return seq.map(([name], i) => mk(name, i < curIdx ? 'past' : i === curIdx ? 'cur' : 'future')).join(' ');
128
- }
129
-
130
- function printRun(ctx, run, problems) {
131
- const lv = run.triage ? ` ${run.triage.level}·${run.triage.kind}` : '';
132
- console.log(`\n▶ pipeline-run ${run.runId}${lv} ${stageBar(run)}`);
133
- if (run.stopType === 'work-order' && run.workOrder) {
134
- const w = run.workOrder;
135
- console.log(`\n== 工单 #${w.id}(${w.kind})${w.title} ==`);
136
- console.log(`目标:${w.goal}`);
137
- for (const s of w.instructions) console.log(` ${s}`);
138
- if (w.context?.kbHits?.length) console.log(`查重命中:\n ${w.context.kbHits.slice(0, 6).join('\n ')}`);
139
- if (w.context?.stderrTail) console.log(`上次门失败输出(尾 20 行):\n ${w.context.stderrTail}`);
140
- console.log('约束:');
141
- for (const c of w.constraints) console.log(` - ${c}`);
142
- console.log('验收(脚本机器校验):');
143
- for (const a of w.acceptance) console.log(` - ${a}`);
144
- console.log(`\n完成工单后回跑:node .agents/scripts/pipeline-run.mjs next${run.docs?.entry ? '' : ''}`);
145
- } else if (run.stopType === 'await-confirm' && run.awaitConfirm) {
146
- const c = run.awaitConfirm;
147
- console.log(`\n== 等待确认 ==${c.ledger ? `(文档:${c.doc},将经 confirm-doc 代录入台账)` : '(对话级确认,记 run 事件不进台账)'}`);
148
- console.log(`要点:${c.points}`);
149
- console.log(`用户确认后回跑:next --delegated "<用户原话>"`);
150
- } else if (run.stopType === 'gate-fail') {
151
- console.log(`\n== 门拒绝(exit 2,不绕不吞——修复后原路重跑 next)==`);
152
- for (const p of problems || run.gateFail?.problems || []) console.log(` - ${p}`);
153
- } else if (run.stopType === 'done') {
154
- console.log(`\n== 完成 ==`);
155
- const gates = run.events.filter((e) => e.type === 'gate');
156
- const fails = gates.filter((e) => e.exit !== 0).length;
157
- console.log(` 需求:${run.requirement}`);
158
- console.log(` 门执行 ${gates.length} 道(非零 ${fails});确认 ${run.events.filter((e) => e.type === 'confirm').length} 次;提交 ${run.events.filter((e) => e.type === 'commit').length} 笔`);
159
- for (const d of [run.docs?.entry, run.docs?.spec, run.docs?.plan].filter(Boolean)) console.log(` 文档:${d}(${docState(ctx, d) || '?'})`);
160
- } else if (run.stopType === 'aborted') {
161
- console.log(`\n== 已放弃(${run.abort?.to || ''})== ${run.abort?.note || ''}`);
162
- }
163
- const stopLine = run.stopType === 'work-order' ? `PIPELINE-STOP work-order ${run.runId} ${run.workOrder?.id}`
164
- : run.stopType === 'await-confirm' ? `PIPELINE-STOP await-confirm ${run.runId} ${run.awaitConfirm?.doc || ''}`
165
- : run.stopType === 'gate-fail' ? `PIPELINE-STOP gate-fail ${run.runId} ${run.stage}`
166
- : run.stopType === 'aborted' ? `PIPELINE-STOP aborted ${run.runId}`
167
- : `PIPELINE-STOP done ${run.runId}`;
168
- console.log(stopLine.trim());
169
- }
170
-
171
- // ── triage / 路径 ──────────────────────────────────────────────────────
172
- export function parseKV(s) {
173
- const out = {};
174
- for (const part of String(s || '').split(/\s+/).filter(Boolean)) {
175
- const i = part.indexOf('=');
176
- if (i > 0) out[part.slice(0, i)] = part.slice(i + 1);
177
- }
178
- return out;
179
- }
180
-
181
- function validateTriage(ctx, kv) {
182
- const problems = [];
183
- if (!KINDS.includes(kv.kind)) problems.push(`kind 须为 ${KINDS.join('|')}`);
184
- if (!LEVELS.includes(kv.level)) problems.push(`level 须为 ${LEVELS.join('|')}`);
185
- const mods = moduleList(ctx);
186
- if (kv.module && !mods.includes(kv.module)) problems.push(`module 须在词表内:${mods.join('|')}`);
187
- if (kv.topic && !/^[a-z0-9][a-z0-9-]*$/.test(kv.topic)) problems.push('topic 须为英文 kebab-case');
188
- return problems;
189
- }
190
-
191
- // ── 状态机(next 的全部合法推进) ──────────────────────────────────────
192
- function confirmGate(ctx, run, docRel, quote, to) {
193
- const args = [docRel];
194
- if (to) args.push('--to', to);
195
- if (quote) args.push('--delegated', quote);
196
- const r = runNode(ctx, run, 'confirm-doc.mjs', args);
197
- if (r.exit !== 0) {
198
- const tail = (r.stderr || r.stdout).split(/\r?\n/).filter(Boolean).slice(-6).join(' | ');
199
- return { ok: false, msg: `confirm-doc exit ${r.exit}:${tail}` };
200
- }
201
- emit(run, { type: 'confirm', doc: docRel, to: to || nextConfirmTarget(docState(ctx, docRel)), source: quote ? 'chat-delegated' : 'tty', ...(quote ? { quote } : {}) });
202
- return { ok: true };
203
- }
204
- // 语义上 confirm-doc 自行决定目标态(approved/done/fixed/closed);事件里记录结果态
205
- function nextConfirmTarget(curState) { return curState || 'approved'; }
206
-
207
- // managedFaceCheck(复核 P2-4 修复 A′,2026-10-02 用户拍板):提交集命中 kit.json 台账面或包源
208
- // templates/_agents/ 时——包源环境(bin/flow-kit.mjs 可达)自动跑 sync 刷台账并把 kit.json 与 sync
209
- // 产物追加进提交集(窗口闭合);装户环境降级为显式 WARN(提示手动补 sync)。返回须追加的文件。
210
- function managedFaceCheck(ctx, run, files) {
211
- let managedRels = null;
212
- try {
213
- const kit = JSON.parse(fs.readFileSync(path.join(ctx.root, '.agents', 'kit.json'), 'utf8'));
214
- managedRels = new Set((kit.managed || []).map((e) => e && e.rel).filter(Boolean));
215
- } catch { return []; } // 无台账(夹具/裸库)不处理
216
- const hit = files.some((f) => f.startsWith('templates/_agents/') || managedRels.has(f));
217
- if (!hit) return [];
218
- const flowKit = path.join(ctx.root, 'bin', 'flow-kit.mjs');
219
- if (!fs.existsSync(flowKit)) {
220
- const msg = '触及 managed 面(kit.json 台账)——装户环境无 flow-kit:提交后须手动跑 flow-kit sync 刷新台账,否则克隆/CI doctor 报漂移';
221
- console.log('⚠️ ' + msg);
222
- emit(run, { type: 'warn', note: msg });
223
- return []; // 复核 P2-D:装户无刷新路径,把未刷新的 kit.json 卷入提交是 no-op 甚至带入中间态——只 WARN 不扩大提交面
224
- }
225
- const cmd = 'node bin/flow-kit.mjs sync';
226
- const t0 = Date.now();
227
- const p = spawnSync(process.execPath, [flowKit, 'sync'], { cwd: ctx.root, encoding: 'utf8', windowsHide: true });
228
- const exit = p.status ?? 1;
229
- emit(run, { type: 'gate', cmd, exit, ms: Date.now() - t0 });
230
- if (exit !== 0) {
231
- console.log(`⚠️ flow-kit sync exit ${exit}——提交将带旧台账,须事后手动补 sync`);
232
- return ['.agents/kit.json'];
233
- }
234
- // sync 产物(.agents/ 与 templates/ 下非运行态改动)+ 台账一并入提交
235
- const extra = ['.agents/kit.json', ...(changedFiles(ctx, run) || [])].filter((c) =>
236
- (c.startsWith('.agents/') || c.startsWith('templates/')) &&
237
- !RUNTIME_OWNED.some((ro) => (ro.endsWith('/') ? c.startsWith(ro) : c === ro)));
238
- emit(run, { type: 'managed-sync', extra: [...new Set(extra)] });
239
- return [...new Set(extra)];
240
- }
241
-
242
- function docsCommit(ctx, run, files, subject) {
243
- const commitFiles = [...new Set([...files, ...managedFaceCheck(ctx, run, files)])];
244
- const add = runGit(ctx, run, ['add', ...commitFiles]);
245
- if (add.exit !== 0) return { ok: false, msg: `git add 失败:${add.stderr.slice(0, 200)}` };
246
- const c = runGit(ctx, run, ['commit', '-m', subject]);
247
- if (c.exit !== 0) return { ok: false, msg: `git commit 失败:${(c.stderr || c.stdout).split(/\r?\n/).filter(Boolean).slice(-4).join(' | ')}` };
248
- const sha = runGit(ctx, run, ['rev-parse', '--short', 'HEAD']);
249
- emit(run, { type: 'commit', sha: sha.stdout.trim(), subject });
250
- return { ok: true };
251
- }
252
-
253
- function changedFiles(ctx, run) {
254
- const r = runGit(ctx, run, ['status', '--porcelain', '-u']); // -u:展开 untracked 目录为逐文件(防「src/」折叠误报越权)
255
- if (r.exit !== 0) return null;
256
- const out = [];
257
- for (const line of r.stdout.split(/\r?\n/).filter(Boolean)) {
258
- let p = line.slice(3).trim();
259
- if (p.includes(' -> ')) {
260
- // 复核 P2-2:rename 行收录 old+new 两路径——旧路径的删除同样属改动面(防改名逃逸越权)
261
- for (const q of p.split(' -> ')) {
262
- const n = q.trim().replace(/^"|"$/g, '').replace(/\\/g, '/');
263
- if (n) out.push(n);
264
- }
265
- continue;
266
- }
267
- p = p.replace(/^"|"$/g, '').replace(/\\/g, '/');
268
- out.push(p);
269
- }
270
- return out;
271
- }
272
-
273
- // 脚本自身管理的运行态路径——confirm/gate/gen-index 副产物,不属宿主越权面(沙箱演练实证,2026-10-02)
274
- // confirmations.d/ 亦为运行态副产物(2026-10-12 ledger-shard-write 的 `--shard` 写入面)——
275
- // 不加会让 --shard 的确认行被沙箱越权检查误判为「宿主改了台账」。
276
- const RUNTIME_OWNED = ['.agents/cache/', '.agents/confirmations.jsonl', '.agents/confirmations.d/', 'workflow/INDEX.md'];
277
-
278
- function checkAuthorized(ctx, run, filesCsv) {
279
- const listed = String(filesCsv || '').split(/[,,]/).map((s) => s.trim().replace(/\\/g, '/')).filter(Boolean);
280
- if (!listed.length) return { ok: false, problems: ['须以 --files 回填本工单实际改动的文件清单(逗号分隔)'] };
281
- const changed = changedFiles(ctx, run);
282
- if (changed === null) return { ok: false, problems: ['git status 失败,无法核对改动面'] };
283
- const beyond = changed.filter((c) =>
284
- !listed.includes(c) && !RUNTIME_OWNED.some((ro) => (ro.endsWith('/') ? c.startsWith(ro) : c === ro)));
285
- if (beyond.length) return { ok: false, problems: [`git 改动超出回填清单(偏离即停):${beyond.join('、')}`] };
286
- run.lastFiles = listed;
287
- return { ok: true };
288
- }
289
-
290
- // locateDeployTarget:deploy 对象定位——--triage topic 显式优先,否则取 workflow/{intents,incidents}
291
- // 最新终态入口(文件名日期序);同名 spec 存在才纳入(L1 无 spec 合法),plan 恒须同名在位。
292
- function locateDeployTarget(ctx, run) {
293
- const all = [];
294
- for (const dir of ['intents', 'incidents']) {
295
- const d = path.join(ctx.root, 'workflow', dir);
296
- if (!fs.existsSync(d)) continue;
297
- for (const f of fs.readdirSync(d)) {
298
- if (!f.endsWith('.md') || f.startsWith('_')) continue;
299
- const rel = `workflow/${dir}/${f}`;
300
- if (['done', 'closed'].includes(docState(ctx, rel))) all.push({ rel, base: f.replace(/\.md$/, '') });
301
- }
302
- }
303
- if (!all.length) return { entry: null };
304
- all.sort((a, b) => b.base.localeCompare(a.base));
305
- const topic = run.triage?.topic && run.triage.topic !== 'task' ? run.triage.topic : null;
306
- // 复核 P2-C 收紧:topic 须与去日期前缀后的主题段等值——子串匹配会误命中(topic=run 命中 pipeline-run)
307
- const hit = topic ? all.find((x) => x.base.replace(/^\d{4}-\d{2}-\d{2}-/, '') === topic) : all[0];
308
- if (!hit) return { entry: null };
309
- const specRel = `workflow/specs/${hit.base}.md`;
310
- return {
311
- entry: hit.rel,
312
- spec: fs.existsSync(path.join(ctx.root, specRel)) ? specRel : null,
313
- plan: `workflow/plans/${hit.base}.md`,
314
- };
315
- }
316
-
317
- function briefReq(run) { return run.requirement.replace(/\s+/g, ' ').slice(0, 40); }
318
-
319
- function kbGate(ctx, run, types) {
320
- const words = (run.requirement.toLowerCase().match(/[a-z0-9]{2,}/g) || []).slice(0, 2);
321
- const kw = words.length ? words : [run.requirement.slice(0, 6)];
322
- const r = runNode(ctx, run, 'kb-search.mjs', [...kw, '--scope', 'workflow', '--type', types, '-n', '6']);
323
- const hits = r.stdout.split(/\r?\n/).filter((l) => l.startsWith('📄')).slice(0, 6);
324
- return { exit: r.exit, hits };
325
- }
326
-
327
- function advance(ctx, run, opt) {
328
- const L = () => run.triage.level;
329
- const K = () => run.triage.kind;
330
- const entry = () => run.docs.entry;
331
- const topic = () => run.triage.topic;
332
-
333
- // 工单型停机点的复验(进入对应阶段时先校验上一工单产出)
334
- while (true) {
335
- const s = run.stage;
336
-
337
- if (s === 'triage') {
338
- if (!run.triage) {
339
- if (!opt.triage) {
340
- issueWO(ctx, run, wo(run, {
341
- kind: 'triage', title: '判级与分类', goal: '读需求与 new-task.md 判级闭集,输出 kind/level/module/topic',
342
- instructions: [
343
- '1. 读 .agents/scripts/level-criteria.mjs 判据单源(L2_SURFACES 触达面闭集 / L1 默认档 / L3_SURFACES 结构面;new-task.md 只承载流程表,判据一律看单源;机器面可先跑 `flow-kit route --kind require` 取路径下限提示)',
344
- `2. 对需求定级:「${run.requirement}」${run.hint ? `(预判参考:${run.hint})` : ''}`,
345
- '3. 回填:next --triage "kind=require|fix|verify|review|deploy level=L1-L3 module=<词表> topic=<英文kebab>"',
346
- ],
347
- context: { docPath: '.agents/commands/new-task.md', kbHits: [], stderrTail: '', relatedDocs: ['workflow/INDEX.md'] },
348
- constraints: ['判级就高不就低;勾红线必 L2+;module 取 .agents/workflow-modules.txt 词表'],
349
- acceptance: ['--triage 三值枚举合法(脚本校验)', '红线词命中而 level<L2 会打 warning(回填者负责就高)'],
350
- }), 'triage');
351
- }
352
- const kv = parseKV(opt.triage);
353
- const problems = validateTriage(ctx, kv);
354
- if (problems.length) stopGateFail(ctx, run, 'triage', problems);
355
- if (/红线|契约|schema|公共接口/.test(run.requirement) && LEVELS.indexOf(kv.level) < LEVELS.indexOf('L2')) {
356
- console.log('⚠️ warning:需求文本命中红线关键词而 level<L2——判级应就高(继续,但责任在回填者)');
357
- }
358
- run.triage = { kind: kv.kind, level: kv.level, module: kv.module || moduleList(ctx)[0], topic: kv.topic || 'task', decidedBy: run.hint ? 'hint+ai' : 'ai', decidedAt: nowIso() };
359
- emit(run, { type: 'triage', ...run.triage });
360
- run.docs = run.docs || { entry: null, spec: null, plan: null };
361
- // 路由
362
- run.stage = K() === 'verify' ? 'verify' : K() === 'review' ? 'review-only' : K() === 'deploy' ? 'deploy-check'
363
- : K() === 'fix' ? 'incident-fill' : 'intent-fill';
364
- continue;
365
- }
366
- run.stage = 'intent-fill'; continue;
367
- }
368
-
369
- if (s === 'intent-fill' || s === 'incident-fill') {
370
- const isInc = s === 'incident-fill';
371
- const rel = isInc ? `workflow/incidents/${today()}-${topic()}.md` : `workflow/intents/${today()}-${topic()}.md`;
372
- run.docs.entry = rel;
373
- const st = docState(ctx, rel);
374
- if (!st) {
375
- const kb = kbGate(ctx, run, isInc ? 'incidents,plans' : 'intents,specs,plans');
376
- run.lastKbHits = kb.hits;
377
- if (isInc) {
378
- // incident 无 fill-* 工具:从 _TEMPLATE.md 复制骨架(机器步骤,记事件)
379
- const tplPath = path.join(ctx.root, 'workflow', 'incidents', '_TEMPLATE.md');
380
- try {
381
- fs.copyFileSync(tplPath, path.join(ctx.root, rel));
382
- emit(run, { type: 'gate', cmd: `cp workflow/incidents/_TEMPLATE.md ${rel}`, exit: 0, ms: 0 });
383
- } catch (e) { stopGateFail(ctx, run, s, [`incident 模板复制失败:${e.message}`]); }
384
- } else {
385
- const r = runNode(ctx, run, 'fill-intent.mjs', ['--module', run.triage.module, '--level', L(), '--topic', topic(), '--output', rel, '--notes', `pipeline-run ${run.runId}`]);
386
- if (r.exit !== 0) stopGateFail(ctx, run, s, [`fill-intent exit ${r.exit}:${(r.stderr || r.stdout).split(/\r?\n/).slice(-3).join(' | ')}`]);
387
- }
388
- }
389
- run.stage = isInc ? 'incident-draft' : 'intent-draft';
390
- issueWO(ctx, run, wo(run, {
391
- kind: 'draft', title: `起草 ${isInc ? 'incident' : 'intent'}:${rel}`, goal: isInc ? '填实事故 4 节 + 复盘三件套' : `填实 intent 各节(${L()} 省节规则见模板注释)`,
392
- instructions: isInc ? [
393
- '1. 按模板填:时间线 / 根因 / 为什么没拦住 / 复盘三件套',
394
- '2. 先查同类:kb-search 命中已附(如有)',
395
- '3. 完成后回跑 next——脚本校验 frontmatter/节完整/占位符',
396
- ] : [
397
- '1. 骨架已由 fill-intent 生成,填实各节正文(背景/教训/目标/非目标/约束/验收)',
398
- '2. 验收标准逐条可测试(写不出判据=还没想清楚)',
399
- '3. 查重命中(如有)在「历史教训/防复发」节引用',
400
- '4. 完成后回跑 next——脚本校验 frontmatter/节完整/占位符',
401
- ],
402
- context: { docPath: rel, kbHits: run.lastKbHits || [], stderrTail: '', relatedDocs: ['.agents/commands/plan.md'] },
403
- constraints: ['只改该文档本身;命名英文 kebab-case;正文不写「状态:/级别:」行'],
404
- acceptance: ['frontmatter 键完整', '必填节非空(L1 省节合法)', '无模板占位符残留'],
405
- }), run.stage);
406
- }
407
-
408
- if (s === 'intent-draft' || s === 'incident-draft') {
409
- const kind = s === 'incident-draft' ? 'incident' : 'intent';
410
- const problems = validateDraftContent(readDoc(ctx, entry()), kind, L());
411
- if (problems.length) stopGateFail(ctx, run, s, problems);
412
- const text = readDoc(ctx, entry());
413
- run.stage = kind === 'incident' ? 'incident-confirm' : 'intent-confirm';
414
- stopConfirm(ctx, run, entry(), summarizeDoc(text), kind !== 'incident');
415
- }
416
-
417
- if (s === 'intent-confirm' || s === 'incident-confirm') {
418
- const ledger = s !== 'incident-confirm';
419
- if (!opt.delegated) stopConfirm(ctx, run, entry(), run.awaitConfirm?.points || summarizeDoc(readDoc(ctx, entry()) || ''), ledger);
420
- if (ledger) {
421
- const r = confirmGate(ctx, run, entry(), opt.delegated);
422
- if (!r.ok) stopGateFail(ctx, run, s, [r.msg]);
423
- } else {
424
- emit(run, { type: 'confirm', doc: entry(), to: 'draft-ok', source: 'conversation', quote: opt.delegated });
425
- }
426
- run.stage = L() === 'L1' || K() === 'fix' ? 'plan-fill' : 'spec-fill';
427
- continue;
428
- }
429
-
430
- if (s === 'spec-fill') {
431
- const rel = `workflow/specs/${today()}-${topic()}.md`;
432
- run.docs.spec = rel;
433
- if (!docState(ctx, rel)) {
434
- const r = runNode(ctx, run, 'fill-spec.mjs', ['--level', L(), '--topic', topic(), '--output', rel]);
435
- if (r.exit !== 0) stopGateFail(ctx, run, s, [`fill-spec exit ${r.exit}(G1 前置门或参数):${(r.stderr || r.stdout).split(/\r?\n/).slice(-3).join(' | ')}`]);
436
- }
437
- run.stage = 'spec-draft';
438
- issueWO(ctx, run, wo(run, {
439
- kind: 'draft', title: `起草 spec:${rel}`, goal: '设计规格 4 节(功能行为/数据流/系统改动/约束遵守映射)',
440
- instructions: [
441
- '1. 骨架已由 fill-spec 生成,填实 4 节',
442
- '2. 约束遵守映射逐条对照根 AGENTS.md 红线,逐条回应',
443
- '3. 多方案取舍列选项交用户(spec 确认时定)',
444
- '4. 完成后回跑 next——脚本机器校验',
445
- ],
446
- context: { docPath: rel, kbHits: [], stderrTail: '', relatedDocs: ['.agents/commands/design.md'] },
447
- constraints: ['只改该文档;页面/交互形态禁止自行推定'],
448
- acceptance: ['4 节齐全非空', '无占位符残留'],
449
- }), 'spec-draft');
450
- }
451
-
452
- if (s === 'spec-draft') {
453
- const problems = validateDraftContent(readDoc(ctx, run.docs.spec), 'spec', L());
454
- if (problems.length) stopGateFail(ctx, run, s, problems);
455
- run.stage = L() === 'L3' ? 'spec-review' : 'spec-confirm';
456
- if (L() === 'L3') {
457
- issueWO(ctx, run, wo(run, {
458
- kind: 'review', title: `独立复核 spec:${run.docs.spec}`, goal: 'L3 强制:新上下文只读复核,结论写入 spec「确认与复核」节',
459
- instructions: [
460
- '1. 以独立视角读 spec 全文与入口 intent',
461
- '2. 找会破坏方案的缺口(问「什么会坏」而非「好不好」)',
462
- '3. 结论(P0/P1 清单或「无」)写入目标文档「## 确认与复核」节(无此节则在文末追加)',
463
- '4. 完成后回跑 next——脚本校验结论在节',
464
- ],
465
- context: { docPath: run.docs.spec, kbHits: [], stderrTail: '', relatedDocs: [] },
466
- constraints: ['只读复核 + 仅在 spec 确认与复核节追加结论;不改其他内容'],
467
- acceptance: ['spec「确认与复核」节含复核结论(P0/P1 或 无)'],
468
- }), 'spec-review');
469
- }
470
- stopConfirm(ctx, run, run.docs.spec, summarizeDoc(readDoc(ctx, run.docs.spec)), true);
471
- }
472
-
473
- if (s === 'spec-review') {
474
- const body = sectionBody(readDoc(ctx, run.docs.spec) || '', '确认与复核') || '';
475
- if (!(/P0\s*\/\s*P1/.test(body) || /P0/.test(body) || /P1/.test(body))) stopGateFail(ctx, run, s, ['spec「确认与复核」节缺复核结论(须含 P0/P1 清单或「无 P0/P1」)']);
476
- run.stage = 'spec-confirm';
477
- stopConfirm(ctx, run, run.docs.spec, summarizeDoc(readDoc(ctx, run.docs.spec)), true);
478
- }
479
-
480
- if (s === 'spec-confirm') {
481
- if (!opt.delegated) stopConfirm(ctx, run, run.docs.spec, run.awaitConfirm?.points || '', true);
482
- const r = confirmGate(ctx, run, run.docs.spec, opt.delegated);
483
- if (!r.ok) stopGateFail(ctx, run, s, [r.msg]);
484
- run.stage = 'plan-fill'; continue;
485
- }
486
-
487
- if (s === 'plan-fill') {
488
- const rel = `workflow/plans/${today()}-${topic()}.md`;
489
- run.docs.plan = rel;
490
- if (!docState(ctx, rel)) {
491
- const r = runNode(ctx, run, 'fill-plan.mjs', ['--level', L(), '--topic', topic(), '--output', rel]);
492
- if (r.exit !== 0) stopGateFail(ctx, run, s, [`fill-plan exit ${r.exit}(G1 前置门或参数):${(r.stderr || r.stdout).split(/\r?\n/).slice(-3).join(' | ')}`]);
493
- }
494
- run.stage = 'plan-draft';
495
- issueWO(ctx, run, wo(run, {
496
- kind: 'draft', title: `起草 plan:${rel}`, goal: `计划文档(${L() === 'L1' ? 'Quick-Plan 三节' : '完整 4 节:改动方案/任务拆解/执行顺序/验证计划'})`,
497
- instructions: [
498
- '1. 骨架已由 fill-plan 生成,填实各节',
499
- '2. 改动方案逐文件列「做什么+判据」——后续 implement 工单的授权面以此为准',
500
- '3. 验证计划对齐入口验收标准',
501
- '4. 完成后回跑 next——脚本机器校验',
502
- ],
503
- context: { docPath: rel, kbHits: [], stderrTail: '', relatedDocs: ['.agents/commands/build.md'] },
504
- constraints: ['只改该文档'],
505
- acceptance: ['节齐全非空', '无占位符残留'],
506
- }), 'plan-draft');
507
- }
508
-
509
- if (s === 'plan-draft') {
510
- const problems = validateDraftContent(readDoc(ctx, run.docs.plan), 'plan', L());
511
- if (problems.length) stopGateFail(ctx, run, s, problems);
512
- run.stage = 'plan-confirm';
513
- stopConfirm(ctx, run, run.docs.plan, summarizeDoc(readDoc(ctx, run.docs.plan)), true);
514
- }
515
-
516
- if (s === 'plan-confirm') {
517
- if (!opt.delegated) stopConfirm(ctx, run, run.docs.plan, run.awaitConfirm?.points || '', true);
518
- const r = confirmGate(ctx, run, run.docs.plan, opt.delegated);
519
- if (!r.ok) stopGateFail(ctx, run, s, [r.msg]);
520
- // 批次一:入口(+spec)+plan 全 approved → 一笔 docs 提交(配对门要求树内成对)
521
- const files = [entry(), run.docs.spec, run.docs.plan].filter(Boolean);
522
- const subject = `docs(workflow): ${topic()} ${K() === 'fix' ? 'incident+plan' : run.docs.spec ? '三件套' : '两件套'} approved——${briefReq(run)}`;
523
- const c = docsCommit(ctx, run, files, subject);
524
- if (!c.ok) stopGateFail(ctx, run, s, [c.msg]);
525
- run.stage = 'changes-confirm';
526
- stopConfirm(ctx, run, run.docs.plan, (sectionBody(readDoc(ctx, run.docs.plan) || '', '改动方案') || '').split(/\r?\n/).slice(0, 5).join(' / ').slice(0, 200), false);
527
- }
528
-
529
- if (s === 'changes-confirm') {
530
- if (!opt.delegated) stopConfirm(ctx, run, run.awaitConfirm?.doc || '', run.awaitConfirm?.points || '', false);
531
- emit(run, { type: 'confirm', doc: '改动清单', to: 'ok', source: 'conversation', quote: opt.delegated });
532
- run.stage = 'implement';
533
- const planFiles = (readDoc(ctx, run.docs.plan).match(/[\w./-]+\.(?:mjs|md|json|txt|cjs|sh|yml|yaml)/g) || []);
534
- issueWO(ctx, run, wo(run, {
535
- kind: 'implement', title: `实现:${briefReq(run)}`, goal: '按 plan 改动方案实现 + 自验',
536
- instructions: [
537
- '1. 按 plan §改动方案逐文件实现(判据照条目)',
538
- '2. 自验:跑 plan §验证计划所列静态门命令',
539
- '3. 偏离即停:改公共接口/计划外文件/新依赖 → 不做,停机向用户上报',
540
- '4. 完成后回填改动文件清单:next --files "a.mjs,b.md"',
541
- ],
542
- context: { docPath: run.docs.plan, kbHits: [], stderrTail: '', relatedDocs: planFiles.slice(0, 8) },
543
- constraints: [`授权文件以 plan 改动方案为准;回填 --files 清单必须与 git status 实际改动一致(脚本核对)`],
544
- acceptance: ['git 改动 ⊆ 回填清单', '后续 verify 门(npm test + check-loop 经 verify.mjs)全绿'],
545
- }), 'implement');
546
- }
547
-
548
- if (s === 'implement' || s === 'fix') {
549
- if (!opt.files) { printRun(ctx, run); process.exit(0); } // 无 --files 重入:重发当前工单(run.workOrder 保留)
550
- const a = checkAuthorized(ctx, run, opt.files);
551
- if (!a.ok) stopGateFail(ctx, run, s, a.problems);
552
- run.stage = 'verify'; continue;
553
- }
554
-
555
- if (s === 'verify') {
556
- const r = runNode(ctx, run, 'verify.mjs', []);
557
- if (K() === 'verify') { // verify-only 短路径:不带修复环,绿即收、败即停
558
- if (r.exit === 0) stopDone(ctx, run);
559
- stopGateFail(ctx, run, s, ['verify 未过(verify-only 不带修复环——人工处理后重跑,或立正式任务走闭环)']);
560
- }
561
- if (r.exit === 0) {
562
- run.fixLoop = { count: 0, cap: FIX_CAP };
563
- // 代码提交(沙箱演练实证的缺口,2026-10-02):verify 绿后、复核/关单前落一笔——
564
- // 文件集 = 当前非运行态、非 workflow 文档的改动(均已过 --files 授权核对)
565
- const codeFiles = (changedFiles(ctx, run) || []).filter((c) =>
566
- !RUNTIME_OWNED.some((ro) => (ro.endsWith('/') ? c.startsWith(ro) : c === ro)) && !c.startsWith('workflow/'));
567
- if (codeFiles.length) {
568
- const verb = K() === 'fix' ? 'fix' : 'feat';
569
- const c = docsCommit(ctx, run, codeFiles, `${verb}(${run.triage.module}): ${briefReq(run)}(pipeline-run ${run.runId})`);
570
- if (!c.ok) stopGateFail(ctx, run, s, [c.msg]);
571
- }
572
- run.stage = (L() === 'L2' || L() === 'L3') ? 'review' : 'closeout'; continue;
573
- }
574
- run.fixLoop = run.fixLoop || { count: 0, cap: FIX_CAP };
575
- run.fixLoop.count += 1;
576
- const tail = (r.stderr || r.stdout).split(/\r?\n/).filter(Boolean).slice(-20).join('\n');
577
- if (run.fixLoop.count >= run.fixLoop.cap) {
578
- stopGateFail(ctx, run, s, [`修复环超限(${run.fixLoop.cap} 次)——人工介入或 abort`]);
579
- }
580
- run.stage = 'fix';
581
- issueWO(ctx, run, wo(run, {
582
- kind: 'fix', title: `修复环 ${run.fixLoop.count}/${run.fixLoop.cap}:verify 未过`, goal: '按失败输出修复后回跑',
583
- instructions: [
584
- '1. 读下方「上次门失败输出」定位失败项',
585
- '2. 修复(授权面仍以 plan 为准,偏离即停)',
586
- '3. 完成后回填:next --files "…"(脚本重核对改动面并重跑 verify)',
587
- ],
588
- context: { docPath: run.docs.plan, kbHits: [], stderrTail: tail, relatedDocs: [] },
589
- constraints: ['不绕门不改门;不 --no-verify'],
590
- acceptance: ['git 改动 ⊆ 回填清单', 'verify.mjs 重跑全绿'],
591
- }), 'fix');
592
- }
593
-
594
- if (s === 'review') {
595
- const target = run.docs.spec || entry();
596
- const body = sectionBody(readDoc(ctx, target) || '', '确认与复核') || '';
597
- if (!(/P0\s*\/\s*P1/.test(body) || /P0/.test(body) || /P1/.test(body))) {
598
- issueWO(ctx, run, wo(run, {
599
- kind: 'review', title: `独立复核(L2/L3):实现与文档对照`, goal: '读入口+spec+plan+diff,产出 P0/P1/P2 清单并把结论写入 spec「确认与复核」节',
600
- instructions: [
601
- '1. 独立读入口/spec/plan 与本次 diff(git diff + 相关文件)',
602
- '2. 逐项对照验收标准找缺口(file:line 证据)',
603
- '3. 结论写入目标文档「## 确认与复核」节(P0/P1 清单或「无」;无此节则在文末追加)',
604
- '4. 定性与合入时机由用户拍板——复核只交证据',
605
- ],
606
- context: { docPath: target, kbHits: [], stderrTail: '', relatedDocs: [entry(), run.docs.plan].filter(Boolean) },
607
- constraints: ['只读 + 仅在 spec 确认与复核节追加结论'],
608
- acceptance: ['spec「确认与复核」节含结论(P0/P1 或 无)'],
609
- }), 'review');
610
- }
611
- run.stage = K() === 'fix' ? 'closeout' : 'closeout';
612
- continue;
613
- }
614
-
615
- if (s === 'closeout') {
616
- if (K() !== 'fix') {
617
- const co = closeoutComplete(readDoc(ctx, entry()) || '');
618
- if (!co.ok) {
619
- issueWO(ctx, run, wo(run, {
620
- kind: 'closeout', title: `勾验收补证据:${entry()}`, goal: '关单前逐条勾验入口文档验收标准并补证据',
621
- instructions: [
622
- '1. 逐条核验「## 验收标准」:达成改 [x] 并补「(证据:<commit SHA/测试名/输出>)」',
623
- '2. 未达成的不得勾——如实留 [ ] 并在下方说明',
624
- '3. 完成后回跑 next(脚本校验全勾+证据在)',
625
- ],
626
- context: { docPath: entry(), kbHits: [], stderrTail: '', relatedDocs: [run.docs.plan].filter(Boolean) },
627
- constraints: ['只改入口文档验收节;证据须真实(SHA/用例名/命令输出)'],
628
- acceptance: ['验收行全 [x] 且每条含 证据:'],
629
- }), 'closeout');
630
- }
631
- }
632
- run.stage = K() === 'fix' ? 'incident-fixed-confirm' : 'done-confirm';
633
- stopConfirm(ctx, run, entry(), '关单确认(done)——逐份原话', true);
634
- }
635
-
636
- if (s === 'done-confirm' || s === 'incident-fixed-confirm' || s === 'incident-closed-confirm') {
637
- const finalize = () => {
638
- runNode(ctx, run, 'gen-workflow-index.mjs', []);
639
- const files = [entry(), run.docs.spec, run.docs.plan].filter(Boolean);
640
- const c = docsCommit(ctx, run, [...files, 'workflow/INDEX.md'], `docs(workflow): ${topic()} 关单——终态落定(pipeline-run ${run.runId})`);
641
- if (!c.ok) stopGateFail(ctx, run, s, [c.msg]);
642
- stopDone(ctx, run);
643
- };
644
- const pendOf = () => {
645
- const pend = [];
646
- if (K() === 'fix') {
647
- const st = docState(ctx, entry());
648
- if (!['fixed', 'closed'].includes(st)) pend.push(entry());
649
- if (st === 'fixed') pend.push(entry()); // 两跳:fixed 之后还需 closed
650
- if (run.docs.plan && !TERMINAL.includes(docState(ctx, run.docs.plan))) pend.push(run.docs.plan);
651
- } else {
652
- for (const rel of [entry(), run.docs.spec, run.docs.plan].filter(Boolean)) {
653
- if (!TERMINAL.includes(docState(ctx, rel))) pend.push(rel);
654
- }
655
- }
656
- return pend;
657
- };
658
- const label = K() === 'fix' ? 'incident 两跳(open→fixed→closed)与 plan 关单' : 'done 关单';
659
- const pend0 = pendOf();
660
- if (!pend0.length) finalize();
661
- if (!opt.delegated) stopConfirm(ctx, run, pend0[0], `${label}——逐份原话,一次一份(余 ${pend0.length} 份)`, true);
662
- const r = confirmGate(ctx, run, pend0[0], opt.delegated);
663
- if (!r.ok) stopGateFail(ctx, run, s, [r.msg]);
664
- const rest = pendOf(); // 一次一份:确认成功即停机,下一份须新原话(confirm-gate-one-per-call 教训)
665
- if (!rest.length) finalize();
666
- stopConfirm(ctx, run, rest[0], `${label}——逐份原话,一次一份(余 ${rest.length} 份)`, true);
667
- }
668
-
669
- // direct-edit 分支随 L0 退役删除(2026-10-13 自源仓收敛系列 1 回灌)——最低档 L1 走 intent+plan 闭环。
670
-
671
- if (s === 'verify-only') { run.stage = 'verify'; continue; }
672
- if (s === 'review-only') {
673
- if (opt.done) stopDone(ctx, run); // 评审清单交付即收(宿主向用户汇报后回填 --done)
674
- issueWO(ctx, run, wo(run, {
675
- kind: 'review', title: '横切评审', goal: '按 .agents/commands/review.md 产出 P0/P1/P2 分级清单交用户定性',
676
- instructions: ['1. 读 review.md 与评审对象', '2. 机器兜底项先跑门,AI 自查项列清单', '3. 结论交用户定性与合入时机'],
677
- context: { docPath: '.agents/commands/review.md', kbHits: [], stderrTail: '', relatedDocs: [] },
678
- constraints: ['只读评审;定性归用户'],
679
- acceptance: ['清单产出(P0/P1/P2 分级)'],
680
- }), 'review-only');
681
- }
682
-
683
- if (s === 'deploy-check') {
684
- // 复核 P1-2 补实现(2026-10-02 用户拍板):deploy-prep 工单 + 三件 done 机器校验(spec §功能行为 deploy-prep 变体)
685
- const target = locateDeployTarget(ctx, run);
686
- if (!target.entry) stopGateFail(ctx, run, s, ['找不到可上线的对象——workflow/{intents,incidents} 无终态(done/closed)入口;或以 --triage topic=<主题> 显式指定']);
687
- run.deployTarget = target;
688
- issueWO(ctx, run, wo(run, {
689
- kind: 'deploy-prep', title: `上线清单核对:${target.entry}`, goal: '回归清单人工核对 + 三件同名 done 机器校验,全过到授权点',
690
- instructions: [
691
- '1. 核对 workflow/regression-checklist.md 回归必过条目(活文档)',
692
- '2. 抽查最近历史 incident 的防复发条目',
693
- '3. 完成后回跑 next——脚本机器校验:check-loop 门 + 三件同名 done',
694
- '4. 全过停授权点;打 tag 由宿主按 git 纪律执行(脚本不代办)',
695
- ],
696
- context: { docPath: 'workflow/regression-checklist.md', kbHits: [], stderrTail: '', relatedDocs: [target.entry, target.spec, target.plan].filter(Boolean) },
697
- constraints: ['只读核对;发现缺口停机上报,不带病上线'],
698
- acceptance: ['check-loop 门 exit 0(脚本执行)', '三件同名 done:入口+spec(如有)+plan 全终态(脚本执行)'],
699
- }), 'deploy-prep');
700
- }
701
-
702
- if (s === 'deploy-prep') {
703
- const t = run.deployTarget;
704
- const r = runNode(ctx, run, 'check-loop.mjs', []);
705
- if (r.exit !== 0) stopGateFail(ctx, run, s, ['check-loop 未过——文档闭环有断档,先补齐再谈上线']);
706
- const gaps = [];
707
- const entrySt = docState(ctx, t.entry);
708
- if (!['done', 'closed'].includes(entrySt)) gaps.push(`${t.entry}(${entrySt || '缺失'}——须 done/closed)`);
709
- if (t.spec) {
710
- const st = docState(ctx, t.spec);
711
- if (st !== 'done') gaps.push(`${t.spec}(${st || '缺失'}——须 done)`);
712
- }
713
- const planSt = docState(ctx, t.plan);
714
- if (planSt !== 'done') gaps.push(`${t.plan}(${planSt || '缺失'}——须 done)`);
715
- if (gaps.length) stopGateFail(ctx, run, s, [`三件同名 done 未满足(spec §校验规则 deploy-prep 行):${gaps.join(';')}`]);
716
- run.stage = 'deploy-await';
717
- stopConfirm(ctx, run, '', `上线授权——对象 ${t.entry}(仅用户本人;tag 由宿主按 git 纪律执行,脚本不代办)`, false);
718
- }
719
-
720
- if (s === 'deploy-await') {
721
- if (!opt.delegated) stopConfirm(ctx, run, '', `上线授权——对象 ${run.deployTarget?.entry || ''}:用户明确说「上」后回跑 next --delegated "<原话>";打 tag 由宿主执行`, false);
722
- emit(run, { type: 'confirm', doc: 'deploy', to: 'authorized', source: 'conversation', quote: opt.delegated });
723
- stopDone(ctx, run);
724
- }
725
-
726
- if (s === 'done') stopDone(ctx, run);
727
- fail(`未知阶段:${s}(run 文件可能损坏——status --adopt 重建,或删 run 重来)`, 1);
728
- }
729
- }
730
-
731
- // ── 子命令 ─────────────────────────────────────────────────────────────
732
- const BOOL_FLAGS = new Set(['adopt', 'json', 'done']); // 复核 P2-5:布尔旗标不吞下一参
733
- function parseArgs(argv) {
734
- const out = { cmd: argv[0], positional: [] };
735
- for (let i = 1; i < argv.length; i++) {
736
- const a = argv[i];
737
- if (a.startsWith('--')) {
738
- const k = a.slice(2);
739
- if (BOOL_FLAGS.has(k)) out[k] = true; else out[k] = argv[++i] ?? true;
740
- } else out.positional.push(a);
741
- }
742
- return out;
743
- }
744
-
745
- function resolveRun(ctx, a) {
746
- const id = a.run || latestRunId(ctx);
747
- if (!id) fail('无活跃 run——先 start "<需求原文>"');
748
- const run = loadRun(ctx, id);
749
- if (!run) fail(`run 文件不存在或损坏:${id}(status --adopt 可按文档现状重建)`);
750
- return run;
751
- }
752
-
753
- const isMain = process.argv[1] && process.argv[1].endsWith('pipeline-run.mjs');
754
- if (isMain) {
755
- const a = parseArgs(process.argv.slice(2));
756
- const ctx = ctxEnv();
757
- const cmd = a.cmd;
758
-
759
- if (cmd === 'start') {
760
- const req = a.positional[0];
761
- if (!req) fail('start 必填需求原文:start "<需求>" [--hint "kind=… level=… module=…"]');
762
- const runId = newRunId(req);
763
- const run = {
764
- runId, requirement: req, hint: a.hint || '', createdAt: nowIso(), updatedAt: nowIso(),
765
- triage: null, stage: 'triage', stopType: 'work-order', workOrder: null, awaitConfirm: null,
766
- fixLoop: { count: 0, cap: FIX_CAP }, docs: { entry: null, spec: null, plan: null },
767
- lastKbHits: [], lastFiles: [], events: [],
768
- };
769
- emit(run, { type: 'run-created', requirement: req });
770
- saveRun(ctx, run);
771
- advance(ctx, run, {}); // 首停机点 = triage 工单
772
- } else if (cmd === 'next') {
773
- const run = resolveRun(ctx, a);
774
- if (run.stopType === 'done' || run.stopType === 'aborted') { printRun(ctx, run); process.exit(0); }
775
- advance(ctx, run, { triage: typeof a.triage === 'string' ? a.triage : undefined, delegated: typeof a.delegated === 'string' ? a.delegated : undefined, files: typeof a.files === 'string' ? a.files : undefined, done: a.done === true });
776
- } else if (cmd === 'status') {
777
- if (a.adopt) { adoptRun(ctx, a); process.exit(0); }
778
- const run = resolveRun(ctx, a);
779
- if (a.json) { console.log(JSON.stringify(run, null, 2)); process.exit(0); }
780
- printRun(ctx, run);
781
- console.log(`\n事件流水(${run.events.length}):`);
782
- for (const e of run.events) {
783
- const bits = [e.t.slice(11, 19), e.type];
784
- if (e.cmd) bits.push(`${e.cmd.slice(0, 70)}${e.exit !== 0 ? ` [exit ${e.exit}]` : ''}`);
785
- if (e.doc) bits.push(e.doc);
786
- if (e.quote) bits.push(`原话「${e.quote.slice(0, 30)}」`);
787
- if (e.subject) bits.push(e.subject.slice(0, 50));
788
- if (e.id) bits.push(`#${e.id}`);
789
- console.log(' ' + bits.join(' | '));
790
- }
791
- process.exit(0);
792
- } else if (cmd === 'watch') {
793
- const interval = Math.max(1, Number(a.interval) || 2);
794
- const render = () => {
795
- const id = a.run || latestRunId(ctx);
796
- console.log('\x1B[2J\x1B[H');
797
- if (!id) { console.log('无 run'); return; }
798
- const run = loadRun(ctx, id);
799
- if (!run) { console.log(`run ${id} 不存在`); return; }
800
- printRun(ctx, run);
801
- const recent = run.events.slice(-5);
802
- console.log('最近事件:');
803
- for (const e of recent) console.log(` ${e.t.slice(11, 19)} ${e.type} ${e.cmd ? e.cmd.slice(0, 50) : ''} ${e.exit !== undefined && e.type === 'gate' ? `exit=${e.exit}` : ''}`);
804
- console.log(`(每 ${interval}s 刷新,Ctrl+C 退出)`);
805
- };
806
- render();
807
- setInterval(render, interval * 1000);
808
- } else if (cmd === 'abort') {
809
- if (!a.run) fail('abort 必填 --run <id>');
810
- const run = loadRun(ctx, a.run);
811
- if (!run) fail(`run 不存在:${a.run}`);
812
- const to = a.to === true ? 'cancelled' : (a.to || 'cancelled');
813
- if (!['superseded', 'cancelled'].includes(to)) fail('--to 须为 superseded|cancelled');
814
- const manual = [];
815
- const flipped = [];
816
- for (const rel of [run.docs?.entry, run.docs?.spec, run.docs?.plan].filter(Boolean)) {
817
- const st = docState(ctx, rel);
818
- if (['approved'].includes(st)) {
819
- const r = confirmGate(ctx, run, rel, typeof a.delegated === 'string' ? a.delegated : '', to);
820
- if (r.ok) flipped.push(rel); else manual.push(rel);
821
- }
822
- }
823
- if (flipped.length) {
824
- runNode(ctx, run, 'gen-workflow-index.mjs', []); // 复核 P2-3:提交前重生成,防陈旧索引入库
825
- const c = docsCommit(ctx, run, [...flipped, 'workflow/INDEX.md'], `docs(workflow): ${run.triage?.topic || 'task'} 放弃——${to}`);
826
- if (!c.ok) console.log('⚠️ 放弃态 docs 提交失败(可手工补交)');
827
- }
828
- run.stopType = 'aborted';
829
- run.abort = { to, note: manual.length ? `以下文档须用户终端亲跑 confirm-doc --to ${to}:${manual.join('、')}` : '' };
830
- emit(run, { type: 'abort', to });
831
- saveRun(ctx, run);
832
- printRun(ctx, run);
833
- process.exit(0);
834
- } else {
835
- fail(`未知命令:${cmd ?? ''}(start | next | status | watch | abort,用法见文件头注释)`);
836
- }
837
- }
838
-
839
- // ── adopt:run 文件丢失/损坏时按文档现状重建(尽力而为,非权威仲裁) ──
840
- function adoptRun(ctx, a) {
841
- const id = a.run || latestRunId(ctx);
842
- if (!id) fail('无可 adopt 的 run id');
843
- const topic = (id.split('-').slice(2, -1).join('-')) || 'task';
844
- const find = (dir) => {
845
- const d = path.join(ctx.root, 'workflow', dir);
846
- if (!fs.existsSync(d)) return null;
847
- const hit = fs.readdirSync(d).map((f) => f.replace(/\.md$/, '')).filter((b) => b.includes(topic) && !b.startsWith('_'))
848
- .sort().pop();
849
- return hit ? `workflow/${dir}/${hit}.md` : null;
850
- };
851
- const entry = find('intents') || find('incidents');
852
- const spec = find('specs');
853
- const plan = find('plans');
854
- if (!entry && !plan) fail(`按 topic「${topic}」未找到任何 workflow 文档——无法重建`);
855
- const run = {
856
- runId: id, requirement: `(adopted ${nowIso()}——原需求原文已不可考,见 git 历史)`, hint: '', createdAt: nowIso(), updatedAt: nowIso(),
857
- triage: { kind: entry && entry.includes('incidents') ? 'fix' : 'require', level: 'L1', module: 'pipeline', topic, decidedBy: 'adopt', decidedAt: nowIso() },
858
- stage: 'adopted', stopType: 'work-order', workOrder: null, awaitConfirm: null, fixLoop: { count: 0, cap: FIX_CAP },
859
- docs: { entry, spec, plan }, lastKbHits: [], lastFiles: [], events: [{ t: nowIso(), type: 'adopt', entry, spec, plan }],
860
- };
861
- saveRun(ctx, run);
862
- console.log(`✅ 已重建 run ${id}(stage=adopted)——文档现状:`);
863
- for (const [k, rel] of Object.entries(run.docs)) if (rel) console.log(` ${k}: ${rel}(${docState(ctx, rel) || '缺失'})`);
864
- console.log(' 提示:adopt 不推断断点位置——按文档现状人工续走(next 会按 stage 拒绝,请对照事件缺失情况手动接续或另起 run)');
865
- }
866
-
867
- export default { parseKV, validateDraftContent, closeoutComplete, placeholdersIn, stageBar };