@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,399 @@
|
|
|
1
|
+
// scripts/coms-hermes-bridge.ts
|
|
2
|
+
//
|
|
3
|
+
// Hermes/Telegram user-remote bridge daemon. Registers a coms peer, turns
|
|
4
|
+
// prompt envelopes into `hermes send` messages, watches the private answer-file
|
|
5
|
+
// wire, and replies to the sender with the mapped answer/error envelope.
|
|
6
|
+
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import * as fs from "node:fs";
|
|
9
|
+
import * as path from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
bindEndpoint,
|
|
14
|
+
ensureComsDirs,
|
|
15
|
+
isCancelEnvelope,
|
|
16
|
+
isPromptEnvelope,
|
|
17
|
+
makeConnHandler,
|
|
18
|
+
makeEndpoint,
|
|
19
|
+
makeResponseEnvelope,
|
|
20
|
+
nowIso,
|
|
21
|
+
removeRegistryEntry,
|
|
22
|
+
resolveUniqueName,
|
|
23
|
+
sendEnvelope,
|
|
24
|
+
ulid,
|
|
25
|
+
writeAck,
|
|
26
|
+
writeNack,
|
|
27
|
+
writeRegistryAtomic,
|
|
28
|
+
type AgentCard,
|
|
29
|
+
type PromptEnvelope,
|
|
30
|
+
type RegistryEntry,
|
|
31
|
+
type SenderIdentity,
|
|
32
|
+
} from "./lib/coms-envelope.ts";
|
|
33
|
+
import {
|
|
34
|
+
formatTelegramQuestion,
|
|
35
|
+
isValidQid,
|
|
36
|
+
logPath as defaultLogPath,
|
|
37
|
+
makeLogRecord,
|
|
38
|
+
mapAnswerToAskResponse,
|
|
39
|
+
qidFromPromptEnvelope,
|
|
40
|
+
questionsDir as defaultQuestionsDir,
|
|
41
|
+
renderLogRecord,
|
|
42
|
+
timeoutMsFromEnv,
|
|
43
|
+
timeoutOutcome,
|
|
44
|
+
validateAnswerFile,
|
|
45
|
+
type BridgeEventName,
|
|
46
|
+
type QuestionOption,
|
|
47
|
+
type QuestionState,
|
|
48
|
+
} from "./lib/hermes-bridge-core.ts";
|
|
49
|
+
|
|
50
|
+
const KEEPALIVE_MS = 30_000;
|
|
51
|
+
const DEFAULT_POLL_MS = 1_000;
|
|
52
|
+
const COLOR = "#38BDF8";
|
|
53
|
+
const DEFAULT_NAME = "user-remote";
|
|
54
|
+
const DEFAULT_PURPOSE = "Remote human via Hermes/Telegram";
|
|
55
|
+
|
|
56
|
+
interface PendingQuestion {
|
|
57
|
+
env: PromptEnvelope;
|
|
58
|
+
state: QuestionState;
|
|
59
|
+
options: QuestionOption[];
|
|
60
|
+
timer: NodeJS.Timeout;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ParsedPrompt {
|
|
64
|
+
question: string;
|
|
65
|
+
context?: string;
|
|
66
|
+
options: QuestionOption[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function flagValue(argv: string[], flag: string): string | null {
|
|
70
|
+
const i = argv.indexOf(flag);
|
|
71
|
+
return i >= 0 && i + 1 < argv.length ? argv[i + 1] : null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function die(msg: string): never {
|
|
75
|
+
console.error(`coms-hermes-bridge: ${msg}`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function parsePrompt(env: PromptEnvelope): ParsedPrompt {
|
|
80
|
+
try {
|
|
81
|
+
const parsed = JSON.parse(env.prompt) as { question?: unknown; context?: unknown; options?: unknown };
|
|
82
|
+
if (parsed && typeof parsed === "object" && typeof parsed.question === "string") {
|
|
83
|
+
const rawOptions = Array.isArray(parsed.options) ? parsed.options : [];
|
|
84
|
+
const options = rawOptions
|
|
85
|
+
.map((option): QuestionOption | null => {
|
|
86
|
+
if (typeof option === "string") return { title: option };
|
|
87
|
+
if (option && typeof option === "object" && typeof (option as { title?: unknown }).title === "string") {
|
|
88
|
+
const desc = (option as { description?: unknown }).description;
|
|
89
|
+
return typeof desc === "string"
|
|
90
|
+
? { title: (option as { title: string }).title, description: desc }
|
|
91
|
+
: { title: (option as { title: string }).title };
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
})
|
|
95
|
+
.filter((option): option is QuestionOption => option !== null);
|
|
96
|
+
const context = typeof parsed.context === "string" && parsed.context.trim() ? parsed.context : undefined;
|
|
97
|
+
return { question: parsed.question, context, options };
|
|
98
|
+
}
|
|
99
|
+
} catch {
|
|
100
|
+
// Plain coms-cli prompts are expected; fall through.
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
question: env.prompt,
|
|
104
|
+
context: `From ${env.sender_name} @ ${env.sender_cwd}`,
|
|
105
|
+
options: [],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function appendLogFile(logFile: string, qid: string, event: BridgeEventName, detail?: unknown): void {
|
|
110
|
+
fs.mkdirSync(path.dirname(logFile), { recursive: true });
|
|
111
|
+
fs.appendFileSync(logFile, renderLogRecord(makeLogRecord(qid, event, detail)));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function appendAnswerRejectLog(logFile: string, qid: string, detail: unknown): void {
|
|
115
|
+
fs.mkdirSync(path.dirname(logFile), { recursive: true });
|
|
116
|
+
fs.appendFileSync(logFile, JSON.stringify({ at: nowIso(), qid, event: "answer_rejected", detail }) + "\n");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function hermesSend(to: string, text: string): Promise<void> {
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
const child = spawn("hermes", ["send", "--to", to, text], { stdio: ["ignore", "pipe", "pipe"] });
|
|
122
|
+
let stderr = "";
|
|
123
|
+
let stdout = "";
|
|
124
|
+
child.stdout?.on("data", (chunk) => { stdout += chunk.toString("utf-8"); });
|
|
125
|
+
child.stderr?.on("data", (chunk) => { stderr += chunk.toString("utf-8"); });
|
|
126
|
+
child.once("error", (err) => reject(err));
|
|
127
|
+
child.once("close", (code) => {
|
|
128
|
+
if (code === 0) {
|
|
129
|
+
resolve();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const detail = (stderr || stdout).trim();
|
|
133
|
+
reject(new Error(`hermes send failed${code === null ? "" : ` (${code})`}${detail ? `: ${detail}` : ""}`));
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function main(): Promise<void> {
|
|
139
|
+
const argv = process.argv.slice(2);
|
|
140
|
+
const requestedName = flagValue(argv, "--name") ?? DEFAULT_NAME;
|
|
141
|
+
const project = flagValue(argv, "--project") ?? "default";
|
|
142
|
+
const to = flagValue(argv, "--to") ?? "telegram";
|
|
143
|
+
const timeoutMs = Number(flagValue(argv, "--timeout") ?? timeoutMsFromEnv());
|
|
144
|
+
const pollMs = Number(flagValue(argv, "--poll-ms") ?? DEFAULT_POLL_MS);
|
|
145
|
+
const qDir = flagValue(argv, "--questions-dir") ?? defaultQuestionsDir();
|
|
146
|
+
const logFile = path.join(path.dirname(qDir), path.basename(defaultLogPath()));
|
|
147
|
+
|
|
148
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) die("--timeout must be a positive number");
|
|
149
|
+
if (!Number.isFinite(pollMs) || pollMs <= 0) die("--poll-ms must be a positive number");
|
|
150
|
+
|
|
151
|
+
ensureComsDirs(project);
|
|
152
|
+
fs.mkdirSync(qDir, { recursive: true });
|
|
153
|
+
fs.mkdirSync(path.dirname(logFile), { recursive: true });
|
|
154
|
+
|
|
155
|
+
const sessionId = ulid();
|
|
156
|
+
const uniqueName = resolveUniqueName(project, requestedName);
|
|
157
|
+
const id: SenderIdentity = {
|
|
158
|
+
session_id: sessionId,
|
|
159
|
+
name: uniqueName,
|
|
160
|
+
endpoint: makeEndpoint(sessionId),
|
|
161
|
+
cwd: process.cwd(),
|
|
162
|
+
};
|
|
163
|
+
const pending = new Map<string, PendingQuestion>();
|
|
164
|
+
const closed = new Map<string, QuestionState>();
|
|
165
|
+
// Answer files the liaison may still be mid-write: an invalid_json file is
|
|
166
|
+
// kept for a short grace window (first-seen timestamps below) instead of
|
|
167
|
+
// being eaten while the write is still in flight.
|
|
168
|
+
const invalidJsonSeen = new Map<string, number>();
|
|
169
|
+
const invalidJsonGraceMs = Math.max(2 * pollMs, 1_000);
|
|
170
|
+
const CLOSED_CAP = 1_000;
|
|
171
|
+
|
|
172
|
+
function markClosed(qid: string, state: QuestionState): void {
|
|
173
|
+
closed.set(qid, state);
|
|
174
|
+
if (closed.size > CLOSED_CAP) {
|
|
175
|
+
const oldest = closed.keys().next().value;
|
|
176
|
+
if (oldest !== undefined) closed.delete(oldest);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function queueDepth(): number {
|
|
181
|
+
return pending.size;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function registryEntry(): RegistryEntry {
|
|
185
|
+
return {
|
|
186
|
+
session_id: sessionId,
|
|
187
|
+
name: uniqueName,
|
|
188
|
+
purpose: DEFAULT_PURPOSE,
|
|
189
|
+
model: "hermes-bridge",
|
|
190
|
+
color: COLOR,
|
|
191
|
+
pid: process.pid,
|
|
192
|
+
endpoint: id.endpoint,
|
|
193
|
+
cwd: id.cwd,
|
|
194
|
+
started_at: nowIso(),
|
|
195
|
+
explicit: false,
|
|
196
|
+
version: 1,
|
|
197
|
+
context_used_pct: 0,
|
|
198
|
+
queue_depth: queueDepth(),
|
|
199
|
+
heartbeat_at: nowIso(),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function sendResponse(env: PromptEnvelope, response: unknown, error: string | null = null): Promise<void> {
|
|
204
|
+
await sendEnvelope(env.sender_endpoint, makeResponseEnvelope(id, env.msg_id, response, error));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async function handleTimeout(qid: string): Promise<void> {
|
|
208
|
+
const item = pending.get(qid);
|
|
209
|
+
if (!item) return;
|
|
210
|
+
pending.delete(qid);
|
|
211
|
+
markClosed(qid, "timeout");
|
|
212
|
+
appendLogFile(logFile, qid, "timeout", { timeout_ms: timeoutMs });
|
|
213
|
+
const outcome = timeoutOutcome(qid, timeoutMs);
|
|
214
|
+
await hermesSend(to, outcome.telegramNote).catch((err) => {
|
|
215
|
+
appendLogFile(logFile, qid, "delivery_error", { phase: "timeout_note", error: err instanceof Error ? err.message : String(err) });
|
|
216
|
+
});
|
|
217
|
+
await sendResponse(item.env, outcome.response, outcome.error).catch((err) => {
|
|
218
|
+
console.error(`coms-hermes-bridge: could not deliver timeout for ${qid}: ${err instanceof Error ? err.message : String(err)}`);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function handlePrompt(env: PromptEnvelope): Promise<void> {
|
|
223
|
+
let qid: string;
|
|
224
|
+
try {
|
|
225
|
+
qid = qidFromPromptEnvelope(env);
|
|
226
|
+
} catch (err) {
|
|
227
|
+
await sendResponse(env, null, err instanceof Error ? err.message : String(err)).catch(() => {});
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const parsed = parsePrompt(env);
|
|
232
|
+
const duplicate = pending.get(qid);
|
|
233
|
+
if (duplicate) clearTimeout(duplicate.timer);
|
|
234
|
+
appendLogFile(logFile, qid, "question_received", { from: env.sender_name });
|
|
235
|
+
const timer = setTimeout(() => { void handleTimeout(qid); }, timeoutMs);
|
|
236
|
+
timer.unref?.();
|
|
237
|
+
pending.set(qid, { env, state: "pending", options: parsed.options, timer });
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
await hermesSend(to, formatTelegramQuestion({
|
|
241
|
+
qid,
|
|
242
|
+
question: parsed.question,
|
|
243
|
+
context: parsed.context,
|
|
244
|
+
options: parsed.options,
|
|
245
|
+
}));
|
|
246
|
+
const item = pending.get(qid);
|
|
247
|
+
if (!item) return;
|
|
248
|
+
item.state = "delivered";
|
|
249
|
+
appendLogFile(logFile, qid, "delivered", { to });
|
|
250
|
+
} catch (err) {
|
|
251
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
252
|
+
const item = pending.get(qid);
|
|
253
|
+
if (item) {
|
|
254
|
+
clearTimeout(item.timer);
|
|
255
|
+
pending.delete(qid);
|
|
256
|
+
}
|
|
257
|
+
appendLogFile(logFile, qid, "delivery_error", { error: message });
|
|
258
|
+
await sendResponse(env, null, message).catch((sendErr) => {
|
|
259
|
+
console.error(`coms-hermes-bridge: could not deliver error for ${qid}: ${sendErr instanceof Error ? sendErr.message : String(sendErr)}`);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async function handleCancel(refMsgId: string): Promise<void> {
|
|
265
|
+
if (!isValidQid(refMsgId)) return;
|
|
266
|
+
const item = pending.get(refMsgId);
|
|
267
|
+
if (!item) return;
|
|
268
|
+
clearTimeout(item.timer);
|
|
269
|
+
pending.delete(refMsgId);
|
|
270
|
+
markClosed(refMsgId, "cancelled");
|
|
271
|
+
appendLogFile(logFile, refMsgId, "cancelled", { reason: "cancel envelope" });
|
|
272
|
+
await hermesSend(to, `✖ [HUB-Q:${refMsgId}] Въпросът е отменен — отговорено е от конзолата.`).catch((err) => {
|
|
273
|
+
appendLogFile(logFile, refMsgId, "delivery_error", { phase: "cancel_note", error: err instanceof Error ? err.message : String(err) });
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function handleLateAnswer(qid: string): Promise<void> {
|
|
278
|
+
appendLogFile(logFile, qid, "late_answer", { state: closed.get(qid) ?? "unknown" });
|
|
279
|
+
await hermesSend(to, `ℹ [HUB-Q:${qid}] Този въпрос вече е затворен; късният отговор е игнориран.`).catch((err) => {
|
|
280
|
+
appendLogFile(logFile, qid, "delivery_error", { phase: "late_note", error: err instanceof Error ? err.message : String(err) });
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async function consumeAnswerFile(file: string): Promise<void> {
|
|
285
|
+
const full = path.join(qDir, file);
|
|
286
|
+
let raw: string;
|
|
287
|
+
try {
|
|
288
|
+
raw = fs.readFileSync(full, "utf-8");
|
|
289
|
+
} catch {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const qidFromName = file.endsWith(".answer.json") ? file.slice(0, -".answer.json".length) : file;
|
|
294
|
+
if (isValidQid(qidFromName) && closed.has(qidFromName)) {
|
|
295
|
+
invalidJsonSeen.delete(file);
|
|
296
|
+
try { fs.unlinkSync(full); } catch { /* ignore */ }
|
|
297
|
+
await handleLateAnswer(qidFromName);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const validation = validateAnswerFile(raw, full, pending.keys());
|
|
302
|
+
if (!validation.ok) {
|
|
303
|
+
if (validation.reason === "invalid_json") {
|
|
304
|
+
// Possibly a partial write from the liaison; retry until the grace expires.
|
|
305
|
+
const firstSeen = invalidJsonSeen.get(file);
|
|
306
|
+
if (firstSeen === undefined) {
|
|
307
|
+
invalidJsonSeen.set(file, Date.now());
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (Date.now() - firstSeen < invalidJsonGraceMs) return;
|
|
311
|
+
}
|
|
312
|
+
invalidJsonSeen.delete(file);
|
|
313
|
+
const logQid = validation.qid && isValidQid(validation.qid) ? validation.qid : (isValidQid(qidFromName) ? qidFromName : "00000000000000000000000000");
|
|
314
|
+
appendAnswerRejectLog(logFile, logQid, { reason: validation.reason, file });
|
|
315
|
+
try { fs.unlinkSync(full); } catch { /* ignore */ }
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
invalidJsonSeen.delete(file);
|
|
320
|
+
const item = pending.get(validation.qid);
|
|
321
|
+
if (!item) return;
|
|
322
|
+
clearTimeout(item.timer);
|
|
323
|
+
pending.delete(validation.qid);
|
|
324
|
+
markClosed(validation.qid, "answered");
|
|
325
|
+
try { fs.unlinkSync(full); } catch { /* ignore */ }
|
|
326
|
+
appendLogFile(logFile, validation.qid, "answered", { answered_by: validation.answer.answered_by });
|
|
327
|
+
const response = mapAnswerToAskResponse(validation.answer.answer, item.options);
|
|
328
|
+
await sendResponse(item.env, response).catch((err) => {
|
|
329
|
+
console.error(`coms-hermes-bridge: could not deliver answer for ${validation.qid}: ${err instanceof Error ? err.message : String(err)}`);
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
async function scanAnswers(): Promise<void> {
|
|
334
|
+
let files: string[];
|
|
335
|
+
try {
|
|
336
|
+
files = fs.readdirSync(qDir);
|
|
337
|
+
} catch {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
for (const file of files) {
|
|
341
|
+
await consumeAnswerFile(file);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const server = await bindEndpoint(
|
|
346
|
+
id.endpoint,
|
|
347
|
+
makeConnHandler((env, socket) => {
|
|
348
|
+
if (isPromptEnvelope(env)) {
|
|
349
|
+
writeAck(socket, env.msg_id);
|
|
350
|
+
void handlePrompt(env);
|
|
351
|
+
} else if (isCancelEnvelope(env)) {
|
|
352
|
+
writeAck(socket, env.msg_id);
|
|
353
|
+
void handleCancel(env.ref_msg_id);
|
|
354
|
+
} else if ((env as { type?: string }).type === "ping") {
|
|
355
|
+
const card: AgentCard = {
|
|
356
|
+
name: uniqueName,
|
|
357
|
+
purpose: DEFAULT_PURPOSE,
|
|
358
|
+
model: "hermes-bridge",
|
|
359
|
+
color: COLOR,
|
|
360
|
+
context_used_pct: 0,
|
|
361
|
+
queue_depth: queueDepth(),
|
|
362
|
+
};
|
|
363
|
+
try {
|
|
364
|
+
socket.write(JSON.stringify({ type: "pong", msg_id: (env as { msg_id?: string }).msg_id ?? "", agent_card: card }) + "\n");
|
|
365
|
+
} catch { /* ignore */ }
|
|
366
|
+
try { socket.end(); } catch { /* ignore */ }
|
|
367
|
+
} else {
|
|
368
|
+
writeNack(socket, (env as { msg_id?: string }).msg_id ?? "", "bridge accepts prompts, cancels, and pings");
|
|
369
|
+
}
|
|
370
|
+
}),
|
|
371
|
+
);
|
|
372
|
+
writeRegistryAtomic(registryEntry(), project);
|
|
373
|
+
console.error(`coms-hermes-bridge: ${uniqueName}@${project} listening (${to})`);
|
|
374
|
+
|
|
375
|
+
const keepalive = setInterval(() => {
|
|
376
|
+
try { writeRegistryAtomic(registryEntry(), project); } catch { /* best-effort */ }
|
|
377
|
+
}, KEEPALIVE_MS);
|
|
378
|
+
keepalive.unref?.();
|
|
379
|
+
const watcher = setInterval(() => { void scanAnswers(); }, pollMs);
|
|
380
|
+
watcher.unref?.();
|
|
381
|
+
|
|
382
|
+
let shuttingDown = false;
|
|
383
|
+
function shutdown(): void {
|
|
384
|
+
if (shuttingDown) return;
|
|
385
|
+
shuttingDown = true;
|
|
386
|
+
clearInterval(keepalive);
|
|
387
|
+
clearInterval(watcher);
|
|
388
|
+
for (const item of pending.values()) clearTimeout(item.timer);
|
|
389
|
+
try { server.close(); } catch { /* ignore */ }
|
|
390
|
+
try { fs.unlinkSync(id.endpoint); } catch { /* ignore */ }
|
|
391
|
+
removeRegistryEntry(project, uniqueName);
|
|
392
|
+
process.exit(0);
|
|
393
|
+
}
|
|
394
|
+
process.on("SIGTERM", shutdown);
|
|
395
|
+
process.on("SIGINT", shutdown);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const isEntry = process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
399
|
+
if (isEntry) void main();
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// scripts/lib/claude-bridge-core.ts
|
|
2
|
+
//
|
|
3
|
+
// Pure logic for the Claude Code coms bridge (scripts/coms-claude-bridge.ts):
|
|
4
|
+
// prompt formatting, completion sentinels, hook-record parsing, reply
|
|
5
|
+
// extraction from pane text, and the serial prompt queue. No sockets, no fs,
|
|
6
|
+
// no herdr — everything here runs under node --test.
|
|
7
|
+
|
|
8
|
+
export const SENTINEL_PREFIX = "<<COMS_DONE:";
|
|
9
|
+
|
|
10
|
+
export function completionSentinel(msgId: string): string {
|
|
11
|
+
return `${SENTINEL_PREFIX}${msgId}>>`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// The prompt as typed into the Claude Code pane. Mirrors the pi side's
|
|
15
|
+
// "[from name @ cwd]" framing so Claude knows who is asking; in sentinel mode
|
|
16
|
+
// (no Stop hook seen yet) it also asks for the completion marker.
|
|
17
|
+
export function formatPanePrompt(
|
|
18
|
+
env: { prompt: string; sender_name: string; sender_cwd: string; msg_id: string },
|
|
19
|
+
sentinelMode: boolean,
|
|
20
|
+
): string {
|
|
21
|
+
const header = `[coms message from ${env.sender_name} @ ${env.sender_cwd}] `;
|
|
22
|
+
const sentinelNote = sentinelMode
|
|
23
|
+
? `\n\nEnd your reply with this exact line so the bridge can capture it: ${completionSentinel(env.msg_id)}`
|
|
24
|
+
: "";
|
|
25
|
+
return `${header}${env.prompt}${sentinelNote}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Stop-hook record: the hook writes {text, session_id?, written_at} as JSON.
|
|
29
|
+
export interface HookRecord {
|
|
30
|
+
text: string;
|
|
31
|
+
written_at?: string;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function parseHookRecord(raw: string): HookRecord | null {
|
|
36
|
+
try {
|
|
37
|
+
const rec = JSON.parse(raw);
|
|
38
|
+
if (rec && typeof rec.text === "string") return rec as HookRecord;
|
|
39
|
+
return null;
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Sentinel-mode fallback: pull the reply out of raw pane text. Takes
|
|
46
|
+
// everything between the last prompt echo (identified by the msg_id-bearing
|
|
47
|
+
// sentinel instruction OR the header line) and the sentinel line, stripped of
|
|
48
|
+
// obvious TUI furniture. Returns null when the sentinel has not appeared.
|
|
49
|
+
export function extractSentinelReply(paneText: string, msgId: string): string | null {
|
|
50
|
+
const sentinel = completionSentinel(msgId);
|
|
51
|
+
const at = paneText.lastIndexOf(sentinel);
|
|
52
|
+
if (at === -1) return null;
|
|
53
|
+
const before = paneText.slice(0, at);
|
|
54
|
+
// Cut at the end of the prompt echo: the sentinel instruction line
|
|
55
|
+
// contains the sentinel too, so use the LAST occurrence before the final
|
|
56
|
+
// one — that's the echo; the reply follows it.
|
|
57
|
+
const echoAt = before.lastIndexOf(sentinel);
|
|
58
|
+
const replyRegion = echoAt !== -1 ? before.slice(echoAt + sentinel.length) : before;
|
|
59
|
+
const lines = replyRegion
|
|
60
|
+
.split("\n")
|
|
61
|
+
.map((l) => l.replace(/^[●❯>\s]+/, "").trimEnd())
|
|
62
|
+
.filter((l) => l.trim() !== "" && !/^[─━┏┗┃│]+/.test(l));
|
|
63
|
+
return lines.join("\n").trim() || null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ━━ Serial prompt queue ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
67
|
+
//
|
|
68
|
+
// One prompt at a time per pane; queue depth is reported in the agent card.
|
|
69
|
+
|
|
70
|
+
export interface QueuedPrompt<T> {
|
|
71
|
+
envelope: T;
|
|
72
|
+
enqueued_at: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class PromptQueue<T> {
|
|
76
|
+
private items: Array<QueuedPrompt<T>> = [];
|
|
77
|
+
private active = false;
|
|
78
|
+
|
|
79
|
+
get depth(): number {
|
|
80
|
+
return this.items.length + (this.active ? 1 : 0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
push(envelope: T, now: () => string = () => new Date().toISOString()): void {
|
|
84
|
+
this.items.push({ envelope, enqueued_at: now() });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Take the next prompt if none is being processed. Callers MUST call
|
|
88
|
+
// done() when processing finishes (success or failure).
|
|
89
|
+
take(): QueuedPrompt<T> | null {
|
|
90
|
+
if (this.active) return null;
|
|
91
|
+
const next = this.items.shift();
|
|
92
|
+
if (!next) return null;
|
|
93
|
+
this.active = true;
|
|
94
|
+
return next;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
done(): void {
|
|
98
|
+
this.active = false;
|
|
99
|
+
}
|
|
100
|
+
}
|