hivemind-pipeline 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +63 -0
- package/README.md +352 -0
- package/dist/bin/swarm.d.ts +3 -0
- package/dist/bin/swarm.d.ts.map +1 -0
- package/dist/bin/swarm.js +293 -0
- package/dist/bin/swarm.js.map +1 -0
- package/dist/dashboard/assets/index-Cf_KwDES.js +359 -0
- package/dist/dashboard/assets/index-SatEQz0u.css +1 -0
- package/dist/dashboard/index.html +16 -0
- package/dist/prompts/Architect-Go.md +455 -0
- package/dist/prompts/Architect-Node.md +379 -0
- package/dist/prompts/Architect-Python.md +63 -0
- package/dist/prompts/Architect-React.md +352 -0
- package/dist/prompts/Architect-Rust.md +63 -0
- package/dist/prompts/Architect-Swift.md +61 -0
- package/dist/prompts/Software-engineer-go.md +254 -0
- package/dist/prompts/Software-engineer-node.md +241 -0
- package/dist/prompts/Software-engineer-python.md +70 -0
- package/dist/prompts/Software-engineer-react.md +167 -0
- package/dist/prompts/Software-engineer-rust.md +69 -0
- package/dist/prompts/Software-engineer-swift.md +69 -0
- package/dist/prompts/Software-lead-go.md +247 -0
- package/dist/prompts/Software-lead-node.md +238 -0
- package/dist/prompts/Software-lead-python.md +53 -0
- package/dist/prompts/Software-lead-react.md +229 -0
- package/dist/prompts/Software-lead-rust.md +53 -0
- package/dist/prompts/Software-lead-swift.md +53 -0
- package/dist/prompts/analyst-go.md +351 -0
- package/dist/prompts/analyst-node.md +317 -0
- package/dist/prompts/analyst-python.md +139 -0
- package/dist/prompts/analyst-react.md +428 -0
- package/dist/prompts/analyst-rust.md +125 -0
- package/dist/prompts/analyst-swift.md +125 -0
- package/dist/prompts/test-engineer-go.md +99 -0
- package/dist/prompts/test-engineer-node.md +97 -0
- package/dist/prompts/test-engineer-python.md +61 -0
- package/dist/prompts/test-engineer-react.md +104 -0
- package/dist/prompts/test-engineer-rust.md +62 -0
- package/dist/prompts/test-engineer-swift.md +66 -0
- package/dist/src/__tests__/commands/analyze.test.d.ts +2 -0
- package/dist/src/__tests__/commands/analyze.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/analyze.test.js +61 -0
- package/dist/src/__tests__/commands/analyze.test.js.map +1 -0
- package/dist/src/__tests__/commands/architect.test.d.ts +2 -0
- package/dist/src/__tests__/commands/architect.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/architect.test.js +46 -0
- package/dist/src/__tests__/commands/architect.test.js.map +1 -0
- package/dist/src/__tests__/commands/build.test.d.ts +2 -0
- package/dist/src/__tests__/commands/build.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/build.test.js +69 -0
- package/dist/src/__tests__/commands/build.test.js.map +1 -0
- package/dist/src/__tests__/commands/dashboard.test.d.ts +2 -0
- package/dist/src/__tests__/commands/dashboard.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/dashboard.test.js +95 -0
- package/dist/src/__tests__/commands/dashboard.test.js.map +1 -0
- package/dist/src/__tests__/commands/doctor.test.d.ts +2 -0
- package/dist/src/__tests__/commands/doctor.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/doctor.test.js +69 -0
- package/dist/src/__tests__/commands/doctor.test.js.map +1 -0
- package/dist/src/__tests__/commands/fix.test.d.ts +2 -0
- package/dist/src/__tests__/commands/fix.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/fix.test.js +147 -0
- package/dist/src/__tests__/commands/fix.test.js.map +1 -0
- package/dist/src/__tests__/commands/init.test.d.ts +2 -0
- package/dist/src/__tests__/commands/init.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/init.test.js +79 -0
- package/dist/src/__tests__/commands/init.test.js.map +1 -0
- package/dist/src/__tests__/commands/learn.test.d.ts +2 -0
- package/dist/src/__tests__/commands/learn.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/learn.test.js +64 -0
- package/dist/src/__tests__/commands/learn.test.js.map +1 -0
- package/dist/src/__tests__/commands/mayday.test.d.ts +2 -0
- package/dist/src/__tests__/commands/mayday.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/mayday.test.js +115 -0
- package/dist/src/__tests__/commands/mayday.test.js.map +1 -0
- package/dist/src/__tests__/commands/memory.test.d.ts +2 -0
- package/dist/src/__tests__/commands/memory.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/memory.test.js +80 -0
- package/dist/src/__tests__/commands/memory.test.js.map +1 -0
- package/dist/src/__tests__/commands/plan.test.d.ts +2 -0
- package/dist/src/__tests__/commands/plan.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/plan.test.js +46 -0
- package/dist/src/__tests__/commands/plan.test.js.map +1 -0
- package/dist/src/__tests__/commands/pr.test.d.ts +2 -0
- package/dist/src/__tests__/commands/pr.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/pr.test.js +170 -0
- package/dist/src/__tests__/commands/pr.test.js.map +1 -0
- package/dist/src/__tests__/commands/refactor.test.d.ts +2 -0
- package/dist/src/__tests__/commands/refactor.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/refactor.test.js +107 -0
- package/dist/src/__tests__/commands/refactor.test.js.map +1 -0
- package/dist/src/__tests__/commands/review.test.d.ts +2 -0
- package/dist/src/__tests__/commands/review.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/review.test.js +125 -0
- package/dist/src/__tests__/commands/review.test.js.map +1 -0
- package/dist/src/__tests__/commands/shared.test.d.ts +2 -0
- package/dist/src/__tests__/commands/shared.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/shared.test.js +112 -0
- package/dist/src/__tests__/commands/shared.test.js.map +1 -0
- package/dist/src/__tests__/commands/spike.test.d.ts +2 -0
- package/dist/src/__tests__/commands/spike.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/spike.test.js +75 -0
- package/dist/src/__tests__/commands/spike.test.js.map +1 -0
- package/dist/src/__tests__/commands/stats.test.d.ts +2 -0
- package/dist/src/__tests__/commands/stats.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/stats.test.js +82 -0
- package/dist/src/__tests__/commands/stats.test.js.map +1 -0
- package/dist/src/__tests__/commands/status.test.d.ts +2 -0
- package/dist/src/__tests__/commands/status.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/status.test.js +60 -0
- package/dist/src/__tests__/commands/status.test.js.map +1 -0
- package/dist/src/__tests__/commands/test-cmd.test.d.ts +2 -0
- package/dist/src/__tests__/commands/test-cmd.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/test-cmd.test.js +76 -0
- package/dist/src/__tests__/commands/test-cmd.test.js.map +1 -0
- package/dist/src/__tests__/commands/test-gen.test.d.ts +2 -0
- package/dist/src/__tests__/commands/test-gen.test.d.ts.map +1 -0
- package/dist/src/__tests__/commands/test-gen.test.js +151 -0
- package/dist/src/__tests__/commands/test-gen.test.js.map +1 -0
- package/dist/src/__tests__/core/agent-manager.test.d.ts +2 -0
- package/dist/src/__tests__/core/agent-manager.test.d.ts.map +1 -0
- package/dist/src/__tests__/core/agent-manager.test.js +167 -0
- package/dist/src/__tests__/core/agent-manager.test.js.map +1 -0
- package/dist/src/__tests__/core/agent-process.test.d.ts +2 -0
- package/dist/src/__tests__/core/agent-process.test.d.ts.map +1 -0
- package/dist/src/__tests__/core/agent-process.test.js +178 -0
- package/dist/src/__tests__/core/agent-process.test.js.map +1 -0
- package/dist/src/__tests__/core/guardrails.test.d.ts +2 -0
- package/dist/src/__tests__/core/guardrails.test.d.ts.map +1 -0
- package/dist/src/__tests__/core/guardrails.test.js +249 -0
- package/dist/src/__tests__/core/guardrails.test.js.map +1 -0
- package/dist/src/__tests__/core/pipeline.test.d.ts +2 -0
- package/dist/src/__tests__/core/pipeline.test.d.ts.map +1 -0
- package/dist/src/__tests__/core/pipeline.test.js +331 -0
- package/dist/src/__tests__/core/pipeline.test.js.map +1 -0
- package/dist/src/__tests__/core/state.test.d.ts +2 -0
- package/dist/src/__tests__/core/state.test.d.ts.map +1 -0
- package/dist/src/__tests__/core/state.test.js +132 -0
- package/dist/src/__tests__/core/state.test.js.map +1 -0
- package/dist/src/__tests__/core/ws-server.test.d.ts +2 -0
- package/dist/src/__tests__/core/ws-server.test.d.ts.map +1 -0
- package/dist/src/__tests__/core/ws-server.test.js +177 -0
- package/dist/src/__tests__/core/ws-server.test.js.map +1 -0
- package/dist/src/__tests__/helpers/temp-dir.d.ts +8 -0
- package/dist/src/__tests__/helpers/temp-dir.d.ts.map +1 -0
- package/dist/src/__tests__/helpers/temp-dir.js +25 -0
- package/dist/src/__tests__/helpers/temp-dir.js.map +1 -0
- package/dist/src/commands/agent.d.ts +3 -0
- package/dist/src/commands/agent.d.ts.map +1 -0
- package/dist/src/commands/agent.js +103 -0
- package/dist/src/commands/agent.js.map +1 -0
- package/dist/src/commands/allocate.d.ts +3 -0
- package/dist/src/commands/allocate.d.ts.map +1 -0
- package/dist/src/commands/allocate.js +229 -0
- package/dist/src/commands/allocate.js.map +1 -0
- package/dist/src/commands/analyze.d.ts +3 -0
- package/dist/src/commands/analyze.d.ts.map +1 -0
- package/dist/src/commands/analyze.js +63 -0
- package/dist/src/commands/analyze.js.map +1 -0
- package/dist/src/commands/architect-review.d.ts +3 -0
- package/dist/src/commands/architect-review.d.ts.map +1 -0
- package/dist/src/commands/architect-review.js +695 -0
- package/dist/src/commands/architect-review.js.map +1 -0
- package/dist/src/commands/architect.d.ts +3 -0
- package/dist/src/commands/architect.d.ts.map +1 -0
- package/dist/src/commands/architect.js +49 -0
- package/dist/src/commands/architect.js.map +1 -0
- package/dist/src/commands/audit.d.ts +3 -0
- package/dist/src/commands/audit.d.ts.map +1 -0
- package/dist/src/commands/audit.js +55 -0
- package/dist/src/commands/audit.js.map +1 -0
- package/dist/src/commands/autopilot.d.ts +7 -0
- package/dist/src/commands/autopilot.d.ts.map +1 -0
- package/dist/src/commands/autopilot.js +377 -0
- package/dist/src/commands/autopilot.js.map +1 -0
- package/dist/src/commands/babysit-prs.d.ts +13 -0
- package/dist/src/commands/babysit-prs.d.ts.map +1 -0
- package/dist/src/commands/babysit-prs.js +283 -0
- package/dist/src/commands/babysit-prs.js.map +1 -0
- package/dist/src/commands/benchmark.d.ts +34 -0
- package/dist/src/commands/benchmark.d.ts.map +1 -0
- package/dist/src/commands/benchmark.js +534 -0
- package/dist/src/commands/benchmark.js.map +1 -0
- package/dist/src/commands/build.d.ts +3 -0
- package/dist/src/commands/build.d.ts.map +1 -0
- package/dist/src/commands/build.js +63 -0
- package/dist/src/commands/build.js.map +1 -0
- package/dist/src/commands/check.d.ts +3 -0
- package/dist/src/commands/check.d.ts.map +1 -0
- package/dist/src/commands/check.js +102 -0
- package/dist/src/commands/check.js.map +1 -0
- package/dist/src/commands/ci.d.ts +3 -0
- package/dist/src/commands/ci.d.ts.map +1 -0
- package/dist/src/commands/ci.js +124 -0
- package/dist/src/commands/ci.js.map +1 -0
- package/dist/src/commands/compete.d.ts +3 -0
- package/dist/src/commands/compete.d.ts.map +1 -0
- package/dist/src/commands/compete.js +164 -0
- package/dist/src/commands/compete.js.map +1 -0
- package/dist/src/commands/compliance.d.ts +3 -0
- package/dist/src/commands/compliance.d.ts.map +1 -0
- package/dist/src/commands/compliance.js +722 -0
- package/dist/src/commands/compliance.js.map +1 -0
- package/dist/src/commands/context.d.ts +3 -0
- package/dist/src/commands/context.d.ts.map +1 -0
- package/dist/src/commands/context.js +171 -0
- package/dist/src/commands/context.js.map +1 -0
- package/dist/src/commands/contract.d.ts +3 -0
- package/dist/src/commands/contract.d.ts.map +1 -0
- package/dist/src/commands/contract.js +384 -0
- package/dist/src/commands/contract.js.map +1 -0
- package/dist/src/commands/dashboard.d.ts +3 -0
- package/dist/src/commands/dashboard.d.ts.map +1 -0
- package/dist/src/commands/dashboard.js +114 -0
- package/dist/src/commands/dashboard.js.map +1 -0
- package/dist/src/commands/delegate.d.ts +3 -0
- package/dist/src/commands/delegate.d.ts.map +1 -0
- package/dist/src/commands/delegate.js +474 -0
- package/dist/src/commands/delegate.js.map +1 -0
- package/dist/src/commands/deploy.d.ts +17 -0
- package/dist/src/commands/deploy.d.ts.map +1 -0
- package/dist/src/commands/deploy.js +163 -0
- package/dist/src/commands/deploy.js.map +1 -0
- package/dist/src/commands/deps.d.ts +3 -0
- package/dist/src/commands/deps.d.ts.map +1 -0
- package/dist/src/commands/deps.js +548 -0
- package/dist/src/commands/deps.js.map +1 -0
- package/dist/src/commands/doctor.d.ts +3 -0
- package/dist/src/commands/doctor.d.ts.map +1 -0
- package/dist/src/commands/doctor.js +120 -0
- package/dist/src/commands/doctor.js.map +1 -0
- package/dist/src/commands/empathize.d.ts +3 -0
- package/dist/src/commands/empathize.d.ts.map +1 -0
- package/dist/src/commands/empathize.js +253 -0
- package/dist/src/commands/empathize.js.map +1 -0
- package/dist/src/commands/evaluate.d.ts +3 -0
- package/dist/src/commands/evaluate.d.ts.map +1 -0
- package/dist/src/commands/evaluate.js +49 -0
- package/dist/src/commands/evaluate.js.map +1 -0
- package/dist/src/commands/evolve.d.ts +3 -0
- package/dist/src/commands/evolve.d.ts.map +1 -0
- package/dist/src/commands/evolve.js +841 -0
- package/dist/src/commands/evolve.js.map +1 -0
- package/dist/src/commands/experiment.d.ts +3 -0
- package/dist/src/commands/experiment.d.ts.map +1 -0
- package/dist/src/commands/experiment.js +286 -0
- package/dist/src/commands/experiment.js.map +1 -0
- package/dist/src/commands/explain.d.ts +3 -0
- package/dist/src/commands/explain.d.ts.map +1 -0
- package/dist/src/commands/explain.js +159 -0
- package/dist/src/commands/explain.js.map +1 -0
- package/dist/src/commands/federate.d.ts +3 -0
- package/dist/src/commands/federate.d.ts.map +1 -0
- package/dist/src/commands/federate.js +148 -0
- package/dist/src/commands/federate.js.map +1 -0
- package/dist/src/commands/fingerprint.d.ts +3 -0
- package/dist/src/commands/fingerprint.d.ts.map +1 -0
- package/dist/src/commands/fingerprint.js +65 -0
- package/dist/src/commands/fingerprint.js.map +1 -0
- package/dist/src/commands/fix.d.ts +3 -0
- package/dist/src/commands/fix.d.ts.map +1 -0
- package/dist/src/commands/fix.js +160 -0
- package/dist/src/commands/fix.js.map +1 -0
- package/dist/src/commands/fleet.d.ts +3 -0
- package/dist/src/commands/fleet.d.ts.map +1 -0
- package/dist/src/commands/fleet.js +311 -0
- package/dist/src/commands/fleet.js.map +1 -0
- package/dist/src/commands/forecast.d.ts +3 -0
- package/dist/src/commands/forecast.d.ts.map +1 -0
- package/dist/src/commands/forecast.js +522 -0
- package/dist/src/commands/forecast.js.map +1 -0
- package/dist/src/commands/govern.d.ts +3 -0
- package/dist/src/commands/govern.d.ts.map +1 -0
- package/dist/src/commands/govern.js +280 -0
- package/dist/src/commands/govern.js.map +1 -0
- package/dist/src/commands/health.d.ts +17 -0
- package/dist/src/commands/health.d.ts.map +1 -0
- package/dist/src/commands/health.js +491 -0
- package/dist/src/commands/health.js.map +1 -0
- package/dist/src/commands/impact.d.ts +3 -0
- package/dist/src/commands/impact.d.ts.map +1 -0
- package/dist/src/commands/impact.js +186 -0
- package/dist/src/commands/impact.js.map +1 -0
- package/dist/src/commands/improve.d.ts +3 -0
- package/dist/src/commands/improve.d.ts.map +1 -0
- package/dist/src/commands/improve.js +240 -0
- package/dist/src/commands/improve.js.map +1 -0
- package/dist/src/commands/inbox.d.ts +29 -0
- package/dist/src/commands/inbox.d.ts.map +1 -0
- package/dist/src/commands/inbox.js +538 -0
- package/dist/src/commands/inbox.js.map +1 -0
- package/dist/src/commands/incident.d.ts +15 -0
- package/dist/src/commands/incident.d.ts.map +1 -0
- package/dist/src/commands/incident.js +318 -0
- package/dist/src/commands/incident.js.map +1 -0
- package/dist/src/commands/init.d.ts +3 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +97 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/journal.d.ts +3 -0
- package/dist/src/commands/journal.d.ts.map +1 -0
- package/dist/src/commands/journal.js +146 -0
- package/dist/src/commands/journal.js.map +1 -0
- package/dist/src/commands/learn.d.ts +9 -0
- package/dist/src/commands/learn.d.ts.map +1 -0
- package/dist/src/commands/learn.js +107 -0
- package/dist/src/commands/learn.js.map +1 -0
- package/dist/src/commands/mayday.d.ts +3 -0
- package/dist/src/commands/mayday.d.ts.map +1 -0
- package/dist/src/commands/mayday.js +145 -0
- package/dist/src/commands/mayday.js.map +1 -0
- package/dist/src/commands/memory.d.ts +3 -0
- package/dist/src/commands/memory.d.ts.map +1 -0
- package/dist/src/commands/memory.js +113 -0
- package/dist/src/commands/memory.js.map +1 -0
- package/dist/src/commands/mentor.d.ts +3 -0
- package/dist/src/commands/mentor.d.ts.map +1 -0
- package/dist/src/commands/mentor.js +225 -0
- package/dist/src/commands/mentor.js.map +1 -0
- package/dist/src/commands/migrate.d.ts +3 -0
- package/dist/src/commands/migrate.d.ts.map +1 -0
- package/dist/src/commands/migrate.js +169 -0
- package/dist/src/commands/migrate.js.map +1 -0
- package/dist/src/commands/models.d.ts +3 -0
- package/dist/src/commands/models.d.ts.map +1 -0
- package/dist/src/commands/models.js +396 -0
- package/dist/src/commands/models.js.map +1 -0
- package/dist/src/commands/multi-repo.d.ts +18 -0
- package/dist/src/commands/multi-repo.d.ts.map +1 -0
- package/dist/src/commands/multi-repo.js +423 -0
- package/dist/src/commands/multi-repo.js.map +1 -0
- package/dist/src/commands/negotiate.d.ts +3 -0
- package/dist/src/commands/negotiate.d.ts.map +1 -0
- package/dist/src/commands/negotiate.js +239 -0
- package/dist/src/commands/negotiate.js.map +1 -0
- package/dist/src/commands/observe.d.ts +3 -0
- package/dist/src/commands/observe.d.ts.map +1 -0
- package/dist/src/commands/observe.js +445 -0
- package/dist/src/commands/observe.js.map +1 -0
- package/dist/src/commands/onboard.d.ts +3 -0
- package/dist/src/commands/onboard.d.ts.map +1 -0
- package/dist/src/commands/onboard.js +263 -0
- package/dist/src/commands/onboard.js.map +1 -0
- package/dist/src/commands/optimize.d.ts +3 -0
- package/dist/src/commands/optimize.d.ts.map +1 -0
- package/dist/src/commands/optimize.js +340 -0
- package/dist/src/commands/optimize.js.map +1 -0
- package/dist/src/commands/own.d.ts +3 -0
- package/dist/src/commands/own.d.ts.map +1 -0
- package/dist/src/commands/own.js +499 -0
- package/dist/src/commands/own.js.map +1 -0
- package/dist/src/commands/pair.d.ts +3 -0
- package/dist/src/commands/pair.d.ts.map +1 -0
- package/dist/src/commands/pair.js +206 -0
- package/dist/src/commands/pair.js.map +1 -0
- package/dist/src/commands/pipeline.d.ts +3 -0
- package/dist/src/commands/pipeline.d.ts.map +1 -0
- package/dist/src/commands/pipeline.js +143 -0
- package/dist/src/commands/pipeline.js.map +1 -0
- package/dist/src/commands/plan.d.ts +3 -0
- package/dist/src/commands/plan.d.ts.map +1 -0
- package/dist/src/commands/plan.js +49 -0
- package/dist/src/commands/plan.js.map +1 -0
- package/dist/src/commands/plugin.d.ts +3 -0
- package/dist/src/commands/plugin.d.ts.map +1 -0
- package/dist/src/commands/plugin.js +114 -0
- package/dist/src/commands/plugin.js.map +1 -0
- package/dist/src/commands/pm.d.ts +38 -0
- package/dist/src/commands/pm.d.ts.map +1 -0
- package/dist/src/commands/pm.js +664 -0
- package/dist/src/commands/pm.js.map +1 -0
- package/dist/src/commands/pr.d.ts +3 -0
- package/dist/src/commands/pr.d.ts.map +1 -0
- package/dist/src/commands/pr.js +225 -0
- package/dist/src/commands/pr.js.map +1 -0
- package/dist/src/commands/prompt-guard.d.ts +3 -0
- package/dist/src/commands/prompt-guard.d.ts.map +1 -0
- package/dist/src/commands/prompt-guard.js +54 -0
- package/dist/src/commands/prompt-guard.js.map +1 -0
- package/dist/src/commands/provenance.d.ts +3 -0
- package/dist/src/commands/provenance.d.ts.map +1 -0
- package/dist/src/commands/provenance.js +96 -0
- package/dist/src/commands/provenance.js.map +1 -0
- package/dist/src/commands/recover.d.ts +3 -0
- package/dist/src/commands/recover.d.ts.map +1 -0
- package/dist/src/commands/recover.js +32 -0
- package/dist/src/commands/recover.js.map +1 -0
- package/dist/src/commands/refactor.d.ts +3 -0
- package/dist/src/commands/refactor.d.ts.map +1 -0
- package/dist/src/commands/refactor.js +143 -0
- package/dist/src/commands/refactor.js.map +1 -0
- package/dist/src/commands/report.d.ts +66 -0
- package/dist/src/commands/report.d.ts.map +1 -0
- package/dist/src/commands/report.js +493 -0
- package/dist/src/commands/report.js.map +1 -0
- package/dist/src/commands/retro.d.ts +71 -0
- package/dist/src/commands/retro.d.ts.map +1 -0
- package/dist/src/commands/retro.js +449 -0
- package/dist/src/commands/retro.js.map +1 -0
- package/dist/src/commands/review.d.ts +3 -0
- package/dist/src/commands/review.d.ts.map +1 -0
- package/dist/src/commands/review.js +202 -0
- package/dist/src/commands/review.js.map +1 -0
- package/dist/src/commands/risk.d.ts +3 -0
- package/dist/src/commands/risk.d.ts.map +1 -0
- package/dist/src/commands/risk.js +110 -0
- package/dist/src/commands/risk.js.map +1 -0
- package/dist/src/commands/roadmap.d.ts +3 -0
- package/dist/src/commands/roadmap.d.ts.map +1 -0
- package/dist/src/commands/roadmap.js +506 -0
- package/dist/src/commands/roadmap.js.map +1 -0
- package/dist/src/commands/runtime-monitor.d.ts +3 -0
- package/dist/src/commands/runtime-monitor.d.ts.map +1 -0
- package/dist/src/commands/runtime-monitor.js +154 -0
- package/dist/src/commands/runtime-monitor.js.map +1 -0
- package/dist/src/commands/sandbox.d.ts +3 -0
- package/dist/src/commands/sandbox.d.ts.map +1 -0
- package/dist/src/commands/sandbox.js +201 -0
- package/dist/src/commands/sandbox.js.map +1 -0
- package/dist/src/commands/scope.d.ts +3 -0
- package/dist/src/commands/scope.d.ts.map +1 -0
- package/dist/src/commands/scope.js +192 -0
- package/dist/src/commands/scope.js.map +1 -0
- package/dist/src/commands/secrets.d.ts +3 -0
- package/dist/src/commands/secrets.d.ts.map +1 -0
- package/dist/src/commands/secrets.js +99 -0
- package/dist/src/commands/secrets.js.map +1 -0
- package/dist/src/commands/secure.d.ts +3 -0
- package/dist/src/commands/secure.d.ts.map +1 -0
- package/dist/src/commands/secure.js +215 -0
- package/dist/src/commands/secure.js.map +1 -0
- package/dist/src/commands/server.d.ts +3 -0
- package/dist/src/commands/server.d.ts.map +1 -0
- package/dist/src/commands/server.js +228 -0
- package/dist/src/commands/server.js.map +1 -0
- package/dist/src/commands/shared.d.ts +18 -0
- package/dist/src/commands/shared.d.ts.map +1 -0
- package/dist/src/commands/shared.js +61 -0
- package/dist/src/commands/shared.js.map +1 -0
- package/dist/src/commands/simplify.d.ts +3 -0
- package/dist/src/commands/simplify.d.ts.map +1 -0
- package/dist/src/commands/simplify.js +194 -0
- package/dist/src/commands/simplify.js.map +1 -0
- package/dist/src/commands/simulate.d.ts +3 -0
- package/dist/src/commands/simulate.d.ts.map +1 -0
- package/dist/src/commands/simulate.js +275 -0
- package/dist/src/commands/simulate.js.map +1 -0
- package/dist/src/commands/slo.d.ts +3 -0
- package/dist/src/commands/slo.d.ts.map +1 -0
- package/dist/src/commands/slo.js +341 -0
- package/dist/src/commands/slo.js.map +1 -0
- package/dist/src/commands/spawn-capability.d.ts +3 -0
- package/dist/src/commands/spawn-capability.d.ts.map +1 -0
- package/dist/src/commands/spawn-capability.js +153 -0
- package/dist/src/commands/spawn-capability.js.map +1 -0
- package/dist/src/commands/specialize.d.ts +3 -0
- package/dist/src/commands/specialize.d.ts.map +1 -0
- package/dist/src/commands/specialize.js +266 -0
- package/dist/src/commands/specialize.js.map +1 -0
- package/dist/src/commands/spike.d.ts +3 -0
- package/dist/src/commands/spike.d.ts.map +1 -0
- package/dist/src/commands/spike.js +109 -0
- package/dist/src/commands/spike.js.map +1 -0
- package/dist/src/commands/standup.d.ts +3 -0
- package/dist/src/commands/standup.d.ts.map +1 -0
- package/dist/src/commands/standup.js +76 -0
- package/dist/src/commands/standup.js.map +1 -0
- package/dist/src/commands/stats.d.ts +39 -0
- package/dist/src/commands/stats.d.ts.map +1 -0
- package/dist/src/commands/stats.js +185 -0
- package/dist/src/commands/stats.js.map +1 -0
- package/dist/src/commands/status.d.ts +3 -0
- package/dist/src/commands/status.d.ts.map +1 -0
- package/dist/src/commands/status.js +65 -0
- package/dist/src/commands/status.js.map +1 -0
- package/dist/src/commands/supply-chain.d.ts +3 -0
- package/dist/src/commands/supply-chain.d.ts.map +1 -0
- package/dist/src/commands/supply-chain.js +110 -0
- package/dist/src/commands/supply-chain.js.map +1 -0
- package/dist/src/commands/system.d.ts +3 -0
- package/dist/src/commands/system.d.ts.map +1 -0
- package/dist/src/commands/system.js +582 -0
- package/dist/src/commands/system.js.map +1 -0
- package/dist/src/commands/teach.d.ts +3 -0
- package/dist/src/commands/teach.d.ts.map +1 -0
- package/dist/src/commands/teach.js +420 -0
- package/dist/src/commands/teach.js.map +1 -0
- package/dist/src/commands/team.d.ts +44 -0
- package/dist/src/commands/team.d.ts.map +1 -0
- package/dist/src/commands/team.js +355 -0
- package/dist/src/commands/team.js.map +1 -0
- package/dist/src/commands/telemetry.d.ts +3 -0
- package/dist/src/commands/telemetry.d.ts.map +1 -0
- package/dist/src/commands/telemetry.js +87 -0
- package/dist/src/commands/telemetry.js.map +1 -0
- package/dist/src/commands/test-gen.d.ts +3 -0
- package/dist/src/commands/test-gen.d.ts.map +1 -0
- package/dist/src/commands/test-gen.js +541 -0
- package/dist/src/commands/test-gen.js.map +1 -0
- package/dist/src/commands/test.d.ts +3 -0
- package/dist/src/commands/test.d.ts.map +1 -0
- package/dist/src/commands/test.js +84 -0
- package/dist/src/commands/test.js.map +1 -0
- package/dist/src/commands/watch.d.ts +11 -0
- package/dist/src/commands/watch.d.ts.map +1 -0
- package/dist/src/commands/watch.js +317 -0
- package/dist/src/commands/watch.js.map +1 -0
- package/dist/src/core/activity-tracker.d.ts +70 -0
- package/dist/src/core/activity-tracker.d.ts.map +1 -0
- package/dist/src/core/activity-tracker.js +294 -0
- package/dist/src/core/activity-tracker.js.map +1 -0
- package/dist/src/core/agent-bus.d.ts +38 -0
- package/dist/src/core/agent-bus.d.ts.map +1 -0
- package/dist/src/core/agent-bus.js +128 -0
- package/dist/src/core/agent-bus.js.map +1 -0
- package/dist/src/core/agent-loop.d.ts +79 -0
- package/dist/src/core/agent-loop.d.ts.map +1 -0
- package/dist/src/core/agent-loop.js +225 -0
- package/dist/src/core/agent-loop.js.map +1 -0
- package/dist/src/core/agent-manager.d.ts +90 -0
- package/dist/src/core/agent-manager.d.ts.map +1 -0
- package/dist/src/core/agent-manager.js +549 -0
- package/dist/src/core/agent-manager.js.map +1 -0
- package/dist/src/core/agent-process.d.ts +95 -0
- package/dist/src/core/agent-process.d.ts.map +1 -0
- package/dist/src/core/agent-process.js +428 -0
- package/dist/src/core/agent-process.js.map +1 -0
- package/dist/src/core/ambiguity-detector.d.ts +31 -0
- package/dist/src/core/ambiguity-detector.d.ts.map +1 -0
- package/dist/src/core/ambiguity-detector.js +286 -0
- package/dist/src/core/ambiguity-detector.js.map +1 -0
- package/dist/src/core/anomaly-detector.d.ts +30 -0
- package/dist/src/core/anomaly-detector.d.ts.map +1 -0
- package/dist/src/core/anomaly-detector.js +300 -0
- package/dist/src/core/anomaly-detector.js.map +1 -0
- package/dist/src/core/api-lifecycle.d.ts +11 -0
- package/dist/src/core/api-lifecycle.d.ts.map +1 -0
- package/dist/src/core/api-lifecycle.js +178 -0
- package/dist/src/core/api-lifecycle.js.map +1 -0
- package/dist/src/core/audit.d.ts +36 -0
- package/dist/src/core/audit.d.ts.map +1 -0
- package/dist/src/core/audit.js +88 -0
- package/dist/src/core/audit.js.map +1 -0
- package/dist/src/core/capability-spawner.d.ts +17 -0
- package/dist/src/core/capability-spawner.d.ts.map +1 -0
- package/dist/src/core/capability-spawner.js +170 -0
- package/dist/src/core/capability-spawner.js.map +1 -0
- package/dist/src/core/codebase-index.d.ts +53 -0
- package/dist/src/core/codebase-index.d.ts.map +1 -0
- package/dist/src/core/codebase-index.js +540 -0
- package/dist/src/core/codebase-index.js.map +1 -0
- package/dist/src/core/codebase-scanner.d.ts +3 -0
- package/dist/src/core/codebase-scanner.d.ts.map +1 -0
- package/dist/src/core/codebase-scanner.js +179 -0
- package/dist/src/core/codebase-scanner.js.map +1 -0
- package/dist/src/core/competitive-intel.d.ts +18 -0
- package/dist/src/core/competitive-intel.d.ts.map +1 -0
- package/dist/src/core/competitive-intel.js +167 -0
- package/dist/src/core/competitive-intel.js.map +1 -0
- package/dist/src/core/config.d.ts +14 -0
- package/dist/src/core/config.d.ts.map +1 -0
- package/dist/src/core/config.js +116 -0
- package/dist/src/core/config.js.map +1 -0
- package/dist/src/core/convention-extractor.d.ts +8 -0
- package/dist/src/core/convention-extractor.d.ts.map +1 -0
- package/dist/src/core/convention-extractor.js +382 -0
- package/dist/src/core/convention-extractor.js.map +1 -0
- package/dist/src/core/cost-tracker.d.ts +23 -0
- package/dist/src/core/cost-tracker.d.ts.map +1 -0
- package/dist/src/core/cost-tracker.js +83 -0
- package/dist/src/core/cost-tracker.js.map +1 -0
- package/dist/src/core/decision-journal.d.ts +41 -0
- package/dist/src/core/decision-journal.d.ts.map +1 -0
- package/dist/src/core/decision-journal.js +204 -0
- package/dist/src/core/decision-journal.js.map +1 -0
- package/dist/src/core/experiment-engine.d.ts +31 -0
- package/dist/src/core/experiment-engine.d.ts.map +1 -0
- package/dist/src/core/experiment-engine.js +248 -0
- package/dist/src/core/experiment-engine.js.map +1 -0
- package/dist/src/core/federation.d.ts +18 -0
- package/dist/src/core/federation.d.ts.map +1 -0
- package/dist/src/core/federation.js +202 -0
- package/dist/src/core/federation.js.map +1 -0
- package/dist/src/core/fingerprint.d.ts +42 -0
- package/dist/src/core/fingerprint.d.ts.map +1 -0
- package/dist/src/core/fingerprint.js +316 -0
- package/dist/src/core/fingerprint.js.map +1 -0
- package/dist/src/core/git.d.ts +50 -0
- package/dist/src/core/git.d.ts.map +1 -0
- package/dist/src/core/git.js +342 -0
- package/dist/src/core/git.js.map +1 -0
- package/dist/src/core/governance.d.ts +53 -0
- package/dist/src/core/governance.d.ts.map +1 -0
- package/dist/src/core/governance.js +276 -0
- package/dist/src/core/governance.js.map +1 -0
- package/dist/src/core/guardrails.d.ts +34 -0
- package/dist/src/core/guardrails.d.ts.map +1 -0
- package/dist/src/core/guardrails.js +575 -0
- package/dist/src/core/guardrails.js.map +1 -0
- package/dist/src/core/impact-analyzer.d.ts +56 -0
- package/dist/src/core/impact-analyzer.d.ts.map +1 -0
- package/dist/src/core/impact-analyzer.js +309 -0
- package/dist/src/core/impact-analyzer.js.map +1 -0
- package/dist/src/core/input-listener.d.ts +45 -0
- package/dist/src/core/input-listener.d.ts.map +1 -0
- package/dist/src/core/input-listener.js +116 -0
- package/dist/src/core/input-listener.js.map +1 -0
- package/dist/src/core/memory-store.d.ts +61 -0
- package/dist/src/core/memory-store.d.ts.map +1 -0
- package/dist/src/core/memory-store.js +195 -0
- package/dist/src/core/memory-store.js.map +1 -0
- package/dist/src/core/observability.d.ts +56 -0
- package/dist/src/core/observability.d.ts.map +1 -0
- package/dist/src/core/observability.js +305 -0
- package/dist/src/core/observability.js.map +1 -0
- package/dist/src/core/pair-engine.d.ts +47 -0
- package/dist/src/core/pair-engine.d.ts.map +1 -0
- package/dist/src/core/pair-engine.js +355 -0
- package/dist/src/core/pair-engine.js.map +1 -0
- package/dist/src/core/perf-analyzer.d.ts +35 -0
- package/dist/src/core/perf-analyzer.d.ts.map +1 -0
- package/dist/src/core/perf-analyzer.js +598 -0
- package/dist/src/core/perf-analyzer.js.map +1 -0
- package/dist/src/core/pipeline-loader.d.ts +46 -0
- package/dist/src/core/pipeline-loader.d.ts.map +1 -0
- package/dist/src/core/pipeline-loader.js +182 -0
- package/dist/src/core/pipeline-loader.js.map +1 -0
- package/dist/src/core/pipeline.d.ts +183 -0
- package/dist/src/core/pipeline.d.ts.map +1 -0
- package/dist/src/core/pipeline.js +2264 -0
- package/dist/src/core/pipeline.js.map +1 -0
- package/dist/src/core/plugins.d.ts +61 -0
- package/dist/src/core/plugins.d.ts.map +1 -0
- package/dist/src/core/plugins.js +114 -0
- package/dist/src/core/plugins.js.map +1 -0
- package/dist/src/core/preflight.d.ts +7 -0
- package/dist/src/core/preflight.d.ts.map +1 -0
- package/dist/src/core/preflight.js +35 -0
- package/dist/src/core/preflight.js.map +1 -0
- package/dist/src/core/prompt-guard.d.ts +44 -0
- package/dist/src/core/prompt-guard.d.ts.map +1 -0
- package/dist/src/core/prompt-guard.js +274 -0
- package/dist/src/core/prompt-guard.js.map +1 -0
- package/dist/src/core/provenance.d.ts +39 -0
- package/dist/src/core/provenance.d.ts.map +1 -0
- package/dist/src/core/provenance.js +115 -0
- package/dist/src/core/provenance.js.map +1 -0
- package/dist/src/core/providers/anthropic-api.d.ts +34 -0
- package/dist/src/core/providers/anthropic-api.d.ts.map +1 -0
- package/dist/src/core/providers/anthropic-api.js +522 -0
- package/dist/src/core/providers/anthropic-api.js.map +1 -0
- package/dist/src/core/providers/api-agent-backend.d.ts +31 -0
- package/dist/src/core/providers/api-agent-backend.d.ts.map +1 -0
- package/dist/src/core/providers/api-agent-backend.js +127 -0
- package/dist/src/core/providers/api-agent-backend.js.map +1 -0
- package/dist/src/core/providers/api-text-backend.d.ts +35 -0
- package/dist/src/core/providers/api-text-backend.d.ts.map +1 -0
- package/dist/src/core/providers/api-text-backend.js +145 -0
- package/dist/src/core/providers/api-text-backend.js.map +1 -0
- package/dist/src/core/providers/claude-cli.d.ts +80 -0
- package/dist/src/core/providers/claude-cli.d.ts.map +1 -0
- package/dist/src/core/providers/claude-cli.js +489 -0
- package/dist/src/core/providers/claude-cli.js.map +1 -0
- package/dist/src/core/providers/cost-table.d.ts +46 -0
- package/dist/src/core/providers/cost-table.d.ts.map +1 -0
- package/dist/src/core/providers/cost-table.js +136 -0
- package/dist/src/core/providers/cost-table.js.map +1 -0
- package/dist/src/core/providers/google.d.ts +26 -0
- package/dist/src/core/providers/google.d.ts.map +1 -0
- package/dist/src/core/providers/google.js +165 -0
- package/dist/src/core/providers/google.js.map +1 -0
- package/dist/src/core/providers/model-catalog.d.ts +72 -0
- package/dist/src/core/providers/model-catalog.d.ts.map +1 -0
- package/dist/src/core/providers/model-catalog.js +290 -0
- package/dist/src/core/providers/model-catalog.js.map +1 -0
- package/dist/src/core/providers/openai-compat.d.ts +35 -0
- package/dist/src/core/providers/openai-compat.d.ts.map +1 -0
- package/dist/src/core/providers/openai-compat.js +479 -0
- package/dist/src/core/providers/openai-compat.js.map +1 -0
- package/dist/src/core/providers/prompt-adapter.d.ts +42 -0
- package/dist/src/core/providers/prompt-adapter.d.ts.map +1 -0
- package/dist/src/core/providers/prompt-adapter.js +282 -0
- package/dist/src/core/providers/prompt-adapter.js.map +1 -0
- package/dist/src/core/providers/registry.d.ts +93 -0
- package/dist/src/core/providers/registry.d.ts.map +1 -0
- package/dist/src/core/providers/registry.js +191 -0
- package/dist/src/core/providers/registry.js.map +1 -0
- package/dist/src/core/providers/types.d.ts +165 -0
- package/dist/src/core/providers/types.d.ts.map +1 -0
- package/dist/src/core/providers/types.js +13 -0
- package/dist/src/core/providers/types.js.map +1 -0
- package/dist/src/core/quality.d.ts +22 -0
- package/dist/src/core/quality.d.ts.map +1 -0
- package/dist/src/core/quality.js +209 -0
- package/dist/src/core/quality.js.map +1 -0
- package/dist/src/core/resource-allocator.d.ts +37 -0
- package/dist/src/core/resource-allocator.d.ts.map +1 -0
- package/dist/src/core/resource-allocator.js +480 -0
- package/dist/src/core/resource-allocator.js.map +1 -0
- package/dist/src/core/risk-scorer.d.ts +35 -0
- package/dist/src/core/risk-scorer.d.ts.map +1 -0
- package/dist/src/core/risk-scorer.js +226 -0
- package/dist/src/core/risk-scorer.js.map +1 -0
- package/dist/src/core/runtime-monitor.d.ts +49 -0
- package/dist/src/core/runtime-monitor.d.ts.map +1 -0
- package/dist/src/core/runtime-monitor.js +235 -0
- package/dist/src/core/runtime-monitor.js.map +1 -0
- package/dist/src/core/sandbox.d.ts +47 -0
- package/dist/src/core/sandbox.d.ts.map +1 -0
- package/dist/src/core/sandbox.js +277 -0
- package/dist/src/core/sandbox.js.map +1 -0
- package/dist/src/core/secret-detector.d.ts +25 -0
- package/dist/src/core/secret-detector.d.ts.map +1 -0
- package/dist/src/core/secret-detector.js +307 -0
- package/dist/src/core/secret-detector.js.map +1 -0
- package/dist/src/core/security-scanner.d.ts +36 -0
- package/dist/src/core/security-scanner.d.ts.map +1 -0
- package/dist/src/core/security-scanner.js +366 -0
- package/dist/src/core/security-scanner.js.map +1 -0
- package/dist/src/core/self-improvement.d.ts +26 -0
- package/dist/src/core/self-improvement.d.ts.map +1 -0
- package/dist/src/core/self-improvement.js +356 -0
- package/dist/src/core/self-improvement.js.map +1 -0
- package/dist/src/core/simulator.d.ts +28 -0
- package/dist/src/core/simulator.d.ts.map +1 -0
- package/dist/src/core/simulator.js +334 -0
- package/dist/src/core/simulator.js.map +1 -0
- package/dist/src/core/specialization.d.ts +47 -0
- package/dist/src/core/specialization.d.ts.map +1 -0
- package/dist/src/core/specialization.js +239 -0
- package/dist/src/core/specialization.js.map +1 -0
- package/dist/src/core/stakeholder-engine.d.ts +47 -0
- package/dist/src/core/stakeholder-engine.d.ts.map +1 -0
- package/dist/src/core/stakeholder-engine.js +380 -0
- package/dist/src/core/stakeholder-engine.js.map +1 -0
- package/dist/src/core/state.d.ts +99 -0
- package/dist/src/core/state.d.ts.map +1 -0
- package/dist/src/core/state.js +545 -0
- package/dist/src/core/state.js.map +1 -0
- package/dist/src/core/supply-chain.d.ts +26 -0
- package/dist/src/core/supply-chain.d.ts.map +1 -0
- package/dist/src/core/supply-chain.js +332 -0
- package/dist/src/core/supply-chain.js.map +1 -0
- package/dist/src/core/telemetry.d.ts +110 -0
- package/dist/src/core/telemetry.d.ts.map +1 -0
- package/dist/src/core/telemetry.js +276 -0
- package/dist/src/core/telemetry.js.map +1 -0
- package/dist/src/core/tools/definitions.d.ts +10 -0
- package/dist/src/core/tools/definitions.d.ts.map +1 -0
- package/dist/src/core/tools/definitions.js +165 -0
- package/dist/src/core/tools/definitions.js.map +1 -0
- package/dist/src/core/tools/executor.d.ts +27 -0
- package/dist/src/core/tools/executor.d.ts.map +1 -0
- package/dist/src/core/tools/executor.js +306 -0
- package/dist/src/core/tools/executor.js.map +1 -0
- package/dist/src/core/tools/sandbox.d.ts +41 -0
- package/dist/src/core/tools/sandbox.d.ts.map +1 -0
- package/dist/src/core/tools/sandbox.js +106 -0
- package/dist/src/core/tools/sandbox.js.map +1 -0
- package/dist/src/core/training-pipeline.d.ts +66 -0
- package/dist/src/core/training-pipeline.d.ts.map +1 -0
- package/dist/src/core/training-pipeline.js +267 -0
- package/dist/src/core/training-pipeline.js.map +1 -0
- package/dist/src/core/triage.d.ts +56 -0
- package/dist/src/core/triage.d.ts.map +1 -0
- package/dist/src/core/triage.js +227 -0
- package/dist/src/core/triage.js.map +1 -0
- package/dist/src/core/user-intelligence.d.ts +29 -0
- package/dist/src/core/user-intelligence.d.ts.map +1 -0
- package/dist/src/core/user-intelligence.js +172 -0
- package/dist/src/core/user-intelligence.js.map +1 -0
- package/dist/src/core/webhooks.d.ts +32 -0
- package/dist/src/core/webhooks.d.ts.map +1 -0
- package/dist/src/core/webhooks.js +126 -0
- package/dist/src/core/webhooks.js.map +1 -0
- package/dist/src/core/ws-server.d.ts +43 -0
- package/dist/src/core/ws-server.d.ts.map +1 -0
- package/dist/src/core/ws-server.js +3278 -0
- package/dist/src/core/ws-server.js.map +1 -0
- package/dist/src/prompts/loader.d.ts +36 -0
- package/dist/src/prompts/loader.d.ts.map +1 -0
- package/dist/src/prompts/loader.js +156 -0
- package/dist/src/prompts/loader.js.map +1 -0
- package/dist/src/types.d.ts +2539 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +62 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt Adaptation Layer
|
|
3
|
+
*
|
|
4
|
+
* Adapts persona system prompts based on target model capabilities.
|
|
5
|
+
* - Tier 3 (Claude CLI): No changes
|
|
6
|
+
* - Tier 2 (API + tools): Remap tool names, strip Claude-specific features
|
|
7
|
+
* - Tier 1 (text-only): Strip all tool refs, add output format instructions
|
|
8
|
+
*/
|
|
9
|
+
/** Claude Code tool name -> Swarm/generic tool name mapping */
|
|
10
|
+
const TOOL_NAME_MAP = {
|
|
11
|
+
'Read': 'read_file',
|
|
12
|
+
'Edit': 'edit_file',
|
|
13
|
+
'Write': 'write_file',
|
|
14
|
+
'Bash': 'run_command',
|
|
15
|
+
'Grep': 'search_files',
|
|
16
|
+
'Glob': 'list_files',
|
|
17
|
+
'Agent': 'spawn_agent',
|
|
18
|
+
'WebSearch': 'web_search',
|
|
19
|
+
'WebFetch': 'web_fetch',
|
|
20
|
+
'NotebookEdit': 'notebook_edit',
|
|
21
|
+
};
|
|
22
|
+
/** Patterns that reference Claude Code-specific features */
|
|
23
|
+
const CLAUDE_SPECIFIC_PATTERNS = [
|
|
24
|
+
/You are (?:powered by )?Claude Code[^.]*\./gi,
|
|
25
|
+
/Claude Code's? (?:built-in )?(?:tools?|commands?|capabilities)[^.]*\./gi,
|
|
26
|
+
/(?:MCP|Model Context Protocol)[^.]*\./gi,
|
|
27
|
+
/permission mode[s]?[^.]*\./gi,
|
|
28
|
+
/sub-?agents?[^.]*spawning[^.]*\./gi,
|
|
29
|
+
/--(?:permission-mode|allowedTools|disallowedTools)[^.\n]*/gi,
|
|
30
|
+
/`claude`\s+CLI[^.]*\./gi,
|
|
31
|
+
];
|
|
32
|
+
/** Persona-specific output format instructions for text-only mode */
|
|
33
|
+
const PERSONA_OUTPUT_INSTRUCTIONS = {
|
|
34
|
+
analyst: [
|
|
35
|
+
'OUTPUT FORMAT:',
|
|
36
|
+
'You must produce a complete markdown document titled "REQUIREMENTS.md".',
|
|
37
|
+
'Structure it with clear sections: Overview, Functional Requirements, Non-Functional Requirements,',
|
|
38
|
+
'User Stories, Acceptance Criteria, and Constraints.',
|
|
39
|
+
'Use numbered requirements (e.g., FR-001, NFR-001) for traceability.',
|
|
40
|
+
'Do NOT include architecture decisions, code, or task breakdowns.',
|
|
41
|
+
].join('\n'),
|
|
42
|
+
architect: [
|
|
43
|
+
'OUTPUT FORMAT:',
|
|
44
|
+
'You must produce a complete markdown document titled "SPEC.md".',
|
|
45
|
+
'Structure it with: System Overview, Architecture Diagram (ASCII/Mermaid), Component Design,',
|
|
46
|
+
'Data Models, API Contracts, Technology Choices with Rationale, and Security Considerations.',
|
|
47
|
+
'Do NOT include implementation code or task breakdowns.',
|
|
48
|
+
].join('\n'),
|
|
49
|
+
lead: [
|
|
50
|
+
'OUTPUT FORMAT:',
|
|
51
|
+
'You must produce a complete markdown document titled "TASKS.md".',
|
|
52
|
+
'Structure tasks with IDs (e.g., FND-001, SVC-002) and include:',
|
|
53
|
+
'Task ID, Description, Acceptance Criteria, Dependencies, and Estimated Complexity.',
|
|
54
|
+
'Group tasks by parallel execution groups where independent tasks can run simultaneously.',
|
|
55
|
+
'Mark parallel groups with "## Parallel Group N" headers.',
|
|
56
|
+
'Do NOT include actual implementation code or redesign the architecture.',
|
|
57
|
+
].join('\n'),
|
|
58
|
+
engineer: [
|
|
59
|
+
'OUTPUT FORMAT:',
|
|
60
|
+
'Implement the code changes as described. For each file you create or modify,',
|
|
61
|
+
'output the complete file content wrapped in a code block with the file path as a header.',
|
|
62
|
+
'Example:',
|
|
63
|
+
'### path/to/file.ts',
|
|
64
|
+
'```typescript',
|
|
65
|
+
'// file content here',
|
|
66
|
+
'```',
|
|
67
|
+
'Ensure all code is production-quality with proper error handling.',
|
|
68
|
+
].join('\n'),
|
|
69
|
+
tester: [
|
|
70
|
+
'OUTPUT FORMAT:',
|
|
71
|
+
'You must produce a complete markdown document titled "TESTPLAN.md".',
|
|
72
|
+
'Structure it with: Test Strategy, Unit Tests, Integration Tests, E2E Tests,',
|
|
73
|
+
'Edge Cases, Performance Tests, and Test Data Requirements.',
|
|
74
|
+
'For each test, include: Test ID, Description, Steps, Expected Result, and Priority.',
|
|
75
|
+
'Do NOT include or modify source code — test plan documentation only.',
|
|
76
|
+
].join('\n'),
|
|
77
|
+
};
|
|
78
|
+
export class PromptAdapter {
|
|
79
|
+
/**
|
|
80
|
+
* Adapt a persona system prompt for a given capability tier.
|
|
81
|
+
*/
|
|
82
|
+
adapt(systemPrompt, tier, options) {
|
|
83
|
+
switch (tier) {
|
|
84
|
+
case 3:
|
|
85
|
+
// Claude CLI — no changes needed
|
|
86
|
+
return { systemPrompt };
|
|
87
|
+
case 2:
|
|
88
|
+
return this.adaptForToolCalling(systemPrompt, options);
|
|
89
|
+
case 1:
|
|
90
|
+
return this.adaptForTextOnly(systemPrompt, options);
|
|
91
|
+
default:
|
|
92
|
+
return { systemPrompt };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// Tier 2: API + tools
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
adaptForToolCalling(systemPrompt, options) {
|
|
99
|
+
let adapted = systemPrompt;
|
|
100
|
+
// Replace Claude tool names with Swarm tool names
|
|
101
|
+
adapted = this.replaceToolNames(adapted);
|
|
102
|
+
// Strip Claude Code-specific references
|
|
103
|
+
adapted = this.stripClaudeToolReferences(adapted);
|
|
104
|
+
// Add Swarm tool usage hints
|
|
105
|
+
adapted = this.addSwarmToolHints(adapted);
|
|
106
|
+
// Add model-specific instructions if provider is known
|
|
107
|
+
if (options?.modelProvider) {
|
|
108
|
+
adapted = this.addModelHints(adapted, options.modelProvider);
|
|
109
|
+
}
|
|
110
|
+
return { systemPrompt: adapted };
|
|
111
|
+
}
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// Tier 1: text-only
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
adaptForTextOnly(systemPrompt, options) {
|
|
116
|
+
let adapted = systemPrompt;
|
|
117
|
+
// Strip ALL tool references — text-only models can't use tools
|
|
118
|
+
adapted = this.stripAllToolReferences(adapted);
|
|
119
|
+
// Strip Claude-specific references
|
|
120
|
+
adapted = this.stripClaudeToolReferences(adapted);
|
|
121
|
+
// Detect persona from prompt content and add output format instructions
|
|
122
|
+
const persona = this.detectPersona(adapted);
|
|
123
|
+
if (persona) {
|
|
124
|
+
adapted = this.addOutputFormatInstructions(adapted, persona);
|
|
125
|
+
}
|
|
126
|
+
// Add model-specific instructions
|
|
127
|
+
if (options?.modelProvider) {
|
|
128
|
+
adapted = this.addModelHints(adapted, options.modelProvider);
|
|
129
|
+
}
|
|
130
|
+
// Build user prompt prefix with injected file contents
|
|
131
|
+
let userPromptPrefix;
|
|
132
|
+
if (options?.injectFileContents && Object.keys(options.injectFileContents).length > 0) {
|
|
133
|
+
const parts = ['Here are the relevant project files for context:\n'];
|
|
134
|
+
for (const [filePath, content] of Object.entries(options.injectFileContents)) {
|
|
135
|
+
parts.push(`### ${filePath}\n\`\`\`\n${content}\n\`\`\`\n`);
|
|
136
|
+
}
|
|
137
|
+
parts.push('---\n');
|
|
138
|
+
userPromptPrefix = parts.join('\n');
|
|
139
|
+
}
|
|
140
|
+
return { systemPrompt: adapted, userPromptPrefix };
|
|
141
|
+
}
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
// Tool name replacement
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
/** Replace Claude Code tool names with Swarm/generic tool names */
|
|
146
|
+
replaceToolNames(prompt) {
|
|
147
|
+
let result = prompt;
|
|
148
|
+
for (const [claudeName, swarmName] of Object.entries(TOOL_NAME_MAP)) {
|
|
149
|
+
// Match tool name in backticks, after "the", or as standalone word in tool context
|
|
150
|
+
const patterns = [
|
|
151
|
+
new RegExp(`\`${claudeName}\``, 'g'),
|
|
152
|
+
new RegExp(`\\bthe ${claudeName} tool\\b`, 'gi'),
|
|
153
|
+
new RegExp(`\\buse ${claudeName}\\b`, 'gi'),
|
|
154
|
+
new RegExp(`\\b${claudeName} tool\\b`, 'gi'),
|
|
155
|
+
];
|
|
156
|
+
for (const pattern of patterns) {
|
|
157
|
+
result = result.replace(pattern, (match) => {
|
|
158
|
+
// Preserve casing style
|
|
159
|
+
if (match.startsWith('`'))
|
|
160
|
+
return `\`${swarmName}\``;
|
|
161
|
+
if (match.toLowerCase().startsWith('the '))
|
|
162
|
+
return `the ${swarmName} tool`;
|
|
163
|
+
if (match.toLowerCase().startsWith('use '))
|
|
164
|
+
return `use ${swarmName}`;
|
|
165
|
+
return `${swarmName} tool`;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
/** Strip references to Claude Code-specific features */
|
|
172
|
+
stripClaudeToolReferences(prompt) {
|
|
173
|
+
let result = prompt;
|
|
174
|
+
for (const pattern of CLAUDE_SPECIFIC_PATTERNS) {
|
|
175
|
+
result = result.replace(pattern, '');
|
|
176
|
+
}
|
|
177
|
+
// Clean up resulting double-newlines
|
|
178
|
+
result = result.replace(/\n{3,}/g, '\n\n');
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
/** Strip ALL tool references (for text-only models) */
|
|
182
|
+
stripAllToolReferences(prompt) {
|
|
183
|
+
let result = prompt;
|
|
184
|
+
// Remove tool usage instruction blocks
|
|
185
|
+
result = result.replace(/(?:^|\n)#+\s*(?:Tools?|Available Tools|Tool Usage)[^\n]*(?:\n(?!#).*?)*/gim, '');
|
|
186
|
+
// Remove individual tool references
|
|
187
|
+
for (const toolName of Object.keys(TOOL_NAME_MAP)) {
|
|
188
|
+
result = result.replace(new RegExp(`\\b(?:use|call|invoke|run)\\s+(?:the\\s+)?${toolName}(?:\\s+tool)?\\b[^.]*\\.?`, 'gi'), '');
|
|
189
|
+
}
|
|
190
|
+
// Remove "you have access to tools" type sentences
|
|
191
|
+
result = result.replace(/you (?:have access to|can use|should use) (?:the following )?tools?[^.]*\./gi, '');
|
|
192
|
+
result = result.replace(/(?:available )?tools?:\s*(?:`[^`]+`(?:,\s*)?)+/gi, '');
|
|
193
|
+
// Clean up whitespace
|
|
194
|
+
result = result.replace(/\n{3,}/g, '\n\n');
|
|
195
|
+
return result.trim();
|
|
196
|
+
}
|
|
197
|
+
// ---------------------------------------------------------------------------
|
|
198
|
+
// Model-specific hints
|
|
199
|
+
// ---------------------------------------------------------------------------
|
|
200
|
+
/** Add model-specific instructions to improve output quality */
|
|
201
|
+
addModelHints(prompt, provider) {
|
|
202
|
+
const hints = [];
|
|
203
|
+
switch (provider.toLowerCase()) {
|
|
204
|
+
case 'openai':
|
|
205
|
+
hints.push('STYLE GUIDANCE: Be concise and direct. Avoid preamble.', 'Structure your response clearly with headers and bullet points where appropriate.');
|
|
206
|
+
break;
|
|
207
|
+
case 'google':
|
|
208
|
+
case 'gemini':
|
|
209
|
+
hints.push('STYLE GUIDANCE: Use well-structured sections with clear headers.', 'Prefer numbered lists for sequential items and bullet points for unordered items.', 'Include a brief summary at the start of your response.');
|
|
210
|
+
break;
|
|
211
|
+
case 'ollama':
|
|
212
|
+
case 'llama':
|
|
213
|
+
case 'local':
|
|
214
|
+
hints.push('STYLE GUIDANCE: Follow the output format instructions exactly.', 'Use proper markdown formatting with headers (##), lists, and code blocks.', 'Be thorough but stay within the scope of your role.', 'Do not add conversational filler — output only the requested document.');
|
|
215
|
+
break;
|
|
216
|
+
case 'deepseek':
|
|
217
|
+
hints.push('STYLE GUIDANCE: Emphasize technical accuracy and code-focused responses.', 'When discussing implementations, prefer concrete code examples.', 'Structure responses with clear technical sections.');
|
|
218
|
+
break;
|
|
219
|
+
// anthropic (API mode) and unknown providers get no extra hints
|
|
220
|
+
default:
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
if (hints.length > 0) {
|
|
224
|
+
return prompt + '\n\n' + hints.join('\n');
|
|
225
|
+
}
|
|
226
|
+
return prompt;
|
|
227
|
+
}
|
|
228
|
+
// ---------------------------------------------------------------------------
|
|
229
|
+
// Output format instructions
|
|
230
|
+
// ---------------------------------------------------------------------------
|
|
231
|
+
/** Add output format instructions based on persona */
|
|
232
|
+
addOutputFormatInstructions(prompt, persona) {
|
|
233
|
+
const instructions = PERSONA_OUTPUT_INSTRUCTIONS[persona];
|
|
234
|
+
if (!instructions)
|
|
235
|
+
return prompt;
|
|
236
|
+
return prompt + '\n\n' + instructions;
|
|
237
|
+
}
|
|
238
|
+
// ---------------------------------------------------------------------------
|
|
239
|
+
// Swarm tool hints (for Tier 2)
|
|
240
|
+
// ---------------------------------------------------------------------------
|
|
241
|
+
addSwarmToolHints(prompt) {
|
|
242
|
+
const hints = [
|
|
243
|
+
'',
|
|
244
|
+
'TOOL USAGE NOTES:',
|
|
245
|
+
'- `read_file`: Read a file from disk. Params: { path: string, offset?: number, limit?: number }',
|
|
246
|
+
'- `edit_file`: Make targeted edits to a file. Params: { path: string, old_text: string, new_text: string }',
|
|
247
|
+
'- `write_file`: Create or overwrite a file. Params: { path: string, content: string }',
|
|
248
|
+
'- `run_command`: Execute a shell command. Params: { command: string, cwd?: string }',
|
|
249
|
+
'- `search_files`: Search file contents with regex. Params: { pattern: string, path?: string, glob?: string }',
|
|
250
|
+
'- `list_files`: Find files by glob pattern. Params: { pattern: string, path?: string }',
|
|
251
|
+
].join('\n');
|
|
252
|
+
return prompt + hints;
|
|
253
|
+
}
|
|
254
|
+
// ---------------------------------------------------------------------------
|
|
255
|
+
// Persona detection
|
|
256
|
+
// ---------------------------------------------------------------------------
|
|
257
|
+
/** Detect the persona from prompt content */
|
|
258
|
+
detectPersona(prompt) {
|
|
259
|
+
const lower = prompt.toLowerCase();
|
|
260
|
+
if (lower.includes('requirements') && lower.includes('analyst'))
|
|
261
|
+
return 'analyst';
|
|
262
|
+
if (lower.includes('architect') && (lower.includes('spec') || lower.includes('design')))
|
|
263
|
+
return 'architect';
|
|
264
|
+
if (lower.includes('lead') && lower.includes('task'))
|
|
265
|
+
return 'lead';
|
|
266
|
+
if (lower.includes('test') && (lower.includes('tester') || lower.includes('test plan')))
|
|
267
|
+
return 'tester';
|
|
268
|
+
if (lower.includes('engineer') && lower.includes('implement'))
|
|
269
|
+
return 'engineer';
|
|
270
|
+
// Fallback: check for persona markers in the prompt
|
|
271
|
+
if (lower.includes('requirements.md'))
|
|
272
|
+
return 'analyst';
|
|
273
|
+
if (lower.includes('spec.md'))
|
|
274
|
+
return 'architect';
|
|
275
|
+
if (lower.includes('tasks.md'))
|
|
276
|
+
return 'lead';
|
|
277
|
+
if (lower.includes('testplan.md'))
|
|
278
|
+
return 'tester';
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=prompt-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-adapter.js","sourceRoot":"","sources":["../../../../src/core/providers/prompt-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,+DAA+D;AAC/D,MAAM,aAAa,GAA2B;IAC5C,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,WAAW,EAAE,YAAY;IACzB,UAAU,EAAE,WAAW;IACvB,cAAc,EAAE,eAAe;CAChC,CAAC;AAEF,4DAA4D;AAC5D,MAAM,wBAAwB,GAAG;IAC/B,8CAA8C;IAC9C,yEAAyE;IACzE,yCAAyC;IACzC,8BAA8B;IAC9B,oCAAoC;IACpC,6DAA6D;IAC7D,yBAAyB;CAC1B,CAAC;AAEF,qEAAqE;AACrE,MAAM,2BAA2B,GAA2B;IAC1D,OAAO,EAAE;QACP,gBAAgB;QAChB,yEAAyE;QACzE,mGAAmG;QACnG,qDAAqD;QACrD,qEAAqE;QACrE,kEAAkE;KACnE,CAAC,IAAI,CAAC,IAAI,CAAC;IAEZ,SAAS,EAAE;QACT,gBAAgB;QAChB,iEAAiE;QACjE,6FAA6F;QAC7F,6FAA6F;QAC7F,wDAAwD;KACzD,CAAC,IAAI,CAAC,IAAI,CAAC;IAEZ,IAAI,EAAE;QACJ,gBAAgB;QAChB,kEAAkE;QAClE,gEAAgE;QAChE,oFAAoF;QACpF,0FAA0F;QAC1F,0DAA0D;QAC1D,yEA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nD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry that maps model strings (e.g. 'sonnet', 'openai/gpt-4o')
|
|
5
|
+
* to their backing LLM providers. Supports aliases, env var expansion,
|
|
6
|
+
* and lazy provider instantiation from config.
|
|
7
|
+
*/
|
|
8
|
+
import type { LLMProvider, ProviderConfig } from './types.js';
|
|
9
|
+
export declare class ProviderRegistry {
|
|
10
|
+
private providers;
|
|
11
|
+
private configs;
|
|
12
|
+
private aliases;
|
|
13
|
+
/**
|
|
14
|
+
* Register a provider instance.
|
|
15
|
+
* @param name - Provider name (e.g. 'openai', 'anthropic')
|
|
16
|
+
* @param provider - The LLMProvider implementation
|
|
17
|
+
* @param config - Optional config to store alongside the provider
|
|
18
|
+
*/
|
|
19
|
+
register(name: string, provider: LLMProvider, config?: ProviderConfig): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get a registered provider by name.
|
|
22
|
+
*/
|
|
23
|
+
getProvider(providerName: string): LLMProvider | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Get stored config for a provider.
|
|
26
|
+
*/
|
|
27
|
+
getConfig(providerName: string): ProviderConfig | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a model string into its components.
|
|
30
|
+
*
|
|
31
|
+
* Resolution order:
|
|
32
|
+
* 1. Check aliases ('sonnet' → 'anthropic/claude-sonnet-4')
|
|
33
|
+
* 2. If contains '/', split on first '/' into provider/modelId
|
|
34
|
+
* 3. If no '/', try to infer provider from known model patterns
|
|
35
|
+
* 4. Fallback: treat as anthropic model (backward compat with existing 'sonnet'/'opus' usage)
|
|
36
|
+
*
|
|
37
|
+
* @param modelString - e.g. 'sonnet', 'openai/gpt-4o', 'anthropic/claude-sonnet-4'
|
|
38
|
+
* @returns Resolved provider, modelId, and fullId
|
|
39
|
+
*/
|
|
40
|
+
resolve(modelString: string): {
|
|
41
|
+
provider: string;
|
|
42
|
+
modelId: string;
|
|
43
|
+
fullId: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Get the provider instance for a model string.
|
|
47
|
+
* Resolves the model, then looks up the provider.
|
|
48
|
+
*/
|
|
49
|
+
getProviderForModel(modelString: string): LLMProvider | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* List all registered provider names.
|
|
52
|
+
*/
|
|
53
|
+
listProviders(): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Set custom aliases (merged with defaults).
|
|
56
|
+
*/
|
|
57
|
+
setAliases(aliases: Record<string, string>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Get all current aliases.
|
|
60
|
+
*/
|
|
61
|
+
getAliases(): Record<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* Expand environment variable references in a string.
|
|
64
|
+
* Replaces `${VAR_NAME}` with `process.env.VAR_NAME`.
|
|
65
|
+
* Returns the original value if the env var is not set.
|
|
66
|
+
*
|
|
67
|
+
* @param value - String potentially containing ${VAR_NAME} references
|
|
68
|
+
* @returns String with env vars expanded
|
|
69
|
+
*/
|
|
70
|
+
static expandEnvVars(value: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Register provider configs from a config object.
|
|
73
|
+
* Does NOT instantiate providers — they are created lazily when first needed.
|
|
74
|
+
* Expands env var references in apiKey and baseUrl.
|
|
75
|
+
*
|
|
76
|
+
* @param providersConfig - Map of provider name → config
|
|
77
|
+
*/
|
|
78
|
+
registerFromConfig(providersConfig: Record<string, ProviderConfig>): void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the global provider registry. Creates a default one if not initialized.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getRegistry(): ProviderRegistry;
|
|
84
|
+
/**
|
|
85
|
+
* Initialize the global provider registry with config.
|
|
86
|
+
* Should be called once during startup after loading SwarmConfig.
|
|
87
|
+
*
|
|
88
|
+
* @param providersConfig - Provider configurations from swarm config
|
|
89
|
+
* @param aliases - Custom model aliases from swarm config
|
|
90
|
+
* @returns The initialized registry
|
|
91
|
+
*/
|
|
92
|
+
export declare function initRegistry(providersConfig?: Record<string, ProviderConfig>, aliases?: Record<string, string>): ProviderRegistry;
|
|
93
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/core/providers/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,YAAY,CAAC;AASzE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAuC;IACxD,OAAO,CAAC,OAAO,CAA0C;IACzD,OAAO,CAAC,OAAO,CAAkD;IAEjE;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI;IAO5E;;OAEG;IACH,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI1D;;OAEG;IACH,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAI3D;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAoCnF;;;OAGG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAKjE;;OAEG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAIjD;;OAEG;IACH,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIpC;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAW3C;;;;;;OAMG;IACH,kBAAkB,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI;CA2B1E;AAMD;;GAEG;AACH,wBAAgB,WAAW,IAAI,gBAAgB,CAK9C;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,gBAAgB,CAYjI"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry that maps model strings (e.g. 'sonnet', 'openai/gpt-4o')
|
|
5
|
+
* to their backing LLM providers. Supports aliases, env var expansion,
|
|
6
|
+
* and lazy provider instantiation from config.
|
|
7
|
+
*/
|
|
8
|
+
/** Built-in shorthand aliases for common models */
|
|
9
|
+
const DEFAULT_ALIASES = {
|
|
10
|
+
'sonnet': 'anthropic/claude-sonnet-4',
|
|
11
|
+
'opus': 'anthropic/claude-opus-4',
|
|
12
|
+
'haiku': 'anthropic/claude-haiku-4-5',
|
|
13
|
+
};
|
|
14
|
+
export class ProviderRegistry {
|
|
15
|
+
providers = new Map();
|
|
16
|
+
configs = new Map();
|
|
17
|
+
aliases = { ...DEFAULT_ALIASES };
|
|
18
|
+
/**
|
|
19
|
+
* Register a provider instance.
|
|
20
|
+
* @param name - Provider name (e.g. 'openai', 'anthropic')
|
|
21
|
+
* @param provider - The LLMProvider implementation
|
|
22
|
+
* @param config - Optional config to store alongside the provider
|
|
23
|
+
*/
|
|
24
|
+
register(name, provider, config) {
|
|
25
|
+
this.providers.set(name, provider);
|
|
26
|
+
if (config) {
|
|
27
|
+
this.configs.set(name, config);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get a registered provider by name.
|
|
32
|
+
*/
|
|
33
|
+
getProvider(providerName) {
|
|
34
|
+
return this.providers.get(providerName);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get stored config for a provider.
|
|
38
|
+
*/
|
|
39
|
+
getConfig(providerName) {
|
|
40
|
+
return this.configs.get(providerName);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resolve a model string into its components.
|
|
44
|
+
*
|
|
45
|
+
* Resolution order:
|
|
46
|
+
* 1. Check aliases ('sonnet' → 'anthropic/claude-sonnet-4')
|
|
47
|
+
* 2. If contains '/', split on first '/' into provider/modelId
|
|
48
|
+
* 3. If no '/', try to infer provider from known model patterns
|
|
49
|
+
* 4. Fallback: treat as anthropic model (backward compat with existing 'sonnet'/'opus' usage)
|
|
50
|
+
*
|
|
51
|
+
* @param modelString - e.g. 'sonnet', 'openai/gpt-4o', 'anthropic/claude-sonnet-4'
|
|
52
|
+
* @returns Resolved provider, modelId, and fullId
|
|
53
|
+
*/
|
|
54
|
+
resolve(modelString) {
|
|
55
|
+
// Step 1: Check aliases
|
|
56
|
+
const aliased = this.aliases[modelString];
|
|
57
|
+
if (aliased) {
|
|
58
|
+
return this.resolve(aliased);
|
|
59
|
+
}
|
|
60
|
+
// Step 2: If contains '/', split into provider/modelId
|
|
61
|
+
const slashIdx = modelString.indexOf('/');
|
|
62
|
+
if (slashIdx > 0) {
|
|
63
|
+
const provider = modelString.slice(0, slashIdx);
|
|
64
|
+
const modelId = modelString.slice(slashIdx + 1);
|
|
65
|
+
return { provider, modelId, fullId: modelString };
|
|
66
|
+
}
|
|
67
|
+
// Step 3: Infer provider from known model patterns
|
|
68
|
+
if (modelString.startsWith('gpt-') || modelString.startsWith('o1') || modelString.startsWith('o3')) {
|
|
69
|
+
return { provider: 'openai', modelId: modelString, fullId: `openai/${modelString}` };
|
|
70
|
+
}
|
|
71
|
+
if (modelString.startsWith('gemini-')) {
|
|
72
|
+
return { provider: 'google', modelId: modelString, fullId: `google/${modelString}` };
|
|
73
|
+
}
|
|
74
|
+
if (modelString.startsWith('claude-')) {
|
|
75
|
+
return { provider: 'anthropic', modelId: modelString, fullId: `anthropic/${modelString}` };
|
|
76
|
+
}
|
|
77
|
+
if (modelString.startsWith('llama-') || modelString.startsWith('mixtral')) {
|
|
78
|
+
return { provider: 'groq', modelId: modelString, fullId: `groq/${modelString}` };
|
|
79
|
+
}
|
|
80
|
+
if (modelString.startsWith('deepseek-')) {
|
|
81
|
+
return { provider: 'deepseek', modelId: modelString, fullId: `deepseek/${modelString}` };
|
|
82
|
+
}
|
|
83
|
+
// Step 4: Fallback — assume anthropic (backward compatibility)
|
|
84
|
+
return { provider: 'anthropic', modelId: modelString, fullId: `anthropic/${modelString}` };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get the provider instance for a model string.
|
|
88
|
+
* Resolves the model, then looks up the provider.
|
|
89
|
+
*/
|
|
90
|
+
getProviderForModel(modelString) {
|
|
91
|
+
const { provider } = this.resolve(modelString);
|
|
92
|
+
return this.providers.get(provider);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* List all registered provider names.
|
|
96
|
+
*/
|
|
97
|
+
listProviders() {
|
|
98
|
+
return Array.from(this.providers.keys());
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Set custom aliases (merged with defaults).
|
|
102
|
+
*/
|
|
103
|
+
setAliases(aliases) {
|
|
104
|
+
this.aliases = { ...DEFAULT_ALIASES, ...aliases };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get all current aliases.
|
|
108
|
+
*/
|
|
109
|
+
getAliases() {
|
|
110
|
+
return { ...this.aliases };
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Expand environment variable references in a string.
|
|
114
|
+
* Replaces `${VAR_NAME}` with `process.env.VAR_NAME`.
|
|
115
|
+
* Returns the original value if the env var is not set.
|
|
116
|
+
*
|
|
117
|
+
* @param value - String potentially containing ${VAR_NAME} references
|
|
118
|
+
* @returns String with env vars expanded
|
|
119
|
+
*/
|
|
120
|
+
static expandEnvVars(value) {
|
|
121
|
+
return value.replace(/\$\{([^}]+)\}/g, (_match, varName) => {
|
|
122
|
+
const envValue = process.env[varName];
|
|
123
|
+
if (envValue !== undefined) {
|
|
124
|
+
return envValue;
|
|
125
|
+
}
|
|
126
|
+
// Return the original placeholder if env var not found
|
|
127
|
+
return _match;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Register provider configs from a config object.
|
|
132
|
+
* Does NOT instantiate providers — they are created lazily when first needed.
|
|
133
|
+
* Expands env var references in apiKey and baseUrl.
|
|
134
|
+
*
|
|
135
|
+
* @param providersConfig - Map of provider name → config
|
|
136
|
+
*/
|
|
137
|
+
registerFromConfig(providersConfig) {
|
|
138
|
+
for (const [name, rawConfig] of Object.entries(providersConfig)) {
|
|
139
|
+
const config = { ...rawConfig };
|
|
140
|
+
// Expand env vars in sensitive fields
|
|
141
|
+
if (config.apiKey) {
|
|
142
|
+
config.apiKey = ProviderRegistry.expandEnvVars(config.apiKey);
|
|
143
|
+
}
|
|
144
|
+
if (config.baseUrl) {
|
|
145
|
+
config.baseUrl = ProviderRegistry.expandEnvVars(config.baseUrl);
|
|
146
|
+
}
|
|
147
|
+
if (config.organization) {
|
|
148
|
+
config.organization = ProviderRegistry.expandEnvVars(config.organization);
|
|
149
|
+
}
|
|
150
|
+
// Expand env vars in custom headers
|
|
151
|
+
if (config.headers) {
|
|
152
|
+
const expandedHeaders = {};
|
|
153
|
+
for (const [key, val] of Object.entries(config.headers)) {
|
|
154
|
+
expandedHeaders[key] = ProviderRegistry.expandEnvVars(val);
|
|
155
|
+
}
|
|
156
|
+
config.headers = expandedHeaders;
|
|
157
|
+
}
|
|
158
|
+
this.configs.set(name, config);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// --- Singleton access ---
|
|
163
|
+
let _registry;
|
|
164
|
+
/**
|
|
165
|
+
* Get the global provider registry. Creates a default one if not initialized.
|
|
166
|
+
*/
|
|
167
|
+
export function getRegistry() {
|
|
168
|
+
if (!_registry) {
|
|
169
|
+
_registry = new ProviderRegistry();
|
|
170
|
+
}
|
|
171
|
+
return _registry;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Initialize the global provider registry with config.
|
|
175
|
+
* Should be called once during startup after loading SwarmConfig.
|
|
176
|
+
*
|
|
177
|
+
* @param providersConfig - Provider configurations from swarm config
|
|
178
|
+
* @param aliases - Custom model aliases from swarm config
|
|
179
|
+
* @returns The initialized registry
|
|
180
|
+
*/
|
|
181
|
+
export function initRegistry(providersConfig, aliases) {
|
|
182
|
+
_registry = new ProviderRegistry();
|
|
183
|
+
if (providersConfig) {
|
|
184
|
+
_registry.registerFromConfig(providersConfig);
|
|
185
|
+
}
|
|
186
|
+
if (aliases) {
|
|
187
|
+
_registry.setAliases(aliases);
|
|
188
|
+
}
|
|
189
|
+
return _registry;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/core/providers/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,mDAAmD;AACnD,MAAM,eAAe,GAA2B;IAC9C,QAAQ,EAAE,2BAA2B;IACrC,MAAM,EAAE,yBAAyB;IACjC,OAAO,EAAE,4BAA4B;CACtC,CAAC;AAEF,MAAM,OAAO,gBAAgB;IACnB,SAAS,GAA6B,IAAI,GAAG,EAAE,CAAC;IAChD,OAAO,GAAgC,IAAI,GAAG,EAAE,CAAC;IACjD,OAAO,GAA2B,EAAE,GAAG,eAAe,EAAE,CAAC;IAEjE;;;;;OAKG;IACH,QAAQ,CAAC,IAAY,EAAE,QAAqB,EAAE,MAAuB;QACnE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ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