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,841 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync, readdirSync, statSync, appendFileSync } from 'node:fs';
|
|
3
|
+
import { join, relative, extname } from 'node:path';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { loadConfig, requireSwarmDir } from '../core/config.js';
|
|
6
|
+
import { createContext } from './shared.js';
|
|
7
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
8
|
+
function getDebtPath(swarmDir) {
|
|
9
|
+
return join(swarmDir, 'debt.json');
|
|
10
|
+
}
|
|
11
|
+
function getHistoryPath(swarmDir) {
|
|
12
|
+
return join(swarmDir, 'debt-history.jsonl');
|
|
13
|
+
}
|
|
14
|
+
function loadDebt(swarmDir) {
|
|
15
|
+
const p = getDebtPath(swarmDir);
|
|
16
|
+
if (!existsSync(p))
|
|
17
|
+
return null;
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(readFileSync(p, 'utf-8'));
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function saveDebt(swarmDir, snapshot) {
|
|
26
|
+
writeFileSync(getDebtPath(swarmDir), JSON.stringify(snapshot, null, 2));
|
|
27
|
+
}
|
|
28
|
+
function appendHistory(swarmDir, score, itemCount) {
|
|
29
|
+
const entry = { date: new Date().toISOString().slice(0, 10), score, items: itemCount, timestamp: Date.now() };
|
|
30
|
+
appendFileSync(getHistoryPath(swarmDir), JSON.stringify(entry) + '\n');
|
|
31
|
+
}
|
|
32
|
+
function loadHistory(swarmDir) {
|
|
33
|
+
const p = getHistoryPath(swarmDir);
|
|
34
|
+
if (!existsSync(p))
|
|
35
|
+
return [];
|
|
36
|
+
const lines = readFileSync(p, 'utf-8').trim().split('\n').filter(Boolean);
|
|
37
|
+
return lines.map((l) => JSON.parse(l));
|
|
38
|
+
}
|
|
39
|
+
/** Age in days since file was last modified. */
|
|
40
|
+
function fileDaysOld(filePath) {
|
|
41
|
+
try {
|
|
42
|
+
const stat = statSync(filePath);
|
|
43
|
+
return Math.floor((Date.now() - stat.mtimeMs) / (1000 * 60 * 60 * 24));
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Recursively collect files, respecting common ignore dirs. */
|
|
50
|
+
function walkDir(dir, ignoreDirs) {
|
|
51
|
+
const results = [];
|
|
52
|
+
let entries;
|
|
53
|
+
try {
|
|
54
|
+
entries = readdirSync(dir);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return results;
|
|
58
|
+
}
|
|
59
|
+
for (const entry of entries) {
|
|
60
|
+
if (ignoreDirs.has(entry))
|
|
61
|
+
continue;
|
|
62
|
+
const full = join(dir, entry);
|
|
63
|
+
try {
|
|
64
|
+
const st = statSync(full);
|
|
65
|
+
if (st.isDirectory()) {
|
|
66
|
+
results.push(...walkDir(full, ignoreDirs));
|
|
67
|
+
}
|
|
68
|
+
else if (st.isFile()) {
|
|
69
|
+
results.push(full);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// skip unreadable
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return results;
|
|
77
|
+
}
|
|
78
|
+
// ── Scanners ─────────────────────────────────────────────────────────────────
|
|
79
|
+
const IGNORE_DIRS = new Set([
|
|
80
|
+
'node_modules', '.git', 'dist', 'build', 'coverage', '.next', '.nuxt',
|
|
81
|
+
'.swarm', '__pycache__', '.tox', 'venv', '.venv', 'vendor', 'target',
|
|
82
|
+
]);
|
|
83
|
+
const SOURCE_EXTS = new Set(['.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.rs', '.swift', '.java', '.kt']);
|
|
84
|
+
function scanCodeQuality(cwd, files) {
|
|
85
|
+
const items = [];
|
|
86
|
+
const sourceFiles = files.filter((f) => SOURCE_EXTS.has(extname(f)));
|
|
87
|
+
for (const file of sourceFiles) {
|
|
88
|
+
let content;
|
|
89
|
+
try {
|
|
90
|
+
content = readFileSync(file, 'utf-8');
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const lines = content.split('\n');
|
|
96
|
+
const rel = relative(cwd, file);
|
|
97
|
+
const age = fileDaysOld(file);
|
|
98
|
+
// 1. Large files (> 300 lines)
|
|
99
|
+
if (lines.length > 300) {
|
|
100
|
+
items.push({
|
|
101
|
+
id: randomUUID().slice(0, 8),
|
|
102
|
+
type: 'code-quality',
|
|
103
|
+
severity: lines.length > 600 ? 4 : 3,
|
|
104
|
+
file: rel,
|
|
105
|
+
description: `File has ${lines.length} lines (threshold: 300). Consider splitting.`,
|
|
106
|
+
estimatedEffort: 'medium',
|
|
107
|
+
autoFixable: false,
|
|
108
|
+
age,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
// 2. Long functions (> 50 lines) — heuristic: function/def/func keyword to closing brace
|
|
112
|
+
const funcPattern = /^[ \t]*(export\s+)?(async\s+)?function\s+\w+|^[ \t]*(export\s+)?(const|let|var)\s+\w+\s*=\s*(async\s+)?\(|^[ \t]*def\s+\w+|^[ \t]*func\s+\w+/;
|
|
113
|
+
let funcStart = -1;
|
|
114
|
+
let funcName = '';
|
|
115
|
+
let braceDepth = 0;
|
|
116
|
+
for (let i = 0; i < lines.length; i++) {
|
|
117
|
+
const line = lines[i];
|
|
118
|
+
if (funcPattern.test(line) && funcStart === -1) {
|
|
119
|
+
funcStart = i;
|
|
120
|
+
funcName = (line.match(/(?:function|def|func|const|let|var)\s+(\w+)/) || [])[1] || 'anonymous';
|
|
121
|
+
braceDepth = 0;
|
|
122
|
+
}
|
|
123
|
+
if (funcStart !== -1) {
|
|
124
|
+
braceDepth += (line.match(/\{/g) || []).length;
|
|
125
|
+
braceDepth -= (line.match(/\}/g) || []).length;
|
|
126
|
+
if (braceDepth <= 0 && i > funcStart) {
|
|
127
|
+
const funcLen = i - funcStart + 1;
|
|
128
|
+
if (funcLen > 50) {
|
|
129
|
+
items.push({
|
|
130
|
+
id: randomUUID().slice(0, 8),
|
|
131
|
+
type: 'code-quality',
|
|
132
|
+
severity: funcLen > 100 ? 4 : 3,
|
|
133
|
+
file: rel,
|
|
134
|
+
description: `Function '${funcName}' is ${funcLen} lines (threshold: 50). Consider refactoring.`,
|
|
135
|
+
estimatedEffort: 'medium',
|
|
136
|
+
autoFixable: false,
|
|
137
|
+
age,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
funcStart = -1;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// 3. TODO/FIXME/HACK comments
|
|
145
|
+
for (let i = 0; i < lines.length; i++) {
|
|
146
|
+
const match = lines[i].match(/\b(TODO|FIXME|HACK|XXX)\b/);
|
|
147
|
+
if (match) {
|
|
148
|
+
items.push({
|
|
149
|
+
id: randomUUID().slice(0, 8),
|
|
150
|
+
type: 'code-quality',
|
|
151
|
+
severity: match[1] === 'HACK' ? 3 : 2,
|
|
152
|
+
file: rel,
|
|
153
|
+
description: `${match[1]} comment at line ${i + 1}: ${lines[i].trim().slice(0, 80)}`,
|
|
154
|
+
estimatedEffort: 'small',
|
|
155
|
+
autoFixable: false,
|
|
156
|
+
age,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// 4. TypeScript `any` types
|
|
161
|
+
if (extname(file) === '.ts' || extname(file) === '.tsx') {
|
|
162
|
+
for (let i = 0; i < lines.length; i++) {
|
|
163
|
+
// Match `: any`, `as any`, `<any>`, but not in comments
|
|
164
|
+
const line = lines[i];
|
|
165
|
+
if (line.trimStart().startsWith('//') || line.trimStart().startsWith('*'))
|
|
166
|
+
continue;
|
|
167
|
+
if (/:\s*any\b|as\s+any\b|<any>/.test(line)) {
|
|
168
|
+
items.push({
|
|
169
|
+
id: randomUUID().slice(0, 8),
|
|
170
|
+
type: 'code-quality',
|
|
171
|
+
severity: 2,
|
|
172
|
+
file: rel,
|
|
173
|
+
description: `Untyped 'any' at line ${i + 1}. Add proper types.`,
|
|
174
|
+
estimatedEffort: 'small',
|
|
175
|
+
autoFixable: true,
|
|
176
|
+
age,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// 5. Deep nesting (indentation > 4 levels)
|
|
182
|
+
let maxNesting = 0;
|
|
183
|
+
for (const line of lines) {
|
|
184
|
+
if (line.trim().length === 0)
|
|
185
|
+
continue;
|
|
186
|
+
const indent = line.match(/^(\s*)/)?.[1] || '';
|
|
187
|
+
const level = indent.includes('\t') ? indent.split('\t').length - 1 : Math.floor(indent.length / 2);
|
|
188
|
+
if (level > maxNesting)
|
|
189
|
+
maxNesting = level;
|
|
190
|
+
}
|
|
191
|
+
if (maxNesting > 8) {
|
|
192
|
+
items.push({
|
|
193
|
+
id: randomUUID().slice(0, 8),
|
|
194
|
+
type: 'code-quality',
|
|
195
|
+
severity: 3,
|
|
196
|
+
file: rel,
|
|
197
|
+
description: `Deep nesting detected (${maxNesting} levels). Consider early returns or extraction.`,
|
|
198
|
+
estimatedEffort: 'medium',
|
|
199
|
+
autoFixable: false,
|
|
200
|
+
age,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return items;
|
|
205
|
+
}
|
|
206
|
+
function scanDependencyDebt(cwd) {
|
|
207
|
+
const items = [];
|
|
208
|
+
const pkgPath = join(cwd, 'package.json');
|
|
209
|
+
if (!existsSync(pkgPath))
|
|
210
|
+
return items;
|
|
211
|
+
let pkg;
|
|
212
|
+
try {
|
|
213
|
+
pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return items;
|
|
217
|
+
}
|
|
218
|
+
const allDeps = {
|
|
219
|
+
...(pkg.dependencies || {}),
|
|
220
|
+
...(pkg.devDependencies || {}),
|
|
221
|
+
};
|
|
222
|
+
// Check for deprecated version patterns (e.g., very old pinned versions)
|
|
223
|
+
for (const [name, version] of Object.entries(allDeps)) {
|
|
224
|
+
if (typeof version !== 'string')
|
|
225
|
+
continue;
|
|
226
|
+
// Flag exact 0.x versions as potentially outdated
|
|
227
|
+
if (/^0\.\d+\.\d+$/.test(version)) {
|
|
228
|
+
items.push({
|
|
229
|
+
id: randomUUID().slice(0, 8),
|
|
230
|
+
type: 'dependency',
|
|
231
|
+
severity: 2,
|
|
232
|
+
file: 'package.json',
|
|
233
|
+
description: `Dependency '${name}@${version}' is pinned to a 0.x version. May be outdated.`,
|
|
234
|
+
estimatedEffort: 'small',
|
|
235
|
+
autoFixable: false,
|
|
236
|
+
age: fileDaysOld(pkgPath),
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
// Check for unused dependencies — heuristic: scan source for import references
|
|
241
|
+
const sourceFiles = walkDir(cwd, IGNORE_DIRS).filter((f) => SOURCE_EXTS.has(extname(f)));
|
|
242
|
+
const allSource = sourceFiles.map((f) => {
|
|
243
|
+
try {
|
|
244
|
+
return readFileSync(f, 'utf-8');
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return '';
|
|
248
|
+
}
|
|
249
|
+
}).join('\n');
|
|
250
|
+
const deps = pkg.dependencies || {};
|
|
251
|
+
for (const depName of Object.keys(deps)) {
|
|
252
|
+
// Skip @types/ packages and common implicit deps
|
|
253
|
+
if (depName.startsWith('@types/'))
|
|
254
|
+
continue;
|
|
255
|
+
// Check if dep name appears in any import/require statement
|
|
256
|
+
const escaped = depName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
257
|
+
const importPattern = new RegExp(`(?:from\\s+['"]${escaped}|require\\(['"]${escaped}|import\\s+['"]${escaped})`, 'm');
|
|
258
|
+
if (!importPattern.test(allSource)) {
|
|
259
|
+
items.push({
|
|
260
|
+
id: randomUUID().slice(0, 8),
|
|
261
|
+
type: 'dependency',
|
|
262
|
+
severity: 2,
|
|
263
|
+
file: 'package.json',
|
|
264
|
+
description: `Dependency '${depName}' may be unused — no import found in source files.`,
|
|
265
|
+
estimatedEffort: 'small',
|
|
266
|
+
autoFixable: false,
|
|
267
|
+
age: fileDaysOld(pkgPath),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return items;
|
|
272
|
+
}
|
|
273
|
+
function scanTestDebt(cwd, files) {
|
|
274
|
+
const items = [];
|
|
275
|
+
const sourceFiles = files.filter((f) => {
|
|
276
|
+
const ext = extname(f);
|
|
277
|
+
if (!SOURCE_EXTS.has(ext))
|
|
278
|
+
return false;
|
|
279
|
+
const rel = relative(cwd, f);
|
|
280
|
+
// Exclude test files themselves
|
|
281
|
+
if (/\.(test|spec|_test)\.[^.]+$/.test(rel))
|
|
282
|
+
return false;
|
|
283
|
+
if (/\b(test|tests|__tests__|__test__)\b/.test(rel))
|
|
284
|
+
return false;
|
|
285
|
+
return true;
|
|
286
|
+
});
|
|
287
|
+
const testFiles = new Set(files.filter((f) => /\.(test|spec|_test)\.[^.]+$/.test(f)).map((f) => relative(cwd, f)));
|
|
288
|
+
for (const file of sourceFiles) {
|
|
289
|
+
const rel = relative(cwd, file);
|
|
290
|
+
const base = rel.replace(/\.[^.]+$/, '');
|
|
291
|
+
const ext = extname(file);
|
|
292
|
+
// Check common test file naming patterns
|
|
293
|
+
const possibleTests = [
|
|
294
|
+
`${base}.test${ext}`,
|
|
295
|
+
`${base}.spec${ext}`,
|
|
296
|
+
`${base}_test${ext}`,
|
|
297
|
+
rel.replace(/^src\//, 'test/').replace(/\.[^.]+$/, `.test${ext}`),
|
|
298
|
+
rel.replace(/^src\//, '__tests__/').replace(/\.[^.]+$/, `.test${ext}`),
|
|
299
|
+
];
|
|
300
|
+
const hasTest = possibleTests.some((t) => testFiles.has(t));
|
|
301
|
+
if (!hasTest) {
|
|
302
|
+
items.push({
|
|
303
|
+
id: randomUUID().slice(0, 8),
|
|
304
|
+
type: 'test',
|
|
305
|
+
severity: 2,
|
|
306
|
+
file: rel,
|
|
307
|
+
description: `No test file found for '${rel}'.`,
|
|
308
|
+
estimatedEffort: 'medium',
|
|
309
|
+
autoFixable: false,
|
|
310
|
+
age: fileDaysOld(file),
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return items;
|
|
315
|
+
}
|
|
316
|
+
function scanDocumentationDebt(cwd, files) {
|
|
317
|
+
const items = [];
|
|
318
|
+
const tsFiles = files.filter((f) => extname(f) === '.ts' || extname(f) === '.tsx');
|
|
319
|
+
for (const file of tsFiles) {
|
|
320
|
+
let content;
|
|
321
|
+
try {
|
|
322
|
+
content = readFileSync(file, 'utf-8');
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
const rel = relative(cwd, file);
|
|
328
|
+
// Check for exported functions/classes without JSDoc
|
|
329
|
+
const exportedPattern = /^export\s+(async\s+)?function\s+(\w+)|^export\s+(class|interface)\s+(\w+)/gm;
|
|
330
|
+
let match;
|
|
331
|
+
let undocumentedExports = 0;
|
|
332
|
+
while ((match = exportedPattern.exec(content)) !== null) {
|
|
333
|
+
const pos = match.index;
|
|
334
|
+
// Look for JSDoc in the 3 lines before the export
|
|
335
|
+
const before = content.slice(Math.max(0, pos - 200), pos);
|
|
336
|
+
if (!before.includes('*/')) {
|
|
337
|
+
undocumentedExports++;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (undocumentedExports > 0) {
|
|
341
|
+
items.push({
|
|
342
|
+
id: randomUUID().slice(0, 8),
|
|
343
|
+
type: 'documentation',
|
|
344
|
+
severity: 1,
|
|
345
|
+
file: rel,
|
|
346
|
+
description: `${undocumentedExports} exported symbol(s) without JSDoc.`,
|
|
347
|
+
estimatedEffort: 'small',
|
|
348
|
+
autoFixable: true,
|
|
349
|
+
age: fileDaysOld(file),
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// Check for stale README
|
|
354
|
+
const readmePath = join(cwd, 'README.md');
|
|
355
|
+
if (existsSync(readmePath)) {
|
|
356
|
+
const readmeAge = fileDaysOld(readmePath);
|
|
357
|
+
if (readmeAge > 90) {
|
|
358
|
+
items.push({
|
|
359
|
+
id: randomUUID().slice(0, 8),
|
|
360
|
+
type: 'documentation',
|
|
361
|
+
severity: 2,
|
|
362
|
+
file: 'README.md',
|
|
363
|
+
description: `README.md is ${readmeAge} days old. May be stale.`,
|
|
364
|
+
estimatedEffort: 'small',
|
|
365
|
+
autoFixable: false,
|
|
366
|
+
age: readmeAge,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
items.push({
|
|
372
|
+
id: randomUUID().slice(0, 8),
|
|
373
|
+
type: 'documentation',
|
|
374
|
+
severity: 3,
|
|
375
|
+
file: 'README.md',
|
|
376
|
+
description: 'No README.md found in project root.',
|
|
377
|
+
estimatedEffort: 'small',
|
|
378
|
+
autoFixable: false,
|
|
379
|
+
age: 0,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
return items;
|
|
383
|
+
}
|
|
384
|
+
function scanArchitectureDebt(cwd, files) {
|
|
385
|
+
const items = [];
|
|
386
|
+
const sourceFiles = files.filter((f) => SOURCE_EXTS.has(extname(f)));
|
|
387
|
+
// Build import graph
|
|
388
|
+
const importCounts = new Map(); // file -> number of times imported by others
|
|
389
|
+
const importMap = new Map(); // file -> set of files it imports
|
|
390
|
+
for (const file of sourceFiles) {
|
|
391
|
+
let content;
|
|
392
|
+
try {
|
|
393
|
+
content = readFileSync(file, 'utf-8');
|
|
394
|
+
}
|
|
395
|
+
catch {
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
const rel = relative(cwd, file);
|
|
399
|
+
const imports = new Set();
|
|
400
|
+
// Match import/require statements
|
|
401
|
+
const importPattern = /(?:import\s+.*?from\s+['"]([^'"]+)['"]|require\(['"]([^'"]+)['"]\))/g;
|
|
402
|
+
let m;
|
|
403
|
+
while ((m = importPattern.exec(content)) !== null) {
|
|
404
|
+
const importPath = m[1] || m[2];
|
|
405
|
+
if (importPath.startsWith('.')) {
|
|
406
|
+
// Resolve relative import to a normalized path
|
|
407
|
+
const resolved = join(file, '..', importPath).replace(/\.[^.]*$/, '');
|
|
408
|
+
const resolvedRel = relative(cwd, resolved);
|
|
409
|
+
imports.add(resolvedRel);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
importMap.set(rel, imports);
|
|
413
|
+
}
|
|
414
|
+
// Count how many files import each file
|
|
415
|
+
for (const [, imports] of importMap) {
|
|
416
|
+
for (const imp of imports) {
|
|
417
|
+
importCounts.set(imp, (importCounts.get(imp) || 0) + 1);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
// God modules: files imported by many others (> 15 importers)
|
|
421
|
+
for (const [file, count] of importCounts) {
|
|
422
|
+
if (count > 15) {
|
|
423
|
+
items.push({
|
|
424
|
+
id: randomUUID().slice(0, 8),
|
|
425
|
+
type: 'architecture',
|
|
426
|
+
severity: count > 25 ? 4 : 3,
|
|
427
|
+
file,
|
|
428
|
+
description: `God module: imported by ${count} files. Consider splitting responsibilities.`,
|
|
429
|
+
estimatedEffort: 'large',
|
|
430
|
+
autoFixable: false,
|
|
431
|
+
age: 0,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
// Circular imports: detect A -> B -> A cycles
|
|
436
|
+
for (const [fileA, importsA] of importMap) {
|
|
437
|
+
for (const impB of importsA) {
|
|
438
|
+
const importsB = importMap.get(impB) || importMap.get(impB + '.ts') || importMap.get(impB + '.js');
|
|
439
|
+
if (importsB) {
|
|
440
|
+
const normalA = fileA.replace(/\.[^.]*$/, '');
|
|
441
|
+
if (importsB.has(normalA) || importsB.has(fileA)) {
|
|
442
|
+
items.push({
|
|
443
|
+
id: randomUUID().slice(0, 8),
|
|
444
|
+
type: 'architecture',
|
|
445
|
+
severity: 4,
|
|
446
|
+
file: fileA,
|
|
447
|
+
description: `Circular import detected: '${fileA}' <-> '${impB}'.`,
|
|
448
|
+
estimatedEffort: 'large',
|
|
449
|
+
autoFixable: false,
|
|
450
|
+
age: 0,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return items;
|
|
457
|
+
}
|
|
458
|
+
/** Calculate aggregate debt score (0 = no debt, 100 = critical). */
|
|
459
|
+
function calculateDebtScore(items) {
|
|
460
|
+
if (items.length === 0)
|
|
461
|
+
return 0;
|
|
462
|
+
const totalSeverity = items.reduce((sum, it) => sum + it.severity, 0);
|
|
463
|
+
// Normalize: score is based on total severity, capped at 100
|
|
464
|
+
const raw = Math.min(100, Math.round((totalSeverity / Math.max(items.length * 5, 1)) * 100 * (Math.log10(items.length + 1) / 2)));
|
|
465
|
+
return Math.min(100, Math.max(0, raw));
|
|
466
|
+
}
|
|
467
|
+
// ── Formatters ───────────────────────────────────────────────────────────────
|
|
468
|
+
function severityLabel(s) {
|
|
469
|
+
const labels = {
|
|
470
|
+
1: chalk.dim('low'),
|
|
471
|
+
2: chalk.blue('minor'),
|
|
472
|
+
3: chalk.yellow('moderate'),
|
|
473
|
+
4: chalk.red('high'),
|
|
474
|
+
5: chalk.bgRed.white(' critical '),
|
|
475
|
+
};
|
|
476
|
+
return labels[s] || chalk.dim('unknown');
|
|
477
|
+
}
|
|
478
|
+
function scoreGauge(score) {
|
|
479
|
+
const width = 30;
|
|
480
|
+
const filled = Math.round((score / 100) * width);
|
|
481
|
+
const empty = width - filled;
|
|
482
|
+
const color = score < 30 ? chalk.green : score < 60 ? chalk.yellow : chalk.red;
|
|
483
|
+
const bar = color('\u2588'.repeat(filled)) + chalk.dim('\u2591'.repeat(empty));
|
|
484
|
+
return `${bar} ${score}/100`;
|
|
485
|
+
}
|
|
486
|
+
function trendArrow(trend) {
|
|
487
|
+
if (trend === 'improving')
|
|
488
|
+
return chalk.green('\u2193 improving');
|
|
489
|
+
if (trend === 'degrading')
|
|
490
|
+
return chalk.red('\u2191 degrading');
|
|
491
|
+
return chalk.dim('\u2192 stable');
|
|
492
|
+
}
|
|
493
|
+
function determineTrend(history) {
|
|
494
|
+
if (history.length < 2)
|
|
495
|
+
return 'stable';
|
|
496
|
+
const recent = history.slice(-5);
|
|
497
|
+
const first = recent[0].score;
|
|
498
|
+
const last = recent[recent.length - 1].score;
|
|
499
|
+
const diff = last - first;
|
|
500
|
+
if (diff < -5)
|
|
501
|
+
return 'improving';
|
|
502
|
+
if (diff > 5)
|
|
503
|
+
return 'degrading';
|
|
504
|
+
return 'stable';
|
|
505
|
+
}
|
|
506
|
+
// ── Command Registration ─────────────────────────────────────────────────────
|
|
507
|
+
export function registerEvolve(program) {
|
|
508
|
+
const evolve = program
|
|
509
|
+
.command('evolve')
|
|
510
|
+
.description('Proactive tech debt management — scan, plan, fix, and track');
|
|
511
|
+
// ── swarm evolve scan ────────────────────────────────────────────────────
|
|
512
|
+
evolve
|
|
513
|
+
.command('scan')
|
|
514
|
+
.description('Analyze codebase for tech debt')
|
|
515
|
+
.option('--type <type>', 'Scan only a specific debt type (code-quality, dependency, test, documentation, architecture)')
|
|
516
|
+
.option('--json', 'Output raw JSON')
|
|
517
|
+
.action(async (opts) => {
|
|
518
|
+
const swarmDir = requireSwarmDir();
|
|
519
|
+
const cwd = process.cwd();
|
|
520
|
+
console.log(chalk.bold('\nScanning for tech debt...\n'));
|
|
521
|
+
const allFiles = walkDir(cwd, IGNORE_DIRS);
|
|
522
|
+
const items = [];
|
|
523
|
+
const types = opts.type ? [opts.type] : ['code-quality', 'dependency', 'test', 'documentation', 'architecture'];
|
|
524
|
+
if (types.includes('code-quality')) {
|
|
525
|
+
process.stdout.write(chalk.dim(' Checking code quality...'));
|
|
526
|
+
const found = scanCodeQuality(cwd, allFiles);
|
|
527
|
+
items.push(...found);
|
|
528
|
+
console.log(chalk.dim(` ${found.length} items`));
|
|
529
|
+
}
|
|
530
|
+
if (types.includes('dependency')) {
|
|
531
|
+
process.stdout.write(chalk.dim(' Checking dependencies...'));
|
|
532
|
+
const found = scanDependencyDebt(cwd);
|
|
533
|
+
items.push(...found);
|
|
534
|
+
console.log(chalk.dim(` ${found.length} items`));
|
|
535
|
+
}
|
|
536
|
+
if (types.includes('test')) {
|
|
537
|
+
process.stdout.write(chalk.dim(' Checking test coverage...'));
|
|
538
|
+
const found = scanTestDebt(cwd, allFiles);
|
|
539
|
+
items.push(...found);
|
|
540
|
+
console.log(chalk.dim(` ${found.length} items`));
|
|
541
|
+
}
|
|
542
|
+
if (types.includes('documentation')) {
|
|
543
|
+
process.stdout.write(chalk.dim(' Checking documentation...'));
|
|
544
|
+
const found = scanDocumentationDebt(cwd, allFiles);
|
|
545
|
+
items.push(...found);
|
|
546
|
+
console.log(chalk.dim(` ${found.length} items`));
|
|
547
|
+
}
|
|
548
|
+
if (types.includes('architecture')) {
|
|
549
|
+
process.stdout.write(chalk.dim(' Checking architecture...'));
|
|
550
|
+
const found = scanArchitectureDebt(cwd, allFiles);
|
|
551
|
+
items.push(...found);
|
|
552
|
+
console.log(chalk.dim(` ${found.length} items`));
|
|
553
|
+
}
|
|
554
|
+
const score = calculateDebtScore(items);
|
|
555
|
+
const history = loadHistory(swarmDir);
|
|
556
|
+
const trend = determineTrend(history);
|
|
557
|
+
// Save snapshot
|
|
558
|
+
const snapshot = { scannedAt: Date.now(), score, items };
|
|
559
|
+
saveDebt(swarmDir, snapshot);
|
|
560
|
+
appendHistory(swarmDir, score, items.length);
|
|
561
|
+
if (opts.json) {
|
|
562
|
+
const data = {
|
|
563
|
+
score,
|
|
564
|
+
trend,
|
|
565
|
+
items: items.map((it) => ({
|
|
566
|
+
id: it.id,
|
|
567
|
+
type: it.type,
|
|
568
|
+
severity: it.severity,
|
|
569
|
+
file: it.file,
|
|
570
|
+
description: it.description,
|
|
571
|
+
estimatedEffort: it.estimatedEffort,
|
|
572
|
+
autoFixable: it.autoFixable,
|
|
573
|
+
age: it.age,
|
|
574
|
+
})),
|
|
575
|
+
burndown: history.slice(-30).map((h) => ({ date: h.date, score: h.score })),
|
|
576
|
+
byType: Object.entries(items.reduce((acc, it) => {
|
|
577
|
+
if (!acc[it.type])
|
|
578
|
+
acc[it.type] = { count: 0, totalSeverity: 0 };
|
|
579
|
+
acc[it.type].count++;
|
|
580
|
+
acc[it.type].totalSeverity += it.severity;
|
|
581
|
+
return acc;
|
|
582
|
+
}, {})).map(([type, data]) => ({ type, ...data })),
|
|
583
|
+
};
|
|
584
|
+
console.log(JSON.stringify(data, null, 2));
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
// Display results
|
|
588
|
+
console.log(`\n${chalk.bold('Debt Score:')} ${scoreGauge(score)} ${trendArrow(trend)}`);
|
|
589
|
+
console.log(`${chalk.bold('Total Items:')} ${items.length}\n`);
|
|
590
|
+
// Group by type
|
|
591
|
+
const byType = new Map();
|
|
592
|
+
for (const item of items) {
|
|
593
|
+
const arr = byType.get(item.type) || [];
|
|
594
|
+
arr.push(item);
|
|
595
|
+
byType.set(item.type, arr);
|
|
596
|
+
}
|
|
597
|
+
for (const [type, typeItems] of byType) {
|
|
598
|
+
const typeSeverity = typeItems.reduce((s, it) => s + it.severity, 0);
|
|
599
|
+
console.log(chalk.bold(` ${type} (${typeItems.length} items, severity: ${typeSeverity})`));
|
|
600
|
+
// Show top 5 highest severity
|
|
601
|
+
const sorted = [...typeItems].sort((a, b) => b.severity - a.severity).slice(0, 5);
|
|
602
|
+
for (const item of sorted) {
|
|
603
|
+
const fixable = item.autoFixable ? chalk.green(' [auto-fixable]') : '';
|
|
604
|
+
console.log(` ${severityLabel(item.severity)} ${chalk.dim(item.file)} — ${item.description}${fixable}`);
|
|
605
|
+
}
|
|
606
|
+
if (typeItems.length > 5) {
|
|
607
|
+
console.log(chalk.dim(` ... and ${typeItems.length - 5} more`));
|
|
608
|
+
}
|
|
609
|
+
console.log();
|
|
610
|
+
}
|
|
611
|
+
const autoFixable = items.filter((it) => it.autoFixable).length;
|
|
612
|
+
if (autoFixable > 0) {
|
|
613
|
+
console.log(chalk.green(` ${autoFixable} items are auto-fixable. Run ${chalk.bold('hivemind evolve work')} to fix them.\n`));
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
// ── swarm evolve plan ────────────────────────────────────────────────────
|
|
617
|
+
evolve
|
|
618
|
+
.command('plan')
|
|
619
|
+
.description('Generate a debt reduction roadmap')
|
|
620
|
+
.option('--target <score>', 'Target debt score (default: 20)', '20')
|
|
621
|
+
.action(async (opts) => {
|
|
622
|
+
const swarmDir = requireSwarmDir();
|
|
623
|
+
const debt = loadDebt(swarmDir);
|
|
624
|
+
if (!debt) {
|
|
625
|
+
console.log(chalk.yellow('No debt data found. Run `hivemind evolve scan` first.'));
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
const targetScore = parseInt(opts.target, 10);
|
|
629
|
+
const items = [...debt.items].sort((a, b) => b.severity - a.severity);
|
|
630
|
+
console.log(chalk.bold('\nDebt Reduction Roadmap\n'));
|
|
631
|
+
console.log(` Current score: ${scoreGauge(debt.score)}`);
|
|
632
|
+
console.log(` Target score: ${targetScore}\n`);
|
|
633
|
+
// Phase 1: Quick wins (auto-fixable, severity >= 2)
|
|
634
|
+
const quickWins = items.filter((it) => it.autoFixable && it.severity >= 2);
|
|
635
|
+
// Phase 2: High severity manual items
|
|
636
|
+
const highSeverity = items.filter((it) => !it.autoFixable && it.severity >= 4);
|
|
637
|
+
// Phase 3: Medium severity
|
|
638
|
+
const medium = items.filter((it) => !it.autoFixable && it.severity === 3);
|
|
639
|
+
// Phase 4: Low severity cleanup
|
|
640
|
+
const low = items.filter((it) => !it.autoFixable && it.severity <= 2);
|
|
641
|
+
const phases = [
|
|
642
|
+
{ name: 'Quick Wins (auto-fixable)', items: quickWins, effort: 'hours' },
|
|
643
|
+
{ name: 'Critical Fixes (severity 4-5)', items: highSeverity, effort: 'days' },
|
|
644
|
+
{ name: 'Moderate Improvements (severity 3)', items: medium, effort: '1-2 weeks' },
|
|
645
|
+
{ name: 'Cleanup (severity 1-2)', items: low, effort: '2-4 weeks' },
|
|
646
|
+
];
|
|
647
|
+
let phaseNum = 1;
|
|
648
|
+
for (const phase of phases) {
|
|
649
|
+
if (phase.items.length === 0)
|
|
650
|
+
continue;
|
|
651
|
+
const phaseSeverity = phase.items.reduce((s, it) => s + it.severity, 0);
|
|
652
|
+
console.log(chalk.bold(` Phase ${phaseNum}: ${phase.name}`));
|
|
653
|
+
console.log(chalk.dim(` Estimated effort: ${phase.effort} | ${phase.items.length} items | Combined severity: ${phaseSeverity}`));
|
|
654
|
+
const typeBreakdown = new Map();
|
|
655
|
+
for (const it of phase.items) {
|
|
656
|
+
typeBreakdown.set(it.type, (typeBreakdown.get(it.type) || 0) + 1);
|
|
657
|
+
}
|
|
658
|
+
for (const [type, count] of typeBreakdown) {
|
|
659
|
+
console.log(chalk.dim(` - ${type}: ${count} items`));
|
|
660
|
+
}
|
|
661
|
+
// Show top 3 items
|
|
662
|
+
for (const it of phase.items.slice(0, 3)) {
|
|
663
|
+
console.log(` ${severityLabel(it.severity)} ${chalk.dim(it.file)} — ${it.description}`);
|
|
664
|
+
}
|
|
665
|
+
if (phase.items.length > 3) {
|
|
666
|
+
console.log(chalk.dim(` ... and ${phase.items.length - 3} more`));
|
|
667
|
+
}
|
|
668
|
+
console.log();
|
|
669
|
+
phaseNum++;
|
|
670
|
+
}
|
|
671
|
+
console.log(chalk.dim(` Tip: Run ${chalk.bold('hivemind evolve work')} to start fixing auto-fixable items.\n`));
|
|
672
|
+
});
|
|
673
|
+
// ── swarm evolve work ────────────────────────────────────────────────────
|
|
674
|
+
evolve
|
|
675
|
+
.command('work')
|
|
676
|
+
.description('Fix highest-priority auto-fixable debt items')
|
|
677
|
+
.option('-n, --count <n>', 'Max items to fix', '10')
|
|
678
|
+
.option('-m, --model <model>', 'Model override (e.g., sonnet, openai/gpt-4o, ollama/llama3)')
|
|
679
|
+
.option('-b, --budget <amount>', 'Max budget in USD', '5')
|
|
680
|
+
.action(async (opts) => {
|
|
681
|
+
const swarmDir = requireSwarmDir();
|
|
682
|
+
const config = loadConfig();
|
|
683
|
+
config.model = opts.model || config.model;
|
|
684
|
+
if (opts.budget) {
|
|
685
|
+
config.maxBudgetUsd = opts.budget === 'none' ? null : (parseFloat(opts.budget) || 5);
|
|
686
|
+
}
|
|
687
|
+
const debt = loadDebt(swarmDir);
|
|
688
|
+
if (!debt) {
|
|
689
|
+
console.log(chalk.yellow('No debt data found. Run `hivemind evolve scan` first.'));
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
const maxItems = parseInt(opts.count, 10);
|
|
693
|
+
const fixableItems = debt.items
|
|
694
|
+
.filter((it) => it.autoFixable)
|
|
695
|
+
.sort((a, b) => b.severity - a.severity)
|
|
696
|
+
.slice(0, maxItems);
|
|
697
|
+
if (fixableItems.length === 0) {
|
|
698
|
+
console.log(chalk.yellow('No auto-fixable debt items found.'));
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
console.log(chalk.bold(`\nFixing ${fixableItems.length} auto-fixable debt items...\n`));
|
|
702
|
+
const { agentManager, cleanup } = createContext(swarmDir, config);
|
|
703
|
+
try {
|
|
704
|
+
// Build a prompt describing all items to fix
|
|
705
|
+
const itemDescriptions = fixableItems.map((it, i) => `${i + 1}. [${it.type}] ${it.file}: ${it.description}`).join('\n');
|
|
706
|
+
const prompt = `You are a tech debt reduction agent. Fix the following auto-fixable issues in the codebase.
|
|
707
|
+
For each item, make the minimal change needed. Do NOT refactor unrelated code.
|
|
708
|
+
|
|
709
|
+
Items to fix:
|
|
710
|
+
${itemDescriptions}
|
|
711
|
+
|
|
712
|
+
Rules:
|
|
713
|
+
- For 'any' types: replace with proper TypeScript types based on usage context.
|
|
714
|
+
- For missing JSDoc: add concise JSDoc comments to exported functions/classes.
|
|
715
|
+
- Keep changes minimal and focused on the specific debt item.
|
|
716
|
+
- Do not introduce new dependencies.
|
|
717
|
+
|
|
718
|
+
After fixing, briefly summarize what you changed.`;
|
|
719
|
+
const agentObj = await agentManager.spawn({
|
|
720
|
+
name: 'debt-fixer',
|
|
721
|
+
persona: 'engineer',
|
|
722
|
+
stack: config.stack,
|
|
723
|
+
prompt,
|
|
724
|
+
model: config.model,
|
|
725
|
+
permissionMode: 'acceptEdits',
|
|
726
|
+
cwd: process.cwd(),
|
|
727
|
+
interactive: false,
|
|
728
|
+
});
|
|
729
|
+
console.log(chalk.dim(` Agent spawned: ${agentObj.id}`));
|
|
730
|
+
console.log(chalk.dim(' Waiting for agent to complete...\n'));
|
|
731
|
+
await agentManager.waitForAgent(agentObj.id);
|
|
732
|
+
const agent = agentManager.getAgent(agentObj.id);
|
|
733
|
+
if (agent) {
|
|
734
|
+
if (agent.status === 'done') {
|
|
735
|
+
console.log(chalk.green('\n Agent completed successfully.'));
|
|
736
|
+
// Print last part of output as summary
|
|
737
|
+
const output = agent.output.trim();
|
|
738
|
+
const lastLines = output.split('\n').slice(-20).join('\n');
|
|
739
|
+
if (lastLines) {
|
|
740
|
+
console.log(chalk.dim('\n Summary:'));
|
|
741
|
+
console.log(chalk.dim(` ${lastLines.split('\n').join('\n ')}`));
|
|
742
|
+
}
|
|
743
|
+
console.log(chalk.dim(`\n Cost: $${agent.cost.totalUsd.toFixed(4)}`));
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
console.log(chalk.red(`\n Agent finished with status: ${agent.status}`));
|
|
747
|
+
if (agent.error)
|
|
748
|
+
console.log(chalk.red(` Error: ${agent.error}`));
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
console.log(chalk.dim(`\n Run ${chalk.bold('hivemind evolve scan')} to measure improvement.\n`));
|
|
752
|
+
}
|
|
753
|
+
finally {
|
|
754
|
+
cleanup();
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
// ── swarm evolve report ──────────────────────────────────────────────────
|
|
758
|
+
evolve
|
|
759
|
+
.command('report')
|
|
760
|
+
.description('Tech debt trend report')
|
|
761
|
+
.option('--json', 'Output raw JSON')
|
|
762
|
+
.action(async (opts) => {
|
|
763
|
+
const swarmDir = requireSwarmDir();
|
|
764
|
+
const debt = loadDebt(swarmDir);
|
|
765
|
+
const history = loadHistory(swarmDir);
|
|
766
|
+
if (!debt) {
|
|
767
|
+
console.log(chalk.yellow('No debt data found. Run `hivemind evolve scan` first.'));
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
const trend = determineTrend(history);
|
|
771
|
+
if (opts.json) {
|
|
772
|
+
const data = {
|
|
773
|
+
score: debt.score,
|
|
774
|
+
trend,
|
|
775
|
+
items: debt.items,
|
|
776
|
+
burndown: history.slice(-30).map((h) => ({ date: h.date, score: h.score })),
|
|
777
|
+
byType: Object.entries(debt.items.reduce((acc, it) => {
|
|
778
|
+
if (!acc[it.type])
|
|
779
|
+
acc[it.type] = { count: 0, totalSeverity: 0 };
|
|
780
|
+
acc[it.type].count++;
|
|
781
|
+
acc[it.type].totalSeverity += it.severity;
|
|
782
|
+
return acc;
|
|
783
|
+
}, {})).map(([type, data]) => ({ type, ...data })),
|
|
784
|
+
};
|
|
785
|
+
console.log(JSON.stringify(data, null, 2));
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
// Display report
|
|
789
|
+
console.log(chalk.bold('\nTech Debt Report\n'));
|
|
790
|
+
console.log(` ${chalk.bold('Debt Score:')} ${scoreGauge(debt.score)} ${trendArrow(trend)}`);
|
|
791
|
+
console.log(` ${chalk.bold('Total Items:')} ${debt.items.length}`);
|
|
792
|
+
console.log(` ${chalk.bold('Auto-fixable:')} ${debt.items.filter((it) => it.autoFixable).length}`);
|
|
793
|
+
console.log(` ${chalk.bold('Last Scan:')} ${new Date(debt.scannedAt).toLocaleString()}`);
|
|
794
|
+
// Items by type
|
|
795
|
+
console.log(chalk.bold('\n By Type:'));
|
|
796
|
+
const byType = new Map();
|
|
797
|
+
for (const item of debt.items) {
|
|
798
|
+
const entry = byType.get(item.type) || { count: 0, severity: 0 };
|
|
799
|
+
entry.count++;
|
|
800
|
+
entry.severity += item.severity;
|
|
801
|
+
byType.set(item.type, entry);
|
|
802
|
+
}
|
|
803
|
+
for (const [type, data] of [...byType.entries()].sort((a, b) => b[1].severity - a[1].severity)) {
|
|
804
|
+
const bar = chalk.red('\u2588'.repeat(Math.min(20, data.count)));
|
|
805
|
+
console.log(` ${type.padEnd(18)} ${String(data.count).padStart(4)} items severity: ${data.severity} ${bar}`);
|
|
806
|
+
}
|
|
807
|
+
// Burndown trend
|
|
808
|
+
if (history.length > 1) {
|
|
809
|
+
console.log(chalk.bold('\n Burndown (last 15 scans):'));
|
|
810
|
+
const recent = history.slice(-15);
|
|
811
|
+
const maxScore = Math.max(...recent.map((h) => h.score), 1);
|
|
812
|
+
for (const entry of recent) {
|
|
813
|
+
const barLen = Math.round((entry.score / maxScore) * 30);
|
|
814
|
+
const color = entry.score < 30 ? chalk.green : entry.score < 60 ? chalk.yellow : chalk.red;
|
|
815
|
+
console.log(` ${entry.date} ${color('\u2588'.repeat(barLen))}${chalk.dim('\u2591'.repeat(30 - barLen))} ${entry.score}`);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
// Severity distribution
|
|
819
|
+
console.log(chalk.bold('\n Severity Distribution:'));
|
|
820
|
+
for (let sev = 5; sev >= 1; sev--) {
|
|
821
|
+
const count = debt.items.filter((it) => it.severity === sev).length;
|
|
822
|
+
if (count > 0) {
|
|
823
|
+
console.log(` ${severityLabel(sev).padEnd(20)} ${count} items`);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
// Top 10 worst files
|
|
827
|
+
const fileScores = new Map();
|
|
828
|
+
for (const item of debt.items) {
|
|
829
|
+
fileScores.set(item.file, (fileScores.get(item.file) || 0) + item.severity);
|
|
830
|
+
}
|
|
831
|
+
const worstFiles = [...fileScores.entries()].sort((a, b) => b[1] - a[1]).slice(0, 10);
|
|
832
|
+
if (worstFiles.length > 0) {
|
|
833
|
+
console.log(chalk.bold('\n Hotspots (top 10 worst files):'));
|
|
834
|
+
for (const [file, score] of worstFiles) {
|
|
835
|
+
console.log(` ${chalk.dim(file.padEnd(50))} severity: ${score}`);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
console.log();
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
//# sourceMappingURL=evolve.js.map
|