@chankov/agent-fleet 0.0.1
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/.claude/commands/build.md +44 -0
- package/.claude/commands/code-simplify.md +22 -0
- package/.claude/commands/design-agent.md +14 -0
- package/.claude/commands/doctor-agent-fleet.md +17 -0
- package/.claude/commands/orchestrate.md +112 -0
- package/.claude/commands/plan.md +16 -0
- package/.claude/commands/prime.md +22 -0
- package/.claude/commands/review.md +16 -0
- package/.claude/commands/setup-agent-fleet.md +25 -0
- package/.claude/commands/ship.md +72 -0
- package/.claude/commands/spec.md +15 -0
- package/.claude/commands/test.md +19 -0
- package/.claude/commands/webperf.md +32 -0
- package/.claude/orchestrate-teams.yaml +24 -0
- package/.opencode/commands/af-build.md +17 -0
- package/.opencode/commands/af-code-simplify.md +16 -0
- package/.opencode/commands/af-compound.md +16 -0
- package/.opencode/commands/af-design-agent.md +15 -0
- package/.opencode/commands/af-doctor-agent-fleet.md +15 -0
- package/.opencode/commands/af-orchestrate.md +112 -0
- package/.opencode/commands/af-plan.md +16 -0
- package/.opencode/commands/af-prime.md +22 -0
- package/.opencode/commands/af-review.md +15 -0
- package/.opencode/commands/af-setup-agent-fleet.md +15 -0
- package/.opencode/commands/af-ship.md +16 -0
- package/.opencode/commands/af-spec.md +16 -0
- package/.opencode/commands/af-test.md +21 -0
- package/.opencode/commands/af-webperf.md +32 -0
- package/.opencode/orchestrate-teams.yaml +24 -0
- package/.pi/agents/dispatch-policy.yaml +32 -0
- package/.pi/agents/model-profiles.yaml +20 -0
- package/.pi/agents/peers.yaml +142 -0
- package/.pi/agents/teams.yaml +39 -0
- package/.pi/damage-control-rules.yaml +297 -0
- package/.pi/extensions/agent-fleet-update-check/README.md +58 -0
- package/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
- package/.pi/extensions/agent-fleet-update-check/package.json +6 -0
- package/.pi/extensions/btw/README.md +118 -0
- package/.pi/extensions/btw/index.ts +917 -0
- package/.pi/extensions/btw/package.json +6 -0
- package/.pi/extensions/btw/state.js +179 -0
- package/.pi/extensions/chrome-devtools-mcp/README.md +58 -0
- package/.pi/extensions/chrome-devtools-mcp/index.ts +92 -0
- package/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.pi/extensions/package-lock.json +1143 -0
- package/.pi/extensions/package.json +9 -0
- package/.pi/extensions/pi-voice-stt/README.md +201 -0
- package/.pi/extensions/pi-voice-stt/config.ts +198 -0
- package/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
- package/.pi/extensions/pi-voice-stt/index.ts +248 -0
- package/.pi/extensions/pi-voice-stt/package.json +6 -0
- package/.pi/extensions/pi-voice-stt/providers.ts +214 -0
- package/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
- package/.pi/harnesses/agent-hub/README.md +562 -0
- package/.pi/harnesses/agent-hub/artifacts.js +92 -0
- package/.pi/harnesses/agent-hub/backend-policy.js +153 -0
- package/.pi/harnesses/agent-hub/delegate.ts +363 -0
- package/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
- package/.pi/harnesses/agent-hub/helpers.ts +165 -0
- package/.pi/harnesses/agent-hub/index.ts +7098 -0
- package/.pi/harnesses/agent-hub/package.json +6 -0
- package/.pi/harnesses/agent-hub/return-contract.js +215 -0
- package/.pi/harnesses/agent-hub/scope-gate.js +103 -0
- package/.pi/harnesses/agent-hub/spawn.ts +179 -0
- package/.pi/harnesses/ask-user-remote/README.md +10 -0
- package/.pi/harnesses/ask-user-remote/index.ts +253 -0
- package/.pi/harnesses/ask-user-remote/race-core.js +106 -0
- package/.pi/harnesses/coms/README.md +71 -0
- package/.pi/harnesses/coms/index.ts +1743 -0
- package/.pi/harnesses/coms/package.json +6 -0
- package/.pi/harnesses/damage-control/README.md +65 -0
- package/.pi/harnesses/damage-control/index.ts +250 -0
- package/.pi/harnesses/damage-control/package.json +6 -0
- package/.pi/harnesses/damage-control/shared.ts +183 -0
- package/.pi/harnesses/damage-control-continue/README.md +116 -0
- package/.pi/harnesses/damage-control-continue/index.ts +522 -0
- package/.pi/harnesses/damage-control-continue/package.json +6 -0
- package/.pi/harnesses/lib/herdr-client.ts +458 -0
- package/.pi/harnesses/lib/herdr-presence.ts +288 -0
- package/.pi/harnesses/package-lock.json +35 -0
- package/.pi/harnesses/package.json +9 -0
- package/.pi/prompts/build.md +24 -0
- package/.pi/prompts/code-simplify.md +22 -0
- package/.pi/prompts/doctor-agent-fleet.md +15 -0
- package/.pi/prompts/plan.md +16 -0
- package/.pi/prompts/review.md +16 -0
- package/.pi/prompts/setup-agent-fleet.md +27 -0
- package/.pi/prompts/ship.md +17 -0
- package/.pi/prompts/spec.md +15 -0
- package/.pi/prompts/test.md +19 -0
- package/.pi/skills/bowser/SKILL.md +145 -0
- package/.versions/0.0.1/.claude/commands/build.md +44 -0
- package/.versions/0.0.1/.claude/commands/code-simplify.md +22 -0
- package/.versions/0.0.1/.claude/commands/design-agent.md +14 -0
- package/.versions/0.0.1/.claude/commands/doctor-agent-fleet.md +17 -0
- package/.versions/0.0.1/.claude/commands/orchestrate.md +112 -0
- package/.versions/0.0.1/.claude/commands/plan.md +16 -0
- package/.versions/0.0.1/.claude/commands/prime.md +22 -0
- package/.versions/0.0.1/.claude/commands/review.md +16 -0
- package/.versions/0.0.1/.claude/commands/setup-agent-fleet.md +25 -0
- package/.versions/0.0.1/.claude/commands/ship.md +72 -0
- package/.versions/0.0.1/.claude/commands/spec.md +15 -0
- package/.versions/0.0.1/.claude/commands/test.md +19 -0
- package/.versions/0.0.1/.claude/commands/webperf.md +32 -0
- package/.versions/0.0.1/.claude/orchestrate-teams.yaml +24 -0
- package/.versions/0.0.1/.opencode/commands/af-build.md +17 -0
- package/.versions/0.0.1/.opencode/commands/af-code-simplify.md +16 -0
- package/.versions/0.0.1/.opencode/commands/af-compound.md +16 -0
- package/.versions/0.0.1/.opencode/commands/af-design-agent.md +15 -0
- package/.versions/0.0.1/.opencode/commands/af-doctor-agent-fleet.md +15 -0
- package/.versions/0.0.1/.opencode/commands/af-orchestrate.md +112 -0
- package/.versions/0.0.1/.opencode/commands/af-plan.md +16 -0
- package/.versions/0.0.1/.opencode/commands/af-prime.md +22 -0
- package/.versions/0.0.1/.opencode/commands/af-review.md +15 -0
- package/.versions/0.0.1/.opencode/commands/af-setup-agent-fleet.md +15 -0
- package/.versions/0.0.1/.opencode/commands/af-ship.md +16 -0
- package/.versions/0.0.1/.opencode/commands/af-spec.md +16 -0
- package/.versions/0.0.1/.opencode/commands/af-test.md +21 -0
- package/.versions/0.0.1/.opencode/commands/af-webperf.md +32 -0
- package/.versions/0.0.1/.opencode/orchestrate-teams.yaml +24 -0
- package/.versions/0.0.1/.pi/agents/dispatch-policy.yaml +32 -0
- package/.versions/0.0.1/.pi/agents/model-profiles.yaml +20 -0
- package/.versions/0.0.1/.pi/agents/peers.yaml +142 -0
- package/.versions/0.0.1/.pi/agents/teams.yaml +39 -0
- package/.versions/0.0.1/.pi/damage-control-rules.yaml +297 -0
- package/.versions/0.0.1/.pi/extensions/agent-fleet-update-check/README.md +58 -0
- package/.versions/0.0.1/.pi/extensions/agent-fleet-update-check/index.ts +161 -0
- package/.versions/0.0.1/.pi/extensions/agent-fleet-update-check/package.json +6 -0
- package/.versions/0.0.1/.pi/extensions/btw/README.md +118 -0
- package/.versions/0.0.1/.pi/extensions/btw/index.ts +917 -0
- package/.versions/0.0.1/.pi/extensions/btw/package.json +6 -0
- package/.versions/0.0.1/.pi/extensions/btw/state.js +179 -0
- package/.versions/0.0.1/.pi/extensions/chrome-devtools-mcp/README.md +58 -0
- package/.versions/0.0.1/.pi/extensions/chrome-devtools-mcp/index.ts +92 -0
- package/.versions/0.0.1/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.versions/0.0.1/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.versions/0.0.1/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.versions/0.0.1/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.versions/0.0.1/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.versions/0.0.1/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.versions/0.0.1/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.versions/0.0.1/.pi/extensions/package-lock.json +1143 -0
- package/.versions/0.0.1/.pi/extensions/package.json +9 -0
- package/.versions/0.0.1/.pi/extensions/pi-voice-stt/README.md +201 -0
- package/.versions/0.0.1/.pi/extensions/pi-voice-stt/config.ts +198 -0
- package/.versions/0.0.1/.pi/extensions/pi-voice-stt/examples/stt.json +35 -0
- package/.versions/0.0.1/.pi/extensions/pi-voice-stt/index.ts +248 -0
- package/.versions/0.0.1/.pi/extensions/pi-voice-stt/package.json +6 -0
- package/.versions/0.0.1/.pi/extensions/pi-voice-stt/providers.ts +214 -0
- package/.versions/0.0.1/.pi/extensions/pi-voice-stt/recorder.ts +158 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/README.md +562 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/artifacts.js +92 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/backend-policy.js +153 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/delegate.ts +363 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/evidence-rules.js +96 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/helpers.ts +165 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/index.ts +7098 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/package.json +6 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/return-contract.js +215 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/scope-gate.js +103 -0
- package/.versions/0.0.1/.pi/harnesses/agent-hub/spawn.ts +179 -0
- package/.versions/0.0.1/.pi/harnesses/ask-user-remote/README.md +10 -0
- package/.versions/0.0.1/.pi/harnesses/ask-user-remote/index.ts +253 -0
- package/.versions/0.0.1/.pi/harnesses/ask-user-remote/race-core.js +106 -0
- package/.versions/0.0.1/.pi/harnesses/coms/README.md +71 -0
- package/.versions/0.0.1/.pi/harnesses/coms/index.ts +1743 -0
- package/.versions/0.0.1/.pi/harnesses/coms/package.json +6 -0
- package/.versions/0.0.1/.pi/harnesses/damage-control/README.md +65 -0
- package/.versions/0.0.1/.pi/harnesses/damage-control/index.ts +250 -0
- package/.versions/0.0.1/.pi/harnesses/damage-control/package.json +6 -0
- package/.versions/0.0.1/.pi/harnesses/damage-control/shared.ts +183 -0
- package/.versions/0.0.1/.pi/harnesses/damage-control-continue/README.md +116 -0
- package/.versions/0.0.1/.pi/harnesses/damage-control-continue/index.ts +522 -0
- package/.versions/0.0.1/.pi/harnesses/damage-control-continue/package.json +6 -0
- package/.versions/0.0.1/.pi/harnesses/lib/herdr-client.ts +458 -0
- package/.versions/0.0.1/.pi/harnesses/lib/herdr-presence.ts +288 -0
- package/.versions/0.0.1/.pi/harnesses/package-lock.json +35 -0
- package/.versions/0.0.1/.pi/harnesses/package.json +9 -0
- package/.versions/0.0.1/.pi/prompts/build.md +24 -0
- package/.versions/0.0.1/.pi/prompts/code-simplify.md +22 -0
- package/.versions/0.0.1/.pi/prompts/doctor-agent-fleet.md +15 -0
- package/.versions/0.0.1/.pi/prompts/plan.md +16 -0
- package/.versions/0.0.1/.pi/prompts/review.md +16 -0
- package/.versions/0.0.1/.pi/prompts/setup-agent-fleet.md +27 -0
- package/.versions/0.0.1/.pi/prompts/ship.md +17 -0
- package/.versions/0.0.1/.pi/prompts/spec.md +15 -0
- package/.versions/0.0.1/.pi/prompts/test.md +19 -0
- package/.versions/0.0.1/.pi/skills/bowser/SKILL.md +145 -0
- package/.versions/0.0.1/.version +1 -0
- package/.versions/0.0.1/agents/architect.md +21 -0
- package/.versions/0.0.1/agents/bowser.md +25 -0
- package/.versions/0.0.1/agents/builder.md +52 -0
- package/.versions/0.0.1/agents/code-reviewer.md +205 -0
- package/.versions/0.0.1/agents/deep-researcher.md +31 -0
- package/.versions/0.0.1/agents/documenter.md +16 -0
- package/.versions/0.0.1/agents/orchestrator.md +43 -0
- package/.versions/0.0.1/agents/plan-reviewer.md +60 -0
- package/.versions/0.0.1/agents/planner.md +69 -0
- package/.versions/0.0.1/agents/releaser.md +22 -0
- package/.versions/0.0.1/agents/researcher.md +28 -0
- package/.versions/0.0.1/agents/security-auditor.md +166 -0
- package/.versions/0.0.1/agents/test-engineer.md +144 -0
- package/.versions/0.0.1/agents/web-debugger.md +42 -0
- package/.versions/0.0.1/agents/web-performance-auditor.md +192 -0
- package/.versions/0.0.1/hooks/SIMPLIFY-IGNORE.md +90 -0
- package/.versions/0.0.1/hooks/coms-stop-hook.mjs +73 -0
- package/.versions/0.0.1/hooks/hooks.json +14 -0
- package/.versions/0.0.1/hooks/session-start.sh +74 -0
- package/.versions/0.0.1/hooks/simplify-ignore.sh +302 -0
- package/.versions/0.0.1/justfile +143 -0
- package/.versions/0.0.1/references/accessibility-checklist.md +160 -0
- package/.versions/0.0.1/references/definition-of-done.md +67 -0
- package/.versions/0.0.1/references/fleet-coordination-patterns.md +151 -0
- package/.versions/0.0.1/references/observability-checklist.md +91 -0
- package/.versions/0.0.1/references/orchestration-patterns.md +370 -0
- package/.versions/0.0.1/references/performance-checklist.md +153 -0
- package/.versions/0.0.1/references/prompting-patterns.md +380 -0
- package/.versions/0.0.1/references/security-checklist.md +179 -0
- package/.versions/0.0.1/references/testing-patterns.md +236 -0
- package/.versions/0.0.1/scripts/coms-claude-bridge.ts +286 -0
- package/.versions/0.0.1/scripts/coms-cli.ts +372 -0
- package/.versions/0.0.1/scripts/coms-hermes-bridge.ts +399 -0
- package/.versions/0.0.1/scripts/lib/claude-bridge-core.ts +100 -0
- package/.versions/0.0.1/scripts/lib/coms-envelope.ts +494 -0
- package/.versions/0.0.1/scripts/lib/herdr-layout.ts +235 -0
- package/.versions/0.0.1/scripts/lib/hermes-bridge-core.ts +238 -0
- package/.versions/0.0.1/scripts/lib/persona-banner.ts +62 -0
- package/.versions/0.0.1/scripts/lib/team-project.ts +75 -0
- package/.versions/0.0.1/scripts/lib/team-snapshot.ts +146 -0
- package/.versions/0.0.1/scripts/peer-banner.ts +40 -0
- package/.versions/0.0.1/scripts/team-snapshot.ts +221 -0
- package/.versions/0.0.1/scripts/team-up.ts +245 -0
- package/.versions/0.0.1/skills/_internal/grilling.md +11 -0
- package/.versions/0.0.1/skills/browser-testing-with-devtools/SKILL.md +352 -0
- package/.versions/0.0.1/skills/code-review-and-quality/SKILL.md +381 -0
- package/.versions/0.0.1/skills/compound-learning/SKILL.md +137 -0
- package/.versions/0.0.1/skills/context-engineering/SKILL.md +291 -0
- package/.versions/0.0.1/skills/deprecation-and-migration/SKILL.md +206 -0
- package/.versions/0.0.1/skills/designing-agents/SKILL.md +394 -0
- package/.versions/0.0.1/skills/designing-agents/pi-harness-authoring.md +209 -0
- package/.versions/0.0.1/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/0.0.1/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/.versions/0.0.1/skills/guided-workspace-setup/SKILL.md +506 -0
- package/.versions/0.0.1/skills/idea-refine/SKILL.md +182 -0
- package/.versions/0.0.1/skills/idea-refine/examples.md +238 -0
- package/.versions/0.0.1/skills/idea-refine/frameworks.md +99 -0
- package/.versions/0.0.1/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/0.0.1/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/0.0.1/skills/incremental-implementation/SKILL.md +287 -0
- package/.versions/0.0.1/skills/interview-me/SKILL.md +226 -0
- package/.versions/0.0.1/skills/orchestration-verification/SKILL.md +181 -0
- package/.versions/0.0.1/skills/peer-coms/SKILL.md +81 -0
- package/.versions/0.0.1/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/0.0.1/skills/planning-and-task-breakdown/SKILL.md +236 -0
- package/.versions/0.0.1/skills/security-and-hardening/SKILL.md +461 -0
- package/.versions/0.0.1/skills/spec-driven-development/SKILL.md +245 -0
- package/.versions/0.0.1/skills/using-agent-skills/SKILL.md +199 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/LICENSE +21 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/README.md +11 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
- package/.versions/0.0.1/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
- package/CHANGELOG.md +65 -0
- package/LICENSE +21 -0
- package/README.md +458 -0
- package/agents/architect.md +21 -0
- package/agents/bowser.md +25 -0
- package/agents/builder.md +52 -0
- package/agents/code-reviewer.md +205 -0
- package/agents/deep-researcher.md +31 -0
- package/agents/documenter.md +16 -0
- package/agents/orchestrator.md +43 -0
- package/agents/plan-reviewer.md +60 -0
- package/agents/planner.md +69 -0
- package/agents/releaser.md +22 -0
- package/agents/researcher.md +28 -0
- package/agents/security-auditor.md +166 -0
- package/agents/test-engineer.md +144 -0
- package/agents/web-debugger.md +42 -0
- package/agents/web-performance-auditor.md +192 -0
- package/bin/cli.js +633 -0
- package/bin/force-patch-changesets.js +44 -0
- package/bin/lib/bootstrap.js +323 -0
- package/bin/lib/detect-agent.js +49 -0
- package/bin/lib/doctor.js +302 -0
- package/bin/lib/transform-persona.js +180 -0
- package/bin/lib/update-notifier.js +195 -0
- package/bin/lib/validate-overrides.js +229 -0
- package/bin/snapshot-version.js +91 -0
- package/docs/agent-fleet-setup.md +355 -0
- package/docs/claude-code-coms-bridge.md +93 -0
- package/docs/getting-started.md +169 -0
- package/docs/npm-install.md +335 -0
- package/docs/opencode-setup.md +248 -0
- package/docs/pi-extensions.md +237 -0
- package/docs/pi-setup.md +455 -0
- package/docs/skill-anatomy.md +150 -0
- package/hooks/SIMPLIFY-IGNORE.md +90 -0
- package/hooks/coms-stop-hook.mjs +73 -0
- package/hooks/hooks.json +14 -0
- package/hooks/session-start.sh +74 -0
- package/hooks/simplify-ignore.sh +302 -0
- package/justfile +143 -0
- package/node_modules/pi-ask-user/LICENSE +21 -0
- package/node_modules/pi-ask-user/README.md +156 -0
- package/node_modules/pi-ask-user/index.ts +1795 -0
- package/node_modules/pi-ask-user/package.json +51 -0
- package/node_modules/pi-ask-user/single-select-layout.ts +203 -0
- package/node_modules/pi-ask-user/skills/ask-user/SKILL.md +162 -0
- package/node_modules/pi-ask-user/skills/ask-user/references/ask-user-skill-extension-spec.md +96 -0
- package/package.json +121 -0
- package/references/accessibility-checklist.md +160 -0
- package/references/definition-of-done.md +67 -0
- package/references/fleet-coordination-patterns.md +151 -0
- package/references/observability-checklist.md +91 -0
- package/references/orchestration-patterns.md +370 -0
- package/references/performance-checklist.md +153 -0
- package/references/prompting-patterns.md +380 -0
- package/references/security-checklist.md +179 -0
- package/references/testing-patterns.md +236 -0
- package/scripts/coms-claude-bridge.ts +286 -0
- package/scripts/coms-cli.ts +372 -0
- package/scripts/coms-hermes-bridge.ts +399 -0
- package/scripts/lib/claude-bridge-core.ts +100 -0
- package/scripts/lib/coms-envelope.ts +494 -0
- package/scripts/lib/herdr-layout.ts +235 -0
- package/scripts/lib/hermes-bridge-core.ts +238 -0
- package/scripts/lib/persona-banner.ts +62 -0
- package/scripts/lib/team-project.ts +75 -0
- package/scripts/lib/team-snapshot.ts +146 -0
- package/scripts/peer-banner.ts +40 -0
- package/scripts/team-snapshot.ts +221 -0
- package/scripts/team-up.ts +245 -0
- package/skills/_internal/grilling.md +11 -0
- package/skills/browser-testing-with-devtools/SKILL.md +352 -0
- package/skills/code-review-and-quality/SKILL.md +381 -0
- package/skills/compound-learning/SKILL.md +137 -0
- package/skills/context-engineering/SKILL.md +291 -0
- package/skills/deprecation-and-migration/SKILL.md +206 -0
- package/skills/designing-agents/SKILL.md +394 -0
- package/skills/designing-agents/pi-harness-authoring.md +209 -0
- package/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/skills/guided-workspace-setup/SKILL.md +506 -0
- package/skills/idea-refine/SKILL.md +182 -0
- package/skills/idea-refine/examples.md +238 -0
- package/skills/idea-refine/frameworks.md +99 -0
- package/skills/idea-refine/refinement-criteria.md +113 -0
- package/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/skills/incremental-implementation/SKILL.md +287 -0
- package/skills/interview-me/SKILL.md +226 -0
- package/skills/orchestration-verification/SKILL.md +181 -0
- package/skills/peer-coms/SKILL.md +81 -0
- package/skills/performance-optimization/SKILL.md +350 -0
- package/skills/planning-and-task-breakdown/SKILL.md +236 -0
- package/skills/security-and-hardening/SKILL.md +461 -0
- package/skills/spec-driven-development/SKILL.md +245 -0
- package/skills/using-agent-skills/SKILL.md +199 -0
- package/vendor/agent-skills-upstream/LICENSE +21 -0
- package/vendor/agent-skills-upstream/README.md +11 -0
- package/vendor/agent-skills-upstream/skills/api-and-interface-design/SKILL.md +294 -0
- package/vendor/agent-skills-upstream/skills/browser-testing-with-devtools/SKILL.md +317 -0
- package/vendor/agent-skills-upstream/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/vendor/agent-skills-upstream/skills/code-review-and-quality/SKILL.md +396 -0
- package/vendor/agent-skills-upstream/skills/code-simplification/SKILL.md +331 -0
- package/vendor/agent-skills-upstream/skills/context-engineering/SKILL.md +289 -0
- package/vendor/agent-skills-upstream/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/vendor/agent-skills-upstream/skills/deprecation-and-migration/SKILL.md +247 -0
- package/vendor/agent-skills-upstream/skills/documentation-and-adrs/SKILL.md +278 -0
- package/vendor/agent-skills-upstream/skills/doubt-driven-development/SKILL.md +243 -0
- package/vendor/agent-skills-upstream/skills/frontend-ui-engineering/SKILL.md +328 -0
- package/vendor/agent-skills-upstream/skills/git-workflow-and-versioning/SKILL.md +355 -0
- package/vendor/agent-skills-upstream/skills/idea-refine/SKILL.md +178 -0
- package/vendor/agent-skills-upstream/skills/idea-refine/examples.md +238 -0
- package/vendor/agent-skills-upstream/skills/idea-refine/frameworks.md +99 -0
- package/vendor/agent-skills-upstream/skills/idea-refine/refinement-criteria.md +113 -0
- package/vendor/agent-skills-upstream/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/vendor/agent-skills-upstream/skills/incremental-implementation/SKILL.md +249 -0
- package/vendor/agent-skills-upstream/skills/interview-me/SKILL.md +225 -0
- package/vendor/agent-skills-upstream/skills/observability-and-instrumentation/SKILL.md +203 -0
- package/vendor/agent-skills-upstream/skills/performance-optimization/SKILL.md +350 -0
- package/vendor/agent-skills-upstream/skills/planning-and-task-breakdown/SKILL.md +234 -0
- package/vendor/agent-skills-upstream/skills/security-and-hardening/SKILL.md +467 -0
- package/vendor/agent-skills-upstream/skills/shipping-and-launch/SKILL.md +310 -0
- package/vendor/agent-skills-upstream/skills/source-driven-development/SKILL.md +194 -0
- package/vendor/agent-skills-upstream/skills/spec-driven-development/SKILL.md +206 -0
- package/vendor/agent-skills-upstream/skills/test-driven-development/SKILL.md +383 -0
- package/vendor/agent-skills-upstream/skills/using-agent-skills/SKILL.md +191 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Dispatch backend policy — pure logic for routing dispatch_agent calls to a
|
|
2
|
+
// native pi subagent or a same-name coms peer (.pi/agents/dispatch-policy.yaml).
|
|
3
|
+
// Parsing + resolution only: no I/O, no pi imports, testable under node --test.
|
|
4
|
+
// The wiring (pool lookup, envelope send, fallback spawn) lives in index.ts.
|
|
5
|
+
|
|
6
|
+
const NAME_RE = /^[A-Za-z0-9_-]+$/;
|
|
7
|
+
const DEFAULT_GRACE_S = 30;
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_POLICY = Object.freeze({
|
|
10
|
+
default: "native",
|
|
11
|
+
grace_s: DEFAULT_GRACE_S,
|
|
12
|
+
substitutions: {},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function stripComment(line) {
|
|
16
|
+
// Values in this file never contain '#'; a minimal comment strip is enough.
|
|
17
|
+
const i = line.indexOf("#");
|
|
18
|
+
return i < 0 ? line : line.slice(0, i);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Minimal parser for the specific dispatch-policy.yaml shape:
|
|
22
|
+
// default: native | coms
|
|
23
|
+
// grace_s: <seconds>
|
|
24
|
+
// substitutions:
|
|
25
|
+
// <member>:
|
|
26
|
+
// prefer: native | coms
|
|
27
|
+
// fallback: native | none
|
|
28
|
+
// timeout_s: <seconds>
|
|
29
|
+
// Not a general YAML parser; tolerant of comments and blank lines only.
|
|
30
|
+
// Never throws: malformed input degrades to DEFAULT_POLICY pieces, with a
|
|
31
|
+
// warning per dropped construct so the hub can notify once.
|
|
32
|
+
export function parseDispatchPolicy(raw) {
|
|
33
|
+
const policy = { default: "native", grace_s: DEFAULT_GRACE_S, substitutions: {} };
|
|
34
|
+
const warnings = [];
|
|
35
|
+
if (typeof raw !== "string" || raw.trim() === "") return { policy, warnings };
|
|
36
|
+
|
|
37
|
+
let inSubstitutions = false;
|
|
38
|
+
let currentMember = null;
|
|
39
|
+
|
|
40
|
+
for (const rawLine of String(raw).split("\n")) {
|
|
41
|
+
const line = stripComment(rawLine.replace(/\s+$/, ""));
|
|
42
|
+
if (line.trim() === "") continue;
|
|
43
|
+
const indent = line.length - line.trimStart().length;
|
|
44
|
+
const content = line.trim();
|
|
45
|
+
const kv = content.match(/^([A-Za-z0-9_-]+):\s*(.*)$/);
|
|
46
|
+
if (!kv) {
|
|
47
|
+
warnings.push(`dispatch-policy: ignored unparseable line: ${content}`);
|
|
48
|
+
// Don't let fields after a broken member header leak into the previous member.
|
|
49
|
+
currentMember = null;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const [, key, value] = kv;
|
|
53
|
+
|
|
54
|
+
if (indent === 0) {
|
|
55
|
+
currentMember = null;
|
|
56
|
+
inSubstitutions = false;
|
|
57
|
+
if (key === "substitutions" && value === "") {
|
|
58
|
+
inSubstitutions = true;
|
|
59
|
+
} else if (key === "default") {
|
|
60
|
+
if (value === "native" || value === "coms") policy.default = value;
|
|
61
|
+
else warnings.push(`dispatch-policy: default must be native|coms, got "${value}"`);
|
|
62
|
+
} else if (key === "grace_s") {
|
|
63
|
+
const n = Number(value);
|
|
64
|
+
if (Number.isFinite(n) && n >= 0) policy.grace_s = Math.floor(n);
|
|
65
|
+
else warnings.push(`dispatch-policy: grace_s must be a non-negative number, got "${value}"`);
|
|
66
|
+
} else {
|
|
67
|
+
warnings.push(`dispatch-policy: unknown top-level key "${key}"`);
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!inSubstitutions) continue;
|
|
73
|
+
|
|
74
|
+
// Member header (one indent level, no value).
|
|
75
|
+
if (value === "") {
|
|
76
|
+
if (NAME_RE.test(key)) {
|
|
77
|
+
currentMember = key.toLowerCase();
|
|
78
|
+
policy.substitutions[currentMember] = { prefer: "coms", fallback: "native" };
|
|
79
|
+
} else {
|
|
80
|
+
warnings.push(`dispatch-policy: invalid member name "${key}"`);
|
|
81
|
+
currentMember = null;
|
|
82
|
+
}
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Member field (deeper indent, key: value).
|
|
87
|
+
if (!currentMember) {
|
|
88
|
+
warnings.push(`dispatch-policy: field "${key}" outside a member block`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const sub = policy.substitutions[currentMember];
|
|
92
|
+
if (key === "prefer") {
|
|
93
|
+
if (value === "native" || value === "coms") sub.prefer = value;
|
|
94
|
+
else warnings.push(`dispatch-policy: ${currentMember}.prefer must be native|coms, got "${value}"`);
|
|
95
|
+
} else if (key === "fallback") {
|
|
96
|
+
if (value === "native" || value === "none") sub.fallback = value;
|
|
97
|
+
else warnings.push(`dispatch-policy: ${currentMember}.fallback must be native|none, got "${value}"`);
|
|
98
|
+
} else if (key === "timeout_s") {
|
|
99
|
+
const n = Number(value);
|
|
100
|
+
if (Number.isFinite(n) && n > 0) sub.timeout_s = Math.floor(n);
|
|
101
|
+
else warnings.push(`dispatch-policy: ${currentMember}.timeout_s must be a positive number, got "${value}"`);
|
|
102
|
+
} else {
|
|
103
|
+
warnings.push(`dispatch-policy: unknown field "${key}" for member ${currentMember}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return { policy, warnings };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Decide the backend for one dispatch. Pure: the caller supplies the CURRENT
|
|
111
|
+
// live pool peer names (peersInScope() at dispatch time — hub and peers boot
|
|
112
|
+
// in parallel, so this must never be cached from team activation).
|
|
113
|
+
//
|
|
114
|
+
// Returns one of:
|
|
115
|
+
// { backend: "native" }
|
|
116
|
+
// { backend: "native", comsMissedNotice: "<member> prefers a coms peer ..." }
|
|
117
|
+
// { backend: "coms", peerName, timeout_s? } — peerName is the pool's exact spelling
|
|
118
|
+
// { backend: "await-coms", grace_s } — coms-required, peer not live yet: poll, then refuse
|
|
119
|
+
export function resolveDispatchBackend({ agentName, policy, livePeerNames }) {
|
|
120
|
+
const p = policy && typeof policy === "object" ? policy : DEFAULT_POLICY;
|
|
121
|
+
const name = String(agentName || "").toLowerCase();
|
|
122
|
+
const sub = (p.substitutions || {})[name];
|
|
123
|
+
const prefer = sub ? sub.prefer : p.default === "coms" ? "coms" : "native";
|
|
124
|
+
if (prefer !== "coms") return { backend: "native" };
|
|
125
|
+
|
|
126
|
+
const live = Array.isArray(livePeerNames) ? livePeerNames : [];
|
|
127
|
+
const match = live.find((n) => String(n).toLowerCase() === name);
|
|
128
|
+
if (match !== undefined) {
|
|
129
|
+
const out = { backend: "coms", peerName: String(match) };
|
|
130
|
+
if (sub && sub.timeout_s) out.timeout_s = sub.timeout_s;
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (sub && sub.fallback === "none") {
|
|
135
|
+
return { backend: "await-coms", grace_s: Number.isFinite(p.grace_s) ? p.grace_s : DEFAULT_GRACE_S };
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
backend: "native",
|
|
139
|
+
comsMissedNotice:
|
|
140
|
+
`${agentName}: prefers a coms peer but none named "${name}" is live in the pool — using the native subagent.`,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// The refusal returned when a coms-required member's peer never appeared
|
|
145
|
+
// within the grace window.
|
|
146
|
+
export function comsRequiredRefusal(agentName, graceS) {
|
|
147
|
+
return (
|
|
148
|
+
`"${agentName}" is configured as coms-required (fallback: none) but no live peer named ` +
|
|
149
|
+
`"${String(agentName).toLowerCase()}" appeared in the pool within ${graceS}s. ` +
|
|
150
|
+
"Start it with `just hub-team <team>` / `just team-up <team>`, widen the pool with /coms, " +
|
|
151
|
+
"or set `fallback: native` in .pi/agents/dispatch-policy.yaml."
|
|
152
|
+
);
|
|
153
|
+
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegate — the injected extension that gives an agent-hub specialist a
|
|
3
|
+
* mid-turn `delegate(role, instruction, context?, allow_write?)` tool.
|
|
4
|
+
*
|
|
5
|
+
* The hub adds `-e delegate.ts` (plus `delegate` in the child's `--tools`
|
|
6
|
+
* allowlist — pi's allowlist applies to extension tools too) when a dispatched
|
|
7
|
+
* persona declares `subagents:` in its frontmatter. Everything this extension
|
|
8
|
+
* may spawn comes from AGENT_HUB_DELEGATE_CONFIG (JSON, serialized by the
|
|
9
|
+
* hub): the declared sub-roles and their models, the remaining depth budget,
|
|
10
|
+
* the tree-wide remaining spawn budget, and the event directory. The child
|
|
11
|
+
* process NEVER re-parses persona files — model choice is configuration, not
|
|
12
|
+
* the LLM's whim.
|
|
13
|
+
*
|
|
14
|
+
* Budgets (readable refusals, never silent):
|
|
15
|
+
* - tree-wide spawn budget: at most 4 delegate children per dispatch
|
|
16
|
+
* - depth budget: each child receives `depth − 1`; the hub normally omits
|
|
17
|
+
* delegate tooling from children at remaining depth 0, so a persona with
|
|
18
|
+
* `delegate_depth: 1` (the default and max) can spawn terminal children
|
|
19
|
+
*
|
|
20
|
+
* Write safety: a child is read-only (read,grep,find,ls) unless it is the ONLY
|
|
21
|
+
* live child and the parent passed `allow_write: true` — then it inherits the
|
|
22
|
+
* parent's tools, intersected with the role's declared `tools:` cap when one
|
|
23
|
+
* exists. Concurrent children are always forced read-only (two agents editing
|
|
24
|
+
* the same files is not solvable with guardrails).
|
|
25
|
+
*
|
|
26
|
+
* Observability: every spawn/timeline/usage/exit is appended as JSONL to
|
|
27
|
+
* `<eventDir>/events.jsonl`. The hub watches that file and renders children as
|
|
28
|
+
* nested rows under the parent's grid card (openable via /zoom). Kill cascade:
|
|
29
|
+
* children are spawned in THIS process's group (the hub spawns specialists
|
|
30
|
+
* detached), so `/agents-kill` on the parent SIGTERMs the whole tree; a
|
|
31
|
+
* SIGTERM trap forwards to live children as a fallback.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
35
|
+
import { Type } from "@sinclair/typebox";
|
|
36
|
+
import { appendFileSync, mkdirSync, writeFileSync } from "fs";
|
|
37
|
+
import type { ChildProcess } from "child_process";
|
|
38
|
+
import { spawnPiAgent } from "./spawn.ts";
|
|
39
|
+
import {
|
|
40
|
+
delegateBudgetRefusal,
|
|
41
|
+
DELEGATE_TREE_SPAWN_BUDGET,
|
|
42
|
+
normalizeDelegateRuntimeBudgets,
|
|
43
|
+
planDelegateSpawn,
|
|
44
|
+
resolveDelegateTools,
|
|
45
|
+
safeAgentKey,
|
|
46
|
+
safePathWithin,
|
|
47
|
+
} from "./helpers.ts";
|
|
48
|
+
|
|
49
|
+
const DEFAULT_CALL_BUDGET = DELEGATE_TREE_SPAWN_BUDGET;
|
|
50
|
+
const RESULT_CAP = 2000;
|
|
51
|
+
const DIGEST_MAX_LINES = 30;
|
|
52
|
+
// How often buffered text/thinking deltas are flushed into the event file.
|
|
53
|
+
const TIMELINE_FLUSH_MS = 700;
|
|
54
|
+
|
|
55
|
+
// Serialized by the hub into AGENT_HUB_DELEGATE_CONFIG. `tag` is this
|
|
56
|
+
// process's node id in the delegation tree ("root" for the specialist itself);
|
|
57
|
+
// nested delegate.ts instances get their child id as tag, so every event line
|
|
58
|
+
// carries an unambiguous parent chain.
|
|
59
|
+
export interface DelegateConfig {
|
|
60
|
+
persona: string;
|
|
61
|
+
tag: string;
|
|
62
|
+
roles: Record<string, { model: string; tools?: string }>;
|
|
63
|
+
depth: number;
|
|
64
|
+
callBudget: number;
|
|
65
|
+
remainingSpawns?: number;
|
|
66
|
+
parentTools: string;
|
|
67
|
+
personaPrompt: string;
|
|
68
|
+
eventDir: string;
|
|
69
|
+
damageControl?: string;
|
|
70
|
+
delegateExt: string;
|
|
71
|
+
cwd: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Appended to every child's system prompt so it knows its place in the tree
|
|
75
|
+
// and reports tersely (its full report returns through the tool result, which
|
|
76
|
+
// lands in the parent's context).
|
|
77
|
+
function subagentProtocol(persona: string, role: string, canDelegate: boolean): string {
|
|
78
|
+
return `
|
|
79
|
+
|
|
80
|
+
## You are the "${role}" sub-agent of a ${persona} specialist
|
|
81
|
+
Your parent delegated ONE specific task to you. Do exactly that task — do not
|
|
82
|
+
widen scope, do not start unrelated work. Your full output is written to a result
|
|
83
|
+
file, but your parent receives only a compact digest. End your final message with
|
|
84
|
+
a \`DIGEST:\` section of no more than 30 lines, self-contained, with path:line
|
|
85
|
+
citations where relevant. Put the most important findings and next actions there.${canDelegate ? `
|
|
86
|
+
You may delegate narrow sub-tasks further via your own delegate tool, within
|
|
87
|
+
its declared roles and remaining tree budget.` : `
|
|
88
|
+
You CANNOT delegate further — your remaining depth is 0, so this child has no
|
|
89
|
+
delegate tooling. Do the work yourself with the tools you have.`}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function childResultDigest(output: string, resultPath: string): { text: string; hasDigest: boolean } {
|
|
93
|
+
const lines = String(output || "").split(/\r?\n/);
|
|
94
|
+
const marker = lines.map(l => l.trim()).findIndex(l => /^DIGEST:\s*$/i.test(l));
|
|
95
|
+
if (marker >= 0) {
|
|
96
|
+
const digestLines = lines.slice(marker, marker + DIGEST_MAX_LINES);
|
|
97
|
+
return {
|
|
98
|
+
text: capInline(`${digestLines.join("\n")}\n\nFull output: ${resultPath}\nRead the result file only if this digest is insufficient.`),
|
|
99
|
+
hasDigest: true,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const fallback = lines.slice(0, DIGEST_MAX_LINES).join("\n");
|
|
103
|
+
return {
|
|
104
|
+
text: capInline(`${fallback}\n\n[no DIGEST section — full output at ${resultPath}]`),
|
|
105
|
+
hasDigest: false,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function capInline(text: string): string {
|
|
110
|
+
return text.length > RESULT_CAP ? text.slice(0, RESULT_CAP) + "\n... [digest truncated]" : text;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default function (pi: ExtensionAPI) {
|
|
114
|
+
let cfg: DelegateConfig | null = null;
|
|
115
|
+
try {
|
|
116
|
+
cfg = JSON.parse(process.env.AGENT_HUB_DELEGATE_CONFIG || "");
|
|
117
|
+
} catch {
|
|
118
|
+
cfg = null;
|
|
119
|
+
}
|
|
120
|
+
// Misconfigured (or launched outside the hub): register nothing — the
|
|
121
|
+
// parent simply has no delegate tool.
|
|
122
|
+
if (!cfg || !cfg.roles || !cfg.eventDir) return;
|
|
123
|
+
const config = cfg;
|
|
124
|
+
const budgets = normalizeDelegateRuntimeBudgets(config, DEFAULT_CALL_BUDGET);
|
|
125
|
+
config.depth = budgets.depth;
|
|
126
|
+
config.callBudget = budgets.callBudget;
|
|
127
|
+
config.remainingSpawns = budgets.remainingSpawns;
|
|
128
|
+
|
|
129
|
+
let callCount = 0;
|
|
130
|
+
let childSeq = 0;
|
|
131
|
+
// Synchronous reservation counter for the write-safety gate. Incremented at
|
|
132
|
+
// the gate (before any await), so two parallel delegate calls can never both
|
|
133
|
+
// observe "I am the only child" — do NOT replace this with liveChildren.size,
|
|
134
|
+
// which only grows once the child process actually spawns.
|
|
135
|
+
let liveCount = 0;
|
|
136
|
+
const liveChildren = new Set<ChildProcess>();
|
|
137
|
+
|
|
138
|
+
// Fallback cascade: the primary kill path is the process group (the hub
|
|
139
|
+
// signals the specialist's negative PID), but if only this process is
|
|
140
|
+
// terminated, forward the signal to any live children.
|
|
141
|
+
process.on("SIGTERM", () => {
|
|
142
|
+
for (const child of liveChildren) {
|
|
143
|
+
try { child.kill("SIGTERM"); } catch {}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const emit = (event: Record<string, unknown>) => {
|
|
148
|
+
try {
|
|
149
|
+
appendFileSync(safePathWithin(config.eventDir, "events.jsonl"), JSON.stringify(event) + "\n", "utf-8");
|
|
150
|
+
} catch {}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const roleNames = Object.keys(config.roles).filter((name) => {
|
|
154
|
+
try { safeAgentKey(name); return true; } catch { return false; }
|
|
155
|
+
});
|
|
156
|
+
if (roleNames.length === 0) return;
|
|
157
|
+
|
|
158
|
+
pi.registerTool({
|
|
159
|
+
name: "delegate",
|
|
160
|
+
label: "Delegate",
|
|
161
|
+
description:
|
|
162
|
+
`Spawn one of your declared sub-agents on its pre-configured model and wait for its report. ` +
|
|
163
|
+
`Declared roles: ${roleNames.join(", ")}. Use it to fan out scoped sub-tasks (reviews, scans, ` +
|
|
164
|
+
`doc checks) instead of doing everything yourself; at most ${DELEGATE_TREE_SPAWN_BUDGET} ` +
|
|
165
|
+
`children may be spawned per dispatch, and parallel children are forced read-only. The child ` +
|
|
166
|
+
`does not share your context — pass everything it needs in \`instruction\`/\`context\`.`,
|
|
167
|
+
parameters: Type.Object({
|
|
168
|
+
role: Type.String({ description: `Declared sub-role to spawn. One of: ${roleNames.join(", ")}` }),
|
|
169
|
+
instruction: Type.String({ description: "The specific, self-contained task for the sub-agent." }),
|
|
170
|
+
context: Type.Optional(Type.String({
|
|
171
|
+
description: "Optional background brief pasted above the instruction (the child shares none of " +
|
|
172
|
+
"your context). The keyword 'fork' (full context fork) is accepted but treated as a summary " +
|
|
173
|
+
"brief in v1 — write the brief out.",
|
|
174
|
+
})),
|
|
175
|
+
allow_write: Type.Optional(Type.Boolean({
|
|
176
|
+
description: "Let the child inherit your tools (including write access). Honored only while it " +
|
|
177
|
+
"is your ONLY live child; concurrent children are always read-only. A role-level tools cap " +
|
|
178
|
+
"still wins and refuses delegation if it leaves no tools.",
|
|
179
|
+
})),
|
|
180
|
+
}),
|
|
181
|
+
|
|
182
|
+
async execute(_toolCallId, params, _signal, onUpdate) {
|
|
183
|
+
const { role, instruction, context, allow_write } = params as {
|
|
184
|
+
role: string; instruction: string; context?: string; allow_write?: boolean;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// Readable refusals — budget exhaustion is an answer, not a mystery.
|
|
188
|
+
const budgetRefusal = delegateBudgetRefusal({
|
|
189
|
+
depth: config.depth,
|
|
190
|
+
callBudget: config.callBudget,
|
|
191
|
+
remainingSpawns: config.remainingSpawns ?? 0,
|
|
192
|
+
callCount,
|
|
193
|
+
});
|
|
194
|
+
if (budgetRefusal) {
|
|
195
|
+
return { content: [{ type: "text" as const, text: budgetRefusal }] };
|
|
196
|
+
}
|
|
197
|
+
const roleKey = roleNames.find(r => r.toLowerCase() === role.toLowerCase());
|
|
198
|
+
if (!roleKey) {
|
|
199
|
+
return {
|
|
200
|
+
content: [{ type: "text" as const, text:
|
|
201
|
+
`Delegation refused: "${role}" is not a declared sub-role. Declared roles: ` +
|
|
202
|
+
`${roleNames.join(", ")}.` }],
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const roleDef = config.roles[roleKey];
|
|
206
|
+
|
|
207
|
+
// Write safety: read-only unless this is the only live child AND the
|
|
208
|
+
// parent explicitly granted write. The role's tools cap always wins.
|
|
209
|
+
const tools = resolveDelegateTools({
|
|
210
|
+
parentTools: config.parentTools,
|
|
211
|
+
roleTools: roleDef.tools,
|
|
212
|
+
allowWrite: allow_write === true,
|
|
213
|
+
concurrent: liveCount > 0,
|
|
214
|
+
});
|
|
215
|
+
if (tools.refused) {
|
|
216
|
+
return {
|
|
217
|
+
content: [{ type: "text" as const, text:
|
|
218
|
+
`Delegation refused: role "${roleKey}" declares tools "${roleDef.tools}" but none are ` +
|
|
219
|
+
`available under the current parent/concurrency tool policy.` }],
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const effectiveTools = tools.effectiveTools;
|
|
223
|
+
const writeDowngraded = tools.writeDowngraded;
|
|
224
|
+
|
|
225
|
+
callCount++;
|
|
226
|
+
childSeq++;
|
|
227
|
+
const plan = planDelegateSpawn({
|
|
228
|
+
tag: config.tag,
|
|
229
|
+
roleKey,
|
|
230
|
+
childSeq,
|
|
231
|
+
depth: config.depth,
|
|
232
|
+
remainingSpawns: config.remainingSpawns ?? 0,
|
|
233
|
+
effectiveTools,
|
|
234
|
+
damageControl: config.damageControl,
|
|
235
|
+
delegateExt: config.delegateExt,
|
|
236
|
+
});
|
|
237
|
+
config.remainingSpawns = plan.nextRemainingSpawns;
|
|
238
|
+
const childId = plan.childId;
|
|
239
|
+
const childDepth = plan.childDepth;
|
|
240
|
+
const childRemainingSpawns = plan.childRemainingSpawns;
|
|
241
|
+
const childCanDelegate = plan.childCanDelegate;
|
|
242
|
+
const childExtensions = plan.childExtensions;
|
|
243
|
+
const childTools = plan.childTools;
|
|
244
|
+
const childConfig: DelegateConfig | null = plan.includeDelegateConfig ? {
|
|
245
|
+
...config,
|
|
246
|
+
tag: childId,
|
|
247
|
+
depth: childDepth,
|
|
248
|
+
remainingSpawns: childRemainingSpawns,
|
|
249
|
+
parentTools: effectiveTools,
|
|
250
|
+
} : null;
|
|
251
|
+
|
|
252
|
+
const sessionsDir = safePathWithin(config.eventDir, "sessions");
|
|
253
|
+
const resultsDir = safePathWithin(config.eventDir, "results");
|
|
254
|
+
const childSessionFile = safePathWithin(sessionsDir, `${childId}.jsonl`);
|
|
255
|
+
const childResultFile = safePathWithin(resultsDir, `${childId}.md`);
|
|
256
|
+
try { mkdirSync(sessionsDir, { recursive: true }); } catch {}
|
|
257
|
+
try { mkdirSync(resultsDir, { recursive: true }); } catch {}
|
|
258
|
+
|
|
259
|
+
emit({
|
|
260
|
+
t: "spawn", id: childId, parent: config.tag, role: roleKey,
|
|
261
|
+
model: roleDef.model, tools: effectiveTools, remainingSpawns: childRemainingSpawns, ts: Date.now(),
|
|
262
|
+
});
|
|
263
|
+
onUpdate?.({
|
|
264
|
+
content: [{ type: "text", text: `Delegating to ${roleKey} (${roleDef.model})...` }],
|
|
265
|
+
details: { id: childId, role: roleKey, model: roleDef.model, status: "running" },
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// Buffered timeline streaming: coalesce text/thinking deltas and flush
|
|
269
|
+
// them into the event file on an interval (and on tool/exit), so the
|
|
270
|
+
// hub can render a live /zoom timeline without an event per token.
|
|
271
|
+
let pendingKind: "text" | "thinking" | null = null;
|
|
272
|
+
let pendingDelta = "";
|
|
273
|
+
const flushTimeline = () => {
|
|
274
|
+
if (!pendingKind || !pendingDelta) return;
|
|
275
|
+
emit({ t: "timeline", id: childId, kind: pendingKind, delta: pendingDelta });
|
|
276
|
+
pendingDelta = "";
|
|
277
|
+
};
|
|
278
|
+
const queueDelta = (kind: "text" | "thinking", delta: string) => {
|
|
279
|
+
if (pendingKind !== kind) flushTimeline();
|
|
280
|
+
pendingKind = kind;
|
|
281
|
+
pendingDelta += delta;
|
|
282
|
+
};
|
|
283
|
+
const flushTimer = setInterval(flushTimeline, TIMELINE_FLUSH_MS);
|
|
284
|
+
|
|
285
|
+
const startTime = Date.now();
|
|
286
|
+
let childProc: ChildProcess | null = null;
|
|
287
|
+
const mode = context?.trim().toLowerCase();
|
|
288
|
+
const brief = context && mode !== "summary" && mode !== "fork" ? context : undefined;
|
|
289
|
+
const prompt = brief
|
|
290
|
+
? `## Context from your parent\n${brief}\n\n## Your task\n${instruction}`
|
|
291
|
+
: instruction;
|
|
292
|
+
|
|
293
|
+
let res;
|
|
294
|
+
liveCount++;
|
|
295
|
+
try {
|
|
296
|
+
res = await spawnPiAgent({
|
|
297
|
+
model: roleDef.model,
|
|
298
|
+
tools: childTools,
|
|
299
|
+
thinking: "off",
|
|
300
|
+
appendSystemPrompt: subagentProtocol(config.persona, roleKey, childCanDelegate),
|
|
301
|
+
sessionFile: childSessionFile,
|
|
302
|
+
prompt,
|
|
303
|
+
extensions: childExtensions,
|
|
304
|
+
env: childConfig ? { AGENT_HUB_DELEGATE_CONFIG: JSON.stringify(childConfig) } : undefined,
|
|
305
|
+
cwd: config.cwd,
|
|
306
|
+
}, {
|
|
307
|
+
onProcess: (p) => { childProc = p; liveChildren.add(p); },
|
|
308
|
+
onTextDelta: (delta) => queueDelta("text", delta),
|
|
309
|
+
onThinkingDelta: (delta) => queueDelta("thinking", delta),
|
|
310
|
+
onToolStart: (toolName, argStr) => {
|
|
311
|
+
flushTimeline();
|
|
312
|
+
emit({ t: "tool", id: childId, name: toolName, args: argStr.slice(0, 500) });
|
|
313
|
+
},
|
|
314
|
+
onUsage: (usage, source) => {
|
|
315
|
+
if (source === "message_end") {
|
|
316
|
+
emit({ t: "usage", id: childId, input: usage.input || 0, output: usage.output || 0 });
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
} finally {
|
|
321
|
+
liveCount--;
|
|
322
|
+
clearInterval(flushTimer);
|
|
323
|
+
if (childProc) liveChildren.delete(childProc);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
flushTimeline();
|
|
327
|
+
const elapsed = Date.now() - startTime;
|
|
328
|
+
const code = res.spawnError ? 1 : (res.exitCode ?? 1);
|
|
329
|
+
emit({ t: "exit", id: childId, code, elapsed, ts: Date.now() });
|
|
330
|
+
|
|
331
|
+
if (res.spawnError) {
|
|
332
|
+
const spawnFailure = `Delegate ${childId} failed to spawn: ${res.spawnError}`;
|
|
333
|
+
try { writeFileSync(childResultFile, spawnFailure + "\n", "utf-8"); } catch {}
|
|
334
|
+
return {
|
|
335
|
+
content: [{ type: "text" as const, text: `${spawnFailure}\n\nFull output: ${childResultFile}` }],
|
|
336
|
+
details: { id: childId, role: roleKey, status: "error", resultPath: childResultFile },
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
let output = res.output;
|
|
341
|
+
if (code !== 0) {
|
|
342
|
+
const errTail = res.stderr.trim().slice(-1000);
|
|
343
|
+
output = output
|
|
344
|
+
? `${output}\n\n[stderr]\n${errTail}`
|
|
345
|
+
: `Delegate ${childId} exited with code ${code} and produced no output.\n\n[stderr]\n${errTail}`;
|
|
346
|
+
}
|
|
347
|
+
try { writeFileSync(childResultFile, output, "utf-8"); } catch {}
|
|
348
|
+
const digest = childResultDigest(output, childResultFile);
|
|
349
|
+
|
|
350
|
+
const notes: string[] = [];
|
|
351
|
+
if (writeDowngraded) notes.push("allow_write ignored — other children were live, so it ran read-only");
|
|
352
|
+
if (mode === "fork") notes.push("context: fork is not supported in v1 — the child started fresh from your instruction");
|
|
353
|
+
const noteBlock = notes.length > 0 ? `\n[note: ${notes.join("; ")}]` : "";
|
|
354
|
+
|
|
355
|
+
return {
|
|
356
|
+
content: [{ type: "text" as const, text:
|
|
357
|
+
`[delegate ${childId} · ${roleDef.model} · ${effectiveTools}] ${code === 0 ? "done" : "error"} ` +
|
|
358
|
+
`in ${Math.round(elapsed / 1000)}s${noteBlock}\n\n${digest.text}` }],
|
|
359
|
+
details: { id: childId, role: roleKey, model: roleDef.model, status: code === 0 ? "done" : "error", elapsed, resultPath: childResultFile, digestFound: digest.hasDigest },
|
|
360
|
+
};
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
2
|
+
|
|
3
|
+
const KNOWN_TAGS = new Set(["test", "runtime-ui", "code-grep", "manual"]);
|
|
4
|
+
|
|
5
|
+
export function validateEvidence(tag, evidence, options = {}) {
|
|
6
|
+
const normalizedTag = String(tag || "").trim().toLowerCase();
|
|
7
|
+
const text = String(evidence || "").trim();
|
|
8
|
+
if (!KNOWN_TAGS.has(normalizedTag)) {
|
|
9
|
+
return { ok: false, reason: `Unknown assertion tag "${tag}"; expected one of test, runtime-ui, code-grep, manual.` };
|
|
10
|
+
}
|
|
11
|
+
if (!text) return { ok: false, reason: "Evidence is required." };
|
|
12
|
+
|
|
13
|
+
if (normalizedTag === "test") return validateTestEvidence(text);
|
|
14
|
+
if (normalizedTag === "runtime-ui") return validateRuntimeUiEvidence(text, options);
|
|
15
|
+
if (normalizedTag === "code-grep") return validateCodeGrepEvidence(text);
|
|
16
|
+
if (normalizedTag === "manual") return validateManualEvidence(text);
|
|
17
|
+
return { ok: false, reason: `Unknown assertion tag "${tag}".` };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function validateTestEvidence(text) {
|
|
21
|
+
const hasIdentifier = /(?:\b(?:npm|pnpm|yarn|node|npx|vitest|jest|pytest|playwright|cargo|go test|bun)\b|\btest(?:s| name| file)?\b|`[^`]+`)/i.test(text);
|
|
22
|
+
const hasOutcome = /(?:\bpass(?:ed|es)?\b|\bgreen\b|\bok\b|\bexit\s*0\b|\b0\s+fail(?:ed|ures)?\b|\b\d+\/\d+\b|✓|✔)/i.test(text);
|
|
23
|
+
if (!hasIdentifier && !hasOutcome) return { ok: false, reason: "Test evidence must name the command/test identifier and its outcome." };
|
|
24
|
+
if (!hasIdentifier) return { ok: false, reason: "Test evidence must name the command or test identifier." };
|
|
25
|
+
if (!hasOutcome) return { ok: false, reason: "Test evidence must include the test outcome (pass/fail count, exit status, or equivalent)." };
|
|
26
|
+
return { ok: true };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function validateRuntimeUiEvidence(text, options) {
|
|
30
|
+
const candidates = extractPathCandidates(text).filter((p) => /(?:^|\/)artifacts\/evidence\//.test(normalizePath(p)));
|
|
31
|
+
if (candidates.length === 0) {
|
|
32
|
+
return { ok: false, reason: "Runtime-ui evidence must reference a session artifact path under artifacts/evidence/." };
|
|
33
|
+
}
|
|
34
|
+
const fileExists = typeof options.fileExists === "function" ? options.fileExists : () => false;
|
|
35
|
+
const evidenceRoot = options.evidenceRoot ? resolve(options.evidenceRoot) : null;
|
|
36
|
+
const resolvedCandidates = candidates.map((p) => resolveSessionEvidenceCandidate(p, evidenceRoot)).filter(Boolean);
|
|
37
|
+
if (resolvedCandidates.length === 0) {
|
|
38
|
+
return { ok: false, reason: "Runtime-ui evidence must reference a session artifact evidence path, not a repo-local ./artifacts path." };
|
|
39
|
+
}
|
|
40
|
+
const existing = resolvedCandidates.find((p) => {
|
|
41
|
+
try { return fileExists(p); } catch { return false; }
|
|
42
|
+
});
|
|
43
|
+
if (!existing) {
|
|
44
|
+
return { ok: false, reason: `Runtime-ui evidence artifact does not exist: ${resolvedCandidates[0]}.` };
|
|
45
|
+
}
|
|
46
|
+
return { ok: true };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function validateCodeGrepEvidence(text) {
|
|
50
|
+
const hasPattern = /(?:\bpattern\s*:|\bregex\s*:|\bgrep\b|`[^`]+`|\/[^/]+\/)/i.test(text);
|
|
51
|
+
const hasSample = /(?:\bmatch(?:ed|es)?\b|\bno[- ]?match(?:es)?\b|\b0\s+matches\b|\bfound\b|\bnot found\b|[\w./-]+:\d+)/i.test(text);
|
|
52
|
+
if (!hasPattern && !hasSample) return { ok: false, reason: "Code-grep evidence must include the searched pattern and a match/no-match result sample." };
|
|
53
|
+
if (!hasPattern) return { ok: false, reason: "Code-grep evidence must include the searched pattern." };
|
|
54
|
+
if (!hasSample) return { ok: false, reason: "Code-grep evidence must include a match/no-match result sample." };
|
|
55
|
+
return { ok: true };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function validateManualEvidence(text) {
|
|
59
|
+
const hasConfirmation = /(?:\bask_user\b|\bhuman\s+confirm(?:ed|ation)\b|\buser\s+(?:confirmed|said|approved|chose|answered)\b|\bmanual\s+confirm(?:ed|ation)\b|"[^"]+")/i.test(text);
|
|
60
|
+
if (!hasConfirmation) return { ok: false, reason: "Manual evidence must reference the ask_user answer or explicit user confirmation." };
|
|
61
|
+
return { ok: true };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function extractPathCandidates(text) {
|
|
65
|
+
const out = [];
|
|
66
|
+
const re = /(?:^|[\s(\[])(["']?)([^"'\s)\]]*(?:\.pi\/agent-sessions\/)?artifacts\/evidence\/[^"'\s)\]]+)\1/g;
|
|
67
|
+
let match;
|
|
68
|
+
while ((match = re.exec(text))) out.push(match[2].replace(/[.,;:]+$/, ""));
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function resolveSessionEvidenceCandidate(candidate, evidenceRoot) {
|
|
73
|
+
const raw = String(candidate || "").trim();
|
|
74
|
+
const normalized = normalizePath(raw);
|
|
75
|
+
if (normalized.startsWith("./artifacts/evidence/")) return null;
|
|
76
|
+
if (evidenceRoot && normalized.startsWith("artifacts/evidence/")) {
|
|
77
|
+
return resolve(evidenceRoot, normalized.slice("artifacts/evidence/".length));
|
|
78
|
+
}
|
|
79
|
+
if (evidenceRoot && normalized.startsWith(".pi/agent-sessions/artifacts/evidence/")) {
|
|
80
|
+
return resolve(evidenceRoot, normalized.slice(".pi/agent-sessions/artifacts/evidence/".length));
|
|
81
|
+
}
|
|
82
|
+
if (isAbsolute(raw)) {
|
|
83
|
+
const abs = resolve(raw);
|
|
84
|
+
return !evidenceRoot || isWithin(evidenceRoot, abs) ? abs : null;
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function isWithin(root, target) {
|
|
90
|
+
const rel = relative(resolve(root), resolve(target));
|
|
91
|
+
return rel === "" || (!!rel && !rel.startsWith("..") && !isAbsolute(rel));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function normalizePath(value) {
|
|
95
|
+
return String(value || "").replace(/\\/g, "/");
|
|
96
|
+
}
|