@mrciphersmith/keryx 0.2.9

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 (297) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +351 -0
  3. package/dist/cli.js +48427 -0
  4. package/dist/proxy-worker.js +381 -0
  5. package/package.json +63 -0
  6. package/src/gdgraph/affected.test.ts +100 -0
  7. package/src/gdgraph/affected.ts +135 -0
  8. package/src/gdgraph/build-integrity.test.ts +193 -0
  9. package/src/gdgraph/build-lang.test.ts +399 -0
  10. package/src/gdgraph/build.test.ts +120 -0
  11. package/src/gdgraph/build.ts +804 -0
  12. package/src/gdgraph/config.test.ts +47 -0
  13. package/src/gdgraph/config.ts +113 -0
  14. package/src/gdgraph/core-sources.test.ts +99 -0
  15. package/src/gdgraph/core-sources.ts +20 -0
  16. package/src/gdgraph/enrich.ts +79 -0
  17. package/src/gdgraph/fallback.test.ts +153 -0
  18. package/src/gdgraph/find.test.ts +78 -0
  19. package/src/gdgraph/find.ts +107 -0
  20. package/src/gdgraph/pagerank.ts +129 -0
  21. package/src/gdgraph/path.test.ts +56 -0
  22. package/src/gdgraph/path.ts +112 -0
  23. package/src/gdgraph/query.ts +133 -0
  24. package/src/gdgraph/repomap.test.ts +110 -0
  25. package/src/gdgraph/repomap.ts +193 -0
  26. package/src/gdgraph/service.test.ts +59 -0
  27. package/src/gdgraph/service.ts +51 -0
  28. package/src/gdgraph/staleness.ts +20 -0
  29. package/src/gdgraph/symbol.test.ts +89 -0
  30. package/src/gdgraph/symbol.ts +123 -0
  31. package/src/gdgraph/symbols-capability.test.ts +41 -0
  32. package/src/gdgraph/symbols-capability.ts +49 -0
  33. package/src/gdgraph/target.ts +56 -0
  34. package/src/gdgraph/treesitter/adapter.test.ts +249 -0
  35. package/src/gdgraph/treesitter/adapter.ts +213 -0
  36. package/src/gdgraph/treesitter/extract.test.ts +278 -0
  37. package/src/gdgraph/treesitter/extract.ts +389 -0
  38. package/src/gdgraph/treesitter/grammars.ts +110 -0
  39. package/src/gdgraph/treesitter/no-treesitter-import.test.ts +51 -0
  40. package/src/gdgraph/treesitter/resolve-calls.test.ts +38 -0
  41. package/src/gdgraph/types.ts +63 -0
  42. package/src/gdskills/bundled/rules/core/api-contracts.mdc +148 -0
  43. package/src/gdskills/bundled/rules/core/async-patterns.mdc +185 -0
  44. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +163 -0
  45. package/src/gdskills/bundled/rules/core/code-review-ai-assistant.mdc +49 -0
  46. package/src/gdskills/bundled/rules/core/code-review-b091-profile.mdc +48 -0
  47. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +54 -0
  48. package/src/gdskills/bundled/rules/core/commit-message-formatting.mdc +25 -0
  49. package/src/gdskills/bundled/rules/core/database-patterns.mdc +162 -0
  50. package/src/gdskills/bundled/rules/core/documentation-management.mdc +106 -0
  51. package/src/gdskills/bundled/rules/core/error-handling.mdc +163 -0
  52. package/src/gdskills/bundled/rules/core/execution-metrics.md +99 -0
  53. package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +40 -0
  54. package/src/gdskills/bundled/rules/core/git-rules.mdc +37 -0
  55. package/src/gdskills/bundled/rules/core/gproject-contracts.mdc +198 -0
  56. package/src/gdskills/bundled/rules/core/implementation-doc-mandate.mdc +149 -0
  57. package/src/gdskills/bundled/rules/core/implementation-plans.mdc +58 -0
  58. package/src/gdskills/bundled/rules/core/jobs-documentation.mdc +221 -0
  59. package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +561 -0
  60. package/src/gdskills/bundled/rules/core/model-selection.mdc +53 -0
  61. package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +50 -0
  62. package/src/gdskills/bundled/rules/core/playwright-testing.mdc +321 -0
  63. package/src/gdskills/bundled/rules/core/requirements-management.mdc +35 -0
  64. package/src/gdskills/bundled/rules/core/requirements-package-standard.mdc +103 -0
  65. package/src/gdskills/bundled/rules/core/review-agent-profile.mdc +49 -0
  66. package/src/gdskills/bundled/rules/core/review-strict-profile.mdc +44 -0
  67. package/src/gdskills/bundled/rules/core/rule-management-workflow.mdc +62 -0
  68. package/src/gdskills/bundled/rules/core/security-baseline.mdc +155 -0
  69. package/src/gdskills/bundled/rules/core/shared-definitions.mdc +79 -0
  70. package/src/gdskills/bundled/rules/core/skill-lifecycle.mdc +55 -0
  71. package/src/gdskills/bundled/rules/core/skills-storage-workflow.mdc +88 -0
  72. package/src/gdskills/bundled/rules/core/solid-principles.mdc +149 -0
  73. package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +36 -0
  74. package/src/gdskills/bundled/rules/core/subagent-context-construction.md +107 -0
  75. package/src/gdskills/bundled/rules/core/subagent-status-protocol.md +169 -0
  76. package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +96 -0
  77. package/src/gdskills/bundled/skills/orchestration/code-verifier/SKILL.codex.md +47 -0
  78. package/src/gdskills/bundled/skills/orchestration/code-verifier/SKILL.cursor.md +55 -0
  79. package/src/gdskills/bundled/skills/orchestration/code-verifier/SKILL.md +352 -0
  80. package/src/gdskills/bundled/skills/orchestration/code-verifier/SKILL.opencode.md +39 -0
  81. package/src/gdskills/bundled/skills/orchestration/code-verifier/SKILL.zed.md +29 -0
  82. package/src/gdskills/bundled/skills/orchestration/context-collector/SKILL.codex.md +567 -0
  83. package/src/gdskills/bundled/skills/orchestration/context-collector/SKILL.cursor.md +567 -0
  84. package/src/gdskills/bundled/skills/orchestration/context-collector/SKILL.md +655 -0
  85. package/src/gdskills/bundled/skills/orchestration/context-collector/SKILL.opencode.md +567 -0
  86. package/src/gdskills/bundled/skills/orchestration/context-collector/SKILL.zed.md +567 -0
  87. package/src/gdskills/bundled/skills/orchestration/context-collector/input-contract.schema.json +134 -0
  88. package/src/gdskills/bundled/skills/orchestration/context-collector/orchestrator-prompt.md +183 -0
  89. package/src/gdskills/bundled/skills/orchestration/context-collector/output-contract.schema.json +208 -0
  90. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/SKILL.codex.md +1412 -0
  91. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/SKILL.cursor.md +1412 -0
  92. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/SKILL.detail.md +735 -0
  93. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/SKILL.md +468 -0
  94. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/SKILL.opencode.md +1412 -0
  95. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/SKILL.zed.md +1412 -0
  96. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/analysis-request.md +62 -0
  97. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/analysis-request.template.md +79 -0
  98. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/input-contract.schema.json +247 -0
  99. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/orchestrator-prompt.md +362 -0
  100. package/src/gdskills/bundled/skills/orchestration/feature-analyzer/output-contract.schema.json +87 -0
  101. package/src/gdskills/bundled/skills/orchestration/feature-dev/SKILL.codex.md +105 -0
  102. package/src/gdskills/bundled/skills/orchestration/feature-dev/SKILL.cursor.md +105 -0
  103. package/src/gdskills/bundled/skills/orchestration/feature-dev/SKILL.md +165 -0
  104. package/src/gdskills/bundled/skills/orchestration/flow-orchestrator/SKILL.md +379 -0
  105. package/src/gdskills/bundled/skills/orchestration/flow-orchestrator/input-contract.schema.json +33 -0
  106. package/src/gdskills/bundled/skills/orchestration/flow-orchestrator/output-contract.schema.json +41 -0
  107. package/src/gdskills/bundled/skills/orchestration/issue-analyzer/SKILL.codex.md +307 -0
  108. package/src/gdskills/bundled/skills/orchestration/issue-analyzer/SKILL.cursor.md +307 -0
  109. package/src/gdskills/bundled/skills/orchestration/issue-analyzer/SKILL.md +373 -0
  110. package/src/gdskills/bundled/skills/orchestration/issue-analyzer/SKILL.opencode.md +307 -0
  111. package/src/gdskills/bundled/skills/orchestration/issue-analyzer/SKILL.zed.md +307 -0
  112. package/src/gdskills/bundled/skills/orchestration/issue-analyzer/input-contract.schema.json +130 -0
  113. package/src/gdskills/bundled/skills/orchestration/issue-analyzer/issue-request.template.md +50 -0
  114. package/src/gdskills/bundled/skills/orchestration/issue-analyzer/orchestrator-prompt.md +155 -0
  115. package/src/gdskills/bundled/skills/orchestration/issue-analyzer/output-contract.schema.json +61 -0
  116. package/src/gdskills/bundled/skills/orchestration/job-documenter/SKILL.codex.md +365 -0
  117. package/src/gdskills/bundled/skills/orchestration/job-documenter/SKILL.cursor.md +365 -0
  118. package/src/gdskills/bundled/skills/orchestration/job-documenter/SKILL.md +373 -0
  119. package/src/gdskills/bundled/skills/orchestration/job-documenter/SKILL.opencode.md +365 -0
  120. package/src/gdskills/bundled/skills/orchestration/job-documenter/SKILL.zed.md +365 -0
  121. package/src/gdskills/bundled/skills/orchestration/job-documenter/input-contract.schema.json +55 -0
  122. package/src/gdskills/bundled/skills/orchestration/job-documenter/output-contract.schema.json +58 -0
  123. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/SKILL.codex.md +1701 -0
  124. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/SKILL.cursor.md +1701 -0
  125. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/SKILL.md +1734 -0
  126. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/SKILL.opencode.md +1701 -0
  127. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/SKILL.zed.md +1701 -0
  128. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/input-contract.schema.json +188 -0
  129. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/orchestrator-prompt.md +179 -0
  130. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/output-contract.schema.json +103 -0
  131. package/src/gdskills/bundled/skills/orchestration/job-orchestrator/state.schema.json +164 -0
  132. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.codex.md +395 -0
  133. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.cursor.md +395 -0
  134. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.md +556 -0
  135. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.opencode.md +395 -0
  136. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.zed.md +395 -0
  137. package/src/gdskills/bundled/skills/orchestration/task-implementer/input-contract.schema.json +204 -0
  138. package/src/gdskills/bundled/skills/orchestration/task-implementer/orchestrator-prompt.md +206 -0
  139. package/src/gdskills/bundled/skills/orchestration/task-implementer/output-contract.schema.json +51 -0
  140. package/src/gdskills/bundled/skills/orchestration/task-implementer/task-request.template.md +111 -0
  141. package/src/gdskills/bundled/skills/planning/autodoc-analyst/SKILL.md +163 -0
  142. package/src/gdskills/bundled/skills/planning/autodoc-architect/SKILL.md +161 -0
  143. package/src/gdskills/bundled/skills/planning/autodoc-assembler/SKILL.md +128 -0
  144. package/src/gdskills/bundled/skills/planning/autodoc-orchestrator/SKILL.md +321 -0
  145. package/src/gdskills/bundled/skills/planning/autodoc-scanner/SKILL.md +166 -0
  146. package/src/gdskills/bundled/skills/planning/autodoc-writer/SKILL.md +253 -0
  147. package/src/gdskills/bundled/skills/planning/brainstorm/SKILL.claude.md +46 -0
  148. package/src/gdskills/bundled/skills/planning/brainstorm/SKILL.codex.md +90 -0
  149. package/src/gdskills/bundled/skills/planning/brainstorm/SKILL.cursor.md +90 -0
  150. package/src/gdskills/bundled/skills/planning/brainstorm/SKILL.md +90 -0
  151. package/src/gdskills/bundled/skills/planning/consistency-checker/SKILL.codex.md +33 -0
  152. package/src/gdskills/bundled/skills/planning/consistency-checker/SKILL.cursor.md +33 -0
  153. package/src/gdskills/bundled/skills/planning/consistency-checker/SKILL.md +190 -0
  154. package/src/gdskills/bundled/skills/planning/docpack-orchestrator/SKILL.md +142 -0
  155. package/src/gdskills/bundled/skills/planning/docpack-orchestrator/input-contract.schema.json +31 -0
  156. package/src/gdskills/bundled/skills/planning/docpack-orchestrator/output-contract.schema.json +31 -0
  157. package/src/gdskills/bundled/skills/planning/docpack-review/SKILL.md +80 -0
  158. package/src/gdskills/bundled/skills/planning/docpack-review/input-contract.schema.json +20 -0
  159. package/src/gdskills/bundled/skills/planning/docpack-review/output-contract.schema.json +36 -0
  160. package/src/gdskills/bundled/skills/planning/interview/SKILL.codex.md +181 -0
  161. package/src/gdskills/bundled/skills/planning/interview/SKILL.cursor.md +181 -0
  162. package/src/gdskills/bundled/skills/planning/interview/SKILL.md +187 -0
  163. package/src/gdskills/bundled/skills/planning/interviewer/SKILL.claude.md +94 -0
  164. package/src/gdskills/bundled/skills/planning/interviewer/SKILL.codex.md +99 -0
  165. package/src/gdskills/bundled/skills/planning/interviewer/SKILL.cursor.md +99 -0
  166. package/src/gdskills/bundled/skills/planning/interviewer/SKILL.md +105 -0
  167. package/src/gdskills/bundled/skills/planning/patterns-researcher/SKILL.codex.md +33 -0
  168. package/src/gdskills/bundled/skills/planning/patterns-researcher/SKILL.cursor.md +33 -0
  169. package/src/gdskills/bundled/skills/planning/patterns-researcher/SKILL.md +237 -0
  170. package/src/gdskills/bundled/skills/planning/planner/SKILL.codex.md +33 -0
  171. package/src/gdskills/bundled/skills/planning/planner/SKILL.cursor.md +33 -0
  172. package/src/gdskills/bundled/skills/planning/planner/SKILL.md +190 -0
  173. package/src/gdskills/bundled/skills/planning/prd-creator/SKILL.codex.md +193 -0
  174. package/src/gdskills/bundled/skills/planning/prd-creator/SKILL.cursor.md +193 -0
  175. package/src/gdskills/bundled/skills/planning/prd-creator/SKILL.md +193 -0
  176. package/src/gdskills/bundled/skills/planning/prd-creator/SKILL.opencode.md +193 -0
  177. package/src/gdskills/bundled/skills/planning/prd-creator/SKILL.zed.md +193 -0
  178. package/src/gdskills/bundled/skills/planning/prd-creator/input-contract.schema.json +63 -0
  179. package/src/gdskills/bundled/skills/planning/prd-creator/output-contract.schema.json +175 -0
  180. package/src/gdskills/bundled/skills/planning/problem-definer/SKILL.codex.md +31 -0
  181. package/src/gdskills/bundled/skills/planning/problem-definer/SKILL.cursor.md +31 -0
  182. package/src/gdskills/bundled/skills/planning/problem-definer/SKILL.md +153 -0
  183. package/src/gdskills/bundled/skills/planning/project-discovery/SKILL.codex.md +32 -0
  184. package/src/gdskills/bundled/skills/planning/project-discovery/SKILL.cursor.md +32 -0
  185. package/src/gdskills/bundled/skills/planning/project-discovery/SKILL.md +166 -0
  186. package/src/gdskills/bundled/skills/planning/spec-writer/SKILL.codex.md +44 -0
  187. package/src/gdskills/bundled/skills/planning/spec-writer/SKILL.cursor.md +44 -0
  188. package/src/gdskills/bundled/skills/planning/spec-writer/SKILL.md +243 -0
  189. package/src/gdskills/bundled/skills/planning/stack-advisor/SKILL.codex.md +43 -0
  190. package/src/gdskills/bundled/skills/planning/stack-advisor/SKILL.cursor.md +43 -0
  191. package/src/gdskills/bundled/skills/planning/stack-advisor/SKILL.md +193 -0
  192. package/src/gdskills/bundled/skills/platform/agent-entrypoint-distiller/SKILL.md +47 -0
  193. package/src/gdskills/bundled/skills/platform/claude-md-management/SKILL.codex.md +87 -0
  194. package/src/gdskills/bundled/skills/platform/claude-md-management/SKILL.cursor.md +87 -0
  195. package/src/gdskills/bundled/skills/platform/claude-md-management/SKILL.md +87 -0
  196. package/src/gdskills/bundled/skills/platform/hookify/SKILL.codex.md +100 -0
  197. package/src/gdskills/bundled/skills/platform/hookify/SKILL.cursor.md +100 -0
  198. package/src/gdskills/bundled/skills/platform/hookify/SKILL.md +100 -0
  199. package/src/gdskills/bundled/skills/quality/changelog/SKILL.claude.md +45 -0
  200. package/src/gdskills/bundled/skills/quality/changelog/SKILL.codex.md +84 -0
  201. package/src/gdskills/bundled/skills/quality/changelog/SKILL.cursor.md +84 -0
  202. package/src/gdskills/bundled/skills/quality/changelog/SKILL.md +84 -0
  203. package/src/gdskills/bundled/skills/quality/commit/SKILL.codex.md +66 -0
  204. package/src/gdskills/bundled/skills/quality/commit/SKILL.cursor.md +66 -0
  205. package/src/gdskills/bundled/skills/quality/commit/SKILL.md +66 -0
  206. package/src/gdskills/bundled/skills/quality/db-migrate/SKILL.claude.md +40 -0
  207. package/src/gdskills/bundled/skills/quality/db-migrate/SKILL.codex.md +66 -0
  208. package/src/gdskills/bundled/skills/quality/db-migrate/SKILL.cursor.md +66 -0
  209. package/src/gdskills/bundled/skills/quality/db-migrate/SKILL.md +66 -0
  210. package/src/gdskills/bundled/skills/quality/dependency-update/SKILL.claude.md +45 -0
  211. package/src/gdskills/bundled/skills/quality/dependency-update/SKILL.codex.md +81 -0
  212. package/src/gdskills/bundled/skills/quality/dependency-update/SKILL.cursor.md +81 -0
  213. package/src/gdskills/bundled/skills/quality/dependency-update/SKILL.md +81 -0
  214. package/src/gdskills/bundled/skills/quality/deploy/SKILL.claude.md +42 -0
  215. package/src/gdskills/bundled/skills/quality/deploy/SKILL.codex.md +70 -0
  216. package/src/gdskills/bundled/skills/quality/deploy/SKILL.cursor.md +70 -0
  217. package/src/gdskills/bundled/skills/quality/deploy/SKILL.md +70 -0
  218. package/src/gdskills/bundled/skills/quality/metaproject-security/SKILL.md +103 -0
  219. package/src/gdskills/bundled/skills/quality/perf-check/SKILL.claude.md +48 -0
  220. package/src/gdskills/bundled/skills/quality/perf-check/SKILL.codex.md +83 -0
  221. package/src/gdskills/bundled/skills/quality/perf-check/SKILL.cursor.md +83 -0
  222. package/src/gdskills/bundled/skills/quality/perf-check/SKILL.md +83 -0
  223. package/src/gdskills/bundled/skills/quality/pr/SKILL.codex.md +75 -0
  224. package/src/gdskills/bundled/skills/quality/pr/SKILL.cursor.md +75 -0
  225. package/src/gdskills/bundled/skills/quality/pr/SKILL.md +75 -0
  226. package/src/gdskills/bundled/skills/quality/pr-issue-documenter/SKILL.codex.md +364 -0
  227. package/src/gdskills/bundled/skills/quality/pr-issue-documenter/SKILL.cursor.md +295 -0
  228. package/src/gdskills/bundled/skills/quality/pr-issue-documenter/SKILL.md +378 -0
  229. package/src/gdskills/bundled/skills/quality/pr-issue-documenter/SKILL.opencode.md +364 -0
  230. package/src/gdskills/bundled/skills/quality/pr-issue-documenter/SKILL.zed.md +38 -0
  231. package/src/gdskills/bundled/skills/quality/pr-issue-documenter/input-contract.schema.json +53 -0
  232. package/src/gdskills/bundled/skills/quality/pr-issue-documenter/output-contract.schema.json +46 -0
  233. package/src/gdskills/bundled/skills/quality/push/SKILL.codex.md +52 -0
  234. package/src/gdskills/bundled/skills/quality/push/SKILL.cursor.md +52 -0
  235. package/src/gdskills/bundled/skills/quality/push/SKILL.md +52 -0
  236. package/src/gdskills/bundled/skills/quality/security-audit/SKILL.claude.md +40 -0
  237. package/src/gdskills/bundled/skills/quality/security-audit/SKILL.codex.md +61 -0
  238. package/src/gdskills/bundled/skills/quality/security-audit/SKILL.cursor.md +61 -0
  239. package/src/gdskills/bundled/skills/quality/security-audit/SKILL.md +61 -0
  240. package/src/gdskills/bundled/skills/quality/test-gen/SKILL.claude.md +30 -0
  241. package/src/gdskills/bundled/skills/quality/test-gen/SKILL.codex.md +75 -0
  242. package/src/gdskills/bundled/skills/quality/test-gen/SKILL.cursor.md +75 -0
  243. package/src/gdskills/bundled/skills/quality/test-gen/SKILL.md +75 -0
  244. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.codex.md +64 -0
  245. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.cursor.md +74 -0
  246. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.md +339 -0
  247. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.opencode.md +48 -0
  248. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.zed.md +44 -0
  249. package/src/gdskills/bundled/skills/quality/tests-creator/input-contract.schema.json +121 -0
  250. package/src/gdskills/bundled/skills/quality/tests-creator/output-contract.schema.json +127 -0
  251. package/src/gdskills/bundled/skills/review/code-ai-review/SKILL.codex.md +204 -0
  252. package/src/gdskills/bundled/skills/review/code-ai-review/SKILL.cursor.md +204 -0
  253. package/src/gdskills/bundled/skills/review/code-ai-review/SKILL.md +203 -0
  254. package/src/gdskills/bundled/skills/review/code-ai-review/SKILL.opencode.md +204 -0
  255. package/src/gdskills/bundled/skills/review/code-ai-review/SKILL.zed.md +204 -0
  256. package/src/gdskills/bundled/skills/review/code-b091-review/SKILL.codex.md +209 -0
  257. package/src/gdskills/bundled/skills/review/code-b091-review/SKILL.cursor.md +209 -0
  258. package/src/gdskills/bundled/skills/review/code-b091-review/SKILL.md +208 -0
  259. package/src/gdskills/bundled/skills/review/code-b091-review/SKILL.opencode.md +209 -0
  260. package/src/gdskills/bundled/skills/review/code-b091-review/SKILL.zed.md +209 -0
  261. package/src/gdskills/bundled/skills/review/code-mobx-store-review/SKILL.codex.md +263 -0
  262. package/src/gdskills/bundled/skills/review/code-mobx-store-review/SKILL.cursor.md +263 -0
  263. package/src/gdskills/bundled/skills/review/code-mobx-store-review/SKILL.md +258 -0
  264. package/src/gdskills/bundled/skills/review/code-mobx-store-review/SKILL.opencode.md +263 -0
  265. package/src/gdskills/bundled/skills/review/code-mobx-store-review/SKILL.zed.md +263 -0
  266. package/src/gdskills/bundled/skills/review/code-style-review/SKILL.codex.md +175 -0
  267. package/src/gdskills/bundled/skills/review/code-style-review/SKILL.cursor.md +175 -0
  268. package/src/gdskills/bundled/skills/review/code-style-review/SKILL.md +168 -0
  269. package/src/gdskills/bundled/skills/review/code-style-review/SKILL.opencode.md +175 -0
  270. package/src/gdskills/bundled/skills/review/code-style-review/SKILL.zed.md +175 -0
  271. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +360 -0
  272. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +337 -0
  273. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +477 -0
  274. package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +93 -0
  275. package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +119 -0
  276. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +595 -0
  277. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +144 -0
  278. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +519 -0
  279. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +323 -0
  280. package/src/gdskills/bundled/skills/review/review-orchestrator/SKILL.md +927 -0
  281. package/src/gdskills/bundled/skills/review/review-orchestrator/input-contract.schema.json +153 -0
  282. package/src/gdskills/bundled/skills/review/review-orchestrator/output-contract.schema.json +77 -0
  283. package/src/gdskills/bundled/skills/review/review-orchestrator/review-context.schema.json +389 -0
  284. package/src/gdskills/bundled/skills/review/review-orchestrator/reviewer-finding.schema.json +189 -0
  285. package/src/gdskills/bundled/skills/review/review-orchestrator/reviewer-input.schema.json +241 -0
  286. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +344 -0
  287. package/src/gdskills/bundled/skills/review/review-pr-feedback/SKILL.md +327 -0
  288. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +348 -0
  289. package/src/gdskills/bundled/skills/review/review-strict/SKILL.md +328 -0
  290. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +343 -0
  291. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +134 -0
  292. package/src/gdskills/bundled/skills/shared/git-merge-base.md +33 -0
  293. package/src/gdskills/contracts/agent-event.schema.json +32 -0
  294. package/src/gdskills/contracts/orchestrator-state.schema.json +58 -0
  295. package/src/gdskills/contracts/review-finding.schema.json +59 -0
  296. package/src/gdskills/contracts/subagent-dispatch.schema.json +123 -0
  297. package/src/gdskills/contracts/subagent-result.schema.json +136 -0
@@ -0,0 +1,1734 @@
1
+ ---
2
+ name: job-orchestrator
3
+ description: "Use when a GitHub issue or complex intent needs to be analyzed, planned, and implemented end-to-end with sub-agents."
4
+ triggers:
5
+ - "Implement issue"
6
+ - "Issue to PR"
7
+ - "Orchestrate"
8
+ - "Run pipeline"
9
+ - "Analyze and implement"
10
+ - "Full implementation"
11
+ - "Full review"
12
+ - "Полное ревью"
13
+ - "Review my code"
14
+ - "Analyze branch"
15
+ - "Review via orchestrator"
16
+ - "Orchestrated review"
17
+ - "Auto-implement"
18
+ - "Auto-implement issue"
19
+ - "Orchestrate issue"
20
+ - "Run issue pipeline"
21
+ - "Full issue implementation"
22
+ metadata:
23
+ author: "MrCipherSmith"
24
+ version: "3.2.0"
25
+ category: "orchestration"
26
+ license: "MIT"
27
+ compatibility: "cursor,codex,zed,opencode,claude"
28
+ ---
29
+
30
+ <SUBAGENT-STOP>
31
+ If you were dispatched as a subagent to execute a specific task, skip this skill entirely.
32
+ This skill is for orchestrators and interactive session-level routing only.
33
+ Proceed directly with your assigned task.
34
+ </SUBAGENT-STOP>
35
+
36
+ # Job Orchestrator
37
+
38
+ ## Purpose
39
+
40
+ Dynamic orchestrator that builds execution plans based on user intent. Unlike a fixed pipeline, the orchestrator adapts its workflow to what the user actually needs — from "just analyze this issue" to "implement, review, and create a PR". It dispatches sub-agents (`issue-analyzer`, `context-collector`, `task-implementer`, review skills) and persists all work via `job-documenter`.
41
+
42
+ **Execution metrics (opt-in):** when a USER runs this orchestrator directly (not as a dispatched subagent), at the start ask "Collect execution statistics for this run? (yes/no)" per `.metaproject/rules/core/execution-metrics.md`. If yes, append the `## Execution Metrics` section at the end and save it under the job dir (`jobs/<job>/metrics/`). Never ask or emit it when dispatched as a subagent.
43
+
44
+ **Key design principle** (from Anthropic's "Building Effective Agents"):
45
+ > "The key difference from parallelization is its flexibility — subtasks aren't pre-defined, but determined by the orchestrator based on the specific input."
46
+
47
+ **Input:** User request (issue URL, analysis request, implementation request, etc.)
48
+ **Output:** Executed plan + persistent job documentation in `.metaproject/jobs/<job-name>/` + optional PR
49
+
50
+ ## When to Use
51
+
52
+ - Implementing a complete GitHub issue from start to finish
53
+ - Analyzing an issue and proposing a solution before implementing
54
+ - Running any multi-step orchestrated workflow
55
+ - Running a comprehensive code review with persistent documentation
56
+ - When the AGENTS.md routing rule (Step 1.5) determines the user wants orchestrated execution and the user confirms
57
+ - User says "implement issue #N", "analyze issue #N", provides an issue URL, or asks for orchestrated work
58
+ - User says "full review", "полное ревью", or any request that implies orchestration
59
+
60
+ ## Architecture: 4 Dynamic Phases
61
+
62
+ ```
63
+ Phase 0: CONTEXT COLLECTION → Gather info, determine intent
64
+ Phase 1: PLAN BUILDING → Build dynamic plan, init job docs
65
+ Phase 2: EXECUTION → Execute plan steps, document each result
66
+ Phase 3: COMPLETION → Final report, optional PR, tell user where docs are
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Phase 0: CONTEXT COLLECTION
72
+
73
+ ### 0.0 State Resumption Check
74
+
75
+ Before asking any questions, check if an interrupted job exists:
76
+ 1. Look in `$JOBS_ROOT` for any directory containing an incomplete `state.json`.
77
+ 2. If found, ASK the user: "Found paused job '<job-name>'. Do you want to resume it or start a new orchestrated job?"
78
+ 3. If resume → Parse `state.json`, restore `JOB_STATE`, and jump directly to the first uncompleted step in Phase 2.
79
+ 4. If new → Proceed to 0.1.
80
+
81
+ ### 0.1 Determine User Intent
82
+
83
+ Parse the user's request to identify the intent:
84
+
85
+ | User Says | Intent | Plan Type |
86
+ |-----------|--------|-----------|
87
+ | "Implement issue #N" / "Issue to PR" | `implement` | Full: analyze → branch → implement → review → fix → checks → PR |
88
+ | "Analyze issue #N" / "Study issue" | `analyze` | Analysis only: analyze → report. Then ask if user wants to implement. |
89
+ | "Review my code" / "Review branch" | `review` | Review only: review → report |
90
+ | "Analyze and implement" | `implement` | Same as implement |
91
+ | Custom request | `custom` | Run `interviewer` skill first, then build plan from output |
92
+
93
+ **Ambiguity detection:** If the request uses vague words ("improve", "fix", "refactor") with no issue number or specific file — trigger the **Interactive Approach Selection** below.
94
+
95
+ ### 0.1.1 Interactive Approach Selection (for ambiguous requests)
96
+
97
+ When intent cannot be determined confidently, present options to the user:
98
+
99
+ ```
100
+ I see several ways to approach this. Which fits best?
101
+
102
+ A) 🔍 Analysis only — decompose into tasks, show plan, stop
103
+ B) 🛠 Full implementation — analyze → implement → review → PR
104
+ C) 📋 Analysis + brainstorm — explore approaches before committing
105
+ D) 🔧 Review only — review current branch changes
106
+ E) 📝 Custom — describe what you need, I'll build the plan
107
+
108
+ > pick a letter or describe your own approach
109
+ ```
110
+
111
+ **Mapping:**
112
+ - A → `analyze` intent
113
+ - B → `implement` intent
114
+ - C → `analyze` intent + trigger `brainstorm` after analysis
115
+ - D → `review` intent
116
+ - E → `custom` intent → proceed to 0.1.5 (interviewer gate)
117
+
118
+ **Skip this step** when intent is clear (explicit issue number, "implement issue #N", "review my code").
119
+
120
+ ### 0.1.5 Interviewer Gate (for `custom` and ambiguous requests)
121
+
122
+ For `custom` intent OR any ambiguous request, invoke the `interviewer` skill **before** collecting standard context. This replaces the generic "What do you need?" question with a structured critical interview.
123
+
124
+ **Invoke:**
125
+ ```
126
+ Load skill: skills/interviewer/SKILL.md
127
+
128
+ INPUT:
129
+ topic: <user's original request>
130
+ goal: "job-orchestrator — build execution plan"
131
+ context:
132
+ codebase_summary: <git log --oneline -10 if available>
133
+ existing_analysis: <any issue content already known>
134
+ ```
135
+
136
+ **Map output:**
137
+ - `derived_context` → `INTENT_STATE.task_description`
138
+ - answers with `confidence: "certain"` → `INTENT_STATE.constraints`
139
+ - `blockers` → surface to user (if non-empty, do NOT proceed)
140
+
141
+ **Gate rule:**
142
+ - `ready_to_proceed: false` → STOP. Tell user what blockers remain.
143
+ - `ready_to_proceed: true` → continue to 0.2 with enriched context.
144
+
145
+ **Skip** for `implement`/`analyze` with an issue number — requirements are in the issue.
146
+
147
+ ### 0.2 Collect Required Context
148
+
149
+ The orchestrator MUST collect all required context before proceeding:
150
+
151
+ **Always ask (mandatory):**
152
+
153
+ 1. **What to do** — for `implement`/`analyze`: from issue. For `custom`: from interviewer output (0.1.5).
154
+
155
+ 2. **Project directory** — NEVER assume. Always ask explicitly:
156
+ ```
157
+ Which project directory should I use?
158
+ ○ Type the full absolute path to your project
159
+ (No default — always ask, never assume.)
160
+ ```
161
+
162
+ 3. **Base branch** — auto-detect from repo:
163
+ ```bash
164
+ # Detect default branch
165
+ git -C <project_dir> symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'
166
+ # Fallback: check for main, master, develop
167
+ ```
168
+ Present detected branch and ask to confirm. No hardcoded default.
169
+
170
+ **Intent-specific questions:**
171
+
172
+ | Intent | Additional Questions |
173
+ |--------|---------------------|
174
+ | `implement` | Create PR? (default: yes). Skip if user already stated. |
175
+ | `analyze` | None — always produced. After: ask if user wants to implement. |
176
+ | `review` | Which branch to review? (default: current branch) |
177
+ | `custom` | None — covered by interviewer in 0.1.5 |
178
+
179
+ 4. **Job name** — auto-generate based on context, ask user to confirm:
180
+ ```
181
+ Job documentation folder:
182
+ ○ issue-4141--pipeline-validation (auto-generated, Recommended)
183
+ ○ Type your own name
184
+ ```
185
+
186
+ **Naming patterns:**
187
+ - Issue implementation: `issue-<N>--<slug>`
188
+ - Issue analysis: `analysis--issue-<N>`
189
+ - Code review: `review--<slug>`
190
+ - Custom: `task--<slug>`
191
+
192
+ ### 0.3 Interview for Implement Intent
193
+
194
+ For `implement` intent, dispatch `interview` skill after collecting context to clarify implementation-specific ambiguities (complements 0.1.5 which handles `custom` intent):
195
+
196
+ ```
197
+ Dispatch interview skill with:
198
+ {
199
+ "goal": <issue title>,
200
+ "context": <collected context + issue body>,
201
+ "domain": "implement",
202
+ "caller": "job-orchestrator",
203
+ "known_facts": [project_dir, base_branch, issue details],
204
+ "max_questions": null
205
+ }
206
+ ```
207
+
208
+ **When to run:** `implement` intent only (if `run_interview: true`, default).
209
+ **Skip for:** `analyze` (analysis reveals details), `review` (scoped by diff), `custom` (covered by 0.1.5).
210
+
211
+ **Output → Phase 1:** `INTERVIEW_RESULT` feeds into plan building — informs task decomposition and architecture.
212
+
213
+ **Brainstorm trigger:** If during interview the user answers "not sure" or the interview identifies an unresolved architectural question (high-impact decision with no clear answer), auto-trigger:
214
+ ```
215
+ Dispatch brainstorm --quick with:
216
+ topic: <the specific architectural question>
217
+ context: <project stack + interview answers so far>
218
+ ```
219
+ Present brainstorm result as enriched answer options, then continue interview.
220
+
221
+ **Skip if:** user says "just do it" / "skip questions", or `run_interview: false`.
222
+
223
+ ### 0.3.1 Dependency Check
224
+
225
+ If the issue or interview reveals the task is primarily about updating dependencies:
226
+ ```
227
+ IF issue title/body contains "update", "upgrade", "bump", "dependency", "CVE":
228
+ Suggest: "This looks like a dependency update task. Use /dependency-update instead?"
229
+ IF user confirms → delegate to dependency-update skill, skip orchestrator pipeline
230
+ ```
231
+
232
+ ### 0.4 Summarize and Confirm
233
+
234
+ Before proceeding, present a summary:
235
+
236
+ ```
237
+ Ready to proceed:
238
+ Intent: implement
239
+ Issue: #4141 — Pipeline validation improvements
240
+ Project: /Users/.../<PROJECT>
241
+ Base: develop-2
242
+ Create PR: yes
243
+ Job name: issue-4141--pipeline-validation
244
+
245
+ Proceed? (yes / adjust)
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Phase 1: PLAN BUILDING
251
+
252
+ ### 1.1 Build Execution Plan
253
+
254
+ Based on intent, construct an ordered list of steps:
255
+
256
+ **For `implement` intent:**
257
+ ```
258
+ PLAN:
259
+ 1. { id: "analyze", type: "analyze", agent: "issue-analyzer", depends: [] }
260
+ 2. { id: "context", type: "context", agent: "context-collector", depends: ["analyze"] }
261
+ 3. { id: "prepare", type: "prepare", agent: "orchestrator", depends: ["context"] }
262
+ 4. { id: "tests-creator", type: "tests", agent: "tests-creator", depends: ["prepare"] }
263
+ 5. { id: "implement", type: "implement", agent: "task-implementer", depends: ["tests-creator"] }
264
+ 6. { id: "sanity-check", type: "check", agent: "orchestrator", depends: ["implement"] }
265
+ 7. { id: "verify", type: "verify", agent: "code-verifier", depends: ["sanity-check"] }
266
+ 8. { id: "review", type: "review", agent: "code-review", depends: ["verify"] }
267
+ 9. { id: "security", type: "security", agent: "security-audit", depends: ["implement"], conditional: true }
268
+ 10. { id: "fix", type: "fix", agent: "task-implementer", depends: ["review"], conditional: true }
269
+ 11. { id: "verify-post-fix", type: "verify", agent: "code-verifier", depends: ["fix"], conditional: true }
270
+ 12. { id: "perf-check", type: "perf", agent: "perf-check", depends: ["verify"], conditional: true }
271
+ 13. { id: "report", type: "report", agent: "orchestrator", depends: ["verify"] }
272
+ 14. { id: "pr", type: "pr", agent: "orchestrator", depends: ["report"], conditional: true }
273
+ 15. { id: "deploy", type: "deploy", agent: "deploy", depends: ["pr"], conditional: true }
274
+ ```
275
+
276
+ **Conditional step triggers:**
277
+ - `sanity-check`: always runs — verifies ≥1 commit was made
278
+ - `tests-creator`: always runs — mandatory TDD step before every task-implementer wave
279
+ - `verify`: always runs — code-verifier is the mandatory quality gate after implementation
280
+ - `security`: diff touches auth/, api/, migrations, schema files, or `.env`
281
+ - `fix`: review or verify found CRITICAL/HIGH findings
282
+ - `verify-post-fix`: always runs after fix (confirms fix resolved the findings)
283
+ - `perf-check`: diff contains *.tsx, *.jsx, *.css, dist/, build/ files
284
+ - `security`: diff touches auth/, api/, migrations, schema files, or `.env`
285
+ - `fix`: review found CRITICAL/WARNING findings
286
+ - `perf-check`: diff contains *.tsx, *.jsx, *.css, dist/, build/ files
287
+ - `pr`: `create_pr: true`
288
+ - `deploy`: user answers "yes" to post-PR staging deploy prompt
289
+
290
+ Note: `security` runs in parallel with `review` (both depend on `implement` results, no overlap).
291
+
292
+ **For `analyze` intent:**
293
+ ```
294
+ PLAN:
295
+ 1. { id: "analyze", type: "analyze", agent: "issue-analyzer", depends: [] }
296
+ 2. { id: "context", type: "context", agent: "context-collector", depends: ["analyze"] }
297
+ 3. { id: "report", type: "report", agent: "orchestrator", depends: ["context"] }
298
+ 4. { id: "proposal", type: "proposal", agent: "orchestrator", depends: ["report"] }
299
+ ```
300
+ Step 4 (`proposal`) asks the user: "Want me to implement this? If yes, I'll extend the plan."
301
+
302
+ **For `review` intent:**
303
+ ```
304
+ PLAN:
305
+ 1. { id: "context", type: "context", agent: "context-collector", depends: [] }
306
+ 2. { id: "review", type: "review", agent: "reviewers", depends: ["context"] }
307
+ 3. { id: "report", type: "report", agent: "orchestrator", depends: ["review"] }
308
+ ```
309
+
310
+ **For `custom` intent:**
311
+ Build plan dynamically. Each step must have: id, type, agent, dependencies.
312
+
313
+ ### 1.2 Initialize Job Documentation
314
+
315
+ Dispatch `job-documenter` with `init` action:
316
+
317
+ ```
318
+ Task({
319
+ description: "Init job docs: <job-name>",
320
+ subagent_type: "general",
321
+ prompt: |
322
+ You are the job-documenter agent.
323
+ Load skill: skills/job-documenter/SKILL.md
324
+ Follow rules: rules/core/jobs-documentation.mdc
325
+
326
+ ACTION: init
327
+ JOB_NAME: <job-name>
328
+ JOBS_ROOT: <JOBS_ROOT>
329
+
330
+ DATA:
331
+ TITLE: <job title>
332
+ DESCRIPTION: <description>
333
+ INTENT: <intent>
334
+ SOURCE: <issue URL or description>
335
+ PROJECT: <project path>
336
+ BRANCH: TBD
337
+ BASE_BRANCH: <base branch>
338
+ PLAN: <plan steps>
339
+
340
+ Execute and return DOCUMENTER_RESULT.
341
+ })
342
+ ```
343
+
344
+ **Validate response:** status must be `success`. If `error` → report to user, ask how to proceed.
345
+
346
+ ### 1.3 Display Plan + Agent Approval
347
+
348
+ Show each step with its agent and status, then ask the user to approve or adjust:
349
+
350
+ ```
351
+ Execution plan — <N> steps:
352
+
353
+ Step 1 analyze issue-analyzer → issue #<N>
354
+ Step 2 context context-collector → project context + test framework
355
+ Step 3 prepare orchestrator → feature branch
356
+ Step 4 tests-creator tests-creator × <tasks> → RED test stubs per task (MANDATORY)
357
+ Step 5 implement task-implementer × <tasks> → <N> tasks make tests GREEN (wave-parallel)
358
+ Step 6 sanity-check orchestrator → verify commits exist
359
+ Step 7 verify code-verifier → lint + type-check + tests + imports (MANDATORY)
360
+ Step 8 review code-review × 4 → parallel agents
361
+ Step 9 fix task-implementer → [conditional: CRITICAL/HIGH findings]
362
+ Step 10 verify-post-fix code-verifier → [conditional: after fix]
363
+ Step 11 report orchestrator → final summary
364
+ Step 12 pr orchestrator + gh CLI → [conditional: create_pr=true]
365
+
366
+ Optional (not in plan — add if needed):
367
+ + security-audit auto-detect: auth/API/DB changes
368
+ + perf-check auto-detect: if frontend/bundle files changed
369
+ + deploy ask after PR: "Deploy to staging?"
370
+
371
+ Proceed? (yes / adjust: "skip fix", "add security-audit", "remove pr", etc.)
372
+ ```
373
+
374
+ **If user adjusts:**
375
+ - Parse natural language: "skip fix" → mark `fix` step as disabled
376
+ - "add security-audit" → insert `{ id: "security-audit", agent: "security-audit", depends: ["review"] }` after review
377
+ - "remove pr" → set `create_pr: false`
378
+ - Re-display updated plan and ask again
379
+
380
+ **If `plan_approval: false`** (automation setting) → skip this display and proceed directly.
381
+
382
+ ---
383
+
384
+ ## Phase 2: EXECUTION
385
+
386
+ Execute each step in plan order, documenting results after each step.
387
+
388
+ ### 2.1 General Execution Loop
389
+
390
+ ```
391
+ FOR step in PLAN:
392
+ IF step.conditional AND condition_not_met:
393
+ SKIP step, mark as "skipped"
394
+ CONTINUE
395
+
396
+ 2.1.1 Mark step as in-progress (update display)
397
+ 2.1.2 Execute step (see step-specific instructions below)
398
+ **CRITICAL RESILIENCE**: If the sub-agent returns a malformed result or fails to follow formatting rules, run an explicit retry:
399
+ "The previous output was malformed. Fix these errors: [errors] and try again." (Max 2 retries before counting as critical failure).
400
+ 2.1.3 Collect result
401
+ 2.1.4 Document result via job-documenter (add-document)
402
+ (Also update job state `state.json`)
403
+ 2.1.5 Update job README via job-documenter (update-readme)
404
+ 2.1.6 Mark step as completed
405
+
406
+ IF step failed critically:
407
+ Ask user: "Step '<name>' failed. Continue with remaining steps or abort?"
408
+ IF abort: skip to Phase 3 (COMPLETION) with status "aborted"
409
+ ```
410
+
411
+ ### 2.2 Step: ANALYZE
412
+
413
+ Dispatch `issue-analyzer` as a sub-agent.
414
+
415
+ **Prepare prompt:** Read `skills/issue-analyzer/orchestrator-prompt.md` (if it exists) and fill in:
416
+ - Issue URL or repo+number
417
+ - Codebase paths with roles
418
+ - Automation settings (skip_confirmation: true, search_depth: focused)
419
+
420
+ **Launch:**
421
+ ```
422
+ Task({
423
+ description: "Issue analysis: #<N>",
424
+ subagent_type: "general",
425
+ prompt: <constructed prompt>
426
+ })
427
+ ```
428
+
429
+ **Parse result:** Extract JSON analysis object:
430
+ ```
431
+ ANALYSIS_RESULT:
432
+ issue_type: from issue.type
433
+ total_tasks: from issue.total_tasks (= tasks.length)
434
+ tasks: [{task_id, task_name, task_type, complexity, dependencies,
435
+ description, target_files, acceptance_criteria, context,
436
+ existing_tests, existing_stories, module_patterns}]
437
+ dependency_order: from dependency_order array (already topologically sorted)
438
+ ```
439
+
440
+ **Validate:** At least 1 task, no circular dependencies, all dependency references valid. Dependency_order array must contain all task_ids exactly once.
441
+
442
+ **Document:** Send to job-documenter:
443
+ ```
444
+ ACTION: add-document
445
+ DATA:
446
+ DOC_TYPE: analysis
447
+ TARGET: both
448
+ TITLE: Issue Analysis — #<N>
449
+ CONTENT: <human-readable summary for man/, raw JSON for ai/>
450
+ AGENT: issue-analyzer
451
+ TASK: Analyze issue #<N>
452
+ ```
453
+
454
+ **For `analyze` intent:** After documenting, present analysis to user. Ask:
455
+ ```
456
+ Analysis complete. Found <N> tasks.
457
+ Want me to implement this? I'll create a feature branch and run the full pipeline.
458
+ ○ Yes, implement
459
+ ○ No, analysis is enough
460
+ ```
461
+ If "Yes" → extend PLAN with context → prepare → implement → review → fix → checks → pr steps. Continue execution.
462
+ If "No" → skip to Phase 3 (COMPLETION).
463
+
464
+ ### 2.3 Step: CONTEXT
465
+
466
+ Dispatch `context-collector` to build the unified context document.
467
+
468
+ **Prepare prompt:** Use the template from `skills/context-collector/SKILL.md`:
469
+
470
+ ```
471
+ Task({
472
+ description: "Collect context: <job-name>",
473
+ subagent_type: "general",
474
+ prompt: |
475
+ You are the context-collector agent. Your task is to research and build
476
+ a context document for the current job.
477
+
478
+ Load the skill from: skills/context-collector/SKILL.md
479
+
480
+ ACTION: collect
481
+ JOB_NAME: <job-name>
482
+ JOBS_ROOT: <JOBS_ROOT>
483
+ PROJECT_DIR: <project_dir>
484
+
485
+ DATA:
486
+ TASK_DESCRIPTION: <from issue or user request>
487
+ FOCUS_AREAS: <derived from analysis — affected areas, libraries>
488
+ ANALYSIS_RESULT: <output from issue-analyzer, if available>
489
+ KNOWN_LIBRARIES: <from package.json scan during analysis>
490
+
491
+ Execute all phases and return a CONTEXT_RESULT block.
492
+ })
493
+ ```
494
+
495
+ **Parse result:**
496
+ ```
497
+ CONTEXT_RESULT:
498
+ status: success | error
499
+ version: <document version>
500
+ summary: <what context was collected>
501
+ ```
502
+
503
+ **Validate:** status must be `success`. If `error` → log warning, continue (context is helpful but not blocking).
504
+
505
+ **After context is collected:** All subsequent sub-agents receive the **versioned** context path from state.json:
506
+ ```
507
+ CONTEXT_LOCATION: <JOBS_ROOT>/<job-name>/ai/context_v<N>.md
508
+ ```
509
+
510
+ **Context versioning:** Never overwrite `context.md` — save snapshots as `context_v1.md`, `context_v2.md`, etc.
511
+ - Version 1 is created during Step 2.3 (first collect)
512
+ - Subsequent versions increment on each update
513
+ - `state.json → context_doc.version` always points to the latest version
514
+ - Sub-agents always read the path from `state.json`, not a hardcoded filename
515
+
516
+ **Triggering context updates during execution:**
517
+
518
+ If during later steps (implement, review) a sub-agent reports missing context or a new library is discovered:
519
+
520
+ ```
521
+ Task({
522
+ description: "Update context: <job-name>",
523
+ subagent_type: "general",
524
+ prompt: |
525
+ You are the context-collector agent. Update the existing context.
526
+
527
+ Load the skill from: skills/context-collector/SKILL.md
528
+
529
+ ACTION: update
530
+ JOB_NAME: <job-name>
531
+ JOBS_ROOT: <JOBS_ROOT>
532
+ PROJECT_DIR: <project_dir>
533
+ CONTEXT_VERSION: <current version + 1> ← write to context_v<N+1>.md
534
+
535
+ DATA:
536
+ TASK_DESCRIPTION: <original task description>
537
+ UPDATE_REASON: <why context needs updating>
538
+ FOCUS_AREAS: <new areas to research>
539
+
540
+ Execute update flow and return a CONTEXT_RESULT block.
541
+ })
542
+ ```
543
+
544
+ ### 2.4 Step: PREPARE
545
+
546
+ Create git worktree for feature branch.
547
+
548
+ > **CRITICAL**: Feature branches MUST be created via `git worktree add`.
549
+ > **NEVER** use `git checkout -b` or `git switch -c` — this switches the main working directory.
550
+ > The worktree is a **sibling directory** to the project directory.
551
+
552
+ **Determine branch name:**
553
+ ```
554
+ Format: feature/<custom-slug>
555
+ Slug: descriptive, lowercase, alphanumeric+hyphens, from issue title/feature
556
+ Examples: feature/pipeline-validation, feature/mirror-step-source-column
557
+ ```
558
+
559
+ **Create worktree:**
560
+ ```bash
561
+ # Fetch latest base branch
562
+ git -C <project_dir> fetch origin <base_branch>
563
+
564
+ # Create worktree as SIBLING directory
565
+ git -C <project_dir> worktree add ../<branch-slug> -b feature/<branch-slug> origin/<base_branch>
566
+
567
+ # Example:
568
+ # Project dir: /Users/user/projects/<PROJECT>
569
+ # git -C ... worktree add ../pipeline-validation -b feature/pipeline-validation origin/develop-2
570
+ # Result worktree: /Users/user/projects/pipeline-validation
571
+ # Result branch: feature/pipeline-validation
572
+
573
+ # Auto-detect package manager and install dependencies
574
+ if [ -f <worktree_path>/bun.lockb ]; then
575
+ PM="bun"; RUNNER="bun run"; bun install --cwd <worktree_path>
576
+ elif [ -f <worktree_path>/pnpm-lock.yaml ]; then
577
+ PM="pnpm"; RUNNER="pnpm run"; pnpm install --prefix <worktree_path>
578
+ elif [ -f <worktree_path>/yarn.lock ]; then
579
+ PM="yarn"; RUNNER="yarn"; yarn --cwd <worktree_path>
580
+ elif [ -f <worktree_path>/package-lock.json ]; then
581
+ PM="npm"; RUNNER="npm run"; npm install --prefix <worktree_path>
582
+ elif [ -f <worktree_path>/requirements.txt ]; then
583
+ PM="python"; RUNNER=""; pip install -r <worktree_path>/requirements.txt
584
+ elif [ -f <worktree_path>/go.mod ]; then
585
+ PM="go"; RUNNER=""; (cd <worktree_path> && go mod download)
586
+ fi
587
+ ```
588
+
589
+ > **IMPORTANT**: After creating the worktree, ALL subsequent operations (implementation, review, lint, test, git) MUST run in the **worktree directory**, NOT in the original project directory.
590
+
591
+ **Record state:**
592
+ ```
593
+ BRANCH_STATE:
594
+ name: feature/<branch-slug>
595
+ base: <base_branch>
596
+ worktree_path: <absolute path to worktree>
597
+ project_dir: <original project directory — DO NOT modify>
598
+ created_from_commit: <commit hash>
599
+ package_manager: <PM>
600
+ run_command: <RUNNER>
601
+ ```
602
+
603
+ > **Store `package_manager` and `run_command` in JOB_STATE** — all subsequent steps use these instead of hardcoded `npm`.
604
+
605
+ **Document:** Update README via job-documenter (update-readme) with branch info.
606
+
607
+ ### 2.4.1 Step: TESTS-CREATOR + IMPLEMENT — Wave Isolation
608
+
609
+ **IRON LAW: tests-creator MUST run before task-implementer for every task. No exceptions.**
610
+
611
+ **CONTEXT BUDGET RULE: Each wave runs as a single isolated sub-agent. The orchestrator never dispatches task-implementers or tests-creator directly. This keeps the orchestrator context bounded to compact wave summaries regardless of job size.**
612
+
613
+ ---
614
+
615
+ #### Why wave isolation
616
+
617
+ When the orchestrator dispatches task-implementers directly, each sub-agent result (STATUS text + verification output) accumulates in the orchestrator's context. After 3–4 waves this context can reach 100k+ tokens, causing the session to freeze during context reload. Wave isolation prevents this: each wave sub-agent runs in its own context and returns only a compact summary.
618
+
619
+ ---
620
+
621
+ #### Execution pattern
622
+
623
+ ```
624
+ WAVES = topological_sort_into_waves(dependency_order, task_dependencies)
625
+
626
+ FOR wave_index, wave_tasks in enumerate(WAVES):
627
+ Dispatch SINGLE Agent("wave-executor") with all tasks in this wave.
628
+
629
+ Receive compact WAVE_RESULT:
630
+ STATUS: WAVE_DONE | WAVE_PARTIAL | WAVE_FAILED
631
+ Wave: <index>
632
+ Commits: [hash msg, hash msg, ...]
633
+ Tests: <N passed, M failed>
634
+ Tasks: task-1 ✅, task-2 ✅
635
+ Result files: <JOBS_ROOT>/<job-name>/results/task-*.json
636
+
637
+ Decision:
638
+ WAVE_DONE → continue to next wave
639
+ WAVE_PARTIAL → log warnings, continue (read result files for details)
640
+ WAVE_FAILED → STOP, read result files for failed tasks, ask user
641
+ ```
642
+
643
+ #### Wave executor prompt template
644
+
645
+ ```
646
+ Task({
647
+ description: "Wave <N>: implement tasks <task_ids>",
648
+ subagent_type: "general",
649
+ prompt: |
650
+ You are a wave executor. Implement all tasks in this wave, then return a compact summary.
651
+
652
+ ## Wave
653
+ Wave <N> of <total>
654
+
655
+ ## Tasks
656
+ <JSON array of task objects for this wave>
657
+
658
+ ## Workspace
659
+ - worktree_path: <absolute path>
660
+ - branch: <branch name>
661
+ - package_manager: <pm>
662
+ - run_command: <runner>
663
+ - issue_number: <N>
664
+ - job_name: <job-name>
665
+ - context_path: <path to context_vN.md>
666
+
667
+ ## Instructions
668
+
669
+ **Step A — tests-creator (MANDATORY, run first):**
670
+ For each task in this wave, dispatch tests-creator in parallel:
671
+ Load skill: skills/tests-creator/SKILL.md
672
+ Pass: task object, workspace, context_path
673
+ Collect: TEST_SPECS[task_id] from each response
674
+ Wait for ALL tests-creator agents to finish before Step B.
675
+
676
+ **Step B — task-implementer (after all test stubs committed):**
677
+ For each task in this wave, dispatch task-implementer in parallel (if no file overlap; sequential otherwise):
678
+ Load skill: skills/task-implementer/SKILL.md
679
+ Pass: task object WITH test_case_specs: TEST_SPECS[task_id], workspace, job_name, context_path
680
+ Wait for ALL task-implementer agents to finish.
681
+
682
+ **Parallel safety check:** Before Step B, verify no two tasks share target_files.
683
+ If overlap → run sequentially within this wave.
684
+
685
+ ## Required response format (compact — no inline JSON)
686
+
687
+ STATUS: WAVE_DONE
688
+ Wave: <N>
689
+ Commits: [abc1234 feat(x): ..., def5678 feat(y): ...]
690
+ Tests: <N passed, M failed>
691
+ Tasks: task-1 ✅, task-2 ✅
692
+ Result files: <JOBS_ROOT>/<job-name>/results/task-1.json, task-2.json
693
+
694
+ Use WAVE_PARTIAL if any task is DONE_WITH_CONCERNS.
695
+ Use WAVE_FAILED if any task is BLOCKED or failed.
696
+ Do NOT include full task output inline — write details to result files.
697
+ })
698
+ ```
699
+
700
+ **After all waves, document:**
701
+ ```
702
+ ACTION: add-document
703
+ DATA:
704
+ DOC_TYPE: implementation-report
705
+ TARGET: both
706
+ TITLE: Implementation Report
707
+ CONTENT: <summary of all waves, commits, test totals>
708
+ AGENT: wave-executor
709
+ TASK: Implementation phase
710
+ ```
711
+
712
+ ### 2.5.1 Post-Implementation Checkpoint
713
+
714
+ After all waves complete, check if tests were created. If not, offer `test-gen`:
715
+
716
+ ```
717
+ # Derive all modified files from wave summaries and result files
718
+ ALL_FILES = collect from WAVE_RESULTS (read result files for details if needed)
719
+
720
+ IF no test files in ALL_FILES:
721
+ Auto-trigger test-gen for new/modified source files
722
+ (skip test files, config files, types-only files)
723
+ ```
724
+
725
+ Then present the implementation summary to user:
726
+
727
+ ```
728
+ Implementation complete:
729
+ - <N>/<M> tasks ✅
730
+ - <X> files modified, <Y> files created
731
+ - Tests: <created by implementer | auto-generated by test-gen | none>
732
+
733
+ What's next?
734
+ A) 🔍 Review → fix → PR (standard pipeline)
735
+ B) 👀 Show me the diff first — I'll review manually
736
+ C) 🚀 Skip review, go straight to PR
737
+ D) ⏹ Stop here — I'll continue manually
738
+ ```
739
+
740
+ **Mapping:**
741
+ - A → continue to REVIEW step (default if no response in 60s)
742
+ - B → run `git diff <merge_base>..HEAD --stat` and `git diff <merge_base>..HEAD`, then re-ask
743
+ - C → skip REVIEW and FIX steps, go to CHECKS → PR
744
+ - D → skip to Phase 3 (COMPLETION) with status "paused"
745
+
746
+ ### 2.5.5 Step: IMPLEMENT SANITY CHECK
747
+
748
+ Lightweight verification after all waves complete, **before** launching review.
749
+ This catches the case where a wave sub-agent claims WAVE_DONE but made no actual git changes.
750
+
751
+ ```bash
752
+ # Run in worktree directory
753
+ git diff --stat <merge_base>..HEAD
754
+ git log <merge_base>..HEAD --oneline
755
+ ```
756
+
757
+ **Gate conditions:**
758
+
759
+ | Check | Pass | Fail action |
760
+ |-------|------|-------------|
761
+ | At least 1 commit exists | ≥1 commit | `retryable` — re-dispatch the failed wave-executor with: "No commits were made. Implement the changes and commit them." |
762
+ | At least 1 file modified | ≥1 file changed | Same as above |
763
+ | Claimed files actually modified | All files in wave result match diff | Log discrepancy as WARNING, continue |
764
+
765
+ **If retry also produces no commits** → classify as `terminal`, ABORT with:
766
+ ```
767
+ "wave-executor returned WAVE_DONE twice but made no git changes.
768
+ Please implement manually and re-run from the review step."
769
+ ```
770
+
771
+ **Record:**
772
+ ```
773
+ SANITY_CHECK:
774
+ commits: <count>
775
+ files_changed: <count>
776
+ lines_added: <N>
777
+ lines_removed: <N>
778
+ verified: true | false
779
+ ```
780
+
781
+ ---
782
+
783
+ ### 2.6 Step: REVIEW
784
+
785
+ #### 2.6.0 Review Strategy Selection
786
+
787
+ If the user didn't specify a review approach, offer options:
788
+
789
+ ```
790
+ How should I review the implementation?
791
+
792
+ A) 🚀 Quick (code-review 4-agent parallel) — ~30 sec
793
+ B) 📋 Thorough (individual reviewers: ai + boss + style + mobx) — ~2 min
794
+ C) 🔒 Security-focused (code-review + security-audit) — ~1 min
795
+ D) ⏭ Skip review entirely
796
+
797
+ > pick a letter (default: A)
798
+ ```
799
+
800
+ Then ask which optional convention reviewers to include when local convention docs or matching
801
+ paths are present:
802
+
803
+ ```
804
+ Which project-convention reviewers should I include?
805
+
806
+ A) Include all detected convention reviewers (recommended)
807
+ B) Choose individually
808
+ C) Skip convention reviewers
809
+
810
+ Detected reviewers:
811
+ - review-frontend-conventions: frontend files / stories / local frontend guide
812
+ - review-testing-practices: tests, stories, MSW, or e2e files
813
+ - review-core-boundaries: shared core/infrastructure files
814
+ - review-flow-graph: shared graph/flow abstraction files
815
+ ```
816
+
817
+ Only show detected reviewers. If the user chooses B, ask for the exact skill names to include or
818
+ exclude, then persist the choice in job state as `convention_reviewers`.
819
+
820
+ **Auto-select** (skip this question) when:
821
+ - `review_mode` is explicitly set in automation settings → use that
822
+ - `convention_reviewers` is explicitly set in automation settings → use that for optional convention reviewers
823
+ - User already chose at Post-Implementation Checkpoint (2.5.1 option A) → use default (A)
824
+ - Time pressure (total_job_timeout close) → use A (fastest)
825
+
826
+ #### 2.6.1 Execute Review
827
+
828
+ Dispatch review skills on the whole branch. **Launch all reviewers in parallel** for speed.
829
+
830
+ **Strategy A — `code-review` (4-agent parallel):**
831
+
832
+ Dispatches 4 agents in parallel (correctness, security, performance, style) and produces a unified severity report.
833
+
834
+ ```
835
+ Launch code-review skill with:
836
+ scope: git diff <merge_base>..HEAD
837
+ output: unified report with CRITICAL/HIGH/MEDIUM/LOW findings
838
+ ```
839
+
840
+ **Fallback — individual reviewers (if code-review unavailable or user prefers):**
841
+
842
+ Determine and **dispatch all reviewers simultaneously** (not sequentially):
843
+
844
+ | Reviewer | Condition | Launch |
845
+ |----------|-----------|--------|
846
+ | `code-ai-review` | Always | Parallel |
847
+ | `code-boss-review` | Always | Parallel |
848
+ | `code-style-review` | Always | Parallel |
849
+ | `code-mobx-store-review` | Only if `*.store.ts` modified | Parallel |
850
+ | `review-frontend-conventions` | If selected and frontend files/local frontend docs match | Parallel |
851
+ | `review-testing-practices` | If selected and tests/stories/e2e files match | Parallel |
852
+ | `review-core-boundaries` | If selected and shared core files match | Parallel |
853
+ | `review-flow-graph` | If selected and shared graph/flow files match | Parallel |
854
+
855
+ ```
856
+ # Launch ALL applicable reviewers in a SINGLE turn (parallel):
857
+ Agent 1: code-ai-review (correctness, security)
858
+ Agent 2: code-boss-review (architecture, logic)
859
+ Agent 3: code-style-review (naming, patterns)
860
+ Agent 4: code-mobx-store-review (if applicable)
861
+ Agent 5+: selected convention reviewers (if applicable)
862
+
863
+ # Wait for all to complete, then merge results
864
+ ```
865
+
866
+ **Review-orchestrator mode (preferred when available):**
867
+
868
+ If `review-orchestrator` exists in the skill catalog, dispatch it with the selected review flags
869
+ instead of manually launching individual reviewers. Pass selected convention reviewer flags:
870
+ `--project-conventions`, `--frontend-conventions`, `--testing-practices`, `--core-boundaries`,
871
+ and/or `--flow-graph`.
872
+
873
+ Pass review orchestration controls:
874
+ ```
875
+ context_mode: <review_context_mode automation setting; default "light", ask "full" for high-risk PRs>
876
+ token_budget: <review_token_budget automation setting or computed scope budget>
877
+ model_strategy: <review_model_strategy automation setting; default "current">
878
+ output: unified report with findings, review_context, token_policy, and model metadata
879
+ ```
880
+
881
+ **Collect and merge findings:**
882
+ ```
883
+ REVIEW_FINDINGS: [{
884
+ reviewer: "<skill-name>",
885
+ findings: [{ file, line, severity: CRITICAL|WARNING|INFO, message }]
886
+ }]
887
+ ```
888
+
889
+ **Strategy C — Security-focused:**
890
+
891
+ Run `code-review` (4-agent) AND `security-audit` in parallel:
892
+ ```
893
+ Agent group 1: code-review (correctness, security, performance, style)
894
+ Agent group 2: security-audit (dependency vulnerabilities, secrets scan, OWASP patterns)
895
+ ```
896
+ Merge findings from both into unified `REVIEW_FINDINGS`.
897
+
898
+ **Deduplicate:** If multiple reviewers flag the same file:line, merge into a single finding with the highest severity.
899
+
900
+ **Classify:**
901
+ ```
902
+ NEEDS_FIX = count(CRITICAL) > 0 OR count(WARNING) > 0
903
+ ```
904
+
905
+ **Document:**
906
+ ```
907
+ ACTION: add-document
908
+ DATA:
909
+ DOC_TYPE: review
910
+ TARGET: both
911
+ TITLE: Code Review Results
912
+ CONTENT: <findings summary for man/, structured findings for ai/>
913
+ ```
914
+
915
+ #### 2.6.2 PR Review Report Publication
916
+
917
+ If this job is reviewing an existing GitHub PR, or if a PR number/URL was resolved before the review step, ask whether to publish the consolidated review report after review findings are documented and before fix decisions. This gives the user a chance to record the current review state before any automatic fix loop changes it.
918
+
919
+ Ask unless automation settings explicitly set `publish_pr_review_report`:
920
+
921
+ ```text
922
+ Publish the review report to the PR?
923
+
924
+ A) Concise PR comment only
925
+ B) Concise PR comment + detailed AI markdown artifact (recommended for follow-up fixes)
926
+ C) Do not publish
927
+
928
+ > pick a letter (default: C)
929
+ ```
930
+
931
+ **Rules:**
932
+ - The PR comment and AI artifact must be written in English only, regardless of the chat language or reviewer output language.
933
+ - Default is C. Never publish to a PR without explicit user confirmation or `publish_pr_review_report: comment`, `publish_pr_review_report: comment-and-ai-artifact`, or legacy `publish_pr_review_report: true`.
934
+ - If the job has review findings but no PR number yet, store `pending_pr_review_report_comment` and `pending_review_ai_artifact` in job state. If the later PR step creates a PR, ask the same question after PR creation.
935
+ - If the user chooses A, delegate concise comment formatting to `review-orchestrator`'s PR Review Report Publication contract when available.
936
+ - If the user chooses B, delegate concise comment formatting and generate `.metaproject/jobs/<job-name>/ai/review-ai-report.md` using `review-orchestrator`'s Detailed AI Markdown Artifact contract.
937
+ - If the user chooses B, the PR comment `Meta` section must include both an `AI artifact` link/path and an `AI artifact description` row explaining in human-readable language that the markdown file contains detailed findings, fix guidance, patch guidance, regression coverage, validation plan, and follow-up agent context.
938
+ - If using legacy reviewers, normalize findings into the same concise PR comment and AI artifact structures before posting.
939
+ - Record the final decision in job state as `publication_plan.mode`: `comment`, `comment-and-ai-artifact`, or `none`.
940
+
941
+ **Automation values:**
942
+ - `publish_pr_review_report: ask` -> ask the question above.
943
+ - `publish_pr_review_report: comment` or legacy `true` -> publish the concise PR comment only.
944
+ - `publish_pr_review_report: comment-and-ai-artifact` -> publish the concise PR comment and create/link the detailed AI markdown artifact.
945
+ - `publish_pr_review_report: none` or legacy `false` -> do not publish.
946
+
947
+ #### 2.6.3 Post-Review Checkpoint
948
+
949
+ After review completes, present findings and ask user:
950
+
951
+ ```
952
+ Review complete:
953
+ 🔴 <N> CRITICAL 🟠 <M> HIGH 🟡 <K> MEDIUM 🔵 <L> LOW
954
+
955
+ A) 🔧 Auto-fix and continue (fix CRITICAL + HIGH, skip LOW)
956
+ B) 📋 Show all findings — I'll decide what to fix
957
+ C) ⏭ Skip fixes, proceed to PR as-is
958
+ D) ⏹ Stop — I'll fix manually
959
+ ```
960
+
961
+ **Mapping:**
962
+ - A → proceed to FIX step (default if CRITICAL > 0)
963
+ - B → display all findings grouped by file, then re-ask A/C/D
964
+ - C → skip FIX step, go to CHECKS (only if 0 CRITICAL — refuse if CRITICAL > 0)
965
+ - D → skip to Phase 3 (COMPLETION) with status "paused"
966
+
967
+ **Auto-proceed** (skip this question) when:
968
+ - 0 findings → skip directly to CHECKS
969
+ - Only INFO findings → skip FIX, go to CHECKS
970
+ - `auto_create_pr: true` → auto-select A
971
+
972
+ ### 2.7 Step: FIX (conditional)
973
+
974
+ Only runs if NEEDS_FIX is true. Default max: **3 iterations** (`max_review_iterations`).
975
+
976
+ ```
977
+ UNRESOLVED_FINDINGS = all CRITICAL + WARNING findings from step 2.6
978
+
979
+ FOR iteration in [1, 2, 3]:
980
+ IF NOT NEEDS_FIX: BREAK
981
+
982
+ 1. Group UNRESOLVED_FINDINGS by file
983
+ 2. Construct fix prompt — MUST include unresolved findings from previous attempt:
984
+
985
+ task_type: "fix"
986
+ findings: <UNRESOLVED_FINDINGS>
987
+ iteration: <N>
988
+ previously_unresolved: <findings that were in UNRESOLVED_FINDINGS last iteration but still present>
989
+ → Prefix: "These specific findings were NOT fixed in iteration <N-1>: [list]"
990
+
991
+ 3. Launch task-implementer with fix prompt
992
+ 4. Run sanity-check (step 2.5.5 logic) — verify commits were made
993
+ 5. Re-run reviewers (step 2.6) — parallel dispatch
994
+ 6. Recompute NEEDS_FIX from new findings
995
+ 7. Update UNRESOLVED_FINDINGS = remaining CRITICAL + WARNING
996
+
997
+ IF still NEEDS_FIX after max iterations:
998
+ Log "Unresolved after <N> iterations" with finding list → continue to checks
999
+ ```
1000
+
1001
+ **Fix prompt escalation pattern:**
1002
+ - Iteration 1: "Fix these findings: [list]"
1003
+ - Iteration 2: "These findings were NOT fixed in iteration 1: [subset]. Fix them now."
1004
+ - Iteration 3: "FINAL attempt. These findings remain after 2 fix passes: [subset]. This is the last fix iteration."
1005
+
1006
+ ### 2.8 Step: VERIFY (code-verifier)
1007
+
1008
+ Dispatch `code-verifier` as a sub-agent. This replaces the orchestrator-internal "checks" step.
1009
+
1010
+ ```
1011
+ Task({
1012
+ description: "Quality gate: <job-name>",
1013
+ subagent_type: "general",
1014
+ prompt: |
1015
+ You are code-verifier. Load skill: skills/code-verifier/SKILL.md
1016
+
1017
+ codebase_path: <worktree_path>
1018
+ base_branch: <base_branch>
1019
+ scope: changed
1020
+
1021
+ Run all 4 phases and return VERIFICATION_RESULT.
1022
+ })
1023
+ ```
1024
+
1025
+ **Handle result:**
1026
+ ```
1027
+ IF VERIFICATION_RESULT.gate == "PASS" or "PASS_WITH_WARNINGS":
1028
+ → Proceed to review
1029
+ → Log findings as informational in job docs
1030
+
1031
+ IF VERIFICATION_RESULT.gate == "FAIL":
1032
+ → Extract CRITICAL/HIGH findings
1033
+ → Check if fix step is already scheduled
1034
+ - If not → add fix step to plan (dispatch task-implementer in fix mode)
1035
+ - If fix already ran 2× → escalate to user, skip to report
1036
+ ```
1037
+
1038
+ **Document result:**
1039
+ ```
1040
+ ACTION: add-document
1041
+ DATA:
1042
+ DOC_TYPE: verification-report
1043
+ TARGET: both
1044
+ TITLE: Verification Report — <gate status>
1045
+ CONTENT: <VERIFICATION_RESULT formatted>
1046
+ AGENT: code-verifier
1047
+ ```
1048
+
1049
+ ### 2.8.1 Step: VERIFY-POST-FIX (code-verifier, conditional)
1050
+
1051
+ After fix iterations, dispatch `code-verifier` again with identical parameters.
1052
+
1053
+ ```
1054
+ IF fix ran:
1055
+ Dispatch code-verifier (same params as step 2.8)
1056
+ IF gate still FAIL:
1057
+ Log "Verification failed after fix" → skip to report with warning
1058
+ IF gate PASS:
1059
+ Proceed to report
1060
+ ```
1061
+
1062
+ ### 2.8.1 Step: PERF-CHECK (optional)
1063
+
1064
+ Auto-trigger `perf-check` when frontend/bundle files were modified:
1065
+
1066
+ ```
1067
+ IF any modified file matches: *.tsx, *.jsx, *.css, *.scss, webpack.*, vite.*, next.config.*
1068
+ AND project has build output (dist/, build/, .next/)
1069
+ THEN:
1070
+ Dispatch perf-check --bundle
1071
+ Add findings to report (informational, not blocking)
1072
+ ```
1073
+
1074
+ Skip if no frontend files changed or no build output exists. Results are advisory — they don't block the PR.
1075
+
1076
+ ### 2.8.2 Step: SKILL LEARNING (conditional)
1077
+
1078
+ Close the self-learning loop (see `rules/core/skill-lifecycle.mdc`). Collect the
1079
+ learning signals produced upstream:
1080
+ - `skill_drift` fields from each task-implementer result (`stale:`/`missing:`).
1081
+ - the `## Skill Learning` block from `review-orchestrator`.
1082
+
1083
+ ```
1084
+ IF no skill_drift and Skill Learning == none:
1085
+ → skip this step (log "no skill drift")
1086
+
1087
+ ELSE for each flagged project-skill:
1088
+ 1. Dispatch a subagent to build the learning proposal:
1089
+ - Model: prefer a cheaper / non-flagship model if one is available in this
1090
+ environment (run .metaproject/scripts/detect-models.sh; see
1091
+ rules/core/model-selection.mdc). Otherwise use the session model.
1092
+ - Command: keryx skills learn --from-review <review-report-path> \
1093
+ --skill <module>/<skill>
1094
+ (or --from-test / --from-failure when the signal came from verification)
1095
+ - The subagent returns the proposal path. It does NOT apply.
1096
+ 2. The orchestrator (flagship) reads the proposal and either:
1097
+ - keryx skills learn apply <proposal.json> (accept), or
1098
+ - discards it and notes why in the report.
1099
+ ```
1100
+
1101
+ Never apply a proposal unread, and never run `learn` in a hook. Record applied
1102
+ skill updates in the Job Report under "Skill Updates".
1103
+
1104
+ ### 2.9 Step: REPORT
1105
+
1106
+ Aggregate all information into a human-readable summary.
1107
+
1108
+ **Report structure:**
1109
+ ```markdown
1110
+ # Job Report: <Title>
1111
+
1112
+ ## Summary
1113
+ - **Intent:** <implement / analyze / review>
1114
+ - **Source:** <issue URL or description>
1115
+ - **Branch:** `<branch_name>`
1116
+ - **Tasks:** <completed>/<total> completed
1117
+ - **Review Iterations:** <N>
1118
+ - **Final Status:** <READY FOR PR | HAS WARNINGS | HAS ISSUES | ANALYSIS ONLY>
1119
+
1120
+ ## Analysis
1121
+ <analysis summary>
1122
+
1123
+ ## Tasks
1124
+ ### task-1: <Name>
1125
+ - **Status:** success
1126
+ - **Files:** <list>
1127
+ - **Commits:** <hashes>
1128
+
1129
+ ## Review Results
1130
+ ### code-ai-review
1131
+ - CRITICAL: <N>, WARNING: <N>, INFO: <N>
1132
+ ### code-boss-review
1133
+ - ...
1134
+
1135
+ ## Unresolved Issues
1136
+ - [ ] <file>:<line> — <message> (from <reviewer>)
1137
+
1138
+ ## Final Checks
1139
+ - Lint: PASS
1140
+ - Type Check: PASS
1141
+ - Tests: 42 passed, 0 failed
1142
+
1143
+ ## Skill Updates
1144
+ - `<module>/<skill>` v1.2.0 → v1.3.0 (from review F-012; applied) | none
1145
+
1146
+ ## Changes Summary
1147
+ ### Files Modified (<N>)
1148
+ - `src/...`
1149
+
1150
+ ### Files Created (<N>)
1151
+ - `src/...`
1152
+
1153
+ ### Commits (<N>)
1154
+ - `abc1234` feat(pipelines): add validation
1155
+ ```
1156
+
1157
+ ### 2.10 Step: PR (conditional)
1158
+
1159
+ Only runs if `create_pr` is true and intent is `implement`.
1160
+
1161
+ **Dispatch `pr-issue-documenter` to generate the PR description:**
1162
+
1163
+ Pass the following context to `pr-issue-documenter`:
1164
+ ```
1165
+ ACTION: generate-pr-description
1166
+ JOB_NAME: <job-name>
1167
+ BRANCH: <feature_branch>
1168
+ BASE: <base_branch>
1169
+ ISSUE_NUMBER: <issue_number if available>
1170
+ CONTEXT_PATH: <JOBS_ROOT>/<job-name>/ai/context.md
1171
+ ```
1172
+
1173
+ `pr-issue-documenter` will analyze the branch diff and produce a structured PR description (Summary + Changes by area + Key Files table). Use its output as the `body` for the PR.
1174
+
1175
+ **Enrich PR with changelog entry:**
1176
+
1177
+ Dispatch `changelog` skill to generate a changelog snippet for this branch:
1178
+ ```
1179
+ changelog <base_branch>..HEAD --format compact
1180
+ ```
1181
+ Append the changelog snippet to the PR body under a `## Changelog` section.
1182
+
1183
+ **Present to user:**
1184
+ ```
1185
+ Implementation complete. Draft PR proposal:
1186
+
1187
+ Title: <type>(#<issue>): <description>
1188
+ Base: <base> ← <head>
1189
+
1190
+ <pr-issue-documenter output>
1191
+
1192
+ ## Changelog
1193
+ <changelog snippet>
1194
+
1195
+ Create this draft PR? (yes/no/edit)
1196
+ ```
1197
+
1198
+ If user says "edit" → show the full body, let them modify before creating.
1199
+
1200
+ **If confirmed:**
1201
+ ```bash
1202
+ gh pr create --title "<title>" --body "$(cat <<'EOF'
1203
+ <body>
1204
+ EOF
1205
+ )" --base <base_branch> --head <feature_branch> --draft
1206
+ ```
1207
+
1208
+ ---
1209
+
1210
+ ## Phase 3: COMPLETION
1211
+
1212
+ ### 3.1 Finalize Job Documentation
1213
+
1214
+ Dispatch job-documenter with `finalize` action:
1215
+
1216
+ ```
1217
+ ACTION: finalize
1218
+ DATA:
1219
+ FINAL_CONTENT: <full report markdown>
1220
+ FINAL_STATUS: completed | aborted
1221
+ SUMMARY: <1-3 sentence summary>
1222
+ ```
1223
+
1224
+ **Validate response:** status must be `success`.
1225
+
1226
+ ### 3.2 Present Results
1227
+
1228
+ Tell user:
1229
+ 1. What was accomplished (summary)
1230
+ 2. Where documentation is stored: `.metaproject/jobs/<job-name>/`
1231
+ 3. PR URL (if created)
1232
+ 4. Metrics summary (time, tokens)
1233
+ 5. Any unresolved issues
1234
+
1235
+ ```
1236
+ ✅ Job completed successfully.
1237
+
1238
+ Documentation: <JOBS_ROOT>/<job-name>/
1239
+ Branch: feature/<slug> (worktree: <path>)
1240
+ PR: <URL or "not created">
1241
+ Metrics: <total time>, <total tokens>
1242
+
1243
+ See .metaproject/jobs/<job-name>/README.md for the full job index.
1244
+ ```
1245
+
1246
+ ### 3.3 Post-Completion Options
1247
+
1248
+ After presenting results, offer next steps:
1249
+
1250
+ ```
1251
+ What would you like to do next?
1252
+
1253
+ A) ✅ Done — nothing else needed
1254
+ B) 🚀 Deploy to staging — run /deploy staging
1255
+ C) 🔄 Start another job
1256
+ D) 📝 Update CLAUDE.md with session learnings
1257
+ ```
1258
+
1259
+ - B → dispatch `deploy` skill with `staging` environment
1260
+ - D → dispatch `claude-md-management` skill
1261
+
1262
+ **Auto-skip** if the job was `analyze` or `review` intent (no deploy makes sense).
1263
+
1264
+ ---
1265
+
1266
+ ## Plan Extension (Dynamic Planning)
1267
+
1268
+ When the orchestrator starts with an `analyze` intent and the user then says "yes, implement":
1269
+
1270
+ 1. **Keep existing completed steps** (analyze, context, report are already done)
1271
+ 2. **Extend plan** with new steps: prepare → implement → review → fix → checks → report → pr
1272
+ 3. **Update job documentation** via job-documenter (update-readme with new plan)
1273
+ 4. **Continue execution** from the first new step
1274
+
1275
+ This is the core of dynamic planning — the plan grows based on user decisions.
1276
+
1277
+ ---
1278
+
1279
+ ## State Management
1280
+
1281
+ The orchestrator maintains state throughout all phases:
1282
+
1283
+ ```
1284
+ JOB_STATE:
1285
+ phase: CONTEXT | PLAN | EXECUTION | COMPLETION
1286
+ intent: implement | analyze | review | custom
1287
+ create_pr: <bool>
1288
+ job_name: <string>
1289
+
1290
+ context:
1291
+ issue: { number, title, url, type }
1292
+ project_dir: <path>
1293
+ base_branch: <string>
1294
+
1295
+ branch:
1296
+ name: <string>
1297
+ worktree_path: <path>
1298
+ merge_base: <commit hash>
1299
+
1300
+ plan:
1301
+ steps: [{ id, type, agent, depends, status: pending|in_progress|completed|skipped|failed, prompt_chars: <int>, prompt_hash: <sha256 first 8 chars> }]
1302
+ current_step: <step_id>
1303
+
1304
+ analysis:
1305
+ total_tasks: <N>
1306
+ tasks: [<task objects>]
1307
+ dependency_order: [<task_ids>]
1308
+
1309
+ context_doc:
1310
+ path: <JOBS_ROOT>/<job-name>/ai/context.md
1311
+ version: <current version>
1312
+ status: collected | updated | not-collected
1313
+
1314
+ implementation:
1315
+ task_results: {<task_id>: <result>}
1316
+ all_commits: [<hash>]
1317
+ all_files: [<path>]
1318
+
1319
+ review:
1320
+ iteration: <N>
1321
+ findings: [<findings>]
1322
+ needs_fix: <bool>
1323
+ unresolved: [<findings>]
1324
+
1325
+ final_checks:
1326
+ lint: <result>
1327
+ type_check: <result>
1328
+ tests: <result>
1329
+
1330
+ documentation:
1331
+ job_path: <JOBS_ROOT>/<job-name>
1332
+ documents_created: [<paths>]
1333
+ ```
1334
+
1335
+ ---
1336
+
1337
+ ## state.json Specification
1338
+
1339
+ The orchestrator persists JOB_STATE to `.metaproject/jobs/<job-name>/state.json` for job resumption.
1340
+
1341
+ **Location:** `.metaproject/jobs/<JOB_NAME>/state.json`
1342
+
1343
+ **Schema reference:** `skills/job-orchestrator/state.schema.json`
1344
+
1345
+ **When to create:** During Phase 1.2 (Initialize Job Documentation) — write initial state after job docs are initialized.
1346
+
1347
+ **When to update:** After every step completion in Phase 2 (EXECUTION) — update `plan.steps[i].status`, `plan.steps[i].prompt` (store the prompt used), and `plan.current_step`.
1348
+
1349
+ **How to write state.json:**
1350
+ ```bash
1351
+ # Write state (orchestrator handles this directly, not via job-documenter)
1352
+ cat > .metaproject/jobs/<JOB_NAME>/state.json << 'EOF'
1353
+ {
1354
+ "phase": "EXECUTION",
1355
+ "intent": "<intent>",
1356
+ "job_name": "<job-name>",
1357
+ ...
1358
+ }
1359
+ EOF
1360
+ ```
1361
+
1362
+ **Job resumption (Phase 0.0):** If `state.json` exists and `phase` is not `COMPLETION`, offer to resume. Parse the file, restore JOB_STATE, jump to the first step with `status: "pending"` or `status: "in_progress"`.
1363
+
1364
+ ---
1365
+
1366
+ ## Interpreting Subagent Results
1367
+
1368
+ **Rule:** `rules/core/subagent-status-protocol.md`
1369
+
1370
+ All subagents dispatched by this orchestrator MUST begin their final response with `STATUS: <STATUS>`. The orchestrator reads this line first and routes accordingly.
1371
+
1372
+ ### Iron Law
1373
+
1374
+ **IF A SUBAGENT DOES NOT START WITH `STATUS:`, TREAT IT AS `NEEDS_CONTEXT` AND REQUEST A PROPERLY FORMATTED RESPONSE**
1375
+
1376
+ Do not attempt to infer status from prose. Do not trust a response that "looks fine" but lacks the status line. Run one explicit retry: "Your response did not start with STATUS: <STATUS>. Please reformat using the subagent status protocol (rules/core/subagent-status-protocol.md) and resend your result."
1377
+
1378
+ ### How to handle each status
1379
+
1380
+ **`STATUS: DONE`**
1381
+ - Accept result.
1382
+ - Extract structured payload (JSON result, files changed, commits, verification results).
1383
+ - Mark step as completed in JOB_STATE.
1384
+ - Continue to next step in the plan.
1385
+
1386
+ **`STATUS: DONE_WITH_CONCERNS`**
1387
+ - Accept result as complete.
1388
+ - Read the `## Concerns for orchestrator` section carefully.
1389
+ - Decide: (a) log concern and continue, (b) surface concern to user at next checkpoint, or (c) re-dispatch with adjusted scope if the concern affects correctness.
1390
+ - Do NOT silently discard concerns. Record them in JOB_STATE and include in the final report.
1391
+ - Mark step as completed.
1392
+
1393
+ **`STATUS: BLOCKED`**
1394
+ - Do NOT proceed to any step that depends on this task.
1395
+ - Read `## Reason` and `## What I need from orchestrator`.
1396
+ - Resolve the blocker: provide the missing file, make the decision, fix the dependency, or escalate to the user.
1397
+ - Re-dispatch the subagent with the resolved context.
1398
+ - If the blocker cannot be resolved (e.g., missing information requires user input) → surface to user: "Task <id> is blocked: <reason>. What would you like to do?"
1399
+
1400
+ **`STATUS: NEEDS_CONTEXT`**
1401
+ - Do NOT mark step as failed.
1402
+ - Read `## Missing information` and `## Where it might be found`.
1403
+ - Locate the missing information (check job context document, issue body, package.json, codebase).
1404
+ - Re-dispatch the subagent with the enriched task input.
1405
+ - If the information is not available anywhere → escalate to user with the specific question.
1406
+
1407
+ ### Red Flag
1408
+
1409
+ **"The subagent didn't use the status protocol, but the result looks fine"**
1410
+
1411
+ Do not accept this. A subagent that ignores the status protocol is unpredictable — its next failure may not look fine. Enforce the protocol on every response. Run the retry. If the subagent still does not comply after the retry, log it as a critical failure and ask the user how to proceed.
1412
+
1413
+ ---
1414
+
1415
+ ## Constructing Subagent Context
1416
+
1417
+ **Rule:** `rules/core/subagent-context-construction.md`
1418
+
1419
+ Every prompt dispatched to a subagent must be **explicitly constructed** by the orchestrator. Subagents do not inherit session context, job state, or prior agent output — they only know what the orchestrator tells them.
1420
+
1421
+ ### Template dispatch block
1422
+
1423
+ Use this structure for every subagent dispatch:
1424
+
1425
+ ```
1426
+ Task({
1427
+ description: "<one-line summary for logs>",
1428
+ subagent_type: "general",
1429
+ prompt: |
1430
+ ## Task
1431
+ <Exactly what to do — no ambiguity>
1432
+
1433
+ ## Acceptance Criteria
1434
+ - <criterion 1>
1435
+ - <criterion 2>
1436
+
1437
+ ## Context
1438
+ <Only what is relevant for THIS task — decisions, constraints, background>
1439
+
1440
+ ## Files to read
1441
+ - <absolute/path/to/file1.ts>
1442
+ - <absolute/path/to/file2.ts>
1443
+
1444
+ ## Constraints
1445
+ - Do NOT modify <file or pattern>
1446
+ - <other hard stops>
1447
+ })
1448
+ ```
1449
+
1450
+ ### Minimality principle
1451
+
1452
+ Pass only what the subagent needs for this specific task. Do not dump job state, full analysis JSON, or conversation history. Extraneous context fills the subagent's context window with noise and increases hallucination risk.
1453
+
1454
+ Each subagent type gets scoped context:
1455
+ - `issue-analyzer` — issue data + codebase paths only
1456
+ - `context-collector` — focus areas + analysis summary (not full analysis JSON)
1457
+ - `task-implementer` — its specific task object + `CONTEXT_PATH` (not other tasks' data)
1458
+ - Reviewers — diff range + file list (not implementation details)
1459
+
1460
+ ### Red Flag
1461
+
1462
+ **"The subagent can read the job state.json if it needs more context"**
1463
+
1464
+ → Iron Law: **Orchestrator constructs context. Subagents receive, not retrieve.**
1465
+
1466
+ The subagent must not fetch orchestrator state independently. If the subagent needs information, the orchestrator puts it in the dispatch prompt. A subagent reading `state.json` on its own is a sign the orchestrator dispatch was incomplete.
1467
+
1468
+ ---
1469
+
1470
+ ## Automation Settings
1471
+
1472
+ | Setting | Default | Options | Description |
1473
+ |---------|---------|---------|-------------|
1474
+ | `skip_confirmation` | `true` | true/false | Skip confirmation for sub-agents |
1475
+ | `base_branch` | auto-detect | any | Base branch (auto-detect from repo default, or ask user) |
1476
+ | `max_review_iterations` | `3` | 1-5 | Max review → fix iterations |
1477
+ | `create_pr` | `true` | true/false | Whether to propose PR at the end |
1478
+ | `auto_create_pr` | `false` | true/false | Auto-create PR without asking |
1479
+ | `review_mode` | `"code-review"` | `"code-review"` / `"individual"` | Use 4-agent parallel or individual reviewers |
1480
+ | `reviewers` | `["code-ai-review", "code-boss-review", "code-style-review"]` | skill names | Individual reviewers (when review_mode=individual) |
1481
+ | `conditional_reviewers` | `{"code-mobx-store-review": "*.store.ts"}` | skill→pattern | Conditional reviewers |
1482
+ | `convention_reviewers` | `"ask"` | `"ask"` / `"all"` / `"none"` / skill names | Optional convention reviewers to include in review |
1483
+ | `run_final_checks` | `true` | true/false | Run lint/type-check/test |
1484
+ | `run_interview` | `true` | true/false | Run interview skill in Phase 0 |
1485
+ | `dry_run` | `false` | true/false | Plan-only mode: full Phase 0+1, no agent dispatch or git ops |
1486
+ | `log_prompt_sizes` | `true` | true/false | Store prompt char count per step in state.json for observability |
1487
+ | `plan_approval` | `true` | true/false | Show agent plan and ask approve/adjust before execution (1.3) |
1488
+ | `run_test_gen` | `true` | true/false | Auto-run test-gen if implementer skips tests |
1489
+ | `run_security_audit` | `true` | true/false | Auto-run security-audit if auth/API/DB files touched |
1490
+ | `run_perf_check` | `true` | true/false | Auto-run perf-check if frontend/bundle files changed |
1491
+ | `run_changelog` | `true` | true/false | Auto-generate changelog entry and include in PR description |
1492
+ | `publish_pr_review_report` | `ask` | `ask`/`comment`/`comment-and-ai-artifact`/`none`/`true`/`false` | Whether to publish a concise PR review comment and optional detailed AI markdown artifact |
1493
+ | `run_deploy` | `ask` | `ask`/`true`/`false` | Post-PR deploy: ask user (ask), always deploy (true), never (false) |
1494
+
1495
+ ## Dry-Run Mode
1496
+
1497
+ When `dry_run: true` is set (or `--dry-run` is passed):
1498
+
1499
+ 1. **Phase 0** runs fully — context collection, interviewer (if applicable), summary + confirm
1500
+ 2. **Phase 1** runs fully — plan is built and displayed with step tree
1501
+ 3. **Phase 2 is skipped entirely** — no sub-agents dispatched, no git operations
1502
+ 4. **Output:** Full plan tree with agent names, input data shapes, dependencies:
1503
+
1504
+ ```
1505
+ Dry-run plan for: issue-4141--pipeline-validation
1506
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1507
+ Step 1: analyze [issue-analyzer] → input: issue #4141
1508
+ Step 2: context [context-collector] → input: analysis result, project_dir
1509
+ Step 3: prepare [orchestrator] → creates: feature/pipeline-validation
1510
+ Step 4: implement [task-implementer × 3] → sequential, 3 tasks
1511
+ Step 5: sanity-check [orchestrator] → verifies commits exist
1512
+ Step 6: review [code-review × 4] → parallel
1513
+ Step 7: fix [task-implementer] → conditional: if NEEDS_FIX
1514
+ Step 8: checks [orchestrator] → lint + type-check + test
1515
+ Step 9: report [orchestrator] → aggregates all results
1516
+ Step 10: pr [orchestrator + gh CLI] → conditional: if create_pr
1517
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1518
+ Estimated sub-agent calls: 11-14 (varies with tasks and review findings)
1519
+ No changes will be made. Use without --dry-run to execute.
1520
+ ```
1521
+
1522
+ 5. Ask user: "Execute this plan? (yes / adjust / abort)"
1523
+
1524
+ ## Budget Guards & Timeouts
1525
+
1526
+ The orchestrator enforces resource limits to prevent runaway sub-agents:
1527
+
1528
+ | Guard | Default | Description |
1529
+ |-------|---------|-------------|
1530
+ | `step_timeout_ms` | `300000` (5 min) | Max time per step. Kill agent if exceeded. |
1531
+ | `implementation_timeout_ms` | `600000` (10 min) | Max time for full implementation phase |
1532
+ | `total_job_timeout_ms` | `1800000` (30 min) | Max time for entire job. Abort to Phase 3 if exceeded. |
1533
+ | `max_retries_per_step` | `2` | Max retries for a failed step before asking user |
1534
+
1535
+ **Timeout behavior:**
1536
+ - When a step times out → mark as `failed`, record partial results if any
1537
+ - Ask user: "Step X timed out after Y minutes. Retry / Skip / Abort?"
1538
+ - If total job timeout → force transition to Phase 3 (COMPLETION) with status "timeout"
1539
+
1540
+ **Context passing rules (minimal context principle):**
1541
+ - `issue-analyzer`: receives only issue data + codebase paths (NOT previous job state)
1542
+ - `context-collector`: receives focus areas + analysis summary (NOT full analysis JSON)
1543
+ - `task-implementer`: receives only its specific task object + context.md path (NOT other tasks' results)
1544
+ - Reviewers: receive only the diff range + file list (NOT implementation details)
1545
+
1546
+ ---
1547
+
1548
+ ## Error Handling
1549
+
1550
+ Each step failure is classified into one of three classes with different recovery paths:
1551
+
1552
+ | Class | Meaning | Action |
1553
+ |-------|---------|--------|
1554
+ | `terminal` | Unrecoverable — cannot continue | ABORT immediately, surface actionable message |
1555
+ | `retryable` | Transient failure (bad output, timeout) | Auto-retry up to 2× with **identical prompt**. After 2 failures → escalate to `recoverable` |
1556
+ | `recoverable` | Partial success or skippable failure | Ask user with specific "continue from here / skip step / abort" options |
1557
+
1558
+ ### Error Table
1559
+
1560
+ | Error | Class | Action |
1561
+ |-------|-------|--------|
1562
+ | Issue not found (404) | `terminal` | ABORT — issue-analyzer reports 404 |
1563
+ | Analysis returns 0 tasks | `recoverable` | Try smart fallback: (1) re-read issue with broader scope, (2) ask user to clarify, (3) if still 0 → ABORT |
1564
+ | Branch/worktree creation fails | `terminal` | ABORT — report git error. NEVER fall back to `git checkout -b` |
1565
+ | Interviewer `ready_to_proceed: false` | `terminal` | STOP — tell user which blockers remain |
1566
+ | Sub-agent returns malformed JSON | `retryable` | Retry with: "Output was malformed. Fix: [errors]. Try again." (max 2×) |
1567
+ | Sub-agent timeout | `retryable` | Retry with identical prompt (max 2×) |
1568
+ | Task implementation fails | `recoverable` | Ask: "Step failed. Continue remaining tasks / skip this task / abort?" |
1569
+ | Job-documenter returns error | `recoverable` | Log warning, continue (documentation is non-blocking) |
1570
+ | All reviewers fail | `recoverable` | Skip review, add warning to report, continue to checks |
1571
+ | Fix loop exceeds max_review_iterations | `recoverable` | Log unresolved findings, continue to checks |
1572
+ | Final checks fail | `recoverable` | Include in report, still propose PR (user decides) |
1573
+ | gh CLI not available | `recoverable` | Print PR data, user creates manually |
1574
+
1575
+ ### Retry Protocol (for `retryable` errors)
1576
+
1577
+ ```
1578
+ attempt 1: run step normally
1579
+ → failure: classify error
1580
+ → if retryable: retry with EXACT same prompt + "Fix these errors: [list]"
1581
+ → if fails again: escalate to recoverable → ask user
1582
+ → if success: continue
1583
+ ```
1584
+
1585
+ **Critical:** On retry, use the **same prompt** stored in `state.json → step.prompt`. Never re-derive it — re-derivation causes drift.
1586
+
1587
+ ---
1588
+
1589
+ ## Progress Notifications
1590
+
1591
+ The orchestrator must keep the user informed during long-running execution. This is especially important for non-interactive channels (Telegram, Slack, CI).
1592
+
1593
+ **At each phase transition:**
1594
+ ```
1595
+ 🔄 Phase 0 → Phase 1: Building execution plan...
1596
+ 🔄 Phase 1 → Phase 2: Executing 7 steps...
1597
+ ✅ Phase 2 → Phase 3: Execution complete, generating report...
1598
+ ```
1599
+
1600
+ **At each step transition (Phase 2):**
1601
+ ```
1602
+ 📋 Job: issue-4141--pipeline-validation
1603
+ ├─ ✅ Analyze issue — 3 tasks found
1604
+ ├─ ✅ Collect context — context.md ready
1605
+ ├─ ✅ Prepare branch — feature/pipeline-validation
1606
+ ├─ 🔄 Implement (2/3 tasks done)
1607
+ │ ├─ ✅ task-1: Add validation schema
1608
+ │ ├─ ✅ task-2: Implement validator
1609
+ │ └─ 🔄 task-3: Add integration tests...
1610
+ ├─ ⏳ Review
1611
+ ├─ ⏳ Fix (if needed)
1612
+ ├─ ⏳ Final checks
1613
+ └─ ⏳ PR
1614
+ ```
1615
+
1616
+ **Minimum notification interval:** Every 30 seconds during long steps (implementation, review). This prevents the user from thinking the process is stuck.
1617
+
1618
+ **If notification tools are unavailable** (no MCP, no Telegram): fall back to inline text output between steps.
1619
+
1620
+ ---
1621
+
1622
+ ## Rules of Engagement
1623
+
1624
+ 1. **DO** ALWAYS collect context in Phase 0 — project directory is MANDATORY, never assume.
1625
+ 2. **DO** build plans dynamically based on intent — not a fixed 8-phase pipeline.
1626
+ 3. **DO** initialize job documentation before executing any step.
1627
+ 4. **DO** document every step result via job-documenter.
1628
+ 5. **DO** parallelize independent tasks and reviewers where safe.
1629
+ 6. **DO** respect dependency order — use wave-based execution for implementation.
1630
+ 7. **DO** limit review → fix loop to max_review_iterations.
1631
+ 8. **DO** present PR proposal to user before creating (unless auto_create_pr).
1632
+ 9. **DO** tell user where documentation is stored at completion.
1633
+ 10. **DO** ALWAYS use `git worktree add` for feature branches — NEVER `git checkout -b`.
1634
+ 11. **DO** run ALL commands in the **worktree directory**, never in the original project.
1635
+ 12. **DO** ask user for confirmation before extending plan (e.g., analyze → implement).
1636
+ 13. **DO** send progress notifications at phase/step transitions and every 30s during long steps.
1637
+ 14. **DO** use auto-detected `package_manager` and `run_command` — never hardcode `npm`.
1638
+ 15. **DO NOT** ask the user anything during execution (after Phase 0) — except for critical failures and plan extension decisions.
1639
+ 16. **DO NOT** push the branch until user confirms (or auto_create_pr).
1640
+ 17. **DO NOT** skip job documentation — it's a core feature, not optional.
1641
+ 18. **DO NOT** create job documentation for sub-agent results directly — orchestrator formats and sends to documenter.
1642
+ 19. **DO** store the prompt used for each sub-agent step in `state.json → step.prompt` before dispatching — required for retry and resume.
1643
+ 20. **DO** classify every step failure as `terminal`, `retryable`, or `recoverable` — never just abort or ask without classifying first.
1644
+ 21. **DO** show agent-explicit plan in 1.3 and ask approve/adjust — unless `plan_approval: false`.
1645
+ 22. **DO** run `sanity-check` after every implement step before dispatching review.
1646
+ 23. **DO** auto-trigger `test-gen` if implementer produced no test files (unless `run_test_gen: false`).
1647
+ 24. **DO** auto-trigger `security-audit` if diff touches auth/API/DB/env files (unless `run_security_audit: false`).
1648
+ 25. **DO** include changelog entry in PR body (unless `run_changelog: false`).
1649
+ 26. **DO NOT** deploy without user confirmation (unless `run_deploy: true` explicitly set).
1650
+
1651
+ ---
1652
+
1653
+ ## Configurable Jobs Root
1654
+
1655
+ The jobs documentation root is configurable, not hardcoded:
1656
+
1657
+ **Resolution order:**
1658
+ 1. `JOBS_ROOT` passed explicitly by the orchestrator in the sub-agent dispatch prompt
1659
+ 2. `GDMETAPRO_JOBS_ROOT` environment variable (if set)
1660
+ 3. Default: `.metaproject/jobs/` ← project-local (PROJECT_DIR is known by Phase 0.2)
1661
+
1662
+ ```bash
1663
+ JOBS_ROOT="${GDMETAPRO_JOBS_ROOT:-.metaproject/jobs}"
1664
+ ```
1665
+
1666
+ All references to job paths in sub-agent prompts must use the resolved `JOBS_ROOT`.
1667
+
1668
+ ---
1669
+
1670
+ ## Post-Mortem (for failed/aborted jobs)
1671
+
1672
+ When a job ends with status `aborted`, `timeout`, or has unresolved critical issues:
1673
+
1674
+ 1. **Auto-generate post-mortem** document:
1675
+ ```markdown
1676
+ # Post-Mortem: <job-name>
1677
+
1678
+ ## Timeline
1679
+ - Phase 0 completed: <timestamp>
1680
+ - Phase 2, step "implement" started: <timestamp>
1681
+ - Step "task-3" failed after 2 retries: <timestamp>
1682
+ - Job aborted by user: <timestamp>
1683
+
1684
+ ## What Went Wrong
1685
+ - <Step name> failed with: <error class> — <error message>
1686
+ - Root cause hypothesis: <analysis>
1687
+
1688
+ ## What Worked
1689
+ - <N> tasks completed successfully
1690
+ - Context collection was accurate
1691
+
1692
+ ## Recommendations for Retry
1693
+ - Fix <specific issue> before re-running
1694
+ - Consider splitting task-3 into smaller subtasks
1695
+ - Increase step_timeout_ms if timeout was the issue
1696
+ ```
1697
+
1698
+ 2. Save to `.metaproject/jobs/<job-name>/post-mortem.md`
1699
+ 3. Include in final user message: "Post-mortem saved to `.metaproject/jobs/<job-name>/post-mortem.md`"
1700
+
1701
+ ---
1702
+
1703
+ ## Metrics Collection
1704
+
1705
+ The orchestrator tracks timing and token usage for each step to enable optimization over time.
1706
+
1707
+ **Collected per step:**
1708
+ ```json
1709
+ {
1710
+ "step_id": "implement",
1711
+ "started_at": "2024-03-15T10:30:00Z",
1712
+ "completed_at": "2024-03-15T10:35:22Z",
1713
+ "duration_ms": 322000,
1714
+ "total_tokens": 84500,
1715
+ "status": "success",
1716
+ "retries": 0
1717
+ }
1718
+ ```
1719
+
1720
+ **Saved to:** `.metaproject/jobs/<job-name>/metrics.json`
1721
+
1722
+ **Aggregated in report:**
1723
+ ```markdown
1724
+ ## Metrics
1725
+ | Step | Duration | Tokens | Retries |
1726
+ |------|----------|--------|---------|
1727
+ | Analyze | 45s | 12K | 0 |
1728
+ | Context | 30s | 8K | 0 |
1729
+ | Implement | 5m 22s | 84K | 0 |
1730
+ | Review | 1m 10s | 25K | 0 |
1731
+ | **Total** | **7m 47s** | **129K** | **0** |
1732
+ ```
1733
+
1734
+ This data helps identify which steps are bottlenecks and whether budget guards need adjustment.