@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,161 @@
1
+ # Diagram Guide — what a good chain diagram looks like
2
+
3
+ `ARTIFACT_FORMAT.md` §4 says which artifact carries which diagram slot. This file says what belongs
4
+ inside one. Read on demand by `do-brainstorm`, `do-design` and `do-plan` at the point each fills a
5
+ slot, and never loaded into a session by default.
6
+
7
+ **Scope.** These rules govern every Mermaid diagram in a feature directory, including ones in
8
+ `as-is/`, `target/` or any other subdirectory a feature grows. The slot registry in §4 of
9
+ `ARTIFACT_FORMAT.md` lists only the slots a template scaffolds, because those are the ones a stage
10
+ is accountable for; the conventions here are wider than that list.
11
+
12
+ ## 1. Permitted types
13
+
14
+ | Type | Carries |
15
+ |---|---|
16
+ | `flowchart` | Structure, scope boundaries, C4 levels, dependency order |
17
+ | `sequenceDiagram` | Time-ordered interaction between participants |
18
+ | `erDiagram` | Entities with attributes, keys and cardinality |
19
+ | `stateDiagram-v2` | States, transitions and the guards between them |
20
+
21
+ **The admission rule.** A type joins this list when it renders in GitHub, the VS Code Markdown
22
+ preview and Obsidian with no plugin installed by the reader, and its grammar is not marked
23
+ experimental by Mermaid. Both halves matter: a type that renders today but whose grammar is still
24
+ moving will silently change shape under artifacts already written against it.
25
+
26
+ **C4 is a zoom model here, not a diagram type.** `C4Context`, `C4Container`, `C4Component` and
27
+ `C4Dynamic` are excluded by the admission rule's second half — Mermaid's own C4 syntax documentation
28
+ states the C4 diagram is experimental and that its syntax and properties can change in future
29
+ releases. The practical cost is visible in Mermaid's own examples: relationship labels are placed by
30
+ hand with one `UpdateRelStyle($offsetX, $offsetY)` call per relationship, and layout is nudged
31
+ through `UpdateLayoutConfig` rather than a direction keyword. Render every C4 level with `flowchart`
32
+ plus `subgraph` instead, which gives explicit direction and puts each label on its arrow without
33
+ per-edge tuning.
34
+
35
+ **Everything else is excluded too**, including types that do render widely — `journey`, `timeline`,
36
+ `quadrantChart`, `gitGraph`, `mindmap` — and every `-beta` grammar. Not because any one of them is
37
+ bad, but because each added type is another set of conventions to carry and another surface that can
38
+ drift between renderers. Four types cover what the chain actually needs.
39
+
40
+ ## 2. Choosing between them
41
+
42
+ | When the content is… | Reach for |
43
+ |---|---|
44
+ | What is in and out of scope | `flowchart`, `subgraph IN` / `subgraph OUT` |
45
+ | Actors and external systems, or deployable units, or a container's internals | `flowchart` with `subgraph` boundaries, one per C4 level |
46
+ | Phases, tasks and what must finish before what | `flowchart`, direction `LR` |
47
+ | Who calls whom, in what order, with the failure branch | `sequenceDiagram` |
48
+ | Entities and the relationships between them, no attributes yet | `flowchart` |
49
+ | Entities with their fields, keys and cardinality | `erDiagram` |
50
+ | A run, a lifecycle, or anything with named states and guarded transitions | `stateDiagram-v2` |
51
+
52
+ Two rules of thumb. If a three-column table says the same thing, write the table. If the content
53
+ wants two of these at once, it is two diagrams.
54
+
55
+ ## 3. Complexity budget
56
+
57
+ Each type is bounded on what actually makes that type illegible, not on one number applied to all.
58
+
59
+ | Type | Element ceiling | Link ceiling |
60
+ |---|---|---|
61
+ | `flowchart` | 12 nodes | 16 edges |
62
+ | `sequenceDiagram` | 8 lifelines | none |
63
+ | `erDiagram` | 8 entities | none |
64
+ | `stateDiagram-v2` | 10 states | none |
65
+
66
+ `subgraph` containers do not count toward the node ceiling; they are grouping, not content.
67
+
68
+ **Why only `flowchart` carries a link ceiling.** A `sequenceDiagram` lays out columnwise — lifelines
69
+ vertical, messages horizontal — so no routing decision is ever made and nothing can tangle however
70
+ many messages it carries. A `flowchart` is routed by the layout engine, and above a certain density
71
+ that engine produces edges that overlap each other or cross boxes that are not their endpoints. The
72
+ edge ceiling exists for that failure and belongs only to the type that has it. The same reasoning
73
+ applies to `erDiagram` relations and `stateDiagram-v2` transitions: a reader tracks entities and
74
+ states, and the links follow from them.
75
+
76
+ **Where the numbers come from.** Measured against 56 Mermaid diagrams in a completed feature, not
77
+ chosen for roundness. Flowchart node counts were bimodal — eleven diagrams at six or fewer, four at
78
+ seventeen or more, nothing between twelve and sixteen — so the ceiling sits in that empty band and
79
+ flags only the four that should have been split. Sequence lifelines ran three to thirteen, with
80
+ twenty-three of twenty-six at eight or fewer. Entity and state counts never exceeded six and seven,
81
+ so those ceilings are stated intent rather than a tested constraint. Re-measure against your own
82
+ corpus before moving a ceiling, and move it with the count rather than by preference.
83
+
84
+ ## 4. When a diagram is over budget
85
+
86
+ Split it into an overview and a detail diagram. The overview keeps the boxes a reader needs to
87
+ orient, and one of them expands into the detail diagram beneath it.
88
+
89
+ Do not shrink labels, do not drop the arrow labels, and do not accept the crowding because the
90
+ content "really is that big". Content that big is the signal, not the exception: a diagram past the
91
+ ceiling is two ideas sharing a frame, and the split is what separates them.
92
+
93
+ The one legitimate alternative is deletion. Two nodes that always travel together are one node, and
94
+ a relationship obvious from the layout does not need its own line.
95
+
96
+ ## 5. Conventions
97
+
98
+ **Direction is declared, never left to default.** Write `flowchart TB` or `flowchart LR`. Pick `LR`
99
+ for anything that reads as a progression (scope, phases, dependency order) and `TB` for anything
100
+ that reads as containment or hierarchy.
101
+
102
+ **Labels go on the arrow, not in the node.** `A -->|"reads"| B`, not a node named "reads from B".
103
+ Keep an arrow label to a short verb phrase: if it needs a clause, the relationship is doing too much
104
+ and wants two arrows or a different type. Quote every label, so a comma or a parenthesis inside it
105
+ cannot end the label early.
106
+
107
+ **Node ids are short and stable; the text lives in the brackets.** `SVC["Payment service"]`, not
108
+ `PaymentService["Payment service"]`. An id is an anchor a later edit reuses; the label is prose that
109
+ changes freely.
110
+
111
+ **`subgraph` marks a boundary, and its label is quoted**: `subgraph boundary["Payment platform"]`.
112
+ Use it for a trust boundary, a deployable unit, a C4 level or a scope partition. Do not use it to
113
+ group things that merely look similar.
114
+
115
+ **In a `sequenceDiagram`, prefer `rect` over `par` to mark a region.** `par` renders as a split
116
+ block that reads as "these happen simultaneously", which is a claim most groupings do not want to
117
+ make and cannot support. `rect` groups without asserting concurrency. Reserve `par` for genuine
118
+ parallelism, and use `alt` for a branch.
119
+
120
+ **Keep edges inside their boundary.** An edge that crosses a `subgraph` boundary is the one the
121
+ layout engine routes across other edges, and it is what produces overlapping arrows and labels
122
+ stranded mid-canvas. This is not a density problem and the node ceiling does not catch it: a
123
+ six-node diagram with two boundary-crossing edges tangles where a nine-node diagram whose edges all
124
+ fan into one sink stays clean. Prefer edges within a boundary, or between two boundaries at the same
125
+ level. When a node inside a `subgraph` must reach one outside it, the boundary is usually drawn in
126
+ the wrong place — move it, or lift the shared node out.
127
+
128
+ **Secondary and asynchronous relations use `-.->`.** Reserve the dashed arrow for what it says:
129
+ optional, deferred, or out of band. A dashed arrow used for variety costs the reader the one signal
130
+ it carries.
131
+
132
+ **Skipping a slot is `N/A: [why]`.** That escape is a format rule and is defined once, in
133
+ `ARTIFACT_FORMAT.md` §4. A slot left silently empty cannot be told apart from an oversight.
134
+
135
+ ## 6. Authored sources
136
+
137
+ Some features author diagrams in PlantUML under `design/c4/` and commit the render. These apply on top of everything above.
138
+
139
+ **C4 divides by level**: `context.puml`, `container.puml`, `component.puml`, one file each; a level not drawn has no file. The Mermaid in `design.md` §2 is generated from these, so editing it by hand
140
+ is a change the next render discards.
141
+
142
+ **The generated view drops seven things** — element type, technology, description, sprite, tag, link
143
+ and the legend — keeping nodes, edges, labels and boundaries. Need any of the seven, open the image;
144
+ that is why the generated block names its source.
145
+
146
+ **A flow gets one lane per actor**, ordered by who acts first, with the failure branch reaching its
147
+ own terminal. One file per flow, `flow-<name>.puml`, matching its `#### Flow: <name>` heading. Skip
148
+ with `N/A: [why]` for a single-actor flow.
149
+
150
+ ## 7. Anti-patterns
151
+
152
+ | Pattern | Why it fails |
153
+ |---|---|
154
+ | A node per step of a process that has no branches | A numbered list says it in fewer words and reads faster |
155
+ | Every node the same shape and weight | Shape is the only hierarchy a diagram has; spending none of it flattens everything |
156
+ | An arrow with no label | The reader can see two things are connected and has to guess how |
157
+ | A label long enough to wrap | A wrapped label pushes its own arrow around and reads as a sentence, not an annotation |
158
+ | Restating a table that sits directly above it | Two representations of one fact drift apart, and the reader has to work out which is current |
159
+ | One diagram carrying both the overview and the detail | Past the ceiling this is the shape the split rule exists to break up |
160
+ | Colour or `classDef` styling as the only way to read it | Styling varies by renderer and theme; anything load-bearing belongs in the structure or the labels |
161
+ | A diagram nobody would miss | If removing it costs the reader nothing, it was decoration |
@@ -0,0 +1,87 @@
1
+ # DoFlow Chain — Spec-Driven Delivery
2
+
3
+ A spec-kit-style, phase-gated delivery loop (`do-brainstorm → do-design → do-plan →
4
+ do-execute-plan → do-test → do-code-review`) on top of the rest of the `/do-*` skills and the five
5
+ specialist agents (`core-implementer`, `quality-guardian`, `research-writer`, `spec-analyst`,
6
+ `system-architect`). Discipline borrowed from spec-kit; enforcement done with the harness's real
7
+ hooks rather than a prompt-read registry. The implement-gate hook is registered in
8
+ `settings.json`. `do-constitution` sits outside the numbered chain — a standalone,
9
+ still-invocable skill that maintains the persistent rules every phase inherits, not a phase
10
+ itself. `do-implement` sits outside the numbered chain too, for the opposite reason: it is the
11
+ no-artifacts-required escape hatch for implementing directly from a description or
12
+ `do-code-review` findings when there is no `plan.md` task checklist to orchestrate — `do-execute-plan`
13
+ remains the chain's own implementation phase.
14
+
15
+ ## Layout
16
+
17
+ | Path | Holds |
18
+ |------|-------|
19
+ | `skills/` | Chain skills: `do-brainstorm` (also creates the feature branch/dir, writes `requirement.md`, optionally captures a PBI/ticket ID), `do-design` (writes `design.md`), `do-plan` (also writes the dependency-ordered task checklist inside `plan.md`, plus a Repo Branch Plan for multi-repo features), `do-execute-plan` (also supports `--scaffold` to emit a reviewable code scaffold under the feature dir — the source layout, signatures and test stubs the three artifacts imply, plus a per-dependency-service contract frame — and lazily creates/tracks each repo's branch as it's first touched; a non-local dependency with a `external-contract:` field gets a frame generated from that doc instead of the default silent skip), `do-test`, `do-code-review`. `do-constitution` is standalone, not part of the numbered chain. |
20
+ | `scripts/doflow/` | The runtime seam. Skills call `bin/doflow-run <verb>` and never name a helper: the dispatcher decides which `bash/*.sh` helper or Node command serves each verb. The dispatcher owns the verb namespace and is the only place it is written down — an inventory here is the drift this row used to produce. |
21
+ | `hooks/` | `pre-implement-gate.sh` — PreToolUse(Edit\|Write) backstop for the one hard gate |
22
+ | `templates/doflow/` | `requirement-template.md` (optional `**Ticket:**` header field) / `design-template.md` / `plan-template.md` (its own "Tasks" subsection folds in what used to be a separate tasks template, supports optional `depends-on:` and `external-contract:` fields per task, and a Repo Branch Plan table for multi-repo features) / `state-template.md` (Repo Branch Status table) / `constitution-template.md` / `external-contract-template.md` (pinned structure for a `external-contract:` target — a documented external dependency `--scaffold` can generate a mechanical frame from) — seeded into each feature dir. A shared pool across skills, not per-skill `assets/` — see note below. |
23
+ | `references/` | `CONSTITUTION_BASE.md` — tier-1 global constitution base |
24
+
25
+ > Paths above are relative to the installed root (`${CLAUDE_CONFIG_DIR:-$HOME/.claude}` globally,
26
+ > or a project's own `.claude/` in project scope). Chain skills' resolver lookups check the global
27
+ > config dir first, then walk upward from `$PWD` for a project-scoped `.claude/` install.
28
+
29
+ ## Core design rules
30
+
31
+ - **Deterministic / generative split, through one seam:** all path math, feature numbering,
32
+ existence checks, grading and verification happen behind `bin/doflow-run <verb>` (`--json`
33
+ output); skill prompts resolve the seam once, then call verbs and reason about what comes back.
34
+ No filesystem math in prompts, and no skill reaching past the dispatcher to a helper by name.
35
+ - **Branch-coupled state (git repos) / directory-scan fallback (non-git roots):** in a git repo,
36
+ the active feature is derived from the branch (`feat/NNN-slug`), not a separate state file.
37
+ Outside a git repo (e.g. doflow installed at a multi-service container root, above the actual
38
+ git sub-repos), `do-paths.sh` falls back to scanning `agent-docs/doflow/` directly — one
39
+ candidate auto-selects, 2+ candidates surface via `candidate_slugs` for the calling skill to
40
+ disambiguate using the platform-specific `RULE_04_QUESTIONS.md` mechanism. Artifacts live in
41
+ `<repo>/agent-docs/doflow/NNN-slug/`
42
+ either way.
43
+ - **Pre-chain intent — an input, not a phase.** An idea that has not been committed to yet goes in
44
+ `<repo>/agent-docs/intent/<kebab-description>.md`, from `templates/doflow/intent-template.md`. It is
45
+ deliberately outside everything the rule above describes: no branch, no slug, no feature directory,
46
+ nothing resolves its path, and it carries neither closed vocabulary because nothing has been decided.
47
+ Intents are **not numbered** — `NNN-` marks a feature that has started, and an intent that is never
48
+ built would consume a number and leave a gap.
49
+
50
+ It is **not a phase**, and adding it to the phase list would break it: a phase resolves against a
51
+ feature directory, which resolves against a branch, so the intent would come to require the branch it
52
+ exists to precede. Instead the discovery stage reads one when given its path, and records it in
53
+ `requirement.md`'s `**Intent:**` field — the argument that does so is declared in `/do-brainstorm`'s
54
+ own `argument-hint`, which is where a single-skill argument is owned. Discovery without an intent is
55
+ unchanged and is the ordinary case.
56
+ - **One hard gate:** source edits are blocked when a feature is started but `requirement.md`,
57
+ `design.md`, or `plan.md` is missing. Every other gate is advisory/skippable (solo,
58
+ low-ceremony).
59
+ - **Two-tier constitution — what is computed vs. what is convention.**
60
+ `references/CONSTITUTION_BASE.md` (tier-1, global) is overlaid by
61
+ `<repo>/agent-docs/constitution.md` (tier-2, per-repo), and tier-2 takes precedence. **That
62
+ overlay is performed by the chain skill reading both files — no component merges them.** This is
63
+ the canonical statement; other places point here rather than restating it.
64
+
65
+ | Step | What happens | Guarantee |
66
+ |------|--------------|-----------|
67
+ | Locate tier-1 | `do-paths.sh` searches two candidates, first hit wins; `null` if none | **computed** |
68
+ | Locate tier-2 | `do-paths.sh` emits the path plus `has_constitution_local` | **computed** |
69
+ | Read both files | the chain skill opens them | agent-performed |
70
+ | Overlay; tier-2 takes precedence on conflict | the chain skill reconciles them in its own reasoning | **convention** |
71
+ | "Tier-2 may not weaken P1 (Safety)" | a rule stated to the agent | **convention, unvalidated** |
72
+ | Constitution Check verdict | recorded in `plan.md` §2 "Constitution Check" | **advisory — blocks nothing** |
73
+ | Propagate pointer to the agent context file | `sync-context.sh` writes a marker block | **computed** |
74
+
75
+ Both path lookups run unconditionally, whether or not `do-constitution` has ever been invoked.
76
+ Nothing detects a conflict between the tiers, and nothing validates the P1 rule — so avoid
77
+ describing this model as *resolved* (there is no merged artifact) or *enforced* (nothing blocks).
78
+ The convention is still load-bearing: it is how the rules actually reach a feature's planning.
79
+ - **`templates/doflow/` is a shared template pool, not the Agent Skills standard's
80
+ `references/`/`assets/` pattern.** The standard nests bundled resources one level inside their
81
+ owning skill (`skill-name/assets/*`); these templates sit outside any single skill's directory
82
+ and are pulled in by four different skills (`do-brainstorm`, `do-design`, `do-plan`,
83
+ `do-constitution`) via a hardcoded relative path in each one's own Behavioral Flow. Intentional
84
+ — a shared pool avoids duplicating the same templates into four separate `skill/assets/`
85
+ folders — but noted explicitly so it isn't mistaken for the standard's per-skill `references/`
86
+ shape, which has a different purpose (on-demand knowledge a skill loads into its own reasoning,
87
+ not scaffold files it copies out as new artifacts).
@@ -0,0 +1,93 @@
1
+ # Evidence Ledger — item schema, provenance, and what the runtime refuses
2
+
3
+ The shape of an evidence batch is the same for every stage that writes one, so it is stated once
4
+ here. A stage's own SKILL.md names the two commands it runs and what *its* items are; everything
5
+ below is common to all of them. Read this before writing a batch.
6
+
7
+ ## The batch
8
+
9
+ One pass at the stage boundary, never one call per fact. The batch file is a JSON array, one object
10
+ per item — scratch input, deleted after the write. It is validated whole: **one rejected item writes
11
+ nothing**, so a half-written stage never reads as complete.
12
+
13
+ ## Per item
14
+
15
+ - **`kind`** — one of `exact-search`, `semantic-retrieval`, `structural`, `historical`,
16
+ `documentation`, `test-result`, `runtime-observation`, `user-statement`, `diff`,
17
+ `generated-analysis`.
18
+ - **`provenance`** — `extracted` | `inferred` | `asserted`, with **no default**. An unstated
19
+ provenance is refused rather than filed as repository fact.
20
+ - **`source`** — `provider` + `capability`. There is no `unknown` stand-in; if you cannot name what
21
+ produced the item, you do not yet have the item.
22
+
23
+ Pairing rules: `extracted` needs a `locator` (unless the item carries an `observation` — the
24
+ command is then what the next worker re-runs to check it); `inferred` and `asserted` need
25
+ `content`; `generated-analysis` and `user-statement` can never be `extracted` — that pairing is how
26
+ a reading of the evidence stops being distinguishable from the evidence.
27
+
28
+ ## Bindings and observations
29
+
30
+ - **`establishes`** — the readiness-template requirement id(s) this item was gathered to prove,
31
+ e.g. `["baseline_tests"]`. The gate counts an item toward a requirement **only** when named here:
32
+ kind alone is a category, and category coverage is not proof. One extracted read may establish
33
+ two requirements by declaring both. An item that establishes nothing is still evidence — it just
34
+ satisfies no gate requirement.
35
+ - **`observation`** — `{command, exitCode}`, the execution behind a `test-result` or
36
+ `runtime-observation`. Required for an `extracted` `test-result`; refused on any inferred or
37
+ asserted item (an inference did not run anything). Where a template expects a passing run
38
+ (`baseline_tests`), a bound observation that exited non-zero is reported as the failure it was —
39
+ never as the passing baseline it is not. A bug reproduction succeeds by observing the expected
40
+ failure, so its observation may exit non-zero.
41
+
42
+ ## The accepted set is closed
43
+
44
+ An item carries exactly `kind`, `provenance`, `source`, `locator`, `content`, `taskId`,
45
+ `establishes`, `observation` — nothing else. Any other key is refused and the whole batch writes
46
+ nothing, so a field you invent costs the batch, not just the field. The list below is what people
47
+ reach for most, and why each is absent:
48
+ `id`, `freshness`, `supports`/`contradicts`, `stage`, any score field. Freshness is measured at the
49
+ write, not declared by the writer; the ledger assigns the id; and evidence attaches to a claim by
50
+ linking (below), not by a field on the item.
51
+
52
+ ## Superseding a stale item
53
+
54
+ An item's `freshness.status` can only move toward `STALE` — the file it named changed, and nothing
55
+ un-changes it. Once a stale item stops mattering (a fresher item already covers the same ground),
56
+ retire it rather than leaving it to block a task's readiness verdict forever: `evidence --action
57
+ supersede --evidence-id <stale-id> --replaced-by <fresh-id>`, naming an id already recorded. Nothing
58
+ is deleted or rewritten — the stale item's own content and locator stay exactly as observed, only
59
+ its `status` becomes `superseded` and unresolvable readiness checks stop counting it. Record the
60
+ replacing item first: the replacement must already exist, the same rule `claim --action supersede`
61
+ already applies.
62
+
63
+ ## Claims
64
+
65
+ Each conclusion is added as a claim in the same pass and is stored as a `hypothesis`. It becomes
66
+ supported only through linked evidence — the `claim` verb's link action, naming the claim id, the
67
+ evidence id, and the relation, spelled exactly `supports` or `contradicts`. An earlier stage, a subagent, or
68
+ an artifact from a previous session having asserted something is not support.
69
+
70
+ A claim may declare a `--role` (lowercase-kebab, e.g. `root-cause`) stating its relationship to
71
+ the task. Where a template requires a role, only a supported claim carrying it counts: a supported
72
+ claim about something unrelated does not answer a requirement it never addressed.
73
+
74
+ The link refuses an evidence id the ledger does not hold: exit 2, naming the id, not a low grade.
75
+ Record the batch first, link afterwards. A claim carrying both fresh support and fresh
76
+ contradiction becomes `conflicted`.
77
+
78
+ ## Relevance is not confidence
79
+
80
+ A match count, a ranking, a "best hit", a profiler's top hot path — each is a property of the query,
81
+ not of the fact. Record the locator. Never a score, a percentage, or a confidence.
82
+
83
+ ## Readiness belongs to the stage that edits source
84
+
85
+ A stage whose `readinessTemplate` is `null` does not call `readiness`, and does not report one as
86
+ skipped: there is no source edit for it to gate. The per-class readiness contract itself is owned by
87
+ the `do-execute-plan` skill's own `readiness_gate.md` reference, not restated here.
88
+
89
+ ## Source is not inference in the report either
90
+
91
+ The same items are the stage's completion report: per item, what was found, its source, its locator,
92
+ and whether it is **extracted** (read verbatim from the repository or a command) or **inferred**
93
+ (your analysis). Never merge those two provenances into one reported line.
@@ -0,0 +1,74 @@
1
+ # Model Selection — choosing a tier per dispatch
2
+
3
+ Choose the lowest capable tier. Name it on every dispatch, and pass `model:` whenever the API
4
+ supports it. Never assume the parent's choice reaches subagents; where per-call selection is
5
+ unavailable, set the model in the agent definition. An unset tier is a defect.
6
+
7
+ ## Capability tiers
8
+
9
+ Tiers describe capability; model names vary by harness. Map each to the harness's supported
10
+ identifier at dispatch; never hardcode a vendor model name here.
11
+
12
+ | Tier | Work |
13
+ |---|---|
14
+ | `light` | Verbatim extraction, classification, mechanical or high-volume work. |
15
+ | `standard` | Normal coding, debugging, writing, analysis, routine research, and evidence gathering. |
16
+ | `frontier` | Architecture, hard debugging, broad refactors, consequential decisions, and every review. |
17
+
18
+ Use the harness's supported model identifier; never invent or probe one. Consequential decisions
19
+ gate money paths, releases or tests, rewrite history, set design, or authorize unchecked action.
20
+ Gather evidence at `standard`; judge it at `frontier`. Split mixed-tier work or use the higher tier.
21
+
22
+ ## Choosing a tier for implementation
23
+
24
+ | Signal | Tier |
25
+ |---|---|
26
+ | 1–2 files, complete spec, exact values | `light` |
27
+ | Several files or integration with existing patterns | `standard` |
28
+ | Design decision or subsystem investigation | `frontier` |
29
+
30
+ `standard` is the floor for prose-led implementation; use `light` only for verbatim or single-file
31
+ mechanical work. Fewer turns can cost less than a cheaper model that needs repeated correction.
32
+
33
+ ## Reviews
34
+
35
+ Reviews are read-only `frontier` work by an agent and model different from the author. Report if that
36
+ tier is unavailable. Review once per phase or fix batch; re-review only an open blocker tests cannot
37
+ settle, after asking. Deep reviews use two independent reviewers with different lenses.
38
+
39
+ ## Archetype dispatch tiers
40
+
41
+ > **Authoritative:** this section governs each archetype's default dispatch tier.
42
+ > `core/registry/models.json` `dispatchTiers.byOwner` mirrors it and G29 asserts they match;
43
+ > change both together.
44
+
45
+ | Archetype | Tier | Why |
46
+ |---|---|---|
47
+ | `system-architect` | `frontier` | Architecture sets system shape: a consequential decision. |
48
+ | `core-implementer` | `standard` | Routine coding against a settled spec. |
49
+ | `quality-guardian` | `standard` | Its testing and evidence work; a review runs at `frontier` per-dispatch (`## Reviews`), not via `byOwner`. |
50
+ | `spec-analyst` | `standard` | Requirements analysis and routine research. |
51
+ | `research-writer` | `standard` | Documentation and routine research. |
52
+
53
+ ## Briefs and inheritance
54
+
55
+ Give `light` and `standard` agents exact files, values or `path:line`, steps, and a check command.
56
+ Give `frontier` agents intent, constraints, evidence, settled decisions, and their open choices.
57
+ Agents that may spawn agents inherit this policy: `light` = verbatim/mechanical;
58
+ `standard` = routine work/research/evidence; `frontier` = architecture, hard debugging,
59
+ broad refactors, consequential decisions, and reviews. Name the tier/model per dispatch.
60
+
61
+ ## Escalation inside a fix loop
62
+
63
+ After a stuck implementer, raise the tier at least once and use a fresh context.
64
+
65
+ Consult the harness's capability notes before assuming its per-dispatch model selection behavior.
66
+
67
+ ## Enforceability: a rendered request, not an observed model
68
+
69
+ `dispatchTiers.byOwner` in `core/registry/models.json` sets each archetype's tier, G29 pins it to the
70
+ table above, and `resolveTier` renders it into every brief. Where a harness supports per-call model
71
+ selection, pass `record.tier` and the policy applies; where it honors only `model: inherit`, the tier
72
+ is a request the host cannot set and the worker runs on the session model — say which case applied in
73
+ the hand-off. No cross-harness mechanism reads a worker's effective model, so the policy is verified
74
+ by the rendered request plus G29, never by observation.
@@ -0,0 +1,36 @@
1
+ # Orchestration
2
+
3
+ Use `references/MODEL_SELECTION.md`; follow `PRINCIPLES.md`, `rules/RULE_02_WORKFLOW.md`, and
4
+ `rules/RULE_04_QUESTIONS.md`.
5
+
6
+ ## Role and handoff
7
+
8
+ Decide, brief, verify, and keep records. Delegate discovery, research, and source/build edits; own
9
+ briefs, workflow calls, state, and between-task checks. Edit only own bookkeeping; return verification
10
+ defects to an agent. Verify material claims and check author and trailers after agent commits.
11
+
12
+ ## Brief and tools
13
+
14
+ Brief with **Goal**, **Context** (`path:line`), **Write set**, **Rules**, **Acceptance and
15
+ verification**, **Report format**, and a model/tier. Put long briefs in scratch files. Keep settled
16
+ scope in the dispatch; mid-run messages may be ignored, so verify the hand-back. Resume finished
17
+ agents, and use a fresh agent when scope grows.
18
+
19
+ The orchestrator chooses tools from each task's evidence needs and names local, web, and MCP tools
20
+ and their read/write scope in the brief. For current facts, specifications, or external patterns, use
21
+ web search/fetch or relevant documentation/retrieval MCPs; prefer primary sources, fetch support,
22
+ and return citations or locators. Routine read-only research needs no user choice. Shared archetypes
23
+ omit tool allowlists, so agents may use the session tool pool within host permissions and sandboxes.
24
+ Check a host exposes needed tools; otherwise gather the source in the orchestrator or report the gap.
25
+ Keep repository search distinct from external research.
26
+
27
+ ## Running work
28
+
29
+ Dispatch due phases before questions. Parallelize only disjoint write sets; keep reviewers read-only.
30
+ Use throwaway worktrees for build/container tests and serialize shared stacks. Commit green logical
31
+ items with the required author. After a failed/stopped agent, check status, log, stashes, and reflog.
32
+
33
+ ## Asking
34
+
35
+ Use sensible defaults. Ask one structured question only when a contract or behavior changes beyond
36
+ the request; resolve agent questions rather than forwarding a list.
@@ -0,0 +1,21 @@
1
+ # Research Configuration
2
+
3
+ No loader reads this file: it holds no knobs, only the discipline a research run follows.
4
+
5
+ **The class.** `research` is a declared task class whose workflow terminates at synthesis and
6
+ declares no readiness template: do not run a readiness check, and do not report one as skipped.
7
+
8
+ **Retrieval.** The capability router covers repository-local needs only — every registered
9
+ capability resolves inside this repo, and `route` rejects a web intent by name. Web retrieval is
10
+ the harness's own tools; name what answered in the report rather than a vendor you assumed. Ask
11
+ `"$DOFLOW" capabilities` what is registered instead of trusting a written table, but do not expect
12
+ a search provider there yet.
13
+ Two passes, in order: one broad discovery pass over the whole scope — terminology, surfaces,
14
+ competing readings — concluding nothing; then one targeted pass per named sub-question.
15
+
16
+ **Stopping.** Stop when every sub-question has an answer or a stated gap, **and** the last round
17
+ produced no new source. A round that only restates what you have is the last.
18
+ Report the remaining gaps rather than searching to raise a count.
19
+
20
+ **Reporting.** Source, provenance and locator per item — never a score, a credibility rating or a
21
+ confidence. Schema and refused fields: `EVIDENCE_LEDGER.md`, beside this file.
@@ -0,0 +1,81 @@
1
+ # Recording a workflow handoff
2
+
3
+ ## Decisions first
4
+
5
+ Before the handoff call, run `"$DOFLOW" paths --json` again (not the stage's earlier result, which
6
+ can predate the register) and, when it reports `has_decisions: true`:
7
+
8
+ 1. List the live decisions with `"$DOFLOW" decision --action list --json`. A decision that changes a
9
+ live one reuses its topic and names it in `supersedes`; a new topic key is for a genuinely new
10
+ subject only.
11
+ 2. Register this stage's decisions (question answers, gate answers carrying a choice, decisions the
12
+ user typed as prompts, "Decide for me" defaults, agent resolutions) in one
13
+ `"$DOFLOW" decision --action add --batch <file>.json --json` call. Drop an item that only
14
+ rewords a live decision, such as a gate answer do-flow registered; it is neither registered nor
15
+ used to supersede. Each item needs `topic` (kebab-case), `statement` (one line), `channel`
16
+ (`question|gate|prompt|default|resolution`), `stage` (the ownership-table stage name) and
17
+ `rationale`; `supersedes`, `refs` and `source` are optional. Skip the call when there are none.
18
+ On exit 1 `topic-conflict`, drop the item if it only rewords the named live decision; otherwise
19
+ add `supersedes` for it, then retry. On exit 1 `register-locked`, retry once; on exit 2, fix the
20
+ named item and retry. Hand off with the stage's decisions registered, or say which are not.
21
+ 3. Write each returned `DEC-###` into the lines of this stage's own artifacts that apply it
22
+ (ARTIFACT_FORMAT.md §12). A stage that owns no artifact puts the identifiers of what each
23
+ decision applies to (FR/IC ids) in the item's `refs` and names the returned `DEC-###` ids in the
24
+ handoff `--note`; it edits no artifact another stage owns.
25
+ 4. Run `"$DOFLOW" validate`. Correct each `stale` or `unknown` finding in an artifact this stage
26
+ owns, changing only the flagged line (an `unknown` one takes the right identifier from the live
27
+ list); report findings in other artifacts without editing them.
28
+ 5. Record the handoff below. It compacts History itself and reports `compaction`; its `--task-id`
29
+ must be the feature slug, not a plan task id, or compaction is skipped. A do-execute-plan
30
+ checkpoint (`annotate`) does not compact; the next completed handoff does.
31
+
32
+ | Stage | Owns |
33
+ |---|---|
34
+ | discovery | `intention/requirement.md` |
35
+ | design | `design/design.md`, `design/specs.md`, `design/data-model.md` |
36
+ | planning | `plan.md` |
37
+ | implementation, verification, review | none; findings are reported |
38
+
39
+ With or without a register, record in this step each finding left unfixed, item named out of scope
40
+ and gate answer that defers work:
41
+ `"$DOFLOW" followup --action add --stage <stage> --statement "<one line>"`.
42
+
43
+ ## The handoff call
44
+
45
+ After a skill finishes its work, call the resolved runtime seam:
46
+
47
+ ```bash
48
+ "$DOFLOW" orchestrate --action handoff --task-id "<task>" --calling-skill "<skill>" --note "<what completed>" --json
49
+ ```
50
+
51
+ Pass `--mcp-outcome <server>=used|nothing-usable|skipped:<reason>|unavailable` once per MCP server
52
+ your step names; a server left without one prints a warning, never a block.
53
+
54
+ Pass `--task-class` only when a classifying skill has accepted that class and may start a run.
55
+ Without an existing run or an explicit class, the result is `standalone` and no state is created.
56
+ An existing run supplies its own class; a conflicting supplied class is refused. Stage ownership
57
+ comes from that run's program, including every occurrence of a skill used more than once.
58
+
59
+ | `disposition` | Meaning | Caller action |
60
+ |---|---|---|
61
+ | `standalone` | No workflow applies | Finish the standalone report |
62
+ | `completed` | This skill's current occurrence was recorded | Report the result and inspect `awaitingGate` |
63
+ | `annotated` | All occurrences were already recorded; the latest received a rerun note | Report the amendment; do not replay stages |
64
+ | `deferred` | A prior gate, unfinished mutating stage or rejected run prevented the handoff | Report `reason`; leave the transition to its owner |
65
+
66
+ The runtime imports earlier non-mutating stages as `imported` + `unverified`, skips optional
67
+ stages, and stops at every gate and unfinished mutating stage. It never approves a gate. A mutating
68
+ candidate still requires the same live readiness evaluation as `complete-stage`.
69
+
70
+ Use `--result passed|failed|unverified` to record the stage's outcome. Omission records `unverified`.
71
+ For bug reproduction, observing the expected failure can satisfy the stage contract; the command's
72
+ nonzero exit alone is not the stage verdict. Reruns append a note and preserve the original outcome.
73
+
74
+ Only handle an `awaitingGate` if the skill owns that gate and the handoff just completed its anchor.
75
+ Follow the owning skill's decision rules; this API supplies no authorization. A deferral is not a
76
+ rejection. The lower-level `decide-gate` action remains explicit.
77
+
78
+ After recording work, regenerate the feature trail with `render-audit --slug="<task>" --json`.
79
+ An external recording failure must be reported; it does not change the substantive findings or
80
+ artifact correctness. A deferred workflow transition is still deferred, even when the artifact is
81
+ valid. Read the JSON fields rather than interpreting exit zero as completed work.
@@ -0,0 +1,25 @@
1
+ # Safety Rules (CRITICAL)
2
+
3
+ ## Priority System
4
+ **CRITICAL** — Security, data safety, production — never compromise
5
+ **IMPORTANT** — Quality, maintainability, professionalism — strong preference
6
+ **RECOMMENDED** — Optimization, style, best practices — apply when practical
7
+
8
+ Conflict order: Safety > Scope > Quality > Speed. Prototype != Production requirements.
9
+
10
+ <important if="debugging, fixing a bug, or investigating a failure">
11
+ ## Failure Investigation
12
+ - Root cause always — understand WHY, not just THAT; fix the cause, not the symptom
13
+ - Never skip/disable/comment-out tests or validation to pass builds
14
+ </important>
15
+
16
+ <important if="performing git operations or starting work on a codebase">
17
+ ## Git Workflow
18
+ - `git status && git branch` first; feature branches for ALL work; never force-push main
19
+ - Commit incrementally with descriptive messages; `git diff` before staging; restore-point commit
20
+ before anything risky
21
+ </important>
22
+
23
+ ## Temporal Awareness
24
+ - Read the date from `<env>` before any temporal claim; never infer it from your knowledge cutoff,
25
+ and state its source
@@ -0,0 +1,23 @@
1
+ # Workflow Rules
2
+
3
+ ## Planning
4
+ - **Parallel by default** — sequential only for hard dependencies; a task list once past 3 tasks, when the session offers one
5
+ - Validate before execution, verify after; run lint/typecheck before marking complete
6
+ - Check deps (package.json) and existing patterns before any changes
7
+ - Feature delivery follows the doflow chain — see `references/DOFLOW_CHAIN.md` for the phase-gated
8
+ flow, artifact contracts, and the enforced gate
9
+
10
+ <important if="planning or starting a multi-step task">
11
+ ## Planning Efficiency
12
+ - Identify concurrent vs sequential operations
13
+ - Map dependencies; batch tool calls; estimate parallelization gains
14
+ </important>
15
+
16
+ ## Implementation Completeness
17
+ - Start it = Finish it. No partial features, TODO stubs, mocks, or "not implemented" throws
18
+ - All generated code must work as specified; no scaffolding placeholders
19
+
20
+ ## Scope Discipline
21
+ - Build ONLY what's asked — no bonus features, no enterprise bloat (auth/monitoring/deployment
22
+ unless requested)
23
+ - MVP first; YAGNI; single responsibility per component
@@ -0,0 +1,14 @@
1
+ # Quality Rules
2
+
3
+ ## Organization & Hygiene
4
+ **Naming**: Follow language standards (camelCase JS, snake_case Python); no mixed conventions
5
+ **Files**: Organize by feature/domain; tests → `tests/`; scripts → `scripts/`; reports → `agent-docs/`
6
+ **Workspace**: Remove temp files, debug scripts, build artifacts after use; never leave clutter in VCS
7
+
8
+ ## Professional Honesty
9
+ - No marketing language ("blazingly fast", "100% secure", "magnificent")
10
+ - No invented sources, figures, citations or quotes; leave out what you cannot trace; state "untested/MVP/needs validation" honestly
11
+ - If you are not sure, say so plainly and name what is unknown; do not present a guess as established
12
+ - Warn when a claim may be outdated: information from memory or an old source can have changed since it was written
13
+ - Never attribute a statement or view to a real person unless you have verified it; otherwise omit the name
14
+ - Push back on bad approaches; evidence-based claims only