@khoavu882/doflow 0.0.0-stage → 2.0.0-beta.3

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 (407) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +132 -2
  3. package/bin/doflow.js +44 -0
  4. package/core/.antigravity-plugin/hooks.json +39 -0
  5. package/core/.antigravity-plugin/mcp_config.json +18 -0
  6. package/core/.antigravity-plugin/plugin.json +31 -0
  7. package/core/.claude-plugin/marketplace.json +20 -0
  8. package/core/.claude-plugin/plugin.json +21 -0
  9. package/core/.codex-plugin/marketplace.json +20 -0
  10. package/core/.codex-plugin/plugin.json +35 -0
  11. package/core/.plugin/plugin.json +19 -0
  12. package/core/harnesses/antigravity/hooks/pre-implementation-gate.sh +9 -0
  13. package/core/harnesses/antigravity/hooks/stop-check.sh +10 -0
  14. package/core/harnesses/claude/hooks/lib.sh +304 -0
  15. package/core/harnesses/claude/hooks/mcp-tool-guard.sh +20 -0
  16. package/core/harnesses/claude/hooks/permission-audit.sh +47 -0
  17. package/core/harnesses/claude/hooks/post-compact.sh +74 -0
  18. package/core/harnesses/claude/hooks/post-edit-lint.sh +36 -0
  19. package/core/harnesses/claude/hooks/post-tool-failure.sh +47 -0
  20. package/core/harnesses/claude/hooks/pre-bash-guard.sh +20 -0
  21. package/core/harnesses/claude/hooks/pre-compact.sh +43 -0
  22. package/core/harnesses/claude/hooks/pre-implement-gate.sh +21 -0
  23. package/core/harnesses/claude/hooks/session-end.sh +89 -0
  24. package/core/harnesses/claude/hooks/session-start.sh +5 -0
  25. package/core/harnesses/claude/hooks/skill-config-audit.sh +39 -0
  26. package/core/harnesses/claude/hooks/stop-check.sh +5 -0
  27. package/core/harnesses/claude/hooks/subagent-audit.sh +7 -0
  28. package/core/harnesses/claude/hooks/user-prompt-submit.sh +5 -0
  29. package/core/harnesses/claude/settings/keybindings.json +20 -0
  30. package/core/harnesses/claude/settings/settings.json +201 -0
  31. package/core/harnesses/claude/statusline/doflow-statusline.sh +49 -0
  32. package/core/harnesses/codex/agents/core-implementer.toml +7 -0
  33. package/core/harnesses/codex/agents/quality-guardian.toml +8 -0
  34. package/core/harnesses/codex/agents/research-writer.toml +8 -0
  35. package/core/harnesses/codex/agents/spec-analyst.toml +8 -0
  36. package/core/harnesses/codex/agents/system-architect.toml +9 -0
  37. package/core/harnesses/codex/config/config.toml +10 -0
  38. package/core/harnesses/codex/hooks/hooks.json +122 -0
  39. package/core/harnesses/codex/hooks/lib.sh +335 -0
  40. package/core/harnesses/codex/hooks/mcp-tool-guard.sh +18 -0
  41. package/core/harnesses/codex/hooks/post-edit-lint.impl.sh +52 -0
  42. package/core/harnesses/codex/hooks/post-edit-lint.sh +6 -0
  43. package/core/harnesses/codex/hooks/pre-bash-guard.sh +18 -0
  44. package/core/harnesses/codex/hooks/pre-compact.impl.sh +46 -0
  45. package/core/harnesses/codex/hooks/pre-compact.sh +9 -0
  46. package/core/harnesses/codex/hooks/pre-implement-gate.sh +19 -0
  47. package/core/harnesses/codex/hooks/session-end.impl.sh +92 -0
  48. package/core/harnesses/codex/hooks/session-end.sh +5 -0
  49. package/core/harnesses/codex/hooks/session-start.sh +5 -0
  50. package/core/harnesses/codex/hooks/stop-check.sh +8 -0
  51. package/core/harnesses/codex/hooks/subagent-audit.sh +8 -0
  52. package/core/harnesses/codex/hooks/user-prompt-submit.sh +6 -0
  53. package/core/harnesses/gemini/hooks/hooks.json +77 -0
  54. package/core/harnesses/gemini/hooks/lib.sh +302 -0
  55. package/core/harnesses/gemini/hooks/mcp-tool-guard.sh +21 -0
  56. package/core/harnesses/gemini/hooks/post-edit-lint.sh +39 -0
  57. package/core/harnesses/gemini/hooks/pre-bash-guard.sh +21 -0
  58. package/core/harnesses/gemini/hooks/pre-compact.sh +38 -0
  59. package/core/harnesses/gemini/hooks/pre-implement-gate.sh +22 -0
  60. package/core/harnesses/gemini/hooks/session-end.impl.sh +89 -0
  61. package/core/harnesses/gemini/hooks/session-end.sh +5 -0
  62. package/core/harnesses/gemini/hooks/session-start.sh +5 -0
  63. package/core/harnesses/gemini/settings/adapter-defaults.json +4 -0
  64. package/core/harnesses/kiro/agents/doflow.json +58 -0
  65. package/core/harnesses/kiro/hooks/doflow.json +53 -0
  66. package/core/harnesses/kiro/hooks/lib.sh +324 -0
  67. package/core/harnesses/kiro/hooks/mcp-tool-guard.sh +9 -0
  68. package/core/harnesses/kiro/hooks/pre-bash-guard.sh +9 -0
  69. package/core/harnesses/kiro/hooks/pre-implement-gate.sh +9 -0
  70. package/core/harnesses/kiro/hooks/session-start.sh +9 -0
  71. package/core/harnesses/kiro/hooks/stop-check.sh +43 -0
  72. package/core/harnesses/shared/hooks/ENVELOPE_MIGRATION.md +39 -0
  73. package/core/harnesses/shared/hooks/adapters/antigravity.js +111 -0
  74. package/core/harnesses/shared/hooks/adapters/arg-fields.js +19 -0
  75. package/core/harnesses/shared/hooks/adapters/gemini.js +114 -0
  76. package/core/harnesses/shared/hooks/hooks.json +47 -0
  77. package/core/harnesses/shared/hooks/policies/blocked-patterns.conf +91 -0
  78. package/core/harnesses/shared/hooks/policies/capture-failure.sh +97 -0
  79. package/core/harnesses/shared/hooks/policies/deny-json.sh +29 -0
  80. package/core/harnesses/shared/hooks/policies/lib.sh +501 -0
  81. package/core/harnesses/shared/hooks/policies/mcp-policy.conf +21 -0
  82. package/core/harnesses/shared/hooks/policies/mcp-tool-guard.sh +91 -0
  83. package/core/harnesses/shared/hooks/policies/pre-bash-guard.sh +328 -0
  84. package/core/harnesses/shared/hooks/policies/pre-implementation-gate.sh +496 -0
  85. package/core/harnesses/shared/hooks/policies/prompt-nudge.jq +131 -0
  86. package/core/harnesses/shared/hooks/policies/session-context.sh +141 -0
  87. package/core/harnesses/shared/hooks/policies/stop-check.sh +264 -0
  88. package/core/harnesses/shared/hooks/policies/subagent-audit.sh +46 -0
  89. package/core/harnesses/shared/hooks/policies/user-prompt-submit.sh +235 -0
  90. package/core/harnesses/shared/hooks/stream-hook-runner.js +590 -0
  91. package/core/harnesses/shared/locator/doflow-run +87 -0
  92. package/core/registry/advice.json +101 -0
  93. package/core/registry/assets.json +792 -0
  94. package/core/registry/capabilities.json +120 -0
  95. package/core/registry/contracts.json +189 -0
  96. package/core/registry/external-tools.json +191 -0
  97. package/core/registry/harnesses.json +2062 -0
  98. package/core/registry/lifecycle.json +231 -0
  99. package/core/registry/mcp.json +18 -0
  100. package/core/registry/models.json +79 -0
  101. package/core/registry/readiness-templates.json +118 -0
  102. package/core/registry/routes.json +47 -0
  103. package/core/registry/storage.json +1057 -0
  104. package/core/registry/verification.json +258 -0
  105. package/core/registry/workflows.json +790 -0
  106. package/core/shared/agent-specs/core-implementer.md +73 -0
  107. package/core/shared/agent-specs/quality-guardian.md +28 -0
  108. package/core/shared/agent-specs/research-writer.md +31 -0
  109. package/core/shared/agent-specs/spec-analyst.md +33 -0
  110. package/core/shared/agent-specs/system-architect.md +29 -0
  111. package/core/shared/guidance/DOFLOW_CORE.md +8 -0
  112. package/core/shared/guidance/FLAGS.md +25 -0
  113. package/core/shared/guidance/PRINCIPLES.md +61 -0
  114. package/core/shared/guidance/VERSION +1 -0
  115. package/core/shared/guidance/mcp/MCP_Context7.md +18 -0
  116. package/core/shared/guidance/mcp/MCP_Sequential.md +17 -0
  117. package/core/shared/guidance/modes/MODE_Brainstorming.md +46 -0
  118. package/core/shared/guidance/modes/MODE_DeepResearch.md +69 -0
  119. package/core/shared/guidance/modes/MODE_Introspection.md +33 -0
  120. package/core/shared/guidance/modes/MODE_Orchestration.md +57 -0
  121. package/core/shared/guidance/modes/MODE_Task_Management.md +74 -0
  122. package/core/shared/guidance/pointers/claude-gemini.md +2 -0
  123. package/core/shared/guidance/pointers/codex.md +6 -0
  124. package/core/shared/guidance/references/ARTIFACT_FORMAT.md +373 -0
  125. package/core/shared/guidance/references/ARTIFACT_VOICE.md +104 -0
  126. package/core/shared/guidance/references/CONSTITUTION_BASE.md +47 -0
  127. package/core/shared/guidance/references/DIAGRAM_GUIDE.md +161 -0
  128. package/core/shared/guidance/references/DOFLOW_CHAIN.md +87 -0
  129. package/core/shared/guidance/references/EVIDENCE_LEDGER.md +93 -0
  130. package/core/shared/guidance/references/MODEL_SELECTION.md +74 -0
  131. package/core/shared/guidance/references/ORCHESTRATION.md +36 -0
  132. package/core/shared/guidance/references/RESEARCH_CONFIG.md +21 -0
  133. package/core/shared/guidance/references/WORKFLOW_HANDOFF.md +81 -0
  134. package/core/shared/guidance/rules/RULE_01_SAFETY.md +25 -0
  135. package/core/shared/guidance/rules/RULE_02_WORKFLOW.md +23 -0
  136. package/core/shared/guidance/rules/RULE_03_QUALITY.md +14 -0
  137. package/core/shared/guidance/rules/RULE_04_QUESTIONS.md +46 -0
  138. package/core/shared/scripts/doflow/assets/mermaid-theme.json +46 -0
  139. package/core/shared/scripts/doflow/bash/do-exec-paths.sh +167 -0
  140. package/core/shared/scripts/doflow/bash/do-git-state.sh +546 -0
  141. package/core/shared/scripts/doflow/bash/do-parallel-check.sh +208 -0
  142. package/core/shared/scripts/doflow/bash/do-paths.sh +347 -0
  143. package/core/shared/scripts/doflow/bash/do-prereqs.sh +66 -0
  144. package/core/shared/scripts/doflow/bash/do-review-package.sh +127 -0
  145. package/core/shared/scripts/doflow/bash/do-task-brief.sh +698 -0
  146. package/core/shared/scripts/doflow/bash/render-audit.sh +224 -0
  147. package/core/shared/scripts/doflow/bash/render-diagrams.sh +177 -0
  148. package/core/shared/scripts/doflow/bash/render-puml.sh +223 -0
  149. package/core/shared/scripts/doflow/bash/sync-context.sh +66 -0
  150. package/core/shared/scripts/doflow/bash/validate-artifacts.sh +526 -0
  151. package/core/shared/scripts/doflow/bin/doflow-run +592 -0
  152. package/core/shared/skills/do/SKILL.md +128 -0
  153. package/core/shared/skills/do/references/estimation.md +13 -0
  154. package/core/shared/skills/do/references/pm_routing.md +25 -0
  155. package/core/shared/skills/do/references/tool_matrix.md +52 -0
  156. package/core/shared/skills/do-brainstorm/SKILL.md +252 -0
  157. package/core/shared/skills/do-code-review/README.md +49 -0
  158. package/core/shared/skills/do-code-review/SKILL.md +333 -0
  159. package/core/shared/skills/do-code-review/assets/sample_c_clean.c +71 -0
  160. package/core/shared/skills/do-code-review/assets/sample_c_smells.c +66 -0
  161. package/core/shared/skills/do-code-review/assets/sample_cpp_shift.cpp +19 -0
  162. package/core/shared/skills/do-code-review/assets/sample_csharp_clean.cs +100 -0
  163. package/core/shared/skills/do-code-review/assets/sample_csharp_smells.cs +78 -0
  164. package/core/shared/skills/do-code-review/assets/sample_java_clean.java +55 -0
  165. package/core/shared/skills/do-code-review/assets/sample_java_smells.java +56 -0
  166. package/core/shared/skills/do-code-review/assets/sample_json_clean.json +7 -0
  167. package/core/shared/skills/do-code-review/assets/sample_markdown_clean.md +30 -0
  168. package/core/shared/skills/do-code-review/assets/sample_markdown_smells.md +29 -0
  169. package/core/shared/skills/do-code-review/assets/sample_shell_heredoc.sh +38 -0
  170. package/core/shared/skills/do-code-review/assets/sample_shell_smells.sh +15 -0
  171. package/core/shared/skills/do-code-review/assets/sample_typescript_strings.ts +36 -0
  172. package/core/shared/skills/do-code-review/assets/sample_yaml_smells.yaml +6 -0
  173. package/core/shared/skills/do-code-review/content-types/config.md +83 -0
  174. package/core/shared/skills/do-code-review/content-types/markdown.md +132 -0
  175. package/core/shared/skills/do-code-review/expected_outputs/sample_c_clean_quality.json +79 -0
  176. package/core/shared/skills/do-code-review/expected_outputs/sample_c_smells_quality.json +169 -0
  177. package/core/shared/skills/do-code-review/expected_outputs/sample_cpp_shift_quality.json +49 -0
  178. package/core/shared/skills/do-code-review/expected_outputs/sample_csharp_clean_quality.json +149 -0
  179. package/core/shared/skills/do-code-review/expected_outputs/sample_csharp_smells_quality.json +157 -0
  180. package/core/shared/skills/do-code-review/expected_outputs/sample_java_clean_quality.json +67 -0
  181. package/core/shared/skills/do-code-review/expected_outputs/sample_java_smells_quality.json +97 -0
  182. package/core/shared/skills/do-code-review/expected_outputs/sample_json_clean_quality.json +33 -0
  183. package/core/shared/skills/do-code-review/expected_outputs/sample_markdown_clean_quality.json +1 -0
  184. package/core/shared/skills/do-code-review/expected_outputs/sample_markdown_smells_quality.json +16 -0
  185. package/core/shared/skills/do-code-review/expected_outputs/sample_shell_heredoc_quality.json +54 -0
  186. package/core/shared/skills/do-code-review/expected_outputs/sample_shell_smells_quality.json +91 -0
  187. package/core/shared/skills/do-code-review/expected_outputs/sample_typescript_strings_quality.json +60 -0
  188. package/core/shared/skills/do-code-review/expected_outputs/sample_yaml_smells_quality.json +46 -0
  189. package/core/shared/skills/do-code-review/languages/c.md +103 -0
  190. package/core/shared/skills/do-code-review/languages/cpp.md +103 -0
  191. package/core/shared/skills/do-code-review/languages/csharp.md +97 -0
  192. package/core/shared/skills/do-code-review/languages/dart.md +108 -0
  193. package/core/shared/skills/do-code-review/languages/go.md +92 -0
  194. package/core/shared/skills/do-code-review/languages/java.md +103 -0
  195. package/core/shared/skills/do-code-review/languages/kotlin.md +88 -0
  196. package/core/shared/skills/do-code-review/languages/php.md +109 -0
  197. package/core/shared/skills/do-code-review/languages/python.md +94 -0
  198. package/core/shared/skills/do-code-review/languages/ruby.md +105 -0
  199. package/core/shared/skills/do-code-review/languages/rust.md +99 -0
  200. package/core/shared/skills/do-code-review/languages/shell.md +90 -0
  201. package/core/shared/skills/do-code-review/languages/swift.md +88 -0
  202. package/core/shared/skills/do-code-review/languages/typescript.md +97 -0
  203. package/core/shared/skills/do-code-review/review-policy.json +47 -0
  204. package/core/shared/skills/do-code-review/rules/universal.md +49 -0
  205. package/core/shared/skills/do-code-review/scripts/code_quality_checker.py +1696 -0
  206. package/core/shared/skills/do-code-review/scripts/doc_quality_checker.py +532 -0
  207. package/core/shared/skills/do-code-review/scripts/pr_analyzer.py +620 -0
  208. package/core/shared/skills/do-code-review/scripts/review_report_generator.py +505 -0
  209. package/core/shared/skills/do-constitution/SKILL.md +72 -0
  210. package/core/shared/skills/do-design/SKILL.md +212 -0
  211. package/core/shared/skills/do-diagnose/SKILL.md +156 -0
  212. package/core/shared/skills/do-diagnose/references/code_audit.md +15 -0
  213. package/core/shared/skills/do-diagnose/references/refactoring.md +12 -0
  214. package/core/shared/skills/do-diagnose/references/root_cause.md +17 -0
  215. package/core/shared/skills/do-document/SKILL.md +81 -0
  216. package/core/shared/skills/do-document/references/api-reference.md +42 -0
  217. package/core/shared/skills/do-document/references/deep_research.md +18 -0
  218. package/core/shared/skills/do-document/references/embedded-research.md +11 -0
  219. package/core/shared/skills/do-document/references/implementation-flow.md +105 -0
  220. package/core/shared/skills/do-document/references/index_generator.md +9 -0
  221. package/core/shared/skills/do-document/references/user-guide.md +22 -0
  222. package/core/shared/skills/do-execute-plan/SKILL.md +261 -0
  223. package/core/shared/skills/do-execute-plan/references/handoff_record.md +57 -0
  224. package/core/shared/skills/do-execute-plan/references/parallel_dispatch.md +92 -0
  225. package/core/shared/skills/do-execute-plan/references/readiness_gate.md +155 -0
  226. package/core/shared/skills/do-execute-plan/references/run_position.md +63 -0
  227. package/core/shared/skills/do-execute-plan/references/scaffold.md +441 -0
  228. package/core/shared/skills/do-execute-plan/references/task_attempts.md +41 -0
  229. package/core/shared/skills/do-flow/SKILL.md +186 -0
  230. package/core/shared/skills/do-flow/references/task_classes.md +134 -0
  231. package/core/shared/skills/do-git/SKILL.md +115 -0
  232. package/core/shared/skills/do-git/references/hotfix-ritual.md +44 -0
  233. package/core/shared/skills/do-git/references/lifecycle-policy.md +54 -0
  234. package/core/shared/skills/do-git/references/release-ritual.md +64 -0
  235. package/core/shared/skills/do-implement/SKILL.md +222 -0
  236. package/core/shared/skills/do-plan/SKILL.md +219 -0
  237. package/core/shared/skills/do-test/SKILL.md +113 -0
  238. package/core/shared/templates/doflow/constitution-template.md +28 -0
  239. package/core/shared/templates/doflow/data-model-template.md +169 -0
  240. package/core/shared/templates/doflow/design-template.md +193 -0
  241. package/core/shared/templates/doflow/external-contract-template.md +35 -0
  242. package/core/shared/templates/doflow/intent-template.md +45 -0
  243. package/core/shared/templates/doflow/plan-template.md +151 -0
  244. package/core/shared/templates/doflow/question-log-template.md +51 -0
  245. package/core/shared/templates/doflow/requirement-template.md +126 -0
  246. package/core/shared/templates/doflow/specs-template.md +55 -0
  247. package/core/shared/templates/doflow/state-template.md +59 -0
  248. package/core/shared/workflows/do-flow-chain.md +17 -0
  249. package/package.json +46 -4
  250. package/src/adapters/antigravity/index.ts +631 -0
  251. package/src/adapters/claude/index.ts +548 -0
  252. package/src/adapters/claude/mcp.ts +94 -0
  253. package/src/adapters/codex/agents.ts +208 -0
  254. package/src/adapters/codex/config.ts +272 -0
  255. package/src/adapters/codex/hooks.ts +203 -0
  256. package/src/adapters/codex/index.ts +707 -0
  257. package/src/adapters/codex/mcp.ts +271 -0
  258. package/src/adapters/codex/native-projection.ts +34 -0
  259. package/src/adapters/copilot/index.ts +413 -0
  260. package/src/adapters/copy-tree.ts +620 -0
  261. package/src/adapters/gemini/hooks.ts +210 -0
  262. package/src/adapters/gemini/index.ts +390 -0
  263. package/src/adapters/hook-commands.ts +60 -0
  264. package/src/adapters/index.ts +106 -0
  265. package/src/adapters/kiro/index.ts +310 -0
  266. package/src/adapters/mcp-entries.ts +331 -0
  267. package/src/adapters/opencode/index.ts +466 -0
  268. package/src/adapters/pi/index.ts +279 -0
  269. package/src/adapters/pi/json-members.ts +185 -0
  270. package/src/adapters/pi/mcp.ts +373 -0
  271. package/src/adapters/resolve-source.ts +19 -0
  272. package/src/cli/commands/install.ts +218 -0
  273. package/src/cli/commands/list-backups.ts +21 -0
  274. package/src/cli/commands/reconcile.ts +120 -0
  275. package/src/cli/commands/remove.ts +82 -0
  276. package/src/cli/commands/rollback.ts +172 -0
  277. package/src/cli/commands/self-update.ts +33 -0
  278. package/src/cli/commands/status.ts +138 -0
  279. package/src/cli/commands/tools.ts +92 -0
  280. package/src/cli/commands/update.ts +162 -0
  281. package/src/cli/index.ts +568 -0
  282. package/src/cli/runtime-commands.ts +281 -0
  283. package/src/cli/shared.ts +218 -0
  284. package/src/helper/bash-helper.ts +34 -0
  285. package/src/helper/git.ts +24 -0
  286. package/src/helper/guardrails.ts +49 -0
  287. package/src/helper/harness-paths.ts +140 -0
  288. package/src/helper/marker-merge.ts +116 -0
  289. package/src/helper/prompt.ts +61 -0
  290. package/src/helper/repo-root.ts +29 -0
  291. package/src/helper/settings-merge.ts +151 -0
  292. package/src/helper/settings-scope.ts +33 -0
  293. package/src/helper/toml.ts +244 -0
  294. package/src/install/backup-set.ts +149 -0
  295. package/src/install/backup.ts +724 -0
  296. package/src/install/context.ts +58 -0
  297. package/src/install/manifest.ts +145 -0
  298. package/src/install/mcp.ts +254 -0
  299. package/src/install/paths.ts +84 -0
  300. package/src/install/targets.ts +90 -0
  301. package/src/install/tool-lifecycle.ts +151 -0
  302. package/src/lifecycle/bash-availability.ts +25 -0
  303. package/src/lifecycle/index.ts +812 -0
  304. package/src/lifecycle/mcp-index.ts +28 -0
  305. package/src/lifecycle/policies.ts +73 -0
  306. package/src/lifecycle/view.ts +175 -0
  307. package/src/registry/index.ts +611 -0
  308. package/src/release/sync-plugin-versions.ts +66 -0
  309. package/src/runtime/advice/cli.ts +283 -0
  310. package/src/runtime/advice/client.ts +324 -0
  311. package/src/runtime/advice/config.ts +189 -0
  312. package/src/runtime/advice/doctor.ts +169 -0
  313. package/src/runtime/advice/endpoint-guard.ts +134 -0
  314. package/src/runtime/advice/kinds.ts +154 -0
  315. package/src/runtime/advice/providers/ollama-systemone.ts +209 -0
  316. package/src/runtime/advice/record.ts +166 -0
  317. package/src/runtime/advice/registry.ts +170 -0
  318. package/src/runtime/advice/strength.ts +66 -0
  319. package/src/runtime/brief-tools.ts +342 -0
  320. package/src/runtime/c4-project.ts +371 -0
  321. package/src/runtime/capability-router.ts +484 -0
  322. package/src/runtime/checkouts.ts +170 -0
  323. package/src/runtime/claims.ts +468 -0
  324. package/src/runtime/cli-result.ts +55 -0
  325. package/src/runtime/cli.ts +678 -0
  326. package/src/runtime/command-detect.ts +516 -0
  327. package/src/runtime/context-pack.ts +492 -0
  328. package/src/runtime/decision-register.ts +493 -0
  329. package/src/runtime/evidence-ledger.ts +338 -0
  330. package/src/runtime/failure/capture.ts +272 -0
  331. package/src/runtime/failure/classifier.ts +68 -0
  332. package/src/runtime/failure/cli.ts +178 -0
  333. package/src/runtime/failure/home.ts +64 -0
  334. package/src/runtime/failure/store.ts +226 -0
  335. package/src/runtime/feature-resolve.ts +79 -0
  336. package/src/runtime/freshness.ts +177 -0
  337. package/src/runtime/health.ts +863 -0
  338. package/src/runtime/history-compactor.ts +237 -0
  339. package/src/runtime/implementation-gate.ts +321 -0
  340. package/src/runtime/inventory/coverage.ts +218 -0
  341. package/src/runtime/inventory/identity.ts +65 -0
  342. package/src/runtime/inventory/index.ts +705 -0
  343. package/src/runtime/inventory/precedence.ts +134 -0
  344. package/src/runtime/inventory/read-scopes.ts +131 -0
  345. package/src/runtime/inventory/siblings.ts +192 -0
  346. package/src/runtime/knowledge/chunker.ts +124 -0
  347. package/src/runtime/knowledge/hybrid.ts +149 -0
  348. package/src/runtime/knowledge/index-store.ts +145 -0
  349. package/src/runtime/knowledge/retrieval.ts +194 -0
  350. package/src/runtime/leak-scan.ts +185 -0
  351. package/src/runtime/lifecycle/cli.ts +276 -0
  352. package/src/runtime/lifecycle/event-store.ts +340 -0
  353. package/src/runtime/lifecycle/fold.ts +353 -0
  354. package/src/runtime/lifecycle/followup.ts +432 -0
  355. package/src/runtime/lifecycle/goal.ts +249 -0
  356. package/src/runtime/lifecycle/intent-writer.ts +86 -0
  357. package/src/runtime/lifecycle/overview.ts +292 -0
  358. package/src/runtime/lifecycle/release.ts +241 -0
  359. package/src/runtime/lifecycle/report-store.ts +221 -0
  360. package/src/runtime/lifecycle/retention.ts +212 -0
  361. package/src/runtime/lifecycle/root.ts +71 -0
  362. package/src/runtime/lifecycle/status.ts +353 -0
  363. package/src/runtime/lifecycle/store-upkeep.ts +393 -0
  364. package/src/runtime/locator-resolve.ts +158 -0
  365. package/src/runtime/mask.ts +210 -0
  366. package/src/runtime/mcp-consultations.ts +412 -0
  367. package/src/runtime/mcp-reach.ts +157 -0
  368. package/src/runtime/model-router.ts +153 -0
  369. package/src/runtime/outcome.ts +467 -0
  370. package/src/runtime/reach.ts +148 -0
  371. package/src/runtime/readiness-record.ts +150 -0
  372. package/src/runtime/readiness.ts +435 -0
  373. package/src/runtime/recovery.ts +282 -0
  374. package/src/runtime/research-request.ts +231 -0
  375. package/src/runtime/retrieval-plan.ts +578 -0
  376. package/src/runtime/scaffold/artifacts.ts +217 -0
  377. package/src/runtime/scaffold/fingerprint.ts +56 -0
  378. package/src/runtime/scaffold/generate.ts +911 -0
  379. package/src/runtime/scaffold/languages.ts +245 -0
  380. package/src/runtime/storage/cli.ts +64 -0
  381. package/src/runtime/storage/engine.ts +249 -0
  382. package/src/runtime/storage/registry.ts +130 -0
  383. package/src/runtime/storage/roots.ts +63 -0
  384. package/src/runtime/storage/rules.ts +282 -0
  385. package/src/runtime/storage/upkeep.ts +243 -0
  386. package/src/runtime/storage/work-status.ts +326 -0
  387. package/src/runtime/task-attempts.ts +415 -0
  388. package/src/runtime/task-classifier.ts +550 -0
  389. package/src/runtime/task-scope.ts +130 -0
  390. package/src/runtime/task-state.ts +176 -0
  391. package/src/runtime/trace/indicators.ts +235 -0
  392. package/src/runtime/trace/ledger.ts +626 -0
  393. package/src/runtime/trace/render.ts +76 -0
  394. package/src/runtime/trace/views.ts +459 -0
  395. package/src/runtime/verification/contract-runner.ts +341 -0
  396. package/src/runtime/verification/engine.ts +1461 -0
  397. package/src/runtime/verification/registry.ts +130 -0
  398. package/src/runtime/verification/scope-bound.ts +418 -0
  399. package/src/runtime/verification/test-selection.ts +172 -0
  400. package/src/runtime/workflow-engine.ts +588 -0
  401. package/src/runtime/workflow-orchestrator.ts +953 -0
  402. package/src/runtime/worktree.ts +340 -0
  403. package/src/state/index.ts +193 -0
  404. package/src/state/lockfile.ts +136 -0
  405. package/src/state/run-lock.ts +408 -0
  406. package/types/node-commonjs.d.ts +68 -0
  407. package/types/runtime.d.ts +91 -0
@@ -0,0 +1,105 @@
1
+ # {Feature Name} — Implementation Flow
2
+
3
+ > **Template version**: 1.0
4
+ >
5
+ > Reference for `/do-document --type impl`. It explains what each section of a generated
6
+ > `implementation-flow.md` must contain and where to pull the content from — it is not itself a
7
+ > filled-in implementation doc. Replace `{placeholders}` with real content when writing the actual
8
+ > file to `agent-docs/doflow/<slug>/implementation-flow.md` for the active feature (same
9
+ > slug-resolution mechanism the rest of the doflow chain already uses for
10
+ > `requirement.md`/`design.md`/`plan.md` — do not introduce a second one).
11
+ >
12
+ > Every section below is narrative except **Changed Surfaces**, which is a table — comparative,
13
+ > evidentiary data (a set of paths each paired with what changed) falls under the guidance tree's
14
+ > `references/ARTIFACT_FORMAT.md` §6's rule to lay that out column-wise rather than as prose or
15
+ > nested bullets.
16
+ >
17
+ > No section here is ID-bearing. This file — and any `implementation-flow.md` generated from it —
18
+ > does not participate in `validate-artifacts.sh`'s index/detail check.
19
+
20
+ ---
21
+
22
+ ## Header [Required]
23
+
24
+ Mirrors the metadata-header convention `design-template.md` already uses — a single line of
25
+ bold-label/value pairs separated by `·`, with chain artifacts cross-referenced as plain relative
26
+ paths (not markdown link syntax, matching `design-template.md`'s `./requirement.md`) — extended
27
+ with `Branch` and links to `./design.md` and `./plan.md` in addition to `./requirement.md`, since an
28
+ implementation summary sits downstream of all three:
29
+
30
+ **Feature:** `[NNN-slug]` · **Branch:** `[branch-name]` · **Status:** Draft · **Created:** `[DATE]`
31
+ · **Requirement:** ./requirement.md · **Design:** ./design.md · **Plan:** ./plan.md
32
+
33
+ - **Feature / Branch** — resolved via the same active-feature mechanism the rest of the doflow
34
+ chain uses; do not hand-derive the slug from the directory name or guess it from `git branch`
35
+ independently.
36
+ - **Status** — `Draft` while the summary is being written, `In-Review` once posted for review,
37
+ `Done` once accepted. This is the impl doc's own status, not `plan.md`'s task-checklist status.
38
+ - **Created** — the date this implementation summary was generated, not when the feature started.
39
+ - **Requirement / Design / Plan** — relative links into the same feature directory, exactly like
40
+ `design-template.md`'s header links to `./requirement.md`. Every doflow feature has all three by
41
+ the time `--type impl` is run (implementation follows planning), so none of these three links is
42
+ optional.
43
+
44
+ ## Summary [Required]
45
+
46
+ 1–3 sentences: what was built, in plain language a reader who has not touched the chain artifacts
47
+ can follow. State the outcome, not the process — "added X so that Y" rather than a chronology of
48
+ commits.
49
+
50
+ `{one-to-three-sentence summary of what shipped}`
51
+
52
+ ## Key Decisions [Required]
53
+
54
+ Narrative, not a table — decisions read as reasoning, not comparable rows. Cover the choices made
55
+ *during* implementation that a reader would otherwise have to reconstruct from the diff: which
56
+ approach was taken when more than one was viable, why a particular library/pattern/boundary was
57
+ used, and anywhere the build surfaced a question `design.md` left open.
58
+
59
+ Where a decision traces back to something `design.md` already recorded, reference it by section and
60
+ ID rather than restating it — e.g. "Followed design.md §3 C2's boundary: the adapter owns
61
+ serialization, per the Components & Boundaries split" or "Accepted the risk noted in design.md §7
62
+ R2; see below for what that cost in practice." Decisions with no design.md antecedent (something
63
+ that only became a decision once code was being written) still belong here, just without a
64
+ back-reference.
65
+
66
+ `{narrative: what was decided and why, cross-referencing design.md §3/§7 where applicable}`
67
+
68
+ ## Deviations from Plan/Design [Required]
69
+
70
+ Narrative. Anywhere the actual implementation diverged from what `plan.md`'s tasks or `design.md`'s
71
+ shape called for — a task done differently than scoped, a component boundary that moved, a step
72
+ skipped or added — explain what changed and why. This is what lets a future reader trust
73
+ `plan.md`/`design.md` as history without re-diffing them against the code.
74
+
75
+ If nothing diverged, write exactly:
76
+
77
+ `None — implemented as designed.`
78
+
79
+ ## Changed Surfaces [Required]
80
+
81
+ A table, populated from `git diff` (or the equivalent comparison against the branch's base) for the
82
+ feature's commits — not hand-recalled from memory. One row per changed path; "what changed" is a
83
+ short phrase, not a full diff.
84
+
85
+ | Path | What Changed |
86
+ |------|---------------|
87
+ | `{path/to/file}` | `{one-line description of the change}` |
88
+
89
+ ## Testing & Verification [Required]
90
+
91
+ Narrative: what was run and how the change was verified — unit/integration tests executed, manual
92
+ checks performed, and their outcome. Reference the plan's verification bar or design's acceptance
93
+ criteria where the testing directly maps to one of them, but describe what actually happened, not
94
+ what was merely planned.
95
+
96
+ `{narrative: tests run, manual verification performed, and results}`
97
+
98
+ ## Follow-ups / Known Gaps [Required]
99
+
100
+ Narrative. Anything intentionally left undone — known limitations, deferred work, follow-up tasks
101
+ worth tracking separately — belongs here so it isn't lost once the feature is marked complete.
102
+
103
+ If there are none, write exactly:
104
+
105
+ `None.`
@@ -0,0 +1,9 @@
1
+ # Project Index & Architecture Reference
2
+
3
+ Methodology for creating whole-repository knowledge indexes:
4
+
5
+ ## Index Sections
6
+ 1. **System Overview**: High-level purpose, tech stack, and primary runtime architecture.
7
+ 2. **Directory Map**: Key directories, responsibilities, and boundary layers.
8
+ 3. **Core Workflows**: End-to-end trace of primary data flows and API request paths.
9
+ 4. **Key Invariants**: Non-obvious architectural constraints and governance rules.
@@ -0,0 +1,22 @@
1
+ # User Guide Template
2
+ # Use this template for creating user-facing guides and tutorials.
3
+
4
+ ## 🎯 Goal: [Feature Name]
5
+ What the user will be able to achieve after following this guide.
6
+
7
+ ### 📋 Prerequisites
8
+ - Required tools/accounts.
9
+ - Necessary permissions.
10
+ - Prior knowledge needed.
11
+
12
+ ### 🚶 Step-by-Step Instructions
13
+ 1. **Step One**: Action $\rightarrow$ Expected Result.
14
+ 2. **Step Two**: Action $\rightarrow$ Expected Result.
15
+ - *Tip*: Add a pro-tip or common pitfall here.
16
+ 3. **Step Three**: Final validation.
17
+
18
+ ### ✅ How to Verify
19
+ How the user knows they succeeded.
20
+
21
+ ### ❓ Troubleshooting
22
+ Common issues and their resolutions.
@@ -0,0 +1,261 @@
1
+ ---
2
+ name: do-execute-plan
3
+ description: "Execute plan.md's task checklist: subagent-driven orchestration over named specialist archetypes (system-architect, core-implementer, quality-guardian) with prerequisite gates, readiness contracts, and parallel execution. Use whenever requirement.md, design.md, and plan.md exist and the next step is building the plan's tasks through subagents, or when the user says 'execute the plan', 'run the plan', 'start building', or 'implement phase N'. Always activate this skill to orchestrate multi-task implementation plans with write-set isolation."
4
+ argument-hint: "[--scope next|phase:N|all|resume] [--review] [--scaffold]"
5
+ effort: high
6
+ ---
7
+
8
+ # do-execute-plan
9
+
10
+ Phase 4 of the DoFlow chain. Executes the task checklist in `plan.md` using specialist subagent archetypes with readiness validation and progressive disclosure.
11
+
12
+ ## Invocation
13
+ ```text
14
+ /do-execute-plan [--scope next|phase:N|all|resume] [--review] [--scaffold]
15
+ ```
16
+
17
+ ## Behavioral Flow
18
+
19
+ 1. **Resolve State & Prerequisite Gate**:
20
+ - Every DoFlow runtime call in this skill — `paths`, `prereqs`, `parallel-check`, `task-brief` —
21
+ goes through the runtime seam. Resolve it **once** here and reuse `$DOFLOW` for all four:
22
+
23
+ ```bash
24
+ # Resolve the DoFlow runtime: nearest project install wins, then the global one.
25
+ D=$PWD; while [ "$D" != / ] && [ ! -x "$D/.doflow/scripts/doflow/bin/doflow-run" ]; do D=$(dirname "$D"); done
26
+ DOFLOW="$D/.doflow/scripts/doflow/bin/doflow-run"
27
+ [ -x "$DOFLOW" ] || DOFLOW="$HOME/.doflow/scripts/doflow/bin/doflow-run"
28
+ [ -x "$DOFLOW" ] || { echo "doflow: no runtime found in any .doflow/ above $PWD, nor at $HOME/.doflow. Run: npx @khoavu882/doflow install -t <harness>" >&2; exit 2; }
29
+ ```
30
+
31
+ Run every command below from the project root — the walk-up starts at `$PWD`. On exit 2, print the message verbatim and stop; it names every path searched.
32
+
33
+ ```bash
34
+ "$DOFLOW" paths --json
35
+ ```
36
+
37
+ - Enforce hard prerequisite gate: `"$DOFLOW" prereqs --require-plan` (requires
38
+ `requirement.md`, `design.md`, `plan.md`).
39
+ - Read `<feature_dir>/state.md` if it exists — the cross-session execution record, per
40
+ `MODE_Task_Management.md`'s "Session Start" sequence. A `complete` row in its Task Ledger means
41
+ that task is done: never re-dispatch it, resume at the first task without one. No `state.md`
42
+ yet is the normal first-run case, not a gap.
43
+
44
+ 2. **Propose the Task Class; the Runtime Validates It**:
45
+ - Name exactly one class id for the work this run executes. `/do-flow` passes one when it
46
+ invoked this skill; a user who named one settles it; otherwise derive it from `plan.md`.
47
+ ```bash
48
+ "$DOFLOW" classify --task-class "<proposed>" --calling-skill do-execute-plan --json
49
+ ```
50
+ Branch on the returned `outcome` field, not the exit code.
51
+ - **`ACCEPTED`** — the returned `workflow` is this run's plan of record; read `stages`, `gates` and `handoff` off it rather than from memory.
52
+ - **`REJECTED`** — **stop.** Print `message` verbatim (it already names `validClasses` and any `suggestions`), ask the user to choose from `validClasses`, then re-validate. Never substitute `feature`.
53
+ A rejection may be about **you** rather than the class (`reason: caller-not-a-stage`). Then the fix is to propose one of the classes in `fit.hostingClasses`, or to hand the work to the skill this class names for the stage you meant — not to re-propose the same class.
54
+ - **Exit 2** — surface the message verbatim and stop.
55
+
56
+ - Take the readiness template from the returned workflow's implementation stage: the entry in
57
+ `stages[]` with `mutatesSource: true`, whose `readinessTemplate` names the contract step 4
58
+ grades against. Do not pick a template by hand.
59
+ - If the accepted workflow has no stage with `mutatesSource: true` — read
60
+ `hasImplementationStage` off the returned object rather than recalling which classes those are
61
+ — this skill is the wrong tool for that class. Say so and stop rather than executing tasks the
62
+ workflow never declared.
63
+ - Also derive `<expected gate id>`: among `gates[]`, the one entry whose `afterStage` equals the
64
+ stage immediately preceding this skill's own stage in `stageIds[]` (`gate-a` in `feature`, since
65
+ `gate-a`'s `afterStage` is `planning`, the stage right before `implementation`) — `null` if no
66
+ gate is anchored there. No shipped workflow anchors two gates to the same stage, so this is
67
+ always at most one entry; do not hardcode `gate-a`, derive it this way so a differently-shaped
68
+ workflow's own gate is found the same way. Step 3 needs this to tell "the gate that belongs to
69
+ this stage" apart from any other gate `catch-up` might stop on.
70
+
71
+ 3. **Position the Run, and Resolve the Approval Gate Standing Before This Stage**:
72
+ - This stage is the one the accepted workflow anchors an `approval`-kind gate directly *before*
73
+ (`gate-a`, "Before implementation", in the `feature` workflow — the gate whose `afterStage` is
74
+ the stage preceding this skill's own). `/do-plan` deliberately leaves it open: an approval gate
75
+ is answered by the human who is asked, and this skill is where that question lands when nothing
76
+ else has already asked it. Until it is decided, the state machine refuses this stage's own
77
+ completion, so resolve it here rather than at step 10.
78
+ - One `orchestrate --action catch-up` call positions the run, stopping either on this stage or
79
+ on any gate in the way; **branch on its `caughtUpTo` / `reason`, not on the exit code.** That
80
+ call and every branch off it — the expected gate, an earlier stage's gate, a blocking mutating
81
+ stage, an already-recorded stage, a finished run — are in this skill's own
82
+ `references/run_position.md`. Read it before running this step; carry the `caughtUpTo` it
83
+ lands on to step 10.
84
+
85
+ 4. **Readiness Evaluation (Contract State)**:
86
+ - Evaluate a task's contract before dispatching it, run from the project the task belongs to.
87
+ This skill is an orchestrated run, and says so:
88
+ ```bash
89
+ "$DOFLOW" readiness --task-class "<template from step 2>" --task-id "<task id>" --mode workflow --json
90
+ "$DOFLOW" evidence --task-id "<task id>" --json
91
+ ```
92
+ - **Both `--task-class` and `--task-id` are required.** Omitting either exits 2 and names the
93
+ valid set. Pass them explicitly rather than letting anything default: a verdict computed for
94
+ another task, or against another class's contract, is worse than no verdict.
95
+ - **Act on `stageEntry.decision`, not the exit code and not your own reading of `state`.** The
96
+ entry policy is the runtime's: `ENTER` → dispatch the task; `GATHER_FIRST` → gather the named
97
+ requirements before dispatching; `ASK_USER` → ask the owed decision and wait; `STOP` → stop
98
+ and surface the conflicted claim. The four underlying states remain the entire state
99
+ vocabulary — `READY`, `NEEDS_EVIDENCE`, `NEEDS_USER_DECISION`, `BLOCKED` — and none of them is
100
+ ever reported as a number, a percentage, or a confidence.
101
+ - Only `bug`, `feature`, `refactor`, `trivial-edit` and `dependency-change` have templates. On
102
+ any other class the verb exits 1 and lists the valid keys; that is the correct answer, not a
103
+ gap to route around.
104
+ - All four states are reachable, so a verdict is about this task rather than about the runtime.
105
+ Dispatch no task until the run's record, below, is `READY`. `BLOCKED` is a claim whose evidence contradicts itself, and `NEEDS_USER_DECISION`
106
+ is what `--user-decision-pending` returns. A first call on a task with nothing recorded grades
107
+ an empty ledger — that is a checklist, not a defect.
108
+ - **The run's record comes first.** The handoff, `verify` and the edit hook read the record
109
+ keyed on the feature slug (the run's task id), so before the first dispatch record the
110
+ `affected_components` evidence, then evaluate with the plan's stated inputs:
111
+ ```bash
112
+ "$DOFLOW" evidence --task-id "<slug>" --action add --batch <batch>.json --json
113
+ "$DOFLOW" readiness --task-class "<template from step 2>" --task-id "<slug>" --mode workflow \
114
+ --verification-plan "<plan.md §7 Validation Strategy>" --scope "<comma-separated paths from plan.md §4>" --json
115
+ ```
116
+ The batch holds one item: `kind` `structural` or `semantic-retrieval`, `provenance`
117
+ `extracted`, `locator` a file in this repository (`plan.md`), `establishes`
118
+ `["affected_components"]`, and `content` summarizing the components and files `plan.md` §4
119
+ lists (schema: the guidance tree's `references/EVIDENCE_LEDGER.md`). `scope_clear` and
120
+ `verification_plan` come from the two stated inputs; `--scope` as a path list is also what
121
+ `verify` bounds the change by. A refusal names the command to run again.
122
+ - `readiness` also accepts `--verification-plan`, `--scope` and `--invariants` — the verb's own
123
+ arguments, unrelated to this skill's `--scope`. Those are inputs
124
+ you **state**, not evidence the gate measured: the report lists them back as `callerAsserted`
125
+ in JSON and `Caller-stated:` in the human report, and a requirement satisfied that way links
126
+ no evidence. Pass them when they are true, and when you report the verdict say which part of
127
+ it rests on a statement rather than on a record. Never pass one to move a state.
128
+ - Do not recall the contract from memory — the templates are versioned and the command reads
129
+ them. This skill's own `references/readiness_gate.md` carries the per-class requirements, what each state
130
+ means, and exactly which input produces it. Read it before acting on a verdict, and never
131
+ write `READY` yourself: the gate did not say it.
132
+
133
+ 5. **Scaffold Generation (`--scaffold`)**:
134
+ - When invoked with `--scaffold`, emit a reviewable code scaffold under `<feature_dir>/scaffold/`
135
+ instead of executing tasks: the source layout, signatures and test stubs that `requirement.md`,
136
+ `design.md` and `plan.md` imply, plus a contract frame per external `depends-on:` service.
137
+ Signatures only, never implementation logic, and never a write into the project's source tree.
138
+ - The in-scope half is deterministic and is **run**, not reasoned through — one verb through the
139
+ same seam as every other runtime call, `"$DOFLOW" scaffold --json`, which resolves the active
140
+ feature itself. The external-dependency half is an algorithm you execute. Both, with the exact
141
+ commands, live in this skill's own `references/scaffold.md`. Report its `status` and,
142
+ specifically, whatever it lists as skipped or not evaluated — a partial scaffold read as
143
+ complete is worse than none.
144
+
145
+ 6. **Task Selection & Parallel Dispatch**:
146
+ - Read the guidance tree's `references/ORCHESTRATION.md` before dispatching agents;
147
+ it governs briefs, tools, running work, verification, and questions.
148
+ - `--scope` selects what this run executes, and takes exactly one value: `next` (the next
149
+ pending task, the default), `phase:N` (one phase), `all` (every pending task), or `resume`
150
+ (pick up where an interrupted run stopped). Where an interrupted run stopped is read from the
151
+ recorded state, never reconstructed from the transcript.
152
+ - Compute dispatch groups with `"$DOFLOW" parallel-check --phase=<N> --json` — it
153
+ groups by phase and `owner:`, and returns the cross-group write-set collisions
154
+ (`group_overlaps[]`, `group_serialize[]`) that decide what may run concurrently. Do not derive
155
+ write-set isolation by inspection; it is computed.
156
+ **Branch on the `parallel_safe` field, never on the exit code.** With `jq` unavailable this
157
+ verb exits 0 and reports `"parallel_safe": null` — a zero exit is not a grant of concurrency.
158
+ `null`, or a missing field, means unknown: run the tasks serially and say why.
159
+ Build each group's brief with
160
+ `"$DOFLOW" task-brief --group=<phase>:<owner> --tasks=<csv>`. Full protocol, field
161
+ meanings, and the serial and per-task fallbacks: this skill's own `references/parallel_dispatch.md`.
162
+ - Before dispatching each task, compile its prior context — the same plan task id step 4 graded:
163
+ ```bash
164
+ "$DOFLOW" context-pack --task-id "<task id>" --json
165
+ ```
166
+ **Exit 1 means the pack came back empty.** Unlike design and plan, this call sits right at the
167
+ point a subagent is about to be handed the task and told to act — so proceeding as though
168
+ nothing happened is exactly the failure this feature exists to remove. An empty pack here can
169
+ still be legitimate: step 4 lets a task reach `READY` on `callerAsserted` inputs alone, which
170
+ link no evidence. Do not withhold dispatch on this alone — readiness already governs whether the
171
+ task may be worked. Instead, carry the empty result into the group's brief itself: state in the
172
+ dispatch, next to the task-brief output, that no prior evidence or claims were compiled for this
173
+ task, so the subagent works from the plan/design text `task-brief` already supplies without
174
+ assuming a grounding evidence base that isn't there. A non-empty pack is included in the brief
175
+ as the subagent's prior context, same handoff.
176
+ - Claim each task before dispatch and finish it with evidence: `references/task_attempts.md`.
177
+ - Dispatch tasks to appropriate specialist archetypes:
178
+ - Architecture & Schema $\rightarrow$ `system-architect`
179
+ - Code Implementation & Refactoring $\rightarrow$ `core-implementer`
180
+ - Test Automation & Quality $\rightarrow$ `quality-guardian`
181
+ - Name a model tier on every dispatch — an omitted tier inherits the session's model. Pass the
182
+ tier from task-brief's `record.tier` as the dispatch model; for review passes and the limit
183
+ where a harness honors only `model: inherit`, see `references/MODEL_SELECTION.md`.
184
+
185
+ 7. **Batch the Phase's Evidence**:
186
+ - One pass at each phase boundary, never one call per fact. Use the plan task id — the same id
187
+ step 4 graded — for every `evidence`, `claim` and `readiness` call about that task; a
188
+ different id reads a different task's record.
189
+ ```bash
190
+ "$DOFLOW" evidence --task-id "<task id>" --action add --batch <batch>.json --json
191
+ "$DOFLOW" claim --task-id "<task id>" --action add --statement "<one conclusion>"
192
+ ```
193
+ Item schema, provenance rules, and the refused-field list: the guidance tree's `references/EVIDENCE_LEDGER.md`. Read it before writing the batch.
194
+ - This phase's items are its completion report, and a subagent's assertion never becomes fact by
195
+ a subagent having made it.
196
+ - Add each conclusion as a claim in this same pass. Each is stored as a `hypothesis` and becomes
197
+ supported only through linked evidence:
198
+ `"$DOFLOW" claim --task-id "<task id>" --action link --claim-id <claim id> --evidence-id <evidence id> --relation supports|contradicts`.
199
+ An evidence id the ledger does not hold is **refused** — exit 2, naming the id — not graded,
200
+ so record the batch first and link afterwards. A claim carrying both fresh support and fresh
201
+ contradiction becomes `conflicted`, which is what makes step 4 report `BLOCKED`.
202
+
203
+ 8. **Update `state.md`**:
204
+ - One checkpoint per phase (or per task, on a `--scope next` run), immediately after step 7's
205
+ evidence/claim batch for that phase — same boundary, not a separate pass to remember later.
206
+ - No `<feature_dir>/state.md` yet: create it from the template. The template is
207
+ `templates/doflow/state-template.md` in the install step 1 resolved: take `constitution_base`
208
+ from that JSON and swap its trailing `guidance/references/CONSTITUTION_BASE.md` for that path.
209
+ Fill `[PLAN_PATH]` from that same resolution's `plan` field, verbatim (repo-root-relative,
210
+ exactly as the resolver returns it) — `state.md` and `plan.md` both sit at the feature dir's
211
+ own root under both layouts, the same single shared location, and the resolver's own field is
212
+ what confirms it rather than a hand-computed guess.
213
+ - Every checkpoint: append the finished task(s) to the Task Ledger (`Commits` as the actual
214
+ `[base7]..[head7]` range once committed, or `uncommitted (working tree)` when this run doesn't
215
+ commit on its own), move them from **In Progress** to **Completed**, and rewrite **Status**,
216
+ **Blocked**, **Findings** and **Next Action** (the next pending task) in place, deleting a
217
+ blocker or finding that no longer applies, so a resumed session (or a different one) can pick up
218
+ from this file and `git log` alone, never from conversation memory. A `Findings` entry records
219
+ a review finding deliberately left unfixed (rare); write "None." otherwise, never omit it.
220
+ - This is bookkeeping, not a gate: a write failure here degrades resumability, not correctness —
221
+ report it and continue rather than treating it as a task failure.
222
+
223
+ 9. **Phase Quality Review** (`--review`, opt-in):
224
+ - Off by default. With `--review`, review each phase on completion for spec compliance before
225
+ advancing. Without it no per-phase review runs: the completion summary says "per-phase review:
226
+ not requested"; review at `/do-code-review` after the test stage (or the caller's final review).
227
+
228
+ 10. **Record the Handoff**:
229
+ - Before recording it, follow the decision step in the guidance tree's
230
+ `references/WORKFLOW_HANDOFF.md`.
231
+ - Once per `/do-execute-plan` invocation, at the last `state.md` checkpoint this run writes —
232
+ not once per phase, since the stage hands off once however many phases it executed. The stage
233
+ id is step 3's `caughtUpTo`, which the run is already positioned on; there is no second
234
+ `catch-up` call and no `status` call to make here.
235
+ - **First: is this run a completion or a checkpoint?** Count `plan.md`'s still-unchecked task
236
+ lines with `grep -cE '^- \[ \] [A-Z]+\.[0-9]+'`. The task-id prefix is load-bearing: a bare
237
+ `^- \[ \]` also matches the plan's own `- [ ] All tasks checked` completion-criteria line, so
238
+ it reports a remaining task on a finished plan and records a checkpoint where a completion
239
+ was owed. Any genuinely remaining task makes this handoff a checkpoint (`annotate`, never
240
+ `complete-stage`); zero remaining is the completion flow. Both branches, their exact
241
+ commands, the readiness record the handoff reads, and how to report the
242
+ resulting `disposition`: this skill's own `references/handoff_record.md`. Read it before
243
+ running this step.
244
+
245
+ **Stop when** every review finding the contract names has an answer or a stated gap, **and** the last round produced no new review finding. A round that only restates what you already have is the last round. Report the remaining gaps rather than continuing.
246
+
247
+ ## Embedded feature research
248
+
249
+ For an external fact gap or explicit request, follow the conditional protocol in `../do-document/references/embedded-research.md` before stage completion.
250
+
251
+ ## Boundaries
252
+ **Will:** Propose a task class and have the runtime validate it, put the approval gate standing
253
+ before this stage to the user — but only when the run still reports it open — and record their
254
+ answer, execute planned tasks with subagents, consult the readiness contract per task, batch each
255
+ phase's evidence and claims, ensure write-set isolation, and record the stage handoff through
256
+ `orchestrate`/`render-audit` — as a completion when every plan task is checked, as a checkpoint
257
+ annotation when this run finished only part of the plan.
258
+ **Will Not:** Bypass missing spec artifacts, modify source code while readiness reports `BLOCKED`,
259
+ hand this stage off while any plan task is still unchecked, re-ask a gate the run no longer reports
260
+ as open, execute under a class the runtime rejected or replaced with `feature`,
261
+ call `readiness` for a stage that declares no template; or express evidence, an estimate or readiness as a number, a percentage or a confidence.
@@ -0,0 +1,57 @@
1
+ # Step 10 — recording the stage handoff
2
+
3
+ The procedural detail behind `/do-execute-plan`'s step 10. `SKILL.md` carries when the step runs
4
+ and the completion-vs-checkpoint decision it turns on; what follows is how each branch is carried
5
+ out. `readiness_gate.md`, referenced below, sits beside this file.
6
+
7
+ - **First: is this run a completion or a checkpoint?** Re-read `plan.md`'s task checklist and
8
+ count the task lines still unchecked. A real task line matches `^- \[ \] [A-Z]+\.[0-9]+` (a
9
+ phase letter, a dot, a number — `- [ ] B.2`); the pattern deliberately excludes the generic
10
+ `- [ ] All tasks checked` line in the plan's own "Completion criteria" section, which carries
11
+ no phase-letter id and is not a task.
12
+ ```bash
13
+ grep -cE '^- \[ \] [A-Z]+\.[0-9]+' "<plan path>"
14
+ ```
15
+ **Any such line remaining means this run's handoff is a checkpoint, not a completion** — the
16
+ normal outcome of a `--scope next` or `--scope phase:N` run, which finishes some of the plan by
17
+ design. Record the checkpoint and stop; do **not** attempt `complete-stage`, which would hand
18
+ the stage off while tasks nobody executed are still open:
19
+ ```bash
20
+ "$DOFLOW" orchestrate --action annotate --task-id "<slug>" --node "<stage id>" --note "<checkpoint: N of M tasks done, scope was --scope next|phase:X>" --json
21
+ ```
22
+ Only when zero such lines remain does the completion flow below run.
23
+ - **Then: confirm the readiness record before completing.** This stage is the workflow's
24
+ `mutatesSource` stage, so the handoff reads the record `readiness` wrote and refuses without a
25
+ `READY` one made before the call; it evaluates nothing itself (`readiness_gate.md`).
26
+ 1. The `affected_components` evidence batch and the `READY` readiness call, both under the
27
+ feature slug, happen before Phase 1 is dispatched (`SKILL.md` step 4), not here. A refusal names the `readiness` command to run:
28
+ run it, gather what it lists until it reports `READY`, then repeat the handoff.
29
+ 2. Then record the handoff. This is the genuine completion case (every task checked), the one
30
+ case where reaching this stage's candidate and recording it as done are the same fact, so
31
+ `handoff`'s always-complete-on-reach behavior is exactly right here and cannot mismark
32
+ unfinished work: the checkpoint branch above never reaches this call:
33
+ ```bash
34
+ "$DOFLOW" orchestrate --action handoff --task-id "<slug>" --task-class "<class>" --calling-skill do-execute-plan \
35
+ --note "<one line, e.g. tasks A.1–E.5 complete>" --result passed --json
36
+ ```
37
+ `--task-class` still matters here even though the run already carries one: a conflicting
38
+ value is refused, so passing it is a check, not a formality. `--result` reflects step 9's phase
39
+ review (when it ran) and step 6's own check runs, never asserted as `passed` when a review
40
+ finding was left unfixed. Without `--review` the result rests on the verification the run did,
41
+ and the note says the per-phase review was not requested.
42
+ - **Report the resulting `disposition` plainly.** `completed` means a `READY` record was
43
+ found and the cursor advanced to the verification stage — check
44
+ its `awaitingGate`; `null` means no gate follows this stage in this workflow. `deferred` means
45
+ a gate, an unfinished mutating stage elsewhere, or a rejected run prevented it — report
46
+ `reason` plainly, this stage resolves no gate. If the handoff refuses for readiness,
47
+ report exactly what is unmet and fix that with the `readiness` command it names — do not
48
+ re-run under a class that grades looser, never assert `READY` yourself, and do not swallow the
49
+ failure into an `annotate`. The `annotate` path above belongs to the unfinished-tasks case
50
+ alone; it is not a catch-all for an unexpected readiness failure here. Finish by rendering the
51
+ trail — the `--slug` value attaches with an `=`; a space-separated one is rejected with an
52
+ error rather than silently rendering the wrong feature's trail:
53
+ ```bash
54
+ "$DOFLOW" render-audit --slug="<slug>" --json
55
+ ```
56
+ - Same standing as step 8's `state.md` write: bookkeeping, not a gate. A failure here degrades
57
+ the trail, not the correctness of the work already done — report it and continue.
@@ -0,0 +1,92 @@
1
+ # Parallel Subagent Orchestration Reference
2
+
3
+ Protocol for safe concurrent task execution by specialist subagents.
4
+
5
+ **Write-set isolation is decided by the `parallel-check` verb, not by judgement.** The commands
6
+ below compute the grouping and the overlap set deterministically from `plan.md`. Read their output;
7
+ do not re-derive it by eye. If a verb is unavailable, say so and run the tasks serially (one at a
8
+ time) rather than guessing at which tasks are safe to run together.
9
+
10
+ ## Resolving the runtime
11
+
12
+ `SKILL.md` step 1 already resolved `$DOFLOW`; reuse it. Resolving is a search of the filesystem, not
13
+ of this file's location — a relative path would resolve against the working directory, which is the
14
+ project root, not the skill. If `$DOFLOW` is unset (this file read on its own), resolve it first:
15
+
16
+ ```bash
17
+ # Resolve the DoFlow runtime: nearest project install wins, then the global one.
18
+ D=$PWD; while [ "$D" != / ] && [ ! -x "$D/.doflow/scripts/doflow/bin/doflow-run" ]; do D=$(dirname "$D"); done
19
+ DOFLOW="$D/.doflow/scripts/doflow/bin/doflow-run"
20
+ [ -x "$DOFLOW" ] || DOFLOW="$HOME/.doflow/scripts/doflow/bin/doflow-run"
21
+ [ -x "$DOFLOW" ] || { echo "doflow: no runtime found in any .doflow/ above $PWD, nor at $HOME/.doflow. Run: npx @khoavu882/doflow install -t <harness>" >&2; exit 2; }
22
+ ```
23
+
24
+ Run every command below from the project root — the walk-up starts at `$PWD`. On exit 2, print the message verbatim and stop; it names every path searched.
25
+
26
+ ## 1. Compute the dispatch groups
27
+
28
+ ```bash
29
+ "$DOFLOW" parallel-check --phase=<PHASE> --json
30
+ ```
31
+
32
+ Returns, alongside the legacy per-task fields (`parallel_tasks`, `sequential_tasks`, `overlaps`,
33
+ `parallel_safe`, `serialize`):
34
+
35
+ | Field | Meaning |
36
+ |---|---|
37
+ | `groups[]` | `{id, owner, tasks[], files[]}` — one dispatch per entry. `id` is `<phase>:<owner>`. |
38
+ | `group_overlaps[]` | `{path, groups[]}` — groups whose write sets collide on `path`. |
39
+ | `group_serialize[]` | Group ids that **must not** run concurrently with each other. |
40
+ | `unowned_tasks[]` | Tasks with no `owner:`; each forms a singleton group with `owner: null`. |
41
+
42
+ Tasks sharing an `owner:` in the same phase merge into one group — one subagent runs them in
43
+ sequence, which is why two tasks in the *same* group may safely touch the same file. That is the
44
+ distinction between `overlaps` (per-task, still reported) and `group_overlaps` (cross-group, the
45
+ one that governs dispatch).
46
+
47
+ ## 2. Dispatch
48
+
49
+ - Launch **one subagent per group**, concurrently, except that any two groups both listed in
50
+ `group_serialize[]` must be run one after the other.
51
+ - Never split a group across subagents: its tasks are ordered and may share files.
52
+ - When the grouping cannot be computed, suppress fan-out entirely — every task runs serially in
53
+ dependency order. Say that fan-out was suppressed and why.
54
+ - When groups are unavailable but per-task data is not, fall back to per-task dispatch using the
55
+ legacy `overlaps`/`serialize` fields.
56
+
57
+ ## 3. Build each group's brief
58
+
59
+ ```bash
60
+ "$DOFLOW" task-brief --group=<PHASE>:<OWNER> --tasks=<id,id,...> --harness=<your harness id> --json
61
+ ```
62
+
63
+ Writes the group brief and returns its path in `path`. The brief carries the shared preamble
64
+ once (where this fits, global constraints, component boundary), then a per-task block for each id in
65
+ the order given. Pass this file to the subagent — it is the whole contract for that dispatch.
66
+
67
+ For a single-task group the brief is byte-identical to `--task=<id>` output, so a one-task group and
68
+ an ungrouped task are the same dispatch.
69
+
70
+ Report paths come from the brief path the same call returned — the workspace is the directory
71
+ holding it, and each task's report is `<workspace>/task-<ID>-report.md`. Each task writes its own
72
+ report before the next one starts.
73
+
74
+ Both verbs reject path traversal in group and task ids with exit 2. On any non-zero exit, stop and
75
+ surface the error — do not proceed with a partial grouping.
76
+
77
+ ## 4. Phase-level quality review
78
+
79
+ Only when `--review` was given: once every group in a phase reports complete, run an integrated
80
+ phase quality review before advancing. Without it, a group's completion goes straight to the
81
+ evidence and `state.md` steps. A finding that does not clear on the first fix goes to
82
+ `"$DOFLOW" recover --error "<what failed>" --failed-check "<check id>" --iteration <n> --json`.
83
+ Exit 0 means a bounded retry is available (`canRetry: true`); exit 1 means the loop must stop —
84
+ report where it stopped and why, quoting the returned `reason`. The bound is the runtime's
85
+ (`maxRecoveryIterations` in `verify --action contract`); you do not choose the count.
86
+
87
+ ## Behavioral posture
88
+
89
+ For complex multi-step orchestration and execution checkpoints, consult the Task Management mode in
90
+ the installed guidance tree: `<config-dir>/guidance/modes/MODE_Task_Management.md` (for example
91
+ `~/.doflow/guidance/modes/MODE_Task_Management.md`). It sits under the DoFlow config directory, not
92
+ beside this file.