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.
- package/.pi/adapters/registry.json +103 -0
- package/.pi/agents/architecture-cartographer.md +53 -0
- package/.pi/agents/chief-vision.md +39 -0
- package/.pi/agents/clarifier.md +58 -0
- package/.pi/agents/context-steward.md +52 -0
- package/.pi/agents/doc-steward.md +34 -0
- package/.pi/agents/explore.md +49 -0
- package/.pi/agents/factory.md +41 -0
- package/.pi/agents/implementer.md +44 -0
- package/.pi/agents/librarian.md +32 -0
- package/.pi/agents/oracle-merge.md +50 -0
- package/.pi/agents/oracle.md +55 -0
- package/.pi/agents/pattern-miner.md +53 -0
- package/.pi/agents/planner.md +39 -0
- package/.pi/agents/project-dna-golden-evaluator.md +32 -0
- package/.pi/agents/project-dna-ontology-steward.md +30 -0
- package/.pi/agents/project-dna-oracle.md +56 -0
- package/.pi/agents/project-dna-orchestrator.md +60 -0
- package/.pi/agents/project-dna-query-steward.md +38 -0
- package/.pi/agents/project-dna-safety-preflight.md +54 -0
- package/.pi/agents/project-dna-test-linker.md +27 -0
- package/.pi/agents/qa.md +38 -0
- package/.pi/agents/refactor-cartographer.md +28 -0
- package/.pi/agents/refactor-mover.md +31 -0
- package/.pi/agents/refactor-oracle.md +49 -0
- package/.pi/agents/repo-scout.md +60 -0
- package/.pi/agents/sample-architect.md +48 -0
- package/.pi/agents/specifier.md +57 -0
- package/.pi/agents/symbol-range-curator.md +41 -0
- package/.pi/agents/synthesis.md +52 -0
- package/.pi/agents/temp-agent-creator.md +35 -0
- package/.pi/autonomy-policy.json +67 -0
- package/.pi/budget-policy.json +54 -0
- package/.pi/capabilities/zob-public-runtime-capabilities.json +1700 -0
- package/.pi/chains/explore-plan-oracle.json +78 -0
- package/.pi/chains/explore-spec-clarify-plan-oracle.json +64 -0
- package/.pi/chains/explore-spec-plan-oracle.json +53 -0
- package/.pi/chains/spec-clarify-plan-oracle.json +53 -0
- package/.pi/chains/spec-factory-oracle.json +42 -0
- package/.pi/chains/spec-plan-oracle.json +42 -0
- package/.pi/compute-profiles/defaults.json +19 -0
- package/.pi/compute-profiles/overrides.json +13 -0
- package/.pi/compute-profiles/risk-rules.json +16 -0
- package/.pi/daemon-policy.json +80 -0
- package/.pi/damage-control-rules.json +45 -0
- package/.pi/extensions/zob-child-safety/index.ts +212 -0
- package/.pi/extensions/zob-harness/AGENTS.md +28 -0
- package/.pi/extensions/zob-harness/index.ts +391 -0
- package/.pi/extensions/zob-harness/src/AGENTS.md +25 -0
- package/.pi/extensions/zob-harness/src/agents.ts +82 -0
- package/.pi/extensions/zob-harness/src/autonomous-runtime.ts +2912 -0
- package/.pi/extensions/zob-harness/src/autonomy-readiness.ts +778 -0
- package/.pi/extensions/zob-harness/src/budget-policy.ts +308 -0
- package/.pi/extensions/zob-harness/src/capabilities.ts +249 -0
- package/.pi/extensions/zob-harness/src/child-runner.ts +249 -0
- package/.pi/extensions/zob-harness/src/chronicle.ts +262 -0
- package/.pi/extensions/zob-harness/src/compute-profile.ts +602 -0
- package/.pi/extensions/zob-harness/src/compute-workflow-shape.ts +168 -0
- package/.pi/extensions/zob-harness/src/coms-v2/AGENTS.md +16 -0
- package/.pi/extensions/zob-harness/src/coms-v2/envelope.ts +121 -0
- package/.pi/extensions/zob-harness/src/coms-v2/identity.ts +53 -0
- package/.pi/extensions/zob-harness/src/coms-v2/ledger-bridge.ts +67 -0
- package/.pi/extensions/zob-harness/src/coms-v2/local-transport.ts +147 -0
- package/.pi/extensions/zob-harness/src/coms-v2/pending-replies.ts +80 -0
- package/.pi/extensions/zob-harness/src/coms-v2/policy.ts +125 -0
- package/.pi/extensions/zob-harness/src/coms-v2/presence.ts +55 -0
- package/.pi/extensions/zob-harness/src/coms-v2/registry.ts +113 -0
- package/.pi/extensions/zob-harness/src/coms-v2/response-capture.ts +50 -0
- package/.pi/extensions/zob-harness/src/coms-v2/transcript-capture.ts +164 -0
- package/.pi/extensions/zob-harness/src/coms-v2/types.ts +149 -0
- package/.pi/extensions/zob-harness/src/coms-v2/zpeer-profile.ts +140 -0
- package/.pi/extensions/zob-harness/src/coms-v2/zpeer.ts +452 -0
- package/.pi/extensions/zob-harness/src/constants.ts +108 -0
- package/.pi/extensions/zob-harness/src/context-gbrain.ts +465 -0
- package/.pi/extensions/zob-harness/src/daemon-policy.ts +223 -0
- package/.pi/extensions/zob-harness/src/daemon-readiness.ts +134 -0
- package/.pi/extensions/zob-harness/src/daemon-runtime.ts +393 -0
- package/.pi/extensions/zob-harness/src/factory/AGENTS.md +24 -0
- package/.pi/extensions/zob-harness/src/factory/agentic-plan.ts +65 -0
- package/.pi/extensions/zob-harness/src/factory/quarantine.ts +319 -0
- package/.pi/extensions/zob-harness/src/factory/run.ts +520 -0
- package/.pi/extensions/zob-harness/src/factory/validation.ts +454 -0
- package/.pi/extensions/zob-harness/src/factory-selector.ts +318 -0
- package/.pi/extensions/zob-harness/src/full-autonomy-test.ts +226 -0
- package/.pi/extensions/zob-harness/src/git-ops.ts +868 -0
- package/.pi/extensions/zob-harness/src/goal-room.ts +178 -0
- package/.pi/extensions/zob-harness/src/goal-runtime.ts +1569 -0
- package/.pi/extensions/zob-harness/src/goal-todo-imports.ts +111 -0
- package/.pi/extensions/zob-harness/src/goal-todo-types.ts +231 -0
- package/.pi/extensions/zob-harness/src/goal-todos.ts +1410 -0
- package/.pi/extensions/zob-harness/src/goal.ts +152 -0
- package/.pi/extensions/zob-harness/src/governed-requests.ts +436 -0
- package/.pi/extensions/zob-harness/src/interactive-autonomy.ts +595 -0
- package/.pi/extensions/zob-harness/src/launch-apply.ts +313 -0
- package/.pi/extensions/zob-harness/src/merge-queue.ts +290 -0
- package/.pi/extensions/zob-harness/src/mission-control.ts +573 -0
- package/.pi/extensions/zob-harness/src/model-availability.ts +52 -0
- package/.pi/extensions/zob-harness/src/model-routing.ts +429 -0
- package/.pi/extensions/zob-harness/src/orchestration/AGENTS.md +23 -0
- package/.pi/extensions/zob-harness/src/orchestration/adaptive-delegation.ts +547 -0
- package/.pi/extensions/zob-harness/src/orchestration/adaptive-workflow.ts +585 -0
- package/.pi/extensions/zob-harness/src/orchestration/lead-plan.ts +192 -0
- package/.pi/extensions/zob-harness/src/orchestration/plan.ts +168 -0
- package/.pi/extensions/zob-harness/src/orchestration/room.ts +346 -0
- package/.pi/extensions/zob-harness/src/orchestration/run.ts +134 -0
- package/.pi/extensions/zob-harness/src/orchestration/supervised-readonly.ts +1147 -0
- package/.pi/extensions/zob-harness/src/orchestration/widget-readers.ts +132 -0
- package/.pi/extensions/zob-harness/src/output-contracts.ts +656 -0
- package/.pi/extensions/zob-harness/src/project-dna.ts +533 -0
- package/.pi/extensions/zob-harness/src/promotion/AGENTS.md +24 -0
- package/.pi/extensions/zob-harness/src/promotion/candidate.ts +336 -0
- package/.pi/extensions/zob-harness/src/promotion/coms.ts +127 -0
- package/.pi/extensions/zob-harness/src/promotion/documentation.ts +142 -0
- package/.pi/extensions/zob-harness/src/promotion/factory.ts +107 -0
- package/.pi/extensions/zob-harness/src/promotion/ledger.ts +2 -0
- package/.pi/extensions/zob-harness/src/promotion/temp-agent.ts +151 -0
- package/.pi/extensions/zob-harness/src/promotion/types.ts +149 -0
- package/.pi/extensions/zob-harness/src/promotion/validate.ts +6 -0
- package/.pi/extensions/zob-harness/src/promotion/write-lane.ts +162 -0
- package/.pi/extensions/zob-harness/src/prompt-packs.ts +239 -0
- package/.pi/extensions/zob-harness/src/queue.ts +386 -0
- package/.pi/extensions/zob-harness/src/rules.ts +225 -0
- package/.pi/extensions/zob-harness/src/runtime/AGENTS.md +26 -0
- package/.pi/extensions/zob-harness/src/runtime/adaptive-zmode.ts +116 -0
- package/.pi/extensions/zob-harness/src/runtime/auto-compaction.ts +715 -0
- package/.pi/extensions/zob-harness/src/runtime/commands.ts +1315 -0
- package/.pi/extensions/zob-harness/src/runtime/compaction-policy.ts +516 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-click-markers.ts +141 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-feed.ts +415 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-markdown.ts +97 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-monitor.ts +553 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-mouse.ts +205 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-overlay.ts +434 -0
- package/.pi/extensions/zob-harness/src/runtime/events.ts +736 -0
- package/.pi/extensions/zob-harness/src/runtime/goal-todo-overlay.ts +214 -0
- package/.pi/extensions/zob-harness/src/runtime/mode-intent.ts +144 -0
- package/.pi/extensions/zob-harness/src/runtime/plan-capture.ts +270 -0
- package/.pi/extensions/zob-harness/src/runtime/state.ts +403 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-autonomous.ts +117 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-compute.ts +136 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-coms.ts +365 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-context.ts +70 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-delegation.ts +1854 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-factory.ts +810 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-goal-room.ts +46 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-governed-requests.ts +38 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-merge-queue.ts +61 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-mission-control.ts +77 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-orchestration.ts +106 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-project-dna.ts +123 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-worker-pool.ts +93 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-workspace-claims.ts +62 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-zcommit.ts +147 -0
- package/.pi/extensions/zob-harness/src/runtime/widget.ts +353 -0
- package/.pi/extensions/zob-harness/src/runtime/zobHarness.ts +60 -0
- package/.pi/extensions/zob-harness/src/safety.ts +338 -0
- package/.pi/extensions/zob-harness/src/sandbox.ts +1508 -0
- package/.pi/extensions/zob-harness/src/schemas-project-dna.ts +47 -0
- package/.pi/extensions/zob-harness/src/schemas.ts +695 -0
- package/.pi/extensions/zob-harness/src/telemetry.ts +373 -0
- package/.pi/extensions/zob-harness/src/topology/AGENTS.md +22 -0
- package/.pi/extensions/zob-harness/src/topology/chains.ts +236 -0
- package/.pi/extensions/zob-harness/src/topology/coms.ts +211 -0
- package/.pi/extensions/zob-harness/src/topology/orchestration-profiles.ts +204 -0
- package/.pi/extensions/zob-harness/src/topology/teams.ts +113 -0
- package/.pi/extensions/zob-harness/src/types/core.ts +47 -0
- package/.pi/extensions/zob-harness/src/types.ts +939 -0
- package/.pi/extensions/zob-harness/src/utils/AGENTS.md +22 -0
- package/.pi/extensions/zob-harness/src/utils/formatting.ts +34 -0
- package/.pi/extensions/zob-harness/src/utils/hashing.ts +11 -0
- package/.pi/extensions/zob-harness/src/utils/json.ts +28 -0
- package/.pi/extensions/zob-harness/src/utils/paths.ts +54 -0
- package/.pi/extensions/zob-harness/src/utils/records.ts +25 -0
- package/.pi/extensions/zob-harness/src/utils/resources.ts +38 -0
- package/.pi/extensions/zob-harness/src/worker-pool.ts +672 -0
- package/.pi/extensions/zob-harness/src/workspace-claims.ts +297 -0
- package/.pi/extensions/zob-switch/index.ts +180 -0
- package/.pi/factories/budget-preflight-dry-run/batch-manifest.json +59 -0
- package/.pi/factories/budget-preflight-dry-run/factory.json +94 -0
- package/.pi/factories/budget-preflight-dry-run/pilot-manifest.json +50 -0
- package/.pi/factories/budget-preflight-dry-run/smoke-manifest.json +43 -0
- package/.pi/factories/code-review-matrix/batch-manifest.json +61 -0
- package/.pi/factories/code-review-matrix/factory.json +163 -0
- package/.pi/factories/code-review-matrix/pilot-manifest.json +41 -0
- package/.pi/factories/code-review-matrix/smoke-manifest.json +35 -0
- package/.pi/factories/factory-forge/batch-manifest.json +56 -0
- package/.pi/factories/factory-forge/factory.json +84 -0
- package/.pi/factories/factory-forge/pilot-manifest.json +32 -0
- package/.pi/factories/factory-forge/smoke-manifest.json +19 -0
- package/.pi/factories/opencode-pattern-canonizer/batch-manifest.json +54 -0
- package/.pi/factories/opencode-pattern-canonizer/factory.json +86 -0
- package/.pi/factories/opencode-pattern-canonizer/pilot-manifest.json +39 -0
- package/.pi/factories/opencode-pattern-canonizer/smoke-manifest.json +26 -0
- package/.pi/factories/project-dna/README.md +182 -0
- package/.pi/factories/project-dna/batch-manifest.json +37 -0
- package/.pi/factories/project-dna/example-project-dna-manifest-v2.json +80 -0
- package/.pi/factories/project-dna/example-project-dna-manifest.json +58 -0
- package/.pi/factories/project-dna/factory.json +131 -0
- package/.pi/factories/project-dna/golden-cases-smoke.json +62 -0
- package/.pi/factories/project-dna/pi-agentic-ontology.json +88 -0
- package/.pi/factories/project-dna/pilot-manifest.json +32 -0
- package/.pi/factories/project-dna/schemas/benchmark-suite.schema.json +27 -0
- package/.pi/factories/project-dna/schemas/code-knowledge-graph.schema.json +97 -0
- package/.pi/factories/project-dna/schemas/context-pack.schema.json +43 -0
- package/.pi/factories/project-dna/schemas/golden-case.schema.json +36 -0
- package/.pi/factories/project-dna/schemas/manifest-v2.schema.json +128 -0
- package/.pi/factories/project-dna/schemas/manifest.schema.json +77 -0
- package/.pi/factories/project-dna/schemas/ontology.schema.json +45 -0
- package/.pi/factories/project-dna/schemas/project-fingerprint.schema.json +28 -0
- package/.pi/factories/project-dna/schemas/query-steward-report.schema.json +52 -0
- package/.pi/factories/project-dna/smoke-manifest.json +27 -0
- package/.pi/factories/roadmap-smoke-lots/batch-manifest.json +49 -0
- package/.pi/factories/roadmap-smoke-lots/factory.json +89 -0
- package/.pi/factories/roadmap-smoke-lots/pilot-manifest.json +50 -0
- package/.pi/factories/roadmap-smoke-lots/smoke-manifest.json +35 -0
- package/.pi/git-policy.json +120 -0
- package/.pi/mission-control/zob_coms_transport.json +64 -0
- package/.pi/model-catalog.example.json +345 -0
- package/.pi/model-economy.example.json +196 -0
- package/.pi/model-routing.json +86 -0
- package/.pi/orchestrations/adaptive-chief-vision.json +193 -0
- package/.pi/orchestrations/ceo-feature-build.json +182 -0
- package/.pi/orchestrations/readonly-dynamic-smoke.json +75 -0
- package/.pi/output-contracts/agent-event.v1.json +19 -0
- package/.pi/output-contracts/base.v1.json +24 -0
- package/.pi/output-contracts/brain-lookup.v1.json +21 -0
- package/.pi/output-contracts/clarification.v1.json +21 -0
- package/.pi/output-contracts/context-pack.v1.json +20 -0
- package/.pi/output-contracts/context-request.v1.json +21 -0
- package/.pi/output-contracts/context-steward.v1.json +19 -0
- package/.pi/output-contracts/context-writeback-proposal.v1.json +18 -0
- package/.pi/output-contracts/delegation-request.v1.json +21 -0
- package/.pi/output-contracts/explore.v1.json +52 -0
- package/.pi/output-contracts/factory.v1.json +48 -0
- package/.pi/output-contracts/guidance-steward.v1.json +18 -0
- package/.pi/output-contracts/implement.v1.json +40 -0
- package/.pi/output-contracts/launch-authorization.v1.json +21 -0
- package/.pi/output-contracts/lead-plan.v1.json +22 -0
- package/.pi/output-contracts/mission-readiness.v1.json +20 -0
- package/.pi/output-contracts/oracle-merge.v1.json +44 -0
- package/.pi/output-contracts/oracle-request.v1.json +20 -0
- package/.pi/output-contracts/oracle.v1.json +44 -0
- package/.pi/output-contracts/orchestration-profile.v1.json +22 -0
- package/.pi/output-contracts/plan.v1.json +48 -0
- package/.pi/output-contracts/prompt-pack.v1.json +20 -0
- package/.pi/output-contracts/qa.v1.json +40 -0
- package/.pi/output-contracts/research.v1.json +36 -0
- package/.pi/output-contracts/spec.v1.json +22 -0
- package/.pi/output-contracts/synthesis.v1.json +44 -0
- package/.pi/output-contracts/temp-agent-card.v1.json +23 -0
- package/.pi/output-contracts/todo-child-result.v1.json +20 -0
- package/.pi/output-contracts/todo-child-result.v2.json +22 -0
- package/.pi/output-contracts/todo-claim-validation.v1.json +22 -0
- package/.pi/output-contracts/todo-split-request.v1.json +20 -0
- package/.pi/prompts/adaptive-workflow.md +63 -0
- package/.pi/prompts/autonomous-runtime.md +15 -0
- package/.pi/prompts/benchmark-contender.md +15 -0
- package/.pi/prompts/benchmark-judge.md +19 -0
- package/.pi/prompts/clarify-spec.md +20 -0
- package/.pi/prompts/compute-plan.md +36 -0
- package/.pi/prompts/compute-preview.md +42 -0
- package/.pi/prompts/contract.md +29 -0
- package/.pi/prompts/explore.md +13 -0
- package/.pi/prompts/factory-run.md +36 -0
- package/.pi/prompts/factory.md +20 -0
- package/.pi/prompts/implement.md +27 -0
- package/.pi/prompts/model-catalog.md +68 -0
- package/.pi/prompts/model-economy.md +64 -0
- package/.pi/prompts/oracle-merge.md +18 -0
- package/.pi/prompts/oracle.md +13 -0
- package/.pi/prompts/orchestrator.md +48 -0
- package/.pi/prompts/parallel-review.md +21 -0
- package/.pi/prompts/plan.md +21 -0
- package/.pi/prompts/project-dna.md +90 -0
- package/.pi/prompts/refactor-oracle.md +23 -0
- package/.pi/prompts/refactor-slice.md +24 -0
- package/.pi/prompts/research.md +20 -0
- package/.pi/prompts/spec.md +19 -0
- package/.pi/prompts/synthesis.md +18 -0
- package/.pi/rules/always.md +38 -0
- package/.pi/rules/docs.md +32 -0
- package/.pi/rules/factory.md +44 -0
- package/.pi/rules/oracle.md +34 -0
- package/.pi/rules/orchestration.md +44 -0
- package/.pi/rules/project.md +34 -0
- package/.pi/rules/prompts.md +43 -0
- package/.pi/rules/runtime.md +43 -0
- package/.pi/rules/sandbox.md +43 -0
- package/.pi/settings.json +28 -0
- package/.pi/skills/zob-agentic-access/SKILL.md +20 -0
- package/.pi/skills/zob-autonomous-runtime/SKILL.md +41 -0
- package/.pi/skills/zob-commit/SKILL.md +79 -0
- package/.pi/skills/zob-compaction-policy/SKILL.md +92 -0
- package/.pi/skills/zob-compute-profile/SKILL.md +108 -0
- package/.pi/skills/zob-coms-safety/SKILL.md +54 -0
- package/.pi/skills/zob-coms-v2-live/SKILL.md +47 -0
- package/.pi/skills/zob-delegation-routing/SKILL.md +82 -0
- package/.pi/skills/zob-factory/SKILL.md +28 -0
- package/.pi/skills/zob-goal-todo-tree/SKILL.md +279 -0
- package/.pi/skills/zob-harness/SKILL.md +68 -0
- package/.pi/skills/zob-mission-control-coms/SKILL.md +39 -0
- package/.pi/skills/zob-oracle/SKILL.md +21 -0
- package/.pi/skills/zob-owner-pool-drill-writer/SKILL.md +244 -0
- package/.pi/skills/zob-owner-pool-launcher/SKILL.md +261 -0
- package/.pi/skills/zob-project-dna/SKILL.md +275 -0
- package/.pi/skills/zob-sandbox/SKILL.md +29 -0
- package/.pi/skills/zob-spec/SKILL.md +25 -0
- package/.pi/skills/zob-split-refactor/SKILL.md +39 -0
- package/.pi/skills/zob-tool-router/SKILL.md +104 -0
- package/.pi/teams/zob-core.json +122 -0
- package/AGENTS.md +89 -0
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +21 -0
- package/README.md +360 -0
- package/SECURITY.md +35 -0
- package/SOURCE_INDEX.md +46 -0
- package/package.json +135 -0
- package/scripts/README.md +57 -0
- package/scripts/autonomy/mission-readiness-secret-smoke.mjs +90 -0
- package/scripts/compute-profile/plan-workflow.mjs +85 -0
- package/scripts/compute-profile/preview.mjs +242 -0
- package/scripts/compute-profile/regression-smoke.mjs +38 -0
- package/scripts/compute-profile/summarize.mjs +72 -0
- package/scripts/compute-profile/validate-policy.mjs +50 -0
- package/scripts/compute-profile/validate-preview.mjs +95 -0
- package/scripts/compute-profile/validate-workflow.mjs +58 -0
- package/scripts/git-ops/commit-policy-smoke.mjs +221 -0
- package/scripts/goal-todo/child-goal-ref-smoke.mjs +252 -0
- package/scripts/harness-switch/static-smoke.mjs +43 -0
- package/scripts/model-catalog/validate-economy.mjs +223 -0
- package/scripts/model-catalog/validate.mjs +199 -0
- package/scripts/package-surface/validate-script-refs.mjs +190 -0
- package/scripts/path-policy/validate-smoke.mjs +103 -0
- package/scripts/project-dna/bench-smoke.mjs +217 -0
- package/scripts/project-dna/build-capsules.mjs +207 -0
- package/scripts/project-dna/build-sample-spec.mjs +140 -0
- package/scripts/project-dna/emit-golden-cases.mjs +75 -0
- package/scripts/project-dna/emit-ontology.mjs +75 -0
- package/scripts/project-dna/generate-sample.mjs +302 -0
- package/scripts/project-dna/oracle-review-smoke.mjs +157 -0
- package/scripts/project-dna/plan-workflow.mjs +289 -0
- package/scripts/project-dna/query-context.mjs +276 -0
- package/scripts/project-dna/query-steward.mjs +149 -0
- package/scripts/project-dna/scan.mjs +553 -0
- package/scripts/project-dna/validate-5of5.mjs +159 -0
- package/scripts/project-dna/validate-golden-cases.mjs +78 -0
- package/scripts/project-dna/validate-ontology.mjs +97 -0
- package/scripts/project-dna/validate-sample-project.mjs +105 -0
- package/scripts/project-dna/validate-scaffold.mjs +383 -0
- package/scripts/project-dna/validate-scan-artifacts.mjs +187 -0
- package/scripts/project-dna/validate-workflow.mjs +166 -0
- package/scripts/start-pi.sh +4 -0
- package/scripts/worker-pool/static-smoke.mjs +54 -0
- package/scripts/zpeer-local-e2e-smoke.mjs +395 -0
- package/scripts/zpeer-static-smoke.mjs +129 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import { buildZcommitPlan, runGovernedZcommitCommit, runGovernedZcommitPush, type ZcommitCommandResult, type ZcommitPlan, type ZcommitPlanOptions } from "../git-ops.js";
|
|
4
|
+
import { ZcommitRunParams } from "../schemas.js";
|
|
5
|
+
import type { HarnessRuntimeState } from "./state.js";
|
|
6
|
+
import { sha256 } from "../utils/hashing.js";
|
|
7
|
+
|
|
8
|
+
function uniqueSorted(values: string[]): string[] {
|
|
9
|
+
return [...new Set(values.filter((value) => value.trim().length > 0))].sort();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function sessionModifiedPathspecs(state: HarnessRuntimeState): string[] {
|
|
13
|
+
const sessionStartedAt = Date.parse(state.zcommit.sessionStartedAt ?? "");
|
|
14
|
+
const touched = Object.keys(state.zcommit.touchedFiles ?? {});
|
|
15
|
+
const ownedThisSession = Object.values(state.zcommit.ownedPathRefs ?? {})
|
|
16
|
+
.filter((ref) => {
|
|
17
|
+
if (Number.isNaN(sessionStartedAt)) return true;
|
|
18
|
+
const lastOwnedAt = Date.parse(ref.lastOwnedAt);
|
|
19
|
+
return !Number.isNaN(lastOwnedAt) && lastOwnedAt >= sessionStartedAt;
|
|
20
|
+
})
|
|
21
|
+
.map((ref) => ref.path);
|
|
22
|
+
return uniqueSorted([...touched, ...ownedThisSession]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function resolvePathspecs(state: HarnessRuntimeState, scope: string | undefined, paths: string[] | undefined): { pathspecs: string[]; errors: string[] } {
|
|
26
|
+
const selectedScope = scope ?? (paths && paths.length > 0 ? "pathspecs" : "all_safe_dirty");
|
|
27
|
+
if (selectedScope === "all_safe_dirty") return { pathspecs: [], errors: [] };
|
|
28
|
+
if (selectedScope === "pathspecs") {
|
|
29
|
+
if (!paths || paths.length === 0) return { pathspecs: [], errors: ["scope=pathspecs requires non-empty paths"] };
|
|
30
|
+
return { pathspecs: uniqueSorted(paths), errors: [] };
|
|
31
|
+
}
|
|
32
|
+
if (selectedScope === "session_modified") {
|
|
33
|
+
const sessionPaths = sessionModifiedPathspecs(state);
|
|
34
|
+
if (paths && paths.length > 0) {
|
|
35
|
+
const allowed = new Set(sessionPaths);
|
|
36
|
+
const requested = uniqueSorted(paths);
|
|
37
|
+
const outside = requested.filter((path) => !allowed.has(path));
|
|
38
|
+
if (outside.length > 0) return { pathspecs: requested.filter((path) => allowed.has(path)), errors: outside.map((path) => `path is not recorded as modified in this session: ${path}`) };
|
|
39
|
+
return { pathspecs: requested, errors: [] };
|
|
40
|
+
}
|
|
41
|
+
if (sessionPaths.length === 0) return { pathspecs: [], errors: ["scope=session_modified found no current-session modified paths; use scope=pathspecs or all_safe_dirty"] };
|
|
42
|
+
return { pathspecs: sessionPaths, errors: [] };
|
|
43
|
+
}
|
|
44
|
+
return { pathspecs: [], errors: [`unknown zcommit scope: ${selectedScope}`] };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function zcommitLedgerEntry(action: string, scope: string, params: { paths?: string[]; message?: string; body?: string[]; user_requested?: boolean }, plan: ZcommitPlan, result?: ZcommitCommandResult): Record<string, unknown> {
|
|
48
|
+
return {
|
|
49
|
+
schema: "zob.zcommit-tool.v1",
|
|
50
|
+
bodyStored: false,
|
|
51
|
+
action,
|
|
52
|
+
scope,
|
|
53
|
+
status: result ? (result.ok ? "ok" : "blocked_or_failed") : "planned",
|
|
54
|
+
userRequested: params.user_requested === true,
|
|
55
|
+
policyLoaded: plan.policyLoaded,
|
|
56
|
+
selectionMode: plan.selectionMode,
|
|
57
|
+
validationMode: plan.validationMode,
|
|
58
|
+
selectionPathspecHashes: plan.selectionPathspecs.map((pathspec) => sha256(pathspec)),
|
|
59
|
+
requestedPathHashes: (params.paths ?? []).map((path) => sha256(path)),
|
|
60
|
+
messageHash: params.message ? sha256(params.message) : undefined,
|
|
61
|
+
bodyLineHashes: (params.body ?? []).map((line) => sha256(line)),
|
|
62
|
+
eligibleCount: plan.eligible.length,
|
|
63
|
+
excludedCount: plan.excluded.length,
|
|
64
|
+
forbiddenCount: plan.forbidden.length,
|
|
65
|
+
unexpectedStagedCount: plan.unexpectedStaged.length,
|
|
66
|
+
noShip: plan.noShip,
|
|
67
|
+
commitEnabled: plan.commitEnabled,
|
|
68
|
+
pushEnabled: plan.pushEnabled,
|
|
69
|
+
validationOk: result?.validation?.ok,
|
|
70
|
+
lastCommitHash: result?.commit?.hash,
|
|
71
|
+
lastCommitShortHash: result?.commit?.shortHash,
|
|
72
|
+
errorHashes: result?.errors.map((error) => sha256(error)),
|
|
73
|
+
actualGitCommitRun: result?.actualGitCommitRun ?? false,
|
|
74
|
+
actualGitPushRun: result?.actualGitPushRun ?? false,
|
|
75
|
+
generatedAt: new Date().toISOString(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function planSummary(plan: ZcommitPlan): string {
|
|
80
|
+
const commit = `${plan.conventionalCommit.type}(${plan.conventionalCommit.scope}): ${plan.conventionalCommit.subject}`;
|
|
81
|
+
const pathspecs = plan.selectionPathspecs.join(", ") || "all-safe-dirty";
|
|
82
|
+
return `mode=${plan.selectionMode} scope_pathspecs=[${pathspecs}] eligible=${plan.eligible.length} excluded=${plan.excluded.length} forbidden=${plan.forbidden.length} commit=${plan.commitEnabled ? "ready" : "blocked"} conventional_commit="${commit}"`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function registerZcommitTools(pi: ExtensionAPI, state: HarnessRuntimeState): void {
|
|
86
|
+
pi.registerTool({
|
|
87
|
+
name: "zob_zcommit_run",
|
|
88
|
+
label: "ZOB Zcommit Run",
|
|
89
|
+
description: "Agent-executable governed zcommit workflow. Plan, commit, push, or commit_and_push via the /zcommit engine when the user explicitly asks; never use direct git commit/push/tag or global staging.",
|
|
90
|
+
promptSnippet: "Use zob_zcommit_run when the user asks you to commit/push. Prefer action=commit_and_push with scope=session_modified or paths; do not ask the user to paste /zcommit commands.",
|
|
91
|
+
parameters: ZcommitRunParams,
|
|
92
|
+
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
93
|
+
const action = params.action ?? "plan";
|
|
94
|
+
const scope = params.scope ?? (params.paths && params.paths.length > 0 ? "pathspecs" : "all_safe_dirty");
|
|
95
|
+
const { pathspecs, errors } = resolvePathspecs(state, scope, params.paths);
|
|
96
|
+
const options: ZcommitPlanOptions = { pathspecs, message: params.message, body: params.body };
|
|
97
|
+
const plan = buildZcommitPlan(ctx.cwd, state.zcommit, options);
|
|
98
|
+
if (errors.length > 0) {
|
|
99
|
+
pi.appendEntry("zob-zcommit", zcommitLedgerEntry(action, scope, params, plan));
|
|
100
|
+
return { content: [{ type: "text", text: `zob_zcommit_run blocked: ${errors.join(" | ")}; ${planSummary(plan)}` }], details: { schema: "zob.zcommit-tool-result.v1", status: "blocked", errors, plan } };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const wantsCommit = action === "commit" || action === "commit_and_push";
|
|
104
|
+
const wantsPush = action === "push" || action === "commit_and_push" || params.push === true;
|
|
105
|
+
if ((wantsCommit || wantsPush) && params.user_requested !== true && state.zcommit.autocommit !== "on") {
|
|
106
|
+
const authorizationErrors = ["commit/push actions require user_requested=true or /zcommit autocommit on"];
|
|
107
|
+
pi.appendEntry("zob-zcommit", zcommitLedgerEntry(action, scope, params, plan));
|
|
108
|
+
return { content: [{ type: "text", text: `zob_zcommit_run blocked: ${authorizationErrors.join(" | ")}; ${planSummary(plan)}` }], details: { schema: "zob.zcommit-tool-result.v1", status: "blocked", errors: authorizationErrors, plan } };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (action === "plan") {
|
|
112
|
+
pi.appendEntry("zob-zcommit", zcommitLedgerEntry("tool_plan", scope, params, plan));
|
|
113
|
+
return { content: [{ type: "text", text: `zob_zcommit_run plan: ${planSummary(plan)}` }], details: { schema: "zob.zcommit-tool-result.v1", status: "planned", plan } };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (action === "commit") {
|
|
117
|
+
const result = runGovernedZcommitCommit(ctx.cwd, state.zcommit, options);
|
|
118
|
+
pi.appendEntry("zob-zcommit", zcommitLedgerEntry(result.ok ? "tool_commit_created" : "tool_commit_blocked", scope, params, result.plan, result));
|
|
119
|
+
if (params.push === true && result.ok) {
|
|
120
|
+
const pushResult = runGovernedZcommitPush(ctx.cwd, state.zcommit, { explicitPush: true });
|
|
121
|
+
pi.appendEntry("zob-zcommit", zcommitLedgerEntry(pushResult.ok ? "tool_push_completed" : "tool_push_blocked", scope, params, pushResult.plan, pushResult));
|
|
122
|
+
return { content: [{ type: "text", text: `zob_zcommit_run commit+push: ${result.message}; ${pushResult.message}` }], details: { schema: "zob.zcommit-tool-result.v1", status: pushResult.ok ? "ok" : "blocked_or_failed", commitResult: result, pushResult } };
|
|
123
|
+
}
|
|
124
|
+
return { content: [{ type: "text", text: `zob_zcommit_run commit: ${result.message}` }], details: { schema: "zob.zcommit-tool-result.v1", status: result.ok ? "ok" : "blocked_or_failed", result } };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (action === "push") {
|
|
128
|
+
const result = runGovernedZcommitPush(ctx.cwd, state.zcommit, { explicitPush: true });
|
|
129
|
+
pi.appendEntry("zob-zcommit", zcommitLedgerEntry(result.ok ? "tool_push_completed" : "tool_push_blocked", scope, params, result.plan, result));
|
|
130
|
+
return { content: [{ type: "text", text: `zob_zcommit_run push: ${result.message}` }], details: { schema: "zob.zcommit-tool-result.v1", status: result.ok ? "ok" : "blocked_or_failed", result } };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (action === "commit_and_push") {
|
|
134
|
+
const commitResult = runGovernedZcommitCommit(ctx.cwd, state.zcommit, options);
|
|
135
|
+
pi.appendEntry("zob-zcommit", zcommitLedgerEntry(commitResult.ok ? "tool_commit_created" : "tool_commit_blocked", scope, params, commitResult.plan, commitResult));
|
|
136
|
+
if (!commitResult.ok) return { content: [{ type: "text", text: `zob_zcommit_run commit_and_push blocked during commit: ${commitResult.message}` }], details: { schema: "zob.zcommit-tool-result.v1", status: "blocked_or_failed", commitResult } };
|
|
137
|
+
const pushResult = runGovernedZcommitPush(ctx.cwd, state.zcommit, { explicitPush: true });
|
|
138
|
+
pi.appendEntry("zob-zcommit", zcommitLedgerEntry(pushResult.ok ? "tool_push_completed" : "tool_push_blocked", scope, params, pushResult.plan, pushResult));
|
|
139
|
+
return { content: [{ type: "text", text: `zob_zcommit_run commit_and_push: ${commitResult.message}; ${pushResult.message}` }], details: { schema: "zob.zcommit-tool-result.v1", status: pushResult.ok ? "ok" : "blocked_or_failed", commitResult, pushResult } };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const unknownErrors = [`unknown zcommit action: ${action}`];
|
|
143
|
+
pi.appendEntry("zob-zcommit", zcommitLedgerEntry("tool_unknown_action", scope, params, plan));
|
|
144
|
+
return { content: [{ type: "text", text: `zob_zcommit_run blocked: ${unknownErrors.join(" | ")}` }], details: { schema: "zob.zcommit-tool-result.v1", status: "blocked", errors: unknownErrors, plan } };
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
|
|
4
|
+
import { MODE_TOOLS } from "../constants.js";
|
|
5
|
+
import { buildDaemonRuntimeState, buildDaemonTickPlan } from "../daemon-runtime.js";
|
|
6
|
+
import { goalTodoCompletionDiagnostics, summarizeGoalTodos } from "../goal-todos.js";
|
|
7
|
+
import { isRecord } from "../utils/records.js";
|
|
8
|
+
import type { AssistantLikeMessage, ModeName } from "../types.js";
|
|
9
|
+
import { readHarnessReadinessWidgetData } from "../orchestration/widget-readers.js";
|
|
10
|
+
import { buildZpeerPeerRoomSummaries } from "../coms-v2/zpeer.js";
|
|
11
|
+
import { delegationCost, delegationDurationMs, formatDelegationCost, formatDuration, summarizeDelegations } from "./delegation-monitor.js";
|
|
12
|
+
import { disposeDelegationMouseSupport } from "./delegation-mouse.js";
|
|
13
|
+
import { formatZcompactHudLine } from "./auto-compaction.js";
|
|
14
|
+
import type { HarnessRuntimeState } from "./state.js";
|
|
15
|
+
|
|
16
|
+
const PRODUCT_HUD_IGNORED_READINESS_BLOCKERS = new Set(["global_autonomy_not_proven_for_arbitrary_factories"]);
|
|
17
|
+
|
|
18
|
+
function isProductHudReadinessBlocker(blocker: string): boolean {
|
|
19
|
+
return !PRODUCT_HUD_IGNORED_READINESS_BLOCKERS.has(blocker.trim());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function formatHudTokenCount(value: number): string {
|
|
23
|
+
const safe = Math.max(0, Math.floor(value));
|
|
24
|
+
if (safe < 1_000) return String(safe);
|
|
25
|
+
if (safe < 1_000_000) return `${(safe / 1_000).toFixed(safe < 10_000 ? 1 : 0)}k`;
|
|
26
|
+
return `${(safe / 1_000_000).toFixed(1)}m`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function formatAgentSeconds(seconds: number | undefined): string {
|
|
30
|
+
if (typeof seconds !== "number" || !Number.isFinite(seconds)) return "—";
|
|
31
|
+
return formatDuration(Math.max(0, Math.trunc(seconds)) * 1000);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function goalEndTimeMs(runtimeGoal: { status?: string; updatedAt?: unknown } | undefined, nowMs: number): number {
|
|
35
|
+
if (!runtimeGoal || runtimeGoal.status === "active") return nowMs;
|
|
36
|
+
const updatedAt = runtimeGoal.updatedAt;
|
|
37
|
+
if (typeof updatedAt !== "number" || !Number.isFinite(updatedAt)) return nowMs;
|
|
38
|
+
return updatedAt * 1000;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function formatGoalElapsed(goalCreatedAt: number | undefined, endMs: number): string {
|
|
42
|
+
if (typeof goalCreatedAt !== "number" || !Number.isFinite(goalCreatedAt)) return "—";
|
|
43
|
+
const startedAtMs = goalCreatedAt * 1000;
|
|
44
|
+
return formatDuration(Math.max(0, endMs - startedAtMs));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function numberFrom(value: unknown): number | undefined {
|
|
48
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function assistantCostFromMessage(message: AssistantLikeMessage): number | undefined {
|
|
52
|
+
if (message.role !== "assistant" || !isRecord(message.usage)) return undefined;
|
|
53
|
+
if (!isRecord(message.usage.cost)) return undefined;
|
|
54
|
+
return numberFrom(message.usage.cost.total);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function collectAssistantMessagesFromEntry(entry: unknown): AssistantLikeMessage[] {
|
|
58
|
+
const result: AssistantLikeMessage[] = [];
|
|
59
|
+
if (!isRecord(entry)) return result;
|
|
60
|
+
|
|
61
|
+
const addRecordMessage = (value: unknown): void => {
|
|
62
|
+
if (isRecord(value) && value.role === "assistant") result.push(value as AssistantLikeMessage);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const addMessages = (value: unknown): void => {
|
|
66
|
+
if (!Array.isArray(value)) return;
|
|
67
|
+
for (const item of value) addRecordMessage(item);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
addRecordMessage(entry);
|
|
71
|
+
addRecordMessage(entry.message);
|
|
72
|
+
addMessages(entry.messages);
|
|
73
|
+
const data = entry.data;
|
|
74
|
+
if (isRecord(data)) {
|
|
75
|
+
addRecordMessage(data);
|
|
76
|
+
addRecordMessage(data.message);
|
|
77
|
+
addMessages(data.messages);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function readConversationCostFromBranch(ctx: ExtensionContext): number | undefined {
|
|
83
|
+
if (!ctx.sessionManager || typeof ctx.sessionManager.getBranch !== "function") return undefined;
|
|
84
|
+
let total = 0;
|
|
85
|
+
let foundNumeric = false;
|
|
86
|
+
try {
|
|
87
|
+
for (const entry of ctx.sessionManager.getBranch()) {
|
|
88
|
+
for (const message of collectAssistantMessagesFromEntry(entry)) {
|
|
89
|
+
const messageCost = assistantCostFromMessage(message);
|
|
90
|
+
if (messageCost === undefined) continue;
|
|
91
|
+
total += Math.max(0, messageCost);
|
|
92
|
+
foundNumeric = true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} catch {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
return foundNumeric ? total : undefined;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function renderHarnessWidget(pi: ExtensionAPI, state: HarnessRuntimeState, ctx: ExtensionContext): void {
|
|
102
|
+
void pi;
|
|
103
|
+
const scopeGateText = state.activeGoal ? state.activeGoal.activeGoal : "unset";
|
|
104
|
+
const runtimeGoal = state.runtimeGoal;
|
|
105
|
+
const runtimeObjectiveText = runtimeGoal ? runtimeGoal.objective : "unset";
|
|
106
|
+
const runtimeTodoSummary = runtimeGoal ? summarizeGoalTodos(state.goalTodos, runtimeGoal.goalId) : undefined;
|
|
107
|
+
const todoDiagnostics = runtimeGoal ? goalTodoCompletionDiagnostics(state.goalTodos, runtimeGoal.goalId) : undefined;
|
|
108
|
+
const readiness = readHarnessReadinessWidgetData(ctx.cwd);
|
|
109
|
+
const daemonStatus = buildDaemonRuntimeState({
|
|
110
|
+
policy: state.daemon.policy,
|
|
111
|
+
runtimeGoal: state.runtimeGoal,
|
|
112
|
+
goalTodos: state.goalTodos,
|
|
113
|
+
autonomy: {
|
|
114
|
+
mode: state.autonomy.mode,
|
|
115
|
+
enabled: state.autonomy.enabled,
|
|
116
|
+
lastReadiness: state.autonomy.lastReadiness,
|
|
117
|
+
lastLaunchAuthorization: state.autonomy.lastLaunchAuthorization,
|
|
118
|
+
},
|
|
119
|
+
loop: state.daemon.loop,
|
|
120
|
+
});
|
|
121
|
+
const daemonPlan = state.daemon.lastPlan ?? buildDaemonTickPlan(daemonStatus);
|
|
122
|
+
if (typeof ctx.ui.setStatus === "function") ctx.ui.setStatus("zob-goal", undefined);
|
|
123
|
+
|
|
124
|
+
ctx.ui.setWidget("zob-harness", (_tui, theme) => {
|
|
125
|
+
const mouseOwner = Symbol("zob-harness-widget");
|
|
126
|
+
|
|
127
|
+
const fit = (text: string, innerWidth: number): string => {
|
|
128
|
+
const clipped = truncateToWidth(text, Math.max(1, innerWidth), "…");
|
|
129
|
+
return clipped + " ".repeat(Math.max(0, innerWidth - visibleWidth(clipped)));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const border = (kind: "top" | "bottom", width: number, label?: string): string => {
|
|
133
|
+
if (width < 8) return truncateToWidth(label ?? "", width, "");
|
|
134
|
+
if (kind === "bottom") return theme.fg("dim", `╰${"─".repeat(width - 2)}╯`);
|
|
135
|
+
const title = label ? ` ${label} ` : "";
|
|
136
|
+
const fillWidth = Math.max(0, width - visibleWidth("╭─") - visibleWidth(title) - visibleWidth("╮"));
|
|
137
|
+
return theme.fg("dim", "╭─") + title + theme.fg("dim", `${"─".repeat(fillWidth)}╮`);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const row = (width: number, content: string): string => {
|
|
141
|
+
if (width < 8) return truncateToWidth(content, width, "");
|
|
142
|
+
const innerWidth = Math.max(1, width - 4);
|
|
143
|
+
return theme.fg("dim", "│ ") + fit(content, innerWidth) + theme.fg("dim", " │");
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const twoColumnRow = (leftWidth: number, rightWidth: number, left: string, right: string): string => {
|
|
147
|
+
return `${theme.fg("dim", "│ ")}${fit(left, leftWidth)}${theme.fg("dim", " │ ")}${fit(right, rightWidth)}${theme.fg("dim", " │")}`;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const threeColumnRow = (leftWidth: number, middleWidth: number, rightWidth: number, left: string, middle: string, right: string): string => {
|
|
151
|
+
return `${theme.fg("dim", "│ ")}${fit(left, leftWidth)}${theme.fg("dim", " │ ")}${fit(middle, middleWidth)}${theme.fg("dim", " │ ")}${fit(right, rightWidth)}${theme.fg("dim", " │")}`;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const meter = (done: number, total: number, size: number): string => {
|
|
155
|
+
const safeTotal = Math.max(1, total);
|
|
156
|
+
const ratio = Math.min(1, Math.max(0, done / safeTotal));
|
|
157
|
+
const filled = Math.min(size, Math.max(0, Math.round(ratio * size)));
|
|
158
|
+
const color: "success" | "muted" = ratio >= 1 ? "success" : "muted";
|
|
159
|
+
return `${theme.fg(color, "█".repeat(filled))}${theme.fg("dim", "░".repeat(Math.max(0, size - filled)))}`;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const humanTodo = (title: string | undefined, fallback: string): string => truncateToWidth(title?.trim() || fallback, 96, "…");
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
dispose() { disposeDelegationMouseSupport(state, { owner: mouseOwner }); },
|
|
166
|
+
invalidate() {},
|
|
167
|
+
render(width: number): string[] {
|
|
168
|
+
disposeDelegationMouseSupport(state, { owner: mouseOwner });
|
|
169
|
+
const panelWidth = Math.max(1, width);
|
|
170
|
+
const delegationSummary = summarizeDelegations(state.delegations);
|
|
171
|
+
const nowMs = Date.now();
|
|
172
|
+
const agentTokens = runtimeGoal?.usage.tokensUsed;
|
|
173
|
+
const subTokenRuns = state.delegations.runs.filter((run) => run.usage);
|
|
174
|
+
const subTokens = subTokenRuns.reduce((sum, run) => sum + Math.max(0, Math.trunc((run.usage?.input ?? 0) + (run.usage?.output ?? 0))), 0);
|
|
175
|
+
const totalKnownTokens = (agentTokens ?? 0) + subTokens;
|
|
176
|
+
const hasKnownTokens = runtimeGoal !== undefined || subTokenRuns.length > 0;
|
|
177
|
+
const knownCostRuns = state.delegations.runs.filter((run) => run.usage);
|
|
178
|
+
const knownSubCost = knownCostRuns.reduce((sum, run) => sum + delegationCost(run), 0);
|
|
179
|
+
const conversationCost = readConversationCostFromBranch(ctx);
|
|
180
|
+
const hasConversationCost = typeof conversationCost === "number";
|
|
181
|
+
const totalKnownCost = hasConversationCost ? knownSubCost + conversationCost : undefined;
|
|
182
|
+
const subDurationMs = state.delegations.runs.reduce((sum, run) => sum + delegationDurationMs(run, nowMs), 0);
|
|
183
|
+
const statusCost = hasConversationCost
|
|
184
|
+
? `cost total ${formatDelegationCost(totalKnownCost)} · convo ${formatDelegationCost(conversationCost)} · sub ${formatDelegationCost(knownSubCost)}`
|
|
185
|
+
: `cost total n/a · convo n/a · sub ${formatDelegationCost(knownSubCost)}`;
|
|
186
|
+
const statusTokens = hasKnownTokens ? formatHudTokenCount(totalKnownTokens) : "—";
|
|
187
|
+
const elapsedTime = runtimeGoal
|
|
188
|
+
? formatGoalElapsed(runtimeGoal.createdAt, goalEndTimeMs(runtimeGoal, nowMs))
|
|
189
|
+
: "—";
|
|
190
|
+
const statusTime = runtimeGoal || state.delegations.runs.length > 0
|
|
191
|
+
? `elapsed ${elapsedTime} · agent ${formatAgentSeconds(runtimeGoal?.usage.activeSeconds)} · sub ${state.delegations.runs.length > 0 ? formatDuration(subDurationMs) : "—"} cum`
|
|
192
|
+
: "—";
|
|
193
|
+
const zcompactLine = formatZcompactHudLine(state.zcompact, ctx);
|
|
194
|
+
const zcompactColor = state.zcompact.running ? "warning" : state.zcompact.mode === "auto" ? "success" : state.zcompact.mode === "observe" ? "accent" : "dim";
|
|
195
|
+
ctx.ui.setStatus("zob-usage", theme.fg("muted", `usage ${statusCost} · tok total ${statusTokens} · time ${statusTime}`));
|
|
196
|
+
ctx.ui.setStatus("zob-zcompact", theme.fg(zcompactColor, zcompactLine));
|
|
197
|
+
const closedTodos = runtimeTodoSummary ? runtimeTodoSummary.done + runtimeTodoSummary.skipped : 0;
|
|
198
|
+
const totalTodos = runtimeTodoSummary?.total ?? 0;
|
|
199
|
+
const progress = totalTodos > 0
|
|
200
|
+
? `${closedTodos}/${totalTodos} ${meter(closedTodos, totalTodos, 10)}`
|
|
201
|
+
: runtimeGoal
|
|
202
|
+
? "not broken down yet"
|
|
203
|
+
: "no active mission";
|
|
204
|
+
const mission = runtimeGoal
|
|
205
|
+
? humanTodo(runtimeObjectiveText, "Mission in progress")
|
|
206
|
+
: scopeGateText !== "unset"
|
|
207
|
+
? humanTodo(scopeGateText, "Mission scoped")
|
|
208
|
+
: "Choose a mission with /goal";
|
|
209
|
+
|
|
210
|
+
const productReadinessBlocker = readiness.blockers.find(isProductHudReadinessBlocker);
|
|
211
|
+
const missionNoShip = Boolean(productReadinessBlocker) || runtimeGoal?.oracle.noShip === true || todoDiagnostics?.effectiveNoShip === true;
|
|
212
|
+
const alerts: string[] = [];
|
|
213
|
+
if (runtimeGoal?.status === "blocked" || runtimeTodoSummary?.blocked) alerts.push("Blocked");
|
|
214
|
+
if (runtimeTodoSummary?.needsUser) alerts.push("Waiting for user");
|
|
215
|
+
if (missionNoShip) alerts.push("Delivery blocked");
|
|
216
|
+
if (runtimeTodoSummary?.claimReturned) alerts.push("Result to review");
|
|
217
|
+
if (runtimeTodoSummary?.needsOracle || runtimeGoal?.status === "ready_for_oracle" || runtimeGoal?.oracle.status === "needed") alerts.push("Review required");
|
|
218
|
+
const uniqueAlerts = [...new Set(alerts)];
|
|
219
|
+
|
|
220
|
+
const assistantsWorking = delegationSummary.running > 0 || delegationSummary.queued > 0 || (runtimeTodoSummary?.delegated ?? 0) > 0;
|
|
221
|
+
const mainState = uniqueAlerts[0]
|
|
222
|
+
?? (assistantsWorking ? "Assistants working" : runtimeGoal ? "In progress" : "Ready");
|
|
223
|
+
const need = uniqueAlerts.length > 0 ? uniqueAlerts.join(" · ") : mainState;
|
|
224
|
+
const blockerText = runtimeGoal?.oracle.blockerSummary ?? productReadinessBlocker;
|
|
225
|
+
const needLine = blockerText && uniqueAlerts.length > 0
|
|
226
|
+
? `${need} — ${truncateToWidth(blockerText, 96, "…")}`
|
|
227
|
+
: need;
|
|
228
|
+
|
|
229
|
+
const nextTitle = runtimeTodoSummary?.nextUser?.title ?? runtimeTodoSummary?.nextAgent?.title;
|
|
230
|
+
const daemonBlocker = daemonStatus.reasonCodes.find((code) => code.includes("blocked") || code.includes("missing") || code.includes("needs"));
|
|
231
|
+
const loop = daemonStatus.loop;
|
|
232
|
+
const loopText = loop ? ` loop=${loop.status} ${loop.tickCount}${loop.maxTicks ? `/${loop.maxTicks}` : ""}` : "";
|
|
233
|
+
const daemonLine = `mode=${daemonStatus.policy.enabled ? "plan-only" : "off"} status=${daemonStatus.status}${loopText} last=${daemonPlan.action}${daemonBlocker ? ` blocker=${daemonBlocker}` : ""}`;
|
|
234
|
+
const nextAction = runtimeTodoSummary?.blocked
|
|
235
|
+
? "Clear the blocker before continuing"
|
|
236
|
+
: runtimeTodoSummary?.needsUser
|
|
237
|
+
? humanTodo(runtimeTodoSummary.nextUser?.title, "Wait for user input")
|
|
238
|
+
: runtimeTodoSummary?.claimReturned
|
|
239
|
+
? "Review the returned result"
|
|
240
|
+
: runtimeTodoSummary?.needsOracle
|
|
241
|
+
? "Request or wait for review"
|
|
242
|
+
: nextTitle
|
|
243
|
+
? humanTodo(nextTitle, "Continue the next step")
|
|
244
|
+
: runtimeGoal
|
|
245
|
+
? "Continue the mission or propose delivery"
|
|
246
|
+
: "Set the mission";
|
|
247
|
+
|
|
248
|
+
const reviewState = runtimeTodoSummary?.claimReturned
|
|
249
|
+
? "Result to review"
|
|
250
|
+
: runtimeTodoSummary?.needsOracle || runtimeGoal?.status === "ready_for_oracle" || runtimeGoal?.oracle.status === "needed"
|
|
251
|
+
? "Review required"
|
|
252
|
+
: "clear";
|
|
253
|
+
const qualityState = missionNoShip
|
|
254
|
+
? "delivery blocked"
|
|
255
|
+
: runtimeGoal?.status === "blocked" || runtimeTodoSummary?.blocked
|
|
256
|
+
? "blocked"
|
|
257
|
+
: totalTodos > 0 || runtimeGoal
|
|
258
|
+
? "check OK"
|
|
259
|
+
: "check needed";
|
|
260
|
+
const activityState = assistantsWorking
|
|
261
|
+
? "assistants"
|
|
262
|
+
: runtimeGoal
|
|
263
|
+
? "working"
|
|
264
|
+
: "idle";
|
|
265
|
+
const assistantsCount = delegationSummary.running + delegationSummary.queued + (runtimeTodoSummary?.delegated ?? 0);
|
|
266
|
+
const assistantsState = assistantsCount > 0
|
|
267
|
+
? `${assistantsCount} active`
|
|
268
|
+
: "none";
|
|
269
|
+
const zpeerRoomSummaries = state.zobLive.peerCard ? buildZpeerPeerRoomSummaries(ctx.cwd, state.zobLive.peerCard) : [];
|
|
270
|
+
const zpeerLast = state.zobLive.lastEvent
|
|
271
|
+
? `${state.zobLive.lastEvent.kind} ${state.zobLive.lastEvent.fromAlias ? `@${state.zobLive.lastEvent.fromAlias}` : "?"}→${state.zobLive.lastEvent.toAlias ? `@${state.zobLive.lastEvent.toAlias}` : "?"} ${state.zobLive.lastEvent.status}`
|
|
272
|
+
: "none";
|
|
273
|
+
const zpeerPending = state.zobLive.pendingReplies.snapshot().filter((item) => item.status === "pending").length;
|
|
274
|
+
const zpeerHeartbeatAge = state.zobLive.lastHeartbeatMs ? formatDuration(nowMs - state.zobLive.lastHeartbeatMs) : "—";
|
|
275
|
+
const zpeerRoomCap = 4;
|
|
276
|
+
const zpeerRoomLines = zpeerRoomSummaries.slice(0, zpeerRoomCap).map((summary) => {
|
|
277
|
+
const marker = summary.active ? "*" : " ";
|
|
278
|
+
const selfAlias = `@${summary.selfAlias ?? "?"}`;
|
|
279
|
+
const peerState = `${summary.online}/${summary.peerCount}${summary.stale > 0 ? ` s${summary.stale}` : ""}${summary.offline > 0 ? ` off${summary.offline}` : ""}`;
|
|
280
|
+
const peerAliases = summary.aliases.filter((alias) => alias !== summary.selfAlias).slice(0, 2).map((alias) => `@${alias}`);
|
|
281
|
+
const aliasOverflow = Math.max(0, summary.aliases.length - (summary.selfAlias && summary.aliases.includes(summary.selfAlias) ? 1 : 0) - peerAliases.length);
|
|
282
|
+
const aliasText = peerAliases.length > 0 ? `${peerAliases.join(" ")}${aliasOverflow > 0 ? ` +${aliasOverflow}` : ""}` : "no peers";
|
|
283
|
+
return theme.fg("muted", truncateToWidth(`${marker} ${summary.roomId} ${selfAlias} ${peerState} ${aliasText}`, 52, "…"));
|
|
284
|
+
});
|
|
285
|
+
if (zpeerRoomSummaries.length > zpeerRoomCap) zpeerRoomLines.push(theme.fg("dim", `+${zpeerRoomSummaries.length - zpeerRoomCap} rooms`));
|
|
286
|
+
const zpeerLines = state.zobLive.peerCard
|
|
287
|
+
? [
|
|
288
|
+
`${theme.fg("accent", "ZPeer")} ${theme.fg("muted", `${zpeerRoomSummaries.length} room${zpeerRoomSummaries.length === 1 ? "" : "s"}`)}`,
|
|
289
|
+
...zpeerRoomLines,
|
|
290
|
+
`${theme.fg("dim", "Last")} ${theme.fg(state.zobLive.lastEvent ? "muted" : "dim", zpeerLast)}`,
|
|
291
|
+
`${theme.fg("dim", "Wait")} ${theme.fg(zpeerPending > 0 ? "warning" : "muted", `${zpeerPending} pending · hb ${zpeerHeartbeatAge}`)}`,
|
|
292
|
+
`${theme.fg("dim", "Status")} ${theme.fg("success", "connected")}`,
|
|
293
|
+
]
|
|
294
|
+
: [
|
|
295
|
+
`${theme.fg("accent", "ZPeer")}`,
|
|
296
|
+
`${theme.fg("dim", "Last")} ${theme.fg(state.zobLive.lastEvent ? "muted" : "dim", zpeerLast)}`,
|
|
297
|
+
`${theme.fg("dim", "Status")} ${theme.fg("dim", "not connected")}`,
|
|
298
|
+
];
|
|
299
|
+
|
|
300
|
+
const leftLines = [
|
|
301
|
+
`${theme.fg("accent", "Mission")} ${theme.fg(runtimeGoal ? "muted" : "dim", mission)}`,
|
|
302
|
+
`${theme.fg("accent", "Progress")} ${theme.fg(totalTodos > 0 ? "muted" : "dim", progress)}`,
|
|
303
|
+
`${theme.fg("accent", "Next")} ${theme.fg(mainState === "Ready" ? "dim" : "muted", nextAction)}`,
|
|
304
|
+
`${theme.fg(uniqueAlerts.length > 0 ? "warning" : "success", "Need")} ${theme.fg(uniqueAlerts.length > 0 ? "warning" : "muted", needLine)}`,
|
|
305
|
+
`${theme.fg("dim", "Daemon")} ${theme.fg("muted", daemonLine)}`,
|
|
306
|
+
`${theme.fg("dim", "Context")} ${theme.fg(zcompactColor, zcompactLine)}`,
|
|
307
|
+
`${theme.fg("dim", "Open")} ${theme.fg("muted", "/zcompact · /zpeer · /zstatus · /todos overlay · /delegates")}`,
|
|
308
|
+
];
|
|
309
|
+
const rightLines = [
|
|
310
|
+
`${theme.fg("accent", "Focus")} ${theme.fg("muted", state.activeMode)}`,
|
|
311
|
+
`${theme.fg("accent", "Activity")} ${theme.fg(assistantsWorking ? "muted" : "dim", activityState)}`,
|
|
312
|
+
`${theme.fg(reviewState === "clear" ? "success" : "warning", "Review")} ${theme.fg(reviewState === "clear" ? "muted" : "warning", reviewState)}`,
|
|
313
|
+
`${theme.fg(qualityState === "check OK" ? "success" : "warning", "Quality")} ${theme.fg(qualityState === "check OK" ? "muted" : "warning", qualityState)}`,
|
|
314
|
+
`${theme.fg("accent", "Assistants")} ${theme.fg(assistantsCount > 0 ? "muted" : "dim", assistantsState)}`,
|
|
315
|
+
];
|
|
316
|
+
const wideRows = Math.max(leftLines.length, zpeerLines.length, rightLines.length);
|
|
317
|
+
|
|
318
|
+
if (panelWidth < 72) return leftLines.slice(0, 4).map((line) => truncateToWidth(line, panelWidth, "…"));
|
|
319
|
+
if (panelWidth < 112) {
|
|
320
|
+
const contextLine = `${theme.fg("dim", "Context")} ${theme.fg(zcompactColor, zcompactLine)}`;
|
|
321
|
+
return [
|
|
322
|
+
border("top", panelWidth, `${theme.fg("accent", "◆ ZOB")} ${theme.fg("muted", "live")}`),
|
|
323
|
+
...leftLines.map((line) => row(panelWidth, line)),
|
|
324
|
+
row(panelWidth, ""),
|
|
325
|
+
...zpeerLines.map((line) => row(panelWidth, line)),
|
|
326
|
+
row(panelWidth, contextLine),
|
|
327
|
+
border("bottom", panelWidth),
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const availableColumnWidth = Math.max(1, panelWidth - 10);
|
|
332
|
+
const zpeerWidth = Math.min(52, Math.max(34, Math.floor(availableColumnWidth * 0.36)));
|
|
333
|
+
const rightWidth = Math.min(32, Math.max(28, Math.floor(availableColumnWidth * 0.26)));
|
|
334
|
+
const leftWidth = Math.max(24, availableColumnWidth - zpeerWidth - rightWidth);
|
|
335
|
+
return [
|
|
336
|
+
border("top", panelWidth, `${theme.fg("accent", "◆ ZOB")} ${theme.fg("muted", "live")}`),
|
|
337
|
+
...Array.from({ length: wideRows }, (_, index) => threeColumnRow(leftWidth, zpeerWidth, rightWidth, leftLines[index] ?? "", zpeerLines[index] ?? "", rightLines[index] ?? "")),
|
|
338
|
+
border("bottom", panelWidth),
|
|
339
|
+
];
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function applyMode(pi: ExtensionAPI, state: HarnessRuntimeState, ctx: ExtensionContext, mode: ModeName, persist = true): void {
|
|
346
|
+
state.activeMode = mode;
|
|
347
|
+
const available = new Set(pi.getAllTools().map((tool) => tool.name));
|
|
348
|
+
pi.setActiveTools(MODE_TOOLS[mode].filter((tool) => available.has(tool)));
|
|
349
|
+
if (persist) pi.appendEntry("zob-mode-state", { mode, timestamp: new Date().toISOString() });
|
|
350
|
+
ctx.ui.setStatus("zob-mode", ctx.ui.theme.fg("accent", `zob:${mode}`));
|
|
351
|
+
renderHarnessWidget(pi, state, ctx);
|
|
352
|
+
ctx.ui.notify(`ZOB mode: ${mode}`, "info");
|
|
353
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
import { registerHarnessCommands } from "./commands.js";
|
|
4
|
+
import { registerHarnessEvents } from "./events.js";
|
|
5
|
+
import { createHarnessRuntimeState } from "./state.js";
|
|
6
|
+
import { registerAutonomousTools } from "./tools-autonomous.js";
|
|
7
|
+
import { registerComsTools } from "./tools-coms.js";
|
|
8
|
+
import { registerComputeTools } from "./tools-compute.js";
|
|
9
|
+
import { registerContextTools } from "./tools-context.js";
|
|
10
|
+
import { registerDelegationTools } from "./tools-delegation.js";
|
|
11
|
+
import { registerMissionControlTools } from "./tools-mission-control.js";
|
|
12
|
+
import { registerFactoryTools } from "./tools-factory.js";
|
|
13
|
+
import { registerProjectDnaTools } from "./tools-project-dna.js";
|
|
14
|
+
import { registerOrchestrationTools } from "./tools-orchestration.js";
|
|
15
|
+
import { registerGoalRuntimeEvents, registerGoalRuntimeTools } from "../goal-runtime.js";
|
|
16
|
+
import { registerGoalRoomTools } from "./tools-goal-room.js";
|
|
17
|
+
import { registerGovernedRequestTools } from "./tools-governed-requests.js";
|
|
18
|
+
import { registerWorkspaceClaimTools } from "./tools-workspace-claims.js";
|
|
19
|
+
import { registerWorkerPoolTools } from "./tools-worker-pool.js";
|
|
20
|
+
import { registerMergeQueueTools } from "./tools-merge-queue.js";
|
|
21
|
+
import { registerZcommitTools } from "./tools-zcommit.js";
|
|
22
|
+
import { renderHarnessWidget } from "./widget.js";
|
|
23
|
+
|
|
24
|
+
export default function zobHarness(pi: ExtensionAPI): void {
|
|
25
|
+
const state = createHarnessRuntimeState();
|
|
26
|
+
|
|
27
|
+
registerHarnessCommands(pi, state);
|
|
28
|
+
|
|
29
|
+
registerGoalRuntimeTools(pi, state);
|
|
30
|
+
|
|
31
|
+
registerDelegationTools(pi, state);
|
|
32
|
+
|
|
33
|
+
registerOrchestrationTools(pi, state);
|
|
34
|
+
|
|
35
|
+
registerComsTools(pi, state);
|
|
36
|
+
|
|
37
|
+
registerGoalRoomTools(pi);
|
|
38
|
+
registerGovernedRequestTools(pi);
|
|
39
|
+
registerWorkspaceClaimTools(pi);
|
|
40
|
+
registerWorkerPoolTools(pi);
|
|
41
|
+
registerMergeQueueTools(pi);
|
|
42
|
+
|
|
43
|
+
registerZcommitTools(pi, state);
|
|
44
|
+
|
|
45
|
+
registerMissionControlTools(pi);
|
|
46
|
+
|
|
47
|
+
registerContextTools(pi);
|
|
48
|
+
|
|
49
|
+
registerComputeTools(pi);
|
|
50
|
+
|
|
51
|
+
registerProjectDnaTools(pi);
|
|
52
|
+
|
|
53
|
+
registerAutonomousTools(pi);
|
|
54
|
+
|
|
55
|
+
registerFactoryTools(pi, state);
|
|
56
|
+
|
|
57
|
+
registerGoalRuntimeEvents(pi, state, (ctx) => renderHarnessWidget(pi, state, ctx));
|
|
58
|
+
|
|
59
|
+
registerHarnessEvents(pi, state);
|
|
60
|
+
}
|