@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,215 @@
|
|
|
1
|
+
const STRUCTURED_KEYS = [
|
|
2
|
+
"changed_files",
|
|
3
|
+
"assertions_proven",
|
|
4
|
+
"assertions_unproven",
|
|
5
|
+
"assertions_failed",
|
|
6
|
+
"tests_run",
|
|
7
|
+
"open_risks",
|
|
8
|
+
"requires_user_decision",
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const ASSERTION_KEYS = new Set(["assertions_proven", "assertions_unproven", "assertions_failed"]);
|
|
12
|
+
|
|
13
|
+
export function extractAssertionIds(taskText) {
|
|
14
|
+
const ids = [];
|
|
15
|
+
const seen = new Set();
|
|
16
|
+
for (const match of String(taskText || "").matchAll(/\bA\d+\b/g)) {
|
|
17
|
+
const id = match[0];
|
|
18
|
+
if (!seen.has(id)) {
|
|
19
|
+
seen.add(id);
|
|
20
|
+
ids.push(id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return ids;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function parseStructuredReturn(finalText) {
|
|
27
|
+
const text = String(finalText || "");
|
|
28
|
+
const candidates = fencedBlocks(text);
|
|
29
|
+
candidates.push(text);
|
|
30
|
+
|
|
31
|
+
let best = null;
|
|
32
|
+
for (const candidate of candidates) {
|
|
33
|
+
const parsed = parseCandidate(candidate);
|
|
34
|
+
if (parsed && (!best || parsed.__score > best.__score)) best = parsed;
|
|
35
|
+
}
|
|
36
|
+
if (!best) return null;
|
|
37
|
+
delete best.__score;
|
|
38
|
+
return best;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function crossCheck(parsed, dispatchedIds) {
|
|
42
|
+
const ids = Array.from(new Set(dispatchedIds || []));
|
|
43
|
+
if (!parsed) {
|
|
44
|
+
return ids.length > 0 ? [{ type: "no_structured_return", ids }] : [];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const notices = [];
|
|
48
|
+
const present = new Set();
|
|
49
|
+
for (const key of ["assertions_proven", "assertions_unproven", "assertions_failed"]) {
|
|
50
|
+
for (const entry of parsed[key] || []) {
|
|
51
|
+
if (entry && entry.id) present.add(entry.id);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const id of ids) {
|
|
55
|
+
if (!present.has(id)) notices.push({ type: "missing", id });
|
|
56
|
+
}
|
|
57
|
+
for (const entry of parsed.assertions_proven || []) {
|
|
58
|
+
if (entry && entry.id && !entry.evidence) {
|
|
59
|
+
notices.push({ type: "proven_without_evidence", id: entry.id, note: entry.note || "" });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return notices;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function fencedBlocks(text) {
|
|
66
|
+
const blocks = [];
|
|
67
|
+
const re = /```[^\n]*\n([\s\S]*?)```/g;
|
|
68
|
+
let match;
|
|
69
|
+
while ((match = re.exec(text))) blocks.push(match[1]);
|
|
70
|
+
return blocks;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function parseCandidate(text) {
|
|
74
|
+
const result = Object.fromEntries(STRUCTURED_KEYS.map((key) => [key, []]));
|
|
75
|
+
let score = 0;
|
|
76
|
+
|
|
77
|
+
const keyBlocks = collectKeyBlocks(text);
|
|
78
|
+
for (const [key, block] of keyBlocks) {
|
|
79
|
+
result[key] = parseEntries(key, block);
|
|
80
|
+
score += 2 + result[key].length;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const sectionBlocks = collectMarkdownSections(text);
|
|
84
|
+
for (const [key, block] of sectionBlocks) {
|
|
85
|
+
if (!keyBlocks.has(key)) {
|
|
86
|
+
result[key] = parseEntries(key, block);
|
|
87
|
+
score += 1 + result[key].length;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (score === 0) return null;
|
|
92
|
+
result.__score = score;
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function collectKeyBlocks(text) {
|
|
97
|
+
const found = new Map();
|
|
98
|
+
const lines = text.split(/\r?\n/);
|
|
99
|
+
for (let i = 0; i < lines.length; i++) {
|
|
100
|
+
const match = lines[i].match(/^\s*([A-Za-z][A-Za-z0-9_ -]*)\s*:\s*(.*)$/);
|
|
101
|
+
if (!match) continue;
|
|
102
|
+
const key = normalizeKey(match[1]);
|
|
103
|
+
if (!STRUCTURED_KEYS.includes(key)) continue;
|
|
104
|
+
|
|
105
|
+
const block = [match[2] || ""];
|
|
106
|
+
let bracketBalance = balanceBrackets(match[2] || "");
|
|
107
|
+
let j = i + 1;
|
|
108
|
+
for (; j < lines.length; j++) {
|
|
109
|
+
const next = lines[j];
|
|
110
|
+
const nextKey = next.match(/^\s*([A-Za-z][A-Za-z0-9_ -]*)\s*:\s*/);
|
|
111
|
+
const isKnownNextKey = nextKey && STRUCTURED_KEYS.includes(normalizeKey(nextKey[1]));
|
|
112
|
+
const isHeading = /^\s*#{1,6}\s+/.test(next);
|
|
113
|
+
if (bracketBalance <= 0 && (isKnownNextKey || isHeading)) break;
|
|
114
|
+
if (next.trim() === "" && bracketBalance <= 0) break;
|
|
115
|
+
block.push(next);
|
|
116
|
+
bracketBalance += balanceBrackets(next);
|
|
117
|
+
}
|
|
118
|
+
found.set(key, block.join("\n"));
|
|
119
|
+
}
|
|
120
|
+
return found;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function collectMarkdownSections(text) {
|
|
124
|
+
const found = new Map();
|
|
125
|
+
const lines = text.split(/\r?\n/);
|
|
126
|
+
for (let i = 0; i < lines.length; i++) {
|
|
127
|
+
const match = lines[i].match(/^\s*#{1,6}\s+(.+?)\s*#*\s*$/);
|
|
128
|
+
if (!match) continue;
|
|
129
|
+
const key = normalizeKey(match[1]);
|
|
130
|
+
if (!STRUCTURED_KEYS.includes(key)) continue;
|
|
131
|
+
const block = [];
|
|
132
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
133
|
+
if (/^\s*#{1,6}\s+/.test(lines[j])) break;
|
|
134
|
+
block.push(lines[j]);
|
|
135
|
+
}
|
|
136
|
+
found.set(key, block.join("\n"));
|
|
137
|
+
}
|
|
138
|
+
return found;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function parseEntries(key, rawBlock) {
|
|
142
|
+
if (ASSERTION_KEYS.has(key)) {
|
|
143
|
+
return splitAssertionEntries(rawBlock).map(parseAssertionEntry).filter(Boolean);
|
|
144
|
+
}
|
|
145
|
+
return splitListEntries(rawBlock);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function normalizeListBlock(rawBlock) {
|
|
149
|
+
let block = String(rawBlock || "").trim();
|
|
150
|
+
if (!block || block === "[]") return "";
|
|
151
|
+
if (block.startsWith("[") && block.endsWith("]")) block = block.slice(1, -1);
|
|
152
|
+
return block;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function strippedLines(block) {
|
|
156
|
+
return block.split(/\r?\n/)
|
|
157
|
+
.map((line) => line.trim())
|
|
158
|
+
.filter(Boolean)
|
|
159
|
+
.map((line) => line.replace(/^[-*]\s+/, "").replace(/^\d+[.)]\s+/, "").replace(/,$/, "").trim())
|
|
160
|
+
.filter(Boolean);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function splitListEntries(rawBlock) {
|
|
164
|
+
const block = normalizeListBlock(rawBlock);
|
|
165
|
+
if (!block) return [];
|
|
166
|
+
const rawLines = block.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
167
|
+
const hasBulletLines = rawLines.some((line) => /^([-*]|\d+[.)])\s+/.test(line));
|
|
168
|
+
if (hasBulletLines) return strippedLines(block);
|
|
169
|
+
return [block.trim()];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function splitAssertionEntries(rawBlock) {
|
|
173
|
+
const block = normalizeListBlock(rawBlock);
|
|
174
|
+
if (!block) return [];
|
|
175
|
+
const rawLines = block.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
176
|
+
const hasBoundaryLines = rawLines.some((line) => /^([-*]|\d+[.)])\s+\bA\d+\b/.test(line));
|
|
177
|
+
if (hasBoundaryLines) return strippedLines(block).filter((line) => /^\bA\d+\b/.test(line));
|
|
178
|
+
return block
|
|
179
|
+
.split(/,(?=\s*A\d+\s*[:\-–—])/g)
|
|
180
|
+
.map((part) => part.trim().replace(/^,+\s*/, "").replace(/,+\s*$/, ""))
|
|
181
|
+
.filter(Boolean);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function parseAssertionEntry(entry) {
|
|
185
|
+
const text = String(entry || "").trim();
|
|
186
|
+
const idMatch = text.match(/\bA\d+\b/);
|
|
187
|
+
if (!idMatch) return null;
|
|
188
|
+
const id = idMatch[0];
|
|
189
|
+
let rest = text.slice((idMatch.index || 0) + id.length).trim();
|
|
190
|
+
rest = rest.replace(/^[:\-–—]\s*/, "");
|
|
191
|
+
|
|
192
|
+
let evidence = null;
|
|
193
|
+
const evidenceMatch = rest.match(/(?:^|\s+[—–-]\s*|\s+)evidence\s*:\s*([\s\S]*)$/i);
|
|
194
|
+
if (evidenceMatch) {
|
|
195
|
+
evidence = evidenceMatch[1].trim() || null;
|
|
196
|
+
rest = rest.slice(0, evidenceMatch.index).trim();
|
|
197
|
+
}
|
|
198
|
+
const note = rest.replace(/[✓✔]\s*$/u, "").trim();
|
|
199
|
+
return { id, note, evidence };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function normalizeKey(value) {
|
|
203
|
+
return String(value || "")
|
|
204
|
+
.trim()
|
|
205
|
+
.toLowerCase()
|
|
206
|
+
.replace(/[`*]/g, "")
|
|
207
|
+
.replace(/[^a-z0-9]+/g, "_")
|
|
208
|
+
.replace(/^_+|_+$/g, "");
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function balanceBrackets(value) {
|
|
212
|
+
const opens = (String(value).match(/\[/g) || []).length;
|
|
213
|
+
const closes = (String(value).match(/\]/g) || []).length;
|
|
214
|
+
return opens - closes;
|
|
215
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
export function snapshotWorktree(cwd) {
|
|
4
|
+
const status = gitStatus(cwd);
|
|
5
|
+
if (status.skipped) return { skipped: true, reason: status.reason, paths: new Set() };
|
|
6
|
+
return { skipped: false, paths: new Set(status.paths) };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function diffAgainst(snapshot, cwd) {
|
|
10
|
+
const current = snapshotWorktree(cwd);
|
|
11
|
+
if (snapshot?.skipped || current.skipped) {
|
|
12
|
+
return { skipped: true, reason: snapshot?.reason || current.reason || "scope gate skipped", paths: [] };
|
|
13
|
+
}
|
|
14
|
+
const before = snapshot?.paths instanceof Set ? snapshot.paths : new Set(snapshot?.paths || []);
|
|
15
|
+
const paths = [...current.paths].filter((p) => !before.has(p)).sort();
|
|
16
|
+
return { skipped: false, paths };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function checkScope(changedPaths, scopeGlobs) {
|
|
20
|
+
const scopes = (scopeGlobs || []).map(normalizePath).filter(Boolean);
|
|
21
|
+
const inScope = [];
|
|
22
|
+
const outOfScope = [];
|
|
23
|
+
for (const rawPath of changedPaths || []) {
|
|
24
|
+
const changed = normalizePath(rawPath);
|
|
25
|
+
if (!changed) continue;
|
|
26
|
+
if (scopes.some((scope) => matchesScope(changed, scope))) inScope.push(changed);
|
|
27
|
+
else outOfScope.push(changed);
|
|
28
|
+
}
|
|
29
|
+
return { inScope: uniqueSorted(inScope), outOfScope: uniqueSorted(outOfScope) };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function gitStatus(cwd) {
|
|
33
|
+
try {
|
|
34
|
+
const output = execFileSync("git", ["-C", cwd, "status", "--porcelain", "--untracked-files=all"], {
|
|
35
|
+
encoding: "utf-8",
|
|
36
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
37
|
+
});
|
|
38
|
+
return { skipped: false, paths: parsePorcelain(output) };
|
|
39
|
+
} catch (err) {
|
|
40
|
+
return { skipped: true, reason: err?.message || "not a git worktree" };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function parsePorcelain(output) {
|
|
45
|
+
const paths = [];
|
|
46
|
+
for (const line of String(output || "").split(/\r?\n/)) {
|
|
47
|
+
if (!line.trim()) continue;
|
|
48
|
+
let file = line.slice(3).trim();
|
|
49
|
+
const rename = file.match(/ -> (.+)$/);
|
|
50
|
+
if (rename) file = rename[1];
|
|
51
|
+
paths.push(normalizePath(unquotePorcelainPath(file)));
|
|
52
|
+
}
|
|
53
|
+
return uniqueSorted(paths.filter(Boolean));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function matchesScope(changedPath, scope) {
|
|
57
|
+
if (hasGlob(scope)) return globToRegExp(scope).test(changedPath);
|
|
58
|
+
const dir = scope.endsWith("/") ? scope.slice(0, -1) : scope;
|
|
59
|
+
return changedPath === dir || changedPath.startsWith(`${dir}/`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function hasGlob(scope) {
|
|
63
|
+
return /[*?]/.test(scope);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function globToRegExp(glob) {
|
|
67
|
+
let out = "^";
|
|
68
|
+
for (let i = 0; i < glob.length; i++) {
|
|
69
|
+
const c = glob[i];
|
|
70
|
+
if (c === "*") {
|
|
71
|
+
if (glob[i + 1] === "*") {
|
|
72
|
+
out += ".*";
|
|
73
|
+
i++;
|
|
74
|
+
} else {
|
|
75
|
+
out += "[^/]*";
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
out += escapeRegExp(c);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
out += "$";
|
|
82
|
+
return new RegExp(out);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function normalizePath(value) {
|
|
86
|
+
return String(value || "").trim().replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+/g, "/");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function uniqueSorted(values) {
|
|
90
|
+
return [...new Set(values)].sort();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function unquotePorcelainPath(value) {
|
|
94
|
+
const trimmed = String(value || "").trim();
|
|
95
|
+
if (trimmed.length >= 2 && trimmed.startsWith('"') && trimmed.endsWith('"')) {
|
|
96
|
+
try { return JSON.parse(trimmed); } catch { return trimmed.slice(1, -1); }
|
|
97
|
+
}
|
|
98
|
+
return trimmed;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function escapeRegExp(value) {
|
|
102
|
+
return value.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
103
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* spawnPiAgent — the ONE place agent-hub code spawns a headless `pi` child and
|
|
3
|
+
* parses its JSON event stream. Used by the hub itself (specialist dispatch +
|
|
4
|
+
* research helpers, index.ts) and by the injected delegate extension
|
|
5
|
+
* (delegate.ts), so the spawn args and stream parsing never exist in two
|
|
6
|
+
* copies.
|
|
7
|
+
*
|
|
8
|
+
* The child is always `pi --mode json -p --no-extensions` with explicit `-e`
|
|
9
|
+
* extensions (damage-control first, delegate when the persona declares
|
|
10
|
+
* subagents), a model, a tool allowlist, and a session file. NOTE: pi's
|
|
11
|
+
* `--tools` allowlist applies to extension-registered tools too, so a tool a
|
|
12
|
+
* `-e` extension provides (e.g. `delegate`) must be NAMED in `tools` or the
|
|
13
|
+
* child model never sees it (validated 2026-06-11).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { spawn, type ChildProcess } from "child_process";
|
|
17
|
+
|
|
18
|
+
export interface PiUsage {
|
|
19
|
+
input?: number;
|
|
20
|
+
output?: number;
|
|
21
|
+
[k: string]: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SpawnPiAgentOptions {
|
|
25
|
+
model: string;
|
|
26
|
+
tools: string;
|
|
27
|
+
thinking: string;
|
|
28
|
+
appendSystemPrompt: string;
|
|
29
|
+
sessionFile: string;
|
|
30
|
+
/** Pass `-c` so the child resumes sessionFile instead of starting fresh. */
|
|
31
|
+
resume?: boolean;
|
|
32
|
+
prompt: string;
|
|
33
|
+
/** `-e` extension paths, in order (damage-control first). */
|
|
34
|
+
extensions?: string[];
|
|
35
|
+
/** Extra env on top of process.env (e.g. AGENT_HUB_DELEGATE_CONFIG). */
|
|
36
|
+
env?: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Spawn the child as its own process group leader (setsid). The kill
|
|
39
|
+
* cascade relies on this: delegate children spawned INSIDE the child
|
|
40
|
+
* inherit its group, so signalling the negative PID kills the whole tree.
|
|
41
|
+
*/
|
|
42
|
+
detached?: boolean;
|
|
43
|
+
cwd?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface SpawnPiAgentCallbacks {
|
|
47
|
+
/** Fires immediately after spawn so the caller can store the proc for kill. */
|
|
48
|
+
onProcess?(proc: ChildProcess): void;
|
|
49
|
+
onTextDelta?(delta: string): void;
|
|
50
|
+
onThinkingDelta?(delta: string): void;
|
|
51
|
+
onToolStart?(toolName: string, argStr: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Usage from the stream: per assistant message (`message_end`) and once at
|
|
54
|
+
* the end with the final assistant message (`agent_end`).
|
|
55
|
+
*/
|
|
56
|
+
onUsage?(usage: PiUsage, source: "message_end" | "agent_end"): void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SpawnPiAgentResult {
|
|
60
|
+
/** Concatenated assistant text deltas. */
|
|
61
|
+
output: string;
|
|
62
|
+
/** Process exit code; null when the child died from a signal (e.g. SIGTERM). */
|
|
63
|
+
exitCode: number | null;
|
|
64
|
+
stderr: string;
|
|
65
|
+
/** Set when the process could not be spawned at all (proc `error` event). */
|
|
66
|
+
spawnError?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function spawnPiAgent(
|
|
70
|
+
opts: SpawnPiAgentOptions,
|
|
71
|
+
cbs: SpawnPiAgentCallbacks = {},
|
|
72
|
+
): Promise<SpawnPiAgentResult> {
|
|
73
|
+
const args = [
|
|
74
|
+
"--mode", "json",
|
|
75
|
+
"-p",
|
|
76
|
+
"--no-extensions",
|
|
77
|
+
...(opts.extensions || []).flatMap(e => ["-e", e]),
|
|
78
|
+
"--model", opts.model,
|
|
79
|
+
"--tools", opts.tools,
|
|
80
|
+
"--thinking", opts.thinking,
|
|
81
|
+
"--append-system-prompt", opts.appendSystemPrompt,
|
|
82
|
+
"--session", opts.sessionFile,
|
|
83
|
+
];
|
|
84
|
+
if (opts.resume) args.push("-c");
|
|
85
|
+
|
|
86
|
+
const textChunks: string[] = [];
|
|
87
|
+
const stderrChunks: string[] = [];
|
|
88
|
+
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
const proc = spawn("pi", args, {
|
|
91
|
+
// pi's CLI does not accept a standalone `--` option separator, so pass
|
|
92
|
+
// the prompt through stdin. Print mode documents stdin as prompt input,
|
|
93
|
+
// and this keeps prompts that start with `-` from being parsed as flags.
|
|
94
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
95
|
+
env: { ...process.env, ...(opts.env || {}) },
|
|
96
|
+
...(opts.cwd ? { cwd: opts.cwd } : {}),
|
|
97
|
+
...(opts.detached ? { detached: true } : {}),
|
|
98
|
+
});
|
|
99
|
+
cbs.onProcess?.(proc);
|
|
100
|
+
proc.stdin?.on("error", () => {});
|
|
101
|
+
proc.stdin?.end(opts.prompt);
|
|
102
|
+
|
|
103
|
+
let buffer = "";
|
|
104
|
+
const handleEvent = (event: any) => {
|
|
105
|
+
if (event.type === "message_update") {
|
|
106
|
+
const delta = event.assistantMessageEvent;
|
|
107
|
+
if (delta?.type === "text_delta") {
|
|
108
|
+
textChunks.push(delta.delta || "");
|
|
109
|
+
cbs.onTextDelta?.(delta.delta || "");
|
|
110
|
+
} else if (delta?.type === "thinking_delta") {
|
|
111
|
+
cbs.onThinkingDelta?.(delta.delta || "");
|
|
112
|
+
}
|
|
113
|
+
} else if (event.type === "tool_execution_start") {
|
|
114
|
+
let argStr = "";
|
|
115
|
+
try { argStr = event.args != null ? JSON.stringify(event.args) : ""; } catch { argStr = ""; }
|
|
116
|
+
cbs.onToolStart?.(event.toolName || "tool", argStr);
|
|
117
|
+
} else if (event.type === "message_end") {
|
|
118
|
+
if (event.message?.usage) cbs.onUsage?.(event.message.usage, "message_end");
|
|
119
|
+
} else if (event.type === "agent_end") {
|
|
120
|
+
const msgs = event.messages || [];
|
|
121
|
+
const last = [...msgs].reverse().find((m: any) => m.role === "assistant");
|
|
122
|
+
if (last?.usage) cbs.onUsage?.(last.usage, "agent_end");
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
proc.stdout!.setEncoding("utf-8");
|
|
127
|
+
proc.stdout!.on("data", (chunk: string) => {
|
|
128
|
+
buffer += chunk;
|
|
129
|
+
const lines = buffer.split("\n");
|
|
130
|
+
buffer = lines.pop() || "";
|
|
131
|
+
for (const line of lines) {
|
|
132
|
+
if (!line.trim()) continue;
|
|
133
|
+
try { handleEvent(JSON.parse(line)); } catch {}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
proc.stderr!.setEncoding("utf-8");
|
|
138
|
+
proc.stderr!.on("data", (chunk: string) => {
|
|
139
|
+
stderrChunks.push(chunk);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
proc.on("close", (code) => {
|
|
143
|
+
if (buffer.trim()) {
|
|
144
|
+
try { handleEvent(JSON.parse(buffer)); } catch {}
|
|
145
|
+
}
|
|
146
|
+
resolve({
|
|
147
|
+
output: textChunks.join(""),
|
|
148
|
+
exitCode: code,
|
|
149
|
+
stderr: stderrChunks.join(""),
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
proc.on("error", (err) => {
|
|
154
|
+
resolve({
|
|
155
|
+
output: "",
|
|
156
|
+
exitCode: 1,
|
|
157
|
+
stderr: stderrChunks.join(""),
|
|
158
|
+
spawnError: err.message,
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Kill a spawned pi child and — when it was spawned `detached` — its whole
|
|
166
|
+
* process group, so delegate children and grandchildren die with their parent.
|
|
167
|
+
* For a non-detached child the group kill fails with ESRCH (its pgid is the
|
|
168
|
+
* hub's, not its own pid) and we fall back to a single-process SIGTERM, which
|
|
169
|
+
* matches the pre-cascade behavior.
|
|
170
|
+
*/
|
|
171
|
+
export function killPiTree(proc: ChildProcess, signal: NodeJS.Signals = "SIGTERM"): void {
|
|
172
|
+
const pid = proc.pid;
|
|
173
|
+
if (pid == null) return;
|
|
174
|
+
try {
|
|
175
|
+
process.kill(-pid, signal);
|
|
176
|
+
} catch {
|
|
177
|
+
try { proc.kill(signal); } catch {}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# ask-user-remote
|
|
2
|
+
|
|
3
|
+
Harness wrapper for `pi-ask-user` that preserves the stock `ask_user` UI and result shape while optionally racing it against the Hermes `user-remote` coms peer.
|
|
4
|
+
|
|
5
|
+
- The stock `pi-ask-user` extension is loaded through a capture proxy; its `ask_user` tool is not registered directly.
|
|
6
|
+
- If no live `user-remote` peer is present at call time, the wrapper calls stock `execute` with the original arguments and signal unchanged.
|
|
7
|
+
- If `user-remote` is present, the wrapper races local stock UI against the remote coms request using `race-core.js`; first answer wins and local-first emits one best-effort cancel.
|
|
8
|
+
- If another extension already registered `ask_user`, registration failure is caught and logged as a warning instead of crashing the session.
|
|
9
|
+
|
|
10
|
+
Tests use fakes for the stock TUI and coms peer. The abort test proves signal propagation and the stock-shaped `{cancelled:true}` result through a fake captured tool; it does not drive a live TUI overlay.
|