@jtf19/vibecoding-kit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (619) hide show
  1. package/AGENTS.md +84 -0
  2. package/CHANGELOG.md +28 -0
  3. package/CLAUDE.md +137 -0
  4. package/CODE_OF_CONDUCT.md +30 -0
  5. package/CONTRIBUTING.md +69 -0
  6. package/LICENSE +67 -0
  7. package/README.md +162 -0
  8. package/SECURITY.md +34 -0
  9. package/adapters/claude/install.md +70 -0
  10. package/adapters/claude/plugin.json +38 -0
  11. package/adapters/claude/settings.example.json +15 -0
  12. package/adapters/codex/hooks.example.json +15 -0
  13. package/adapters/codex/install.md +72 -0
  14. package/adapters/codex/plugin.json +58 -0
  15. package/adapters/cursor/hooks.example.json +17 -0
  16. package/adapters/cursor/install.md +72 -0
  17. package/adapters/cursor/plugin.json +42 -0
  18. package/adapters/opencode/install.md +95 -0
  19. package/adapters/opencode/plugin.js +56 -0
  20. package/adapters/opencode/plugin.json +58 -0
  21. package/adapters/pi/extension.ts +56 -0
  22. package/adapters/pi/install.md +95 -0
  23. package/adapters/pi/plugin.json +58 -0
  24. package/bin/vibe-cli-usage.mjs +43 -0
  25. package/bin/vibe.mjs +120 -0
  26. package/docs/acceptance-checklist.md +1226 -0
  27. package/docs/architecture-debt-burndown.md +537 -0
  28. package/docs/architecture.md +77 -0
  29. package/docs/ci-evidence-onboarding.md +143 -0
  30. package/docs/development.md +71 -0
  31. package/docs/evidence-authoring.md +188 -0
  32. package/docs/golden-path.md +179 -0
  33. package/docs/install-acceptance-checklist.md +90 -0
  34. package/docs/install-claude.md +41 -0
  35. package/docs/install-codex.md +41 -0
  36. package/docs/install-cursor.md +41 -0
  37. package/docs/install-experience-roadmap.md +394 -0
  38. package/docs/install.md +119 -0
  39. package/docs/maintainer-guide.md +197 -0
  40. package/docs/phase-1-implementation.md +848 -0
  41. package/docs/phase-2-roadmap.md +142 -0
  42. package/docs/quick-recipes.md +115 -0
  43. package/docs/readiness-interpretation.md +105 -0
  44. package/docs/readiness-troubleshooting.md +209 -0
  45. package/docs/release-check-reference.md +63 -0
  46. package/docs/release-guide.md +481 -0
  47. package/docs/release-notes.md +75 -0
  48. package/docs/runtime-contract.md +1010 -0
  49. package/docs/runtime-maintainer-validation.md +212 -0
  50. package/docs/runtime-roadmap.md +2265 -0
  51. package/docs/skill-authoring-guide.md +150 -0
  52. package/docs/submodule-guide.md +131 -0
  53. package/docs/team-adoption.md +113 -0
  54. package/docs/user-guide.md +108 -0
  55. package/docs/vibecoding-fork-analysis.md +398 -0
  56. package/docs/workflow-chaining.md +539 -0
  57. package/examples/ci/README.md +61 -0
  58. package/examples/ci/ci-evidence-input.example.json +56 -0
  59. package/examples/ci/generate-diff-coverage.mjs +90 -0
  60. package/examples/ci/generate-test-evidence.mjs +82 -0
  61. package/examples/ci/github-actions-readiness.yml +108 -0
  62. package/examples/claude-project/README.md +57 -0
  63. package/examples/codex-project/README.md +57 -0
  64. package/examples/cursor-project/README.md +57 -0
  65. package/examples/full-chain/README.md +63 -0
  66. package/examples/full-chain/architecture-design.md +128 -0
  67. package/examples/full-chain/commit-readiness.json +31 -0
  68. package/examples/full-chain/delivery-traceability.yaml +32 -0
  69. package/examples/full-chain/diff-coverage.json +73 -0
  70. package/examples/full-chain/evidence.json +20 -0
  71. package/examples/full-chain/implementation-plan.md +54 -0
  72. package/examples/full-chain/product-acceptance.md +86 -0
  73. package/examples/full-chain/product-discovery.md +84 -0
  74. package/examples/full-chain/product-spec.md +88 -0
  75. package/examples/full-chain/scenario-acceptance.yaml +32 -0
  76. package/examples/full-chain/test-evidence.json +29 -0
  77. package/examples/full-chain/ui-design-contract.md +87 -0
  78. package/examples/golden-path/README.md +84 -0
  79. package/examples/golden-path/diff-coverage.json +66 -0
  80. package/examples/golden-path/implementation-plan.md +62 -0
  81. package/examples/golden-path/product-spec.md +96 -0
  82. package/examples/golden-path/test-evidence.json +29 -0
  83. package/examples/runtime-fixtures/architecture-design.md +128 -0
  84. package/examples/runtime-fixtures/commit-readiness.json +31 -0
  85. package/examples/runtime-fixtures/delivery-traceability.yaml +32 -0
  86. package/examples/runtime-fixtures/diff-coverage.json +73 -0
  87. package/examples/runtime-fixtures/evidence.json +20 -0
  88. package/examples/runtime-fixtures/implementation-plan.md +54 -0
  89. package/examples/runtime-fixtures/negative/commit-readiness-boundary-escalated.json +27 -0
  90. package/examples/runtime-fixtures/negative/delivery-traceability-bad-ref.yaml +32 -0
  91. package/examples/runtime-fixtures/negative/diff-coverage-changed-file-without-task-ref.json +40 -0
  92. package/examples/runtime-fixtures/negative/diff-coverage-operation-mismatch.json +38 -0
  93. package/examples/runtime-fixtures/negative/diff-coverage-required-task-missing.json +24 -0
  94. package/examples/runtime-fixtures/negative/diff-coverage-unexpected-file.json +20 -0
  95. package/examples/runtime-fixtures/negative/test-evidence-missing-output-digest.json +23 -0
  96. package/examples/runtime-fixtures/negative/test-evidence-risky-task-missing.json +29 -0
  97. package/examples/runtime-fixtures/product-acceptance.md +86 -0
  98. package/examples/runtime-fixtures/product-discovery.md +84 -0
  99. package/examples/runtime-fixtures/product-spec.md +88 -0
  100. package/examples/runtime-fixtures/scenario-acceptance.yaml +32 -0
  101. package/examples/runtime-fixtures/test-evidence.json +29 -0
  102. package/examples/runtime-fixtures/ui-design-contract.md +87 -0
  103. package/hooks/post-tool-compact/README.md +47 -0
  104. package/hooks/session-start/README.md +112 -0
  105. package/hooks/session-start/session-start-state-boundary-contract.mjs +161 -0
  106. package/hooks/session-start/session-start.md +29 -0
  107. package/hooks/session-start/session-start.mjs +49 -0
  108. package/hooks/workflow-handoff/README.md +44 -0
  109. package/hooks/workflow-handoff/workflow-handoff.md +11 -0
  110. package/package.json +72 -0
  111. package/skills/using-vibecoding/SKILL.md +396 -0
  112. package/skills/vibe-brainstorming/SKILL.md +98 -0
  113. package/skills/vibe-context-compact/SKILL.md +95 -0
  114. package/skills/vibe-debugging/SKILL.md +87 -0
  115. package/skills/vibe-dispatching-parallel-work/SKILL.md +144 -0
  116. package/skills/vibe-executing-plans/SKILL.md +114 -0
  117. package/skills/vibe-finishing-a-development-branch/SKILL.md +110 -0
  118. package/skills/vibe-implementation/SKILL.md +84 -0
  119. package/skills/vibe-planning/SKILL.md +102 -0
  120. package/skills/vibe-product-acceptance/SKILL.md +106 -0
  121. package/skills/vibe-product-discovery/SKILL.md +107 -0
  122. package/skills/vibe-product-spec/SKILL.md +105 -0
  123. package/skills/vibe-receiving-code-review/SKILL.md +110 -0
  124. package/skills/vibe-requesting-code-review/SKILL.md +106 -0
  125. package/skills/vibe-review/SKILL.md +106 -0
  126. package/skills/vibe-subagent-driven-development/SKILL.md +198 -0
  127. package/skills/vibe-systematic-debugging/SKILL.md +106 -0
  128. package/skills/vibe-test-driven-development/SKILL.md +112 -0
  129. package/skills/vibe-ui-design/SKILL.md +107 -0
  130. package/skills/vibe-verification/SKILL.md +84 -0
  131. package/skills/vibe-verification-before-completion/SKILL.md +170 -0
  132. package/skills/vibe-workspace-isolation/SKILL.md +158 -0
  133. package/skills/vibe-writing-plans/SKILL.md +137 -0
  134. package/skills/vibe-writing-skills/SKILL.md +118 -0
  135. package/templates/AGENTS.md +88 -0
  136. package/templates/CLAUDE.md +88 -0
  137. package/templates/VIBE-CODING.md +157 -0
  138. package/templates/architecture-design.md +139 -0
  139. package/templates/delivery-traceability.yaml +52 -0
  140. package/templates/evidence/README.md +117 -0
  141. package/templates/evidence/diff-coverage.json +34 -0
  142. package/templates/evidence/test-evidence.json +29 -0
  143. package/templates/implementation-plan.md +73 -0
  144. package/templates/product-acceptance.md +84 -0
  145. package/templates/product-discovery.md +81 -0
  146. package/templates/product-spec.md +84 -0
  147. package/templates/scenario-acceptance.yaml +37 -0
  148. package/templates/ui-design-contract.md +86 -0
  149. package/tools/vibe-architecture-check/README.md +66 -0
  150. package/tools/vibe-architecture-check/index.mjs +691 -0
  151. package/tools/vibe-compact/README.md +65 -0
  152. package/tools/vibe-compact/compact-contract.mjs +63 -0
  153. package/tools/vibe-compact/index.mjs +111 -0
  154. package/tools/vibe-doctor/README.md +200 -0
  155. package/tools/vibe-doctor/index.mjs +1721 -0
  156. package/tools/vibe-init/README.md +231 -0
  157. package/tools/vibe-init/index.mjs +369 -0
  158. package/tools/vibe-init/init-cli-args.mjs +100 -0
  159. package/tools/vibe-init/init-entry-merge-model.mjs +33 -0
  160. package/tools/vibe-init/init-install-manifest-model.mjs +137 -0
  161. package/tools/vibe-init/init-installed-agent-experience-contract.mjs +172 -0
  162. package/tools/vibe-init/init-platform-model.mjs +11 -0
  163. package/tools/vibe-init/init-presentation.mjs +149 -0
  164. package/tools/vibe-lifecycle/README.md +37 -0
  165. package/tools/vibe-lifecycle/index.mjs +365 -0
  166. package/tools/vibe-lifecycle/lifecycle-cli-args.mjs +104 -0
  167. package/tools/vibe-lifecycle/lifecycle-summary-model.mjs +67 -0
  168. package/tools/vibe-lifecycle/lifecycle-uninstall-plan-model.mjs +11 -0
  169. package/tools/vibe-plugin-pack/README.md +105 -0
  170. package/tools/vibe-plugin-pack/index.mjs +302 -0
  171. package/tools/vibe-plugin-pack/plugin-pack-cli.mjs +39 -0
  172. package/tools/vibe-plugin-pack/plugin-pack-manifest.mjs +37 -0
  173. package/tools/vibe-profile/index.mjs +212 -0
  174. package/tools/vibe-release-check/README.md +123 -0
  175. package/tools/vibe-release-check/command-manifest/release-check-base-commands.mjs +23 -0
  176. package/tools/vibe-release-check/command-manifest/release-check-closeout-commands.mjs +16 -0
  177. package/tools/vibe-release-check/command-manifest/release-check-command-metadata.mjs +32 -0
  178. package/tools/vibe-release-check/command-manifest/release-check-completion-commands.mjs +41 -0
  179. package/tools/vibe-release-check/command-manifest/release-check-full-chain-commands.mjs +12 -0
  180. package/tools/vibe-release-check/command-manifest/release-check-golden-path-commands.mjs +12 -0
  181. package/tools/vibe-release-check/command-manifest/release-check-install-commands.mjs +26 -0
  182. package/tools/vibe-release-check/command-manifest/release-check-learning-smoke-commands.mjs +21 -0
  183. package/tools/vibe-release-check/command-manifest/release-check-methodology-commands.mjs +27 -0
  184. package/tools/vibe-release-check/command-manifest/release-check-runtime-smoke-commands.mjs +116 -0
  185. package/tools/vibe-release-check/command-manifest/release-check-token-smoke-commands.mjs +21 -0
  186. package/tools/vibe-release-check/index.mjs +223 -0
  187. package/tools/vibe-release-check/release-check-behavior-smoke.mjs +177 -0
  188. package/tools/vibe-release-check/release-check-cli.mjs +37 -0
  189. package/tools/vibe-release-check/release-check-command-manifest.mjs +49 -0
  190. package/tools/vibe-release-check/release-check-completion-fixtures.mjs +151 -0
  191. package/tools/vibe-release-check/release-check-completion-suite.mjs +110 -0
  192. package/tools/vibe-release-check/release-check-dispatch.mjs +116 -0
  193. package/tools/vibe-release-check/release-check-full-chain-suite.mjs +55 -0
  194. package/tools/vibe-release-check/release-check-golden-path-suite.mjs +85 -0
  195. package/tools/vibe-release-check/release-check-install-marker-specs.mjs +133 -0
  196. package/tools/vibe-release-check/release-check-install-suite.mjs +112 -0
  197. package/tools/vibe-release-check/release-check-json-assertion-helpers.mjs +157 -0
  198. package/tools/vibe-release-check/release-check-json-markers.mjs +33 -0
  199. package/tools/vibe-release-check/release-check-learning-fixture-specs.mjs +199 -0
  200. package/tools/vibe-release-check/release-check-learning-suite.mjs +249 -0
  201. package/tools/vibe-release-check/release-check-live-behavior-smoke-fixture.mjs +406 -0
  202. package/tools/vibe-release-check/release-check-methodology-suite.mjs +108 -0
  203. package/tools/vibe-release-check/release-check-package-boundary-smoke.mjs +111 -0
  204. package/tools/vibe-release-check/release-check-platform-transcript-smoke-fixture.mjs +150 -0
  205. package/tools/vibe-release-check/release-check-readonly-marker-data.mjs +1 -0
  206. package/tools/vibe-release-check/release-check-readonly-marker-smoke-specs.mjs +170 -0
  207. package/tools/vibe-release-check/release-check-run-summary.mjs +67 -0
  208. package/tools/vibe-release-check/release-check-runtime-automation-fixtures.mjs +1 -0
  209. package/tools/vibe-release-check/release-check-runtime-automation-governance-reply-trace-smoke-helpers.mjs +224 -0
  210. package/tools/vibe-release-check/release-check-runtime-automation-governance-smoke-specs.mjs +215 -0
  211. package/tools/vibe-release-check/release-check-runtime-automation-governance-suite.mjs +5 -0
  212. package/tools/vibe-release-check/release-check-runtime-automation-methodology-smoke-specs.mjs +157 -0
  213. package/tools/vibe-release-check/release-check-runtime-automation-methodology-suite.mjs +130 -0
  214. package/tools/vibe-release-check/release-check-runtime-automation-platform-smoke-helpers.mjs +306 -0
  215. package/tools/vibe-release-check/release-check-runtime-automation-platform-suite.mjs +30 -0
  216. package/tools/vibe-release-check/release-check-runtime-automation-smoke-fixtures.mjs +53 -0
  217. package/tools/vibe-release-check/release-check-runtime-automation-source-candidate-smoke-helpers.mjs +506 -0
  218. package/tools/vibe-release-check/release-check-runtime-automation-source-suite.mjs +5 -0
  219. package/tools/vibe-release-check/release-check-runtime-automation-subagents-lifecycle-smoke-helpers.mjs +305 -0
  220. package/tools/vibe-release-check/release-check-runtime-automation-subagents-suite.mjs +25 -0
  221. package/tools/vibe-release-check/release-check-runtime-automation-suite.mjs +25 -0
  222. package/tools/vibe-release-check/release-check-runtime-daemon-bounded-run-smoke-helpers.mjs +243 -0
  223. package/tools/vibe-release-check/release-check-runtime-daemon-suite.mjs +5 -0
  224. package/tools/vibe-release-check/release-check-runtime-dispatch-fixtures.mjs +129 -0
  225. package/tools/vibe-release-check/release-check-runtime-dispatch-suite.mjs +5 -0
  226. package/tools/vibe-release-check/release-check-runtime-execution-approval-smoke-helpers.mjs +274 -0
  227. package/tools/vibe-release-check/release-check-runtime-execution-approval-suite.mjs +5 -0
  228. package/tools/vibe-release-check/release-check-runtime-execution-base-suite.mjs +388 -0
  229. package/tools/vibe-release-check/release-check-runtime-execution-recovery-suite.mjs +412 -0
  230. package/tools/vibe-release-check/release-check-runtime-execution-scheduler-suite.mjs +261 -0
  231. package/tools/vibe-release-check/release-check-runtime-execution-suite.mjs +11 -0
  232. package/tools/vibe-release-check/release-check-runtime-flow-smoke.mjs +347 -0
  233. package/tools/vibe-release-check/release-check-runtime-handoff-fixture-specs.mjs +211 -0
  234. package/tools/vibe-release-check/release-check-runtime-handoff-fixtures.mjs +11 -0
  235. package/tools/vibe-release-check/release-check-runtime-handoff-smoke-specs.mjs +86 -0
  236. package/tools/vibe-release-check/release-check-runtime-handoff-suite.mjs +316 -0
  237. package/tools/vibe-release-check/release-check-runtime-ledger-fixture-specs.mjs +9 -0
  238. package/tools/vibe-release-check/release-check-runtime-ledger-fixtures.mjs +51 -0
  239. package/tools/vibe-release-check/release-check-runtime-ledger-suite.mjs +24 -0
  240. package/tools/vibe-release-check/release-check-runtime-scheduler-fixture-specs.mjs +129 -0
  241. package/tools/vibe-release-check/release-check-runtime-scheduler-fixtures.mjs +10 -0
  242. package/tools/vibe-release-check/release-check-runtime-sdd-suite.mjs +535 -0
  243. package/tools/vibe-release-check/release-check-runtime-smoke-harness.mjs +140 -0
  244. package/tools/vibe-release-check/release-check-runtime-surface-expectations.mjs +106 -0
  245. package/tools/vibe-release-check/release-check-runtime-surface-smoke.mjs +112 -0
  246. package/tools/vibe-release-check/release-check-runtime-task-artifact-suite.mjs +105 -0
  247. package/tools/vibe-release-check/release-check-runtime-task-fixture-specs.mjs +270 -0
  248. package/tools/vibe-release-check/release-check-runtime-task-fixtures.mjs +19 -0
  249. package/tools/vibe-release-check/release-check-runtime.mjs +53 -0
  250. package/tools/vibe-release-check/release-check-stage103-118-fixtures.mjs +214 -0
  251. package/tools/vibe-release-check/release-check-stage103-118-smoke-specs.mjs +97 -0
  252. package/tools/vibe-release-check/release-check-stage103-118-smoke.mjs +861 -0
  253. package/tools/vibe-release-check/release-check-stage11-smoke.mjs +66 -0
  254. package/tools/vibe-release-check/release-check-stage119-120-fixture-specs.mjs +119 -0
  255. package/tools/vibe-release-check/release-check-stage119-120-smoke.mjs +325 -0
  256. package/tools/vibe-release-check/release-check-stage12-smoke.mjs +59 -0
  257. package/tools/vibe-release-check/release-check-stage121-136-fixture-specs.mjs +26 -0
  258. package/tools/vibe-release-check/release-check-stage121-136-fixtures.mjs +591 -0
  259. package/tools/vibe-release-check/release-check-stage121-136-smoke.mjs +917 -0
  260. package/tools/vibe-release-check/release-check-stage13-smoke.mjs +78 -0
  261. package/tools/vibe-release-check/release-check-stage137-140-smoke.mjs +534 -0
  262. package/tools/vibe-release-check/release-check-stage14-smoke.mjs +101 -0
  263. package/tools/vibe-release-check/release-check-stage141-148-smoke.mjs +1143 -0
  264. package/tools/vibe-release-check/release-check-stage15-smoke.mjs +132 -0
  265. package/tools/vibe-release-check/release-check-stage50-53-smoke.mjs +429 -0
  266. package/tools/vibe-release-check/release-check-subagent-adapter-bridge-smoke.mjs +162 -0
  267. package/tools/vibe-release-check/release-check-suite-plan-smoke.mjs +86 -0
  268. package/tools/vibe-release-check/release-check-suites.mjs +164 -0
  269. package/tools/vibe-release-check/release-check-test-run-smoke.mjs +59 -0
  270. package/tools/vibe-release-check/release-check-timing.mjs +98 -0
  271. package/tools/vibe-release-check/release-check-token-suite.mjs +260 -0
  272. package/tools/vibe-release-check/release-check-workflow-entry-suite.mjs +195 -0
  273. package/tools/vibe-release-check/release-check-workflow-governance-fixtures.mjs +138 -0
  274. package/tools/vibe-release-check/release-check-workflow-governance-smoke-suite.mjs +768 -0
  275. package/tools/vibe-release-check/release-check-workflow-ux-smoke.mjs +456 -0
  276. package/tools/vibe-runtime/README.md +2637 -0
  277. package/tools/vibe-runtime/index.mjs +3117 -0
  278. package/tools/vibe-runtime/runtime-adapter-bootstrap-matrix.mjs +264 -0
  279. package/tools/vibe-runtime/runtime-adapter-entry-acceptance.mjs +310 -0
  280. package/tools/vibe-runtime/runtime-adapter-packaging-consistency-command.mjs +131 -0
  281. package/tools/vibe-runtime/runtime-adapter-packaging-consistency.mjs +253 -0
  282. package/tools/vibe-runtime/runtime-advice-hub-model.mjs +175 -0
  283. package/tools/vibe-runtime/runtime-agent-session-start-contract.mjs +138 -0
  284. package/tools/vibe-runtime/runtime-artifact-ref-validation.mjs +281 -0
  285. package/tools/vibe-runtime/runtime-automatic-verification-gate-contract.mjs +134 -0
  286. package/tools/vibe-runtime/runtime-automation-boundary-text.mjs +7 -0
  287. package/tools/vibe-runtime/runtime-automation-command.mjs +367 -0
  288. package/tools/vibe-runtime/runtime-automation-plan-model.mjs +239 -0
  289. package/tools/vibe-runtime/runtime-automation-policy-model.mjs +175 -0
  290. package/tools/vibe-runtime/runtime-automation-readiness.mjs +347 -0
  291. package/tools/vibe-runtime/runtime-autopilot-lab-profile-contract.mjs +223 -0
  292. package/tools/vibe-runtime/runtime-behavioral-evaluation-contract.mjs +529 -0
  293. package/tools/vibe-runtime/runtime-behavioral-negative-gate-matrix.mjs +274 -0
  294. package/tools/vibe-runtime/runtime-bounded-attempt-policy-model.mjs +13 -0
  295. package/tools/vibe-runtime/runtime-bounded-foreground-command-executor-contract.mjs +288 -0
  296. package/tools/vibe-runtime/runtime-capability-registry.mjs +250 -0
  297. package/tools/vibe-runtime/runtime-cli-args.mjs +550 -0
  298. package/tools/vibe-runtime/runtime-cli-command-specs.mjs +63 -0
  299. package/tools/vibe-runtime/runtime-cli-dispatch.mjs +21 -0
  300. package/tools/vibe-runtime/runtime-cli-evidence-option-specs.mjs +193 -0
  301. package/tools/vibe-runtime/runtime-cli-evidence-options.mjs +28 -0
  302. package/tools/vibe-runtime/runtime-cli-from-options.mjs +222 -0
  303. package/tools/vibe-runtime/runtime-cli-low-risk-option-specs.mjs +128 -0
  304. package/tools/vibe-runtime/runtime-cli-main.mjs +32 -0
  305. package/tools/vibe-runtime/runtime-cli-option-default-families.mjs +454 -0
  306. package/tools/vibe-runtime/runtime-cli-option-defaults.mjs +33 -0
  307. package/tools/vibe-runtime/runtime-cli-option-handlers.mjs +82 -0
  308. package/tools/vibe-runtime/runtime-cli-usage.mjs +316 -0
  309. package/tools/vibe-runtime/runtime-cli-value-options.mjs +74 -0
  310. package/tools/vibe-runtime/runtime-close-loop-dashboard.mjs +283 -0
  311. package/tools/vibe-runtime/runtime-closeout-parity-contract.mjs +214 -0
  312. package/tools/vibe-runtime/runtime-command-container.mjs +26 -0
  313. package/tools/vibe-runtime/runtime-command-surface-registry.mjs +383 -0
  314. package/tools/vibe-runtime/runtime-command-wrapper-deps.mjs +13 -0
  315. package/tools/vibe-runtime/runtime-commit-readiness-envelope.mjs +281 -0
  316. package/tools/vibe-runtime/runtime-completion-boundary-text.mjs +7 -0
  317. package/tools/vibe-runtime/runtime-completion-bundle-contract.mjs +71 -0
  318. package/tools/vibe-runtime/runtime-completion-chain-assembly.mjs +48 -0
  319. package/tools/vibe-runtime/runtime-completion-command.mjs +50 -0
  320. package/tools/vibe-runtime/runtime-completion-evidence-bundle.mjs +269 -0
  321. package/tools/vibe-runtime/runtime-completion-evidence-descriptors.mjs +156 -0
  322. package/tools/vibe-runtime/runtime-completion-local-evidence-gates.mjs +164 -0
  323. package/tools/vibe-runtime/runtime-completion-presentation.mjs +71 -0
  324. package/tools/vibe-runtime/runtime-completion-readiness-summary.mjs +159 -0
  325. package/tools/vibe-runtime/runtime-confirmed-one-shot-plan.mjs +300 -0
  326. package/tools/vibe-runtime/runtime-context-budget-entry-defaults-command.mjs +77 -0
  327. package/tools/vibe-runtime/runtime-context-budget-entry-defaults.mjs +341 -0
  328. package/tools/vibe-runtime/runtime-contract-marker-registry.mjs +13 -0
  329. package/tools/vibe-runtime/runtime-contributor-guardrail-command.mjs +78 -0
  330. package/tools/vibe-runtime/runtime-contributor-guardrail-evidence.mjs +319 -0
  331. package/tools/vibe-runtime/runtime-control-plane-command.mjs +237 -0
  332. package/tools/vibe-runtime/runtime-control-plane-evals-artifacts.mjs +123 -0
  333. package/tools/vibe-runtime/runtime-control-plane-evals-boundary-model.mjs +75 -0
  334. package/tools/vibe-runtime/runtime-control-plane-evals-cases.mjs +547 -0
  335. package/tools/vibe-runtime/runtime-control-plane-evals-command.mjs +527 -0
  336. package/tools/vibe-runtime/runtime-control-plane-evals-report-validation.mjs +209 -0
  337. package/tools/vibe-runtime/runtime-control-plane-planner-artifacts.mjs +457 -0
  338. package/tools/vibe-runtime/runtime-control-plane-planning-command.mjs +563 -0
  339. package/tools/vibe-runtime/runtime-control-plane-planning-input.mjs +99 -0
  340. package/tools/vibe-runtime/runtime-control-plane-planning-listing.mjs +48 -0
  341. package/tools/vibe-runtime/runtime-control-plane-planning-presentation.mjs +246 -0
  342. package/tools/vibe-runtime/runtime-control-plane-planning-validation.mjs +529 -0
  343. package/tools/vibe-runtime/runtime-control-plane-readonly-command.mjs +537 -0
  344. package/tools/vibe-runtime/runtime-control-plane-readonly-deps.mjs +146 -0
  345. package/tools/vibe-runtime/runtime-control-plane-release-evidence.mjs +525 -0
  346. package/tools/vibe-runtime/runtime-control-plane-release-gates.mjs +369 -0
  347. package/tools/vibe-runtime/runtime-control-plane-router-planning-model.mjs +152 -0
  348. package/tools/vibe-runtime/runtime-control-plane-routing-artifacts.mjs +588 -0
  349. package/tools/vibe-runtime/runtime-controlled-change-delivery-contract.mjs +165 -0
  350. package/tools/vibe-runtime/runtime-controlled-execution-gate-contract.mjs +141 -0
  351. package/tools/vibe-runtime/runtime-controlled-long-running-automation-contract.mjs +184 -0
  352. package/tools/vibe-runtime/runtime-controlled-subagent-orchestration-contract.mjs +169 -0
  353. package/tools/vibe-runtime/runtime-daemon-command.mjs +166 -0
  354. package/tools/vibe-runtime/runtime-daemon-state-lifecycle-model.mjs +359 -0
  355. package/tools/vibe-runtime/runtime-delivery-methodology-command.mjs +17 -0
  356. package/tools/vibe-runtime/runtime-delivery-methodology-gates.mjs +277 -0
  357. package/tools/vibe-runtime/runtime-diff-coverage-envelope.mjs +301 -0
  358. package/tools/vibe-runtime/runtime-dispatch-command.mjs +484 -0
  359. package/tools/vibe-runtime/runtime-dispatch-readonly-artifacts.mjs +406 -0
  360. package/tools/vibe-runtime/runtime-dispatch-state-lifecycle-model.mjs +199 -0
  361. package/tools/vibe-runtime/runtime-durable-state-recovery-contract.mjs +172 -0
  362. package/tools/vibe-runtime/runtime-entry-advice-model.mjs +201 -0
  363. package/tools/vibe-runtime/runtime-entry-deps-builder.mjs +54 -0
  364. package/tools/vibe-runtime/runtime-entry-presentation.mjs +82 -0
  365. package/tools/vibe-runtime/runtime-entry-summary-model.mjs +343 -0
  366. package/tools/vibe-runtime/runtime-entry-trigger-discipline.mjs +341 -0
  367. package/tools/vibe-runtime/runtime-entry-trigger-tightening-command.mjs +79 -0
  368. package/tools/vibe-runtime/runtime-entry-trigger-tightening.mjs +357 -0
  369. package/tools/vibe-runtime/runtime-eval-catalog-model.mjs +101 -0
  370. package/tools/vibe-runtime/runtime-eval-transcript-fixtures.mjs +218 -0
  371. package/tools/vibe-runtime/runtime-evidence-intake-envelope.mjs +278 -0
  372. package/tools/vibe-runtime/runtime-evidence-repair-model.mjs +180 -0
  373. package/tools/vibe-runtime/runtime-executable-plan-contract.mjs +428 -0
  374. package/tools/vibe-runtime/runtime-execution-approval-lifecycle-models.mjs +278 -0
  375. package/tools/vibe-runtime/runtime-execution-candidate-approval-artifacts.mjs +227 -0
  376. package/tools/vibe-runtime/runtime-execution-command.mjs +544 -0
  377. package/tools/vibe-runtime/runtime-execution-enabled-bridge-model.mjs +113 -0
  378. package/tools/vibe-runtime/runtime-execution-enabled-closeout-boundary.mjs +89 -0
  379. package/tools/vibe-runtime/runtime-execution-enabled-preflight-model.mjs +185 -0
  380. package/tools/vibe-runtime/runtime-execution-enabled-profile-contract.mjs +127 -0
  381. package/tools/vibe-runtime/runtime-execution-enabled-run-envelope.mjs +153 -0
  382. package/tools/vibe-runtime/runtime-execution-evidence-binder.mjs +537 -0
  383. package/tools/vibe-runtime/runtime-execution-plan-artifacts.mjs +136 -0
  384. package/tools/vibe-runtime/runtime-execution-policy-artifacts.mjs +377 -0
  385. package/tools/vibe-runtime/runtime-execution-presentation.mjs +174 -0
  386. package/tools/vibe-runtime/runtime-execution-readonly-artifacts.mjs +228 -0
  387. package/tools/vibe-runtime/runtime-execution-run-preflight-artifacts.mjs +265 -0
  388. package/tools/vibe-runtime/runtime-execution-safety-artifacts.mjs +131 -0
  389. package/tools/vibe-runtime/runtime-execution-state-write-lifecycle-model.mjs +99 -0
  390. package/tools/vibe-runtime/runtime-experience-friction-matrix.mjs +395 -0
  391. package/tools/vibe-runtime/runtime-experience-learning-pattern.mjs +354 -0
  392. package/tools/vibe-runtime/runtime-experience-regression-dashboard.mjs +398 -0
  393. package/tools/vibe-runtime/runtime-experience-upgrade-command.mjs +92 -0
  394. package/tools/vibe-runtime/runtime-experience-upgrade-prioritizer.mjs +451 -0
  395. package/tools/vibe-runtime/runtime-foreground-worker-plan.mjs +275 -0
  396. package/tools/vibe-runtime/runtime-git-diff-read-model.mjs +322 -0
  397. package/tools/vibe-runtime/runtime-governance-attestation.mjs +304 -0
  398. package/tools/vibe-runtime/runtime-governance-command.mjs +609 -0
  399. package/tools/vibe-runtime/runtime-governance-convergence-reports.mjs +601 -0
  400. package/tools/vibe-runtime/runtime-governance-pr-models.mjs +551 -0
  401. package/tools/vibe-runtime/runtime-governance-presentation.mjs +67 -0
  402. package/tools/vibe-runtime/runtime-governance-route-model.mjs +194 -0
  403. package/tools/vibe-runtime/runtime-governance-surface-reports.mjs +495 -0
  404. package/tools/vibe-runtime/runtime-hooks-boundary-model.mjs +356 -0
  405. package/tools/vibe-runtime/runtime-hooks-command.mjs +286 -0
  406. package/tools/vibe-runtime/runtime-human-completion-evidence-model.mjs +220 -0
  407. package/tools/vibe-runtime/runtime-human-friendly-aliases.mjs +250 -0
  408. package/tools/vibe-runtime/runtime-implementation-methodology-command.mjs +17 -0
  409. package/tools/vibe-runtime/runtime-implementation-methodology-gates.mjs +164 -0
  410. package/tools/vibe-runtime/runtime-implementation-task-registry.mjs +334 -0
  411. package/tools/vibe-runtime/runtime-install-experience-command.mjs +120 -0
  412. package/tools/vibe-runtime/runtime-install-experience-score.mjs +334 -0
  413. package/tools/vibe-runtime/runtime-installed-multiround-ux-acceptance.mjs +149 -0
  414. package/tools/vibe-runtime/runtime-interaction-command-domain-registry.mjs +46 -0
  415. package/tools/vibe-runtime/runtime-interaction-command.mjs +648 -0
  416. package/tools/vibe-runtime/runtime-interaction-completion-command.mjs +220 -0
  417. package/tools/vibe-runtime/runtime-interaction-entry-command.mjs +130 -0
  418. package/tools/vibe-runtime/runtime-interaction-workflow-envelopes.mjs +412 -0
  419. package/tools/vibe-runtime/runtime-learning-advice-model.mjs +157 -0
  420. package/tools/vibe-runtime/runtime-learning-artifact-model.mjs +509 -0
  421. package/tools/vibe-runtime/runtime-learning-audit-model.mjs +106 -0
  422. package/tools/vibe-runtime/runtime-learning-interaction-command.mjs +220 -0
  423. package/tools/vibe-runtime/runtime-learning-observation-model.mjs +124 -0
  424. package/tools/vibe-runtime/runtime-learning-presentation.mjs +84 -0
  425. package/tools/vibe-runtime/runtime-learning-run-preview-model.mjs +184 -0
  426. package/tools/vibe-runtime/runtime-lease-command.mjs +95 -0
  427. package/tools/vibe-runtime/runtime-lease-state-lifecycle-model.mjs +247 -0
  428. package/tools/vibe-runtime/runtime-list-presentation.mjs +7 -0
  429. package/tools/vibe-runtime/runtime-live-behavior-transcript-model.mjs +164 -0
  430. package/tools/vibe-runtime/runtime-local-behavior-eval-contracts-command.mjs +76 -0
  431. package/tools/vibe-runtime/runtime-local-behavior-eval-contracts.mjs +382 -0
  432. package/tools/vibe-runtime/runtime-local-commit-automation-gate.mjs +254 -0
  433. package/tools/vibe-runtime/runtime-local-json-input.mjs +32 -0
  434. package/tools/vibe-runtime/runtime-methodology-coverage-map.mjs +398 -0
  435. package/tools/vibe-runtime/runtime-methodology-coverage-marker-specs.mjs +61 -0
  436. package/tools/vibe-runtime/runtime-methodology-coverage-presentation.mjs +26 -0
  437. package/tools/vibe-runtime/runtime-methodology-gate-model.mjs +154 -0
  438. package/tools/vibe-runtime/runtime-methodology-gate-output-envelope.mjs +4 -0
  439. package/tools/vibe-runtime/runtime-methodology-interaction-command.mjs +147 -0
  440. package/tools/vibe-runtime/runtime-methodology-presentation.mjs +76 -0
  441. package/tools/vibe-runtime/runtime-methodology-route-model.mjs +93 -0
  442. package/tools/vibe-runtime/runtime-next-action-console.mjs +388 -0
  443. package/tools/vibe-runtime/runtime-next-action-evidence-prompts-command.mjs +84 -0
  444. package/tools/vibe-runtime/runtime-next-action-evidence-prompts.mjs +327 -0
  445. package/tools/vibe-runtime/runtime-observability-command.mjs +96 -0
  446. package/tools/vibe-runtime/runtime-observability-presentation.mjs +30 -0
  447. package/tools/vibe-runtime/runtime-observability-readiness-model.mjs +204 -0
  448. package/tools/vibe-runtime/runtime-patch-queue-contract.mjs +151 -0
  449. package/tools/vibe-runtime/runtime-plan-action-manifest.mjs +334 -0
  450. package/tools/vibe-runtime/runtime-planner-route-model.mjs +75 -0
  451. package/tools/vibe-runtime/runtime-platform-acceptance-command.mjs +216 -0
  452. package/tools/vibe-runtime/runtime-platform-capability-artifacts.mjs +156 -0
  453. package/tools/vibe-runtime/runtime-platform-capability-model.mjs +105 -0
  454. package/tools/vibe-runtime/runtime-platform-command.mjs +329 -0
  455. package/tools/vibe-runtime/runtime-platform-presentation.mjs +78 -0
  456. package/tools/vibe-runtime/runtime-platform-session-artifacts.mjs +857 -0
  457. package/tools/vibe-runtime/runtime-platform-transcript-example-pack.mjs +293 -0
  458. package/tools/vibe-runtime/runtime-platform-transcript-intake-model.mjs +247 -0
  459. package/tools/vibe-runtime/runtime-platform-transcript-replay-model.mjs +371 -0
  460. package/tools/vibe-runtime/runtime-policy-catalog.mjs +54 -0
  461. package/tools/vibe-runtime/runtime-product-methodology-command.mjs +17 -0
  462. package/tools/vibe-runtime/runtime-product-methodology-gates.mjs +316 -0
  463. package/tools/vibe-runtime/runtime-progressive-entry-ux.mjs +237 -0
  464. package/tools/vibe-runtime/runtime-queue-command.mjs +98 -0
  465. package/tools/vibe-runtime/runtime-queue-state-lifecycle-model.mjs +318 -0
  466. package/tools/vibe-runtime/runtime-readiness-gate-split.mjs +196 -0
  467. package/tools/vibe-runtime/runtime-readonly-local-json-output-envelope.mjs +24 -0
  468. package/tools/vibe-runtime/runtime-recovery-classification-models.mjs +412 -0
  469. package/tools/vibe-runtime/runtime-recovery-command.mjs +107 -0
  470. package/tools/vibe-runtime/runtime-recovery-presentation.mjs +65 -0
  471. package/tools/vibe-runtime/runtime-recovery-state-lifecycle-model.mjs +419 -0
  472. package/tools/vibe-runtime/runtime-release-command-deps.mjs +4 -0
  473. package/tools/vibe-runtime/runtime-release-command.mjs +225 -0
  474. package/tools/vibe-runtime/runtime-release-state-lifecycle-model.mjs +48 -0
  475. package/tools/vibe-runtime/runtime-reply-artifact-lifecycle-model.mjs +84 -0
  476. package/tools/vibe-runtime/runtime-reply-command.mjs +488 -0
  477. package/tools/vibe-runtime/runtime-retry-command.mjs +223 -0
  478. package/tools/vibe-runtime/runtime-retry-run-gate-model.mjs +151 -0
  479. package/tools/vibe-runtime/runtime-review-envelope.mjs +449 -0
  480. package/tools/vibe-runtime/runtime-review-feedback-gate.mjs +160 -0
  481. package/tools/vibe-runtime/runtime-runbook-executor-preview-contract.mjs +361 -0
  482. package/tools/vibe-runtime/runtime-scheduler-command.mjs +8 -0
  483. package/tools/vibe-runtime/runtime-scheduler-risk-artifacts.mjs +775 -0
  484. package/tools/vibe-runtime/runtime-scheduler-state-lifecycle-model.mjs +53 -0
  485. package/tools/vibe-runtime/runtime-sdd-consumption-command.mjs +386 -0
  486. package/tools/vibe-runtime/runtime-sdd-evidence-chain-model.mjs +200 -0
  487. package/tools/vibe-runtime/runtime-sdd-handoff-chain-model.mjs +168 -0
  488. package/tools/vibe-runtime/runtime-sdd-implementer-artifact-model.mjs +90 -0
  489. package/tools/vibe-runtime/runtime-sdd-loop-command.mjs +659 -0
  490. package/tools/vibe-runtime/runtime-sdd-plan-preflight-model.mjs +121 -0
  491. package/tools/vibe-runtime/runtime-sdd-review-package-command.mjs +197 -0
  492. package/tools/vibe-runtime/runtime-sdd-review-package-model.mjs +183 -0
  493. package/tools/vibe-runtime/runtime-sdd-task-brief-model.mjs +144 -0
  494. package/tools/vibe-runtime/runtime-self-test-gate-profile.mjs +225 -0
  495. package/tools/vibe-runtime/runtime-sequential-stage-runbook.mjs +406 -0
  496. package/tools/vibe-runtime/runtime-session-checkpoint-model.mjs +217 -0
  497. package/tools/vibe-runtime/runtime-session-skill-command.mjs +241 -0
  498. package/tools/vibe-runtime/runtime-session-start-example-command.mjs +122 -0
  499. package/tools/vibe-runtime/runtime-session-start-example-pack.mjs +290 -0
  500. package/tools/vibe-runtime/runtime-session-start-shape-acceptance.mjs +344 -0
  501. package/tools/vibe-runtime/runtime-skill-contract-schema.mjs +221 -0
  502. package/tools/vibe-runtime/runtime-skill-route-registry.mjs +47 -0
  503. package/tools/vibe-runtime/runtime-skill-runtime-traceability-map.mjs +268 -0
  504. package/tools/vibe-runtime/runtime-source-merge-apply-boundary-model.mjs +130 -0
  505. package/tools/vibe-runtime/runtime-source-merge-artifacts.mjs +920 -0
  506. package/tools/vibe-runtime/runtime-source-merge-command.mjs +160 -0
  507. package/tools/vibe-runtime/runtime-source-merge-entry-command.mjs +153 -0
  508. package/tools/vibe-runtime/runtime-source-patch-plan-model.mjs +119 -0
  509. package/tools/vibe-runtime/runtime-stage-scriptlet.mjs +430 -0
  510. package/tools/vibe-runtime/runtime-staged-commit-readiness.mjs +469 -0
  511. package/tools/vibe-runtime/runtime-state-directory-model.mjs +7 -0
  512. package/tools/vibe-runtime/runtime-state-io.mjs +41 -0
  513. package/tools/vibe-runtime/runtime-state-paths.mjs +231 -0
  514. package/tools/vibe-runtime/runtime-state-presence-model.mjs +6 -0
  515. package/tools/vibe-runtime/runtime-state-risk-paths.mjs +70 -0
  516. package/tools/vibe-runtime/runtime-subagent-adapter-dispatch-command.mjs +266 -0
  517. package/tools/vibe-runtime/runtime-subagent-boundary-contracts.mjs +118 -0
  518. package/tools/vibe-runtime/runtime-subagent-permission-command.mjs +78 -0
  519. package/tools/vibe-runtime/runtime-subagent-permission-gate-model.mjs +131 -0
  520. package/tools/vibe-runtime/runtime-subagent-permission-visibility.mjs +294 -0
  521. package/tools/vibe-runtime/runtime-subagents-artifact-specs.mjs +257 -0
  522. package/tools/vibe-runtime/runtime-subagents-command.mjs +10 -0
  523. package/tools/vibe-runtime/runtime-subagents-eligibility-model.mjs +340 -0
  524. package/tools/vibe-runtime/runtime-subagents-platform-session-proxies.mjs +54 -0
  525. package/tools/vibe-runtime/runtime-subagents-presentation.mjs +91 -0
  526. package/tools/vibe-runtime/runtime-subagents-risk-artifacts.mjs +853 -0
  527. package/tools/vibe-runtime/runtime-subagents-stage-artifact-model.mjs +538 -0
  528. package/tools/vibe-runtime/runtime-subagents-tail-routing-model.mjs +48 -0
  529. package/tools/vibe-runtime/runtime-suite-plan-model.mjs +194 -0
  530. package/tools/vibe-runtime/runtime-superpowers-comparison-matrix.mjs +399 -0
  531. package/tools/vibe-runtime/runtime-superpowers-gap-matrix.mjs +307 -0
  532. package/tools/vibe-runtime/runtime-superpowers-parity-command.mjs +102 -0
  533. package/tools/vibe-runtime/runtime-superpowers-parity-profile-contract.mjs +183 -0
  534. package/tools/vibe-runtime/runtime-superpowers-parity-scorecard.mjs +460 -0
  535. package/tools/vibe-runtime/runtime-superpowers-regression-guard.mjs +270 -0
  536. package/tools/vibe-runtime/runtime-superpowers-style-eval-pack.mjs +367 -0
  537. package/tools/vibe-runtime/runtime-task-commit-gates.mjs +62 -0
  538. package/tools/vibe-runtime/runtime-task-commit-readiness.mjs +66 -0
  539. package/tools/vibe-runtime/runtime-task-commit-sidecar.mjs +65 -0
  540. package/tools/vibe-runtime/runtime-tdd-trace-contract.mjs +277 -0
  541. package/tools/vibe-runtime/runtime-test-evidence-model.mjs +196 -0
  542. package/tools/vibe-runtime/runtime-test-run-command-deps.mjs +7 -0
  543. package/tools/vibe-runtime/runtime-test-run-command.mjs +108 -0
  544. package/tools/vibe-runtime/runtime-token-economy-model.mjs +336 -0
  545. package/tools/vibe-runtime/runtime-token-interaction-command.mjs +381 -0
  546. package/tools/vibe-runtime/runtime-token-savior-budget.mjs +370 -0
  547. package/tools/vibe-runtime/runtime-tokens-command-deps.mjs +17 -0
  548. package/tools/vibe-runtime/runtime-tokens-command.mjs +117 -0
  549. package/tools/vibe-runtime/runtime-tokens-presentation.mjs +45 -0
  550. package/tools/vibe-runtime/runtime-trace-command.mjs +283 -0
  551. package/tools/vibe-runtime/runtime-trace-source-registry.mjs +132 -0
  552. package/tools/vibe-runtime/runtime-verification-gate-chain-model.mjs +131 -0
  553. package/tools/vibe-runtime/runtime-verification-repair-loop-plan.mjs +188 -0
  554. package/tools/vibe-runtime/runtime-workflow-alias-boundary-text.mjs +7 -0
  555. package/tools/vibe-runtime/runtime-workflow-alias-interaction-command.mjs +145 -0
  556. package/tools/vibe-runtime/runtime-workflow-command-deps.mjs +41 -0
  557. package/tools/vibe-runtime/runtime-workflow-command.mjs +191 -0
  558. package/tools/vibe-runtime/runtime-workflow-discipline-summary.mjs +164 -0
  559. package/tools/vibe-runtime/runtime-workflow-entry-envelopes.mjs +156 -0
  560. package/tools/vibe-runtime/runtime-workflow-ledger-command.mjs +239 -0
  561. package/tools/vibe-runtime/runtime-workflow-ledger-state-lifecycle-model.mjs +46 -0
  562. package/tools/vibe-runtime/runtime-workflow-loop-contract.mjs +259 -0
  563. package/tools/vibe-runtime/runtime-workflow-next-step-gate-model.mjs +106 -0
  564. package/tools/vibe-runtime/runtime-workflow-presentation.mjs +355 -0
  565. package/tools/vibe-runtime/runtime-workflow-readiness-model.mjs +176 -0
  566. package/tools/vibe-runtime/runtime-workflow-run-plan-model.mjs +207 -0
  567. package/tools/vibe-runtime/runtime-workflow-start-model.mjs +229 -0
  568. package/tools/vibe-runtime/runtime-workflow-state-artifacts.mjs +381 -0
  569. package/tools/vibe-runtime/runtime-workflow-state-helpers.mjs +456 -0
  570. package/tools/vibe-runtime/runtime-workflow-state-summary.mjs +65 -0
  571. package/tools/vibe-runtime/runtime-workflow-state-validation.mjs +104 -0
  572. package/tools/vibe-runtime/runtime-workflow-ux-model.mjs +205 -0
  573. package/tools/vibe-runtime/runtime-workspace-boundary-text.mjs +7 -0
  574. package/tools/vibe-runtime/runtime-workspace-isolation-command.mjs +295 -0
  575. package/tools/vibe-runtime/state-core-paths.mjs +113 -0
  576. package/tools/vibe-runtime/state-extension-paths.mjs +198 -0
  577. package/tools/vibe-runtime/state-safe-paths.mjs +2 -0
  578. package/tools/vibe-runtime-check/README.md +110 -0
  579. package/tools/vibe-runtime-check/architecture-tool-contracts.mjs +150 -0
  580. package/tools/vibe-runtime-check/index.mjs +186 -0
  581. package/tools/vibe-runtime-check/install-summary-adoption-contracts.mjs +115 -0
  582. package/tools/vibe-runtime-check/marker-contract-core.mjs +20 -0
  583. package/tools/vibe-runtime-check/product-artifact-contracts.mjs +24 -0
  584. package/tools/vibe-runtime-check/release-check-install-placement-contracts.mjs +166 -0
  585. package/tools/vibe-runtime-check/release-runtime-suite-layer-contracts.mjs +137 -0
  586. package/tools/vibe-runtime-check/runtime-architecture-manifest-drift-contracts.mjs +128 -0
  587. package/tools/vibe-runtime-check/runtime-automation-readiness-contracts.mjs +404 -0
  588. package/tools/vibe-runtime-check/runtime-capability-registry-contracts.mjs +299 -0
  589. package/tools/vibe-runtime-check/runtime-check-diagnostics-presentation.mjs +71 -0
  590. package/tools/vibe-runtime-check/runtime-cli-surface-contracts.mjs +156 -0
  591. package/tools/vibe-runtime-check/runtime-close-loop-contracts.mjs +163 -0
  592. package/tools/vibe-runtime-check/runtime-contract-delivery-registry.mjs +19 -0
  593. package/tools/vibe-runtime-check/runtime-contract-implementation-registry.mjs +23 -0
  594. package/tools/vibe-runtime-check/runtime-contract-local-evidence-registry.mjs +43 -0
  595. package/tools/vibe-runtime-check/runtime-contract-product-registry.mjs +83 -0
  596. package/tools/vibe-runtime-check/runtime-contract-registry.mjs +19 -0
  597. package/tools/vibe-runtime-check/runtime-control-plane-contracts.mjs +14 -0
  598. package/tools/vibe-runtime-check/runtime-doc-contract-marker-specs.mjs +349 -0
  599. package/tools/vibe-runtime-check/runtime-doc-contracts.mjs +24 -0
  600. package/tools/vibe-runtime-check/runtime-doc-marker-contracts.mjs +25 -0
  601. package/tools/vibe-runtime-check/runtime-entry-size-contracts.mjs +477 -0
  602. package/tools/vibe-runtime-check/runtime-experience-cli-contract-specs.mjs +98 -0
  603. package/tools/vibe-runtime-check/runtime-experience-cli-contracts.mjs +12 -0
  604. package/tools/vibe-runtime-check/runtime-experience-contracts.mjs +187 -0
  605. package/tools/vibe-runtime-check/runtime-governance-learning-token-contract-specs.mjs +92 -0
  606. package/tools/vibe-runtime-check/runtime-governance-learning-token-contracts.mjs +12 -0
  607. package/tools/vibe-runtime-check/runtime-high-risk-boundary-contracts.mjs +35 -0
  608. package/tools/vibe-runtime-check/runtime-high-risk-boundary-matrix.mjs +75 -0
  609. package/tools/vibe-runtime-check/runtime-index-import-boundary-contracts.mjs +192 -0
  610. package/tools/vibe-runtime-check/runtime-optimization-boundary-contracts.mjs +49 -0
  611. package/tools/vibe-runtime-check/runtime-pure-model-boundary-contracts.mjs +176 -0
  612. package/tools/vibe-runtime-check/runtime-release-closeout-contracts.mjs +25 -0
  613. package/tools/vibe-runtime-check/runtime-roadmap-marker-specs.mjs +559 -0
  614. package/tools/vibe-runtime-check/runtime-source-bundle.mjs +119 -0
  615. package/tools/vibe-runtime-check/runtime-tool-readme-contracts.mjs +93 -0
  616. package/tools/vibe-runtime-check/runtime-tool-readme-marker-specs.mjs +952 -0
  617. package/tools/vibe-runtime-check/workflow-skill-contracts.mjs +129 -0
  618. package/tools/vibe-runtime-check/workflow-skill-route-registry-contracts.mjs +106 -0
  619. package/tools/vibe-runtime-check/workflow-ux-contracts.mjs +46 -0
@@ -0,0 +1,853 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { createRuntimeSubagentAdapterDispatchCommand } from './runtime-subagent-adapter-dispatch-command.mjs';
4
+ import { createSubagentBoundaryContracts } from './runtime-subagent-boundary-contracts.mjs';
5
+ import { buildControlledSubagentOrchestrationContract } from './runtime-controlled-subagent-orchestration-contract.mjs';
6
+ import { createSubagentEligibilityModel } from './runtime-subagents-eligibility-model.mjs';
7
+ import { createRuntimeSubagentsStageArtifactModel } from './runtime-subagents-stage-artifact-model.mjs';
8
+ import { createRuntimeSubagentsTailRouting } from './runtime-subagents-tail-routing-model.mjs';
9
+ import { createSubagentPlatformSessionProxies } from './runtime-subagents-platform-session-proxies.mjs';
10
+ import { createRuntimeSubagentsPresentation } from './runtime-subagents-presentation.mjs';
11
+
12
+ export const runtimeSubagentsCommandContractSync = {
13
+ runtime_check_owner: 'tools/vibe-runtime-check/index.mjs',
14
+ release_check_owner: 'tools/vibe-release-check',
15
+ };
16
+
17
+ export const createRuntimeSubagentsRiskArtifacts = function (deps) {
18
+ const {
19
+ jsonSchemaVersion,
20
+ stateDirectoryName,
21
+ subagentEligibilityDirectoryName,
22
+ subagentDispatchesDirectoryName,
23
+ subagentAdapterDispatchesDirectoryName,
24
+ schedulerRunsDirectoryName,
25
+ subagentRunLeasesDirectoryName,
26
+ subagentRunResultsDirectoryName,
27
+ subagentResultsDirectoryName,
28
+ subagentReviewsDirectoryName,
29
+ } = deps;
30
+ const {
31
+ ensureRoot,
32
+ workflowPath,
33
+ readWorkflow,
34
+ validateState,
35
+ tasksFromState,
36
+ asList,
37
+ validateTaskId,
38
+ fileDigest,
39
+ digestObject,
40
+ validateCommonArtifactSafety,
41
+ readJsonArtifact,
42
+ writeStateArtifact,
43
+ writeJsonEnvelope,
44
+ listStateFiles,
45
+ printList,
46
+ subagentEligibilityDirectory,
47
+ subagentDispatchesDirectory,
48
+ subagentAdapterDispatchesDirectory,
49
+ schedulerRunsDirectory,
50
+ subagentRunLeasesDirectory,
51
+ subagentRunResultsDirectory,
52
+ subagentResultsDirectory,
53
+ subagentReviewsDirectory,
54
+ subagentEligibilityFilePath,
55
+ subagentDispatchFilePath,
56
+ subagentAdapterDispatchFilePath,
57
+ subagentRunLeaseFilePath,
58
+ subagentRunResultFilePath,
59
+ subagentResultFilePath,
60
+ subagentReviewFilePath,
61
+ schedulerHookPlanFilePath,
62
+ validateSchedulerHookPlanArtifact,
63
+ safeStateArtifactFilePath,
64
+ orchestratorDispatchPlanFilePath,
65
+ validateOrchestratorArtifact,
66
+ platformCapabilityFilePath,
67
+ validatePlatformCapabilityArtifact,
68
+ getPlatformCommand,
69
+ } = deps;
70
+
71
+ const {
72
+ listPlatformSessionApprovalFiles, listPlatformSessionFiles, listPlatformSessionLeaseFiles, listPlatformSessionResultFiles, listPlatformSessionCancellationFiles, listPlatformSessionIntakeFiles, listPlatformSessionReviewFiles,
73
+ platformSessionApprovalSnapshotPath, platformSessionIntakeSnapshotPath, platformSessionReviewSnapshotPath, platformSessionApprovalsDirectory, platformSessionsDirectory, platformSessionLeasesDirectory, platformSessionResultsDirectory, platformSessionCancellationsDirectory, platformSessionIntakeDirectory, platformSessionReviewsDirectory,
74
+ platformSessionApprovalFilePath, platformSessionFilePath, platformSessionLeaseFilePath, platformSessionResultFilePath, platformSessionCancellationFilePath, platformSessionIntakeFilePath, platformSessionReviewFilePath,
75
+ platformSessionApprovalEnvelope, platformSessionEnvelope, platformSessionCancelEnvelope, platformSessionResultIntakeEnvelope, platformSessionReviewEnvelope,
76
+ validatePlatformSessionApprovalArtifact, validatePlatformSessionArtifact, validatePlatformSessionCancelArtifact, validatePlatformSessionIntakeArtifact, validatePlatformSessionReviewArtifact,
77
+ writePlatformSessionApproval, writePlatformSession, writePlatformSessionCancel, writePlatformSessionIntake, writePlatformSessionReview,
78
+ printPlatformSessionApproval, printPlatformSession, printPlatformSessionCancel, printPlatformSessionResultReview,
79
+ } = createSubagentPlatformSessionProxies(getPlatformCommand);
80
+
81
+ const {
82
+ printSubagentEligibility,
83
+ printSubagentEligibilityAudit,
84
+ printSubagentSingleShotRun,
85
+ printSubagentResultOrReview,
86
+ printSubagentDispatch,
87
+ } = createRuntimeSubagentsPresentation({ printList });
88
+
89
+ const {
90
+ subagentEligibilityGateIds,
91
+ subagentEligibilityRequiredEvidence,
92
+ subagentEligibilityForbiddenEvidence,
93
+ subagentEligibilityPlannedWrites,
94
+ subagentDispatchPlannedWrites,
95
+ stage35SubagentEligibilitySafety,
96
+ stage36SubagentDispatchSafety,
97
+ validateStage35SubagentEligibilitySafety,
98
+ } = createSubagentBoundaryContracts({
99
+ stateDirectoryName,
100
+ subagentEligibilityDirectoryName,
101
+ subagentDispatchesDirectoryName,
102
+ validateCommonArtifactSafety,
103
+ });
104
+
105
+ function controlledSubagentOrchestrationForEnvelope(envelope, phase) {
106
+ const detail = envelope.subagent_eligibility
107
+ || envelope.subagent_dispatch
108
+ || envelope.subagent_adapter_dispatch
109
+ || envelope.platform_session_approval
110
+ || envelope.subagent_scheduler_run
111
+ || envelope.subagent_run_result
112
+ || envelope.subagent_result
113
+ || envelope.subagent_review
114
+ || envelope.platform_session_review
115
+ || envelope.platform_session_intake
116
+ || {};
117
+ return buildControlledSubagentOrchestrationContract({
118
+ phase,
119
+ writeMode: envelope.safety?.writes === true ? 'explicit-confirm-sidecar-only' : 'none',
120
+ eligibilityGateBound: Boolean(envelope.subagent_eligibility),
121
+ dispatchArtifactBound: Boolean(envelope.subagent_dispatch),
122
+ adapterHandoffBound: Boolean(envelope.subagent_adapter_dispatch),
123
+ platformSessionApprovalBound: Boolean(envelope.platform_session_approval),
124
+ singleShotResultBound: Boolean(envelope.subagent_scheduler_run || envelope.subagent_run_result),
125
+ resultReviewGateBound: Boolean(envelope.subagent_result || envelope.subagent_review || envelope.platform_session_review || envelope.platform_session_intake),
126
+ artifactSummary: envelope.summary || {
127
+ mode: envelope.mode || '',
128
+ task_id: detail.task_id || '',
129
+ status: detail.dispatch_status || detail.approval_status || detail.run_status || detail.result_status || detail.ingest_status || detail.review_status || '',
130
+ writes: envelope.safety?.writes === true,
131
+ },
132
+ blockedReasons: envelope.quality || detail.blocked_reasons || [],
133
+ });
134
+ }
135
+
136
+ function withControlledSubagentOrchestration(envelope, phase) {
137
+ return {
138
+ ...envelope,
139
+ controlled_subagent_orchestration: controlledSubagentOrchestrationForEnvelope(envelope, phase),
140
+ };
141
+ }
142
+
143
+ const {
144
+ subagentEligibilityGateResults,
145
+ orchestratorDispatchTargetForTask,
146
+ subagentEligibilityBridgeGateResults,
147
+ subagentEligibilityBridgeEnvelope,
148
+ subagentEligibilityEnvelope,
149
+ validateSubagentEligibilityArtifact,
150
+ } = createSubagentEligibilityModel({
151
+ jsonSchemaVersion,
152
+ stateDirectoryName,
153
+ subagentEligibilityDirectoryName,
154
+ ensureRoot,
155
+ workflowPath,
156
+ readWorkflow,
157
+ validateState,
158
+ tasksFromState,
159
+ asList,
160
+ validateTaskId,
161
+ fileDigest,
162
+ digestObject,
163
+ readJsonArtifact,
164
+ orchestratorDispatchPlanFilePath,
165
+ validateOrchestratorArtifact,
166
+ subagentEligibilityGateIds,
167
+ subagentEligibilityRequiredEvidence,
168
+ subagentEligibilityForbiddenEvidence,
169
+ subagentEligibilityPlannedWrites,
170
+ stage35SubagentEligibilitySafety,
171
+ validateStage35SubagentEligibilitySafety,
172
+ });
173
+
174
+ function subagentEligibilitySnapshotPath(root) {
175
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
176
+ return path.join(subagentEligibilityDirectory(root), `${timestamp}.subagent-eligibility.json`);
177
+ }
178
+
179
+ function listSubagentEligibilityFiles(root) {
180
+ return listStateFiles(root, subagentEligibilityDirectory, '.subagent-eligibility.json');
181
+ }
182
+
183
+ function writeSubagentEligibility(root, envelope) {
184
+ const file = subagentEligibilitySnapshotPath(root);
185
+ const payload = { schema_version: jsonSchemaVersion, command: 'subagents', ...envelope, safety: { ...envelope.safety, subagent_eligibility_artifact: true } };
186
+ const verification = validateSubagentEligibilityArtifact(root, payload);
187
+ if (!verification.ok) throw new Error(`subagent eligibility verification failed: ${verification.failures.join('; ')}`);
188
+ return writeStateArtifact(path.dirname(file), path.basename(file), payload);
189
+ }
190
+
191
+ function subagentEligibilityAuditEnvelope(root, mode, eligibilityFile = '') {
192
+ if (mode === 'list') {
193
+ const eligibilities = listSubagentEligibilityFiles(root).map((fileName) => {
194
+ try {
195
+ const artifact = readJsonArtifact(path.join(subagentEligibilityDirectory(root), fileName), 'Subagent eligibility');
196
+ const verification = validateSubagentEligibilityArtifact(root, artifact);
197
+ return { file: fileName, task_id: artifact.subagent_eligibility?.task_id || '', eligible: artifact.subagent_eligibility?.eligible === true, verification_ok: verification.ok, verification_failures: verification.failures };
198
+ } catch (error) {
199
+ return { file: fileName, task_id: '', eligible: false, verification_ok: false, verification_failures: [error.message] };
200
+ }
201
+ });
202
+ return { mode: 'subagent-eligibility-list', ok: true, eligibilities, summary: { count: eligibilities.length, eligible_count: eligibilities.filter((item) => item.eligible).length, failed_count: eligibilities.filter((item) => !item.verification_ok).length }, quality: [], action: 'read-only subagent eligibility audit listed local gate artifacts. No subagent dispatch occurred.' };
203
+ }
204
+ const file = subagentEligibilityFilePath(root, eligibilityFile);
205
+ const artifact = readJsonArtifact(file, 'Subagent eligibility');
206
+ const verification = validateSubagentEligibilityArtifact(root, artifact);
207
+ if (mode === 'verify' && !verification.ok) throw new Error(`subagent eligibility verification failed: ${verification.failures.join('; ')}`);
208
+ return { mode: mode === 'verify' ? 'subagent-eligibility-verify' : 'subagent-eligibility-show', ok: verification.ok, summary: { file: path.basename(file), task_id: artifact.subagent_eligibility?.task_id || '', eligible: artifact.subagent_eligibility?.eligible === true }, verification, eligibility: artifact, quality: verification.failures, action: 'read-only subagent eligibility audit inspected one local gate artifact. No subagent dispatch occurred.' };
209
+ }
210
+
211
+ function subagentDispatchSnapshotPath(root) {
212
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
213
+ return path.join(subagentDispatchesDirectory(root), `${timestamp}.subagent-dispatch.json`);
214
+ }
215
+
216
+ function listSubagentDispatchFiles(root) {
217
+ return listStateFiles(root, subagentDispatchesDirectory, '.subagent-dispatch.json');
218
+ }
219
+
220
+ const {
221
+ subagentSchedulerRunSnapshotPath,
222
+ subagentRunLeaseSnapshotPath,
223
+ subagentRunResultSnapshotPath,
224
+ listSubagentSchedulerRunFiles,
225
+ listSubagentRunLeaseFiles,
226
+ listSubagentRunResultFiles,
227
+ subagentSingleShotRunEnvelope,
228
+ validateSubagentSingleShotRunArtifact,
229
+ subagentResultSnapshotPath,
230
+ subagentReviewSnapshotPath,
231
+ listSubagentResultFiles,
232
+ listSubagentReviewFiles,
233
+ subagentResultIngestionEnvelope,
234
+ validateSubagentResultArtifact,
235
+ subagentReviewGateEnvelope,
236
+ validateSubagentReviewArtifact,
237
+ } = createRuntimeSubagentsStageArtifactModel({
238
+ ...deps,
239
+ fs,
240
+ path,
241
+ validateSubagentDispatchArtifact,
242
+ });
243
+
244
+ function writeSubagentSingleShotRun(root, envelope) {
245
+ const runFile = subagentSchedulerRunSnapshotPath(root, envelope.files.scheduler_run.replace('.subagent-scheduler-run.json', ''));
246
+ const leaseFile = subagentRunLeaseSnapshotPath(root, envelope.files.lease.replace('.subagent-lease.json', ''));
247
+ const resultFile = subagentRunResultSnapshotPath(root, envelope.files.result.replace('.subagent-run-result.json', ''));
248
+ const payload = { schema_version: jsonSchemaVersion, command: 'subagents', ...envelope, safety: { ...envelope.safety, scheduler_run_artifact: true, subagent_lease_artifact: true, subagent_run_result_artifact: true } };
249
+ const verification = validateSubagentSingleShotRunArtifact(root, payload, path.basename(runFile));
250
+ if (!verification.ok) throw new Error(`subagent single-shot run verification failed: ${verification.failures.join('; ')}`);
251
+ writeStateArtifact(path.dirname(runFile), path.basename(runFile), payload);
252
+ writeStateArtifact(path.dirname(leaseFile), path.basename(leaseFile), payload);
253
+ writeStateArtifact(path.dirname(resultFile), path.basename(resultFile), payload);
254
+ return { runFile, leaseFile, resultFile };
255
+ }
256
+
257
+ function writeSubagentResult(root, envelope) {
258
+ const fileName = envelope.files?.subagent_result || path.basename(subagentResultSnapshotPath(root));
259
+ const file = subagentResultFilePath(root, fileName);
260
+ const payload = { schema_version: jsonSchemaVersion, command: 'subagents', ...envelope, safety: { ...envelope.safety, subagent_result_artifact: true } };
261
+ const verification = validateSubagentResultArtifact(root, payload, path.basename(file));
262
+ if (!verification.ok) throw new Error(`subagent result verification failed: ${verification.failures.join('; ')}`);
263
+ return writeStateArtifact(path.dirname(file), path.basename(file), payload);
264
+ }
265
+
266
+ function writeSubagentReview(root, envelope) {
267
+ const fileName = envelope.files?.subagent_review || path.basename(subagentReviewSnapshotPath(root));
268
+ const file = subagentReviewFilePath(root, fileName);
269
+ const payload = { schema_version: jsonSchemaVersion, command: 'subagents', ...envelope, safety: { ...envelope.safety, subagent_review_artifact: true } };
270
+ const verification = validateSubagentReviewArtifact(root, payload, path.basename(file));
271
+ if (!verification.ok) throw new Error(`subagent review verification failed: ${verification.failures.join('; ')}`);
272
+ return writeStateArtifact(path.dirname(file), path.basename(file), payload);
273
+ }
274
+
275
+ function subagentDispatchEnvelope(root, schedulerPlanFile, eligibilityFile, { persist = false, orchestratorDispatchPlanFile = '' } = {}) {
276
+ ensureRoot(root);
277
+ if (!eligibilityFile) throw new Error('subagents --dispatch requires --eligibility <eligibility-file>');
278
+ const hasOrchestratorBridge = Boolean(orchestratorDispatchPlanFile);
279
+ if (!schedulerPlanFile && !hasOrchestratorBridge) throw new Error('subagents --dispatch requires --from-plan <scheduler-hook-plan-file> or --from-orchestrator <orchestrator-dispatch-plan-file>');
280
+ let schedulerPlanPath = '';
281
+ let schedulerPlan = null;
282
+ let schedulerVerification = { ok: true, failures: [] };
283
+ let schedulerPlanDigest = '';
284
+ if (schedulerPlanFile) {
285
+ schedulerPlanPath = schedulerHookPlanFilePath(root, schedulerPlanFile);
286
+ schedulerPlan = readJsonArtifact(schedulerPlanPath, 'Scheduler hook plan');
287
+ schedulerVerification = validateSchedulerHookPlanArtifact(root, schedulerPlan);
288
+ if (!schedulerVerification.ok) throw new Error(`scheduler hook plan verification failed: ${schedulerVerification.failures.join('; ')}`);
289
+ schedulerPlanDigest = fileDigest(schedulerPlanPath);
290
+ }
291
+ let orchestratorDispatchPlanPath = '';
292
+ let orchestratorDispatchPlan = null;
293
+ let orchestratorVerification = { ok: true, failures: [] };
294
+ let orchestratorDispatchPlanDigest = '';
295
+ if (hasOrchestratorBridge) {
296
+ orchestratorDispatchPlanPath = orchestratorDispatchPlanFilePath(root, orchestratorDispatchPlanFile);
297
+ orchestratorDispatchPlan = readJsonArtifact(orchestratorDispatchPlanPath, 'Orchestrator dispatch plan');
298
+ orchestratorVerification = validateOrchestratorArtifact(root, orchestratorDispatchPlan, path.basename(orchestratorDispatchPlanPath));
299
+ if (!orchestratorVerification.ok) throw new Error(`orchestrator dispatch plan verification failed: ${orchestratorVerification.failures.join('; ')}`);
300
+ orchestratorDispatchPlanDigest = fileDigest(orchestratorDispatchPlanPath);
301
+ }
302
+ const eligibilityPath = subagentEligibilityFilePath(root, eligibilityFile);
303
+ const eligibility = readJsonArtifact(eligibilityPath, 'Subagent eligibility');
304
+ const eligibilityVerification = validateSubagentEligibilityArtifact(root, eligibility);
305
+ if (!eligibilityVerification.ok) throw new Error(`subagent eligibility verification failed: ${eligibilityVerification.failures.join('; ')}`);
306
+ if (eligibility.subagent_eligibility?.eligible !== true) throw new Error('subagent eligibility is not approved');
307
+ const eligibilityDigest = fileDigest(eligibilityPath);
308
+ const taskId = eligibility.subagent_eligibility.task_id;
309
+ if (hasOrchestratorBridge) {
310
+ const source = eligibility.subagent_eligibility?.source || {};
311
+ if (source.kind !== 'orchestrator-dispatch-plan') throw new Error('subagents --dispatch --from-orchestrator requires Stage 50 bridge eligibility');
312
+ if (source.file !== path.basename(orchestratorDispatchPlanPath)) throw new Error('subagent eligibility source does not match orchestrator dispatch plan');
313
+ const target = orchestratorDispatchTargetForTask(orchestratorDispatchPlan.orchestrator_dispatch_plan || {}, taskId);
314
+ if (!target) throw new Error('orchestrator dispatch plan does not contain eligibility task');
315
+ }
316
+ const dispatchCore = {
317
+ version: 1,
318
+ stage: 'Stage 36',
319
+ created_at: new Date().toISOString(),
320
+ writes: Boolean(persist),
321
+ dispatch_status: 'approved-dispatch-artifact-only',
322
+ task_id: taskId,
323
+ scheduler_hook_plan_file: schedulerPlanPath ? path.basename(schedulerPlanPath) : '',
324
+ scheduler_hook_plan_digest: schedulerPlanDigest,
325
+ scheduler_plan_id: schedulerPlan?.scheduler_hook_plan?.scheduler_plan_id || '',
326
+ orchestrator_dispatch_plan_file: orchestratorDispatchPlanPath ? path.basename(orchestratorDispatchPlanPath) : '',
327
+ orchestrator_dispatch_plan_digest: orchestratorDispatchPlanDigest,
328
+ orchestrator_dispatch_plan_artifact_digest: orchestratorDispatchPlan?.orchestrator_dispatch_plan?.dispatch_plan_digest || '',
329
+ eligibility_file: path.basename(eligibilityPath),
330
+ eligibility_digest: eligibilityDigest,
331
+ task_brief_digest: eligibility.subagent_eligibility?.task_digest || '',
332
+ workflow_digest: eligibility.subagent_eligibility?.workflow_sha256 || '',
333
+ methodology_gate_digest: digestObject(eligibility.subagent_eligibility?.gates || []),
334
+ scheduler_plan_digest: schedulerPlan?.scheduler_hook_plan?.plan_digest || '',
335
+ approval_policy_digest: digestObject({ required: ['scheduler-hook-plan-review', 'subagent-eligibility-review'], allowed_followup: ['dispatch-artifact-only'], approval_required: true }),
336
+ capability_matrix_digest: digestObject(eligibility.subagent_eligibility?.platform_capability || {}),
337
+ allowed_followup: ['claim-artifact-only'],
338
+ lease_required: true,
339
+ review_required: true,
340
+ no_session_create: true,
341
+ no_platform_api: true,
342
+ no_subagent_run: true,
343
+ no_scheduler_run: true,
344
+ no_git: true,
345
+ no_worktree: true,
346
+ planned_writes: subagentDispatchPlannedWrites(persist),
347
+ };
348
+ return {
349
+ mode: 'subagent-dispatch',
350
+ ok: true,
351
+ state_present: fs.existsSync(workflowPath(root)),
352
+ subagent_dispatch: { ...dispatchCore, dispatch_digest: digestObject(dispatchCore) },
353
+ scheduler_hook_plan: schedulerPlanPath ? { file: path.basename(schedulerPlanPath), digest: schedulerPlanDigest, verification: schedulerVerification } : null,
354
+ orchestrator_dispatch_plan: orchestratorDispatchPlanPath ? { file: path.basename(orchestratorDispatchPlanPath), digest: orchestratorDispatchPlanDigest, verification: orchestratorVerification } : null,
355
+ subagent_eligibility: { file: path.basename(eligibilityPath), digest: eligibilityDigest, verification: eligibilityVerification },
356
+ safety: stage36SubagentDispatchSafety(persist),
357
+ quality: [],
358
+ action: persist
359
+ ? 'approved subagent dispatch artifact was written. No subagent session, platform API, scheduler run, git, worktree, or business source write occurred.'
360
+ : 'approved subagent dispatch was previewed read-only. No files were written and no subagent session was created.',
361
+ };
362
+ }
363
+
364
+ function validateSubagentDispatchArtifact(root, artifact) {
365
+ const failures = [];
366
+ if (artifact.schema_version !== jsonSchemaVersion) failures.push('schema_version must be 1');
367
+ if (artifact.command !== 'subagents') failures.push('command must be subagents');
368
+ if (artifact.mode !== 'subagent-dispatch') failures.push('mode must be subagent-dispatch');
369
+ if (artifact.ok !== true) failures.push('subagent dispatch artifact ok must be true');
370
+ const dispatch = artifact.subagent_dispatch || {};
371
+ if (dispatch.version !== 1) failures.push('subagent_dispatch.version must be 1');
372
+ if (dispatch.stage !== 'Stage 36') failures.push('subagent_dispatch.stage must be Stage 36');
373
+ if (dispatch.writes !== true) failures.push('subagent_dispatch.writes must be true');
374
+ if (dispatch.dispatch_status !== 'approved-dispatch-artifact-only') failures.push('subagent_dispatch.dispatch_status must be approved-dispatch-artifact-only');
375
+ const usesSchedulerPlan = Boolean(dispatch.scheduler_hook_plan_file);
376
+ const usesOrchestratorBridge = Boolean(dispatch.orchestrator_dispatch_plan_file);
377
+ if (!dispatch.task_id) failures.push('subagent_dispatch.task_id is required');
378
+ if (!usesSchedulerPlan && !usesOrchestratorBridge) failures.push('subagent_dispatch requires scheduler hook plan or orchestrator dispatch plan source');
379
+ if (usesSchedulerPlan && !String(dispatch.scheduler_hook_plan_file).endsWith('.scheduler-hook-plan.json')) failures.push('subagent_dispatch.scheduler_hook_plan_file must be a scheduler hook plan artifact');
380
+ if (usesOrchestratorBridge && !String(dispatch.orchestrator_dispatch_plan_file).endsWith('.orchestrator-dispatch-plan.json')) failures.push('subagent_dispatch.orchestrator_dispatch_plan_file must be an orchestrator dispatch plan artifact');
381
+ if (!dispatch.eligibility_file || !String(dispatch.eligibility_file).endsWith('.subagent-eligibility.json')) failures.push('subagent_dispatch.eligibility_file must be a subagent eligibility artifact');
382
+ if (!Array.isArray(dispatch.allowed_followup) || digestObject(dispatch.allowed_followup) !== digestObject(['claim-artifact-only'])) failures.push('subagent_dispatch.allowed_followup must equal claim-artifact-only');
383
+ for (const key of ['lease_required', 'review_required', 'no_session_create', 'no_platform_api', 'no_subagent_run', 'no_scheduler_run', 'no_git', 'no_worktree']) {
384
+ if (dispatch[key] !== true) failures.push(`subagent_dispatch.${key} must be true`);
385
+ }
386
+ if (!Array.isArray(dispatch.planned_writes)) failures.push('subagent_dispatch.planned_writes must be an array');
387
+ else if (dispatch.writes === true && digestObject(dispatch.planned_writes) !== digestObject([path.join(stateDirectoryName, subagentDispatchesDirectoryName, '<timestamp>.subagent-dispatch.json').replace(/\\/g, '/')])) failures.push('subagent_dispatch.planned_writes must only contain subagent dispatch artifact');
388
+ const digestPayload = { ...dispatch };
389
+ delete digestPayload.dispatch_digest;
390
+ if (dispatch.dispatch_digest !== digestObject(digestPayload)) failures.push('subagent_dispatch digest mismatch');
391
+ if (root && usesSchedulerPlan) {
392
+ try {
393
+ const planPath = schedulerHookPlanFilePath(root, dispatch.scheduler_hook_plan_file);
394
+ if (fileDigest(planPath) !== dispatch.scheduler_hook_plan_digest) failures.push('subagent_dispatch scheduler hook plan digest mismatch');
395
+ const plan = readJsonArtifact(planPath, 'Scheduler hook plan');
396
+ const verification = validateSchedulerHookPlanArtifact(root, plan);
397
+ failures.push(...verification.failures.map((failure) => `scheduler hook plan: ${failure}`));
398
+ if ((plan.scheduler_hook_plan?.scheduler_plan_id || '') !== dispatch.scheduler_plan_id) failures.push('subagent_dispatch scheduler_plan_id mismatch');
399
+ if ((plan.scheduler_hook_plan?.plan_digest || '') !== dispatch.scheduler_plan_digest) failures.push('subagent_dispatch scheduler plan digest mismatch');
400
+ } catch (error) {
401
+ failures.push(error.message);
402
+ }
403
+ }
404
+ if (root && usesOrchestratorBridge) {
405
+ try {
406
+ const planPath = orchestratorDispatchPlanFilePath(root, dispatch.orchestrator_dispatch_plan_file);
407
+ if (fileDigest(planPath) !== dispatch.orchestrator_dispatch_plan_digest) failures.push('subagent_dispatch orchestrator dispatch plan digest mismatch');
408
+ const plan = readJsonArtifact(planPath, 'Orchestrator dispatch plan');
409
+ const verification = validateOrchestratorArtifact(root, plan, path.basename(planPath));
410
+ failures.push(...verification.failures.map((failure) => `orchestrator dispatch plan: ${failure}`));
411
+ if ((plan.orchestrator_dispatch_plan?.dispatch_plan_digest || '') !== dispatch.orchestrator_dispatch_plan_artifact_digest) failures.push('subagent_dispatch orchestrator dispatch plan artifact digest mismatch');
412
+ const target = orchestratorDispatchTargetForTask(plan.orchestrator_dispatch_plan || {}, dispatch.task_id);
413
+ if (!target) failures.push('subagent_dispatch task not found in orchestrator dispatch plan');
414
+ } catch (error) {
415
+ failures.push(error.message);
416
+ }
417
+ }
418
+ if (root && dispatch.eligibility_file) {
419
+ try {
420
+ const eligibilityPath = subagentEligibilityFilePath(root, dispatch.eligibility_file);
421
+ if (fileDigest(eligibilityPath) !== dispatch.eligibility_digest) failures.push('subagent_dispatch eligibility digest mismatch');
422
+ const eligibility = readJsonArtifact(eligibilityPath, 'Subagent eligibility');
423
+ const verification = validateSubagentEligibilityArtifact(root, eligibility);
424
+ failures.push(...verification.failures.map((failure) => `subagent eligibility: ${failure}`));
425
+ if (eligibility.subagent_eligibility?.eligible !== true) failures.push('subagent_dispatch eligibility must be approved');
426
+ const eligibilitySourceKind = eligibility.subagent_eligibility?.source?.kind || 'workflow-task';
427
+ if (usesOrchestratorBridge && eligibilitySourceKind !== 'orchestrator-dispatch-plan') failures.push('subagent_dispatch orchestrator bridge requires Stage 50 bridge eligibility');
428
+ if (!usesOrchestratorBridge && eligibilitySourceKind === 'orchestrator-dispatch-plan') failures.push('subagent_dispatch Stage 50 bridge eligibility requires orchestrator dispatch plan source');
429
+ if (usesOrchestratorBridge && eligibility.subagent_eligibility?.source?.file !== dispatch.orchestrator_dispatch_plan_file) failures.push('subagent_dispatch eligibility source file mismatch');
430
+ if ((eligibility.subagent_eligibility?.task_id || '') !== dispatch.task_id) failures.push('subagent_dispatch task_id mismatch');
431
+ if ((eligibility.subagent_eligibility?.task_digest || '') !== dispatch.task_brief_digest) failures.push('subagent_dispatch task brief digest mismatch');
432
+ if ((eligibility.subagent_eligibility?.workflow_sha256 || '') !== dispatch.workflow_digest) failures.push('subagent_dispatch workflow digest mismatch');
433
+ if (digestObject(eligibility.subagent_eligibility?.gates || []) !== dispatch.methodology_gate_digest) failures.push('subagent_dispatch methodology gate digest mismatch');
434
+ if (digestObject(eligibility.subagent_eligibility?.platform_capability || {}) !== dispatch.capability_matrix_digest) failures.push('subagent_dispatch capability matrix digest mismatch');
435
+ } catch (error) {
436
+ failures.push(error.message);
437
+ }
438
+ }
439
+ const expectedApprovalPolicyDigest = digestObject({ required: ['scheduler-hook-plan-review', 'subagent-eligibility-review'], allowed_followup: ['dispatch-artifact-only'], approval_required: true });
440
+ if (dispatch.approval_policy_digest !== expectedApprovalPolicyDigest) failures.push('subagent_dispatch approval policy digest mismatch');
441
+ failures.push(...validateCommonArtifactSafety(artifact.safety, 'Stage 36'));
442
+ if (artifact.safety?.writes !== true) failures.push('safety.writes must be true');
443
+ if (artifact.safety?.subagent_dispatch_artifact !== true) failures.push('safety.subagent_dispatch_artifact must be true');
444
+ for (const key of ['scheduler_plan', 'scheduler_run', 'session_create', 'subagent_dispatch', 'external_api', 'external_delivery', 'model_invocation', 'runtime_action', 'auto_execution', 'platform_api', 'skill_execution', 'business_source_write', 'subagent', 'mcp', 'daemon', 'git', 'worktree']) {
445
+ if (artifact.safety?.[key] !== false) failures.push(`safety.${key} must be false`);
446
+ }
447
+ return { ok: failures.length === 0, failures };
448
+ }
449
+
450
+ function writeSubagentDispatch(root, envelope) {
451
+ const file = subagentDispatchSnapshotPath(root);
452
+ const payload = { schema_version: jsonSchemaVersion, command: 'subagents', ...envelope, safety: { ...envelope.safety, subagent_dispatch_artifact: true } };
453
+ const verification = validateSubagentDispatchArtifact(root, payload);
454
+ if (!verification.ok) throw new Error(`subagent dispatch verification failed: ${verification.failures.join('; ')}`);
455
+ return writeStateArtifact(path.dirname(file), path.basename(file), payload);
456
+ }
457
+
458
+ const {
459
+ subagentAdapterDispatchSnapshotPath,
460
+ listSubagentAdapterDispatchFiles,
461
+ subagentAdapterDispatchEnvelope,
462
+ validateSubagentAdapterDispatchArtifact,
463
+ writeSubagentAdapterDispatch,
464
+ printSubagentAdapterDispatch,
465
+ } = createRuntimeSubagentAdapterDispatchCommand({
466
+ jsonSchemaVersion,
467
+ stateDirectoryName,
468
+ subagentAdapterDispatchesDirectoryName,
469
+ ensureRoot,
470
+ workflowPath,
471
+ fileDigest,
472
+ digestObject,
473
+ readJsonArtifact,
474
+ writeStateArtifact,
475
+ listStateFiles,
476
+ subagentAdapterDispatchesDirectory,
477
+ subagentAdapterDispatchFilePath,
478
+ subagentDispatchFilePath,
479
+ subagentEligibilityFilePath,
480
+ platformCapabilityFilePath,
481
+ validateSubagentDispatchArtifact,
482
+ validateSubagentEligibilityArtifact,
483
+ validatePlatformCapabilityArtifact,
484
+ });
485
+
486
+ function subagentAuditListEnvelope(root, mode, fileName) {
487
+ const eligibilityEnvelope = subagentEligibilityAuditEnvelope(root, mode, fileName);
488
+ const dispatches = listSubagentDispatchFiles(root).map((name) => {
489
+ try {
490
+ const artifact = readJsonArtifact(path.join(subagentDispatchesDirectory(root), name), 'Subagent dispatch');
491
+ const verification = validateSubagentDispatchArtifact(root, artifact);
492
+ return { file: name, task_id: artifact.subagent_dispatch?.task_id || '', eligible: true, verification_ok: verification.ok, verification_failures: verification.failures, kind: 'subagent-dispatch' };
493
+ } catch (error) {
494
+ return { file: name, task_id: '', eligible: false, verification_ok: false, verification_failures: [error.message], kind: 'subagent-dispatch' };
495
+ }
496
+ });
497
+ const adapterDispatches = listSubagentAdapterDispatchFiles(root).map((name) => {
498
+ try {
499
+ const artifact = readJsonArtifact(path.join(subagentAdapterDispatchesDirectory(root), name), 'Subagent adapter dispatch');
500
+ const verification = validateSubagentAdapterDispatchArtifact(root, artifact, name);
501
+ return { file: name, task_id: artifact.subagent_adapter_dispatch?.task_id || '', eligible: true, verification_ok: verification.ok, verification_failures: verification.failures, kind: 'subagent-adapter-dispatch' };
502
+ } catch (error) {
503
+ return { file: name, task_id: '', eligible: false, verification_ok: false, verification_failures: [error.message], kind: 'subagent-adapter-dispatch' };
504
+ }
505
+ });
506
+ const singleShotFiles = [
507
+ ...listSubagentSchedulerRunFiles(root).map((name) => ['subagent-scheduler-run', name, schedulerRunsDirectory(root)]),
508
+ ...listSubagentRunLeaseFiles(root).map((name) => ['subagent-run-lease', name, subagentRunLeasesDirectory(root)]),
509
+ ...listSubagentRunResultFiles(root).map((name) => ['subagent-run-result', name, subagentRunResultsDirectory(root)]),
510
+ ].map(([kind, name, directory]) => {
511
+ try {
512
+ const artifact = readJsonArtifact(path.join(directory, name), kind);
513
+ const verification = validateSubagentSingleShotRunArtifact(root, artifact, name);
514
+ return { file: name, task_id: artifact.subagent_scheduler_run?.task_id || '', eligible: true, verification_ok: verification.ok, verification_failures: verification.failures, kind };
515
+ } catch (error) {
516
+ return { file: name, task_id: '', eligible: false, verification_ok: false, verification_failures: [error.message], kind };
517
+ }
518
+ });
519
+ const stage38Files = [
520
+ ...listSubagentResultFiles(root).map((name) => ['subagent-result', name, subagentResultsDirectory(root), validateSubagentResultArtifact]),
521
+ ...listSubagentReviewFiles(root).map((name) => ['subagent-review', name, subagentReviewsDirectory(root), validateSubagentReviewArtifact]),
522
+ ].map(([kind, name, directory, verifier]) => {
523
+ try {
524
+ const artifact = readJsonArtifact(path.join(directory, name), kind);
525
+ const verification = verifier(root, artifact, name);
526
+ const detail = artifact.subagent_result || artifact.subagent_review || {};
527
+ return { file: name, task_id: detail.task_id || '', eligible: true, verification_ok: verification.ok, verification_failures: verification.failures, kind };
528
+ } catch (error) {
529
+ return { file: name, task_id: '', eligible: false, verification_ok: false, verification_failures: [error.message], kind };
530
+ }
531
+ });
532
+ const sessionApprovals = listPlatformSessionApprovalFiles(root).map((name) => {
533
+ try {
534
+ const artifact = readJsonArtifact(path.join(platformSessionApprovalsDirectory(root), name), 'Platform session approval');
535
+ const verification = validatePlatformSessionApprovalArtifact(root, artifact, name);
536
+ return { file: name, task_id: artifact.platform_session_approval?.task_id || '', eligible: true, verification_ok: verification.ok, verification_failures: verification.failures, kind: 'platform-session-approval' };
537
+ } catch (error) {
538
+ return { file: name, task_id: '', eligible: false, verification_ok: false, verification_failures: [error.message], kind: 'platform-session-approval' };
539
+ }
540
+ });
541
+ const sessionRuntimeFiles = [
542
+ ...listPlatformSessionFiles(root).map((name) => ['platform-session', name, platformSessionsDirectory(root)]),
543
+ ...listPlatformSessionLeaseFiles(root).map((name) => ['platform-session-lease', name, platformSessionLeasesDirectory(root)]),
544
+ ...listPlatformSessionResultFiles(root).map((name) => ['platform-session-result', name, platformSessionResultsDirectory(root)]),
545
+ ].map(([kind, name, directory]) => {
546
+ try {
547
+ const artifact = readJsonArtifact(path.join(directory, name), kind);
548
+ const verification = validatePlatformSessionArtifact(root, artifact, name);
549
+ return { file: name, task_id: artifact.platform_session?.approval_file || '', eligible: true, verification_ok: verification.ok, verification_failures: verification.failures, kind };
550
+ } catch (error) {
551
+ return { file: name, task_id: '', eligible: false, verification_ok: false, verification_failures: [error.message], kind };
552
+ }
553
+ });
554
+ const sessionCancelFiles = listPlatformSessionCancellationFiles(root).map((name) => {
555
+ try {
556
+ const artifact = readJsonArtifact(path.join(platformSessionCancellationsDirectory(root), name), 'Platform session cancellation');
557
+ const verification = validatePlatformSessionCancelArtifact(root, artifact, name);
558
+ return { file: name, task_id: artifact.platform_session_cancel?.session_file || '', eligible: true, verification_ok: verification.ok, verification_failures: verification.failures, kind: 'platform-session-cancel' };
559
+ } catch (error) {
560
+ return { file: name, task_id: '', eligible: false, verification_ok: false, verification_failures: [error.message], kind: 'platform-session-cancel' };
561
+ }
562
+ });
563
+ const sessionReviewFiles = [
564
+ ...listPlatformSessionIntakeFiles(root).map((name) => ['platform-session-intake', name, platformSessionIntakeDirectory(root), validatePlatformSessionIntakeArtifact]),
565
+ ...listPlatformSessionReviewFiles(root).map((name) => ['platform-session-review', name, platformSessionReviewsDirectory(root), validatePlatformSessionReviewArtifact]),
566
+ ].map(([kind, name, directory, verifier]) => {
567
+ try {
568
+ const artifact = readJsonArtifact(path.join(directory, name), kind);
569
+ const verification = verifier(root, artifact, name);
570
+ const detail = artifact.platform_session_intake || artifact.platform_session_review || {};
571
+ return { file: name, task_id: detail.session_file || '', eligible: true, verification_ok: verification.ok, verification_failures: verification.failures, kind };
572
+ } catch (error) {
573
+ return { file: name, task_id: '', eligible: false, verification_ok: false, verification_failures: [error.message], kind };
574
+ }
575
+ });
576
+ const eligibilities = eligibilityEnvelope.eligibilities.map((item) => ({ ...item, kind: 'subagent-eligibility' }));
577
+ const all = [...eligibilities, ...dispatches, ...adapterDispatches, ...singleShotFiles, ...stage38Files, ...sessionApprovals, ...sessionRuntimeFiles, ...sessionCancelFiles, ...sessionReviewFiles];
578
+ return { mode: 'subagent-artifact-list', ok: true, eligibilities: all, summary: { count: all.length, eligible_count: eligibilities.filter((item) => item.eligible).length, dispatch_count: dispatches.length, adapter_dispatch_count: adapterDispatches.length, run_artifact_count: singleShotFiles.length, result_artifact_count: stage38Files.length, session_approval_count: sessionApprovals.length, platform_session_count: sessionRuntimeFiles.length, platform_session_cancel_count: sessionCancelFiles.length, platform_session_review_count: sessionReviewFiles.length, failed_count: all.filter((item) => !item.verification_ok).length }, quality: [], action: 'read-only subagent audit listed eligibility, dispatch, adapter dispatch, single-shot run, result, review, session approval, platform session, session cancellation, and session review artifacts. No subagent dispatch occurred.' };
579
+ }
580
+
581
+ function subagentAuditEnvelope(root, mode, fileName = '') {
582
+ if (mode === 'list') {
583
+ return subagentAuditListEnvelope(root, mode, fileName);
584
+ }
585
+ if (fileName.endsWith('.platform-session-intake.json') || fileName.endsWith('.platform-session-review.json')) {
586
+ const isIntake = fileName.endsWith('.platform-session-intake.json');
587
+ const file = isIntake ? platformSessionIntakeFilePath(root, fileName) : platformSessionReviewFilePath(root, fileName);
588
+ const artifact = readJsonArtifact(file, 'Platform session review');
589
+ const verification = isIntake ? validatePlatformSessionIntakeArtifact(root, artifact, path.basename(file)) : validatePlatformSessionReviewArtifact(root, artifact, path.basename(file));
590
+ if (mode === 'verify' && !verification.ok) throw new Error(`platform session review verification failed: ${verification.failures.join('; ')}`);
591
+ const verifyMode = isIntake ? 'platform-session-intake-verify' : 'platform-session-review-verify';
592
+ const showMode = isIntake ? 'platform-session-intake-show' : 'platform-session-review-show';
593
+ return { mode: mode === 'verify' ? verifyMode : showMode, ok: verification.ok, summary: { file: path.basename(file), status: artifact.platform_session_intake?.intake_status || artifact.platform_session_review?.review_status || '' }, verification, review: artifact, quality: verification.failures, action: 'read-only platform session review audit inspected one local review artifact. No source was written.' };
594
+ }
595
+ if (fileName.endsWith('.platform-session-cancel.json')) {
596
+ const file = platformSessionCancellationFilePath(root, fileName);
597
+ const artifact = readJsonArtifact(file, 'Platform session cancellation');
598
+ const verification = validatePlatformSessionCancelArtifact(root, artifact, path.basename(file));
599
+ if (mode === 'verify' && !verification.ok) throw new Error(`platform session cancel verification failed: ${verification.failures.join('; ')}`);
600
+ return { mode: mode === 'verify' ? 'platform-session-cancel-verify' : 'platform-session-cancel-show', ok: verification.ok, summary: { file: path.basename(file), session_id: artifact.platform_session_cancel?.session_id || '', cancel_status: artifact.platform_session_cancel?.cancel_status || '' }, verification, cancellation: artifact, quality: verification.failures, action: 'read-only platform session cancellation audit inspected one local cancellation artifact. No source was written.' };
601
+ }
602
+ if (fileName.endsWith('.platform-session.json') || fileName.endsWith('.platform-session-lease.json') || fileName.endsWith('.platform-session-result.json')) {
603
+ const file = fileName.endsWith('.platform-session.json') ? platformSessionFilePath(root, fileName)
604
+ : fileName.endsWith('.platform-session-lease.json') ? platformSessionLeaseFilePath(root, fileName)
605
+ : platformSessionResultFilePath(root, fileName);
606
+ const artifact = readJsonArtifact(file, 'Platform session');
607
+ const verification = validatePlatformSessionArtifact(root, artifact, path.basename(file));
608
+ if (mode === 'verify' && !verification.ok) throw new Error(`platform session verification failed: ${verification.failures.join('; ')}`);
609
+ return { mode: mode === 'verify' ? 'platform-session-verify' : 'platform-session-show', ok: verification.ok, summary: { file: path.basename(file), session_id: artifact.platform_session?.session_id || '', session_status: artifact.platform_session?.session_status || '' }, verification, session: artifact, quality: verification.failures, action: 'read-only platform session audit inspected one local session artifact. No source was written.' };
610
+ }
611
+ if (fileName.endsWith('.platform-session-approval.json')) {
612
+ const file = platformSessionApprovalFilePath(root, fileName);
613
+ const artifact = readJsonArtifact(file, 'Platform session approval');
614
+ const verification = validatePlatformSessionApprovalArtifact(root, artifact, path.basename(file));
615
+ if (mode === 'verify' && !verification.ok) throw new Error(`platform session approval verification failed: ${verification.failures.join('; ')}`);
616
+ return { mode: mode === 'verify' ? 'platform-session-approval-verify' : 'platform-session-approval-show', ok: verification.ok, summary: { file: path.basename(file), task_id: artifact.platform_session_approval?.task_id || '', platform: artifact.platform_session_approval?.platform || '', approval_status: artifact.platform_session_approval?.approval_status || '' }, verification, approval: artifact, quality: verification.failures, action: 'read-only platform session approval audit inspected one local approval artifact. No session was created.' };
617
+ }
618
+ if (fileName.endsWith('.subagent-result.json')) {
619
+ const file = subagentResultFilePath(root, fileName);
620
+ const artifact = readJsonArtifact(file, 'Subagent result');
621
+ const verification = validateSubagentResultArtifact(root, artifact, path.basename(file));
622
+ if (mode === 'verify' && !verification.ok) throw new Error(`subagent result verification failed: ${verification.failures.join('; ')}`);
623
+ return { mode: mode === 'verify' ? 'subagent-result-verify' : 'subagent-result-show', ok: verification.ok, summary: { file: path.basename(file), task_id: artifact.subagent_result?.task_id || '', ingest_status: artifact.subagent_result?.ingest_status || '' }, verification, result: artifact, quality: verification.failures, action: 'read-only subagent result audit inspected one local result artifact. No result was merged.' };
624
+ }
625
+ if (fileName.endsWith('.subagent-review.json')) {
626
+ const file = subagentReviewFilePath(root, fileName);
627
+ const artifact = readJsonArtifact(file, 'Subagent review');
628
+ const verification = validateSubagentReviewArtifact(root, artifact, path.basename(file));
629
+ if (mode === 'verify' && !verification.ok) throw new Error(`subagent review verification failed: ${verification.failures.join('; ')}`);
630
+ return { mode: mode === 'verify' ? 'subagent-review-verify' : 'subagent-review-show', ok: verification.ok, summary: { file: path.basename(file), task_id: artifact.subagent_review?.task_id || '', review_status: artifact.subagent_review?.review_status || '' }, verification, review: artifact, quality: verification.failures, action: 'read-only subagent review audit inspected one local review gate artifact. No result was merged.' };
631
+ }
632
+ if (fileName.endsWith('.subagent-scheduler-run.json') || fileName.endsWith('.subagent-lease.json') || fileName.endsWith('.subagent-run-result.json')) {
633
+ const file = fileName.endsWith('.subagent-scheduler-run.json') ? safeStateArtifactFilePath(root, schedulerRunsDirectory, fileName, '.subagent-scheduler-run.json', 'Subagent scheduler run')
634
+ : fileName.endsWith('.subagent-lease.json') ? subagentRunLeaseFilePath(root, fileName)
635
+ : subagentRunResultFilePath(root, fileName);
636
+ const artifact = readJsonArtifact(file, 'Subagent single-shot run');
637
+ const verification = validateSubagentSingleShotRunArtifact(root, artifact, path.basename(file));
638
+ if (mode === 'verify' && !verification.ok) throw new Error(`subagent single-shot run verification failed: ${verification.failures.join('; ')}`);
639
+ return { mode: mode === 'verify' ? 'subagent-single-shot-run-verify' : 'subagent-single-shot-run-show', ok: verification.ok, summary: { file: path.basename(file), task_id: artifact.subagent_scheduler_run?.task_id || '', run_status: artifact.subagent_scheduler_run?.run_status || '' }, verification, run: artifact, quality: verification.failures, action: 'read-only subagent single-shot run audit inspected one local run artifact. No subagent session was created.' };
640
+ }
641
+ if (fileName.endsWith('.subagent-adapter-dispatch.json')) {
642
+ const file = subagentAdapterDispatchFilePath(root, fileName);
643
+ const artifact = readJsonArtifact(file, 'Subagent adapter dispatch');
644
+ const verification = validateSubagentAdapterDispatchArtifact(root, artifact, path.basename(file));
645
+ if (mode === 'verify' && !verification.ok) throw new Error(`subagent adapter dispatch verification failed: ${verification.failures.join('; ')}`);
646
+ return { mode: mode === 'verify' ? 'subagent-adapter-dispatch-verify' : 'subagent-adapter-dispatch-show', ok: verification.ok, summary: { file: path.basename(file), task_id: artifact.subagent_adapter_dispatch?.task_id || '', dispatch_status: artifact.subagent_adapter_dispatch?.dispatch_status || '' }, verification, adapter_dispatch: artifact, quality: verification.failures, action: 'read-only subagent adapter dispatch audit inspected one local adapter handoff artifact. No adapter or subagent session was created.' };
647
+ }
648
+ if (fileName.endsWith('.subagent-dispatch.json')) {
649
+ const file = subagentDispatchFilePath(root, fileName);
650
+ const artifact = readJsonArtifact(file, 'Subagent dispatch');
651
+ const verification = validateSubagentDispatchArtifact(root, artifact);
652
+ if (mode === 'verify' && !verification.ok) throw new Error(`subagent dispatch verification failed: ${verification.failures.join('; ')}`);
653
+ return { mode: mode === 'verify' ? 'subagent-dispatch-verify' : 'subagent-dispatch-show', ok: verification.ok, summary: { file: path.basename(file), task_id: artifact.subagent_dispatch?.task_id || '', dispatch_status: artifact.subagent_dispatch?.dispatch_status || '' }, verification, dispatch: artifact, quality: verification.failures, action: 'read-only subagent dispatch audit inspected one local dispatch artifact. No subagent session was created.' };
654
+ }
655
+ return subagentEligibilityAuditEnvelope(root, mode, fileName);
656
+ }
657
+
658
+ function runPlatformSessionSubagentsMode(options) {
659
+ if (options.cancelSession) {
660
+ if (!options.confirm) throw new Error('subagents --cancel-session requires --confirm');
661
+ const envelope = withControlledSubagentOrchestration(platformSessionCancelEnvelope(options.root, options.subagentsFile, { persist: true }), 'platform-session-cancel-gate');
662
+ const file = writePlatformSessionCancel(options.root, envelope);
663
+ if (options.json) writeJsonEnvelope('subagents', { ...envelope, platform_session_cancel_file: path.basename(file) });
664
+ else printPlatformSessionCancel(envelope, file);
665
+ return true;
666
+ }
667
+ if (options.createSession) {
668
+ if (!options.confirm) throw new Error('subagents --create-session requires --confirm');
669
+ if (options.run || options.subagentsDispatch || options.subagentsAdapterDispatch || options.subagentsEligibility || options.subagentsIngestResult || options.subagentsReviewGate || options.sessionApproval) throw new Error('subagents --create-session cannot be combined with other subagent write modes');
670
+ const envelope = withControlledSubagentOrchestration(platformSessionEnvelope(options.root, options.fromApproval, { persist: true }), 'platform-session-sidecar-gate');
671
+ const files = writePlatformSession(options.root, envelope);
672
+ if (options.json) writeJsonEnvelope('subagents', { ...envelope, platform_session_file: path.basename(files.sessionFile), platform_session_lease_file: path.basename(files.leaseFile), platform_session_result_file: path.basename(files.resultFile) });
673
+ else printPlatformSession(envelope, files);
674
+ return true;
675
+ }
676
+ if (options.sessionResultIngest) {
677
+ if (options.run || options.subagentsDispatch || options.subagentsAdapterDispatch || options.subagentsEligibility || options.subagentsIngestResult || options.subagentsReviewGate || options.sessionResultReview || options.sessionApproval || options.createSession || options.cancelSession) throw new Error('subagents --ingest-session-result cannot be combined with other subagent write modes');
678
+ const intakeArtifactFile = options.confirm ? path.basename(platformSessionIntakeSnapshotPath(options.root)) : '';
679
+ const envelope = withControlledSubagentOrchestration(platformSessionResultIntakeEnvelope(options.root, options.subagentsResultFile, { persist: options.confirm, artifactFile: intakeArtifactFile }), 'platform-session-result-intake-gate');
680
+ if (options.confirm) {
681
+ const file = writePlatformSessionIntake(options.root, envelope);
682
+ if (options.json) writeJsonEnvelope('subagents', { ...envelope, platform_session_intake_file: path.basename(file) });
683
+ else printPlatformSessionResultReview(envelope, file);
684
+ return true;
685
+ }
686
+ if (options.json) writeJsonEnvelope('subagents', envelope);
687
+ else printPlatformSessionResultReview(envelope);
688
+ return true;
689
+ }
690
+ if (options.sessionResultReview) {
691
+ if (options.run || options.subagentsDispatch || options.subagentsAdapterDispatch || options.subagentsEligibility || options.subagentsIngestResult || options.subagentsReviewGate || options.sessionResultIngest || options.sessionApproval || options.createSession || options.cancelSession) throw new Error('subagents --review-session-result cannot be combined with other subagent write modes');
692
+ const reviewArtifactFile = options.confirm ? path.basename(platformSessionReviewSnapshotPath(options.root)) : '';
693
+ const envelope = withControlledSubagentOrchestration(platformSessionReviewEnvelope(options.root, options.subagentsResultFile, { persist: options.confirm, artifactFile: reviewArtifactFile }), 'platform-session-review-gate');
694
+ if (options.confirm) {
695
+ const file = writePlatformSessionReview(options.root, envelope);
696
+ if (options.json) writeJsonEnvelope('subagents', { ...envelope, platform_session_review_file: path.basename(file) });
697
+ else printPlatformSessionResultReview(envelope, file);
698
+ return true;
699
+ }
700
+ if (options.json) writeJsonEnvelope('subagents', envelope);
701
+ else printPlatformSessionResultReview(envelope);
702
+ return true;
703
+ }
704
+ if (options.sessionApproval) {
705
+ if (options.run || options.subagentsDispatch || options.subagentsAdapterDispatch || options.subagentsEligibility || options.subagentsIngestResult || options.subagentsReviewGate) throw new Error('subagents --session-approval cannot be combined with other subagent write modes');
706
+ const approvalArtifactFile = options.confirm ? path.basename(platformSessionApprovalSnapshotPath(options.root)) : '';
707
+ const envelope = withControlledSubagentOrchestration(platformSessionApprovalEnvelope(options.root, options.fromDispatch, options.capabilityFile, { persist: options.confirm, artifactFile: approvalArtifactFile }), 'platform-session-approval-gate');
708
+ if (options.confirm) {
709
+ const file = writePlatformSessionApproval(options.root, envelope);
710
+ if (options.json) writeJsonEnvelope('subagents', { ...envelope, platform_session_approval_file: path.basename(file) });
711
+ else printPlatformSessionApproval(envelope, file);
712
+ return true;
713
+ }
714
+ if (options.json) writeJsonEnvelope('subagents', envelope);
715
+ else printPlatformSessionApproval(envelope);
716
+ return true;
717
+ }
718
+ return false;
719
+ }
720
+
721
+ function emitSubagentArtifactEnvelope(options, envelope, writeConfirmed, printEnvelope, fileKey) {
722
+ if (options.confirm) {
723
+ const file = writeConfirmed();
724
+ if (options.json) writeJsonEnvelope('subagents', { ...envelope, [fileKey]: path.basename(file) });
725
+ else printEnvelope(envelope, file);
726
+ return true;
727
+ }
728
+ if (options.json) writeJsonEnvelope('subagents', envelope);
729
+ else printEnvelope(envelope);
730
+ return true;
731
+ }
732
+ function runSubagentAdapterDispatchMode(options) {
733
+ if (!options.subagentsAdapterDispatch) return false;
734
+ if (options.run || options.subagentsDispatch || options.subagentsEligibility || options.subagentsIngestResult || options.subagentsReviewGate || options.sessionApproval || options.createSession || options.cancelSession) throw new Error('subagents --adapter-dispatch cannot be combined with other subagent write modes');
735
+ const adapterArtifactFile = options.confirm ? path.basename(subagentAdapterDispatchSnapshotPath(options.root)) : '';
736
+ const envelope = withControlledSubagentOrchestration(subagentAdapterDispatchEnvelope(options.root, options.fromDispatch, options.capabilityFile, { persist: options.confirm, artifactFile: adapterArtifactFile }), 'adapter-handoff-gate');
737
+ return emitSubagentArtifactEnvelope(options, envelope, () => writeSubagentAdapterDispatch(options.root, envelope), printSubagentAdapterDispatch, 'subagent_adapter_dispatch_file');
738
+ }
739
+ function runSubagentResultIngestMode(options) {
740
+ if (!options.subagentsIngestResult) return false;
741
+ if (options.run || options.subagentsDispatch || options.subagentsAdapterDispatch || options.subagentsEligibility || options.subagentsReviewGate) throw new Error('subagents --ingest-result cannot be combined with other subagent write modes');
742
+ const resultArtifactFile = options.confirm ? path.basename(subagentResultSnapshotPath(options.root)) : '';
743
+ const envelope = withControlledSubagentOrchestration(subagentResultIngestionEnvelope(options.root, options.subagentsResultFile, { persist: options.confirm, artifactFile: resultArtifactFile }), 'result-ingestion-gate');
744
+ return emitSubagentArtifactEnvelope(options, envelope, () => writeSubagentResult(options.root, envelope), printSubagentResultOrReview, 'subagent_result_file');
745
+ }
746
+ function runSubagentReviewGateMode(options) {
747
+ if (!options.subagentsReviewGate) return false;
748
+ if (options.run || options.subagentsDispatch || options.subagentsAdapterDispatch || options.subagentsEligibility || options.subagentsIngestResult) throw new Error('subagents --review-gate cannot be combined with other subagent write modes');
749
+ const reviewArtifactFile = options.confirm ? path.basename(subagentReviewSnapshotPath(options.root)) : '';
750
+ const envelope = withControlledSubagentOrchestration(subagentReviewGateEnvelope(options.root, options.subagentsResultFile, { persist: options.confirm, artifactFile: reviewArtifactFile }), 'result-review-gate');
751
+ return emitSubagentArtifactEnvelope(options, envelope, () => writeSubagentReview(options.root, envelope), printSubagentResultOrReview, 'subagent_review_file');
752
+ }
753
+ function runSubagentSingleShotMode(options) {
754
+ if (!options.run) return false;
755
+ if (!options.fromDispatch) throw new Error('subagents --run requires --from-dispatch <subagent-dispatch-file>');
756
+ if (!options.confirm) throw new Error('subagents --run requires --confirm');
757
+ const envelope = withControlledSubagentOrchestration(subagentSingleShotRunEnvelope(options.root, options.fromDispatch, { persist: true }), 'single-shot-result-recording');
758
+ const files = writeSubagentSingleShotRun(options.root, envelope);
759
+ if (options.json) writeJsonEnvelope('subagents', { ...envelope, subagent_scheduler_run_file: path.basename(files.runFile), subagent_lease_file: path.basename(files.leaseFile), subagent_run_result_file: path.basename(files.resultFile) });
760
+ else printSubagentSingleShotRun(envelope, files);
761
+ return true;
762
+ }
763
+ function runSubagentDispatchArtifactMode(options) {
764
+ if (!options.subagentsDispatch) return false;
765
+ if (!options.confirm) throw new Error('subagents --dispatch requires --confirm');
766
+ const envelope = withControlledSubagentOrchestration(subagentDispatchEnvelope(options.root, options.schedulerPlanFile, options.subagentsEligibilityFile, { persist: true, orchestratorDispatchPlanFile: options.subagentsFromOrchestrator ? options.orchestratorFile : '' }), 'dispatch-artifact-gate');
767
+ const file = writeSubagentDispatch(options.root, envelope);
768
+ if (options.json) writeJsonEnvelope('subagents', { ...envelope, subagent_dispatch_file: path.basename(file) });
769
+ else printSubagentDispatch(envelope, file);
770
+ return true;
771
+ }
772
+ function runSubagentArtifactMode(options) {
773
+ return runSubagentAdapterDispatchMode(options) || runSubagentResultIngestMode(options) || runSubagentReviewGateMode(options) || runSubagentSingleShotMode(options) || runSubagentDispatchArtifactMode(options);
774
+ }
775
+ const controlledSubagentEligibilityBridgeEnvelope = (...args) => withControlledSubagentOrchestration(
776
+ subagentEligibilityBridgeEnvelope(...args),
777
+ 'orchestrator-eligibility-gate',
778
+ );
779
+ const controlledSubagentEligibilityEnvelope = (...args) => withControlledSubagentOrchestration(
780
+ subagentEligibilityEnvelope(...args),
781
+ 'eligibility-gate',
782
+ );
783
+ const controlledSubagentAuditEnvelope = (...args) => withControlledSubagentOrchestration(
784
+ subagentAuditEnvelope(...args),
785
+ 'artifact-audit',
786
+ );
787
+
788
+ const { runSubagents } = createRuntimeSubagentsTailRouting({
789
+ path,
790
+ writeJsonEnvelope,
791
+ subagentEligibilityBridgeEnvelope: controlledSubagentEligibilityBridgeEnvelope,
792
+ subagentEligibilityEnvelope: controlledSubagentEligibilityEnvelope,
793
+ writeSubagentEligibility,
794
+ printSubagentEligibility,
795
+ subagentAuditEnvelope: controlledSubagentAuditEnvelope,
796
+ printSubagentEligibilityAudit,
797
+ runPlatformSessionSubagentsMode,
798
+ runSubagentArtifactMode,
799
+ });
800
+
801
+ return {
802
+ subagentEligibilityGateIds,
803
+ subagentEligibilityRequiredEvidence,
804
+ subagentEligibilityForbiddenEvidence,
805
+ subagentEligibilitySnapshotPath,
806
+ listSubagentEligibilityFiles,
807
+ subagentEligibilityGateResults,
808
+ orchestratorDispatchTargetForTask,
809
+ subagentEligibilityBridgeGateResults,
810
+ subagentEligibilityBridgeEnvelope: controlledSubagentEligibilityBridgeEnvelope,
811
+ subagentEligibilityEnvelope: controlledSubagentEligibilityEnvelope,
812
+ validateSubagentEligibilityArtifact,
813
+ writeSubagentEligibility,
814
+ subagentEligibilityAuditEnvelope: controlledSubagentAuditEnvelope,
815
+ printSubagentEligibility,
816
+ printSubagentEligibilityAudit,
817
+ subagentDispatchSnapshotPath,
818
+ listSubagentDispatchFiles,
819
+ subagentSchedulerRunSnapshotPath,
820
+ subagentRunLeaseSnapshotPath,
821
+ subagentRunResultSnapshotPath,
822
+ listSubagentSchedulerRunFiles,
823
+ listSubagentRunLeaseFiles,
824
+ listSubagentRunResultFiles,
825
+ subagentSingleShotRunEnvelope,
826
+ validateSubagentSingleShotRunArtifact,
827
+ writeSubagentSingleShotRun,
828
+ printSubagentSingleShotRun,
829
+ subagentResultSnapshotPath,
830
+ subagentReviewSnapshotPath,
831
+ listSubagentResultFiles,
832
+ listSubagentReviewFiles,
833
+ subagentResultIngestionEnvelope,
834
+ validateSubagentResultArtifact,
835
+ writeSubagentResult,
836
+ subagentReviewGateEnvelope,
837
+ validateSubagentReviewArtifact,
838
+ writeSubagentReview,
839
+ printSubagentResultOrReview,
840
+ subagentDispatchEnvelope,
841
+ validateSubagentDispatchArtifact,
842
+ writeSubagentDispatch,
843
+ printSubagentDispatch,
844
+ subagentAdapterDispatchSnapshotPath,
845
+ listSubagentAdapterDispatchFiles,
846
+ subagentAdapterDispatchEnvelope,
847
+ validateSubagentAdapterDispatchArtifact,
848
+ writeSubagentAdapterDispatch,
849
+ printSubagentAdapterDispatch,
850
+ subagentAuditEnvelope,
851
+ runSubagents,
852
+ };
853
+ };