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,695 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync, readdirSync, statSync, mkdirSync } from 'node:fs';
|
|
3
|
+
import { join, relative, dirname } from 'node:path';
|
|
4
|
+
import { requireSwarmDir, loadConfig } from '../core/config.js';
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// File scanning
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
const SCAN_EXTENSIONS = new Set(['.ts', '.js', '.py', '.go']);
|
|
9
|
+
const IGNORE_DIRS = new Set([
|
|
10
|
+
'node_modules', '.git', 'dist', 'build', '.swarm', 'coverage',
|
|
11
|
+
'.next', '.nuxt', '__pycache__', '.tox', 'vendor', '.cache',
|
|
12
|
+
]);
|
|
13
|
+
function scanFiles(rootDir) {
|
|
14
|
+
const files = [];
|
|
15
|
+
function walk(dir) {
|
|
16
|
+
let entries;
|
|
17
|
+
try {
|
|
18
|
+
entries = readdirSync(dir);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
for (const entry of entries) {
|
|
24
|
+
const fullPath = join(dir, entry);
|
|
25
|
+
let stat;
|
|
26
|
+
try {
|
|
27
|
+
stat = statSync(fullPath);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (stat.isDirectory()) {
|
|
33
|
+
if (!IGNORE_DIRS.has(entry)) {
|
|
34
|
+
walk(fullPath);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (stat.isFile()) {
|
|
38
|
+
const ext = entry.slice(entry.lastIndexOf('.'));
|
|
39
|
+
if (SCAN_EXTENSIONS.has(ext)) {
|
|
40
|
+
let content;
|
|
41
|
+
try {
|
|
42
|
+
content = readFileSync(fullPath, 'utf-8');
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const lines = content.split('\n').length;
|
|
48
|
+
const imports = extractImports(content, ext);
|
|
49
|
+
files.push({
|
|
50
|
+
path: fullPath,
|
|
51
|
+
relativePath: relative(rootDir, fullPath),
|
|
52
|
+
lines,
|
|
53
|
+
imports,
|
|
54
|
+
size: stat.size,
|
|
55
|
+
ext,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
walk(rootDir);
|
|
62
|
+
return files;
|
|
63
|
+
}
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
// Import extraction
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
function extractImports(content, ext) {
|
|
68
|
+
const imports = [];
|
|
69
|
+
if (ext === '.ts' || ext === '.js') {
|
|
70
|
+
// ES import
|
|
71
|
+
const esImportRe = /import\s+(?:.*?\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
72
|
+
let m;
|
|
73
|
+
while ((m = esImportRe.exec(content)) !== null) {
|
|
74
|
+
imports.push(m[1]);
|
|
75
|
+
}
|
|
76
|
+
// require()
|
|
77
|
+
const requireRe = /require\(['"]([^'"]+)['"]\)/g;
|
|
78
|
+
while ((m = requireRe.exec(content)) !== null) {
|
|
79
|
+
imports.push(m[1]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (ext === '.py') {
|
|
83
|
+
// Python imports
|
|
84
|
+
const pyImportRe = /^(?:from\s+(\S+)\s+import|import\s+(\S+))/gm;
|
|
85
|
+
let m;
|
|
86
|
+
while ((m = pyImportRe.exec(content)) !== null) {
|
|
87
|
+
imports.push(m[1] || m[2]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else if (ext === '.go') {
|
|
91
|
+
// Go imports
|
|
92
|
+
const goImportRe = /import\s+(?:"([^"]+)"|\(\s*([\s\S]*?)\s*\))/g;
|
|
93
|
+
let m;
|
|
94
|
+
while ((m = goImportRe.exec(content)) !== null) {
|
|
95
|
+
if (m[1]) {
|
|
96
|
+
imports.push(m[1]);
|
|
97
|
+
}
|
|
98
|
+
else if (m[2]) {
|
|
99
|
+
const block = m[2];
|
|
100
|
+
const lineRe = /"([^"]+)"/g;
|
|
101
|
+
let lm;
|
|
102
|
+
while ((lm = lineRe.exec(block)) !== null) {
|
|
103
|
+
imports.push(lm[1]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return imports;
|
|
109
|
+
}
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
// Resolve relative imports to file paths
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
function resolveImport(importPath, fromFile, rootDir, fileSet) {
|
|
114
|
+
// Only resolve relative imports
|
|
115
|
+
if (!importPath.startsWith('.'))
|
|
116
|
+
return null;
|
|
117
|
+
const fromDir = dirname(fromFile);
|
|
118
|
+
let resolved = join(fromDir, importPath);
|
|
119
|
+
// Strip .js extension that might reference .ts files
|
|
120
|
+
resolved = resolved.replace(/\.js$/, '');
|
|
121
|
+
// Try exact match, then with extensions
|
|
122
|
+
const candidates = [
|
|
123
|
+
resolved,
|
|
124
|
+
resolved + '.ts',
|
|
125
|
+
resolved + '.js',
|
|
126
|
+
resolved + '.py',
|
|
127
|
+
resolved + '.go',
|
|
128
|
+
join(resolved, 'index.ts'),
|
|
129
|
+
join(resolved, 'index.js'),
|
|
130
|
+
];
|
|
131
|
+
for (const c of candidates) {
|
|
132
|
+
const rel = relative(rootDir, c);
|
|
133
|
+
if (fileSet.has(rel))
|
|
134
|
+
return rel;
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
// Circular dependency detection (DFS)
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
function detectCircularDeps(files, rootDir) {
|
|
142
|
+
const fileSet = new Set(files.map(f => f.relativePath));
|
|
143
|
+
const adjList = new Map();
|
|
144
|
+
for (const file of files) {
|
|
145
|
+
const deps = [];
|
|
146
|
+
for (const imp of file.imports) {
|
|
147
|
+
const resolved = resolveImport(imp, file.path, rootDir, fileSet);
|
|
148
|
+
if (resolved)
|
|
149
|
+
deps.push(resolved);
|
|
150
|
+
}
|
|
151
|
+
adjList.set(file.relativePath, deps);
|
|
152
|
+
}
|
|
153
|
+
const cycles = [];
|
|
154
|
+
const visited = new Set();
|
|
155
|
+
const inStack = new Set();
|
|
156
|
+
const stack = [];
|
|
157
|
+
function dfs(node) {
|
|
158
|
+
if (inStack.has(node)) {
|
|
159
|
+
const cycleStart = stack.indexOf(node);
|
|
160
|
+
const cycle = stack.slice(cycleStart).concat(node);
|
|
161
|
+
cycles.push({ cycle, length: cycle.length - 1 });
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (visited.has(node))
|
|
165
|
+
return;
|
|
166
|
+
visited.add(node);
|
|
167
|
+
inStack.add(node);
|
|
168
|
+
stack.push(node);
|
|
169
|
+
for (const dep of adjList.get(node) || []) {
|
|
170
|
+
dfs(dep);
|
|
171
|
+
}
|
|
172
|
+
stack.pop();
|
|
173
|
+
inStack.delete(node);
|
|
174
|
+
}
|
|
175
|
+
for (const file of files) {
|
|
176
|
+
dfs(file.relativePath);
|
|
177
|
+
}
|
|
178
|
+
// Deduplicate cycles (normalize by smallest element first)
|
|
179
|
+
const seen = new Set();
|
|
180
|
+
return cycles.filter(c => {
|
|
181
|
+
const normalized = [...c.cycle.slice(0, -1)];
|
|
182
|
+
const minIdx = normalized.indexOf(normalized.reduce((a, b) => (a < b ? a : b)));
|
|
183
|
+
const key = [...normalized.slice(minIdx), ...normalized.slice(0, minIdx)].join(' -> ');
|
|
184
|
+
if (seen.has(key))
|
|
185
|
+
return false;
|
|
186
|
+
seen.add(key);
|
|
187
|
+
return true;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
// God module detection
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
function detectGodModules(files, rootDir, threshold = 10) {
|
|
194
|
+
const fileSet = new Set(files.map(f => f.relativePath));
|
|
195
|
+
const importedByCount = new Map();
|
|
196
|
+
for (const file of files) {
|
|
197
|
+
for (const imp of file.imports) {
|
|
198
|
+
const resolved = resolveImport(imp, file.path, rootDir, fileSet);
|
|
199
|
+
if (resolved) {
|
|
200
|
+
importedByCount.set(resolved, (importedByCount.get(resolved) || 0) + 1);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const gods = [];
|
|
205
|
+
for (const file of files) {
|
|
206
|
+
const outgoing = file.imports.filter(i => resolveImport(i, file.path, rootDir, fileSet)).length;
|
|
207
|
+
const incoming = importedByCount.get(file.relativePath) || 0;
|
|
208
|
+
const total = outgoing + incoming;
|
|
209
|
+
if (total >= threshold) {
|
|
210
|
+
gods.push({
|
|
211
|
+
file: file.relativePath,
|
|
212
|
+
importCount: outgoing,
|
|
213
|
+
importedBy: incoming,
|
|
214
|
+
totalConnections: total,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return gods.sort((a, b) => b.totalConnections - a.totalConnections);
|
|
219
|
+
}
|
|
220
|
+
// ---------------------------------------------------------------------------
|
|
221
|
+
// Complexity heuristics
|
|
222
|
+
// ---------------------------------------------------------------------------
|
|
223
|
+
function calculateComplexity(files) {
|
|
224
|
+
if (files.length === 0) {
|
|
225
|
+
return { score: 0, largeFiles: [], avgLines: 0, totalFiles: 0 };
|
|
226
|
+
}
|
|
227
|
+
const totalLines = files.reduce((sum, f) => sum + f.lines, 0);
|
|
228
|
+
const avgLines = Math.round(totalLines / files.length);
|
|
229
|
+
const largeFiles = files.filter(f => f.lines > 300).sort((a, b) => b.lines - a.lines);
|
|
230
|
+
// Score: 0-100 where higher = more complex/risky
|
|
231
|
+
let score = 0;
|
|
232
|
+
// Penalize large average file size
|
|
233
|
+
score += Math.min(30, Math.round((avgLines / 200) * 30));
|
|
234
|
+
// Penalize many large files
|
|
235
|
+
score += Math.min(30, Math.round((largeFiles.length / Math.max(files.length, 1)) * 100));
|
|
236
|
+
// Penalize high total file count (sprawl)
|
|
237
|
+
score += Math.min(20, Math.round((files.length / 500) * 20));
|
|
238
|
+
// Penalize deep nesting (files with many path segments)
|
|
239
|
+
const avgDepth = files.reduce((s, f) => s + f.relativePath.split('/').length, 0) / files.length;
|
|
240
|
+
score += Math.min(20, Math.round((avgDepth / 6) * 20));
|
|
241
|
+
return { score: Math.min(100, score), largeFiles: largeFiles.slice(0, 15), avgLines, totalFiles: files.length };
|
|
242
|
+
}
|
|
243
|
+
// ---------------------------------------------------------------------------
|
|
244
|
+
// Coupling score
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
function calculateCoupling(files, rootDir) {
|
|
247
|
+
if (files.length === 0)
|
|
248
|
+
return 0;
|
|
249
|
+
const fileSet = new Set(files.map(f => f.relativePath));
|
|
250
|
+
let totalEdges = 0;
|
|
251
|
+
for (const file of files) {
|
|
252
|
+
for (const imp of file.imports) {
|
|
253
|
+
if (resolveImport(imp, file.path, rootDir, fileSet)) {
|
|
254
|
+
totalEdges++;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Coupling density: edges / possible edges, scaled to 0-100
|
|
259
|
+
const possibleEdges = files.length * (files.length - 1);
|
|
260
|
+
if (possibleEdges === 0)
|
|
261
|
+
return 0;
|
|
262
|
+
const density = totalEdges / possibleEdges;
|
|
263
|
+
return Math.min(100, Math.round(density * 1000)); // Scale up for readability
|
|
264
|
+
}
|
|
265
|
+
// ---------------------------------------------------------------------------
|
|
266
|
+
// Growth pattern analysis
|
|
267
|
+
// ---------------------------------------------------------------------------
|
|
268
|
+
function analyzeGrowthPatterns(files) {
|
|
269
|
+
const trends = [];
|
|
270
|
+
// Analyze file size distribution
|
|
271
|
+
const sizes = files.map(f => f.lines).sort((a, b) => a - b);
|
|
272
|
+
const median = sizes[Math.floor(sizes.length / 2)] || 0;
|
|
273
|
+
const p90 = sizes[Math.floor(sizes.length * 0.9)] || 0;
|
|
274
|
+
const skew = p90 / Math.max(median, 1);
|
|
275
|
+
if (skew > 5) {
|
|
276
|
+
trends.push({
|
|
277
|
+
metric: 'File size distribution',
|
|
278
|
+
direction: 'degrading',
|
|
279
|
+
detail: `High skew (p90/median = ${skew.toFixed(1)}x) — a few files are disproportionately large`,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
else if (skew > 2) {
|
|
283
|
+
trends.push({
|
|
284
|
+
metric: 'File size distribution',
|
|
285
|
+
direction: 'stable',
|
|
286
|
+
detail: `Moderate skew (p90/median = ${skew.toFixed(1)}x) — acceptable distribution`,
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
trends.push({
|
|
291
|
+
metric: 'File size distribution',
|
|
292
|
+
direction: 'improving',
|
|
293
|
+
detail: `Low skew (p90/median = ${skew.toFixed(1)}x) — evenly distributed file sizes`,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
// Analyze import fan-out
|
|
297
|
+
const importCounts = files.map(f => f.imports.length).sort((a, b) => a - b);
|
|
298
|
+
const avgImports = importCounts.reduce((s, c) => s + c, 0) / Math.max(importCounts.length, 1);
|
|
299
|
+
const maxImports = importCounts[importCounts.length - 1] || 0;
|
|
300
|
+
if (maxImports > 20) {
|
|
301
|
+
trends.push({
|
|
302
|
+
metric: 'Import fan-out',
|
|
303
|
+
direction: 'degrading',
|
|
304
|
+
detail: `Max imports in a single file: ${maxImports} (avg: ${avgImports.toFixed(1)}) — high coupling risk`,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
else if (avgImports > 8) {
|
|
308
|
+
trends.push({
|
|
309
|
+
metric: 'Import fan-out',
|
|
310
|
+
direction: 'stable',
|
|
311
|
+
detail: `Average imports per file: ${avgImports.toFixed(1)} — monitor for growth`,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
trends.push({
|
|
316
|
+
metric: 'Import fan-out',
|
|
317
|
+
direction: 'improving',
|
|
318
|
+
detail: `Average imports per file: ${avgImports.toFixed(1)} — well-factored modules`,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
// Directory depth
|
|
322
|
+
const depths = files.map(f => f.relativePath.split('/').length);
|
|
323
|
+
const maxDepth = Math.max(...depths, 0);
|
|
324
|
+
if (maxDepth > 8) {
|
|
325
|
+
trends.push({
|
|
326
|
+
metric: 'Directory depth',
|
|
327
|
+
direction: 'degrading',
|
|
328
|
+
detail: `Max nesting depth: ${maxDepth} levels — consider flattening the structure`,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
trends.push({
|
|
333
|
+
metric: 'Directory depth',
|
|
334
|
+
direction: 'stable',
|
|
335
|
+
detail: `Max nesting depth: ${maxDepth} levels — reasonable project structure`,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
return trends;
|
|
339
|
+
}
|
|
340
|
+
// ---------------------------------------------------------------------------
|
|
341
|
+
// Focus-area specific analysis
|
|
342
|
+
// ---------------------------------------------------------------------------
|
|
343
|
+
function focusAnalysis(focus, files) {
|
|
344
|
+
const issues = [];
|
|
345
|
+
let idCounter = 1;
|
|
346
|
+
const makeId = () => `ARCH-${String(idCounter++).padStart(3, '0')}`;
|
|
347
|
+
if (!focus || focus === 'performance') {
|
|
348
|
+
// Check for large files that may cause slow builds / bundle sizes
|
|
349
|
+
const hugeFiles = files.filter(f => f.lines > 500);
|
|
350
|
+
if (hugeFiles.length > 0) {
|
|
351
|
+
issues.push({
|
|
352
|
+
id: makeId(),
|
|
353
|
+
title: 'Oversized source files detected',
|
|
354
|
+
severity: hugeFiles.some(f => f.lines > 1000) ? 'high' : 'medium',
|
|
355
|
+
category: 'performance',
|
|
356
|
+
evidence: hugeFiles.slice(0, 5).map(f => `${f.relativePath} (${f.lines} lines)`).join(', '),
|
|
357
|
+
impact: 'Large files slow IDE performance, increase build times, and make code review harder',
|
|
358
|
+
solutions: [
|
|
359
|
+
{ name: 'Split into modules', description: 'Break large files into focused, single-responsibility modules', effort: 'medium', risk: 'low', recommended: true },
|
|
360
|
+
{ name: 'Extract utilities', description: 'Move shared helpers to utility modules', effort: 'low', risk: 'low', recommended: false },
|
|
361
|
+
],
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (!focus || focus === 'scalability') {
|
|
366
|
+
// Check for single-directory bottleneck
|
|
367
|
+
const dirCounts = new Map();
|
|
368
|
+
for (const f of files) {
|
|
369
|
+
const dir = dirname(f.relativePath);
|
|
370
|
+
dirCounts.set(dir, (dirCounts.get(dir) || 0) + 1);
|
|
371
|
+
}
|
|
372
|
+
const bloatedDirs = [...dirCounts.entries()].filter(([, count]) => count > 20).sort((a, b) => b[1] - a[1]);
|
|
373
|
+
if (bloatedDirs.length > 0) {
|
|
374
|
+
issues.push({
|
|
375
|
+
id: makeId(),
|
|
376
|
+
title: 'Directory scalability bottleneck',
|
|
377
|
+
severity: bloatedDirs[0][1] > 40 ? 'high' : 'medium',
|
|
378
|
+
category: 'scalability',
|
|
379
|
+
evidence: bloatedDirs.slice(0, 5).map(([dir, count]) => `${dir}/ (${count} files)`).join(', '),
|
|
380
|
+
impact: 'Too many files in a single directory hinders navigation and increases merge conflicts',
|
|
381
|
+
solutions: [
|
|
382
|
+
{ name: 'Introduce sub-packages', description: 'Group related files into feature-based sub-directories', effort: 'medium', risk: 'medium', recommended: true },
|
|
383
|
+
{ name: 'Domain-driven structure', description: 'Reorganize by bounded contexts or feature domains', effort: 'high', risk: 'medium', recommended: false },
|
|
384
|
+
],
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (!focus || focus === 'maintainability') {
|
|
389
|
+
// Check for deeply nested files
|
|
390
|
+
const deepFiles = files.filter(f => f.relativePath.split('/').length > 6);
|
|
391
|
+
if (deepFiles.length > 0) {
|
|
392
|
+
issues.push({
|
|
393
|
+
id: makeId(),
|
|
394
|
+
title: 'Deeply nested file structure',
|
|
395
|
+
severity: 'medium',
|
|
396
|
+
category: 'maintainability',
|
|
397
|
+
evidence: deepFiles.slice(0, 5).map(f => f.relativePath).join(', '),
|
|
398
|
+
impact: 'Deep nesting makes navigation difficult and import paths excessively long',
|
|
399
|
+
solutions: [
|
|
400
|
+
{ name: 'Flatten structure', description: 'Reduce nesting by colocating related files', effort: 'medium', risk: 'low', recommended: true },
|
|
401
|
+
{ name: 'Use path aliases', description: 'Configure TypeScript/bundler path aliases for deep imports', effort: 'low', risk: 'low', recommended: false },
|
|
402
|
+
],
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
// Check for files with no imports (potential dead code)
|
|
406
|
+
const orphanFiles = files.filter(f => f.imports.length === 0 && f.lines > 10);
|
|
407
|
+
if (orphanFiles.length > 5) {
|
|
408
|
+
issues.push({
|
|
409
|
+
id: makeId(),
|
|
410
|
+
title: 'Potential dead code or isolated modules',
|
|
411
|
+
severity: 'low',
|
|
412
|
+
category: 'maintainability',
|
|
413
|
+
evidence: `${orphanFiles.length} files with zero imports: ${orphanFiles.slice(0, 5).map(f => f.relativePath).join(', ')}`,
|
|
414
|
+
impact: 'Isolated files may be dead code, increasing maintenance burden',
|
|
415
|
+
solutions: [
|
|
416
|
+
{ name: 'Audit for dead code', description: 'Review isolated files and remove unused code', effort: 'low', risk: 'low', recommended: true },
|
|
417
|
+
{ name: 'Add integration', description: 'Connect orphan modules to the rest of the codebase or document their standalone purpose', effort: 'low', risk: 'low', recommended: false },
|
|
418
|
+
],
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (!focus || focus === 'security') {
|
|
423
|
+
// Check for hardcoded secrets patterns
|
|
424
|
+
const secretPatterns = [
|
|
425
|
+
/(?:api[_-]?key|secret|password|token|credential)\s*[:=]\s*['"][^'"]{8,}['"]/i,
|
|
426
|
+
/(?:AKIA|AIza)[A-Za-z0-9]{12,}/,
|
|
427
|
+
];
|
|
428
|
+
const suspectFiles = [];
|
|
429
|
+
for (const file of files) {
|
|
430
|
+
try {
|
|
431
|
+
const content = readFileSync(file.path, 'utf-8');
|
|
432
|
+
for (const pattern of secretPatterns) {
|
|
433
|
+
if (pattern.test(content)) {
|
|
434
|
+
suspectFiles.push(file.relativePath);
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
catch {
|
|
440
|
+
// skip unreadable
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
if (suspectFiles.length > 0) {
|
|
444
|
+
issues.push({
|
|
445
|
+
id: makeId(),
|
|
446
|
+
title: 'Potential hardcoded secrets detected',
|
|
447
|
+
severity: 'critical',
|
|
448
|
+
category: 'security',
|
|
449
|
+
evidence: suspectFiles.slice(0, 10).join(', '),
|
|
450
|
+
impact: 'Hardcoded secrets can be leaked through version control, logs, or build artifacts',
|
|
451
|
+
solutions: [
|
|
452
|
+
{ name: 'Use environment variables', description: 'Move secrets to environment variables or a secrets manager', effort: 'low', risk: 'low', recommended: true },
|
|
453
|
+
{ name: 'Add secret scanning', description: 'Integrate a pre-commit secret scanner like gitleaks or trufflehog', effort: 'low', risk: 'low', recommended: true },
|
|
454
|
+
],
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return issues;
|
|
459
|
+
}
|
|
460
|
+
// ---------------------------------------------------------------------------
|
|
461
|
+
// Report generation
|
|
462
|
+
// ---------------------------------------------------------------------------
|
|
463
|
+
function generateMarkdown(data, focus) {
|
|
464
|
+
const lines = [];
|
|
465
|
+
lines.push('# Architecture Review Report');
|
|
466
|
+
lines.push('');
|
|
467
|
+
if (focus) {
|
|
468
|
+
lines.push(`> **Focus Area:** ${focus}`);
|
|
469
|
+
lines.push('');
|
|
470
|
+
}
|
|
471
|
+
lines.push(`> Generated: ${new Date(data.timestamp).toISOString()}`);
|
|
472
|
+
lines.push('');
|
|
473
|
+
// Summary
|
|
474
|
+
lines.push('## Summary');
|
|
475
|
+
lines.push('');
|
|
476
|
+
lines.push(data.summary);
|
|
477
|
+
lines.push('');
|
|
478
|
+
// Scores
|
|
479
|
+
lines.push('## Metrics');
|
|
480
|
+
lines.push('');
|
|
481
|
+
lines.push(`| Metric | Score |`);
|
|
482
|
+
lines.push(`|--------|-------|`);
|
|
483
|
+
lines.push(`| Coupling | ${data.couplingScore}/100 |`);
|
|
484
|
+
lines.push(`| Complexity | ${data.complexityScore}/100 |`);
|
|
485
|
+
lines.push('');
|
|
486
|
+
// Issues
|
|
487
|
+
if (data.issues.length > 0) {
|
|
488
|
+
lines.push('## Issues');
|
|
489
|
+
lines.push('');
|
|
490
|
+
for (const issue of data.issues) {
|
|
491
|
+
const severityColor = {
|
|
492
|
+
critical: '🔴', high: '🟠', medium: '🟡', low: '🟢',
|
|
493
|
+
};
|
|
494
|
+
lines.push(`### ${severityColor[issue.severity] || ''} ${issue.id}: ${issue.title}`);
|
|
495
|
+
lines.push('');
|
|
496
|
+
lines.push(`- **Severity:** ${issue.severity}`);
|
|
497
|
+
lines.push(`- **Category:** ${issue.category}`);
|
|
498
|
+
lines.push(`- **Evidence:** ${issue.evidence}`);
|
|
499
|
+
lines.push(`- **Impact:** ${issue.impact}`);
|
|
500
|
+
lines.push('');
|
|
501
|
+
if (issue.solutions.length > 0) {
|
|
502
|
+
lines.push('**Solutions:**');
|
|
503
|
+
lines.push('');
|
|
504
|
+
for (const sol of issue.solutions) {
|
|
505
|
+
const rec = sol.recommended ? ' *(recommended)*' : '';
|
|
506
|
+
lines.push(`- **${sol.name}**${rec}: ${sol.description} (effort: ${sol.effort}, risk: ${sol.risk})`);
|
|
507
|
+
}
|
|
508
|
+
lines.push('');
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
// Trends
|
|
513
|
+
if (data.trends.length > 0) {
|
|
514
|
+
lines.push('## Growth Patterns & Trends');
|
|
515
|
+
lines.push('');
|
|
516
|
+
const arrows = { improving: '↗', degrading: '↘', stable: '→' };
|
|
517
|
+
for (const trend of data.trends) {
|
|
518
|
+
lines.push(`- ${arrows[trend.direction] || '→'} **${trend.metric}** (${trend.direction}): ${trend.detail}`);
|
|
519
|
+
}
|
|
520
|
+
lines.push('');
|
|
521
|
+
}
|
|
522
|
+
// Action plan
|
|
523
|
+
if (data.actionPlan.length > 0) {
|
|
524
|
+
lines.push('## Action Plan');
|
|
525
|
+
lines.push('');
|
|
526
|
+
lines.push('| Priority | Action | Effort | Impact |');
|
|
527
|
+
lines.push('|----------|--------|--------|--------|');
|
|
528
|
+
for (const item of data.actionPlan) {
|
|
529
|
+
lines.push(`| ${item.priority} | ${item.action} | ${item.effort} | ${item.impact} |`);
|
|
530
|
+
}
|
|
531
|
+
lines.push('');
|
|
532
|
+
}
|
|
533
|
+
return lines.join('\n');
|
|
534
|
+
}
|
|
535
|
+
// ---------------------------------------------------------------------------
|
|
536
|
+
// Build action plan from issues
|
|
537
|
+
// ---------------------------------------------------------------------------
|
|
538
|
+
function buildActionPlan(issues) {
|
|
539
|
+
const severityWeight = { critical: 1, high: 2, medium: 3, low: 4 };
|
|
540
|
+
const sorted = [...issues].sort((a, b) => (severityWeight[a.severity] || 5) - (severityWeight[b.severity] || 5));
|
|
541
|
+
return sorted.map((issue, idx) => {
|
|
542
|
+
const recommended = issue.solutions.find(s => s.recommended);
|
|
543
|
+
return {
|
|
544
|
+
priority: idx + 1,
|
|
545
|
+
action: recommended ? `${issue.title} — ${recommended.name}` : issue.title,
|
|
546
|
+
effort: recommended?.effort || 'medium',
|
|
547
|
+
impact: issue.severity === 'critical' || issue.severity === 'high' ? 'high' : 'medium',
|
|
548
|
+
};
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
// ---------------------------------------------------------------------------
|
|
552
|
+
// Command registration
|
|
553
|
+
// ---------------------------------------------------------------------------
|
|
554
|
+
export function registerArchitectReview(program) {
|
|
555
|
+
program
|
|
556
|
+
.command('architect-review')
|
|
557
|
+
.description('Strategic architecture review — analyze coupling, complexity, circular deps, and growth patterns')
|
|
558
|
+
.option('-f, --focus <area>', 'Focus on a specific area: performance, scalability, maintainability, security')
|
|
559
|
+
.option('-d, --dir <path>', 'Project directory to scan (default: cwd)')
|
|
560
|
+
.option('-t, --threshold <n>', 'God-module connection threshold', '10')
|
|
561
|
+
.action(async (opts) => {
|
|
562
|
+
const swarmDir = requireSwarmDir();
|
|
563
|
+
const _config = loadConfig();
|
|
564
|
+
const projectDir = opts.dir ? join(process.cwd(), opts.dir) : process.cwd();
|
|
565
|
+
const focus = opts.focus;
|
|
566
|
+
const godThreshold = parseInt(opts.threshold, 10) || 10;
|
|
567
|
+
if (focus && !['performance', 'scalability', 'maintainability', 'security'].includes(focus)) {
|
|
568
|
+
console.error(chalk.red(`Invalid focus area: ${focus}. Choose from: performance, scalability, maintainability, security`));
|
|
569
|
+
process.exit(1);
|
|
570
|
+
}
|
|
571
|
+
console.log(chalk.bold('\nArchitecture Review'));
|
|
572
|
+
console.log(chalk.dim(`Scanning: ${projectDir}`));
|
|
573
|
+
if (focus)
|
|
574
|
+
console.log(chalk.dim(`Focus: ${focus}`));
|
|
575
|
+
console.log('');
|
|
576
|
+
// 1. Scan files
|
|
577
|
+
console.log(chalk.cyan('Scanning project files...'));
|
|
578
|
+
const files = scanFiles(projectDir);
|
|
579
|
+
console.log(chalk.dim(` Found ${files.length} source files`));
|
|
580
|
+
if (files.length === 0) {
|
|
581
|
+
console.log(chalk.yellow('No source files found. Nothing to review.'));
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
// 2. Detect circular dependencies
|
|
585
|
+
console.log(chalk.cyan('Detecting circular dependencies...'));
|
|
586
|
+
const circularDeps = detectCircularDeps(files, projectDir);
|
|
587
|
+
console.log(chalk.dim(` Found ${circularDeps.length} circular dependency cycle(s)`));
|
|
588
|
+
// 3. Detect god modules
|
|
589
|
+
console.log(chalk.cyan('Finding god modules...'));
|
|
590
|
+
const godModules = detectGodModules(files, projectDir, godThreshold);
|
|
591
|
+
console.log(chalk.dim(` Found ${godModules.length} god module(s) (threshold: ${godThreshold} connections)`));
|
|
592
|
+
// 4. Calculate complexity
|
|
593
|
+
console.log(chalk.cyan('Calculating complexity heuristics...'));
|
|
594
|
+
const complexity = calculateComplexity(files);
|
|
595
|
+
console.log(chalk.dim(` Complexity score: ${complexity.score}/100 | Avg lines: ${complexity.avgLines}`));
|
|
596
|
+
// 5. Calculate coupling
|
|
597
|
+
console.log(chalk.cyan('Calculating coupling score...'));
|
|
598
|
+
const couplingScore = calculateCoupling(files, projectDir);
|
|
599
|
+
console.log(chalk.dim(` Coupling score: ${couplingScore}/100`));
|
|
600
|
+
// 6. Analyze growth patterns
|
|
601
|
+
console.log(chalk.cyan('Analyzing growth patterns...'));
|
|
602
|
+
const trends = analyzeGrowthPatterns(files);
|
|
603
|
+
// 7. Build issues list
|
|
604
|
+
console.log(chalk.cyan('Compiling issues...'));
|
|
605
|
+
const issues = [];
|
|
606
|
+
// Circular dep issues
|
|
607
|
+
if (circularDeps.length > 0) {
|
|
608
|
+
issues.push({
|
|
609
|
+
id: 'ARCH-CYC',
|
|
610
|
+
title: 'Circular dependencies detected',
|
|
611
|
+
severity: circularDeps.length > 5 ? 'critical' : circularDeps.length > 2 ? 'high' : 'medium',
|
|
612
|
+
category: 'maintainability',
|
|
613
|
+
evidence: circularDeps.slice(0, 5).map(c => c.cycle.join(' -> ')).join('; '),
|
|
614
|
+
impact: 'Circular dependencies create tight coupling, make testing difficult, and can cause runtime initialization issues',
|
|
615
|
+
solutions: [
|
|
616
|
+
{ name: 'Dependency inversion', description: 'Introduce interfaces/abstractions to break the cycle', effort: 'medium', risk: 'low', recommended: true },
|
|
617
|
+
{ name: 'Extract shared module', description: 'Move shared code into a separate module that both sides depend on', effort: 'medium', risk: 'low', recommended: false },
|
|
618
|
+
{ name: 'Barrel file restructure', description: 'Reorganize barrel/index files to eliminate re-export cycles', effort: 'low', risk: 'low', recommended: false },
|
|
619
|
+
],
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
// God module issues
|
|
623
|
+
if (godModules.length > 0) {
|
|
624
|
+
issues.push({
|
|
625
|
+
id: 'ARCH-GOD',
|
|
626
|
+
title: 'God modules with excessive connections',
|
|
627
|
+
severity: godModules[0].totalConnections > 25 ? 'high' : 'medium',
|
|
628
|
+
category: 'scalability',
|
|
629
|
+
evidence: godModules.slice(0, 5).map(g => `${g.file} (${g.totalConnections} connections: ${g.importCount} out, ${g.importedBy} in)`).join('; '),
|
|
630
|
+
impact: 'God modules become bottlenecks for changes, slow builds, and increase merge conflict risk',
|
|
631
|
+
solutions: [
|
|
632
|
+
{ name: 'Decompose into focused modules', description: 'Split the module by responsibility into smaller, focused units', effort: 'high', risk: 'medium', recommended: true },
|
|
633
|
+
{ name: 'Introduce facade pattern', description: 'Keep the module as a thin facade delegating to smaller internal modules', effort: 'medium', risk: 'low', recommended: false },
|
|
634
|
+
],
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
// Focus-specific issues
|
|
638
|
+
const focusIssues = focusAnalysis(focus, files);
|
|
639
|
+
issues.push(...focusIssues);
|
|
640
|
+
// 8. Build action plan
|
|
641
|
+
const actionPlan = buildActionPlan(issues);
|
|
642
|
+
// 9. Build summary
|
|
643
|
+
const criticalCount = issues.filter(i => i.severity === 'critical').length;
|
|
644
|
+
const highCount = issues.filter(i => i.severity === 'high').length;
|
|
645
|
+
const summaryParts = [
|
|
646
|
+
`Scanned **${files.length}** files across the project.`,
|
|
647
|
+
`Found **${issues.length}** issue(s): ${criticalCount} critical, ${highCount} high, ${issues.length - criticalCount - highCount} medium/low.`,
|
|
648
|
+
`Coupling score: **${couplingScore}/100** | Complexity score: **${complexity.score}/100**.`,
|
|
649
|
+
circularDeps.length > 0
|
|
650
|
+
? `Detected **${circularDeps.length}** circular dependency cycle(s).`
|
|
651
|
+
: 'No circular dependencies detected.',
|
|
652
|
+
godModules.length > 0
|
|
653
|
+
? `Found **${godModules.length}** god module(s).`
|
|
654
|
+
: 'No god modules found.',
|
|
655
|
+
];
|
|
656
|
+
const data = {
|
|
657
|
+
summary: summaryParts.join(' '),
|
|
658
|
+
issues,
|
|
659
|
+
couplingScore,
|
|
660
|
+
complexityScore: complexity.score,
|
|
661
|
+
trends,
|
|
662
|
+
actionPlan,
|
|
663
|
+
timestamp: Date.now(),
|
|
664
|
+
};
|
|
665
|
+
// 10. Write outputs
|
|
666
|
+
const reportPath = join(projectDir, 'ARCHITECTURE-REVIEW.md');
|
|
667
|
+
const jsonPath = join(swarmDir, 'arch-review.json');
|
|
668
|
+
// Ensure .swarm dir exists
|
|
669
|
+
if (!existsSync(swarmDir)) {
|
|
670
|
+
mkdirSync(swarmDir, { recursive: true });
|
|
671
|
+
}
|
|
672
|
+
const markdown = generateMarkdown(data, focus);
|
|
673
|
+
writeFileSync(reportPath, markdown, 'utf-8');
|
|
674
|
+
writeFileSync(jsonPath, JSON.stringify(data, null, 2), 'utf-8');
|
|
675
|
+
console.log('');
|
|
676
|
+
console.log(chalk.green('Architecture review complete!'));
|
|
677
|
+
console.log('');
|
|
678
|
+
// Print summary
|
|
679
|
+
if (criticalCount > 0) {
|
|
680
|
+
console.log(chalk.red(` ${criticalCount} critical issue(s)`));
|
|
681
|
+
}
|
|
682
|
+
if (highCount > 0) {
|
|
683
|
+
console.log(chalk.yellow(` ${highCount} high-severity issue(s)`));
|
|
684
|
+
}
|
|
685
|
+
console.log(chalk.dim(` ${issues.length - criticalCount - highCount} medium/low issue(s)`));
|
|
686
|
+
console.log('');
|
|
687
|
+
console.log(chalk.dim(` Coupling: ${couplingScore}/100`));
|
|
688
|
+
console.log(chalk.dim(` Complexity: ${complexity.score}/100`));
|
|
689
|
+
console.log('');
|
|
690
|
+
console.log(` Report: ${chalk.underline(reportPath)}`);
|
|
691
|
+
console.log(` Data: ${chalk.underline(jsonPath)}`);
|
|
692
|
+
console.log('');
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
//# sourceMappingURL=architect-review.js.map
|