@monoes/cli 1.0.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.
Files changed (1262) hide show
  1. package/.claude/agents/analysis/analyze-code-quality.md +179 -0
  2. package/.claude/agents/analysis/code-analyzer.md +210 -0
  3. package/.claude/agents/analysis/code-review/analyze-code-quality.md +179 -0
  4. package/.claude/agents/architecture/arch-system-design.md +157 -0
  5. package/.claude/agents/architecture/system-design/arch-system-design.md +155 -0
  6. package/.claude/agents/browser/browser-agent.yaml +182 -0
  7. package/.claude/agents/consensus/byzantine-coordinator.md +63 -0
  8. package/.claude/agents/consensus/crdt-synchronizer.md +997 -0
  9. package/.claude/agents/consensus/gossip-coordinator.md +63 -0
  10. package/.claude/agents/consensus/performance-benchmarker.md +851 -0
  11. package/.claude/agents/consensus/quorum-manager.md +823 -0
  12. package/.claude/agents/consensus/raft-manager.md +63 -0
  13. package/.claude/agents/consensus/security-manager.md +622 -0
  14. package/.claude/agents/core/coder.md +470 -0
  15. package/.claude/agents/core/planner.md +393 -0
  16. package/.claude/agents/core/researcher.md +393 -0
  17. package/.claude/agents/core/reviewer.md +535 -0
  18. package/.claude/agents/core/tester.md +527 -0
  19. package/.claude/agents/custom/test-long-runner.md +44 -0
  20. package/.claude/agents/data/data-ml-model.md +459 -0
  21. package/.claude/agents/data/ml/data-ml-model.md +193 -0
  22. package/.claude/agents/development/backend/dev-backend-api.md +142 -0
  23. package/.claude/agents/development/dev-backend-api.md +354 -0
  24. package/.claude/agents/devops/ci-cd/ops-cicd-github.md +164 -0
  25. package/.claude/agents/devops/ops-cicd-github.md +165 -0
  26. package/.claude/agents/documentation/api-docs/docs-api-openapi.md +174 -0
  27. package/.claude/agents/documentation/docs-api-openapi.md +362 -0
  28. package/.claude/agents/github/code-review-swarm.md +385 -0
  29. package/.claude/agents/github/github-modes.md +173 -0
  30. package/.claude/agents/github/issue-tracker.md +616 -0
  31. package/.claude/agents/github/multi-repo-swarm.md +553 -0
  32. package/.claude/agents/github/pr-manager.md +455 -0
  33. package/.claude/agents/github/project-board-sync.md +509 -0
  34. package/.claude/agents/github/release-manager.md +638 -0
  35. package/.claude/agents/github/release-swarm.md +629 -0
  36. package/.claude/agents/github/repo-architect.md +411 -0
  37. package/.claude/agents/github/swarm-issue.md +573 -0
  38. package/.claude/agents/github/swarm-pr.md +458 -0
  39. package/.claude/agents/github/sync-coordinator.md +452 -0
  40. package/.claude/agents/github/workflow-automation.md +946 -0
  41. package/.claude/agents/goal/agent.md +816 -0
  42. package/.claude/agents/goal/goal-planner.md +73 -0
  43. package/.claude/agents/optimization/benchmark-suite.md +665 -0
  44. package/.claude/agents/optimization/load-balancer.md +431 -0
  45. package/.claude/agents/optimization/performance-monitor.md +672 -0
  46. package/.claude/agents/optimization/resource-allocator.md +674 -0
  47. package/.claude/agents/optimization/topology-optimizer.md +808 -0
  48. package/.claude/agents/payments/agentic-payments.md +126 -0
  49. package/.claude/agents/sona/sona-learning-optimizer.md +74 -0
  50. package/.claude/agents/sparc/architecture.md +713 -0
  51. package/.claude/agents/sparc/pseudocode.md +525 -0
  52. package/.claude/agents/sparc/refinement.md +838 -0
  53. package/.claude/agents/sparc/specification.md +491 -0
  54. package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +225 -0
  55. package/.claude/agents/specialized/spec-mobile-react-native.md +227 -0
  56. package/.claude/agents/sublinear/consensus-coordinator.md +338 -0
  57. package/.claude/agents/sublinear/matrix-optimizer.md +185 -0
  58. package/.claude/agents/sublinear/pagerank-analyzer.md +299 -0
  59. package/.claude/agents/sublinear/performance-optimizer.md +368 -0
  60. package/.claude/agents/sublinear/trading-predictor.md +246 -0
  61. package/.claude/agents/swarm/adaptive-coordinator.md +1149 -0
  62. package/.claude/agents/swarm/hierarchical-coordinator.md +741 -0
  63. package/.claude/agents/swarm/mesh-coordinator.md +989 -0
  64. package/.claude/agents/templates/automation-smart-agent.md +205 -0
  65. package/.claude/agents/templates/base-template-generator.md +298 -0
  66. package/.claude/agents/templates/coordinator-swarm-init.md +90 -0
  67. package/.claude/agents/templates/github-pr-manager.md +177 -0
  68. package/.claude/agents/templates/implementer-sparc-coder.md +259 -0
  69. package/.claude/agents/templates/memory-coordinator.md +187 -0
  70. package/.claude/agents/templates/orchestrator-task.md +139 -0
  71. package/.claude/agents/templates/performance-analyzer.md +199 -0
  72. package/.claude/agents/templates/sparc-coordinator.md +541 -0
  73. package/.claude/agents/testing/production-validator.md +395 -0
  74. package/.claude/agents/testing/tdd-london-swarm.md +244 -0
  75. package/.claude/agents/tmp.json +0 -0
  76. package/.claude/commands/agents/README.md +50 -0
  77. package/.claude/commands/agents/agent-capabilities.md +147 -0
  78. package/.claude/commands/agents/agent-coordination.md +28 -0
  79. package/.claude/commands/agents/agent-spawning.md +28 -0
  80. package/.claude/commands/agents/agent-types.md +216 -0
  81. package/.claude/commands/agents/health.md +139 -0
  82. package/.claude/commands/agents/list.md +100 -0
  83. package/.claude/commands/agents/logs.md +130 -0
  84. package/.claude/commands/agents/metrics.md +124 -0
  85. package/.claude/commands/agents/pool.md +127 -0
  86. package/.claude/commands/agents/spawn.md +146 -0
  87. package/.claude/commands/agents/status.md +115 -0
  88. package/.claude/commands/agents/stop.md +102 -0
  89. package/.claude/commands/coordination/README.md +9 -0
  90. package/.claude/commands/coordination/agent-spawn.md +25 -0
  91. package/.claude/commands/coordination/init.md +44 -0
  92. package/.claude/commands/coordination/orchestrate.md +43 -0
  93. package/.claude/commands/coordination/spawn.md +45 -0
  94. package/.claude/commands/coordination/swarm-init.md +85 -0
  95. package/.claude/commands/coordination/task-orchestrate.md +25 -0
  96. package/.claude/commands/hive-mind/README.md +17 -0
  97. package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -0
  98. package/.claude/commands/hive-mind/hive-mind-init.md +18 -0
  99. package/.claude/commands/hive-mind/hive-mind-memory.md +8 -0
  100. package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -0
  101. package/.claude/commands/hive-mind/hive-mind-resume.md +8 -0
  102. package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -0
  103. package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -0
  104. package/.claude/commands/hive-mind/hive-mind-status.md +8 -0
  105. package/.claude/commands/hive-mind/hive-mind-stop.md +8 -0
  106. package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -0
  107. package/.claude/commands/hive-mind/hive-mind.md +27 -0
  108. package/.claude/commands/memory/README.md +9 -0
  109. package/.claude/commands/memory/memory-persist.md +25 -0
  110. package/.claude/commands/memory/memory-search.md +25 -0
  111. package/.claude/commands/memory/memory-usage.md +25 -0
  112. package/.claude/commands/memory/neural.md +47 -0
  113. package/.claude/commands/monitoring/README.md +9 -0
  114. package/.claude/commands/monitoring/agent-metrics.md +25 -0
  115. package/.claude/commands/monitoring/agents.md +44 -0
  116. package/.claude/commands/monitoring/real-time-view.md +25 -0
  117. package/.claude/commands/monitoring/status.md +46 -0
  118. package/.claude/commands/monitoring/swarm-monitor.md +25 -0
  119. package/.claude/commands/monobrain-help.md +103 -0
  120. package/.claude/commands/monobrain-memory.md +107 -0
  121. package/.claude/commands/monobrain-swarm.md +205 -0
  122. package/.claude/commands/optimization/README.md +9 -0
  123. package/.claude/commands/optimization/auto-topology.md +62 -0
  124. package/.claude/commands/optimization/cache-manage.md +25 -0
  125. package/.claude/commands/optimization/parallel-execute.md +25 -0
  126. package/.claude/commands/optimization/parallel-execution.md +50 -0
  127. package/.claude/commands/optimization/topology-optimize.md +25 -0
  128. package/.claude/commands/pair/README.md +261 -0
  129. package/.claude/commands/pair/commands.md +546 -0
  130. package/.claude/commands/pair/config.md +510 -0
  131. package/.claude/commands/pair/examples.md +512 -0
  132. package/.claude/commands/pair/modes.md +348 -0
  133. package/.claude/commands/pair/session.md +407 -0
  134. package/.claude/commands/pair/start.md +209 -0
  135. package/.claude/commands/sparc.md +166 -0
  136. package/.claude/commands/stream-chain/pipeline.md +121 -0
  137. package/.claude/commands/stream-chain/run.md +70 -0
  138. package/.claude/commands/swarm/README.md +15 -0
  139. package/.claude/commands/swarm/analysis.md +95 -0
  140. package/.claude/commands/swarm/development.md +96 -0
  141. package/.claude/commands/swarm/examples.md +168 -0
  142. package/.claude/commands/swarm/maintenance.md +102 -0
  143. package/.claude/commands/swarm/optimization.md +117 -0
  144. package/.claude/commands/swarm/research.md +136 -0
  145. package/.claude/commands/swarm/swarm-analysis.md +8 -0
  146. package/.claude/commands/swarm/swarm-background.md +8 -0
  147. package/.claude/commands/swarm/swarm-init.md +19 -0
  148. package/.claude/commands/swarm/swarm-modes.md +8 -0
  149. package/.claude/commands/swarm/swarm-monitor.md +8 -0
  150. package/.claude/commands/swarm/swarm-spawn.md +19 -0
  151. package/.claude/commands/swarm/swarm-status.md +8 -0
  152. package/.claude/commands/swarm/swarm-strategies.md +8 -0
  153. package/.claude/commands/swarm/swarm.md +105 -0
  154. package/.claude/commands/swarm/testing.md +131 -0
  155. package/.claude/commands/training/README.md +9 -0
  156. package/.claude/commands/training/model-update.md +25 -0
  157. package/.claude/commands/training/neural-patterns.md +108 -0
  158. package/.claude/commands/training/neural-train.md +75 -0
  159. package/.claude/commands/training/pattern-learn.md +25 -0
  160. package/.claude/commands/training/specialization.md +63 -0
  161. package/.claude/commands/truth/start.md +143 -0
  162. package/.claude/commands/verify/check.md +50 -0
  163. package/.claude/commands/verify/start.md +128 -0
  164. package/.claude/commands/workflows/README.md +9 -0
  165. package/.claude/commands/workflows/development.md +78 -0
  166. package/.claude/commands/workflows/research.md +63 -0
  167. package/.claude/commands/workflows/workflow-create.md +25 -0
  168. package/.claude/commands/workflows/workflow-execute.md +25 -0
  169. package/.claude/commands/workflows/workflow-export.md +25 -0
  170. package/.claude/helpers/README.md +105 -0
  171. package/.claude/helpers/adr-compliance.sh +186 -0
  172. package/.claude/helpers/auto-commit.sh +178 -0
  173. package/.claude/helpers/auto-memory-hook.mjs +368 -0
  174. package/.claude/helpers/checkpoint-manager.sh +251 -0
  175. package/.claude/helpers/daemon-manager.sh +252 -0
  176. package/.claude/helpers/ddd-tracker.sh +144 -0
  177. package/.claude/helpers/github-safe.js +106 -0
  178. package/.claude/helpers/github-setup.sh +28 -0
  179. package/.claude/helpers/guidance-hook.sh +13 -0
  180. package/.claude/helpers/guidance-hooks.sh +102 -0
  181. package/.claude/helpers/health-monitor.sh +108 -0
  182. package/.claude/helpers/hook-handler.cjs +319 -0
  183. package/.claude/helpers/intelligence.cjs +968 -0
  184. package/.claude/helpers/learning-hooks.sh +329 -0
  185. package/.claude/helpers/learning-optimizer.sh +127 -0
  186. package/.claude/helpers/learning-service.mjs +1144 -0
  187. package/.claude/helpers/memory.js +83 -0
  188. package/.claude/helpers/metrics-db.mjs +488 -0
  189. package/.claude/helpers/pattern-consolidator.sh +86 -0
  190. package/.claude/helpers/perf-worker.sh +160 -0
  191. package/.claude/helpers/post-commit +16 -0
  192. package/.claude/helpers/pre-commit +26 -0
  193. package/.claude/helpers/quick-start.sh +19 -0
  194. package/.claude/helpers/router.js +66 -0
  195. package/.claude/helpers/security-scanner.sh +127 -0
  196. package/.claude/helpers/session.js +135 -0
  197. package/.claude/helpers/setup-mcp.sh +18 -0
  198. package/.claude/helpers/standard-checkpoint-hooks.sh +189 -0
  199. package/.claude/helpers/statusline-hook.sh +21 -0
  200. package/.claude/helpers/statusline.cjs +576 -0
  201. package/.claude/helpers/statusline.js +316 -0
  202. package/.claude/helpers/swarm-comms.sh +353 -0
  203. package/.claude/helpers/swarm-hooks.sh +761 -0
  204. package/.claude/helpers/swarm-monitor.sh +211 -0
  205. package/.claude/helpers/sync-v3-metrics.sh +245 -0
  206. package/.claude/helpers/update-v3-progress.sh +166 -0
  207. package/.claude/helpers/v3-quick-status.sh +58 -0
  208. package/.claude/helpers/v3.sh +111 -0
  209. package/.claude/helpers/validate-v3-config.sh +216 -0
  210. package/.claude/helpers/worker-manager.sh +170 -0
  211. package/.claude/settings.json +182 -0
  212. package/.claude/skills/agentdb-advanced/SKILL.md +550 -0
  213. package/.claude/skills/agentdb-learning/SKILL.md +545 -0
  214. package/.claude/skills/agentdb-memory-patterns/SKILL.md +339 -0
  215. package/.claude/skills/agentdb-optimization/SKILL.md +509 -0
  216. package/.claude/skills/agentdb-vector-search/SKILL.md +339 -0
  217. package/.claude/skills/agentic-jujutsu/SKILL.md +645 -0
  218. package/.claude/skills/aidefence-scan.md +151 -0
  219. package/.claude/skills/aidefence.yaml +297 -0
  220. package/.claude/skills/browser/SKILL.md +204 -0
  221. package/.claude/skills/flow-nexus-neural/SKILL.md +738 -0
  222. package/.claude/skills/flow-nexus-platform/SKILL.md +1157 -0
  223. package/.claude/skills/flow-nexus-swarm/SKILL.md +610 -0
  224. package/.claude/skills/github-code-review/SKILL.md +1163 -0
  225. package/.claude/skills/github-multi-repo/SKILL.md +928 -0
  226. package/.claude/skills/github-project-management/SKILL.md +1277 -0
  227. package/.claude/skills/github-release-management/SKILL.md +1141 -0
  228. package/.claude/skills/github-workflow-automation/SKILL.md +1129 -0
  229. package/.claude/skills/hive-mind-advanced/SKILL.md +712 -0
  230. package/.claude/skills/hooks-automation/SKILL.md +1201 -0
  231. package/.claude/skills/pair-programming/SKILL.md +1202 -0
  232. package/.claude/skills/performance-analysis/SKILL.md +563 -0
  233. package/.claude/skills/reasoningbank-agentdb/SKILL.md +446 -0
  234. package/.claude/skills/reasoningbank-intelligence/SKILL.md +210 -0
  235. package/.claude/skills/secure-review.md +181 -0
  236. package/.claude/skills/skill-builder/SKILL.md +910 -0
  237. package/.claude/skills/sparc-methodology/SKILL.md +1115 -0
  238. package/.claude/skills/stream-chain/SKILL.md +563 -0
  239. package/.claude/skills/swarm-advanced/SKILL.md +973 -0
  240. package/.claude/skills/swarm-orchestration/SKILL.md +190 -0
  241. package/.claude/skills/v3-cli-modernization/SKILL.md +941 -0
  242. package/.claude/skills/v3-core-implementation/SKILL.md +867 -0
  243. package/.claude/skills/v3-ddd-architecture/SKILL.md +451 -0
  244. package/.claude/skills/v3-integration-deep/SKILL.md +258 -0
  245. package/.claude/skills/v3-mcp-optimization/SKILL.md +816 -0
  246. package/.claude/skills/v3-memory-unification/SKILL.md +180 -0
  247. package/.claude/skills/v3-performance-optimization/SKILL.md +408 -0
  248. package/.claude/skills/v3-security-overhaul/SKILL.md +91 -0
  249. package/.claude/skills/v3-swarm-coordination/SKILL.md +433 -0
  250. package/.claude/skills/verification-quality/SKILL.md +677 -0
  251. package/.claude/skills/worker-benchmarks/skill.md +135 -0
  252. package/.claude/skills/worker-integration/skill.md +154 -0
  253. package/README.md +646 -0
  254. package/bin/cli.js +156 -0
  255. package/bin/mcp-server.js +189 -0
  256. package/bin/preinstall.cjs +2 -0
  257. package/dist/src/agents/halt-signal.d.ts +25 -0
  258. package/dist/src/agents/halt-signal.d.ts.map +1 -0
  259. package/dist/src/agents/halt-signal.js +50 -0
  260. package/dist/src/agents/halt-signal.js.map +1 -0
  261. package/dist/src/agents/index.d.ts +18 -0
  262. package/dist/src/agents/index.d.ts.map +1 -0
  263. package/dist/src/agents/index.js +13 -0
  264. package/dist/src/agents/index.js.map +1 -0
  265. package/dist/src/agents/managed-agent.d.ts +41 -0
  266. package/dist/src/agents/managed-agent.d.ts.map +1 -0
  267. package/dist/src/agents/managed-agent.js +66 -0
  268. package/dist/src/agents/managed-agent.js.map +1 -0
  269. package/dist/src/agents/prompt-experiment.d.ts +22 -0
  270. package/dist/src/agents/prompt-experiment.d.ts.map +1 -0
  271. package/dist/src/agents/prompt-experiment.js +49 -0
  272. package/dist/src/agents/prompt-experiment.js.map +1 -0
  273. package/dist/src/agents/prompt-version-manager.d.ts +19 -0
  274. package/dist/src/agents/prompt-version-manager.d.ts.map +1 -0
  275. package/dist/src/agents/prompt-version-manager.js +58 -0
  276. package/dist/src/agents/prompt-version-manager.js.map +1 -0
  277. package/dist/src/agents/registry-builder.d.ts +36 -0
  278. package/dist/src/agents/registry-builder.d.ts.map +1 -0
  279. package/dist/src/agents/registry-builder.js +200 -0
  280. package/dist/src/agents/registry-builder.js.map +1 -0
  281. package/dist/src/agents/registry-query.d.ts +71 -0
  282. package/dist/src/agents/registry-query.d.ts.map +1 -0
  283. package/dist/src/agents/registry-query.js +125 -0
  284. package/dist/src/agents/registry-query.js.map +1 -0
  285. package/dist/src/agents/score-decay.d.ts +19 -0
  286. package/dist/src/agents/score-decay.d.ts.map +1 -0
  287. package/dist/src/agents/score-decay.js +22 -0
  288. package/dist/src/agents/score-decay.js.map +1 -0
  289. package/dist/src/agents/shared-instructions-loader.d.ts +13 -0
  290. package/dist/src/agents/shared-instructions-loader.d.ts.map +1 -0
  291. package/dist/src/agents/shared-instructions-loader.js +40 -0
  292. package/dist/src/agents/shared-instructions-loader.js.map +1 -0
  293. package/dist/src/agents/specialization-scorer.d.ts +54 -0
  294. package/dist/src/agents/specialization-scorer.d.ts.map +1 -0
  295. package/dist/src/agents/specialization-scorer.js +204 -0
  296. package/dist/src/agents/specialization-scorer.js.map +1 -0
  297. package/dist/src/agents/termination-watcher.d.ts +30 -0
  298. package/dist/src/agents/termination-watcher.d.ts.map +1 -0
  299. package/dist/src/agents/termination-watcher.js +84 -0
  300. package/dist/src/agents/termination-watcher.js.map +1 -0
  301. package/dist/src/agents/trigger-index.d.ts +20 -0
  302. package/dist/src/agents/trigger-index.d.ts.map +1 -0
  303. package/dist/src/agents/trigger-index.js +38 -0
  304. package/dist/src/agents/trigger-index.js.map +1 -0
  305. package/dist/src/agents/trigger-scanner.d.ts +62 -0
  306. package/dist/src/agents/trigger-scanner.d.ts.map +1 -0
  307. package/dist/src/agents/trigger-scanner.js +260 -0
  308. package/dist/src/agents/trigger-scanner.js.map +1 -0
  309. package/dist/src/agents/version-diff.d.ts +18 -0
  310. package/dist/src/agents/version-diff.d.ts.map +1 -0
  311. package/dist/src/agents/version-diff.js +64 -0
  312. package/dist/src/agents/version-diff.js.map +1 -0
  313. package/dist/src/agents/version-store.d.ts +61 -0
  314. package/dist/src/agents/version-store.d.ts.map +1 -0
  315. package/dist/src/agents/version-store.js +212 -0
  316. package/dist/src/agents/version-store.js.map +1 -0
  317. package/dist/src/appliance/gguf-engine.d.ts +91 -0
  318. package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
  319. package/dist/src/appliance/gguf-engine.js +425 -0
  320. package/dist/src/appliance/gguf-engine.js.map +1 -0
  321. package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
  322. package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
  323. package/dist/src/appliance/ruvllm-bridge.js +292 -0
  324. package/dist/src/appliance/ruvllm-bridge.js.map +1 -0
  325. package/dist/src/appliance/rvfa-builder.d.ts +44 -0
  326. package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
  327. package/dist/src/appliance/rvfa-builder.js +329 -0
  328. package/dist/src/appliance/rvfa-builder.js.map +1 -0
  329. package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
  330. package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
  331. package/dist/src/appliance/rvfa-distribution.js +370 -0
  332. package/dist/src/appliance/rvfa-distribution.js.map +1 -0
  333. package/dist/src/appliance/rvfa-format.d.ts +111 -0
  334. package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
  335. package/dist/src/appliance/rvfa-format.js +393 -0
  336. package/dist/src/appliance/rvfa-format.js.map +1 -0
  337. package/dist/src/appliance/rvfa-runner.d.ts +69 -0
  338. package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
  339. package/dist/src/appliance/rvfa-runner.js +237 -0
  340. package/dist/src/appliance/rvfa-runner.js.map +1 -0
  341. package/dist/src/appliance/rvfa-signing.d.ts +123 -0
  342. package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
  343. package/dist/src/appliance/rvfa-signing.js +347 -0
  344. package/dist/src/appliance/rvfa-signing.js.map +1 -0
  345. package/dist/src/autopilot-state.d.ts +77 -0
  346. package/dist/src/autopilot-state.d.ts.map +1 -0
  347. package/dist/src/autopilot-state.js +279 -0
  348. package/dist/src/autopilot-state.js.map +1 -0
  349. package/dist/src/benchmarks/benchmark-runner.d.ts +36 -0
  350. package/dist/src/benchmarks/benchmark-runner.d.ts.map +1 -0
  351. package/dist/src/benchmarks/benchmark-runner.js +128 -0
  352. package/dist/src/benchmarks/benchmark-runner.js.map +1 -0
  353. package/dist/src/benchmarks/metric-evaluators.d.ts +35 -0
  354. package/dist/src/benchmarks/metric-evaluators.d.ts.map +1 -0
  355. package/dist/src/benchmarks/metric-evaluators.js +91 -0
  356. package/dist/src/benchmarks/metric-evaluators.js.map +1 -0
  357. package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
  358. package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
  359. package/dist/src/benchmarks/pretrain/index.js +404 -0
  360. package/dist/src/benchmarks/pretrain/index.js.map +1 -0
  361. package/dist/src/commands/agent-version.d.ts +8 -0
  362. package/dist/src/commands/agent-version.d.ts.map +1 -0
  363. package/dist/src/commands/agent-version.js +78 -0
  364. package/dist/src/commands/agent-version.js.map +1 -0
  365. package/dist/src/commands/agent-wasm.d.ts +14 -0
  366. package/dist/src/commands/agent-wasm.d.ts.map +1 -0
  367. package/dist/src/commands/agent-wasm.js +333 -0
  368. package/dist/src/commands/agent-wasm.js.map +1 -0
  369. package/dist/src/commands/agent.d.ts +8 -0
  370. package/dist/src/commands/agent.d.ts.map +1 -0
  371. package/dist/src/commands/agent.js +941 -0
  372. package/dist/src/commands/agent.js.map +1 -0
  373. package/dist/src/commands/analyze.d.ts +19 -0
  374. package/dist/src/commands/analyze.d.ts.map +1 -0
  375. package/dist/src/commands/analyze.js +2048 -0
  376. package/dist/src/commands/analyze.js.map +1 -0
  377. package/dist/src/commands/appliance-advanced.d.ts +9 -0
  378. package/dist/src/commands/appliance-advanced.d.ts.map +1 -0
  379. package/dist/src/commands/appliance-advanced.js +215 -0
  380. package/dist/src/commands/appliance-advanced.js.map +1 -0
  381. package/dist/src/commands/appliance.d.ts +8 -0
  382. package/dist/src/commands/appliance.d.ts.map +1 -0
  383. package/dist/src/commands/appliance.js +406 -0
  384. package/dist/src/commands/appliance.js.map +1 -0
  385. package/dist/src/commands/autopilot.d.ts +15 -0
  386. package/dist/src/commands/autopilot.d.ts.map +1 -0
  387. package/dist/src/commands/autopilot.js +362 -0
  388. package/dist/src/commands/autopilot.js.map +1 -0
  389. package/dist/src/commands/benchmark.d.ts +10 -0
  390. package/dist/src/commands/benchmark.d.ts.map +1 -0
  391. package/dist/src/commands/benchmark.js +460 -0
  392. package/dist/src/commands/benchmark.js.map +1 -0
  393. package/dist/src/commands/claims.d.ts +10 -0
  394. package/dist/src/commands/claims.d.ts.map +1 -0
  395. package/dist/src/commands/claims.js +624 -0
  396. package/dist/src/commands/claims.js.map +1 -0
  397. package/dist/src/commands/cleanup.d.ts +13 -0
  398. package/dist/src/commands/cleanup.d.ts.map +1 -0
  399. package/dist/src/commands/cleanup.js +218 -0
  400. package/dist/src/commands/cleanup.js.map +1 -0
  401. package/dist/src/commands/completions.d.ts +10 -0
  402. package/dist/src/commands/completions.d.ts.map +1 -0
  403. package/dist/src/commands/completions.js +539 -0
  404. package/dist/src/commands/completions.js.map +1 -0
  405. package/dist/src/commands/config.d.ts +8 -0
  406. package/dist/src/commands/config.d.ts.map +1 -0
  407. package/dist/src/commands/config.js +428 -0
  408. package/dist/src/commands/config.js.map +1 -0
  409. package/dist/src/commands/consensus.d.ts +8 -0
  410. package/dist/src/commands/consensus.d.ts.map +1 -0
  411. package/dist/src/commands/consensus.js +64 -0
  412. package/dist/src/commands/consensus.js.map +1 -0
  413. package/dist/src/commands/cost.d.ts +8 -0
  414. package/dist/src/commands/cost.d.ts.map +1 -0
  415. package/dist/src/commands/cost.js +48 -0
  416. package/dist/src/commands/cost.js.map +1 -0
  417. package/dist/src/commands/daemon.d.ts +8 -0
  418. package/dist/src/commands/daemon.d.ts.map +1 -0
  419. package/dist/src/commands/daemon.js +669 -0
  420. package/dist/src/commands/daemon.js.map +1 -0
  421. package/dist/src/commands/deployment.d.ts +10 -0
  422. package/dist/src/commands/deployment.d.ts.map +1 -0
  423. package/dist/src/commands/deployment.js +672 -0
  424. package/dist/src/commands/deployment.js.map +1 -0
  425. package/dist/src/commands/dlq.d.ts +8 -0
  426. package/dist/src/commands/dlq.d.ts.map +1 -0
  427. package/dist/src/commands/dlq.js +81 -0
  428. package/dist/src/commands/dlq.js.map +1 -0
  429. package/dist/src/commands/doctor.d.ts +10 -0
  430. package/dist/src/commands/doctor.d.ts.map +1 -0
  431. package/dist/src/commands/doctor.js +619 -0
  432. package/dist/src/commands/doctor.js.map +1 -0
  433. package/dist/src/commands/embeddings.d.ts +18 -0
  434. package/dist/src/commands/embeddings.d.ts.map +1 -0
  435. package/dist/src/commands/embeddings.js +1576 -0
  436. package/dist/src/commands/embeddings.js.map +1 -0
  437. package/dist/src/commands/eval.d.ts +8 -0
  438. package/dist/src/commands/eval.d.ts.map +1 -0
  439. package/dist/src/commands/eval.js +81 -0
  440. package/dist/src/commands/eval.js.map +1 -0
  441. package/dist/src/commands/flows.d.ts +8 -0
  442. package/dist/src/commands/flows.d.ts.map +1 -0
  443. package/dist/src/commands/flows.js +90 -0
  444. package/dist/src/commands/flows.js.map +1 -0
  445. package/dist/src/commands/guidance.d.ts +8 -0
  446. package/dist/src/commands/guidance.d.ts.map +1 -0
  447. package/dist/src/commands/guidance.js +560 -0
  448. package/dist/src/commands/guidance.js.map +1 -0
  449. package/dist/src/commands/hive-mind.d.ts +11 -0
  450. package/dist/src/commands/hive-mind.d.ts.map +1 -0
  451. package/dist/src/commands/hive-mind.js +1237 -0
  452. package/dist/src/commands/hive-mind.js.map +1 -0
  453. package/dist/src/commands/hooks.d.ts +8 -0
  454. package/dist/src/commands/hooks.d.ts.map +1 -0
  455. package/dist/src/commands/hooks.js +4442 -0
  456. package/dist/src/commands/hooks.js.map +1 -0
  457. package/dist/src/commands/index.d.ts +117 -0
  458. package/dist/src/commands/index.d.ts.map +1 -0
  459. package/dist/src/commands/index.js +384 -0
  460. package/dist/src/commands/index.js.map +1 -0
  461. package/dist/src/commands/init.d.ts +8 -0
  462. package/dist/src/commands/init.d.ts.map +1 -0
  463. package/dist/src/commands/init.js +969 -0
  464. package/dist/src/commands/init.js.map +1 -0
  465. package/dist/src/commands/issues.d.ts +21 -0
  466. package/dist/src/commands/issues.d.ts.map +1 -0
  467. package/dist/src/commands/issues.js +567 -0
  468. package/dist/src/commands/issues.js.map +1 -0
  469. package/dist/src/commands/knowledge.d.ts +8 -0
  470. package/dist/src/commands/knowledge.d.ts.map +1 -0
  471. package/dist/src/commands/knowledge.js +82 -0
  472. package/dist/src/commands/knowledge.js.map +1 -0
  473. package/dist/src/commands/mcp.d.ts +11 -0
  474. package/dist/src/commands/mcp.d.ts.map +1 -0
  475. package/dist/src/commands/mcp.js +718 -0
  476. package/dist/src/commands/mcp.js.map +1 -0
  477. package/dist/src/commands/memory.d.ts +8 -0
  478. package/dist/src/commands/memory.d.ts.map +1 -0
  479. package/dist/src/commands/memory.js +1299 -0
  480. package/dist/src/commands/memory.js.map +1 -0
  481. package/dist/src/commands/metrics.d.ts +8 -0
  482. package/dist/src/commands/metrics.d.ts.map +1 -0
  483. package/dist/src/commands/metrics.js +55 -0
  484. package/dist/src/commands/metrics.js.map +1 -0
  485. package/dist/src/commands/migrate.d.ts +8 -0
  486. package/dist/src/commands/migrate.d.ts.map +1 -0
  487. package/dist/src/commands/migrate.js +742 -0
  488. package/dist/src/commands/migrate.js.map +1 -0
  489. package/dist/src/commands/neural.d.ts +10 -0
  490. package/dist/src/commands/neural.d.ts.map +1 -0
  491. package/dist/src/commands/neural.js +1454 -0
  492. package/dist/src/commands/neural.js.map +1 -0
  493. package/dist/src/commands/performance.d.ts +10 -0
  494. package/dist/src/commands/performance.d.ts.map +1 -0
  495. package/dist/src/commands/performance.js +579 -0
  496. package/dist/src/commands/performance.js.map +1 -0
  497. package/dist/src/commands/plugins.d.ts +11 -0
  498. package/dist/src/commands/plugins.d.ts.map +1 -0
  499. package/dist/src/commands/plugins.js +820 -0
  500. package/dist/src/commands/plugins.js.map +1 -0
  501. package/dist/src/commands/process.d.ts +10 -0
  502. package/dist/src/commands/process.d.ts.map +1 -0
  503. package/dist/src/commands/process.js +695 -0
  504. package/dist/src/commands/process.js.map +1 -0
  505. package/dist/src/commands/progress.d.ts +11 -0
  506. package/dist/src/commands/progress.d.ts.map +1 -0
  507. package/dist/src/commands/progress.js +259 -0
  508. package/dist/src/commands/progress.js.map +1 -0
  509. package/dist/src/commands/prompt.d.ts +8 -0
  510. package/dist/src/commands/prompt.d.ts.map +1 -0
  511. package/dist/src/commands/prompt.js +78 -0
  512. package/dist/src/commands/prompt.js.map +1 -0
  513. package/dist/src/commands/providers.d.ts +10 -0
  514. package/dist/src/commands/providers.d.ts.map +1 -0
  515. package/dist/src/commands/providers.js +359 -0
  516. package/dist/src/commands/providers.js.map +1 -0
  517. package/dist/src/commands/registry.d.ts +8 -0
  518. package/dist/src/commands/registry.d.ts.map +1 -0
  519. package/dist/src/commands/registry.js +143 -0
  520. package/dist/src/commands/registry.js.map +1 -0
  521. package/dist/src/commands/replay.d.ts +8 -0
  522. package/dist/src/commands/replay.d.ts.map +1 -0
  523. package/dist/src/commands/replay.js +60 -0
  524. package/dist/src/commands/replay.js.map +1 -0
  525. package/dist/src/commands/route.d.ts +16 -0
  526. package/dist/src/commands/route.d.ts.map +1 -0
  527. package/dist/src/commands/route.js +907 -0
  528. package/dist/src/commands/route.js.map +1 -0
  529. package/dist/src/commands/ruvector/backup.d.ts +11 -0
  530. package/dist/src/commands/ruvector/backup.d.ts.map +1 -0
  531. package/dist/src/commands/ruvector/backup.js +746 -0
  532. package/dist/src/commands/ruvector/backup.js.map +1 -0
  533. package/dist/src/commands/ruvector/benchmark.d.ts +11 -0
  534. package/dist/src/commands/ruvector/benchmark.d.ts.map +1 -0
  535. package/dist/src/commands/ruvector/benchmark.js +489 -0
  536. package/dist/src/commands/ruvector/benchmark.js.map +1 -0
  537. package/dist/src/commands/ruvector/import.d.ts +18 -0
  538. package/dist/src/commands/ruvector/import.d.ts.map +1 -0
  539. package/dist/src/commands/ruvector/import.js +349 -0
  540. package/dist/src/commands/ruvector/import.js.map +1 -0
  541. package/dist/src/commands/ruvector/index.d.ts +29 -0
  542. package/dist/src/commands/ruvector/index.d.ts.map +1 -0
  543. package/dist/src/commands/ruvector/index.js +129 -0
  544. package/dist/src/commands/ruvector/index.js.map +1 -0
  545. package/dist/src/commands/ruvector/init.d.ts +11 -0
  546. package/dist/src/commands/ruvector/init.d.ts.map +1 -0
  547. package/dist/src/commands/ruvector/init.js +466 -0
  548. package/dist/src/commands/ruvector/init.js.map +1 -0
  549. package/dist/src/commands/ruvector/migrate.d.ts +11 -0
  550. package/dist/src/commands/ruvector/migrate.d.ts.map +1 -0
  551. package/dist/src/commands/ruvector/migrate.js +497 -0
  552. package/dist/src/commands/ruvector/migrate.js.map +1 -0
  553. package/dist/src/commands/ruvector/optimize.d.ts +11 -0
  554. package/dist/src/commands/ruvector/optimize.d.ts.map +1 -0
  555. package/dist/src/commands/ruvector/optimize.js +504 -0
  556. package/dist/src/commands/ruvector/optimize.js.map +1 -0
  557. package/dist/src/commands/ruvector/setup.d.ts +18 -0
  558. package/dist/src/commands/ruvector/setup.d.ts.map +1 -0
  559. package/dist/src/commands/ruvector/setup.js +765 -0
  560. package/dist/src/commands/ruvector/setup.js.map +1 -0
  561. package/dist/src/commands/ruvector/status.d.ts +11 -0
  562. package/dist/src/commands/ruvector/status.d.ts.map +1 -0
  563. package/dist/src/commands/ruvector/status.js +478 -0
  564. package/dist/src/commands/ruvector/status.js.map +1 -0
  565. package/dist/src/commands/scores.d.ts +8 -0
  566. package/dist/src/commands/scores.d.ts.map +1 -0
  567. package/dist/src/commands/scores.js +95 -0
  568. package/dist/src/commands/scores.js.map +1 -0
  569. package/dist/src/commands/security.d.ts +10 -0
  570. package/dist/src/commands/security.d.ts.map +1 -0
  571. package/dist/src/commands/security.js +617 -0
  572. package/dist/src/commands/security.js.map +1 -0
  573. package/dist/src/commands/session.d.ts +8 -0
  574. package/dist/src/commands/session.d.ts.map +1 -0
  575. package/dist/src/commands/session.js +750 -0
  576. package/dist/src/commands/session.js.map +1 -0
  577. package/dist/src/commands/start.d.ts +8 -0
  578. package/dist/src/commands/start.d.ts.map +1 -0
  579. package/dist/src/commands/start.js +418 -0
  580. package/dist/src/commands/start.js.map +1 -0
  581. package/dist/src/commands/status.d.ts +8 -0
  582. package/dist/src/commands/status.d.ts.map +1 -0
  583. package/dist/src/commands/status.js +591 -0
  584. package/dist/src/commands/status.js.map +1 -0
  585. package/dist/src/commands/swarm.d.ts +8 -0
  586. package/dist/src/commands/swarm.d.ts.map +1 -0
  587. package/dist/src/commands/swarm.js +801 -0
  588. package/dist/src/commands/swarm.js.map +1 -0
  589. package/dist/src/commands/task.d.ts +8 -0
  590. package/dist/src/commands/task.d.ts.map +1 -0
  591. package/dist/src/commands/task.js +671 -0
  592. package/dist/src/commands/task.js.map +1 -0
  593. package/dist/src/commands/tools.d.ts +8 -0
  594. package/dist/src/commands/tools.d.ts.map +1 -0
  595. package/dist/src/commands/tools.js +76 -0
  596. package/dist/src/commands/tools.js.map +1 -0
  597. package/dist/src/commands/transfer-store.d.ts +13 -0
  598. package/dist/src/commands/transfer-store.d.ts.map +1 -0
  599. package/dist/src/commands/transfer-store.js +428 -0
  600. package/dist/src/commands/transfer-store.js.map +1 -0
  601. package/dist/src/commands/update.d.ts +8 -0
  602. package/dist/src/commands/update.d.ts.map +1 -0
  603. package/dist/src/commands/update.js +276 -0
  604. package/dist/src/commands/update.js.map +1 -0
  605. package/dist/src/commands/workflow.d.ts +8 -0
  606. package/dist/src/commands/workflow.d.ts.map +1 -0
  607. package/dist/src/commands/workflow.js +617 -0
  608. package/dist/src/commands/workflow.js.map +1 -0
  609. package/dist/src/config-adapter.d.ts +15 -0
  610. package/dist/src/config-adapter.d.ts.map +1 -0
  611. package/dist/src/config-adapter.js +186 -0
  612. package/dist/src/config-adapter.js.map +1 -0
  613. package/dist/src/consensus/audit-writer.d.ts +50 -0
  614. package/dist/src/consensus/audit-writer.d.ts.map +1 -0
  615. package/dist/src/consensus/audit-writer.js +109 -0
  616. package/dist/src/consensus/audit-writer.js.map +1 -0
  617. package/dist/src/consensus/index.d.ts +7 -0
  618. package/dist/src/consensus/index.d.ts.map +1 -0
  619. package/dist/src/consensus/index.js +6 -0
  620. package/dist/src/consensus/index.js.map +1 -0
  621. package/dist/src/consensus/vote-signer.d.ts +19 -0
  622. package/dist/src/consensus/vote-signer.d.ts.map +1 -0
  623. package/dist/src/consensus/vote-signer.js +32 -0
  624. package/dist/src/consensus/vote-signer.js.map +1 -0
  625. package/dist/src/context/context-provider.d.ts +44 -0
  626. package/dist/src/context/context-provider.d.ts.map +1 -0
  627. package/dist/src/context/context-provider.js +25 -0
  628. package/dist/src/context/context-provider.js.map +1 -0
  629. package/dist/src/context/git-state-provider.d.ts +12 -0
  630. package/dist/src/context/git-state-provider.d.ts.map +1 -0
  631. package/dist/src/context/git-state-provider.js +34 -0
  632. package/dist/src/context/git-state-provider.js.map +1 -0
  633. package/dist/src/context/index.d.ts +12 -0
  634. package/dist/src/context/index.d.ts.map +1 -0
  635. package/dist/src/context/index.js +12 -0
  636. package/dist/src/context/index.js.map +1 -0
  637. package/dist/src/context/project-conventions-provider.d.ts +15 -0
  638. package/dist/src/context/project-conventions-provider.d.ts.map +1 -0
  639. package/dist/src/context/project-conventions-provider.js +19 -0
  640. package/dist/src/context/project-conventions-provider.js.map +1 -0
  641. package/dist/src/context/prompt-assembler.d.ts +26 -0
  642. package/dist/src/context/prompt-assembler.d.ts.map +1 -0
  643. package/dist/src/context/prompt-assembler.js +93 -0
  644. package/dist/src/context/prompt-assembler.js.map +1 -0
  645. package/dist/src/context/task-history-provider.d.ts +24 -0
  646. package/dist/src/context/task-history-provider.d.ts.map +1 -0
  647. package/dist/src/context/task-history-provider.js +32 -0
  648. package/dist/src/context/task-history-provider.js.map +1 -0
  649. package/dist/src/context/user-preferences-provider.d.ts +14 -0
  650. package/dist/src/context/user-preferences-provider.d.ts.map +1 -0
  651. package/dist/src/context/user-preferences-provider.js +27 -0
  652. package/dist/src/context/user-preferences-provider.js.map +1 -0
  653. package/dist/src/dlq/dlq-reader.d.ts +29 -0
  654. package/dist/src/dlq/dlq-reader.d.ts.map +1 -0
  655. package/dist/src/dlq/dlq-reader.js +64 -0
  656. package/dist/src/dlq/dlq-reader.js.map +1 -0
  657. package/dist/src/dlq/dlq-replayer.d.ts +20 -0
  658. package/dist/src/dlq/dlq-replayer.d.ts.map +1 -0
  659. package/dist/src/dlq/dlq-replayer.js +56 -0
  660. package/dist/src/dlq/dlq-replayer.js.map +1 -0
  661. package/dist/src/dlq/dlq-writer.d.ts +24 -0
  662. package/dist/src/dlq/dlq-writer.d.ts.map +1 -0
  663. package/dist/src/dlq/dlq-writer.js +43 -0
  664. package/dist/src/dlq/dlq-writer.js.map +1 -0
  665. package/dist/src/dlq/index.d.ts +10 -0
  666. package/dist/src/dlq/index.d.ts.map +1 -0
  667. package/dist/src/dlq/index.js +7 -0
  668. package/dist/src/dlq/index.js.map +1 -0
  669. package/dist/src/eval/dataset-manager.d.ts +33 -0
  670. package/dist/src/eval/dataset-manager.d.ts.map +1 -0
  671. package/dist/src/eval/dataset-manager.js +97 -0
  672. package/dist/src/eval/dataset-manager.js.map +1 -0
  673. package/dist/src/eval/dataset-runner.d.ts +23 -0
  674. package/dist/src/eval/dataset-runner.d.ts.map +1 -0
  675. package/dist/src/eval/dataset-runner.js +59 -0
  676. package/dist/src/eval/dataset-runner.js.map +1 -0
  677. package/dist/src/eval/index.d.ts +10 -0
  678. package/dist/src/eval/index.d.ts.map +1 -0
  679. package/dist/src/eval/index.js +7 -0
  680. package/dist/src/eval/index.js.map +1 -0
  681. package/dist/src/eval/trace-collector.d.ts +40 -0
  682. package/dist/src/eval/trace-collector.d.ts.map +1 -0
  683. package/dist/src/eval/trace-collector.js +82 -0
  684. package/dist/src/eval/trace-collector.js.map +1 -0
  685. package/dist/src/index.d.ts +82 -0
  686. package/dist/src/index.d.ts.map +1 -0
  687. package/dist/src/index.js +578 -0
  688. package/dist/src/index.js.map +1 -0
  689. package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
  690. package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
  691. package/dist/src/infrastructure/in-memory-repositories.js +264 -0
  692. package/dist/src/infrastructure/in-memory-repositories.js.map +1 -0
  693. package/dist/src/init/claudemd-generator.d.ts +25 -0
  694. package/dist/src/init/claudemd-generator.d.ts.map +1 -0
  695. package/dist/src/init/claudemd-generator.js +486 -0
  696. package/dist/src/init/claudemd-generator.js.map +1 -0
  697. package/dist/src/init/executor.d.ts +41 -0
  698. package/dist/src/init/executor.d.ts.map +1 -0
  699. package/dist/src/init/executor.js +1807 -0
  700. package/dist/src/init/executor.js.map +1 -0
  701. package/dist/src/init/helpers-generator.d.ts +60 -0
  702. package/dist/src/init/helpers-generator.d.ts.map +1 -0
  703. package/dist/src/init/helpers-generator.js +1185 -0
  704. package/dist/src/init/helpers-generator.js.map +1 -0
  705. package/dist/src/init/index.d.ts +13 -0
  706. package/dist/src/init/index.d.ts.map +1 -0
  707. package/dist/src/init/index.js +15 -0
  708. package/dist/src/init/index.js.map +1 -0
  709. package/dist/src/init/mcp-generator.d.ts +26 -0
  710. package/dist/src/init/mcp-generator.d.ts.map +1 -0
  711. package/dist/src/init/mcp-generator.js +116 -0
  712. package/dist/src/init/mcp-generator.js.map +1 -0
  713. package/dist/src/init/settings-generator.d.ts +14 -0
  714. package/dist/src/init/settings-generator.d.ts.map +1 -0
  715. package/dist/src/init/settings-generator.js +392 -0
  716. package/dist/src/init/settings-generator.js.map +1 -0
  717. package/dist/src/init/statusline-generator.d.ts +28 -0
  718. package/dist/src/init/statusline-generator.d.ts.map +1 -0
  719. package/dist/src/init/statusline-generator.js +833 -0
  720. package/dist/src/init/statusline-generator.js.map +1 -0
  721. package/dist/src/init/types.d.ts +295 -0
  722. package/dist/src/init/types.d.ts.map +1 -0
  723. package/dist/src/init/types.js +263 -0
  724. package/dist/src/init/types.js.map +1 -0
  725. package/dist/src/interactive/interrupt.d.ts +22 -0
  726. package/dist/src/interactive/interrupt.d.ts.map +1 -0
  727. package/dist/src/interactive/interrupt.js +66 -0
  728. package/dist/src/interactive/interrupt.js.map +1 -0
  729. package/dist/src/mcp/deprecation-injector.d.ts +25 -0
  730. package/dist/src/mcp/deprecation-injector.d.ts.map +1 -0
  731. package/dist/src/mcp/deprecation-injector.js +48 -0
  732. package/dist/src/mcp/deprecation-injector.js.map +1 -0
  733. package/dist/src/mcp/tool-registry.d.ts +61 -0
  734. package/dist/src/mcp/tool-registry.d.ts.map +1 -0
  735. package/dist/src/mcp/tool-registry.js +212 -0
  736. package/dist/src/mcp/tool-registry.js.map +1 -0
  737. package/dist/src/mcp-client.d.ts +92 -0
  738. package/dist/src/mcp-client.d.ts.map +1 -0
  739. package/dist/src/mcp-client.js +249 -0
  740. package/dist/src/mcp-client.js.map +1 -0
  741. package/dist/src/mcp-server.d.ts +163 -0
  742. package/dist/src/mcp-server.d.ts.map +1 -0
  743. package/dist/src/mcp-server.js +682 -0
  744. package/dist/src/mcp-server.js.map +1 -0
  745. package/dist/src/mcp-tools/agent-tools.d.ts +9 -0
  746. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -0
  747. package/dist/src/mcp-tools/agent-tools.js +564 -0
  748. package/dist/src/mcp-tools/agent-tools.js.map +1 -0
  749. package/dist/src/mcp-tools/agentdb-tools.d.ts +30 -0
  750. package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -0
  751. package/dist/src/mcp-tools/agentdb-tools.js +557 -0
  752. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -0
  753. package/dist/src/mcp-tools/analyze-tools.d.ts +38 -0
  754. package/dist/src/mcp-tools/analyze-tools.d.ts.map +1 -0
  755. package/dist/src/mcp-tools/analyze-tools.js +317 -0
  756. package/dist/src/mcp-tools/analyze-tools.js.map +1 -0
  757. package/dist/src/mcp-tools/auto-install.d.ts +83 -0
  758. package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
  759. package/dist/src/mcp-tools/auto-install.js +131 -0
  760. package/dist/src/mcp-tools/auto-install.js.map +1 -0
  761. package/dist/src/mcp-tools/autopilot-tools.d.ts +12 -0
  762. package/dist/src/mcp-tools/autopilot-tools.d.ts.map +1 -0
  763. package/dist/src/mcp-tools/autopilot-tools.js +227 -0
  764. package/dist/src/mcp-tools/autopilot-tools.js.map +1 -0
  765. package/dist/src/mcp-tools/browser-tools.d.ts +13 -0
  766. package/dist/src/mcp-tools/browser-tools.d.ts.map +1 -0
  767. package/dist/src/mcp-tools/browser-tools.js +550 -0
  768. package/dist/src/mcp-tools/browser-tools.js.map +1 -0
  769. package/dist/src/mcp-tools/claims-tools.d.ts +12 -0
  770. package/dist/src/mcp-tools/claims-tools.d.ts.map +1 -0
  771. package/dist/src/mcp-tools/claims-tools.js +747 -0
  772. package/dist/src/mcp-tools/claims-tools.js.map +1 -0
  773. package/dist/src/mcp-tools/config-tools.d.ts +8 -0
  774. package/dist/src/mcp-tools/config-tools.d.ts.map +1 -0
  775. package/dist/src/mcp-tools/config-tools.js +353 -0
  776. package/dist/src/mcp-tools/config-tools.js.map +1 -0
  777. package/dist/src/mcp-tools/coordination-tools.d.ts +13 -0
  778. package/dist/src/mcp-tools/coordination-tools.d.ts.map +1 -0
  779. package/dist/src/mcp-tools/coordination-tools.js +673 -0
  780. package/dist/src/mcp-tools/coordination-tools.js.map +1 -0
  781. package/dist/src/mcp-tools/daa-tools.d.ts +13 -0
  782. package/dist/src/mcp-tools/daa-tools.d.ts.map +1 -0
  783. package/dist/src/mcp-tools/daa-tools.js +473 -0
  784. package/dist/src/mcp-tools/daa-tools.js.map +1 -0
  785. package/dist/src/mcp-tools/embeddings-tools.d.ts +9 -0
  786. package/dist/src/mcp-tools/embeddings-tools.d.ts.map +1 -0
  787. package/dist/src/mcp-tools/embeddings-tools.js +782 -0
  788. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -0
  789. package/dist/src/mcp-tools/github-tools.d.ts +9 -0
  790. package/dist/src/mcp-tools/github-tools.d.ts.map +1 -0
  791. package/dist/src/mcp-tools/github-tools.js +472 -0
  792. package/dist/src/mcp-tools/github-tools.js.map +1 -0
  793. package/dist/src/mcp-tools/guidance-tools.d.ts +15 -0
  794. package/dist/src/mcp-tools/guidance-tools.d.ts.map +1 -0
  795. package/dist/src/mcp-tools/guidance-tools.js +618 -0
  796. package/dist/src/mcp-tools/guidance-tools.js.map +1 -0
  797. package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
  798. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -0
  799. package/dist/src/mcp-tools/hive-mind-tools.js +842 -0
  800. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -0
  801. package/dist/src/mcp-tools/hooks-tools.d.ts +44 -0
  802. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -0
  803. package/dist/src/mcp-tools/hooks-tools.js +3295 -0
  804. package/dist/src/mcp-tools/hooks-tools.js.map +1 -0
  805. package/dist/src/mcp-tools/index.d.ts +27 -0
  806. package/dist/src/mcp-tools/index.d.ts.map +1 -0
  807. package/dist/src/mcp-tools/index.js +26 -0
  808. package/dist/src/mcp-tools/index.js.map +1 -0
  809. package/dist/src/mcp-tools/memory-tools.d.ts +14 -0
  810. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -0
  811. package/dist/src/mcp-tools/memory-tools.js +512 -0
  812. package/dist/src/mcp-tools/memory-tools.js.map +1 -0
  813. package/dist/src/mcp-tools/neural-tools.d.ts +16 -0
  814. package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -0
  815. package/dist/src/mcp-tools/neural-tools.js +634 -0
  816. package/dist/src/mcp-tools/neural-tools.js.map +1 -0
  817. package/dist/src/mcp-tools/performance-tools.d.ts +16 -0
  818. package/dist/src/mcp-tools/performance-tools.d.ts.map +1 -0
  819. package/dist/src/mcp-tools/performance-tools.js +643 -0
  820. package/dist/src/mcp-tools/performance-tools.js.map +1 -0
  821. package/dist/src/mcp-tools/progress-tools.d.ts +14 -0
  822. package/dist/src/mcp-tools/progress-tools.d.ts.map +1 -0
  823. package/dist/src/mcp-tools/progress-tools.js +348 -0
  824. package/dist/src/mcp-tools/progress-tools.js.map +1 -0
  825. package/dist/src/mcp-tools/request-tracker.d.ts +17 -0
  826. package/dist/src/mcp-tools/request-tracker.d.ts.map +1 -0
  827. package/dist/src/mcp-tools/request-tracker.js +27 -0
  828. package/dist/src/mcp-tools/request-tracker.js.map +1 -0
  829. package/dist/src/mcp-tools/ruvllm-tools.d.ts +9 -0
  830. package/dist/src/mcp-tools/ruvllm-tools.d.ts.map +1 -0
  831. package/dist/src/mcp-tools/ruvllm-tools.js +284 -0
  832. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -0
  833. package/dist/src/mcp-tools/security-tools.d.ts +18 -0
  834. package/dist/src/mcp-tools/security-tools.d.ts.map +1 -0
  835. package/dist/src/mcp-tools/security-tools.js +434 -0
  836. package/dist/src/mcp-tools/security-tools.js.map +1 -0
  837. package/dist/src/mcp-tools/session-tools.d.ts +8 -0
  838. package/dist/src/mcp-tools/session-tools.d.ts.map +1 -0
  839. package/dist/src/mcp-tools/session-tools.js +338 -0
  840. package/dist/src/mcp-tools/session-tools.js.map +1 -0
  841. package/dist/src/mcp-tools/swarm-tools.d.ts +9 -0
  842. package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -0
  843. package/dist/src/mcp-tools/swarm-tools.js +289 -0
  844. package/dist/src/mcp-tools/swarm-tools.js.map +1 -0
  845. package/dist/src/mcp-tools/system-tools.d.ts +13 -0
  846. package/dist/src/mcp-tools/system-tools.d.ts.map +1 -0
  847. package/dist/src/mcp-tools/system-tools.js +551 -0
  848. package/dist/src/mcp-tools/system-tools.js.map +1 -0
  849. package/dist/src/mcp-tools/task-tools.d.ts +8 -0
  850. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -0
  851. package/dist/src/mcp-tools/task-tools.js +406 -0
  852. package/dist/src/mcp-tools/task-tools.js.map +1 -0
  853. package/dist/src/mcp-tools/terminal-tools.d.ts +8 -0
  854. package/dist/src/mcp-tools/terminal-tools.d.ts.map +1 -0
  855. package/dist/src/mcp-tools/terminal-tools.js +260 -0
  856. package/dist/src/mcp-tools/terminal-tools.js.map +1 -0
  857. package/dist/src/mcp-tools/transfer-tools.d.ts +14 -0
  858. package/dist/src/mcp-tools/transfer-tools.d.ts.map +1 -0
  859. package/dist/src/mcp-tools/transfer-tools.js +396 -0
  860. package/dist/src/mcp-tools/transfer-tools.js.map +1 -0
  861. package/dist/src/mcp-tools/types.d.ts +37 -0
  862. package/dist/src/mcp-tools/types.d.ts.map +1 -0
  863. package/dist/src/mcp-tools/types.js +14 -0
  864. package/dist/src/mcp-tools/types.js.map +1 -0
  865. package/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
  866. package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +1 -0
  867. package/dist/src/mcp-tools/wasm-agent-tools.js +230 -0
  868. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -0
  869. package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
  870. package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -0
  871. package/dist/src/mcp-tools/workflow-tools.js +562 -0
  872. package/dist/src/mcp-tools/workflow-tools.js.map +1 -0
  873. package/dist/src/memory/ewc-consolidation.d.ts +295 -0
  874. package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
  875. package/dist/src/memory/ewc-consolidation.js +601 -0
  876. package/dist/src/memory/ewc-consolidation.js.map +1 -0
  877. package/dist/src/memory/intelligence.d.ts +338 -0
  878. package/dist/src/memory/intelligence.d.ts.map +1 -0
  879. package/dist/src/memory/intelligence.js +1023 -0
  880. package/dist/src/memory/intelligence.js.map +1 -0
  881. package/dist/src/memory/memory-bridge.d.ts +407 -0
  882. package/dist/src/memory/memory-bridge.d.ts.map +1 -0
  883. package/dist/src/memory/memory-bridge.js +1500 -0
  884. package/dist/src/memory/memory-bridge.js.map +1 -0
  885. package/dist/src/memory/memory-initializer.d.ts +412 -0
  886. package/dist/src/memory/memory-initializer.d.ts.map +1 -0
  887. package/dist/src/memory/memory-initializer.js +2222 -0
  888. package/dist/src/memory/memory-initializer.js.map +1 -0
  889. package/dist/src/memory/sona-optimizer.d.ts +227 -0
  890. package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
  891. package/dist/src/memory/sona-optimizer.js +633 -0
  892. package/dist/src/memory/sona-optimizer.js.map +1 -0
  893. package/dist/src/model/complexity-scorer.d.ts +21 -0
  894. package/dist/src/model/complexity-scorer.d.ts.map +1 -0
  895. package/dist/src/model/complexity-scorer.js +106 -0
  896. package/dist/src/model/complexity-scorer.js.map +1 -0
  897. package/dist/src/model/index.d.ts +4 -0
  898. package/dist/src/model/index.d.ts.map +1 -0
  899. package/dist/src/model/index.js +4 -0
  900. package/dist/src/model/index.js.map +1 -0
  901. package/dist/src/model/model-settings.d.ts +22 -0
  902. package/dist/src/model/model-settings.d.ts.map +1 -0
  903. package/dist/src/model/model-settings.js +33 -0
  904. package/dist/src/model/model-settings.js.map +1 -0
  905. package/dist/src/model/model-tier-resolver.d.ts +24 -0
  906. package/dist/src/model/model-tier-resolver.d.ts.map +1 -0
  907. package/dist/src/model/model-tier-resolver.js +65 -0
  908. package/dist/src/model/model-tier-resolver.js.map +1 -0
  909. package/dist/src/orchestration/index.d.ts +7 -0
  910. package/dist/src/orchestration/index.d.ts.map +1 -0
  911. package/dist/src/orchestration/index.js +6 -0
  912. package/dist/src/orchestration/index.js.map +1 -0
  913. package/dist/src/orchestration/mode-dispatcher.d.ts +11 -0
  914. package/dist/src/orchestration/mode-dispatcher.d.ts.map +1 -0
  915. package/dist/src/orchestration/mode-dispatcher.js +31 -0
  916. package/dist/src/orchestration/mode-dispatcher.js.map +1 -0
  917. package/dist/src/orchestration/routing-modes.d.ts +68 -0
  918. package/dist/src/orchestration/routing-modes.d.ts.map +1 -0
  919. package/dist/src/orchestration/routing-modes.js +150 -0
  920. package/dist/src/orchestration/routing-modes.js.map +1 -0
  921. package/dist/src/output.d.ts +133 -0
  922. package/dist/src/output.d.ts.map +1 -0
  923. package/dist/src/output.js +514 -0
  924. package/dist/src/output.js.map +1 -0
  925. package/dist/src/parser.d.ts +51 -0
  926. package/dist/src/parser.d.ts.map +1 -0
  927. package/dist/src/parser.js +425 -0
  928. package/dist/src/parser.js.map +1 -0
  929. package/dist/src/plugins/manager.d.ts +133 -0
  930. package/dist/src/plugins/manager.d.ts.map +1 -0
  931. package/dist/src/plugins/manager.js +400 -0
  932. package/dist/src/plugins/manager.js.map +1 -0
  933. package/dist/src/plugins/store/discovery.d.ts +88 -0
  934. package/dist/src/plugins/store/discovery.d.ts.map +1 -0
  935. package/dist/src/plugins/store/discovery.js +1147 -0
  936. package/dist/src/plugins/store/discovery.js.map +1 -0
  937. package/dist/src/plugins/store/index.d.ts +76 -0
  938. package/dist/src/plugins/store/index.d.ts.map +1 -0
  939. package/dist/src/plugins/store/index.js +141 -0
  940. package/dist/src/plugins/store/index.js.map +1 -0
  941. package/dist/src/plugins/store/search.d.ts +46 -0
  942. package/dist/src/plugins/store/search.d.ts.map +1 -0
  943. package/dist/src/plugins/store/search.js +230 -0
  944. package/dist/src/plugins/store/search.js.map +1 -0
  945. package/dist/src/plugins/store/types.d.ts +274 -0
  946. package/dist/src/plugins/store/types.d.ts.map +1 -0
  947. package/dist/src/plugins/store/types.js +7 -0
  948. package/dist/src/plugins/store/types.js.map +1 -0
  949. package/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
  950. package/dist/src/plugins/tests/demo-plugin-store.d.ts.map +1 -0
  951. package/dist/src/plugins/tests/demo-plugin-store.js +126 -0
  952. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -0
  953. package/dist/src/plugins/tests/standalone-test.d.ts +12 -0
  954. package/dist/src/plugins/tests/standalone-test.d.ts.map +1 -0
  955. package/dist/src/plugins/tests/standalone-test.js +188 -0
  956. package/dist/src/plugins/tests/standalone-test.js.map +1 -0
  957. package/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
  958. package/dist/src/plugins/tests/test-plugin-store.d.ts.map +1 -0
  959. package/dist/src/plugins/tests/test-plugin-store.js +206 -0
  960. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -0
  961. package/dist/src/production/circuit-breaker.d.ts +101 -0
  962. package/dist/src/production/circuit-breaker.d.ts.map +1 -0
  963. package/dist/src/production/circuit-breaker.js +241 -0
  964. package/dist/src/production/circuit-breaker.js.map +1 -0
  965. package/dist/src/production/error-handler.d.ts +92 -0
  966. package/dist/src/production/error-handler.d.ts.map +1 -0
  967. package/dist/src/production/error-handler.js +299 -0
  968. package/dist/src/production/error-handler.js.map +1 -0
  969. package/dist/src/production/index.d.ts +23 -0
  970. package/dist/src/production/index.d.ts.map +1 -0
  971. package/dist/src/production/index.js +18 -0
  972. package/dist/src/production/index.js.map +1 -0
  973. package/dist/src/production/monitoring.d.ts +161 -0
  974. package/dist/src/production/monitoring.d.ts.map +1 -0
  975. package/dist/src/production/monitoring.js +356 -0
  976. package/dist/src/production/monitoring.js.map +1 -0
  977. package/dist/src/production/rate-limiter.d.ts +80 -0
  978. package/dist/src/production/rate-limiter.d.ts.map +1 -0
  979. package/dist/src/production/rate-limiter.js +201 -0
  980. package/dist/src/production/rate-limiter.js.map +1 -0
  981. package/dist/src/production/retry.d.ts +48 -0
  982. package/dist/src/production/retry.d.ts.map +1 -0
  983. package/dist/src/production/retry.js +179 -0
  984. package/dist/src/production/retry.js.map +1 -0
  985. package/dist/src/prompt.d.ts +44 -0
  986. package/dist/src/prompt.d.ts.map +1 -0
  987. package/dist/src/prompt.js +501 -0
  988. package/dist/src/prompt.js.map +1 -0
  989. package/dist/src/runtime/headless.d.ts +60 -0
  990. package/dist/src/runtime/headless.d.ts.map +1 -0
  991. package/dist/src/runtime/headless.js +284 -0
  992. package/dist/src/runtime/headless.js.map +1 -0
  993. package/dist/src/ruvector/agent-wasm.d.ts +182 -0
  994. package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
  995. package/dist/src/ruvector/agent-wasm.js +316 -0
  996. package/dist/src/ruvector/agent-wasm.js.map +1 -0
  997. package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
  998. package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
  999. package/dist/src/ruvector/ast-analyzer.js +277 -0
  1000. package/dist/src/ruvector/ast-analyzer.js.map +1 -0
  1001. package/dist/src/ruvector/coverage-router.d.ts +160 -0
  1002. package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
  1003. package/dist/src/ruvector/coverage-router.js +529 -0
  1004. package/dist/src/ruvector/coverage-router.js.map +1 -0
  1005. package/dist/src/ruvector/coverage-tools.d.ts +33 -0
  1006. package/dist/src/ruvector/coverage-tools.d.ts.map +1 -0
  1007. package/dist/src/ruvector/coverage-tools.js +157 -0
  1008. package/dist/src/ruvector/coverage-tools.js.map +1 -0
  1009. package/dist/src/ruvector/diff-classifier.d.ts +175 -0
  1010. package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
  1011. package/dist/src/ruvector/diff-classifier.js +698 -0
  1012. package/dist/src/ruvector/diff-classifier.js.map +1 -0
  1013. package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
  1014. package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
  1015. package/dist/src/ruvector/enhanced-model-router.js +529 -0
  1016. package/dist/src/ruvector/enhanced-model-router.js.map +1 -0
  1017. package/dist/src/ruvector/flash-attention.d.ts +195 -0
  1018. package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
  1019. package/dist/src/ruvector/flash-attention.js +643 -0
  1020. package/dist/src/ruvector/flash-attention.js.map +1 -0
  1021. package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
  1022. package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
  1023. package/dist/src/ruvector/graph-analyzer.js +929 -0
  1024. package/dist/src/ruvector/graph-analyzer.js.map +1 -0
  1025. package/dist/src/ruvector/index.d.ts +40 -0
  1026. package/dist/src/ruvector/index.d.ts.map +1 -0
  1027. package/dist/src/ruvector/index.js +76 -0
  1028. package/dist/src/ruvector/index.js.map +1 -0
  1029. package/dist/src/ruvector/lora-adapter.d.ts +218 -0
  1030. package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
  1031. package/dist/src/ruvector/lora-adapter.js +455 -0
  1032. package/dist/src/ruvector/lora-adapter.js.map +1 -0
  1033. package/dist/src/ruvector/model-router.d.ts +220 -0
  1034. package/dist/src/ruvector/model-router.d.ts.map +1 -0
  1035. package/dist/src/ruvector/model-router.js +488 -0
  1036. package/dist/src/ruvector/model-router.js.map +1 -0
  1037. package/dist/src/ruvector/moe-router.d.ts +206 -0
  1038. package/dist/src/ruvector/moe-router.d.ts.map +1 -0
  1039. package/dist/src/ruvector/moe-router.js +626 -0
  1040. package/dist/src/ruvector/moe-router.js.map +1 -0
  1041. package/dist/src/ruvector/q-learning-router.d.ts +211 -0
  1042. package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
  1043. package/dist/src/ruvector/q-learning-router.js +681 -0
  1044. package/dist/src/ruvector/q-learning-router.js.map +1 -0
  1045. package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
  1046. package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
  1047. package/dist/src/ruvector/ruvllm-wasm.js +363 -0
  1048. package/dist/src/ruvector/ruvllm-wasm.js.map +1 -0
  1049. package/dist/src/ruvector/semantic-router.d.ts +77 -0
  1050. package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
  1051. package/dist/src/ruvector/semantic-router.js +178 -0
  1052. package/dist/src/ruvector/semantic-router.js.map +1 -0
  1053. package/dist/src/ruvector/vector-db.d.ts +69 -0
  1054. package/dist/src/ruvector/vector-db.d.ts.map +1 -0
  1055. package/dist/src/ruvector/vector-db.js +243 -0
  1056. package/dist/src/ruvector/vector-db.js.map +1 -0
  1057. package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
  1058. package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
  1059. package/dist/src/services/agentic-flow-bridge.js +95 -0
  1060. package/dist/src/services/agentic-flow-bridge.js.map +1 -0
  1061. package/dist/src/services/claim-service.d.ts +204 -0
  1062. package/dist/src/services/claim-service.d.ts.map +1 -0
  1063. package/dist/src/services/claim-service.js +818 -0
  1064. package/dist/src/services/claim-service.js.map +1 -0
  1065. package/dist/src/services/config-file-manager.d.ts +37 -0
  1066. package/dist/src/services/config-file-manager.d.ts.map +1 -0
  1067. package/dist/src/services/config-file-manager.js +224 -0
  1068. package/dist/src/services/config-file-manager.js.map +1 -0
  1069. package/dist/src/services/container-worker-pool.d.ts +197 -0
  1070. package/dist/src/services/container-worker-pool.d.ts.map +1 -0
  1071. package/dist/src/services/container-worker-pool.js +583 -0
  1072. package/dist/src/services/container-worker-pool.js.map +1 -0
  1073. package/dist/src/services/headless-worker-executor.d.ts +304 -0
  1074. package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
  1075. package/dist/src/services/headless-worker-executor.js +1024 -0
  1076. package/dist/src/services/headless-worker-executor.js.map +1 -0
  1077. package/dist/src/services/index.d.ts +13 -0
  1078. package/dist/src/services/index.d.ts.map +1 -0
  1079. package/dist/src/services/index.js +11 -0
  1080. package/dist/src/services/index.js.map +1 -0
  1081. package/dist/src/services/registry-api.d.ts +58 -0
  1082. package/dist/src/services/registry-api.d.ts.map +1 -0
  1083. package/dist/src/services/registry-api.js +146 -0
  1084. package/dist/src/services/registry-api.js.map +1 -0
  1085. package/dist/src/services/ruvector-training.d.ts +222 -0
  1086. package/dist/src/services/ruvector-training.d.ts.map +1 -0
  1087. package/dist/src/services/ruvector-training.js +688 -0
  1088. package/dist/src/services/ruvector-training.js.map +1 -0
  1089. package/dist/src/services/worker-daemon.d.ts +245 -0
  1090. package/dist/src/services/worker-daemon.d.ts.map +1 -0
  1091. package/dist/src/services/worker-daemon.js +960 -0
  1092. package/dist/src/services/worker-daemon.js.map +1 -0
  1093. package/dist/src/services/worker-queue.d.ts +194 -0
  1094. package/dist/src/services/worker-queue.d.ts.map +1 -0
  1095. package/dist/src/services/worker-queue.js +513 -0
  1096. package/dist/src/services/worker-queue.js.map +1 -0
  1097. package/dist/src/suggest.d.ts +53 -0
  1098. package/dist/src/suggest.d.ts.map +1 -0
  1099. package/dist/src/suggest.js +200 -0
  1100. package/dist/src/suggest.js.map +1 -0
  1101. package/dist/src/swarm/communication-graph.d.ts +25 -0
  1102. package/dist/src/swarm/communication-graph.d.ts.map +1 -0
  1103. package/dist/src/swarm/communication-graph.js +77 -0
  1104. package/dist/src/swarm/communication-graph.js.map +1 -0
  1105. package/dist/src/swarm/flow-enforcer.d.ts +29 -0
  1106. package/dist/src/swarm/flow-enforcer.d.ts.map +1 -0
  1107. package/dist/src/swarm/flow-enforcer.js +49 -0
  1108. package/dist/src/swarm/flow-enforcer.js.map +1 -0
  1109. package/dist/src/swarm/flow-visualizer.d.ts +16 -0
  1110. package/dist/src/swarm/flow-visualizer.d.ts.map +1 -0
  1111. package/dist/src/swarm/flow-visualizer.js +44 -0
  1112. package/dist/src/swarm/flow-visualizer.js.map +1 -0
  1113. package/dist/src/transfer/anonymization/index.d.ts +25 -0
  1114. package/dist/src/transfer/anonymization/index.d.ts.map +1 -0
  1115. package/dist/src/transfer/anonymization/index.js +175 -0
  1116. package/dist/src/transfer/anonymization/index.js.map +1 -0
  1117. package/dist/src/transfer/deploy-seraphine.d.ts +13 -0
  1118. package/dist/src/transfer/deploy-seraphine.d.ts.map +1 -0
  1119. package/dist/src/transfer/deploy-seraphine.js +205 -0
  1120. package/dist/src/transfer/deploy-seraphine.js.map +1 -0
  1121. package/dist/src/transfer/export.d.ts +25 -0
  1122. package/dist/src/transfer/export.d.ts.map +1 -0
  1123. package/dist/src/transfer/export.js +113 -0
  1124. package/dist/src/transfer/export.js.map +1 -0
  1125. package/dist/src/transfer/index.d.ts +12 -0
  1126. package/dist/src/transfer/index.d.ts.map +1 -0
  1127. package/dist/src/transfer/index.js +31 -0
  1128. package/dist/src/transfer/index.js.map +1 -0
  1129. package/dist/src/transfer/ipfs/client.d.ts +109 -0
  1130. package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
  1131. package/dist/src/transfer/ipfs/client.js +307 -0
  1132. package/dist/src/transfer/ipfs/client.js.map +1 -0
  1133. package/dist/src/transfer/ipfs/upload.d.ts +95 -0
  1134. package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
  1135. package/dist/src/transfer/ipfs/upload.js +411 -0
  1136. package/dist/src/transfer/ipfs/upload.js.map +1 -0
  1137. package/dist/src/transfer/models/seraphine.d.ts +72 -0
  1138. package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
  1139. package/dist/src/transfer/models/seraphine.js +373 -0
  1140. package/dist/src/transfer/models/seraphine.js.map +1 -0
  1141. package/dist/src/transfer/serialization/cfp.d.ts +49 -0
  1142. package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
  1143. package/dist/src/transfer/serialization/cfp.js +183 -0
  1144. package/dist/src/transfer/serialization/cfp.js.map +1 -0
  1145. package/dist/src/transfer/storage/gcs.d.ts +82 -0
  1146. package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
  1147. package/dist/src/transfer/storage/gcs.js +272 -0
  1148. package/dist/src/transfer/storage/gcs.js.map +1 -0
  1149. package/dist/src/transfer/storage/index.d.ts +6 -0
  1150. package/dist/src/transfer/storage/index.d.ts.map +1 -0
  1151. package/dist/src/transfer/storage/index.js +6 -0
  1152. package/dist/src/transfer/storage/index.js.map +1 -0
  1153. package/dist/src/transfer/store/discovery.d.ts +84 -0
  1154. package/dist/src/transfer/store/discovery.d.ts.map +1 -0
  1155. package/dist/src/transfer/store/discovery.js +382 -0
  1156. package/dist/src/transfer/store/discovery.js.map +1 -0
  1157. package/dist/src/transfer/store/download.d.ts +70 -0
  1158. package/dist/src/transfer/store/download.d.ts.map +1 -0
  1159. package/dist/src/transfer/store/download.js +334 -0
  1160. package/dist/src/transfer/store/download.js.map +1 -0
  1161. package/dist/src/transfer/store/index.d.ts +84 -0
  1162. package/dist/src/transfer/store/index.d.ts.map +1 -0
  1163. package/dist/src/transfer/store/index.js +153 -0
  1164. package/dist/src/transfer/store/index.js.map +1 -0
  1165. package/dist/src/transfer/store/publish.d.ts +76 -0
  1166. package/dist/src/transfer/store/publish.d.ts.map +1 -0
  1167. package/dist/src/transfer/store/publish.js +294 -0
  1168. package/dist/src/transfer/store/publish.js.map +1 -0
  1169. package/dist/src/transfer/store/registry.d.ts +58 -0
  1170. package/dist/src/transfer/store/registry.d.ts.map +1 -0
  1171. package/dist/src/transfer/store/registry.js +285 -0
  1172. package/dist/src/transfer/store/registry.js.map +1 -0
  1173. package/dist/src/transfer/store/search.d.ts +54 -0
  1174. package/dist/src/transfer/store/search.d.ts.map +1 -0
  1175. package/dist/src/transfer/store/search.js +232 -0
  1176. package/dist/src/transfer/store/search.js.map +1 -0
  1177. package/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
  1178. package/dist/src/transfer/store/tests/standalone-test.d.ts.map +1 -0
  1179. package/dist/src/transfer/store/tests/standalone-test.js +190 -0
  1180. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -0
  1181. package/dist/src/transfer/store/types.d.ts +193 -0
  1182. package/dist/src/transfer/store/types.d.ts.map +1 -0
  1183. package/dist/src/transfer/store/types.js +6 -0
  1184. package/dist/src/transfer/store/types.js.map +1 -0
  1185. package/dist/src/transfer/test-seraphine.d.ts +6 -0
  1186. package/dist/src/transfer/test-seraphine.d.ts.map +1 -0
  1187. package/dist/src/transfer/test-seraphine.js +105 -0
  1188. package/dist/src/transfer/test-seraphine.js.map +1 -0
  1189. package/dist/src/transfer/tests/test-store.d.ts +7 -0
  1190. package/dist/src/transfer/tests/test-store.d.ts.map +1 -0
  1191. package/dist/src/transfer/tests/test-store.js +214 -0
  1192. package/dist/src/transfer/tests/test-store.js.map +1 -0
  1193. package/dist/src/transfer/types.d.ts +245 -0
  1194. package/dist/src/transfer/types.d.ts.map +1 -0
  1195. package/dist/src/transfer/types.js +6 -0
  1196. package/dist/src/transfer/types.js.map +1 -0
  1197. package/dist/src/types.d.ts +198 -0
  1198. package/dist/src/types.d.ts.map +1 -0
  1199. package/dist/src/types.js +38 -0
  1200. package/dist/src/types.js.map +1 -0
  1201. package/dist/src/update/checker.d.ts +34 -0
  1202. package/dist/src/update/checker.d.ts.map +1 -0
  1203. package/dist/src/update/checker.js +190 -0
  1204. package/dist/src/update/checker.js.map +1 -0
  1205. package/dist/src/update/executor.d.ts +32 -0
  1206. package/dist/src/update/executor.d.ts.map +1 -0
  1207. package/dist/src/update/executor.js +181 -0
  1208. package/dist/src/update/executor.js.map +1 -0
  1209. package/dist/src/update/index.d.ts +33 -0
  1210. package/dist/src/update/index.d.ts.map +1 -0
  1211. package/dist/src/update/index.js +64 -0
  1212. package/dist/src/update/index.js.map +1 -0
  1213. package/dist/src/update/rate-limiter.d.ts +20 -0
  1214. package/dist/src/update/rate-limiter.d.ts.map +1 -0
  1215. package/dist/src/update/rate-limiter.js +96 -0
  1216. package/dist/src/update/rate-limiter.js.map +1 -0
  1217. package/dist/src/update/validator.d.ts +17 -0
  1218. package/dist/src/update/validator.d.ts.map +1 -0
  1219. package/dist/src/update/validator.js +123 -0
  1220. package/dist/src/update/validator.js.map +1 -0
  1221. package/dist/src/workflow/condition-evaluator.d.ts +10 -0
  1222. package/dist/src/workflow/condition-evaluator.d.ts.map +1 -0
  1223. package/dist/src/workflow/condition-evaluator.js +48 -0
  1224. package/dist/src/workflow/condition-evaluator.js.map +1 -0
  1225. package/dist/src/workflow/context-resolver.d.ts +12 -0
  1226. package/dist/src/workflow/context-resolver.d.ts.map +1 -0
  1227. package/dist/src/workflow/context-resolver.js +23 -0
  1228. package/dist/src/workflow/context-resolver.js.map +1 -0
  1229. package/dist/src/workflow/dag-builder.d.ts +17 -0
  1230. package/dist/src/workflow/dag-builder.d.ts.map +1 -0
  1231. package/dist/src/workflow/dag-builder.js +113 -0
  1232. package/dist/src/workflow/dag-builder.js.map +1 -0
  1233. package/dist/src/workflow/dag-executor.d.ts +9 -0
  1234. package/dist/src/workflow/dag-executor.d.ts.map +1 -0
  1235. package/dist/src/workflow/dag-executor.js +78 -0
  1236. package/dist/src/workflow/dag-executor.js.map +1 -0
  1237. package/dist/src/workflow/dag-types.d.ts +41 -0
  1238. package/dist/src/workflow/dag-types.d.ts.map +1 -0
  1239. package/dist/src/workflow/dag-types.js +8 -0
  1240. package/dist/src/workflow/dag-types.js.map +1 -0
  1241. package/dist/src/workflow/dsl-parser.d.ts +12 -0
  1242. package/dist/src/workflow/dsl-parser.d.ts.map +1 -0
  1243. package/dist/src/workflow/dsl-parser.js +20 -0
  1244. package/dist/src/workflow/dsl-parser.js.map +1 -0
  1245. package/dist/src/workflow/dsl-schema.d.ts +54 -0
  1246. package/dist/src/workflow/dsl-schema.d.ts.map +1 -0
  1247. package/dist/src/workflow/dsl-schema.js +76 -0
  1248. package/dist/src/workflow/dsl-schema.js.map +1 -0
  1249. package/dist/src/workflow/index.d.ts +13 -0
  1250. package/dist/src/workflow/index.d.ts.map +1 -0
  1251. package/dist/src/workflow/index.js +11 -0
  1252. package/dist/src/workflow/index.js.map +1 -0
  1253. package/dist/src/workflow/template-engine.d.ts +11 -0
  1254. package/dist/src/workflow/template-engine.d.ts.map +1 -0
  1255. package/dist/src/workflow/template-engine.js +33 -0
  1256. package/dist/src/workflow/template-engine.js.map +1 -0
  1257. package/dist/src/workflow/workflow-executor.d.ts +29 -0
  1258. package/dist/src/workflow/workflow-executor.d.ts.map +1 -0
  1259. package/dist/src/workflow/workflow-executor.js +142 -0
  1260. package/dist/src/workflow/workflow-executor.js.map +1 -0
  1261. package/dist/tsconfig.tsbuildinfo +1 -0
  1262. package/package.json +113 -0
@@ -0,0 +1,2048 @@
1
+ /**
2
+ * CLI Analyze Command
3
+ * Code analysis, diff classification, AST analysis, and change risk assessment
4
+ *
5
+ * Features:
6
+ * - AST analysis using ruvector (tree-sitter) with graceful fallback
7
+ * - Symbol extraction (functions, classes, variables, types)
8
+ * - Cyclomatic complexity scoring
9
+ * - Diff classification and risk assessment
10
+ * - Graph boundaries using MinCut algorithm
11
+ * - Module communities using Louvain algorithm
12
+ * - Circular dependency detection
13
+ *
14
+ * github.com/nokhodian/monobrain
15
+ */
16
+ import { output } from '../output.js';
17
+ import { callMCPTool, MCPClientError } from '../mcp-client.js';
18
+ import * as path from 'path';
19
+ import * as fs from 'fs/promises';
20
+ import { writeFile } from 'fs/promises';
21
+ import { resolve } from 'path';
22
+ import { execSync } from 'child_process';
23
+ // Dynamic import for AST analyzer
24
+ async function getASTAnalyzer() {
25
+ try {
26
+ return await import('../ruvector/ast-analyzer.js');
27
+ }
28
+ catch {
29
+ return null;
30
+ }
31
+ }
32
+ // Dynamic import for graph analyzer
33
+ async function getGraphAnalyzer() {
34
+ try {
35
+ return await import('../ruvector/graph-analyzer.js');
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ }
41
+ // Diff subcommand
42
+ const diffCommand = {
43
+ name: 'diff',
44
+ description: 'Analyze git diff for change risk assessment and classification',
45
+ options: [
46
+ {
47
+ name: 'risk',
48
+ short: 'r',
49
+ description: 'Show risk assessment',
50
+ type: 'boolean',
51
+ default: false,
52
+ },
53
+ {
54
+ name: 'classify',
55
+ short: 'c',
56
+ description: 'Classify change type',
57
+ type: 'boolean',
58
+ default: false,
59
+ },
60
+ {
61
+ name: 'reviewers',
62
+ description: 'Show recommended reviewers',
63
+ type: 'boolean',
64
+ default: false,
65
+ },
66
+ {
67
+ name: 'format',
68
+ short: 'f',
69
+ description: 'Output format: text, json, table',
70
+ type: 'string',
71
+ default: 'text',
72
+ choices: ['text', 'json', 'table'],
73
+ },
74
+ {
75
+ name: 'verbose',
76
+ short: 'v',
77
+ description: 'Show detailed file-level analysis',
78
+ type: 'boolean',
79
+ default: false,
80
+ },
81
+ ],
82
+ examples: [
83
+ { command: 'monobrain analyze diff --risk', description: 'Analyze current diff with risk assessment' },
84
+ { command: 'monobrain analyze diff HEAD~1 --classify', description: 'Classify changes from last commit' },
85
+ { command: 'monobrain analyze diff main..feature --format json', description: 'Compare branches with JSON output' },
86
+ { command: 'monobrain analyze diff --reviewers', description: 'Get recommended reviewers for changes' },
87
+ ],
88
+ action: async (ctx) => {
89
+ const ref = ctx.args[0] || 'HEAD';
90
+ const showRisk = ctx.flags.risk;
91
+ const showClassify = ctx.flags.classify;
92
+ const showReviewers = ctx.flags.reviewers;
93
+ const formatType = ctx.flags.format || 'text';
94
+ const verbose = ctx.flags.verbose;
95
+ // If no specific flag, show all
96
+ const showAll = !showRisk && !showClassify && !showReviewers;
97
+ output.printInfo(`Analyzing diff: ${output.highlight(ref)}`);
98
+ try {
99
+ // Call MCP tool for diff analysis
100
+ const result = await callMCPTool('analyze_diff', {
101
+ ref,
102
+ includeFileRisks: verbose,
103
+ includeReviewers: showReviewers || showAll,
104
+ });
105
+ // JSON output
106
+ if (formatType === 'json') {
107
+ output.printJson(result);
108
+ return { success: true, data: result };
109
+ }
110
+ output.writeln();
111
+ // Summary box
112
+ const files = result.files || [];
113
+ const risk = result.risk || { overall: 'unknown', score: 0, breakdown: { fileCount: 0, totalChanges: 0, highRiskFiles: [], securityConcerns: [], breakingChanges: [], testCoverage: 'unknown' } };
114
+ const classification = result.classification || { category: 'unknown', confidence: 0, reasoning: '' };
115
+ output.printBox([
116
+ `Ref: ${result.ref || 'HEAD'}`,
117
+ `Files: ${files.length}`,
118
+ `Risk: ${getRiskDisplay(risk.overall)} (${risk.score}/100)`,
119
+ `Type: ${classification.category}${classification.subcategory ? ` (${classification.subcategory})` : ''}`,
120
+ ``,
121
+ result.summary || 'No summary available',
122
+ ].join('\n'), 'Diff Analysis');
123
+ // Risk assessment
124
+ if (showRisk || showAll) {
125
+ output.writeln();
126
+ output.writeln(output.bold('Risk Assessment'));
127
+ output.writeln(output.dim('-'.repeat(50)));
128
+ output.printTable({
129
+ columns: [
130
+ { key: 'metric', header: 'Metric', width: 25 },
131
+ { key: 'value', header: 'Value', width: 30 },
132
+ ],
133
+ data: [
134
+ { metric: 'Overall Risk', value: getRiskDisplay(risk.overall) },
135
+ { metric: 'Risk Score', value: `${risk.score}/100` },
136
+ { metric: 'Files Changed', value: risk.breakdown.fileCount },
137
+ { metric: 'Total Lines Changed', value: risk.breakdown.totalChanges },
138
+ { metric: 'Test Coverage', value: risk.breakdown.testCoverage },
139
+ ],
140
+ });
141
+ // Security concerns
142
+ if (risk.breakdown.securityConcerns.length > 0) {
143
+ output.writeln();
144
+ output.writeln(output.bold(output.warning('Security Concerns')));
145
+ output.printList(risk.breakdown.securityConcerns.map(c => output.warning(c)));
146
+ }
147
+ // Breaking changes
148
+ if (risk.breakdown.breakingChanges.length > 0) {
149
+ output.writeln();
150
+ output.writeln(output.bold(output.error('Potential Breaking Changes')));
151
+ output.printList(risk.breakdown.breakingChanges.map(c => output.error(c)));
152
+ }
153
+ // High risk files
154
+ if (risk.breakdown.highRiskFiles.length > 0) {
155
+ output.writeln();
156
+ output.writeln(output.bold('High Risk Files'));
157
+ output.printList(risk.breakdown.highRiskFiles.map(f => output.warning(f)));
158
+ }
159
+ }
160
+ // Classification
161
+ if (showClassify || showAll) {
162
+ output.writeln();
163
+ output.writeln(output.bold('Classification'));
164
+ output.writeln(output.dim('-'.repeat(50)));
165
+ output.printTable({
166
+ columns: [
167
+ { key: 'field', header: 'Field', width: 15 },
168
+ { key: 'value', header: 'Value', width: 40 },
169
+ ],
170
+ data: [
171
+ { field: 'Category', value: classification.category },
172
+ { field: 'Subcategory', value: classification.subcategory || '-' },
173
+ { field: 'Confidence', value: `${(classification.confidence * 100).toFixed(0)}%` },
174
+ ],
175
+ });
176
+ output.writeln();
177
+ output.writeln(output.dim(`Reasoning: ${classification.reasoning}`));
178
+ }
179
+ // Reviewers
180
+ if (showReviewers || showAll) {
181
+ output.writeln();
182
+ output.writeln(output.bold('Recommended Reviewers'));
183
+ output.writeln(output.dim('-'.repeat(50)));
184
+ const reviewers = result.recommendedReviewers || [];
185
+ if (reviewers.length > 0) {
186
+ output.printNumberedList(reviewers.map(r => output.highlight(r)));
187
+ }
188
+ else {
189
+ output.writeln(output.dim('No specific reviewers recommended'));
190
+ }
191
+ }
192
+ // Verbose file-level details
193
+ if (verbose && result.fileRisks) {
194
+ output.writeln();
195
+ output.writeln(output.bold('File-Level Analysis'));
196
+ output.writeln(output.dim('-'.repeat(50)));
197
+ output.printTable({
198
+ columns: [
199
+ { key: 'path', header: 'File', width: 40 },
200
+ { key: 'risk', header: 'Risk', width: 12, format: (v) => getRiskDisplay(String(v)) },
201
+ { key: 'score', header: 'Score', width: 8, align: 'right' },
202
+ { key: 'reasons', header: 'Reasons', width: 30, format: (v) => {
203
+ const reasons = v;
204
+ return reasons.slice(0, 2).join('; ');
205
+ } },
206
+ ],
207
+ data: result.fileRisks,
208
+ });
209
+ }
210
+ // Files changed table
211
+ if (formatType === 'table' || showAll) {
212
+ output.writeln();
213
+ output.writeln(output.bold('Files Changed'));
214
+ output.writeln(output.dim('-'.repeat(50)));
215
+ output.printTable({
216
+ columns: [
217
+ { key: 'status', header: 'Status', width: 10, format: (v) => getStatusDisplay(String(v)) },
218
+ { key: 'path', header: 'File', width: 45 },
219
+ { key: 'additions', header: '+', width: 8, align: 'right', format: (v) => output.success(`+${v}`) },
220
+ { key: 'deletions', header: '-', width: 8, align: 'right', format: (v) => output.error(`-${v}`) },
221
+ ],
222
+ data: files.slice(0, 20),
223
+ });
224
+ if (files.length > 20) {
225
+ output.writeln(output.dim(` ... and ${files.length - 20} more files`));
226
+ }
227
+ }
228
+ return { success: true, data: result };
229
+ }
230
+ catch (error) {
231
+ if (error instanceof MCPClientError) {
232
+ output.printError(`Diff analysis failed: ${error.message}`);
233
+ }
234
+ else {
235
+ output.printError(`Unexpected error: ${String(error)}`);
236
+ }
237
+ return { success: false, exitCode: 1 };
238
+ }
239
+ },
240
+ };
241
+ // Code subcommand (placeholder for future code analysis)
242
+ const codeCommand = {
243
+ name: 'code',
244
+ description: 'Static code analysis and quality assessment',
245
+ options: [
246
+ { name: 'path', short: 'p', type: 'string', description: 'Path to analyze', default: '.' },
247
+ { name: 'type', short: 't', type: 'string', description: 'Analysis type: quality, complexity, security', default: 'quality' },
248
+ { name: 'format', short: 'f', type: 'string', description: 'Output format: text, json', default: 'text' },
249
+ ],
250
+ examples: [
251
+ { command: 'monobrain analyze code -p ./src', description: 'Analyze source directory' },
252
+ { command: 'monobrain analyze code --type complexity', description: 'Run complexity analysis' },
253
+ ],
254
+ action: async (ctx) => {
255
+ const targetPath = resolve(ctx.flags.path || '.');
256
+ const analysisType = ctx.flags.type || 'quality';
257
+ const formatJson = ctx.flags.format === 'json';
258
+ output.writeln();
259
+ output.writeln(output.bold('Code Analysis'));
260
+ output.writeln(output.dim('-'.repeat(50)));
261
+ const spinner = output.createSpinner({ text: `Analyzing ${targetPath}...`, spinner: 'dots' });
262
+ spinner.start();
263
+ try {
264
+ const files = await scanSourceFiles(targetPath);
265
+ if (files.length === 0) {
266
+ spinner.stop();
267
+ output.printWarning('No source files found');
268
+ return { success: true };
269
+ }
270
+ const fileStats = [];
271
+ for (const filePath of files) {
272
+ const content = await fs.readFile(filePath, 'utf-8');
273
+ const lines = content.split('\n');
274
+ const nonEmpty = lines.filter(l => l.trim().length > 0 && !/^\s*(\/\/|\/\*|\*\s|#)/.test(l)).length;
275
+ const todos = (content.match(/\b(TODO|FIXME|HACK|XXX)\b/gi) || []).length;
276
+ const fns = (content.match(/(?:export\s+)?(?:async\s+)?function\s+\w+|(?:const|let|var)\s+\w+\s*=\s*(?:async\s+)?\([^)]*\)\s*=>/g) || []).length;
277
+ const imps = (content.match(/^import\s+/gm) || []).length + (content.match(/require\s*\(/g) || []).length;
278
+ let maxNesting = 0;
279
+ let nesting = 0;
280
+ for (const line of lines) {
281
+ nesting += (line.match(/\{/g) || []).length;
282
+ nesting -= (line.match(/\}/g) || []).length;
283
+ if (nesting > maxNesting)
284
+ maxNesting = nesting;
285
+ }
286
+ const securityIssues = [];
287
+ if (/\beval\s*\(/.test(content))
288
+ securityIssues.push('eval()');
289
+ if (/\bexec\s*\(/.test(content))
290
+ securityIssues.push('exec()');
291
+ if (/\.innerHTML\s*=/.test(content))
292
+ securityIssues.push('innerHTML');
293
+ if (/dangerouslySetInnerHTML/.test(content))
294
+ securityIssues.push('dangerouslySetInnerHTML');
295
+ if (/['"](?:password|secret|api[_-]?key|token)\s*[:=]\s*['"][^'"]{3,}['"]/i.test(content))
296
+ securityIssues.push('hardcoded secret');
297
+ if (/new\s+Function\s*\(/.test(content))
298
+ securityIssues.push('new Function()');
299
+ fileStats.push({
300
+ file: filePath,
301
+ loc: nonEmpty,
302
+ todos,
303
+ functions: fns,
304
+ imports: imps,
305
+ maxNesting,
306
+ securityIssues,
307
+ });
308
+ }
309
+ spinner.stop();
310
+ const totalLoc = fileStats.reduce((s, f) => s + f.loc, 0);
311
+ const totalTodos = fileStats.reduce((s, f) => s + f.todos, 0);
312
+ const totalFunctions = fileStats.reduce((s, f) => s + f.functions, 0);
313
+ const totalImports = fileStats.reduce((s, f) => s + f.imports, 0);
314
+ const avgFileSize = Math.round(totalLoc / files.length);
315
+ const longestFile = fileStats.reduce((a, b) => a.loc > b.loc ? a : b);
316
+ const avgFnPerFile = (totalFunctions / files.length).toFixed(1);
317
+ const deepestNesting = fileStats.reduce((a, b) => a.maxNesting > b.maxNesting ? a : b);
318
+ const allSecurityIssues = fileStats.filter(f => f.securityIssues.length > 0);
319
+ if (formatJson) {
320
+ const jsonData = { type: analysisType, path: targetPath, files: files.length, totalLoc, totalTodos, totalFunctions, totalImports, avgFileSize, fileStats: fileStats.map(f => ({ relativePath: path.relative(targetPath, f.file), loc: f.loc, todos: f.todos, functions: f.functions, imports: f.imports, maxNesting: f.maxNesting, securityIssues: f.securityIssues })) };
321
+ output.printJson(jsonData);
322
+ return { success: true, data: jsonData };
323
+ }
324
+ if (analysisType === 'quality') {
325
+ output.printBox([`Files: ${files.length}`, `Lines of Code: ${totalLoc.toLocaleString()}`, `Avg File Size: ${avgFileSize} LOC`, `TODO/FIXME: ${totalTodos}`, `Functions: ${totalFunctions}`, `Imports: ${totalImports}`].join('\n'), 'Quality Summary');
326
+ output.writeln();
327
+ output.writeln(output.bold('Largest Files'));
328
+ output.writeln(output.dim('-'.repeat(60)));
329
+ const top10 = [...fileStats].sort((a, b) => b.loc - a.loc).slice(0, 10);
330
+ output.printTable({
331
+ columns: [
332
+ { key: 'file', header: 'File', width: 45 },
333
+ { key: 'loc', header: 'LOC', width: 8, align: 'right' },
334
+ { key: 'fns', header: 'Fns', width: 6, align: 'right' },
335
+ { key: 'todos', header: 'TODOs', width: 7, align: 'right' },
336
+ ],
337
+ data: top10.map(f => ({ file: path.relative(targetPath, f.file), loc: f.loc, fns: f.functions, todos: f.todos })),
338
+ });
339
+ if (totalTodos > 0) {
340
+ output.writeln();
341
+ output.printWarning(`${totalTodos} TODO/FIXME comments found across ${fileStats.filter(f => f.todos > 0).length} files`);
342
+ }
343
+ }
344
+ else if (analysisType === 'complexity') {
345
+ output.printBox([`Files: ${files.length}`, `Total Functions: ${totalFunctions}`, `Avg Functions/File: ${avgFnPerFile}`, `Deepest Nesting: ${deepestNesting.maxNesting} levels (${path.relative(targetPath, deepestNesting.file)})`, `Longest File: ${longestFile.loc} LOC (${path.relative(targetPath, longestFile.file)})`].join('\n'), 'Complexity Summary');
346
+ output.writeln();
347
+ output.writeln(output.bold('High Complexity Files (nesting > 5)'));
348
+ output.writeln(output.dim('-'.repeat(60)));
349
+ const complex = fileStats.filter(f => f.maxNesting > 5).sort((a, b) => b.maxNesting - a.maxNesting);
350
+ if (complex.length === 0) {
351
+ output.printSuccess('No files with excessive nesting detected');
352
+ }
353
+ else {
354
+ output.printTable({
355
+ columns: [
356
+ { key: 'file', header: 'File', width: 45 },
357
+ { key: 'nesting', header: 'Max Nest', width: 10, align: 'right' },
358
+ { key: 'fns', header: 'Fns', width: 6, align: 'right' },
359
+ { key: 'loc', header: 'LOC', width: 8, align: 'right' },
360
+ ],
361
+ data: complex.slice(0, 15).map(f => ({ file: path.relative(targetPath, f.file), nesting: f.maxNesting, fns: f.functions, loc: f.loc })),
362
+ });
363
+ }
364
+ }
365
+ else if (analysisType === 'security') {
366
+ output.printBox([`Files Scanned: ${files.length}`, `Files with Issues: ${allSecurityIssues.length}`, `Total Issues: ${allSecurityIssues.reduce((s, f) => s + f.securityIssues.length, 0)}`].join('\n'), 'Security Summary');
367
+ if (allSecurityIssues.length === 0) {
368
+ output.writeln();
369
+ output.printSuccess('No common security patterns detected');
370
+ }
371
+ else {
372
+ output.writeln();
373
+ output.writeln(output.bold('Security Concerns'));
374
+ output.writeln(output.dim('-'.repeat(60)));
375
+ output.printTable({
376
+ columns: [
377
+ { key: 'file', header: 'File', width: 40 },
378
+ { key: 'issues', header: 'Issues', width: 35 },
379
+ ],
380
+ data: allSecurityIssues.map(f => ({ file: path.relative(targetPath, f.file), issues: f.securityIssues.join(', ') })),
381
+ });
382
+ }
383
+ }
384
+ else {
385
+ output.printWarning(`Unknown analysis type: ${analysisType}. Use quality, complexity, or security.`);
386
+ }
387
+ return { success: true };
388
+ }
389
+ catch (error) {
390
+ spinner.stop();
391
+ const message = error instanceof Error ? error.message : String(error);
392
+ output.printError(`Code analysis failed: ${message}`);
393
+ return { success: false, exitCode: 1 };
394
+ }
395
+ },
396
+ };
397
+ // ============================================================================
398
+ // AST Analysis Subcommands (using ruvector tree-sitter with fallback)
399
+ // ============================================================================
400
+ /**
401
+ * Helper: Truncate file path for display
402
+ */
403
+ function truncatePathAst(filePath, maxLen = 45) {
404
+ if (filePath.length <= maxLen)
405
+ return filePath;
406
+ return '...' + filePath.slice(-(maxLen - 3));
407
+ }
408
+ /**
409
+ * Helper: Format complexity value with color coding
410
+ */
411
+ function formatComplexityValueAst(value) {
412
+ if (value <= 5)
413
+ return output.success(String(value));
414
+ if (value <= 10)
415
+ return output.warning(String(value));
416
+ return output.error(String(value));
417
+ }
418
+ /**
419
+ * Helper: Get type marker for symbols
420
+ */
421
+ function getTypeMarkerAst(type) {
422
+ switch (type) {
423
+ case 'function': return output.success('fn');
424
+ case 'class': return output.info('class');
425
+ case 'variable': return output.dim('var');
426
+ case 'type': return output.highlight('type');
427
+ case 'interface': return output.highlight('iface');
428
+ default: return output.dim(type.slice(0, 5));
429
+ }
430
+ }
431
+ /**
432
+ * Helper: Get complexity rating text
433
+ */
434
+ function getComplexityRatingAst(value) {
435
+ if (value <= 5)
436
+ return output.success('Simple');
437
+ if (value <= 10)
438
+ return output.warning('Moderate');
439
+ if (value <= 20)
440
+ return output.error('Complex');
441
+ return output.error(output.bold('Very Complex'));
442
+ }
443
+ /**
444
+ * AST analysis subcommand
445
+ */
446
+ const astCommand = {
447
+ name: 'ast',
448
+ description: 'Analyze code using AST parsing (tree-sitter via ruvector)',
449
+ options: [
450
+ {
451
+ name: 'complexity',
452
+ short: 'c',
453
+ description: 'Include complexity metrics',
454
+ type: 'boolean',
455
+ default: false,
456
+ },
457
+ {
458
+ name: 'symbols',
459
+ short: 's',
460
+ description: 'Include symbol extraction',
461
+ type: 'boolean',
462
+ default: false,
463
+ },
464
+ {
465
+ name: 'format',
466
+ short: 'f',
467
+ description: 'Output format (text, json, table)',
468
+ type: 'string',
469
+ default: 'text',
470
+ choices: ['text', 'json', 'table'],
471
+ },
472
+ {
473
+ name: 'output',
474
+ short: 'o',
475
+ description: 'Output file path',
476
+ type: 'string',
477
+ },
478
+ {
479
+ name: 'verbose',
480
+ short: 'v',
481
+ description: 'Show detailed analysis',
482
+ type: 'boolean',
483
+ default: false,
484
+ },
485
+ ],
486
+ examples: [
487
+ { command: 'monobrain analyze ast src/', description: 'Analyze all files in src/' },
488
+ { command: 'monobrain analyze ast src/index.ts --complexity', description: 'Analyze with complexity' },
489
+ { command: 'monobrain analyze ast . --format json', description: 'JSON output' },
490
+ { command: 'monobrain analyze ast src/ --symbols', description: 'Extract symbols' },
491
+ ],
492
+ action: async (ctx) => {
493
+ const targetPath = ctx.args[0] || ctx.cwd;
494
+ const showComplexity = ctx.flags.complexity;
495
+ const showSymbols = ctx.flags.symbols;
496
+ const formatType = ctx.flags.format || 'text';
497
+ const outputFile = ctx.flags.output;
498
+ const verbose = ctx.flags.verbose;
499
+ // If no specific flags, show summary
500
+ const showAll = !showComplexity && !showSymbols;
501
+ output.printInfo(`Analyzing: ${output.highlight(targetPath)}`);
502
+ output.writeln();
503
+ const spinner = output.createSpinner({ text: 'Parsing AST...', spinner: 'dots' });
504
+ spinner.start();
505
+ try {
506
+ const astModule = await getASTAnalyzer();
507
+ if (!astModule) {
508
+ spinner.stop();
509
+ output.printWarning('AST analyzer not available, using regex fallback');
510
+ }
511
+ // Resolve path and check if file or directory
512
+ const resolvedPath = resolve(targetPath);
513
+ const stat = await fs.stat(resolvedPath);
514
+ const isDirectory = stat.isDirectory();
515
+ let results = [];
516
+ if (isDirectory) {
517
+ // Scan directory for source files
518
+ const files = await scanSourceFiles(resolvedPath);
519
+ spinner.stop();
520
+ output.printInfo(`Found ${files.length} source files`);
521
+ spinner.start();
522
+ for (const file of files.slice(0, 100)) {
523
+ try {
524
+ const content = await fs.readFile(file, 'utf-8');
525
+ if (astModule) {
526
+ const analyzer = astModule.createASTAnalyzer();
527
+ const analysis = analyzer.analyze(content, file);
528
+ results.push(analysis);
529
+ }
530
+ else {
531
+ // Fallback analysis
532
+ results.push(fallbackAnalyze(content, file));
533
+ }
534
+ }
535
+ catch {
536
+ // Skip files that can't be analyzed
537
+ }
538
+ }
539
+ }
540
+ else {
541
+ // Single file
542
+ const content = await fs.readFile(resolvedPath, 'utf-8');
543
+ if (astModule) {
544
+ const analyzer = astModule.createASTAnalyzer();
545
+ const analysis = analyzer.analyze(content, resolvedPath);
546
+ results.push(analysis);
547
+ }
548
+ else {
549
+ results.push(fallbackAnalyze(content, resolvedPath));
550
+ }
551
+ }
552
+ spinner.stop();
553
+ if (results.length === 0) {
554
+ output.printWarning('No files analyzed');
555
+ return { success: true };
556
+ }
557
+ // Calculate totals
558
+ const totals = {
559
+ files: results.length,
560
+ functions: results.reduce((sum, r) => sum + r.functions.length, 0),
561
+ classes: results.reduce((sum, r) => sum + r.classes.length, 0),
562
+ imports: results.reduce((sum, r) => sum + r.imports.length, 0),
563
+ avgComplexity: results.reduce((sum, r) => sum + r.complexity.cyclomatic, 0) / results.length,
564
+ totalLoc: results.reduce((sum, r) => sum + r.complexity.loc, 0),
565
+ };
566
+ // JSON output
567
+ if (formatType === 'json') {
568
+ const jsonOutput = { files: results, totals };
569
+ if (outputFile) {
570
+ await writeFile(outputFile, JSON.stringify(jsonOutput, null, 2));
571
+ output.printSuccess(`Results written to ${outputFile}`);
572
+ }
573
+ else {
574
+ output.printJson(jsonOutput);
575
+ }
576
+ return { success: true, data: jsonOutput };
577
+ }
578
+ // Summary box
579
+ output.printBox([
580
+ `Files analyzed: ${totals.files}`,
581
+ `Functions: ${totals.functions}`,
582
+ `Classes: ${totals.classes}`,
583
+ `Total LOC: ${totals.totalLoc}`,
584
+ `Avg Complexity: ${formatComplexityValueAst(Math.round(totals.avgComplexity))}`,
585
+ ].join('\n'), 'AST Analysis Summary');
586
+ // Complexity view
587
+ if (showComplexity || showAll) {
588
+ output.writeln();
589
+ output.writeln(output.bold('Complexity by File'));
590
+ output.writeln(output.dim('-'.repeat(60)));
591
+ const complexityData = results
592
+ .map(r => ({
593
+ file: truncatePathAst(r.filePath),
594
+ cyclomatic: r.complexity.cyclomatic,
595
+ cognitive: r.complexity.cognitive,
596
+ loc: r.complexity.loc,
597
+ rating: getComplexityRatingAst(r.complexity.cyclomatic),
598
+ }))
599
+ .sort((a, b) => b.cyclomatic - a.cyclomatic)
600
+ .slice(0, 15);
601
+ output.printTable({
602
+ columns: [
603
+ { key: 'file', header: 'File', width: 40 },
604
+ { key: 'cyclomatic', header: 'Cyclo', width: 8, align: 'right', format: (v) => formatComplexityValueAst(v) },
605
+ { key: 'cognitive', header: 'Cogni', width: 8, align: 'right' },
606
+ { key: 'loc', header: 'LOC', width: 8, align: 'right' },
607
+ { key: 'rating', header: 'Rating', width: 15 },
608
+ ],
609
+ data: complexityData,
610
+ });
611
+ if (results.length > 15) {
612
+ output.writeln(output.dim(` ... and ${results.length - 15} more files`));
613
+ }
614
+ }
615
+ // Symbols view
616
+ if (showSymbols || showAll) {
617
+ output.writeln();
618
+ output.writeln(output.bold('Extracted Symbols'));
619
+ output.writeln(output.dim('-'.repeat(60)));
620
+ const allSymbols = [];
621
+ for (const r of results) {
622
+ for (const fn of r.functions) {
623
+ allSymbols.push({ name: fn.name, type: 'function', file: truncatePathAst(r.filePath, 30), line: fn.startLine });
624
+ }
625
+ for (const cls of r.classes) {
626
+ allSymbols.push({ name: cls.name, type: 'class', file: truncatePathAst(r.filePath, 30), line: cls.startLine });
627
+ }
628
+ }
629
+ const displaySymbols = allSymbols.slice(0, 20);
630
+ output.printTable({
631
+ columns: [
632
+ { key: 'type', header: 'Type', width: 8, format: (v) => getTypeMarkerAst(v) },
633
+ { key: 'name', header: 'Symbol', width: 30 },
634
+ { key: 'file', header: 'File', width: 35 },
635
+ { key: 'line', header: 'Line', width: 8, align: 'right' },
636
+ ],
637
+ data: displaySymbols,
638
+ });
639
+ if (allSymbols.length > 20) {
640
+ output.writeln(output.dim(` ... and ${allSymbols.length - 20} more symbols`));
641
+ }
642
+ }
643
+ // Verbose output
644
+ if (verbose) {
645
+ output.writeln();
646
+ output.writeln(output.bold('Import Analysis'));
647
+ output.writeln(output.dim('-'.repeat(60)));
648
+ const importCounts = new Map();
649
+ for (const r of results) {
650
+ for (const imp of r.imports) {
651
+ importCounts.set(imp, (importCounts.get(imp) || 0) + 1);
652
+ }
653
+ }
654
+ const topImports = Array.from(importCounts.entries())
655
+ .sort((a, b) => b[1] - a[1])
656
+ .slice(0, 10);
657
+ for (const [imp, count] of topImports) {
658
+ output.writeln(` ${output.highlight(count.toString().padStart(3))} ${imp}`);
659
+ }
660
+ }
661
+ if (outputFile) {
662
+ await writeFile(outputFile, JSON.stringify({ files: results, totals }, null, 2));
663
+ output.printSuccess(`Results written to ${outputFile}`);
664
+ }
665
+ return { success: true, data: { files: results, totals } };
666
+ }
667
+ catch (error) {
668
+ spinner.stop();
669
+ const message = error instanceof Error ? error.message : String(error);
670
+ output.printError(`AST analysis failed: ${message}`);
671
+ return { success: false, exitCode: 1 };
672
+ }
673
+ },
674
+ };
675
+ /**
676
+ * Complexity analysis subcommand
677
+ */
678
+ const complexityAstCommand = {
679
+ name: 'complexity',
680
+ aliases: ['cx'],
681
+ description: 'Analyze code complexity metrics',
682
+ options: [
683
+ {
684
+ name: 'threshold',
685
+ short: 't',
686
+ description: 'Complexity threshold to flag (default: 10)',
687
+ type: 'number',
688
+ default: 10,
689
+ },
690
+ {
691
+ name: 'format',
692
+ short: 'f',
693
+ description: 'Output format (text, json)',
694
+ type: 'string',
695
+ default: 'text',
696
+ choices: ['text', 'json'],
697
+ },
698
+ {
699
+ name: 'output',
700
+ short: 'o',
701
+ description: 'Output file path',
702
+ type: 'string',
703
+ },
704
+ ],
705
+ examples: [
706
+ { command: 'monobrain analyze complexity src/', description: 'Analyze complexity' },
707
+ { command: 'monobrain analyze complexity src/ --threshold 15', description: 'Flag high complexity' },
708
+ ],
709
+ action: async (ctx) => {
710
+ const targetPath = ctx.args[0] || ctx.cwd;
711
+ const threshold = ctx.flags.threshold || 10;
712
+ const formatType = ctx.flags.format || 'text';
713
+ const outputFile = ctx.flags.output;
714
+ output.printInfo(`Analyzing complexity: ${output.highlight(targetPath)}`);
715
+ output.writeln();
716
+ const spinner = output.createSpinner({ text: 'Calculating complexity...', spinner: 'dots' });
717
+ spinner.start();
718
+ try {
719
+ const astModule = await getASTAnalyzer();
720
+ const resolvedPath = resolve(targetPath);
721
+ const stat = await fs.stat(resolvedPath);
722
+ const files = stat.isDirectory() ? await scanSourceFiles(resolvedPath) : [resolvedPath];
723
+ const results = [];
724
+ for (const file of files.slice(0, 100)) {
725
+ try {
726
+ const content = await fs.readFile(file, 'utf-8');
727
+ let analysis;
728
+ if (astModule) {
729
+ const analyzer = astModule.createASTAnalyzer();
730
+ analysis = analyzer.analyze(content, file);
731
+ }
732
+ else {
733
+ analysis = fallbackAnalyze(content, file);
734
+ }
735
+ const flagged = analysis.complexity.cyclomatic > threshold;
736
+ const rating = analysis.complexity.cyclomatic <= 5 ? 'Simple' :
737
+ analysis.complexity.cyclomatic <= 10 ? 'Moderate' :
738
+ analysis.complexity.cyclomatic <= 20 ? 'Complex' : 'Very Complex';
739
+ results.push({
740
+ file: file,
741
+ cyclomatic: analysis.complexity.cyclomatic,
742
+ cognitive: analysis.complexity.cognitive,
743
+ loc: analysis.complexity.loc,
744
+ commentDensity: analysis.complexity.commentDensity,
745
+ rating,
746
+ flagged,
747
+ });
748
+ }
749
+ catch {
750
+ // Skip files that can't be analyzed
751
+ }
752
+ }
753
+ spinner.stop();
754
+ // Sort by complexity descending
755
+ results.sort((a, b) => b.cyclomatic - a.cyclomatic);
756
+ const flaggedCount = results.filter(r => r.flagged).length;
757
+ const avgComplexity = results.length > 0
758
+ ? results.reduce((sum, r) => sum + r.cyclomatic, 0) / results.length
759
+ : 0;
760
+ if (formatType === 'json') {
761
+ const jsonOutput = { files: results, summary: { total: results.length, flagged: flaggedCount, avgComplexity, threshold } };
762
+ if (outputFile) {
763
+ await writeFile(outputFile, JSON.stringify(jsonOutput, null, 2));
764
+ output.printSuccess(`Results written to ${outputFile}`);
765
+ }
766
+ else {
767
+ output.printJson(jsonOutput);
768
+ }
769
+ return { success: true, data: jsonOutput };
770
+ }
771
+ // Summary
772
+ output.printBox([
773
+ `Files analyzed: ${results.length}`,
774
+ `Threshold: ${threshold}`,
775
+ `Flagged files: ${flaggedCount > 0 ? output.error(String(flaggedCount)) : output.success('0')}`,
776
+ `Average complexity: ${formatComplexityValueAst(Math.round(avgComplexity))}`,
777
+ ].join('\n'), 'Complexity Analysis');
778
+ // Show flagged files first
779
+ if (flaggedCount > 0) {
780
+ output.writeln();
781
+ output.writeln(output.bold(output.warning(`High Complexity Files (>${threshold})`)));
782
+ output.writeln(output.dim('-'.repeat(60)));
783
+ const flaggedFiles = results.filter(r => r.flagged).slice(0, 10);
784
+ output.printTable({
785
+ columns: [
786
+ { key: 'file', header: 'File', width: 40, format: (v) => truncatePathAst(v) },
787
+ { key: 'cyclomatic', header: 'Cyclo', width: 8, align: 'right', format: (v) => output.error(String(v)) },
788
+ { key: 'cognitive', header: 'Cogni', width: 8, align: 'right' },
789
+ { key: 'loc', header: 'LOC', width: 8, align: 'right' },
790
+ { key: 'rating', header: 'Rating', width: 15 },
791
+ ],
792
+ data: flaggedFiles,
793
+ });
794
+ }
795
+ // Show all files in table format
796
+ output.writeln();
797
+ output.writeln(output.bold('All Files'));
798
+ output.writeln(output.dim('-'.repeat(60)));
799
+ const displayFiles = results.slice(0, 15);
800
+ output.printTable({
801
+ columns: [
802
+ { key: 'file', header: 'File', width: 40, format: (v) => truncatePathAst(v) },
803
+ { key: 'cyclomatic', header: 'Cyclo', width: 8, align: 'right', format: (v) => formatComplexityValueAst(v) },
804
+ { key: 'cognitive', header: 'Cogni', width: 8, align: 'right' },
805
+ { key: 'loc', header: 'LOC', width: 8, align: 'right' },
806
+ ],
807
+ data: displayFiles,
808
+ });
809
+ if (results.length > 15) {
810
+ output.writeln(output.dim(` ... and ${results.length - 15} more files`));
811
+ }
812
+ if (outputFile) {
813
+ await writeFile(outputFile, JSON.stringify({ files: results, summary: { total: results.length, flagged: flaggedCount, avgComplexity, threshold } }, null, 2));
814
+ output.printSuccess(`Results written to ${outputFile}`);
815
+ }
816
+ return { success: true, data: { files: results, flaggedCount } };
817
+ }
818
+ catch (error) {
819
+ spinner.stop();
820
+ const message = error instanceof Error ? error.message : String(error);
821
+ output.printError(`Complexity analysis failed: ${message}`);
822
+ return { success: false, exitCode: 1 };
823
+ }
824
+ },
825
+ };
826
+ /**
827
+ * Symbol extraction subcommand
828
+ */
829
+ const symbolsCommand = {
830
+ name: 'symbols',
831
+ aliases: ['sym'],
832
+ description: 'Extract and list code symbols (functions, classes, types)',
833
+ options: [
834
+ {
835
+ name: 'type',
836
+ short: 't',
837
+ description: 'Filter by symbol type (function, class, all)',
838
+ type: 'string',
839
+ default: 'all',
840
+ choices: ['function', 'class', 'all'],
841
+ },
842
+ {
843
+ name: 'format',
844
+ short: 'f',
845
+ description: 'Output format (text, json)',
846
+ type: 'string',
847
+ default: 'text',
848
+ choices: ['text', 'json'],
849
+ },
850
+ {
851
+ name: 'output',
852
+ short: 'o',
853
+ description: 'Output file path',
854
+ type: 'string',
855
+ },
856
+ ],
857
+ examples: [
858
+ { command: 'monobrain analyze symbols src/', description: 'Extract all symbols' },
859
+ { command: 'monobrain analyze symbols src/ --type function', description: 'Only functions' },
860
+ { command: 'monobrain analyze symbols src/ --format json', description: 'JSON output' },
861
+ ],
862
+ action: async (ctx) => {
863
+ const targetPath = ctx.args[0] || ctx.cwd;
864
+ const symbolType = ctx.flags.type || 'all';
865
+ const formatType = ctx.flags.format || 'text';
866
+ const outputFile = ctx.flags.output;
867
+ output.printInfo(`Extracting symbols: ${output.highlight(targetPath)}`);
868
+ output.writeln();
869
+ const spinner = output.createSpinner({ text: 'Parsing code...', spinner: 'dots' });
870
+ spinner.start();
871
+ try {
872
+ const astModule = await getASTAnalyzer();
873
+ const resolvedPath = resolve(targetPath);
874
+ const stat = await fs.stat(resolvedPath);
875
+ const files = stat.isDirectory() ? await scanSourceFiles(resolvedPath) : [resolvedPath];
876
+ const symbols = [];
877
+ for (const file of files.slice(0, 100)) {
878
+ try {
879
+ const content = await fs.readFile(file, 'utf-8');
880
+ let analysis;
881
+ if (astModule) {
882
+ const analyzer = astModule.createASTAnalyzer();
883
+ analysis = analyzer.analyze(content, file);
884
+ }
885
+ else {
886
+ analysis = fallbackAnalyze(content, file);
887
+ }
888
+ if (symbolType === 'all' || symbolType === 'function') {
889
+ for (const fn of analysis.functions) {
890
+ symbols.push({
891
+ name: fn.name,
892
+ type: 'function',
893
+ file,
894
+ startLine: fn.startLine,
895
+ endLine: fn.endLine,
896
+ });
897
+ }
898
+ }
899
+ if (symbolType === 'all' || symbolType === 'class') {
900
+ for (const cls of analysis.classes) {
901
+ symbols.push({
902
+ name: cls.name,
903
+ type: 'class',
904
+ file,
905
+ startLine: cls.startLine,
906
+ endLine: cls.endLine,
907
+ });
908
+ }
909
+ }
910
+ }
911
+ catch {
912
+ // Skip files that can't be parsed
913
+ }
914
+ }
915
+ spinner.stop();
916
+ // Sort by file then name
917
+ symbols.sort((a, b) => a.file.localeCompare(b.file) || a.name.localeCompare(b.name));
918
+ if (formatType === 'json') {
919
+ if (outputFile) {
920
+ await writeFile(outputFile, JSON.stringify(symbols, null, 2));
921
+ output.printSuccess(`Results written to ${outputFile}`);
922
+ }
923
+ else {
924
+ output.printJson(symbols);
925
+ }
926
+ return { success: true, data: symbols };
927
+ }
928
+ // Summary
929
+ const functionCount = symbols.filter(s => s.type === 'function').length;
930
+ const classCount = symbols.filter(s => s.type === 'class').length;
931
+ output.printBox([
932
+ `Total symbols: ${symbols.length}`,
933
+ `Functions: ${functionCount}`,
934
+ `Classes: ${classCount}`,
935
+ `Files: ${files.length}`,
936
+ ].join('\n'), 'Symbol Extraction');
937
+ output.writeln();
938
+ output.writeln(output.bold('Symbols'));
939
+ output.writeln(output.dim('-'.repeat(60)));
940
+ const displaySymbols = symbols.slice(0, 30);
941
+ output.printTable({
942
+ columns: [
943
+ { key: 'type', header: 'Type', width: 10, format: (v) => getTypeMarkerAst(v) },
944
+ { key: 'name', header: 'Name', width: 30 },
945
+ { key: 'file', header: 'File', width: 35, format: (v) => truncatePathAst(v, 33) },
946
+ { key: 'startLine', header: 'Line', width: 8, align: 'right' },
947
+ ],
948
+ data: displaySymbols,
949
+ });
950
+ if (symbols.length > 30) {
951
+ output.writeln(output.dim(` ... and ${symbols.length - 30} more symbols`));
952
+ }
953
+ if (outputFile) {
954
+ await writeFile(outputFile, JSON.stringify(symbols, null, 2));
955
+ output.printSuccess(`Results written to ${outputFile}`);
956
+ }
957
+ return { success: true, data: symbols };
958
+ }
959
+ catch (error) {
960
+ spinner.stop();
961
+ const message = error instanceof Error ? error.message : String(error);
962
+ output.printError(`Symbol extraction failed: ${message}`);
963
+ return { success: false, exitCode: 1 };
964
+ }
965
+ },
966
+ };
967
+ /**
968
+ * Imports analysis subcommand
969
+ */
970
+ const importsCommand = {
971
+ name: 'imports',
972
+ aliases: ['imp'],
973
+ description: 'Analyze import dependencies across files',
974
+ options: [
975
+ {
976
+ name: 'format',
977
+ short: 'f',
978
+ description: 'Output format (text, json)',
979
+ type: 'string',
980
+ default: 'text',
981
+ choices: ['text', 'json'],
982
+ },
983
+ {
984
+ name: 'output',
985
+ short: 'o',
986
+ description: 'Output file path',
987
+ type: 'string',
988
+ },
989
+ {
990
+ name: 'external',
991
+ short: 'e',
992
+ description: 'Show only external (npm) imports',
993
+ type: 'boolean',
994
+ default: false,
995
+ },
996
+ ],
997
+ examples: [
998
+ { command: 'monobrain analyze imports src/', description: 'Analyze all imports' },
999
+ { command: 'monobrain analyze imports src/ --external', description: 'Only npm packages' },
1000
+ ],
1001
+ action: async (ctx) => {
1002
+ const targetPath = ctx.args[0] || ctx.cwd;
1003
+ const formatType = ctx.flags.format || 'text';
1004
+ const outputFile = ctx.flags.output;
1005
+ const externalOnly = ctx.flags.external;
1006
+ output.printInfo(`Analyzing imports: ${output.highlight(targetPath)}`);
1007
+ output.writeln();
1008
+ const spinner = output.createSpinner({ text: 'Scanning imports...', spinner: 'dots' });
1009
+ spinner.start();
1010
+ try {
1011
+ const astModule = await getASTAnalyzer();
1012
+ const resolvedPath = resolve(targetPath);
1013
+ const stat = await fs.stat(resolvedPath);
1014
+ const files = stat.isDirectory() ? await scanSourceFiles(resolvedPath) : [resolvedPath];
1015
+ const importCounts = new Map();
1016
+ const fileImports = new Map();
1017
+ for (const file of files.slice(0, 100)) {
1018
+ try {
1019
+ const content = await fs.readFile(file, 'utf-8');
1020
+ let analysis;
1021
+ if (astModule) {
1022
+ const analyzer = astModule.createASTAnalyzer();
1023
+ analysis = analyzer.analyze(content, file);
1024
+ }
1025
+ else {
1026
+ analysis = fallbackAnalyze(content, file);
1027
+ }
1028
+ const imports = analysis.imports.filter(imp => {
1029
+ if (externalOnly) {
1030
+ return !imp.startsWith('.') && !imp.startsWith('/');
1031
+ }
1032
+ return true;
1033
+ });
1034
+ fileImports.set(file, imports);
1035
+ for (const imp of imports) {
1036
+ const existing = importCounts.get(imp) || { count: 0, files: [] };
1037
+ existing.count++;
1038
+ existing.files.push(file);
1039
+ importCounts.set(imp, existing);
1040
+ }
1041
+ }
1042
+ catch {
1043
+ // Skip files that can't be parsed
1044
+ }
1045
+ }
1046
+ spinner.stop();
1047
+ // Sort by count
1048
+ const sortedImports = Array.from(importCounts.entries())
1049
+ .sort((a, b) => b[1].count - a[1].count);
1050
+ if (formatType === 'json') {
1051
+ const jsonOutput = {
1052
+ imports: Object.fromEntries(sortedImports),
1053
+ fileImports: Object.fromEntries(fileImports),
1054
+ };
1055
+ if (outputFile) {
1056
+ await writeFile(outputFile, JSON.stringify(jsonOutput, null, 2));
1057
+ output.printSuccess(`Results written to ${outputFile}`);
1058
+ }
1059
+ else {
1060
+ output.printJson(jsonOutput);
1061
+ }
1062
+ return { success: true, data: jsonOutput };
1063
+ }
1064
+ // Summary
1065
+ const externalImports = sortedImports.filter(([imp]) => !imp.startsWith('.') && !imp.startsWith('/'));
1066
+ const localImports = sortedImports.filter(([imp]) => imp.startsWith('.') || imp.startsWith('/'));
1067
+ output.printBox([
1068
+ `Total unique imports: ${sortedImports.length}`,
1069
+ `External (npm): ${externalImports.length}`,
1070
+ `Local (relative): ${localImports.length}`,
1071
+ `Files scanned: ${files.length}`,
1072
+ ].join('\n'), 'Import Analysis');
1073
+ // Most used imports
1074
+ output.writeln();
1075
+ output.writeln(output.bold('Most Used Imports'));
1076
+ output.writeln(output.dim('-'.repeat(60)));
1077
+ const topImports = sortedImports.slice(0, 20);
1078
+ output.printTable({
1079
+ columns: [
1080
+ { key: 'count', header: 'Uses', width: 8, align: 'right' },
1081
+ { key: 'import', header: 'Import', width: 50 },
1082
+ { key: 'type', header: 'Type', width: 10 },
1083
+ ],
1084
+ data: topImports.map(([imp, data]) => ({
1085
+ count: data.count,
1086
+ import: imp,
1087
+ type: imp.startsWith('.') || imp.startsWith('/') ? output.dim('local') : output.highlight('npm'),
1088
+ })),
1089
+ });
1090
+ if (sortedImports.length > 20) {
1091
+ output.writeln(output.dim(` ... and ${sortedImports.length - 20} more imports`));
1092
+ }
1093
+ if (outputFile) {
1094
+ await writeFile(outputFile, JSON.stringify({
1095
+ imports: Object.fromEntries(sortedImports),
1096
+ fileImports: Object.fromEntries(fileImports),
1097
+ }, null, 2));
1098
+ output.printSuccess(`Results written to ${outputFile}`);
1099
+ }
1100
+ return { success: true, data: { imports: sortedImports } };
1101
+ }
1102
+ catch (error) {
1103
+ spinner.stop();
1104
+ const message = error instanceof Error ? error.message : String(error);
1105
+ output.printError(`Import analysis failed: ${message}`);
1106
+ return { success: false, exitCode: 1 };
1107
+ }
1108
+ },
1109
+ };
1110
+ /**
1111
+ * Helper: Scan directory for source files
1112
+ */
1113
+ async function scanSourceFiles(dir, maxDepth = 10) {
1114
+ const files = [];
1115
+ const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'];
1116
+ const excludeDirs = ['node_modules', 'dist', 'build', '.git', 'coverage', '__pycache__'];
1117
+ async function scan(currentDir, depth) {
1118
+ if (depth > maxDepth)
1119
+ return;
1120
+ try {
1121
+ const entries = await fs.readdir(currentDir, { withFileTypes: true });
1122
+ for (const entry of entries) {
1123
+ const fullPath = path.join(currentDir, entry.name);
1124
+ if (entry.isDirectory()) {
1125
+ if (!excludeDirs.includes(entry.name)) {
1126
+ await scan(fullPath, depth + 1);
1127
+ }
1128
+ }
1129
+ else if (entry.isFile()) {
1130
+ const ext = path.extname(entry.name);
1131
+ if (extensions.includes(ext)) {
1132
+ files.push(fullPath);
1133
+ }
1134
+ }
1135
+ }
1136
+ }
1137
+ catch {
1138
+ // Skip directories we can't read
1139
+ }
1140
+ }
1141
+ await scan(dir, 0);
1142
+ return files;
1143
+ }
1144
+ /**
1145
+ * Fallback analysis when ruvector is not available
1146
+ */
1147
+ function fallbackAnalyze(code, filePath) {
1148
+ const lines = code.split('\n');
1149
+ const functions = [];
1150
+ const classes = [];
1151
+ const imports = [];
1152
+ const exports = [];
1153
+ // Extract functions
1154
+ const funcPattern = /(?:export\s+)?(?:async\s+)?function\s+(\w+)|(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\([^)]*\)\s*=>|^\s*(?:async\s+)?(\w+)\s*\([^)]*\)\s*(?::\s*\w+)?\s*\{/gm;
1155
+ let match;
1156
+ while ((match = funcPattern.exec(code)) !== null) {
1157
+ const name = match[1] || match[2] || match[3];
1158
+ if (name && !['if', 'while', 'for', 'switch'].includes(name)) {
1159
+ const lineNum = code.substring(0, match.index).split('\n').length;
1160
+ functions.push({ name, startLine: lineNum, endLine: lineNum + 10 });
1161
+ }
1162
+ }
1163
+ // Extract classes
1164
+ const classPattern = /(?:export\s+)?class\s+(\w+)/gm;
1165
+ while ((match = classPattern.exec(code)) !== null) {
1166
+ const lineNum = code.substring(0, match.index).split('\n').length;
1167
+ classes.push({ name: match[1], startLine: lineNum, endLine: lineNum + 20 });
1168
+ }
1169
+ // Extract imports
1170
+ const importPattern = /import\s+(?:.*\s+from\s+)?['"]([^'"]+)['"]/gm;
1171
+ while ((match = importPattern.exec(code)) !== null) {
1172
+ imports.push(match[1]);
1173
+ }
1174
+ const requirePattern = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/gm;
1175
+ while ((match = requirePattern.exec(code)) !== null) {
1176
+ imports.push(match[1]);
1177
+ }
1178
+ // Extract exports
1179
+ const exportPattern = /export\s+(?:default\s+)?(?:const|let|var|function|class|interface|type|enum)\s+(\w+)/gm;
1180
+ while ((match = exportPattern.exec(code)) !== null) {
1181
+ exports.push(match[1]);
1182
+ }
1183
+ // Calculate complexity
1184
+ const nonEmptyLines = lines.filter(l => l.trim().length > 0).length;
1185
+ const commentLines = lines.filter(l => /^\s*(\/\/|\/\*|\*|#)/.test(l)).length;
1186
+ const decisionPoints = (code.match(/\b(if|else|for|while|switch|case|catch|&&|\|\||\?)\b/g) || []).length;
1187
+ let cognitive = 0;
1188
+ let nestingLevel = 0;
1189
+ for (const line of lines) {
1190
+ const opens = (line.match(/\{/g) || []).length;
1191
+ const closes = (line.match(/\}/g) || []).length;
1192
+ if (/\b(if|for|while|switch)\b/.test(line)) {
1193
+ cognitive += 1 + nestingLevel;
1194
+ }
1195
+ nestingLevel = Math.max(0, nestingLevel + opens - closes);
1196
+ }
1197
+ // Detect language
1198
+ const ext = path.extname(filePath).toLowerCase();
1199
+ const language = ext === '.ts' || ext === '.tsx' ? 'typescript' :
1200
+ ext === '.js' || ext === '.jsx' || ext === '.mjs' || ext === '.cjs' ? 'javascript' :
1201
+ ext === '.py' ? 'python' : 'unknown';
1202
+ return {
1203
+ filePath,
1204
+ language,
1205
+ functions,
1206
+ classes,
1207
+ imports,
1208
+ exports,
1209
+ complexity: {
1210
+ cyclomatic: decisionPoints + 1,
1211
+ cognitive,
1212
+ loc: nonEmptyLines,
1213
+ commentDensity: lines.length > 0 ? commentLines / lines.length : 0,
1214
+ },
1215
+ };
1216
+ }
1217
+ // Dependencies subcommand
1218
+ const depsCommand = {
1219
+ name: 'deps',
1220
+ description: 'Analyze project dependencies',
1221
+ options: [
1222
+ { name: 'outdated', short: 'o', type: 'boolean', description: 'Show only outdated dependencies' },
1223
+ { name: 'security', short: 's', type: 'boolean', description: 'Check for security vulnerabilities' },
1224
+ { name: 'format', short: 'f', type: 'string', description: 'Output format: text, json', default: 'text' },
1225
+ ],
1226
+ examples: [
1227
+ { command: 'monobrain analyze deps --outdated', description: 'Show outdated dependencies' },
1228
+ { command: 'monobrain analyze deps --security', description: 'Check for vulnerabilities' },
1229
+ ],
1230
+ action: async (ctx) => {
1231
+ const showOutdated = ctx.flags.outdated;
1232
+ const checkSecurity = ctx.flags.security;
1233
+ const formatJson = ctx.flags.format === 'json';
1234
+ output.writeln();
1235
+ output.writeln(output.bold('Dependency Analysis'));
1236
+ output.writeln(output.dim('-'.repeat(50)));
1237
+ try {
1238
+ const pkgPath = resolve('package.json');
1239
+ let pkgContent;
1240
+ try {
1241
+ pkgContent = await fs.readFile(pkgPath, 'utf-8');
1242
+ }
1243
+ catch {
1244
+ output.printError('No package.json found in current directory');
1245
+ return { success: false, exitCode: 1 };
1246
+ }
1247
+ const pkg = JSON.parse(pkgContent);
1248
+ const deps = Object.entries(pkg.dependencies || {});
1249
+ const devDeps = Object.entries(pkg.devDependencies || {});
1250
+ const optDeps = Object.entries(pkg.optionalDependencies || {});
1251
+ const peerDeps = Object.entries(pkg.peerDependencies || {});
1252
+ const total = deps.length + devDeps.length + optDeps.length + peerDeps.length;
1253
+ if (formatJson && !showOutdated && !checkSecurity) {
1254
+ const jsonData = { name: pkg.name, version: pkg.version, dependencies: deps.length, devDependencies: devDeps.length, optionalDependencies: optDeps.length, peerDependencies: peerDeps.length, total };
1255
+ output.printJson(jsonData);
1256
+ return { success: true, data: jsonData };
1257
+ }
1258
+ output.printBox([`Package: ${pkg.name || 'unknown'} @ ${pkg.version || '0.0.0'}`, `Dependencies: ${deps.length}`, `Dev Dependencies: ${devDeps.length}`, `Optional: ${optDeps.length}`, `Peer: ${peerDeps.length}`, `Total: ${total}`].join('\n'), 'Dependency Summary');
1259
+ if (showOutdated) {
1260
+ output.writeln();
1261
+ output.writeln(output.bold('Outdated Check'));
1262
+ output.writeln(output.dim('-'.repeat(60)));
1263
+ const outdated = [];
1264
+ const checkDeps = async (entries, category) => {
1265
+ for (const [name, declared] of entries) {
1266
+ try {
1267
+ const installedPkg = resolve('node_modules', name, 'package.json');
1268
+ const raw = await fs.readFile(installedPkg, 'utf-8');
1269
+ const installedContent = JSON.parse(raw);
1270
+ const installed = installedContent.version || 'unknown';
1271
+ const cleanDeclared = declared.replace(/^[\^~>=<]+/, '');
1272
+ if (installed !== cleanDeclared) {
1273
+ outdated.push({ name, declared: declared, installed, category });
1274
+ }
1275
+ }
1276
+ catch {
1277
+ outdated.push({ name, declared: declared, installed: 'not installed', category });
1278
+ }
1279
+ }
1280
+ };
1281
+ await checkDeps(deps, 'prod');
1282
+ await checkDeps(devDeps, 'dev');
1283
+ if (outdated.length === 0) {
1284
+ output.printSuccess('All dependencies match declared versions');
1285
+ }
1286
+ else {
1287
+ output.printTable({
1288
+ columns: [
1289
+ { key: 'name', header: 'Package', width: 30 },
1290
+ { key: 'declared', header: 'Declared', width: 14 },
1291
+ { key: 'installed', header: 'Installed', width: 14 },
1292
+ { key: 'category', header: 'Type', width: 6 },
1293
+ ],
1294
+ data: outdated.slice(0, 30),
1295
+ });
1296
+ if (outdated.length > 30) {
1297
+ output.writeln(output.dim(` ... and ${outdated.length - 30} more`));
1298
+ }
1299
+ }
1300
+ }
1301
+ if (checkSecurity) {
1302
+ output.writeln();
1303
+ output.writeln(output.bold('Security Audit'));
1304
+ output.writeln(output.dim('-'.repeat(60)));
1305
+ try {
1306
+ const auditRaw = execSync('npm audit --json 2>/dev/null', { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
1307
+ const audit = JSON.parse(auditRaw);
1308
+ const vulns = audit.metadata?.vulnerabilities || audit.vulnerabilities || {};
1309
+ const info = vulns.info || 0;
1310
+ const low = vulns.low || 0;
1311
+ const moderate = vulns.moderate || 0;
1312
+ const high = vulns.high || 0;
1313
+ const critical = vulns.critical || 0;
1314
+ const totalVulns = info + low + moderate + high + critical;
1315
+ if (totalVulns === 0) {
1316
+ output.printSuccess('No known vulnerabilities found');
1317
+ }
1318
+ else {
1319
+ output.printTable({
1320
+ columns: [
1321
+ { key: 'severity', header: 'Severity', width: 12 },
1322
+ { key: 'count', header: 'Count', width: 8, align: 'right' },
1323
+ ],
1324
+ data: [
1325
+ ...(critical > 0 ? [{ severity: 'Critical', count: critical }] : []),
1326
+ ...(high > 0 ? [{ severity: 'High', count: high }] : []),
1327
+ ...(moderate > 0 ? [{ severity: 'Moderate', count: moderate }] : []),
1328
+ ...(low > 0 ? [{ severity: 'Low', count: low }] : []),
1329
+ ...(info > 0 ? [{ severity: 'Info', count: info }] : []),
1330
+ { severity: 'Total', count: totalVulns },
1331
+ ],
1332
+ });
1333
+ if (critical > 0 || high > 0) {
1334
+ output.printWarning(`${critical + high} high/critical vulnerabilities found. Run 'npm audit' for details.`);
1335
+ }
1336
+ }
1337
+ }
1338
+ catch {
1339
+ output.printWarning('npm audit failed. Ensure npm is available and node_modules is installed.');
1340
+ }
1341
+ }
1342
+ return { success: true };
1343
+ }
1344
+ catch (error) {
1345
+ const message = error instanceof Error ? error.message : String(error);
1346
+ output.printError(`Dependency analysis failed: ${message}`);
1347
+ return { success: false, exitCode: 1 };
1348
+ }
1349
+ },
1350
+ };
1351
+ // ============================================================================
1352
+ // Graph Analysis Subcommands (MinCut, Louvain, Circular Dependencies)
1353
+ // ============================================================================
1354
+ /**
1355
+ * Analyze code boundaries using MinCut algorithm
1356
+ */
1357
+ const boundariesCommand = {
1358
+ name: 'boundaries',
1359
+ aliases: ['boundary', 'mincut'],
1360
+ description: 'Find natural code boundaries using MinCut algorithm',
1361
+ options: [
1362
+ {
1363
+ name: 'partitions',
1364
+ short: 'p',
1365
+ description: 'Number of partitions to find',
1366
+ type: 'number',
1367
+ default: 2,
1368
+ },
1369
+ {
1370
+ name: 'output',
1371
+ short: 'o',
1372
+ description: 'Output file path',
1373
+ type: 'string',
1374
+ },
1375
+ {
1376
+ name: 'format',
1377
+ short: 'f',
1378
+ description: 'Output format (text, json, dot)',
1379
+ type: 'string',
1380
+ default: 'text',
1381
+ choices: ['text', 'json', 'dot'],
1382
+ },
1383
+ ],
1384
+ examples: [
1385
+ { command: 'monobrain analyze boundaries src/', description: 'Find code boundaries in src/' },
1386
+ { command: 'monobrain analyze boundaries -p 3 src/', description: 'Find 3 partitions' },
1387
+ { command: 'monobrain analyze boundaries -f dot -o graph.dot src/', description: 'Export to DOT format' },
1388
+ ],
1389
+ action: async (ctx) => {
1390
+ const targetDir = ctx.args[0] || ctx.cwd;
1391
+ const numPartitions = ctx.flags.partitions || 2;
1392
+ const outputFile = ctx.flags.output;
1393
+ const format = ctx.flags.format || 'text';
1394
+ output.printInfo(`Analyzing code boundaries in: ${output.highlight(targetDir)}`);
1395
+ output.writeln();
1396
+ const spinner = output.createSpinner({ text: 'Building dependency graph...', spinner: 'dots' });
1397
+ spinner.start();
1398
+ try {
1399
+ const analyzer = await getGraphAnalyzer();
1400
+ if (!analyzer) {
1401
+ spinner.stop();
1402
+ output.printError('Graph analyzer module not available');
1403
+ return { success: false, exitCode: 1 };
1404
+ }
1405
+ const result = await analyzer.analyzeGraph(resolve(targetDir), {
1406
+ includeBoundaries: true,
1407
+ includeModules: false,
1408
+ numPartitions,
1409
+ });
1410
+ spinner.stop();
1411
+ // Handle different output formats
1412
+ if (format === 'json') {
1413
+ const jsonOutput = {
1414
+ boundaries: result.boundaries,
1415
+ statistics: result.statistics,
1416
+ circularDependencies: result.circularDependencies,
1417
+ };
1418
+ if (outputFile) {
1419
+ await writeFile(outputFile, JSON.stringify(jsonOutput, null, 2));
1420
+ output.printSuccess(`Results written to ${outputFile}`);
1421
+ }
1422
+ else {
1423
+ output.printJson(jsonOutput);
1424
+ }
1425
+ return { success: true, data: jsonOutput };
1426
+ }
1427
+ if (format === 'dot') {
1428
+ const dotOutput = analyzer.exportToDot(result, {
1429
+ includeLabels: true,
1430
+ highlightCycles: true,
1431
+ });
1432
+ if (outputFile) {
1433
+ await writeFile(outputFile, dotOutput);
1434
+ output.printSuccess(`DOT graph written to ${outputFile}`);
1435
+ output.writeln(output.dim('Visualize with: dot -Tpng -o graph.png ' + outputFile));
1436
+ }
1437
+ else {
1438
+ output.writeln(dotOutput);
1439
+ }
1440
+ return { success: true };
1441
+ }
1442
+ // Text format (default)
1443
+ output.printBox([
1444
+ `Files analyzed: ${result.statistics.nodeCount}`,
1445
+ `Dependencies: ${result.statistics.edgeCount}`,
1446
+ `Avg degree: ${result.statistics.avgDegree.toFixed(2)}`,
1447
+ `Density: ${(result.statistics.density * 100).toFixed(2)}%`,
1448
+ `Components: ${result.statistics.componentCount}`,
1449
+ ].join('\n'), 'Graph Statistics');
1450
+ if (result.boundaries && result.boundaries.length > 0) {
1451
+ output.writeln();
1452
+ output.writeln(output.bold('MinCut Boundaries'));
1453
+ output.writeln();
1454
+ for (let i = 0; i < result.boundaries.length; i++) {
1455
+ const boundary = result.boundaries[i];
1456
+ output.writeln(output.bold(`Boundary ${i + 1} (cut value: ${boundary.cutValue})`));
1457
+ output.writeln();
1458
+ output.writeln(output.dim('Partition 1:'));
1459
+ const p1Display = boundary.partition1.slice(0, 10);
1460
+ output.printList(p1Display);
1461
+ if (boundary.partition1.length > 10) {
1462
+ output.writeln(output.dim(` ... and ${boundary.partition1.length - 10} more files`));
1463
+ }
1464
+ output.writeln();
1465
+ output.writeln(output.dim('Partition 2:'));
1466
+ const p2Display = boundary.partition2.slice(0, 10);
1467
+ output.printList(p2Display);
1468
+ if (boundary.partition2.length > 10) {
1469
+ output.writeln(output.dim(` ... and ${boundary.partition2.length - 10} more files`));
1470
+ }
1471
+ output.writeln();
1472
+ output.writeln(output.success('Suggestion:'));
1473
+ output.writeln(` ${boundary.suggestion}`);
1474
+ output.writeln();
1475
+ }
1476
+ }
1477
+ // Show circular dependencies
1478
+ if (result.circularDependencies.length > 0) {
1479
+ output.writeln();
1480
+ output.writeln(output.bold(output.warning('Circular Dependencies Detected')));
1481
+ output.writeln();
1482
+ for (const cycle of result.circularDependencies.slice(0, 5)) {
1483
+ const severityColor = cycle.severity === 'high' ? output.error : cycle.severity === 'medium' ? output.warning : output.dim;
1484
+ output.writeln(`${severityColor(`[${cycle.severity.toUpperCase()}]`)} ${cycle.cycle.join(' -> ')}`);
1485
+ output.writeln(output.dim(` ${cycle.suggestion}`));
1486
+ output.writeln();
1487
+ }
1488
+ if (result.circularDependencies.length > 5) {
1489
+ output.writeln(output.dim(`... and ${result.circularDependencies.length - 5} more cycles`));
1490
+ }
1491
+ }
1492
+ if (outputFile) {
1493
+ await writeFile(outputFile, JSON.stringify(result, null, 2));
1494
+ output.printSuccess(`Full results written to ${outputFile}`);
1495
+ }
1496
+ return { success: true, data: result };
1497
+ }
1498
+ catch (error) {
1499
+ spinner.stop();
1500
+ const message = error instanceof Error ? error.message : String(error);
1501
+ output.printError(`Analysis failed: ${message}`);
1502
+ return { success: false, exitCode: 1 };
1503
+ }
1504
+ },
1505
+ };
1506
+ /**
1507
+ * Analyze modules/communities using Louvain algorithm
1508
+ */
1509
+ const modulesCommand = {
1510
+ name: 'modules',
1511
+ aliases: ['communities', 'louvain'],
1512
+ description: 'Detect module communities using Louvain algorithm',
1513
+ options: [
1514
+ {
1515
+ name: 'output',
1516
+ short: 'o',
1517
+ description: 'Output file path',
1518
+ type: 'string',
1519
+ },
1520
+ {
1521
+ name: 'format',
1522
+ short: 'f',
1523
+ description: 'Output format (text, json, dot)',
1524
+ type: 'string',
1525
+ default: 'text',
1526
+ choices: ['text', 'json', 'dot'],
1527
+ },
1528
+ {
1529
+ name: 'min-size',
1530
+ short: 'm',
1531
+ description: 'Minimum community size to display',
1532
+ type: 'number',
1533
+ default: 2,
1534
+ },
1535
+ ],
1536
+ examples: [
1537
+ { command: 'monobrain analyze modules src/', description: 'Detect module communities' },
1538
+ { command: 'monobrain analyze modules -f dot -o modules.dot src/', description: 'Export colored DOT graph' },
1539
+ { command: 'monobrain analyze modules -m 3 src/', description: 'Only show communities with 3+ files' },
1540
+ ],
1541
+ action: async (ctx) => {
1542
+ const targetDir = ctx.args[0] || ctx.cwd;
1543
+ const outputFile = ctx.flags.output;
1544
+ const format = ctx.flags.format || 'text';
1545
+ const minSize = ctx.flags['min-size'] || 2;
1546
+ output.printInfo(`Detecting module communities in: ${output.highlight(targetDir)}`);
1547
+ output.writeln();
1548
+ const spinner = output.createSpinner({ text: 'Building dependency graph...', spinner: 'dots' });
1549
+ spinner.start();
1550
+ try {
1551
+ const analyzer = await getGraphAnalyzer();
1552
+ if (!analyzer) {
1553
+ spinner.stop();
1554
+ output.printError('Graph analyzer module not available');
1555
+ return { success: false, exitCode: 1 };
1556
+ }
1557
+ const result = await analyzer.analyzeGraph(resolve(targetDir), {
1558
+ includeBoundaries: false,
1559
+ includeModules: true,
1560
+ });
1561
+ spinner.stop();
1562
+ // Filter communities by size
1563
+ const communities = result.communities?.filter(c => c.members.length >= minSize) || [];
1564
+ // Handle different output formats
1565
+ if (format === 'json') {
1566
+ const jsonOutput = {
1567
+ communities,
1568
+ statistics: result.statistics,
1569
+ };
1570
+ if (outputFile) {
1571
+ await writeFile(outputFile, JSON.stringify(jsonOutput, null, 2));
1572
+ output.printSuccess(`Results written to ${outputFile}`);
1573
+ }
1574
+ else {
1575
+ output.printJson(jsonOutput);
1576
+ }
1577
+ return { success: true, data: jsonOutput };
1578
+ }
1579
+ if (format === 'dot') {
1580
+ const dotOutput = analyzer.exportToDot(result, {
1581
+ includeLabels: true,
1582
+ colorByCommunity: true,
1583
+ highlightCycles: true,
1584
+ });
1585
+ if (outputFile) {
1586
+ await writeFile(outputFile, dotOutput);
1587
+ output.printSuccess(`DOT graph written to ${outputFile}`);
1588
+ output.writeln(output.dim('Visualize with: dot -Tpng -o modules.png ' + outputFile));
1589
+ }
1590
+ else {
1591
+ output.writeln(dotOutput);
1592
+ }
1593
+ return { success: true };
1594
+ }
1595
+ // Text format (default)
1596
+ output.printBox([
1597
+ `Files analyzed: ${result.statistics.nodeCount}`,
1598
+ `Dependencies: ${result.statistics.edgeCount}`,
1599
+ `Communities found: ${result.communities?.length || 0}`,
1600
+ `Showing: ${communities.length} (min size: ${minSize})`,
1601
+ ].join('\n'), 'Module Detection Results');
1602
+ if (communities.length > 0) {
1603
+ output.writeln();
1604
+ output.writeln(output.bold('Detected Communities'));
1605
+ output.writeln();
1606
+ for (const community of communities.slice(0, 10)) {
1607
+ const cohesionIndicator = community.cohesion > 0.5 ? output.success('High') :
1608
+ community.cohesion > 0.2 ? output.warning('Medium') : output.dim('Low');
1609
+ output.writeln(output.bold(`Community ${community.id}: ${community.suggestedName || 'unnamed'}`));
1610
+ output.writeln(` ${output.dim('Cohesion:')} ${cohesionIndicator} (${(community.cohesion * 100).toFixed(1)}%)`);
1611
+ output.writeln(` ${output.dim('Central node:')} ${community.centralNode || 'none'}`);
1612
+ output.writeln(` ${output.dim('Members:')} ${community.members.length} files`);
1613
+ const displayMembers = community.members.slice(0, 5);
1614
+ for (const member of displayMembers) {
1615
+ output.writeln(` - ${member}`);
1616
+ }
1617
+ if (community.members.length > 5) {
1618
+ output.writeln(output.dim(` ... and ${community.members.length - 5} more`));
1619
+ }
1620
+ output.writeln();
1621
+ }
1622
+ if (communities.length > 10) {
1623
+ output.writeln(output.dim(`... and ${communities.length - 10} more communities`));
1624
+ }
1625
+ }
1626
+ if (outputFile) {
1627
+ await writeFile(outputFile, JSON.stringify(result, null, 2));
1628
+ output.printSuccess(`Full results written to ${outputFile}`);
1629
+ }
1630
+ return { success: true, data: result };
1631
+ }
1632
+ catch (error) {
1633
+ spinner.stop();
1634
+ const message = error instanceof Error ? error.message : String(error);
1635
+ output.printError(`Analysis failed: ${message}`);
1636
+ return { success: false, exitCode: 1 };
1637
+ }
1638
+ },
1639
+ };
1640
+ /**
1641
+ * Build and export dependency graph
1642
+ */
1643
+ const dependenciesCommand = {
1644
+ name: 'dependencies',
1645
+ aliases: ['graph'],
1646
+ description: 'Build and export full dependency graph',
1647
+ options: [
1648
+ {
1649
+ name: 'output',
1650
+ short: 'o',
1651
+ description: 'Output file path',
1652
+ type: 'string',
1653
+ },
1654
+ {
1655
+ name: 'format',
1656
+ short: 'f',
1657
+ description: 'Output format (text, json, dot)',
1658
+ type: 'string',
1659
+ default: 'text',
1660
+ choices: ['text', 'json', 'dot'],
1661
+ },
1662
+ {
1663
+ name: 'include',
1664
+ short: 'i',
1665
+ description: 'File extensions to include (comma-separated)',
1666
+ type: 'string',
1667
+ default: '.ts,.tsx,.js,.jsx,.mjs,.cjs',
1668
+ },
1669
+ {
1670
+ name: 'exclude',
1671
+ short: 'e',
1672
+ description: 'Patterns to exclude (comma-separated)',
1673
+ type: 'string',
1674
+ default: 'node_modules,dist,build,.git',
1675
+ },
1676
+ {
1677
+ name: 'depth',
1678
+ short: 'd',
1679
+ description: 'Maximum directory depth',
1680
+ type: 'number',
1681
+ default: 10,
1682
+ },
1683
+ ],
1684
+ examples: [
1685
+ { command: 'monobrain analyze dependencies src/', description: 'Build dependency graph' },
1686
+ { command: 'monobrain analyze dependencies -f dot -o deps.dot src/', description: 'Export to DOT' },
1687
+ { command: 'monobrain analyze dependencies -i .ts,.tsx src/', description: 'Only TypeScript files' },
1688
+ ],
1689
+ action: async (ctx) => {
1690
+ const targetDir = ctx.args[0] || ctx.cwd;
1691
+ const outputFile = ctx.flags.output;
1692
+ const format = ctx.flags.format || 'text';
1693
+ const include = (ctx.flags.include || '.ts,.tsx,.js,.jsx,.mjs,.cjs').split(',');
1694
+ const exclude = (ctx.flags.exclude || 'node_modules,dist,build,.git').split(',');
1695
+ const maxDepth = ctx.flags.depth || 10;
1696
+ output.printInfo(`Building dependency graph for: ${output.highlight(targetDir)}`);
1697
+ output.writeln();
1698
+ const spinner = output.createSpinner({ text: 'Scanning files...', spinner: 'dots' });
1699
+ spinner.start();
1700
+ try {
1701
+ const analyzer = await getGraphAnalyzer();
1702
+ if (!analyzer) {
1703
+ spinner.stop();
1704
+ output.printError('Graph analyzer module not available');
1705
+ return { success: false, exitCode: 1 };
1706
+ }
1707
+ const graph = await analyzer.buildDependencyGraph(resolve(targetDir), {
1708
+ include,
1709
+ exclude,
1710
+ maxDepth,
1711
+ });
1712
+ spinner.stop();
1713
+ // Detect circular dependencies
1714
+ const circularDeps = analyzer.detectCircularDependencies(graph);
1715
+ // Handle different output formats
1716
+ if (format === 'json') {
1717
+ const jsonOutput = {
1718
+ nodes: Array.from(graph.nodes.values()),
1719
+ edges: graph.edges,
1720
+ metadata: graph.metadata,
1721
+ circularDependencies: circularDeps,
1722
+ };
1723
+ if (outputFile) {
1724
+ await writeFile(outputFile, JSON.stringify(jsonOutput, null, 2));
1725
+ output.printSuccess(`Graph written to ${outputFile}`);
1726
+ }
1727
+ else {
1728
+ output.printJson(jsonOutput);
1729
+ }
1730
+ return { success: true, data: jsonOutput };
1731
+ }
1732
+ if (format === 'dot') {
1733
+ const result = { graph, circularDependencies: circularDeps, statistics: {
1734
+ nodeCount: graph.nodes.size,
1735
+ edgeCount: graph.edges.length,
1736
+ avgDegree: 0,
1737
+ maxDegree: 0,
1738
+ density: 0,
1739
+ componentCount: 0,
1740
+ } };
1741
+ const dotOutput = analyzer.exportToDot(result, {
1742
+ includeLabels: true,
1743
+ highlightCycles: true,
1744
+ });
1745
+ if (outputFile) {
1746
+ await writeFile(outputFile, dotOutput);
1747
+ output.printSuccess(`DOT graph written to ${outputFile}`);
1748
+ output.writeln(output.dim('Visualize with: dot -Tpng -o deps.png ' + outputFile));
1749
+ }
1750
+ else {
1751
+ output.writeln(dotOutput);
1752
+ }
1753
+ return { success: true };
1754
+ }
1755
+ // Text format (default)
1756
+ output.printBox([
1757
+ `Files: ${graph.metadata.totalFiles}`,
1758
+ `Dependencies: ${graph.metadata.totalEdges}`,
1759
+ `Build time: ${graph.metadata.buildTime}ms`,
1760
+ `Root: ${graph.metadata.rootDir}`,
1761
+ ].join('\n'), 'Dependency Graph');
1762
+ // Show top files by imports
1763
+ output.writeln();
1764
+ output.writeln(output.bold('Most Connected Files'));
1765
+ output.writeln();
1766
+ const nodesByDegree = Array.from(graph.nodes.values())
1767
+ .map(n => ({
1768
+ ...n,
1769
+ degree: graph.edges.filter(e => e.source === n.id || e.target === n.id).length,
1770
+ }))
1771
+ .sort((a, b) => b.degree - a.degree)
1772
+ .slice(0, 10);
1773
+ output.printTable({
1774
+ columns: [
1775
+ { key: 'path', header: 'File', width: 50 },
1776
+ { key: 'degree', header: 'Connections', width: 12, align: 'right' },
1777
+ { key: 'complexity', header: 'Complexity', width: 12, align: 'right' },
1778
+ ],
1779
+ data: nodesByDegree.map(n => ({
1780
+ path: n.path.length > 48 ? '...' + n.path.slice(-45) : n.path,
1781
+ degree: n.degree,
1782
+ complexity: n.complexity || 0,
1783
+ })),
1784
+ });
1785
+ // Show circular dependencies
1786
+ if (circularDeps.length > 0) {
1787
+ output.writeln();
1788
+ output.writeln(output.bold(output.warning(`Circular Dependencies: ${circularDeps.length}`)));
1789
+ output.writeln();
1790
+ for (const cycle of circularDeps.slice(0, 3)) {
1791
+ output.writeln(` ${cycle.cycle.join(' -> ')}`);
1792
+ }
1793
+ if (circularDeps.length > 3) {
1794
+ output.writeln(output.dim(` ... and ${circularDeps.length - 3} more`));
1795
+ }
1796
+ }
1797
+ if (outputFile) {
1798
+ const fullOutput = {
1799
+ nodes: Array.from(graph.nodes.values()),
1800
+ edges: graph.edges,
1801
+ metadata: graph.metadata,
1802
+ circularDependencies: circularDeps,
1803
+ };
1804
+ await writeFile(outputFile, JSON.stringify(fullOutput, null, 2));
1805
+ output.printSuccess(`Full results written to ${outputFile}`);
1806
+ }
1807
+ return { success: true };
1808
+ }
1809
+ catch (error) {
1810
+ spinner.stop();
1811
+ const message = error instanceof Error ? error.message : String(error);
1812
+ output.printError(`Analysis failed: ${message}`);
1813
+ return { success: false, exitCode: 1 };
1814
+ }
1815
+ },
1816
+ };
1817
+ /**
1818
+ * Detect circular dependencies
1819
+ */
1820
+ const circularCommand = {
1821
+ name: 'circular',
1822
+ aliases: ['cycles'],
1823
+ description: 'Detect circular dependencies in codebase',
1824
+ options: [
1825
+ {
1826
+ name: 'output',
1827
+ short: 'o',
1828
+ description: 'Output file path',
1829
+ type: 'string',
1830
+ },
1831
+ {
1832
+ name: 'format',
1833
+ short: 'f',
1834
+ description: 'Output format (text, json)',
1835
+ type: 'string',
1836
+ default: 'text',
1837
+ choices: ['text', 'json'],
1838
+ },
1839
+ {
1840
+ name: 'severity',
1841
+ short: 's',
1842
+ description: 'Minimum severity to show (low, medium, high)',
1843
+ type: 'string',
1844
+ default: 'low',
1845
+ choices: ['low', 'medium', 'high'],
1846
+ },
1847
+ ],
1848
+ examples: [
1849
+ { command: 'monobrain analyze circular src/', description: 'Find circular dependencies' },
1850
+ { command: 'monobrain analyze circular -s high src/', description: 'Only high severity cycles' },
1851
+ ],
1852
+ action: async (ctx) => {
1853
+ const targetDir = ctx.args[0] || ctx.cwd;
1854
+ const outputFile = ctx.flags.output;
1855
+ const format = ctx.flags.format || 'text';
1856
+ const minSeverity = ctx.flags.severity || 'low';
1857
+ output.printInfo(`Detecting circular dependencies in: ${output.highlight(targetDir)}`);
1858
+ output.writeln();
1859
+ const spinner = output.createSpinner({ text: 'Analyzing dependencies...', spinner: 'dots' });
1860
+ spinner.start();
1861
+ try {
1862
+ const analyzer = await getGraphAnalyzer();
1863
+ if (!analyzer) {
1864
+ spinner.stop();
1865
+ output.printError('Graph analyzer module not available');
1866
+ return { success: false, exitCode: 1 };
1867
+ }
1868
+ const graph = await analyzer.buildDependencyGraph(resolve(targetDir));
1869
+ const cycles = analyzer.detectCircularDependencies(graph);
1870
+ spinner.stop();
1871
+ // Filter by severity
1872
+ const severityOrder = { low: 0, medium: 1, high: 2 };
1873
+ const minLevel = severityOrder[minSeverity] || 0;
1874
+ const filtered = cycles.filter(c => severityOrder[c.severity] >= minLevel);
1875
+ if (format === 'json') {
1876
+ const jsonOutput = { cycles: filtered, total: cycles.length, filtered: filtered.length };
1877
+ if (outputFile) {
1878
+ await writeFile(outputFile, JSON.stringify(jsonOutput, null, 2));
1879
+ output.printSuccess(`Results written to ${outputFile}`);
1880
+ }
1881
+ else {
1882
+ output.printJson(jsonOutput);
1883
+ }
1884
+ return { success: true, data: jsonOutput };
1885
+ }
1886
+ // Text format
1887
+ if (filtered.length === 0) {
1888
+ output.printSuccess('No circular dependencies found!');
1889
+ return { success: true };
1890
+ }
1891
+ output.printBox([
1892
+ `Total cycles: ${cycles.length}`,
1893
+ `Shown (${minSeverity}+): ${filtered.length}`,
1894
+ `High severity: ${cycles.filter(c => c.severity === 'high').length}`,
1895
+ `Medium severity: ${cycles.filter(c => c.severity === 'medium').length}`,
1896
+ `Low severity: ${cycles.filter(c => c.severity === 'low').length}`,
1897
+ ].join('\n'), 'Circular Dependencies');
1898
+ output.writeln();
1899
+ // Group by severity
1900
+ const grouped = {
1901
+ high: filtered.filter(c => c.severity === 'high'),
1902
+ medium: filtered.filter(c => c.severity === 'medium'),
1903
+ low: filtered.filter(c => c.severity === 'low'),
1904
+ };
1905
+ for (const [severity, items] of Object.entries(grouped)) {
1906
+ if (items.length === 0)
1907
+ continue;
1908
+ const color = severity === 'high' ? output.error : severity === 'medium' ? output.warning : output.dim;
1909
+ output.writeln(color(output.bold(`${severity.toUpperCase()} SEVERITY (${items.length})`)));
1910
+ output.writeln();
1911
+ for (const cycle of items.slice(0, 5)) {
1912
+ output.writeln(` ${cycle.cycle.join(' -> ')}`);
1913
+ output.writeln(output.dim(` Fix: ${cycle.suggestion}`));
1914
+ output.writeln();
1915
+ }
1916
+ if (items.length > 5) {
1917
+ output.writeln(output.dim(` ... and ${items.length - 5} more ${severity} cycles`));
1918
+ output.writeln();
1919
+ }
1920
+ }
1921
+ if (outputFile) {
1922
+ await writeFile(outputFile, JSON.stringify({ cycles: filtered }, null, 2));
1923
+ output.printSuccess(`Results written to ${outputFile}`);
1924
+ }
1925
+ return { success: true, data: { cycles: filtered } };
1926
+ }
1927
+ catch (error) {
1928
+ spinner.stop();
1929
+ const message = error instanceof Error ? error.message : String(error);
1930
+ output.printError(`Analysis failed: ${message}`);
1931
+ return { success: false, exitCode: 1 };
1932
+ }
1933
+ },
1934
+ };
1935
+ // Helper functions
1936
+ function getRiskDisplay(risk) {
1937
+ switch (risk) {
1938
+ case 'critical':
1939
+ return output.color(output.bold('CRITICAL'), 'bgRed', 'white');
1940
+ case 'high-risk':
1941
+ return output.error('HIGH');
1942
+ case 'medium-risk':
1943
+ return output.warning('MEDIUM');
1944
+ case 'low-risk':
1945
+ return output.success('LOW');
1946
+ default:
1947
+ return risk;
1948
+ }
1949
+ }
1950
+ function getStatusDisplay(status) {
1951
+ switch (status) {
1952
+ case 'added':
1953
+ return output.success('A');
1954
+ case 'modified':
1955
+ return output.warning('M');
1956
+ case 'deleted':
1957
+ return output.error('D');
1958
+ case 'renamed':
1959
+ return output.info('R');
1960
+ default:
1961
+ return status;
1962
+ }
1963
+ }
1964
+ // Main analyze command
1965
+ export const analyzeCommand = {
1966
+ name: 'analyze',
1967
+ description: 'Code analysis, diff classification, graph boundaries, and change risk assessment',
1968
+ aliases: ['an'],
1969
+ subcommands: [
1970
+ diffCommand,
1971
+ codeCommand,
1972
+ depsCommand,
1973
+ astCommand,
1974
+ complexityAstCommand,
1975
+ symbolsCommand,
1976
+ importsCommand,
1977
+ boundariesCommand,
1978
+ modulesCommand,
1979
+ dependenciesCommand,
1980
+ circularCommand,
1981
+ ],
1982
+ options: [
1983
+ {
1984
+ name: 'format',
1985
+ short: 'f',
1986
+ description: 'Output format: text, json, table',
1987
+ type: 'string',
1988
+ default: 'text',
1989
+ },
1990
+ ],
1991
+ examples: [
1992
+ { command: 'monobrain analyze ast src/', description: 'Analyze code with AST parsing' },
1993
+ { command: 'monobrain analyze complexity src/ --threshold 15', description: 'Find high-complexity files' },
1994
+ { command: 'monobrain analyze symbols src/ --type function', description: 'Extract all functions' },
1995
+ { command: 'monobrain analyze imports src/ --external', description: 'List npm dependencies' },
1996
+ { command: 'monobrain analyze diff --risk', description: 'Analyze diff with risk assessment' },
1997
+ { command: 'monobrain analyze boundaries src/', description: 'Find code boundaries using MinCut' },
1998
+ { command: 'monobrain analyze modules src/', description: 'Detect module communities with Louvain' },
1999
+ { command: 'monobrain analyze dependencies src/ --format dot', description: 'Export dependency graph as DOT' },
2000
+ { command: 'monobrain analyze circular src/', description: 'Find circular dependencies' },
2001
+ { command: 'monobrain analyze deps --security', description: 'Check dependency vulnerabilities' },
2002
+ ],
2003
+ action: async (ctx) => {
2004
+ // If no subcommand, show help
2005
+ output.writeln();
2006
+ output.writeln(output.bold('Analyze Commands'));
2007
+ output.writeln(output.dim('-'.repeat(50)));
2008
+ output.writeln();
2009
+ output.writeln(output.bold('Available subcommands:'));
2010
+ output.writeln();
2011
+ output.writeln(` ${output.highlight('diff')} Analyze git diff for change risk and classification`);
2012
+ output.writeln(` ${output.highlight('code')} Static code analysis and quality assessment`);
2013
+ output.writeln(` ${output.highlight('deps')} Analyze project dependencies`);
2014
+ output.writeln(` ${output.highlight('ast')} AST analysis with symbol extraction and complexity`);
2015
+ output.writeln(` ${output.highlight('complexity')} Analyze cyclomatic and cognitive complexity`);
2016
+ output.writeln(` ${output.highlight('symbols')} Extract functions, classes, and types`);
2017
+ output.writeln(` ${output.highlight('imports')} Analyze import dependencies`);
2018
+ output.writeln(` ${output.highlight('boundaries')} Find code boundaries using MinCut algorithm`);
2019
+ output.writeln(` ${output.highlight('modules')} Detect module communities using Louvain algorithm`);
2020
+ output.writeln(` ${output.highlight('dependencies')} Build and export full dependency graph`);
2021
+ output.writeln(` ${output.highlight('circular')} Detect circular dependencies in codebase`);
2022
+ output.writeln();
2023
+ output.writeln(output.bold('AST Analysis Examples:'));
2024
+ output.writeln();
2025
+ output.writeln(` ${output.dim('monobrain analyze ast src/')} # Full AST analysis`);
2026
+ output.writeln(` ${output.dim('monobrain analyze ast src/index.ts -c')} # Include complexity`);
2027
+ output.writeln(` ${output.dim('monobrain analyze complexity src/ -t 15')} # Flag high complexity`);
2028
+ output.writeln(` ${output.dim('monobrain analyze symbols src/ --type fn')} # Extract functions`);
2029
+ output.writeln(` ${output.dim('monobrain analyze imports src/ --external')} # Only npm imports`);
2030
+ output.writeln();
2031
+ output.writeln(output.bold('Graph Analysis Examples:'));
2032
+ output.writeln();
2033
+ output.writeln(` ${output.dim('monobrain analyze boundaries src/')} # Find natural code boundaries`);
2034
+ output.writeln(` ${output.dim('monobrain analyze modules src/')} # Detect module communities`);
2035
+ output.writeln(` ${output.dim('monobrain analyze dependencies -f dot src/')} # Export to DOT format`);
2036
+ output.writeln(` ${output.dim('monobrain analyze circular src/')} # Find circular deps`);
2037
+ output.writeln();
2038
+ output.writeln(output.bold('Diff Analysis Examples:'));
2039
+ output.writeln();
2040
+ output.writeln(` ${output.dim('monobrain analyze diff --risk')} # Risk assessment`);
2041
+ output.writeln(` ${output.dim('monobrain analyze diff HEAD~1 --classify')} # Classify changes`);
2042
+ output.writeln(` ${output.dim('monobrain analyze diff main..feature')} # Compare branches`);
2043
+ output.writeln();
2044
+ return { success: true };
2045
+ },
2046
+ };
2047
+ export default analyzeCommand;
2048
+ //# sourceMappingURL=analyze.js.map