zob-harness 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 (356) hide show
  1. package/.pi/adapters/registry.json +103 -0
  2. package/.pi/agents/architecture-cartographer.md +53 -0
  3. package/.pi/agents/chief-vision.md +39 -0
  4. package/.pi/agents/clarifier.md +58 -0
  5. package/.pi/agents/context-steward.md +52 -0
  6. package/.pi/agents/doc-steward.md +34 -0
  7. package/.pi/agents/explore.md +49 -0
  8. package/.pi/agents/factory.md +41 -0
  9. package/.pi/agents/implementer.md +44 -0
  10. package/.pi/agents/librarian.md +32 -0
  11. package/.pi/agents/oracle-merge.md +50 -0
  12. package/.pi/agents/oracle.md +55 -0
  13. package/.pi/agents/pattern-miner.md +53 -0
  14. package/.pi/agents/planner.md +39 -0
  15. package/.pi/agents/project-dna-golden-evaluator.md +32 -0
  16. package/.pi/agents/project-dna-ontology-steward.md +30 -0
  17. package/.pi/agents/project-dna-oracle.md +56 -0
  18. package/.pi/agents/project-dna-orchestrator.md +60 -0
  19. package/.pi/agents/project-dna-query-steward.md +38 -0
  20. package/.pi/agents/project-dna-safety-preflight.md +54 -0
  21. package/.pi/agents/project-dna-test-linker.md +27 -0
  22. package/.pi/agents/qa.md +38 -0
  23. package/.pi/agents/refactor-cartographer.md +28 -0
  24. package/.pi/agents/refactor-mover.md +31 -0
  25. package/.pi/agents/refactor-oracle.md +49 -0
  26. package/.pi/agents/repo-scout.md +60 -0
  27. package/.pi/agents/sample-architect.md +48 -0
  28. package/.pi/agents/specifier.md +57 -0
  29. package/.pi/agents/symbol-range-curator.md +41 -0
  30. package/.pi/agents/synthesis.md +52 -0
  31. package/.pi/agents/temp-agent-creator.md +35 -0
  32. package/.pi/autonomy-policy.json +67 -0
  33. package/.pi/budget-policy.json +54 -0
  34. package/.pi/capabilities/zob-public-runtime-capabilities.json +1700 -0
  35. package/.pi/chains/explore-plan-oracle.json +78 -0
  36. package/.pi/chains/explore-spec-clarify-plan-oracle.json +64 -0
  37. package/.pi/chains/explore-spec-plan-oracle.json +53 -0
  38. package/.pi/chains/spec-clarify-plan-oracle.json +53 -0
  39. package/.pi/chains/spec-factory-oracle.json +42 -0
  40. package/.pi/chains/spec-plan-oracle.json +42 -0
  41. package/.pi/compute-profiles/defaults.json +19 -0
  42. package/.pi/compute-profiles/overrides.json +13 -0
  43. package/.pi/compute-profiles/risk-rules.json +16 -0
  44. package/.pi/daemon-policy.json +80 -0
  45. package/.pi/damage-control-rules.json +45 -0
  46. package/.pi/extensions/zob-child-safety/index.ts +212 -0
  47. package/.pi/extensions/zob-harness/AGENTS.md +28 -0
  48. package/.pi/extensions/zob-harness/index.ts +391 -0
  49. package/.pi/extensions/zob-harness/src/AGENTS.md +25 -0
  50. package/.pi/extensions/zob-harness/src/agents.ts +82 -0
  51. package/.pi/extensions/zob-harness/src/autonomous-runtime.ts +2912 -0
  52. package/.pi/extensions/zob-harness/src/autonomy-readiness.ts +778 -0
  53. package/.pi/extensions/zob-harness/src/budget-policy.ts +308 -0
  54. package/.pi/extensions/zob-harness/src/capabilities.ts +249 -0
  55. package/.pi/extensions/zob-harness/src/child-runner.ts +249 -0
  56. package/.pi/extensions/zob-harness/src/chronicle.ts +262 -0
  57. package/.pi/extensions/zob-harness/src/compute-profile.ts +602 -0
  58. package/.pi/extensions/zob-harness/src/compute-workflow-shape.ts +168 -0
  59. package/.pi/extensions/zob-harness/src/coms-v2/AGENTS.md +16 -0
  60. package/.pi/extensions/zob-harness/src/coms-v2/envelope.ts +121 -0
  61. package/.pi/extensions/zob-harness/src/coms-v2/identity.ts +53 -0
  62. package/.pi/extensions/zob-harness/src/coms-v2/ledger-bridge.ts +67 -0
  63. package/.pi/extensions/zob-harness/src/coms-v2/local-transport.ts +147 -0
  64. package/.pi/extensions/zob-harness/src/coms-v2/pending-replies.ts +80 -0
  65. package/.pi/extensions/zob-harness/src/coms-v2/policy.ts +125 -0
  66. package/.pi/extensions/zob-harness/src/coms-v2/presence.ts +55 -0
  67. package/.pi/extensions/zob-harness/src/coms-v2/registry.ts +113 -0
  68. package/.pi/extensions/zob-harness/src/coms-v2/response-capture.ts +50 -0
  69. package/.pi/extensions/zob-harness/src/coms-v2/transcript-capture.ts +164 -0
  70. package/.pi/extensions/zob-harness/src/coms-v2/types.ts +149 -0
  71. package/.pi/extensions/zob-harness/src/coms-v2/zpeer-profile.ts +140 -0
  72. package/.pi/extensions/zob-harness/src/coms-v2/zpeer.ts +452 -0
  73. package/.pi/extensions/zob-harness/src/constants.ts +108 -0
  74. package/.pi/extensions/zob-harness/src/context-gbrain.ts +465 -0
  75. package/.pi/extensions/zob-harness/src/daemon-policy.ts +223 -0
  76. package/.pi/extensions/zob-harness/src/daemon-readiness.ts +134 -0
  77. package/.pi/extensions/zob-harness/src/daemon-runtime.ts +393 -0
  78. package/.pi/extensions/zob-harness/src/factory/AGENTS.md +24 -0
  79. package/.pi/extensions/zob-harness/src/factory/agentic-plan.ts +65 -0
  80. package/.pi/extensions/zob-harness/src/factory/quarantine.ts +319 -0
  81. package/.pi/extensions/zob-harness/src/factory/run.ts +520 -0
  82. package/.pi/extensions/zob-harness/src/factory/validation.ts +454 -0
  83. package/.pi/extensions/zob-harness/src/factory-selector.ts +318 -0
  84. package/.pi/extensions/zob-harness/src/full-autonomy-test.ts +226 -0
  85. package/.pi/extensions/zob-harness/src/git-ops.ts +868 -0
  86. package/.pi/extensions/zob-harness/src/goal-room.ts +178 -0
  87. package/.pi/extensions/zob-harness/src/goal-runtime.ts +1569 -0
  88. package/.pi/extensions/zob-harness/src/goal-todo-imports.ts +111 -0
  89. package/.pi/extensions/zob-harness/src/goal-todo-types.ts +231 -0
  90. package/.pi/extensions/zob-harness/src/goal-todos.ts +1410 -0
  91. package/.pi/extensions/zob-harness/src/goal.ts +152 -0
  92. package/.pi/extensions/zob-harness/src/governed-requests.ts +436 -0
  93. package/.pi/extensions/zob-harness/src/interactive-autonomy.ts +595 -0
  94. package/.pi/extensions/zob-harness/src/launch-apply.ts +313 -0
  95. package/.pi/extensions/zob-harness/src/merge-queue.ts +290 -0
  96. package/.pi/extensions/zob-harness/src/mission-control.ts +573 -0
  97. package/.pi/extensions/zob-harness/src/model-availability.ts +52 -0
  98. package/.pi/extensions/zob-harness/src/model-routing.ts +429 -0
  99. package/.pi/extensions/zob-harness/src/orchestration/AGENTS.md +23 -0
  100. package/.pi/extensions/zob-harness/src/orchestration/adaptive-delegation.ts +547 -0
  101. package/.pi/extensions/zob-harness/src/orchestration/adaptive-workflow.ts +585 -0
  102. package/.pi/extensions/zob-harness/src/orchestration/lead-plan.ts +192 -0
  103. package/.pi/extensions/zob-harness/src/orchestration/plan.ts +168 -0
  104. package/.pi/extensions/zob-harness/src/orchestration/room.ts +346 -0
  105. package/.pi/extensions/zob-harness/src/orchestration/run.ts +134 -0
  106. package/.pi/extensions/zob-harness/src/orchestration/supervised-readonly.ts +1147 -0
  107. package/.pi/extensions/zob-harness/src/orchestration/widget-readers.ts +132 -0
  108. package/.pi/extensions/zob-harness/src/output-contracts.ts +656 -0
  109. package/.pi/extensions/zob-harness/src/project-dna.ts +533 -0
  110. package/.pi/extensions/zob-harness/src/promotion/AGENTS.md +24 -0
  111. package/.pi/extensions/zob-harness/src/promotion/candidate.ts +336 -0
  112. package/.pi/extensions/zob-harness/src/promotion/coms.ts +127 -0
  113. package/.pi/extensions/zob-harness/src/promotion/documentation.ts +142 -0
  114. package/.pi/extensions/zob-harness/src/promotion/factory.ts +107 -0
  115. package/.pi/extensions/zob-harness/src/promotion/ledger.ts +2 -0
  116. package/.pi/extensions/zob-harness/src/promotion/temp-agent.ts +151 -0
  117. package/.pi/extensions/zob-harness/src/promotion/types.ts +149 -0
  118. package/.pi/extensions/zob-harness/src/promotion/validate.ts +6 -0
  119. package/.pi/extensions/zob-harness/src/promotion/write-lane.ts +162 -0
  120. package/.pi/extensions/zob-harness/src/prompt-packs.ts +239 -0
  121. package/.pi/extensions/zob-harness/src/queue.ts +386 -0
  122. package/.pi/extensions/zob-harness/src/rules.ts +225 -0
  123. package/.pi/extensions/zob-harness/src/runtime/AGENTS.md +26 -0
  124. package/.pi/extensions/zob-harness/src/runtime/adaptive-zmode.ts +116 -0
  125. package/.pi/extensions/zob-harness/src/runtime/auto-compaction.ts +715 -0
  126. package/.pi/extensions/zob-harness/src/runtime/commands.ts +1315 -0
  127. package/.pi/extensions/zob-harness/src/runtime/compaction-policy.ts +516 -0
  128. package/.pi/extensions/zob-harness/src/runtime/delegation-click-markers.ts +141 -0
  129. package/.pi/extensions/zob-harness/src/runtime/delegation-feed.ts +415 -0
  130. package/.pi/extensions/zob-harness/src/runtime/delegation-markdown.ts +97 -0
  131. package/.pi/extensions/zob-harness/src/runtime/delegation-monitor.ts +553 -0
  132. package/.pi/extensions/zob-harness/src/runtime/delegation-mouse.ts +205 -0
  133. package/.pi/extensions/zob-harness/src/runtime/delegation-overlay.ts +434 -0
  134. package/.pi/extensions/zob-harness/src/runtime/events.ts +736 -0
  135. package/.pi/extensions/zob-harness/src/runtime/goal-todo-overlay.ts +214 -0
  136. package/.pi/extensions/zob-harness/src/runtime/mode-intent.ts +144 -0
  137. package/.pi/extensions/zob-harness/src/runtime/plan-capture.ts +270 -0
  138. package/.pi/extensions/zob-harness/src/runtime/state.ts +403 -0
  139. package/.pi/extensions/zob-harness/src/runtime/tools-autonomous.ts +117 -0
  140. package/.pi/extensions/zob-harness/src/runtime/tools-compute.ts +136 -0
  141. package/.pi/extensions/zob-harness/src/runtime/tools-coms.ts +365 -0
  142. package/.pi/extensions/zob-harness/src/runtime/tools-context.ts +70 -0
  143. package/.pi/extensions/zob-harness/src/runtime/tools-delegation.ts +1854 -0
  144. package/.pi/extensions/zob-harness/src/runtime/tools-factory.ts +810 -0
  145. package/.pi/extensions/zob-harness/src/runtime/tools-goal-room.ts +46 -0
  146. package/.pi/extensions/zob-harness/src/runtime/tools-governed-requests.ts +38 -0
  147. package/.pi/extensions/zob-harness/src/runtime/tools-merge-queue.ts +61 -0
  148. package/.pi/extensions/zob-harness/src/runtime/tools-mission-control.ts +77 -0
  149. package/.pi/extensions/zob-harness/src/runtime/tools-orchestration.ts +106 -0
  150. package/.pi/extensions/zob-harness/src/runtime/tools-project-dna.ts +123 -0
  151. package/.pi/extensions/zob-harness/src/runtime/tools-worker-pool.ts +93 -0
  152. package/.pi/extensions/zob-harness/src/runtime/tools-workspace-claims.ts +62 -0
  153. package/.pi/extensions/zob-harness/src/runtime/tools-zcommit.ts +147 -0
  154. package/.pi/extensions/zob-harness/src/runtime/widget.ts +353 -0
  155. package/.pi/extensions/zob-harness/src/runtime/zobHarness.ts +60 -0
  156. package/.pi/extensions/zob-harness/src/safety.ts +338 -0
  157. package/.pi/extensions/zob-harness/src/sandbox.ts +1508 -0
  158. package/.pi/extensions/zob-harness/src/schemas-project-dna.ts +47 -0
  159. package/.pi/extensions/zob-harness/src/schemas.ts +695 -0
  160. package/.pi/extensions/zob-harness/src/telemetry.ts +373 -0
  161. package/.pi/extensions/zob-harness/src/topology/AGENTS.md +22 -0
  162. package/.pi/extensions/zob-harness/src/topology/chains.ts +236 -0
  163. package/.pi/extensions/zob-harness/src/topology/coms.ts +211 -0
  164. package/.pi/extensions/zob-harness/src/topology/orchestration-profiles.ts +204 -0
  165. package/.pi/extensions/zob-harness/src/topology/teams.ts +113 -0
  166. package/.pi/extensions/zob-harness/src/types/core.ts +47 -0
  167. package/.pi/extensions/zob-harness/src/types.ts +939 -0
  168. package/.pi/extensions/zob-harness/src/utils/AGENTS.md +22 -0
  169. package/.pi/extensions/zob-harness/src/utils/formatting.ts +34 -0
  170. package/.pi/extensions/zob-harness/src/utils/hashing.ts +11 -0
  171. package/.pi/extensions/zob-harness/src/utils/json.ts +28 -0
  172. package/.pi/extensions/zob-harness/src/utils/paths.ts +54 -0
  173. package/.pi/extensions/zob-harness/src/utils/records.ts +25 -0
  174. package/.pi/extensions/zob-harness/src/utils/resources.ts +38 -0
  175. package/.pi/extensions/zob-harness/src/worker-pool.ts +672 -0
  176. package/.pi/extensions/zob-harness/src/workspace-claims.ts +297 -0
  177. package/.pi/extensions/zob-switch/index.ts +180 -0
  178. package/.pi/factories/budget-preflight-dry-run/batch-manifest.json +59 -0
  179. package/.pi/factories/budget-preflight-dry-run/factory.json +94 -0
  180. package/.pi/factories/budget-preflight-dry-run/pilot-manifest.json +50 -0
  181. package/.pi/factories/budget-preflight-dry-run/smoke-manifest.json +43 -0
  182. package/.pi/factories/code-review-matrix/batch-manifest.json +61 -0
  183. package/.pi/factories/code-review-matrix/factory.json +163 -0
  184. package/.pi/factories/code-review-matrix/pilot-manifest.json +41 -0
  185. package/.pi/factories/code-review-matrix/smoke-manifest.json +35 -0
  186. package/.pi/factories/factory-forge/batch-manifest.json +56 -0
  187. package/.pi/factories/factory-forge/factory.json +84 -0
  188. package/.pi/factories/factory-forge/pilot-manifest.json +32 -0
  189. package/.pi/factories/factory-forge/smoke-manifest.json +19 -0
  190. package/.pi/factories/opencode-pattern-canonizer/batch-manifest.json +54 -0
  191. package/.pi/factories/opencode-pattern-canonizer/factory.json +86 -0
  192. package/.pi/factories/opencode-pattern-canonizer/pilot-manifest.json +39 -0
  193. package/.pi/factories/opencode-pattern-canonizer/smoke-manifest.json +26 -0
  194. package/.pi/factories/project-dna/README.md +182 -0
  195. package/.pi/factories/project-dna/batch-manifest.json +37 -0
  196. package/.pi/factories/project-dna/example-project-dna-manifest-v2.json +80 -0
  197. package/.pi/factories/project-dna/example-project-dna-manifest.json +58 -0
  198. package/.pi/factories/project-dna/factory.json +131 -0
  199. package/.pi/factories/project-dna/golden-cases-smoke.json +62 -0
  200. package/.pi/factories/project-dna/pi-agentic-ontology.json +88 -0
  201. package/.pi/factories/project-dna/pilot-manifest.json +32 -0
  202. package/.pi/factories/project-dna/schemas/benchmark-suite.schema.json +27 -0
  203. package/.pi/factories/project-dna/schemas/code-knowledge-graph.schema.json +97 -0
  204. package/.pi/factories/project-dna/schemas/context-pack.schema.json +43 -0
  205. package/.pi/factories/project-dna/schemas/golden-case.schema.json +36 -0
  206. package/.pi/factories/project-dna/schemas/manifest-v2.schema.json +128 -0
  207. package/.pi/factories/project-dna/schemas/manifest.schema.json +77 -0
  208. package/.pi/factories/project-dna/schemas/ontology.schema.json +45 -0
  209. package/.pi/factories/project-dna/schemas/project-fingerprint.schema.json +28 -0
  210. package/.pi/factories/project-dna/schemas/query-steward-report.schema.json +52 -0
  211. package/.pi/factories/project-dna/smoke-manifest.json +27 -0
  212. package/.pi/factories/roadmap-smoke-lots/batch-manifest.json +49 -0
  213. package/.pi/factories/roadmap-smoke-lots/factory.json +89 -0
  214. package/.pi/factories/roadmap-smoke-lots/pilot-manifest.json +50 -0
  215. package/.pi/factories/roadmap-smoke-lots/smoke-manifest.json +35 -0
  216. package/.pi/git-policy.json +120 -0
  217. package/.pi/mission-control/zob_coms_transport.json +64 -0
  218. package/.pi/model-catalog.example.json +345 -0
  219. package/.pi/model-economy.example.json +196 -0
  220. package/.pi/model-routing.json +86 -0
  221. package/.pi/orchestrations/adaptive-chief-vision.json +193 -0
  222. package/.pi/orchestrations/ceo-feature-build.json +182 -0
  223. package/.pi/orchestrations/readonly-dynamic-smoke.json +75 -0
  224. package/.pi/output-contracts/agent-event.v1.json +19 -0
  225. package/.pi/output-contracts/base.v1.json +24 -0
  226. package/.pi/output-contracts/brain-lookup.v1.json +21 -0
  227. package/.pi/output-contracts/clarification.v1.json +21 -0
  228. package/.pi/output-contracts/context-pack.v1.json +20 -0
  229. package/.pi/output-contracts/context-request.v1.json +21 -0
  230. package/.pi/output-contracts/context-steward.v1.json +19 -0
  231. package/.pi/output-contracts/context-writeback-proposal.v1.json +18 -0
  232. package/.pi/output-contracts/delegation-request.v1.json +21 -0
  233. package/.pi/output-contracts/explore.v1.json +52 -0
  234. package/.pi/output-contracts/factory.v1.json +48 -0
  235. package/.pi/output-contracts/guidance-steward.v1.json +18 -0
  236. package/.pi/output-contracts/implement.v1.json +40 -0
  237. package/.pi/output-contracts/launch-authorization.v1.json +21 -0
  238. package/.pi/output-contracts/lead-plan.v1.json +22 -0
  239. package/.pi/output-contracts/mission-readiness.v1.json +20 -0
  240. package/.pi/output-contracts/oracle-merge.v1.json +44 -0
  241. package/.pi/output-contracts/oracle-request.v1.json +20 -0
  242. package/.pi/output-contracts/oracle.v1.json +44 -0
  243. package/.pi/output-contracts/orchestration-profile.v1.json +22 -0
  244. package/.pi/output-contracts/plan.v1.json +48 -0
  245. package/.pi/output-contracts/prompt-pack.v1.json +20 -0
  246. package/.pi/output-contracts/qa.v1.json +40 -0
  247. package/.pi/output-contracts/research.v1.json +36 -0
  248. package/.pi/output-contracts/spec.v1.json +22 -0
  249. package/.pi/output-contracts/synthesis.v1.json +44 -0
  250. package/.pi/output-contracts/temp-agent-card.v1.json +23 -0
  251. package/.pi/output-contracts/todo-child-result.v1.json +20 -0
  252. package/.pi/output-contracts/todo-child-result.v2.json +22 -0
  253. package/.pi/output-contracts/todo-claim-validation.v1.json +22 -0
  254. package/.pi/output-contracts/todo-split-request.v1.json +20 -0
  255. package/.pi/prompts/adaptive-workflow.md +63 -0
  256. package/.pi/prompts/autonomous-runtime.md +15 -0
  257. package/.pi/prompts/benchmark-contender.md +15 -0
  258. package/.pi/prompts/benchmark-judge.md +19 -0
  259. package/.pi/prompts/clarify-spec.md +20 -0
  260. package/.pi/prompts/compute-plan.md +36 -0
  261. package/.pi/prompts/compute-preview.md +42 -0
  262. package/.pi/prompts/contract.md +29 -0
  263. package/.pi/prompts/explore.md +13 -0
  264. package/.pi/prompts/factory-run.md +36 -0
  265. package/.pi/prompts/factory.md +20 -0
  266. package/.pi/prompts/implement.md +27 -0
  267. package/.pi/prompts/model-catalog.md +68 -0
  268. package/.pi/prompts/model-economy.md +64 -0
  269. package/.pi/prompts/oracle-merge.md +18 -0
  270. package/.pi/prompts/oracle.md +13 -0
  271. package/.pi/prompts/orchestrator.md +48 -0
  272. package/.pi/prompts/parallel-review.md +21 -0
  273. package/.pi/prompts/plan.md +21 -0
  274. package/.pi/prompts/project-dna.md +90 -0
  275. package/.pi/prompts/refactor-oracle.md +23 -0
  276. package/.pi/prompts/refactor-slice.md +24 -0
  277. package/.pi/prompts/research.md +20 -0
  278. package/.pi/prompts/spec.md +19 -0
  279. package/.pi/prompts/synthesis.md +18 -0
  280. package/.pi/rules/always.md +38 -0
  281. package/.pi/rules/docs.md +32 -0
  282. package/.pi/rules/factory.md +44 -0
  283. package/.pi/rules/oracle.md +34 -0
  284. package/.pi/rules/orchestration.md +44 -0
  285. package/.pi/rules/project.md +34 -0
  286. package/.pi/rules/prompts.md +43 -0
  287. package/.pi/rules/runtime.md +43 -0
  288. package/.pi/rules/sandbox.md +43 -0
  289. package/.pi/settings.json +28 -0
  290. package/.pi/skills/zob-agentic-access/SKILL.md +20 -0
  291. package/.pi/skills/zob-autonomous-runtime/SKILL.md +41 -0
  292. package/.pi/skills/zob-commit/SKILL.md +79 -0
  293. package/.pi/skills/zob-compaction-policy/SKILL.md +92 -0
  294. package/.pi/skills/zob-compute-profile/SKILL.md +108 -0
  295. package/.pi/skills/zob-coms-safety/SKILL.md +54 -0
  296. package/.pi/skills/zob-coms-v2-live/SKILL.md +47 -0
  297. package/.pi/skills/zob-delegation-routing/SKILL.md +82 -0
  298. package/.pi/skills/zob-factory/SKILL.md +28 -0
  299. package/.pi/skills/zob-goal-todo-tree/SKILL.md +279 -0
  300. package/.pi/skills/zob-harness/SKILL.md +68 -0
  301. package/.pi/skills/zob-mission-control-coms/SKILL.md +39 -0
  302. package/.pi/skills/zob-oracle/SKILL.md +21 -0
  303. package/.pi/skills/zob-owner-pool-drill-writer/SKILL.md +244 -0
  304. package/.pi/skills/zob-owner-pool-launcher/SKILL.md +261 -0
  305. package/.pi/skills/zob-project-dna/SKILL.md +275 -0
  306. package/.pi/skills/zob-sandbox/SKILL.md +29 -0
  307. package/.pi/skills/zob-spec/SKILL.md +25 -0
  308. package/.pi/skills/zob-split-refactor/SKILL.md +39 -0
  309. package/.pi/skills/zob-tool-router/SKILL.md +104 -0
  310. package/.pi/teams/zob-core.json +122 -0
  311. package/AGENTS.md +89 -0
  312. package/CONTRIBUTING.md +56 -0
  313. package/LICENSE +21 -0
  314. package/README.md +360 -0
  315. package/SECURITY.md +35 -0
  316. package/SOURCE_INDEX.md +46 -0
  317. package/package.json +135 -0
  318. package/scripts/README.md +57 -0
  319. package/scripts/autonomy/mission-readiness-secret-smoke.mjs +90 -0
  320. package/scripts/compute-profile/plan-workflow.mjs +85 -0
  321. package/scripts/compute-profile/preview.mjs +242 -0
  322. package/scripts/compute-profile/regression-smoke.mjs +38 -0
  323. package/scripts/compute-profile/summarize.mjs +72 -0
  324. package/scripts/compute-profile/validate-policy.mjs +50 -0
  325. package/scripts/compute-profile/validate-preview.mjs +95 -0
  326. package/scripts/compute-profile/validate-workflow.mjs +58 -0
  327. package/scripts/git-ops/commit-policy-smoke.mjs +221 -0
  328. package/scripts/goal-todo/child-goal-ref-smoke.mjs +252 -0
  329. package/scripts/harness-switch/static-smoke.mjs +43 -0
  330. package/scripts/model-catalog/validate-economy.mjs +223 -0
  331. package/scripts/model-catalog/validate.mjs +199 -0
  332. package/scripts/package-surface/validate-script-refs.mjs +190 -0
  333. package/scripts/path-policy/validate-smoke.mjs +103 -0
  334. package/scripts/project-dna/bench-smoke.mjs +217 -0
  335. package/scripts/project-dna/build-capsules.mjs +207 -0
  336. package/scripts/project-dna/build-sample-spec.mjs +140 -0
  337. package/scripts/project-dna/emit-golden-cases.mjs +75 -0
  338. package/scripts/project-dna/emit-ontology.mjs +75 -0
  339. package/scripts/project-dna/generate-sample.mjs +302 -0
  340. package/scripts/project-dna/oracle-review-smoke.mjs +157 -0
  341. package/scripts/project-dna/plan-workflow.mjs +289 -0
  342. package/scripts/project-dna/query-context.mjs +276 -0
  343. package/scripts/project-dna/query-steward.mjs +149 -0
  344. package/scripts/project-dna/scan.mjs +553 -0
  345. package/scripts/project-dna/validate-5of5.mjs +159 -0
  346. package/scripts/project-dna/validate-golden-cases.mjs +78 -0
  347. package/scripts/project-dna/validate-ontology.mjs +97 -0
  348. package/scripts/project-dna/validate-sample-project.mjs +105 -0
  349. package/scripts/project-dna/validate-scaffold.mjs +383 -0
  350. package/scripts/project-dna/validate-scan-artifacts.mjs +187 -0
  351. package/scripts/project-dna/validate-workflow.mjs +166 -0
  352. package/scripts/start-pi.sh +4 -0
  353. package/scripts/worker-pool/static-smoke.mjs +54 -0
  354. package/scripts/zpeer-local-e2e-smoke.mjs +395 -0
  355. package/scripts/zpeer-static-smoke.mjs +129 -0
  356. package/tsconfig.json +12 -0
@@ -0,0 +1,403 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { TUI } from "@earendil-works/pi-tui";
3
+
4
+ import { DEFAULT_RULES, MODE_PROMPTS } from "../constants.js";
5
+ import type { ChildResult, DamageRules, DelegationFailureKind, GoalState, ModeName, QueueTickResult, RuleResolution } from "../types.js";
6
+ import { validateGoalState, validateStrictGoalSpecAnchor, type StrictGoalSpecAnchor } from "../goal.js";
7
+ import { DEFAULT_GOAL_ACTIVATION_MODE, restoreGoalActivationModeFromBranch, restoreRuntimeGoalFromBranch, type GoalActivationMode, type RuntimeGoal } from "../goal-runtime.js";
8
+ import { createGoalTodoState, restoreGoalTodosFromBranch, type GoalTodoState } from "../goal-todos.js";
9
+ import { isRecord } from "../utils/records.js";
10
+ import type { ZobLiveEnvelope } from "../coms-v2/envelope.js";
11
+ import type { ZobLocalTransportServer } from "../coms-v2/local-transport.js";
12
+ import { ZobPendingReplies } from "../coms-v2/pending-replies.js";
13
+ import type { ZobLivePeerCard } from "../coms-v2/types.js";
14
+ import { createDelegationMonitorState, trimDelegationRuns, type DelegationMonitorState, type DelegationRunMode, type DelegationRunSource, type DelegationRunStatus, type DelegationRunView } from "./delegation-monitor.js";
15
+ import { DEFAULT_DAEMON_RUNTIME_POLICY, type DaemonLoopSnapshot, type DaemonRuntimePolicy, type DaemonRuntimeState, type DaemonTickPlan } from "../daemon-runtime.js";
16
+ import { createInteractiveAutonomyRuntimeState, restoreInteractiveAutonomyState, type InteractiveAutonomyRuntimeState } from "../interactive-autonomy.js";
17
+ import type { ZobModeIntent } from "./mode-intent.js";
18
+ import { createZcompactRuntimeState, restoreZcompactStateFromBranch, type ZcompactRuntimeState } from "./auto-compaction.js";
19
+ import { createZcommitRuntimeState, recordZcommitOwnedPath, type ZcommitLastCommitRecord, type ZcommitOwnershipSource, type ZcommitRuntimeState, type ZcommitToggleState } from "../git-ops.js";
20
+
21
+ export interface DelegationMouseRuntimeState {
22
+ tui?: TUI;
23
+ enabled: boolean;
24
+ unsubscribe?: () => void;
25
+ opening: boolean;
26
+ overlaySelect?: (runId: string) => boolean;
27
+ overlayClose?: () => boolean;
28
+ overlayScroll?: (direction: "up" | "down", x?: number, y?: number) => boolean;
29
+ mouseReenableTimer?: ReturnType<typeof setTimeout>;
30
+ releasedUntilMs?: number;
31
+ suppressOpenUntilMs?: number;
32
+ mouseReleaseEpoch: number;
33
+ widgetOwner?: symbol;
34
+ }
35
+
36
+ export interface ZobLiveLastEvent {
37
+ kind: "status" | "attempt" | "delivered" | "waiting" | "reply" | "sent" | "completed" | "blocked" | "error" | "timeout" | "expired" | "inbound" | "response_sent" | "heartbeat";
38
+ roomId?: string;
39
+ fromAlias?: string;
40
+ toAlias?: string;
41
+ status: string;
42
+ reason?: string;
43
+ msgId?: string;
44
+ taskHash?: string;
45
+ outputHash?: string;
46
+ at: string;
47
+ localOnly: true;
48
+ networkEnabled: false;
49
+ bodyStored: false;
50
+ }
51
+
52
+ export interface ZobLiveRuntimeState {
53
+ pendingReplies: ZobPendingReplies;
54
+ server?: ZobLocalTransportServer;
55
+ peerCard?: ZobLivePeerCard;
56
+ inbound?: { envelope: ZobLiveEnvelope; receivedAt: string; responseSent: boolean; repoRoot: string };
57
+ lastEvent?: ZobLiveLastEvent;
58
+ zpeerAskGuard?: { windowStartedMs: number; count: number; lastRoomId?: string; lastTargetAlias?: string; lastMessageHash?: string };
59
+ heartbeatTimer?: ReturnType<typeof setTimeout>;
60
+ lastHeartbeatMs?: number;
61
+ }
62
+
63
+ export interface DaemonHarnessRuntimeState {
64
+ policy: DaemonRuntimePolicy;
65
+ lastStatus?: DaemonRuntimeState;
66
+ lastPlan?: DaemonTickPlan;
67
+ loop: DaemonLoopSnapshot;
68
+ loopTimer?: ReturnType<typeof setTimeout>;
69
+ lastQueueTick?: QueueTickResult;
70
+ updatedAt?: string;
71
+ }
72
+
73
+ export interface BackgroundDelegationRuntimeRun {
74
+ runId: string;
75
+ startedAtMs: number;
76
+ promise: Promise<ChildResult>;
77
+ abortController: AbortController;
78
+ result?: ChildResult;
79
+ error?: string;
80
+ }
81
+
82
+ export interface HarnessRuntimeState {
83
+ activeMode: ModeName;
84
+ currentRules: DamageRules;
85
+ activeGoal?: GoalState;
86
+ goalRequired: boolean;
87
+ goalActivationMode?: GoalActivationMode;
88
+ runtimeGoal?: RuntimeGoal;
89
+ goalTodos: GoalTodoState;
90
+ runtimeGoalContinuationQueuedFor?: string;
91
+ runtimeGoalContinuationScheduledFor?: string;
92
+ runtimeGoalContinuationCompactionFor?: string;
93
+ runtimeGoalContinuationTimer?: ReturnType<typeof setTimeout>;
94
+ runtimeGoalContinuationTurnFor?: string;
95
+ runtimeGoalLastAccountedAtMs?: number;
96
+ activeRuleResolution?: RuleResolution;
97
+ lastUserInputText?: string;
98
+ lastModeIntent?: ZobModeIntent & { at: number; accepted: boolean; validationReason: string };
99
+ delegations: DelegationMonitorState;
100
+ delegationMouse: DelegationMouseRuntimeState;
101
+ zobLive: ZobLiveRuntimeState;
102
+ autonomy: InteractiveAutonomyRuntimeState;
103
+ daemon: DaemonHarnessRuntimeState;
104
+ zcompact: ZcompactRuntimeState;
105
+ zcommit: ZcommitRuntimeState;
106
+ backgroundDelegations: Map<string, BackgroundDelegationRuntimeRun>;
107
+ }
108
+
109
+ export function createHarnessRuntimeState(): HarnessRuntimeState {
110
+ return {
111
+ activeMode: "explore",
112
+ currentRules: DEFAULT_RULES,
113
+ activeGoal: undefined,
114
+ goalRequired: false,
115
+ goalActivationMode: DEFAULT_GOAL_ACTIVATION_MODE,
116
+ runtimeGoal: undefined,
117
+ goalTodos: createGoalTodoState(),
118
+ runtimeGoalContinuationQueuedFor: undefined,
119
+ runtimeGoalContinuationScheduledFor: undefined,
120
+ runtimeGoalContinuationCompactionFor: undefined,
121
+ runtimeGoalContinuationTimer: undefined,
122
+ runtimeGoalLastAccountedAtMs: undefined,
123
+ activeRuleResolution: undefined,
124
+ lastUserInputText: undefined,
125
+ lastModeIntent: undefined,
126
+ delegations: createDelegationMonitorState(),
127
+ delegationMouse: { enabled: false, opening: false, mouseReleaseEpoch: 0 },
128
+ zobLive: { pendingReplies: new ZobPendingReplies() },
129
+ autonomy: createInteractiveAutonomyRuntimeState(),
130
+ daemon: {
131
+ policy: { ...DEFAULT_DAEMON_RUNTIME_POLICY, enabled: false },
132
+ loop: {
133
+ schema: "zob.daemon-loop-snapshot.v1",
134
+ status: "stopped",
135
+ tickCount: 0,
136
+ supervised: true,
137
+ bounded: true,
138
+ sessionLocal: true,
139
+ autoStartDaemon: false,
140
+ continuousLoop: false,
141
+ cronEnabled: false,
142
+ },
143
+ },
144
+ zcompact: createZcompactRuntimeState(),
145
+ zcommit: createZcommitRuntimeState(),
146
+ backgroundDelegations: new Map(),
147
+ };
148
+ }
149
+
150
+ export function strictGoalErrors(state: HarnessRuntimeState): string[] {
151
+ return state.goalRequired ? validateGoalState(state.activeGoal) : [];
152
+ }
153
+
154
+ export function strictGoalSpecErrors(state: HarnessRuntimeState, anchor: Omit<StrictGoalSpecAnchor, "activeGoal">): string[] {
155
+ return validateStrictGoalSpecAnchor({ ...anchor, activeGoal: state.activeGoal });
156
+ }
157
+
158
+ export function asGoalState(value: unknown): GoalState | undefined {
159
+ if (!isRecord(value)) return undefined;
160
+ const goal = {
161
+ originalUserAsk: typeof value.originalUserAsk === "string" ? value.originalUserAsk : "",
162
+ activeGoal: typeof value.activeGoal === "string" ? value.activeGoal : "",
163
+ constraints: typeof value.constraints === "string" ? value.constraints : "",
164
+ expectedOutput: typeof value.expectedOutput === "string" ? value.expectedOutput : "",
165
+ validationEvidence: typeof value.validationEvidence === "string" ? value.validationEvidence : "",
166
+ setAt: typeof value.setAt === "string" ? value.setAt : new Date().toISOString(),
167
+ };
168
+ return validateGoalState(goal).length === 0 ? goal : undefined;
169
+ }
170
+
171
+ function stringField(record: Record<string, unknown>, key: string): string | undefined {
172
+ const value = record[key];
173
+ return typeof value === "string" && value.trim().length > 0 ? value : undefined;
174
+ }
175
+
176
+ function numberField(record: Record<string, unknown>, key: string): number | undefined {
177
+ const value = record[key];
178
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
179
+ }
180
+
181
+ function parseTimeMs(value: string | undefined, fallback: number): number {
182
+ if (!value) return fallback;
183
+ const parsed = Date.parse(value);
184
+ return Number.isFinite(parsed) ? parsed : fallback;
185
+ }
186
+
187
+ function asDelegationMode(value: string | undefined): DelegationRunMode {
188
+ return value === "parallel" || value === "chain" || value === "single" ? value : "single";
189
+ }
190
+
191
+ function asDelegationSource(value: string | undefined): DelegationRunSource {
192
+ return value === "delegate_task" ? "delegate_task" : "delegate_agent";
193
+ }
194
+
195
+ function asDelegationFailureKind(value: string | undefined): DelegationFailureKind | undefined {
196
+ return value === "preflight" || value === "config" || value === "output_gate" || value === "child_runtime" || value === "aborted" ? value : undefined;
197
+ }
198
+
199
+ function stringArrayField(record: Record<string, unknown>, key: string): string[] | undefined {
200
+ const value = record[key];
201
+ return Array.isArray(value) ? value.map(String) : undefined;
202
+ }
203
+
204
+ function asZcommitToggle(value: unknown): ZcommitToggleState | undefined {
205
+ return value === "on" || value === "off" ? value : undefined;
206
+ }
207
+
208
+ function asZcommitOwnershipSource(value: unknown): ZcommitOwnershipSource | undefined {
209
+ return value === "local_tool_call" || value === "parent_accepted_child_claim" || value === "compaction_continuity" ? value : undefined;
210
+ }
211
+
212
+ function normalizeZcommitChildChangedPathRefs(value: unknown): DelegationRunView["childChangedPaths"] {
213
+ if (!Array.isArray(value)) return undefined;
214
+ return value.flatMap((item) => {
215
+ if (!isRecord(item) || typeof item.path !== "string" || typeof item.pathHash !== "string" || typeof item.status !== "string") return [];
216
+ return [{ path: item.path, pathHash: item.pathHash, status: item.status, contentHash: typeof item.contentHash === "string" ? item.contentHash : undefined }];
217
+ }).slice(0, 100);
218
+ }
219
+
220
+ function asZcommitLastCommitRecord(value: unknown): ZcommitLastCommitRecord | undefined {
221
+ if (!isRecord(value) || typeof value.hash !== "string" || typeof value.shortHash !== "string" || typeof value.subject !== "string" || !Array.isArray(value.files) || typeof value.createdAt !== "string") return undefined;
222
+ return {
223
+ hash: value.hash,
224
+ shortHash: value.shortHash,
225
+ subject: value.subject,
226
+ files: value.files.map(String),
227
+ remote: typeof value.remote === "string" ? value.remote : undefined,
228
+ branch: typeof value.branch === "string" ? value.branch : undefined,
229
+ createdAt: value.createdAt,
230
+ pushedAt: typeof value.pushedAt === "string" ? value.pushedAt : undefined,
231
+ };
232
+ }
233
+
234
+ function restoreZcommitOwnedPathRefsFromData(state: HarnessRuntimeState, repoRoot: string, data: Record<string, unknown>, fallbackSource: ZcommitOwnershipSource, fallbackAt: string): void {
235
+ const refs = Array.isArray(data.ownedPathRefs) ? data.ownedPathRefs : [];
236
+ for (const value of refs) {
237
+ if (!isRecord(value) || typeof value.path !== "string") continue;
238
+ recordZcommitOwnedPath(state.zcommit, repoRoot, value.path, asZcommitOwnershipSource(value.source) ?? fallbackSource, typeof value.lastOwnedAt === "string" ? value.lastOwnedAt : fallbackAt);
239
+ }
240
+ }
241
+
242
+ function restoreZcommitMetadataFromEntries(state: HarnessRuntimeState, repoRoot: string, entries: unknown[]): void {
243
+ for (const entry of entries) {
244
+ if (!isRecord(entry) || entry.customType !== "zob-zcommit" || !isRecord(entry.data)) continue;
245
+ const data = entry.data as Record<string, unknown>;
246
+ const entryAt = stringField(data, "generatedAt") ?? stringField(entry, "timestamp") ?? new Date().toISOString();
247
+ state.zcommit.autocommit = asZcommitToggle(data.autocommit) ?? state.zcommit.autocommit;
248
+ state.zcommit.autopush = asZcommitToggle(data.autopush) ?? state.zcommit.autopush;
249
+ const lastCommit = asZcommitLastCommitRecord(data.lastCommit);
250
+ if (lastCommit) state.zcommit.lastCommit = lastCommit;
251
+ const lastCommitHash = stringField(data, "lastCommitHash");
252
+ const lastCommitShortHash = stringField(data, "lastCommitShortHash");
253
+ if (!lastCommit && lastCommitHash && lastCommitShortHash) {
254
+ state.zcommit.lastCommit = { hash: lastCommitHash, shortHash: lastCommitShortHash, subject: "restored /zcommit commit", files: [], createdAt: entryAt };
255
+ }
256
+ restoreZcommitOwnedPathRefsFromData(state, repoRoot, data, "local_tool_call", entryAt);
257
+ state.zcommit.updatedAt = entryAt;
258
+ }
259
+ }
260
+
261
+ function restoreDaemonMetadataFromEntries(state: HarnessRuntimeState, entries: unknown[]): void {
262
+ for (const entry of entries) {
263
+ if (!isRecord(entry) || !isRecord(entry.data)) continue;
264
+ const customType = typeof entry.customType === "string" ? entry.customType : "";
265
+ const data = entry.data as Record<string, unknown>;
266
+ if (customType !== "zob-daemon-runtime" && customType !== "zob-daemon-plan") continue;
267
+ state.daemon.policy = {
268
+ ...state.daemon.policy,
269
+ enabled: false,
270
+ planOnly: true,
271
+ scopedToActiveGoal: true,
272
+ autoStartAllowed: false,
273
+ continuousLoopAllowed: false,
274
+ cronAllowed: false,
275
+ childDispatchAllowed: false,
276
+ queueClaimsAllowed: false,
277
+ todoMutationAllowed: false,
278
+ productionApplyAllowed: false,
279
+ };
280
+ state.daemon.updatedAt = stringField(data, "generatedAt") ?? stringField(entry, "timestamp") ?? state.daemon.updatedAt;
281
+ state.daemon.loop = {
282
+ ...state.daemon.loop,
283
+ status: "stopped",
284
+ stoppedAt: state.daemon.updatedAt,
285
+ autoStartDaemon: false,
286
+ continuousLoop: false,
287
+ cronEnabled: false,
288
+ };
289
+ }
290
+ }
291
+
292
+ function usageField(record: Record<string, unknown>): ChildResult["usage"] | undefined {
293
+ const usage = isRecord(record.usage) ? record.usage : undefined;
294
+ if (!usage) return undefined;
295
+ const numberValue = (key: string): number => {
296
+ const value = usage[key];
297
+ return typeof value === "number" && Number.isFinite(value) ? value : 0;
298
+ };
299
+ return {
300
+ turns: numberValue("turns"),
301
+ input: numberValue("input"),
302
+ output: numberValue("output"),
303
+ cacheRead: numberValue("cacheRead"),
304
+ cacheWrite: numberValue("cacheWrite"),
305
+ cost: numberValue("cost"),
306
+ contextTokens: numberValue("contextTokens"),
307
+ };
308
+ }
309
+
310
+ function restoredStatusFromLedger(event: string | undefined, status: string | undefined): DelegationRunStatus {
311
+ if (event === "preflight_failed" || event === "config_failed") return "preflight_failed";
312
+ if (status === "complete" || status === "completed") return "complete";
313
+ if (status === "aborted") return "aborted";
314
+ if (status === "failed" || status === "incomplete_or_failed" || status === "failed_preflight") return "failed";
315
+ return event === "end" ? "complete" : "running";
316
+ }
317
+
318
+ function restoreDelegationRunsFromEntries(state: HarnessRuntimeState, entries: unknown[]): void {
319
+ const restored = new Map<string, DelegationRunView>();
320
+ for (const entry of entries) {
321
+ if (!isRecord(entry) || entry.customType !== "zob-delegation" || !isRecord(entry.data)) continue;
322
+ const data = entry.data as Record<string, unknown>;
323
+ const runId = stringField(data, "runId");
324
+ if (!runId) continue;
325
+ const event = stringField(data, "event");
326
+ const timestampMs = parseTimeMs(stringField(data, "startedAt") ?? stringField(data, "endedAt") ?? stringField(entry, "timestamp"), Date.now());
327
+ const existing = restored.get(runId);
328
+ const source = asDelegationSource(stringField(data, "source") ?? stringField(data, "tool"));
329
+ const mode = asDelegationMode(stringField(data, "delegationMode") ?? stringField(data, "mode"));
330
+ const agent = stringField(data, "agent") ?? existing?.agent ?? "delegate";
331
+ const taskHash = stringField(data, "taskHash");
332
+ const startedAtMs = existing?.startedAtMs ?? parseTimeMs(stringField(data, "startedAt"), Math.max(0, timestampMs - (numberField(data, "latencyMs") ?? 0)));
333
+ const status = restoredStatusFromLedger(event, stringField(data, "status"));
334
+ const restoredRun: DelegationRunView = {
335
+ id: runId,
336
+ parentToolCallId: stringField(data, "parentToolCallId") ?? existing?.parentToolCallId ?? runId,
337
+ source: existing?.source ?? source,
338
+ mode: existing?.mode ?? mode,
339
+ index: numberField(data, "index") ?? existing?.index,
340
+ agent,
341
+ taskPreview: existing?.taskPreview ?? (taskHash ? `task hash ${taskHash.slice(0, 12)}` : "restored delegation"),
342
+ status,
343
+ startedAtMs,
344
+ endedAtMs: parseTimeMs(stringField(data, "endedAt"), timestampMs),
345
+ outputPreview: existing?.outputPreview ?? "",
346
+ stderrPreview: existing?.stderrPreview ?? "",
347
+ sessionPath: stringField(data, "sessionPath") ?? existing?.sessionPath,
348
+ exitCode: numberField(data, "exitCode") ?? existing?.exitCode,
349
+ gatePassed: typeof data.gatePassed === "boolean" ? data.gatePassed : existing?.gatePassed,
350
+ gateErrors: stringArrayField(data, "gateErrors") ?? stringArrayField(data, "errors") ?? existing?.gateErrors,
351
+ failureKind: asDelegationFailureKind(stringField(data, "failureKind")) ?? existing?.failureKind,
352
+ stopReason: stringField(data, "stopReason") ?? existing?.stopReason,
353
+ stopCondition: stringField(data, "stopCondition") ?? existing?.stopCondition,
354
+ errorMessage: Array.isArray(data.errors) ? data.errors.map(String).join("; ") : existing?.errorMessage,
355
+ childChangedPaths: normalizeZcommitChildChangedPathRefs(data.childChangedPathRefs) ?? existing?.childChangedPaths,
356
+ usage: usageField(data) ?? existing?.usage,
357
+ };
358
+ if (event === "start") restoredRun.endedAtMs = existing?.endedAtMs;
359
+ restored.set(runId, restoredRun);
360
+ }
361
+ if (restored.size === 0) return;
362
+ state.delegations.runs = [...restored.values()].sort((a, b) => b.startedAtMs - a.startedAtMs);
363
+ trimDelegationRuns(state.delegations);
364
+ }
365
+
366
+ export function restoreHarnessState(state: HarnessRuntimeState, ctx: ExtensionContext): void {
367
+ const branch = ctx.sessionManager.getBranch();
368
+ for (const entry of branch) {
369
+ if (!isRecord(entry)) continue;
370
+ const customType = typeof entry.customType === "string" ? entry.customType : "";
371
+ const data = isRecord(entry.data) ? entry.data : undefined;
372
+ if (customType === "zob-mode-state" && data && typeof data.mode === "string" && data.mode in MODE_PROMPTS) state.activeMode = data.mode as ModeName;
373
+ if (customType === "zob-goal") state.activeGoal = asGoalState(data) ?? state.activeGoal;
374
+ if (customType === "zob-job-intake" && data && isRecord(data.goal)) state.activeGoal = asGoalState(data.goal) ?? state.activeGoal;
375
+ if (customType === "zob-job-intake") state.goalRequired = true;
376
+ }
377
+ state.runtimeGoal = restoreRuntimeGoalFromBranch(branch);
378
+ state.goalActivationMode = restoreGoalActivationModeFromBranch(branch) ?? state.goalActivationMode;
379
+ state.goalTodos = restoreGoalTodosFromBranch(branch);
380
+ state.autonomy = restoreInteractiveAutonomyState(ctx.cwd, branch, state.autonomy);
381
+ state.zcompact = restoreZcompactStateFromBranch(branch, state.zcompact);
382
+ restoreDaemonMetadataFromEntries(state, branch);
383
+ restoreZcommitMetadataFromEntries(state, ctx.cwd, branch);
384
+ state.daemon.lastStatus = undefined;
385
+ state.daemon.lastPlan = undefined;
386
+ restoreDelegationRunsFromEntries(state, branch);
387
+ }
388
+
389
+ export function inferModeFromUserIntent(text: string): ModeName | undefined {
390
+ const normalized = text.trim().toLowerCase();
391
+ if (!normalized || normalized.startsWith("/")) return undefined;
392
+ const asksForOrchestration = /\b(orchestrator|orchestrat(?:e|ion|or)|orchestrer|multi[- ]?agent|lead(?:s)?|worker(?:s)?|chief vision|coordonn(?:e|er|ation)|d[eé]l[eè]gu(?:e|er|ation)|delegat(?:e|ion)|sub[- ]?agents?|subtasks?|work graph|todo graph|graphe de travail|graphe todo)\b/i.test(normalized);
393
+ if (asksForOrchestration) return "orchestrator";
394
+ const asksForMutation = /\b(update|udpate|modify|modifier|modifie|change|changer|corrige|correction|fix|patch|implement|impl[eé]mente|edit|write|[eé]cris|ajoute|add|create|cr[eé]e|supprime|delete|remove|refactor|refactorise|remplace|am[eé]lior(?:e|er)|appliqu(?:e|er)|mets?|mettre|rends?|rendre|fais\s+en\s+sorte|mets? .*jour|mise .*jour|faire .*update|continue .*update)\b/i.test(normalized);
395
+ if (!asksForMutation) return undefined;
396
+ const factoryIntent = /\b(factory|factory_run|pilot|batch|sentinel|manifest|quarantine|software factory)\b/i.test(normalized);
397
+ return factoryIntent ? "factory" : "implement";
398
+ }
399
+
400
+
401
+ export function bashLooksLikeFileMutation(command: string): boolean {
402
+ return /(^|[^2])>\s*[^&]|>>|\btee\b|\bsed\s+-i\b|\bperl\s+-pi\b|writeFileSync|writeFile\(|write_text\(|open\([^)]*["']w|\bpython3?\b[\s\S]*write|\bnode\b[\s\S]*writeFile/i.test(command);
403
+ }
@@ -0,0 +1,117 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+
3
+ import { AutonomousDryRunParams, AutonomousReadOnlySmokeParams, AutonomousValidateRunParams, AutonomousValidateSmokeParams } from "../schemas.js";
4
+ import { validateAutonomousReadOnlySmokeRunArtifacts, validateAutonomousRuntimeDryRunArtifacts, writeAutonomousReadOnlySmokeRunReport, writeAutonomousRuntimeDryRunReport } from "../autonomous-runtime.js";
5
+
6
+ export function registerAutonomousTools(pi: ExtensionAPI): void {
7
+ pi.registerTool({
8
+ name: "zob_autonomous_dry_run",
9
+ label: "ZOB Autonomous Runtime Dry-Run",
10
+ description: "Build a metadata-only P0 autonomous runtime dry-run: spec gate, context_scope, model routing plan, factory selection, proof plan, and final report plan. No child dispatch, no daemon, no production writes, no live/global routing, no global autonomy claim.",
11
+ parameters: AutonomousDryRunParams,
12
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
13
+ try {
14
+ const report = writeAutonomousRuntimeDryRunReport(ctx.cwd, {
15
+ userNeed: params.user_need,
16
+ refinedSpec: params.refined_spec,
17
+ runId: params.run_id,
18
+ constraints: params.constraints,
19
+ acceptanceCriteria: params.acceptance_criteria,
20
+ expectedArtifacts: params.expected_artifacts,
21
+ allowedPaths: params.allowed_paths,
22
+ forbiddenPaths: params.forbidden_paths,
23
+ allowedSources: params.allowed_sources,
24
+ maxContextTokens: params.max_context_tokens,
25
+ applyPolicy: params.apply_policy,
26
+ budgetProfile: params.budget_profile,
27
+ risk: params.risk,
28
+ authorizedAutonomyLevel: params.authorized_autonomy_level,
29
+ userLaunchConfirmed: params.user_launch_confirmed,
30
+ launchConfirmedAt: params.launch_confirmed_at,
31
+ allowedActions: params.allowed_actions,
32
+ });
33
+ const status = typeof report.status === "string" ? report.status : "unknown";
34
+ const runId = typeof report.runId === "string" ? report.runId : "unknown";
35
+ const reportPath = typeof report.reportPath === "string" ? report.reportPath : "reports/autonomous-runs";
36
+ return { content: [{ type: "text", text: `zob_autonomous_dry_run: ${status} ${runId} -> ${reportPath}` }], details: report };
37
+ } catch (error) {
38
+ const message = error instanceof Error ? error.message : String(error);
39
+ return { content: [{ type: "text", text: `zob_autonomous_dry_run blocked: ${message}` }], details: { status: "blocked", errors: [message], noExecution: true, childDispatchAllowed: false } };
40
+ }
41
+ },
42
+ });
43
+
44
+ pi.registerTool({
45
+ name: "zob_autonomous_readonly_smoke",
46
+ label: "ZOB Autonomous Read-Only Smoke",
47
+ description: "Run a Phase 4A reports-only deterministic autonomous smoke: spec/context/model-routing/factory-selection gates, deterministic factory_run smoke, structural oracle review, validation, and SMOKE_AUTONOMY_PASSED sentinel. No child dispatch, no daemon, no production writes, no live/global routing, no global autonomy claim.",
48
+ parameters: AutonomousReadOnlySmokeParams,
49
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
50
+ try {
51
+ const report = writeAutonomousReadOnlySmokeRunReport(ctx.cwd, {
52
+ userNeed: params.user_need,
53
+ refinedSpec: params.refined_spec,
54
+ runId: params.run_id,
55
+ factoryRunId: params.factory_run_id,
56
+ constraints: params.constraints,
57
+ acceptanceCriteria: params.acceptance_criteria,
58
+ expectedArtifacts: params.expected_artifacts,
59
+ allowedPaths: params.allowed_paths,
60
+ forbiddenPaths: params.forbidden_paths,
61
+ allowedSources: params.allowed_sources,
62
+ maxContextTokens: params.max_context_tokens,
63
+ applyPolicy: params.apply_policy,
64
+ budgetProfile: params.budget_profile,
65
+ risk: params.risk,
66
+ authorizedAutonomyLevel: params.authorized_autonomy_level,
67
+ userLaunchConfirmed: params.user_launch_confirmed,
68
+ launchConfirmedAt: params.launch_confirmed_at,
69
+ allowedActions: params.allowed_actions,
70
+ });
71
+ const status = typeof report.status === "string" ? report.status : "unknown";
72
+ const runId = typeof report.runId === "string" ? report.runId : "unknown";
73
+ const validationPath = typeof report.validationPath === "string" ? report.validationPath : "reports/autonomous-runs";
74
+ return { content: [{ type: "text", text: `zob_autonomous_readonly_smoke: ${status} ${runId} -> ${validationPath}` }], details: report };
75
+ } catch (error) {
76
+ const message = error instanceof Error ? error.message : String(error);
77
+ return { content: [{ type: "text", text: `zob_autonomous_readonly_smoke blocked: ${message}` }], details: { status: "blocked", errors: [message], childDispatchAllowed: false, daemonStarted: false, productionWritesPerformed: false, autoApply: false } };
78
+ }
79
+ },
80
+ });
81
+
82
+ pi.registerTool({
83
+ name: "zob_autonomous_validate_run",
84
+ label: "ZOB Autonomous Dry-Run Artifact Validation",
85
+ description: "Read-only validation for an existing P0 autonomous dry-run artifact set. Checks required artifacts, metadata/hash-only posture, context citations, runtime gates, run graph, factory proof requirements, and no-execution/no-network/no-global-autonomy flags.",
86
+ parameters: AutonomousValidateRunParams,
87
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
88
+ try {
89
+ const validation = validateAutonomousRuntimeDryRunArtifacts(ctx.cwd, params.run_id);
90
+ const status = validation.valid === true ? "valid" : "invalid";
91
+ const failedChecks = Array.isArray(validation.failedChecks) ? validation.failedChecks : [];
92
+ return { content: [{ type: "text", text: failedChecks.length === 0 ? `zob_autonomous_validate_run: ${status} ${params.run_id}` : `zob_autonomous_validate_run: ${status} ${params.run_id}\n- ${failedChecks.join("\n- ")}` }], details: validation };
93
+ } catch (error) {
94
+ const message = error instanceof Error ? error.message : String(error);
95
+ return { content: [{ type: "text", text: `zob_autonomous_validate_run blocked: ${message}` }], details: { status: "blocked", errors: [message], noExecution: true, childDispatchAllowed: false, networkAccessed: false } };
96
+ }
97
+ },
98
+ });
99
+
100
+ pi.registerTool({
101
+ name: "zob_autonomous_validate_smoke",
102
+ label: "ZOB Autonomous Read-Only Smoke Validation",
103
+ description: "Read-only validation for an existing Phase 4A autonomous read-only smoke artifact set. Checks factory-run-ref, structural oracle, validation, sentinels, and no global autonomy flags.",
104
+ parameters: AutonomousValidateSmokeParams,
105
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
106
+ try {
107
+ const validation = validateAutonomousReadOnlySmokeRunArtifacts(ctx.cwd, params.run_id);
108
+ const status = validation.valid === true ? "valid" : "invalid";
109
+ const failedChecks = Array.isArray(validation.failedChecks) ? validation.failedChecks : [];
110
+ return { content: [{ type: "text", text: failedChecks.length === 0 ? `zob_autonomous_validate_smoke: ${status} ${params.run_id}` : `zob_autonomous_validate_smoke: ${status} ${params.run_id}\n- ${failedChecks.join("\n- ")}` }], details: validation };
111
+ } catch (error) {
112
+ const message = error instanceof Error ? error.message : String(error);
113
+ return { content: [{ type: "text", text: `zob_autonomous_validate_smoke blocked: ${message}` }], details: { status: "blocked", errors: [message], childDispatchAllowed: false, networkAccessed: false } };
114
+ }
115
+ },
116
+ });
117
+ }
@@ -0,0 +1,136 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+
3
+ import { buildComputePreview, resolveComputeProfile, validateComputeProfileArtifacts, writeComputeProfileReports } from "../compute-profile.js";
4
+ import { buildComputeWorkflowShape } from "../compute-workflow-shape.js";
5
+ import { ComputePlanWorkflowParams, ComputePreviewParams, ComputeResolveProfileParams, ComputeValidateProfileParams, ComputeWriteProfileReportsParams } from "../schemas.js";
6
+
7
+ export function registerComputeTools(pi: ExtensionAPI): void {
8
+ pi.registerTool({
9
+ name: "zob_compute_preview",
10
+ label: "ZOB Compute Profile Preview",
11
+ description: "Preview task/project complexity and recommend low/medium/high/xhigh/max compute without child dispatch, network access, or source writes.",
12
+ parameters: ComputePreviewParams,
13
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
14
+ try {
15
+ const preview = buildComputePreview(ctx.cwd, {
16
+ runId: params.run_id,
17
+ domain: params.domain,
18
+ requestedProfile: params.requested_profile,
19
+ targetPath: params.target_path,
20
+ taskHash: params.task_hash,
21
+ maxProfile: params.max_profile,
22
+ computeCaps: params.compute_caps,
23
+ riskHints: params.risk_hints,
24
+ });
25
+ const recommended = typeof preview.recommendedProfile === "string" ? preview.recommendedProfile : "unknown";
26
+ const confidence = typeof preview.confidence === "string" ? preview.confidence : "unknown";
27
+ return { content: [{ type: "text", text: `zob_compute_preview: recommended=${recommended} confidence=${confidence}` }], details: preview };
28
+ } catch (error) {
29
+ const message = error instanceof Error ? error.message : String(error);
30
+ return { content: [{ type: "text", text: `zob_compute_preview blocked: ${message}` }], details: { status: "blocked", errors: [message], noExecution: true, childDispatchAllowed: false, networkAccessed: false } };
31
+ }
32
+ },
33
+ });
34
+
35
+ pi.registerTool({
36
+ name: "zob_compute_resolve_profile",
37
+ label: "ZOB Compute Profile Resolve",
38
+ description: "Resolve requested compute profile into an effective profile, hard caps, and gates. Metadata-only; no child dispatch, network access, or source writes.",
39
+ parameters: ComputeResolveProfileParams,
40
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
41
+ try {
42
+ const resolution = resolveComputeProfile(ctx.cwd, {
43
+ runId: params.run_id,
44
+ domain: params.domain,
45
+ requestedProfile: params.requested_profile,
46
+ targetPath: params.target_path,
47
+ taskHash: params.task_hash,
48
+ maxProfile: params.max_profile,
49
+ computeCaps: params.compute_caps,
50
+ riskHints: params.risk_hints,
51
+ });
52
+ const effective = typeof resolution.effectiveProfile === "string" ? resolution.effectiveProfile : "unknown";
53
+ const noShip = resolution.noShip === true ? " no_ship=true" : "";
54
+ return { content: [{ type: "text", text: `zob_compute_resolve_profile: effective=${effective}${noShip}` }], details: resolution };
55
+ } catch (error) {
56
+ const message = error instanceof Error ? error.message : String(error);
57
+ return { content: [{ type: "text", text: `zob_compute_resolve_profile blocked: ${message}` }], details: { status: "blocked", errors: [message], noExecution: true, childDispatchAllowed: false, networkAccessed: false } };
58
+ }
59
+ },
60
+ });
61
+
62
+ pi.registerTool({
63
+ name: "zob_compute_plan_workflow",
64
+ label: "ZOB Compute Workflow Shape",
65
+ description: "Build a metadata-only workflow shape from a resolved compute profile. No child dispatch, network access, or source writes.",
66
+ parameters: ComputePlanWorkflowParams,
67
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
68
+ try {
69
+ const shape = buildComputeWorkflowShape(ctx.cwd, {
70
+ runId: params.run_id,
71
+ domain: params.domain,
72
+ requestedProfile: params.requested_profile,
73
+ targetPath: params.target_path,
74
+ taskHash: params.task_hash,
75
+ maxProfile: params.max_profile,
76
+ computeCaps: params.compute_caps,
77
+ riskHints: params.risk_hints,
78
+ resolutionPath: params.resolution_path,
79
+ });
80
+ const effective = typeof shape.effectiveProfile === "string" ? shape.effectiveProfile : "unknown";
81
+ const laneCount = Array.isArray(shape.lanes) ? shape.lanes.length : 0;
82
+ return { content: [{ type: "text", text: `zob_compute_plan_workflow: effective=${effective} lanes=${laneCount}` }], details: shape };
83
+ } catch (error) {
84
+ const message = error instanceof Error ? error.message : String(error);
85
+ return { content: [{ type: "text", text: `zob_compute_plan_workflow blocked: ${message}` }], details: { status: "blocked", errors: [message], noExecution: true, childDispatchAllowed: false, networkAccessed: false } };
86
+ }
87
+ },
88
+ });
89
+
90
+ pi.registerTool({
91
+ name: "zob_compute_validate_profile",
92
+ label: "ZOB Compute Profile Artifact Validation",
93
+ description: "Validate existing compute-preview/profile-resolution artifacts. Read-only; no execution, network access, or child dispatch.",
94
+ parameters: ComputeValidateProfileParams,
95
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
96
+ try {
97
+ const validation = validateComputeProfileArtifacts(ctx.cwd, {
98
+ previewPath: params.preview_path,
99
+ resolutionPath: params.resolution_path,
100
+ });
101
+ const status = validation.valid === true ? "valid" : "invalid";
102
+ const errors = Array.isArray(validation.errors) ? validation.errors : [];
103
+ return { content: [{ type: "text", text: errors.length === 0 ? `zob_compute_validate_profile: ${status}` : `zob_compute_validate_profile: ${status}\n- ${errors.join("\n- ")}` }], details: validation };
104
+ } catch (error) {
105
+ const message = error instanceof Error ? error.message : String(error);
106
+ return { content: [{ type: "text", text: `zob_compute_validate_profile blocked: ${message}` }], details: { status: "blocked", errors: [message], noExecution: true, childDispatchAllowed: false, networkAccessed: false } };
107
+ }
108
+ },
109
+ });
110
+
111
+ pi.registerTool({
112
+ name: "zob_compute_write_profile_reports",
113
+ label: "ZOB Compute Profile Report Writer",
114
+ description: "Write local metadata-only compute preview/profile-resolution reports under .pi/logs/compute-profile. No child dispatch, network access, or source writes.",
115
+ parameters: ComputeWriteProfileReportsParams,
116
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
117
+ try {
118
+ const report = writeComputeProfileReports(ctx.cwd, {
119
+ runId: params.run_id,
120
+ domain: params.domain,
121
+ requestedProfile: params.requested_profile,
122
+ targetPath: params.target_path,
123
+ taskHash: params.task_hash,
124
+ maxProfile: params.max_profile,
125
+ computeCaps: params.compute_caps,
126
+ riskHints: params.risk_hints,
127
+ });
128
+ const previewPath = typeof report.previewPath === "string" ? report.previewPath : ".pi/logs/compute-profile";
129
+ return { content: [{ type: "text", text: `zob_compute_write_profile_reports: written -> ${previewPath}` }], details: report };
130
+ } catch (error) {
131
+ const message = error instanceof Error ? error.message : String(error);
132
+ return { content: [{ type: "text", text: `zob_compute_write_profile_reports blocked: ${message}` }], details: { status: "blocked", errors: [message], noExecution: true, childDispatchAllowed: false, networkAccessed: false } };
133
+ }
134
+ },
135
+ });
136
+ }