@claude-flow/cli 3.0.0-alpha.6 → 3.0.0-alpha.61

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 (753) hide show
  1. package/.claude/agents/analysis/analyze-code-quality.md +181 -0
  2. package/.claude/agents/analysis/code-analyzer.md +210 -0
  3. package/.claude/agents/architecture/arch-system-design.md +157 -0
  4. package/.claude/agents/consensus/byzantine-coordinator.md +63 -0
  5. package/.claude/agents/consensus/crdt-synchronizer.md +997 -0
  6. package/.claude/agents/consensus/gossip-coordinator.md +63 -0
  7. package/.claude/agents/consensus/performance-benchmarker.md +851 -0
  8. package/.claude/agents/consensus/quorum-manager.md +823 -0
  9. package/.claude/agents/consensus/raft-manager.md +63 -0
  10. package/.claude/agents/consensus/security-manager.md +622 -0
  11. package/.claude/agents/core/coder.md +453 -0
  12. package/.claude/agents/core/planner.md +375 -0
  13. package/.claude/agents/core/researcher.md +369 -0
  14. package/.claude/agents/core/reviewer.md +520 -0
  15. package/.claude/agents/core/tester.md +512 -0
  16. package/.claude/agents/custom/test-long-runner.md +44 -0
  17. package/.claude/agents/data/data-ml-model.md +445 -0
  18. package/.claude/agents/development/dev-backend-api.md +346 -0
  19. package/.claude/agents/devops/ops-cicd-github.md +165 -0
  20. package/.claude/agents/documentation/docs-api-openapi.md +355 -0
  21. package/.claude/agents/flow-nexus/app-store.md +88 -0
  22. package/.claude/agents/flow-nexus/authentication.md +69 -0
  23. package/.claude/agents/flow-nexus/challenges.md +81 -0
  24. package/.claude/agents/flow-nexus/neural-network.md +88 -0
  25. package/.claude/agents/flow-nexus/payments.md +83 -0
  26. package/.claude/agents/flow-nexus/sandbox.md +76 -0
  27. package/.claude/agents/flow-nexus/swarm.md +76 -0
  28. package/.claude/agents/flow-nexus/user-tools.md +96 -0
  29. package/.claude/agents/flow-nexus/workflow.md +84 -0
  30. package/.claude/agents/github/code-review-swarm.md +377 -0
  31. package/.claude/agents/github/github-modes.md +173 -0
  32. package/.claude/agents/github/issue-tracker.md +576 -0
  33. package/.claude/agents/github/multi-repo-swarm.md +553 -0
  34. package/.claude/agents/github/pr-manager.md +438 -0
  35. package/.claude/agents/github/project-board-sync.md +509 -0
  36. package/.claude/agents/github/release-manager.md +605 -0
  37. package/.claude/agents/github/release-swarm.md +583 -0
  38. package/.claude/agents/github/repo-architect.md +398 -0
  39. package/.claude/agents/github/swarm-issue.md +573 -0
  40. package/.claude/agents/github/swarm-pr.md +428 -0
  41. package/.claude/agents/github/sync-coordinator.md +452 -0
  42. package/.claude/agents/github/workflow-automation.md +903 -0
  43. package/.claude/agents/goal/agent.md +816 -0
  44. package/.claude/agents/goal/goal-planner.md +73 -0
  45. package/.claude/agents/optimization/benchmark-suite.md +665 -0
  46. package/.claude/agents/optimization/load-balancer.md +431 -0
  47. package/.claude/agents/optimization/performance-monitor.md +672 -0
  48. package/.claude/agents/optimization/resource-allocator.md +674 -0
  49. package/.claude/agents/optimization/topology-optimizer.md +808 -0
  50. package/.claude/agents/payments/agentic-payments.md +126 -0
  51. package/.claude/agents/sona/sona-learning-optimizer.md +254 -0
  52. package/.claude/agents/sparc/architecture.md +699 -0
  53. package/.claude/agents/sparc/pseudocode.md +520 -0
  54. package/.claude/agents/sparc/refinement.md +802 -0
  55. package/.claude/agents/sparc/specification.md +478 -0
  56. package/.claude/agents/specialized/spec-mobile-react-native.md +227 -0
  57. package/.claude/agents/sublinear/consensus-coordinator.md +338 -0
  58. package/.claude/agents/sublinear/matrix-optimizer.md +185 -0
  59. package/.claude/agents/sublinear/pagerank-analyzer.md +299 -0
  60. package/.claude/agents/sublinear/performance-optimizer.md +368 -0
  61. package/.claude/agents/sublinear/trading-predictor.md +246 -0
  62. package/.claude/agents/swarm/adaptive-coordinator.md +1127 -0
  63. package/.claude/agents/swarm/hierarchical-coordinator.md +710 -0
  64. package/.claude/agents/swarm/mesh-coordinator.md +963 -0
  65. package/.claude/agents/templates/automation-smart-agent.md +205 -0
  66. package/.claude/agents/templates/base-template-generator.md +268 -0
  67. package/.claude/agents/templates/coordinator-swarm-init.md +90 -0
  68. package/.claude/agents/templates/github-pr-manager.md +177 -0
  69. package/.claude/agents/templates/implementer-sparc-coder.md +259 -0
  70. package/.claude/agents/templates/memory-coordinator.md +187 -0
  71. package/.claude/agents/templates/orchestrator-task.md +139 -0
  72. package/.claude/agents/templates/performance-analyzer.md +199 -0
  73. package/.claude/agents/templates/sparc-coordinator.md +514 -0
  74. package/.claude/agents/testing/production-validator.md +395 -0
  75. package/.claude/agents/testing/tdd-london-swarm.md +244 -0
  76. package/.claude/agents/v3/adr-architect.md +184 -0
  77. package/.claude/agents/v3/claims-authorizer.md +208 -0
  78. package/.claude/agents/v3/collective-intelligence-coordinator.md +993 -0
  79. package/.claude/agents/v3/ddd-domain-expert.md +220 -0
  80. package/.claude/agents/v3/memory-specialist.md +995 -0
  81. package/.claude/agents/v3/performance-engineer.md +1233 -0
  82. package/.claude/agents/v3/reasoningbank-learner.md +213 -0
  83. package/.claude/agents/v3/security-architect.md +867 -0
  84. package/.claude/agents/v3/security-auditor.md +771 -0
  85. package/.claude/agents/v3/sparc-orchestrator.md +182 -0
  86. package/.claude/agents/v3/swarm-memory-manager.md +157 -0
  87. package/.claude/agents/v3/v3-integration-architect.md +205 -0
  88. package/.claude/commands/agents/README.md +50 -0
  89. package/.claude/commands/agents/agent-capabilities.md +140 -0
  90. package/.claude/commands/agents/agent-coordination.md +28 -0
  91. package/.claude/commands/agents/agent-spawning.md +28 -0
  92. package/.claude/commands/agents/agent-types.md +216 -0
  93. package/.claude/commands/agents/health.md +139 -0
  94. package/.claude/commands/agents/list.md +100 -0
  95. package/.claude/commands/agents/logs.md +130 -0
  96. package/.claude/commands/agents/metrics.md +122 -0
  97. package/.claude/commands/agents/pool.md +127 -0
  98. package/.claude/commands/agents/spawn.md +140 -0
  99. package/.claude/commands/agents/status.md +115 -0
  100. package/.claude/commands/agents/stop.md +102 -0
  101. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
  102. package/.claude/commands/analysis/README.md +9 -0
  103. package/.claude/commands/analysis/bottleneck-detect.md +162 -0
  104. package/.claude/commands/analysis/performance-bottlenecks.md +59 -0
  105. package/.claude/commands/analysis/performance-report.md +25 -0
  106. package/.claude/commands/analysis/token-efficiency.md +45 -0
  107. package/.claude/commands/analysis/token-usage.md +25 -0
  108. package/.claude/commands/automation/README.md +9 -0
  109. package/.claude/commands/automation/auto-agent.md +122 -0
  110. package/.claude/commands/automation/self-healing.md +106 -0
  111. package/.claude/commands/automation/session-memory.md +90 -0
  112. package/.claude/commands/automation/smart-agents.md +73 -0
  113. package/.claude/commands/automation/smart-spawn.md +25 -0
  114. package/.claude/commands/automation/workflow-select.md +25 -0
  115. package/.claude/commands/claude-flow-help.md +103 -0
  116. package/.claude/commands/claude-flow-memory.md +107 -0
  117. package/.claude/commands/claude-flow-swarm.md +205 -0
  118. package/.claude/commands/coordination/README.md +9 -0
  119. package/.claude/commands/coordination/agent-spawn.md +25 -0
  120. package/.claude/commands/coordination/init.md +44 -0
  121. package/.claude/commands/coordination/orchestrate.md +43 -0
  122. package/.claude/commands/coordination/spawn.md +45 -0
  123. package/.claude/commands/coordination/swarm-init.md +85 -0
  124. package/.claude/commands/coordination/task-orchestrate.md +25 -0
  125. package/.claude/commands/flow-nexus/app-store.md +124 -0
  126. package/.claude/commands/flow-nexus/challenges.md +120 -0
  127. package/.claude/commands/flow-nexus/login-registration.md +65 -0
  128. package/.claude/commands/flow-nexus/neural-network.md +134 -0
  129. package/.claude/commands/flow-nexus/payments.md +116 -0
  130. package/.claude/commands/flow-nexus/sandbox.md +83 -0
  131. package/.claude/commands/flow-nexus/swarm.md +87 -0
  132. package/.claude/commands/flow-nexus/user-tools.md +152 -0
  133. package/.claude/commands/flow-nexus/workflow.md +115 -0
  134. package/.claude/commands/github/README.md +11 -0
  135. package/.claude/commands/github/code-review-swarm.md +514 -0
  136. package/.claude/commands/github/code-review.md +25 -0
  137. package/.claude/commands/github/github-modes.md +147 -0
  138. package/.claude/commands/github/github-swarm.md +121 -0
  139. package/.claude/commands/github/issue-tracker.md +292 -0
  140. package/.claude/commands/github/issue-triage.md +25 -0
  141. package/.claude/commands/github/multi-repo-swarm.md +519 -0
  142. package/.claude/commands/github/pr-enhance.md +26 -0
  143. package/.claude/commands/github/pr-manager.md +170 -0
  144. package/.claude/commands/github/project-board-sync.md +471 -0
  145. package/.claude/commands/github/release-manager.md +338 -0
  146. package/.claude/commands/github/release-swarm.md +544 -0
  147. package/.claude/commands/github/repo-analyze.md +25 -0
  148. package/.claude/commands/github/repo-architect.md +367 -0
  149. package/.claude/commands/github/swarm-issue.md +482 -0
  150. package/.claude/commands/github/swarm-pr.md +285 -0
  151. package/.claude/commands/github/sync-coordinator.md +301 -0
  152. package/.claude/commands/github/workflow-automation.md +442 -0
  153. package/.claude/commands/hive-mind/README.md +17 -0
  154. package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -0
  155. package/.claude/commands/hive-mind/hive-mind-init.md +18 -0
  156. package/.claude/commands/hive-mind/hive-mind-memory.md +8 -0
  157. package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -0
  158. package/.claude/commands/hive-mind/hive-mind-resume.md +8 -0
  159. package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -0
  160. package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -0
  161. package/.claude/commands/hive-mind/hive-mind-status.md +8 -0
  162. package/.claude/commands/hive-mind/hive-mind-stop.md +8 -0
  163. package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -0
  164. package/.claude/commands/hive-mind/hive-mind.md +27 -0
  165. package/.claude/commands/hooks/README.md +11 -0
  166. package/.claude/commands/hooks/overview.md +58 -0
  167. package/.claude/commands/hooks/post-edit.md +117 -0
  168. package/.claude/commands/hooks/post-task.md +112 -0
  169. package/.claude/commands/hooks/pre-edit.md +113 -0
  170. package/.claude/commands/hooks/pre-task.md +111 -0
  171. package/.claude/commands/hooks/session-end.md +118 -0
  172. package/.claude/commands/hooks/setup.md +103 -0
  173. package/.claude/commands/memory/README.md +9 -0
  174. package/.claude/commands/memory/memory-persist.md +25 -0
  175. package/.claude/commands/memory/memory-search.md +25 -0
  176. package/.claude/commands/memory/memory-usage.md +25 -0
  177. package/.claude/commands/memory/neural.md +47 -0
  178. package/.claude/commands/monitoring/README.md +9 -0
  179. package/.claude/commands/monitoring/agent-metrics.md +25 -0
  180. package/.claude/commands/monitoring/agents.md +44 -0
  181. package/.claude/commands/monitoring/real-time-view.md +25 -0
  182. package/.claude/commands/monitoring/status.md +46 -0
  183. package/.claude/commands/monitoring/swarm-monitor.md +25 -0
  184. package/.claude/commands/optimization/README.md +9 -0
  185. package/.claude/commands/optimization/auto-topology.md +62 -0
  186. package/.claude/commands/optimization/cache-manage.md +25 -0
  187. package/.claude/commands/optimization/parallel-execute.md +25 -0
  188. package/.claude/commands/optimization/parallel-execution.md +50 -0
  189. package/.claude/commands/optimization/topology-optimize.md +25 -0
  190. package/.claude/commands/pair/README.md +261 -0
  191. package/.claude/commands/pair/commands.md +546 -0
  192. package/.claude/commands/pair/config.md +510 -0
  193. package/.claude/commands/pair/examples.md +512 -0
  194. package/.claude/commands/pair/modes.md +348 -0
  195. package/.claude/commands/pair/session.md +407 -0
  196. package/.claude/commands/pair/start.md +209 -0
  197. package/.claude/commands/sparc/analyzer.md +52 -0
  198. package/.claude/commands/sparc/architect.md +53 -0
  199. package/.claude/commands/sparc/ask.md +97 -0
  200. package/.claude/commands/sparc/batch-executor.md +54 -0
  201. package/.claude/commands/sparc/code.md +89 -0
  202. package/.claude/commands/sparc/coder.md +54 -0
  203. package/.claude/commands/sparc/debug.md +83 -0
  204. package/.claude/commands/sparc/debugger.md +54 -0
  205. package/.claude/commands/sparc/designer.md +53 -0
  206. package/.claude/commands/sparc/devops.md +109 -0
  207. package/.claude/commands/sparc/docs-writer.md +80 -0
  208. package/.claude/commands/sparc/documenter.md +54 -0
  209. package/.claude/commands/sparc/innovator.md +54 -0
  210. package/.claude/commands/sparc/integration.md +83 -0
  211. package/.claude/commands/sparc/mcp.md +117 -0
  212. package/.claude/commands/sparc/memory-manager.md +54 -0
  213. package/.claude/commands/sparc/optimizer.md +54 -0
  214. package/.claude/commands/sparc/orchestrator.md +132 -0
  215. package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -0
  216. package/.claude/commands/sparc/refinement-optimization-mode.md +83 -0
  217. package/.claude/commands/sparc/researcher.md +54 -0
  218. package/.claude/commands/sparc/reviewer.md +54 -0
  219. package/.claude/commands/sparc/security-review.md +80 -0
  220. package/.claude/commands/sparc/sparc-modes.md +174 -0
  221. package/.claude/commands/sparc/sparc.md +111 -0
  222. package/.claude/commands/sparc/spec-pseudocode.md +80 -0
  223. package/.claude/commands/sparc/supabase-admin.md +348 -0
  224. package/.claude/commands/sparc/swarm-coordinator.md +54 -0
  225. package/.claude/commands/sparc/tdd.md +54 -0
  226. package/.claude/commands/sparc/tester.md +54 -0
  227. package/.claude/commands/sparc/tutorial.md +79 -0
  228. package/.claude/commands/sparc/workflow-manager.md +54 -0
  229. package/.claude/commands/sparc.md +166 -0
  230. package/.claude/commands/stream-chain/pipeline.md +121 -0
  231. package/.claude/commands/stream-chain/run.md +70 -0
  232. package/.claude/commands/swarm/README.md +15 -0
  233. package/.claude/commands/swarm/analysis.md +95 -0
  234. package/.claude/commands/swarm/development.md +96 -0
  235. package/.claude/commands/swarm/examples.md +168 -0
  236. package/.claude/commands/swarm/maintenance.md +102 -0
  237. package/.claude/commands/swarm/optimization.md +117 -0
  238. package/.claude/commands/swarm/research.md +136 -0
  239. package/.claude/commands/swarm/swarm-analysis.md +8 -0
  240. package/.claude/commands/swarm/swarm-background.md +8 -0
  241. package/.claude/commands/swarm/swarm-init.md +19 -0
  242. package/.claude/commands/swarm/swarm-modes.md +8 -0
  243. package/.claude/commands/swarm/swarm-monitor.md +8 -0
  244. package/.claude/commands/swarm/swarm-spawn.md +19 -0
  245. package/.claude/commands/swarm/swarm-status.md +8 -0
  246. package/.claude/commands/swarm/swarm-strategies.md +8 -0
  247. package/.claude/commands/swarm/swarm.md +87 -0
  248. package/.claude/commands/swarm/testing.md +131 -0
  249. package/.claude/commands/training/README.md +9 -0
  250. package/.claude/commands/training/model-update.md +25 -0
  251. package/.claude/commands/training/neural-patterns.md +74 -0
  252. package/.claude/commands/training/neural-train.md +25 -0
  253. package/.claude/commands/training/pattern-learn.md +25 -0
  254. package/.claude/commands/training/specialization.md +63 -0
  255. package/.claude/commands/truth/start.md +143 -0
  256. package/.claude/commands/verify/check.md +50 -0
  257. package/.claude/commands/verify/start.md +128 -0
  258. package/.claude/commands/workflows/README.md +9 -0
  259. package/.claude/commands/workflows/development.md +78 -0
  260. package/.claude/commands/workflows/research.md +63 -0
  261. package/.claude/commands/workflows/workflow-create.md +25 -0
  262. package/.claude/commands/workflows/workflow-execute.md +25 -0
  263. package/.claude/commands/workflows/workflow-export.md +25 -0
  264. package/.claude/helpers/README.md +97 -0
  265. package/.claude/helpers/adr-compliance.sh +186 -0
  266. package/.claude/helpers/auto-commit.sh +178 -0
  267. package/.claude/helpers/checkpoint-manager.sh +251 -0
  268. package/.claude/helpers/daemon-manager.sh +252 -0
  269. package/.claude/helpers/ddd-tracker.sh +144 -0
  270. package/.claude/helpers/github-safe.js +106 -0
  271. package/.claude/helpers/github-setup.sh +28 -0
  272. package/.claude/helpers/guidance-hook.sh +13 -0
  273. package/.claude/helpers/guidance-hooks.sh +102 -0
  274. package/.claude/helpers/health-monitor.sh +108 -0
  275. package/.claude/helpers/learning-hooks.sh +329 -0
  276. package/.claude/helpers/learning-optimizer.sh +127 -0
  277. package/.claude/helpers/learning-service.mjs +1144 -0
  278. package/.claude/helpers/memory.js +83 -0
  279. package/.claude/helpers/metrics-db.mjs +488 -0
  280. package/.claude/helpers/pattern-consolidator.sh +86 -0
  281. package/.claude/helpers/perf-worker.sh +160 -0
  282. package/.claude/helpers/post-commit +16 -0
  283. package/.claude/helpers/pre-commit +26 -0
  284. package/.claude/helpers/quick-start.sh +19 -0
  285. package/.claude/helpers/router.js +66 -0
  286. package/.claude/helpers/security-scanner.sh +127 -0
  287. package/.claude/helpers/session.js +127 -0
  288. package/.claude/helpers/setup-mcp.sh +18 -0
  289. package/.claude/helpers/standard-checkpoint-hooks.sh +189 -0
  290. package/.claude/helpers/statusline-hook.sh +21 -0
  291. package/.claude/helpers/statusline.js +316 -0
  292. package/.claude/helpers/swarm-comms.sh +353 -0
  293. package/.claude/helpers/swarm-hooks.sh +761 -0
  294. package/.claude/helpers/swarm-monitor.sh +211 -0
  295. package/.claude/helpers/sync-v3-metrics.sh +245 -0
  296. package/.claude/helpers/update-v3-progress.sh +166 -0
  297. package/.claude/helpers/v3-quick-status.sh +58 -0
  298. package/.claude/helpers/v3.sh +111 -0
  299. package/.claude/helpers/validate-v3-config.sh +216 -0
  300. package/.claude/helpers/worker-manager.sh +170 -0
  301. package/.claude/settings.json +259 -0
  302. package/.claude/skills/agentdb-advanced/SKILL.md +550 -0
  303. package/.claude/skills/agentdb-learning/SKILL.md +545 -0
  304. package/.claude/skills/agentdb-memory-patterns/SKILL.md +339 -0
  305. package/.claude/skills/agentdb-optimization/SKILL.md +509 -0
  306. package/.claude/skills/agentdb-vector-search/SKILL.md +339 -0
  307. package/.claude/skills/agentic-jujutsu/SKILL.md +645 -0
  308. package/.claude/skills/flow-nexus-neural/SKILL.md +738 -0
  309. package/.claude/skills/flow-nexus-platform/SKILL.md +1157 -0
  310. package/.claude/skills/flow-nexus-swarm/SKILL.md +610 -0
  311. package/.claude/skills/github-code-review/SKILL.md +1140 -0
  312. package/.claude/skills/github-multi-repo/SKILL.md +874 -0
  313. package/.claude/skills/github-project-management/SKILL.md +1277 -0
  314. package/.claude/skills/github-release-management/SKILL.md +1081 -0
  315. package/.claude/skills/github-workflow-automation/SKILL.md +1065 -0
  316. package/.claude/skills/hive-mind-advanced/SKILL.md +712 -0
  317. package/.claude/skills/hooks-automation/SKILL.md +1201 -0
  318. package/.claude/skills/pair-programming/SKILL.md +1202 -0
  319. package/.claude/skills/performance-analysis/SKILL.md +563 -0
  320. package/.claude/skills/reasoningbank-agentdb/SKILL.md +446 -0
  321. package/.claude/skills/reasoningbank-intelligence/SKILL.md +201 -0
  322. package/{.claude-flow → .claude/skills/skill-builder/.claude-flow}/metrics/performance.json +3 -3
  323. package/.claude/skills/skill-builder/.claude-flow/metrics/task-metrics.json +10 -0
  324. package/.claude/skills/skill-builder/SKILL.md +910 -0
  325. package/.claude/skills/sparc-methodology/SKILL.md +1115 -0
  326. package/.claude/skills/stream-chain/SKILL.md +563 -0
  327. package/.claude/skills/swarm-advanced/SKILL.md +973 -0
  328. package/.claude/skills/swarm-orchestration/SKILL.md +179 -0
  329. package/.claude/skills/v3-cli-modernization/SKILL.md +872 -0
  330. package/.claude/skills/v3-core-implementation/SKILL.md +797 -0
  331. package/.claude/skills/v3-ddd-architecture/SKILL.md +442 -0
  332. package/.claude/skills/v3-integration-deep/SKILL.md +241 -0
  333. package/.claude/skills/v3-mcp-optimization/SKILL.md +777 -0
  334. package/.claude/skills/v3-memory-unification/SKILL.md +174 -0
  335. package/.claude/skills/v3-performance-optimization/SKILL.md +390 -0
  336. package/.claude/skills/v3-security-overhaul/SKILL.md +82 -0
  337. package/.claude/skills/v3-swarm-coordination/SKILL.md +340 -0
  338. package/.claude/skills/verification-quality/SKILL.md +649 -0
  339. package/.claude/skills/worker-benchmarks/skill.md +135 -0
  340. package/.claude/skills/worker-integration/skill.md +154 -0
  341. package/README.md +428 -6
  342. package/bin/cli.js +142 -6
  343. package/bin/mcp-server.js +188 -0
  344. package/dist/src/commands/agent.d.ts.map +1 -1
  345. package/dist/src/commands/agent.js +42 -26
  346. package/dist/src/commands/agent.js.map +1 -1
  347. package/dist/src/commands/analyze.d.ts +19 -0
  348. package/dist/src/commands/analyze.d.ts.map +1 -0
  349. package/dist/src/commands/analyze.js +1823 -0
  350. package/dist/src/commands/analyze.js.map +1 -0
  351. package/dist/src/commands/claims.d.ts +10 -0
  352. package/dist/src/commands/claims.d.ts.map +1 -0
  353. package/dist/src/commands/claims.js +288 -0
  354. package/dist/src/commands/claims.js.map +1 -0
  355. package/dist/src/commands/completions.d.ts +10 -0
  356. package/dist/src/commands/completions.d.ts.map +1 -0
  357. package/dist/src/commands/completions.js +539 -0
  358. package/dist/src/commands/completions.js.map +1 -0
  359. package/dist/src/commands/daemon.d.ts +8 -0
  360. package/dist/src/commands/daemon.d.ts.map +1 -0
  361. package/dist/src/commands/daemon.js +593 -0
  362. package/dist/src/commands/daemon.js.map +1 -0
  363. package/dist/src/commands/deployment.d.ts +10 -0
  364. package/dist/src/commands/deployment.d.ts.map +1 -0
  365. package/dist/src/commands/deployment.js +289 -0
  366. package/dist/src/commands/deployment.js.map +1 -0
  367. package/dist/src/commands/doctor.d.ts +10 -0
  368. package/dist/src/commands/doctor.d.ts.map +1 -0
  369. package/dist/src/commands/doctor.js +448 -0
  370. package/dist/src/commands/doctor.js.map +1 -0
  371. package/dist/src/commands/embeddings.d.ts +18 -0
  372. package/dist/src/commands/embeddings.d.ts.map +1 -0
  373. package/dist/src/commands/embeddings.js +616 -0
  374. package/dist/src/commands/embeddings.js.map +1 -0
  375. package/dist/src/commands/hive-mind.d.ts.map +1 -1
  376. package/dist/src/commands/hive-mind.js +252 -35
  377. package/dist/src/commands/hive-mind.js.map +1 -1
  378. package/dist/src/commands/hooks.d.ts.map +1 -1
  379. package/dist/src/commands/hooks.js +800 -6
  380. package/dist/src/commands/hooks.js.map +1 -1
  381. package/dist/src/commands/index.d.ts +52 -14
  382. package/dist/src/commands/index.d.ts.map +1 -1
  383. package/dist/src/commands/index.js +191 -38
  384. package/dist/src/commands/index.js.map +1 -1
  385. package/dist/src/commands/init.d.ts.map +1 -1
  386. package/dist/src/commands/init.js +80 -9
  387. package/dist/src/commands/init.js.map +1 -1
  388. package/dist/src/commands/issues.d.ts +21 -0
  389. package/dist/src/commands/issues.d.ts.map +1 -0
  390. package/dist/src/commands/issues.js +567 -0
  391. package/dist/src/commands/issues.js.map +1 -0
  392. package/dist/src/commands/mcp.js +3 -3
  393. package/dist/src/commands/mcp.js.map +1 -1
  394. package/dist/src/commands/memory.d.ts.map +1 -1
  395. package/dist/src/commands/memory.js +223 -4
  396. package/dist/src/commands/memory.js.map +1 -1
  397. package/dist/src/commands/neural.d.ts +10 -0
  398. package/dist/src/commands/neural.d.ts.map +1 -0
  399. package/dist/src/commands/neural.js +224 -0
  400. package/dist/src/commands/neural.js.map +1 -0
  401. package/dist/src/commands/performance.d.ts +10 -0
  402. package/dist/src/commands/performance.d.ts.map +1 -0
  403. package/dist/src/commands/performance.js +262 -0
  404. package/dist/src/commands/performance.js.map +1 -0
  405. package/dist/src/commands/plugins.d.ts +11 -0
  406. package/dist/src/commands/plugins.d.ts.map +1 -0
  407. package/dist/src/commands/plugins.js +630 -0
  408. package/dist/src/commands/plugins.js.map +1 -0
  409. package/dist/src/commands/progress.d.ts +11 -0
  410. package/dist/src/commands/progress.d.ts.map +1 -0
  411. package/dist/src/commands/progress.js +259 -0
  412. package/dist/src/commands/progress.js.map +1 -0
  413. package/dist/src/commands/providers.d.ts +10 -0
  414. package/dist/src/commands/providers.d.ts.map +1 -0
  415. package/dist/src/commands/providers.js +232 -0
  416. package/dist/src/commands/providers.js.map +1 -0
  417. package/dist/src/commands/route.d.ts +16 -0
  418. package/dist/src/commands/route.d.ts.map +1 -0
  419. package/dist/src/commands/route.js +813 -0
  420. package/dist/src/commands/route.js.map +1 -0
  421. package/dist/src/commands/security.d.ts +10 -0
  422. package/dist/src/commands/security.d.ts.map +1 -0
  423. package/dist/src/commands/security.js +261 -0
  424. package/dist/src/commands/security.js.map +1 -0
  425. package/dist/src/commands/start.d.ts.map +1 -1
  426. package/dist/src/commands/start.js +22 -2
  427. package/dist/src/commands/start.js.map +1 -1
  428. package/dist/src/commands/swarm.d.ts.map +1 -1
  429. package/dist/src/commands/swarm.js +185 -32
  430. package/dist/src/commands/swarm.js.map +1 -1
  431. package/dist/src/commands/transfer-store.d.ts +13 -0
  432. package/dist/src/commands/transfer-store.d.ts.map +1 -0
  433. package/dist/src/commands/transfer-store.js +428 -0
  434. package/dist/src/commands/transfer-store.js.map +1 -0
  435. package/dist/src/index.d.ts +3 -1
  436. package/dist/src/index.d.ts.map +1 -1
  437. package/dist/src/index.js +69 -10
  438. package/dist/src/index.js.map +1 -1
  439. package/dist/src/init/claudemd-generator.d.ts.map +1 -1
  440. package/dist/src/init/claudemd-generator.js +407 -405
  441. package/dist/src/init/claudemd-generator.js.map +1 -1
  442. package/dist/src/init/executor.d.ts.map +1 -1
  443. package/dist/src/init/executor.js +142 -31
  444. package/dist/src/init/executor.js.map +1 -1
  445. package/dist/src/init/helpers-generator.js +1 -1
  446. package/dist/src/init/helpers-generator.js.map +1 -1
  447. package/dist/src/init/mcp-generator.d.ts +9 -0
  448. package/dist/src/init/mcp-generator.d.ts.map +1 -1
  449. package/dist/src/init/mcp-generator.js +57 -28
  450. package/dist/src/init/mcp-generator.js.map +1 -1
  451. package/dist/src/init/settings-generator.d.ts.map +1 -1
  452. package/dist/src/init/settings-generator.js +116 -62
  453. package/dist/src/init/settings-generator.js.map +1 -1
  454. package/dist/src/init/statusline-generator.d.ts +6 -0
  455. package/dist/src/init/statusline-generator.d.ts.map +1 -1
  456. package/dist/src/init/statusline-generator.js +252 -89
  457. package/dist/src/init/statusline-generator.js.map +1 -1
  458. package/dist/src/init/types.d.ts +6 -0
  459. package/dist/src/init/types.d.ts.map +1 -1
  460. package/dist/src/init/types.js +8 -2
  461. package/dist/src/init/types.js.map +1 -1
  462. package/dist/src/mcp-client.d.ts.map +1 -1
  463. package/dist/src/mcp-client.js +17 -1
  464. package/dist/src/mcp-client.js.map +1 -1
  465. package/dist/src/mcp-server.d.ts +6 -1
  466. package/dist/src/mcp-server.d.ts.map +1 -1
  467. package/dist/src/mcp-server.js +169 -38
  468. package/dist/src/mcp-server.js.map +1 -1
  469. package/dist/src/mcp-tools/agent-tools.d.ts +1 -1
  470. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
  471. package/dist/src/mcp-tools/agent-tools.js +350 -14
  472. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  473. package/dist/src/mcp-tools/analyze-tools.d.ts +38 -0
  474. package/dist/src/mcp-tools/analyze-tools.d.ts.map +1 -0
  475. package/dist/src/mcp-tools/analyze-tools.js +317 -0
  476. package/dist/src/mcp-tools/analyze-tools.js.map +1 -0
  477. package/dist/src/mcp-tools/config-tools.d.ts +1 -1
  478. package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
  479. package/dist/src/mcp-tools/config-tools.js +262 -15
  480. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  481. package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
  482. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -0
  483. package/dist/src/mcp-tools/hive-mind-tools.js +447 -0
  484. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -0
  485. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  486. package/dist/src/mcp-tools/hooks-tools.js +195 -31
  487. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  488. package/dist/src/mcp-tools/index.d.ts +6 -0
  489. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  490. package/dist/src/mcp-tools/index.js +6 -0
  491. package/dist/src/mcp-tools/index.js.map +1 -1
  492. package/dist/src/mcp-tools/progress-tools.d.ts +14 -0
  493. package/dist/src/mcp-tools/progress-tools.d.ts.map +1 -0
  494. package/dist/src/mcp-tools/progress-tools.js +343 -0
  495. package/dist/src/mcp-tools/progress-tools.js.map +1 -0
  496. package/dist/src/mcp-tools/session-tools.d.ts +1 -1
  497. package/dist/src/mcp-tools/session-tools.d.ts.map +1 -1
  498. package/dist/src/mcp-tools/session-tools.js +237 -22
  499. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  500. package/dist/src/mcp-tools/task-tools.d.ts +1 -1
  501. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
  502. package/dist/src/mcp-tools/task-tools.js +219 -17
  503. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  504. package/dist/src/mcp-tools/transfer-tools.d.ts +14 -0
  505. package/dist/src/mcp-tools/transfer-tools.d.ts.map +1 -0
  506. package/dist/src/mcp-tools/transfer-tools.js +396 -0
  507. package/dist/src/mcp-tools/transfer-tools.js.map +1 -0
  508. package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
  509. package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -0
  510. package/dist/src/mcp-tools/workflow-tools.js +481 -0
  511. package/dist/src/mcp-tools/workflow-tools.js.map +1 -0
  512. package/dist/src/output.d.ts +16 -0
  513. package/dist/src/output.d.ts.map +1 -1
  514. package/dist/src/output.js +42 -0
  515. package/dist/src/output.js.map +1 -1
  516. package/dist/src/plugins/store/discovery.d.ts +73 -0
  517. package/dist/src/plugins/store/discovery.d.ts.map +1 -0
  518. package/dist/src/plugins/store/discovery.js +568 -0
  519. package/dist/src/plugins/store/discovery.js.map +1 -0
  520. package/dist/src/plugins/store/index.d.ts +76 -0
  521. package/dist/src/plugins/store/index.d.ts.map +1 -0
  522. package/dist/src/plugins/store/index.js +141 -0
  523. package/dist/src/plugins/store/index.js.map +1 -0
  524. package/dist/src/plugins/store/search.d.ts +46 -0
  525. package/dist/src/plugins/store/search.d.ts.map +1 -0
  526. package/dist/src/plugins/store/search.js +230 -0
  527. package/dist/src/plugins/store/search.js.map +1 -0
  528. package/dist/src/plugins/store/types.d.ts +274 -0
  529. package/dist/src/plugins/store/types.d.ts.map +1 -0
  530. package/dist/src/plugins/store/types.js +7 -0
  531. package/dist/src/plugins/store/types.js.map +1 -0
  532. package/dist/src/plugins/tests/demo-plugin-store.d.ts +7 -0
  533. package/dist/src/plugins/tests/demo-plugin-store.d.ts.map +1 -0
  534. package/dist/src/plugins/tests/demo-plugin-store.js +126 -0
  535. package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -0
  536. package/dist/src/plugins/tests/standalone-test.d.ts +12 -0
  537. package/dist/src/plugins/tests/standalone-test.d.ts.map +1 -0
  538. package/dist/src/plugins/tests/standalone-test.js +188 -0
  539. package/dist/src/plugins/tests/standalone-test.js.map +1 -0
  540. package/dist/src/plugins/tests/test-plugin-store.d.ts +7 -0
  541. package/dist/src/plugins/tests/test-plugin-store.d.ts.map +1 -0
  542. package/dist/src/plugins/tests/test-plugin-store.js +206 -0
  543. package/dist/src/plugins/tests/test-plugin-store.js.map +1 -0
  544. package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
  545. package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
  546. package/dist/src/ruvector/ast-analyzer.js +277 -0
  547. package/dist/src/ruvector/ast-analyzer.js.map +1 -0
  548. package/dist/src/ruvector/coverage-router.d.ts +160 -0
  549. package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
  550. package/dist/src/ruvector/coverage-router.js +529 -0
  551. package/dist/src/ruvector/coverage-router.js.map +1 -0
  552. package/dist/src/ruvector/coverage-tools.d.ts +33 -0
  553. package/dist/src/ruvector/coverage-tools.d.ts.map +1 -0
  554. package/dist/src/ruvector/coverage-tools.js +157 -0
  555. package/dist/src/ruvector/coverage-tools.js.map +1 -0
  556. package/dist/src/ruvector/diff-classifier.d.ts +175 -0
  557. package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
  558. package/dist/src/ruvector/diff-classifier.js +698 -0
  559. package/dist/src/ruvector/diff-classifier.js.map +1 -0
  560. package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
  561. package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
  562. package/dist/src/ruvector/graph-analyzer.js +929 -0
  563. package/dist/src/ruvector/graph-analyzer.js.map +1 -0
  564. package/dist/src/ruvector/index.d.ts +27 -0
  565. package/dist/src/ruvector/index.d.ts.map +1 -0
  566. package/dist/src/ruvector/index.js +53 -0
  567. package/dist/src/ruvector/index.js.map +1 -0
  568. package/dist/src/ruvector/q-learning-router.d.ts +211 -0
  569. package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
  570. package/dist/src/ruvector/q-learning-router.js +681 -0
  571. package/dist/src/ruvector/q-learning-router.js.map +1 -0
  572. package/dist/src/ruvector/vector-db.d.ts +69 -0
  573. package/dist/src/ruvector/vector-db.d.ts.map +1 -0
  574. package/dist/src/ruvector/vector-db.js +243 -0
  575. package/dist/src/ruvector/vector-db.js.map +1 -0
  576. package/dist/src/services/claim-service.d.ts +204 -0
  577. package/dist/src/services/claim-service.d.ts.map +1 -0
  578. package/dist/src/services/claim-service.js +818 -0
  579. package/dist/src/services/claim-service.js.map +1 -0
  580. package/dist/src/services/container-worker-pool.d.ts +197 -0
  581. package/dist/src/services/container-worker-pool.d.ts.map +1 -0
  582. package/dist/src/services/container-worker-pool.js +581 -0
  583. package/dist/src/services/container-worker-pool.js.map +1 -0
  584. package/dist/src/services/headless-worker-executor.d.ts +304 -0
  585. package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
  586. package/dist/src/services/headless-worker-executor.js +997 -0
  587. package/dist/src/services/headless-worker-executor.js.map +1 -0
  588. package/dist/src/services/index.d.ts +13 -0
  589. package/dist/src/services/index.d.ts.map +1 -0
  590. package/dist/src/services/index.js +11 -0
  591. package/dist/src/services/index.js.map +1 -0
  592. package/dist/src/services/worker-daemon.d.ts +203 -0
  593. package/dist/src/services/worker-daemon.d.ts.map +1 -0
  594. package/dist/src/services/worker-daemon.js +745 -0
  595. package/dist/src/services/worker-daemon.js.map +1 -0
  596. package/dist/src/services/worker-queue.d.ts +194 -0
  597. package/dist/src/services/worker-queue.d.ts.map +1 -0
  598. package/dist/src/services/worker-queue.js +511 -0
  599. package/dist/src/services/worker-queue.js.map +1 -0
  600. package/dist/src/suggest.d.ts +53 -0
  601. package/dist/src/suggest.d.ts.map +1 -0
  602. package/dist/src/suggest.js +200 -0
  603. package/dist/src/suggest.js.map +1 -0
  604. package/dist/src/transfer/anonymization/index.d.ts +25 -0
  605. package/dist/src/transfer/anonymization/index.d.ts.map +1 -0
  606. package/dist/src/transfer/anonymization/index.js +175 -0
  607. package/dist/src/transfer/anonymization/index.js.map +1 -0
  608. package/dist/src/transfer/deploy-seraphine.d.ts +13 -0
  609. package/dist/src/transfer/deploy-seraphine.d.ts.map +1 -0
  610. package/dist/src/transfer/deploy-seraphine.js +205 -0
  611. package/dist/src/transfer/deploy-seraphine.js.map +1 -0
  612. package/dist/src/transfer/export.d.ts +25 -0
  613. package/dist/src/transfer/export.d.ts.map +1 -0
  614. package/dist/src/transfer/export.js +113 -0
  615. package/dist/src/transfer/export.js.map +1 -0
  616. package/dist/src/transfer/index.d.ts +12 -0
  617. package/dist/src/transfer/index.d.ts.map +1 -0
  618. package/dist/src/transfer/index.js +31 -0
  619. package/dist/src/transfer/index.js.map +1 -0
  620. package/dist/src/transfer/ipfs/client.d.ts +31 -0
  621. package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
  622. package/dist/src/transfer/ipfs/client.js +74 -0
  623. package/dist/src/transfer/ipfs/client.js.map +1 -0
  624. package/dist/src/transfer/ipfs/upload.d.ts +95 -0
  625. package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
  626. package/dist/src/transfer/ipfs/upload.js +410 -0
  627. package/dist/src/transfer/ipfs/upload.js.map +1 -0
  628. package/dist/src/transfer/models/seraphine.d.ts +72 -0
  629. package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
  630. package/dist/src/transfer/models/seraphine.js +373 -0
  631. package/dist/src/transfer/models/seraphine.js.map +1 -0
  632. package/dist/src/transfer/serialization/cfp.d.ts +49 -0
  633. package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
  634. package/dist/src/transfer/serialization/cfp.js +180 -0
  635. package/dist/src/transfer/serialization/cfp.js.map +1 -0
  636. package/dist/src/transfer/store/discovery.d.ts +84 -0
  637. package/dist/src/transfer/store/discovery.d.ts.map +1 -0
  638. package/dist/src/transfer/store/discovery.js +275 -0
  639. package/dist/src/transfer/store/discovery.js.map +1 -0
  640. package/dist/src/transfer/store/download.d.ts +70 -0
  641. package/dist/src/transfer/store/download.d.ts.map +1 -0
  642. package/dist/src/transfer/store/download.js +295 -0
  643. package/dist/src/transfer/store/download.js.map +1 -0
  644. package/dist/src/transfer/store/index.d.ts +84 -0
  645. package/dist/src/transfer/store/index.d.ts.map +1 -0
  646. package/dist/src/transfer/store/index.js +153 -0
  647. package/dist/src/transfer/store/index.js.map +1 -0
  648. package/dist/src/transfer/store/publish.d.ts +76 -0
  649. package/dist/src/transfer/store/publish.d.ts.map +1 -0
  650. package/dist/src/transfer/store/publish.js +262 -0
  651. package/dist/src/transfer/store/publish.js.map +1 -0
  652. package/dist/src/transfer/store/registry.d.ts +58 -0
  653. package/dist/src/transfer/store/registry.d.ts.map +1 -0
  654. package/dist/src/transfer/store/registry.js +285 -0
  655. package/dist/src/transfer/store/registry.js.map +1 -0
  656. package/dist/src/transfer/store/search.d.ts +54 -0
  657. package/dist/src/transfer/store/search.d.ts.map +1 -0
  658. package/dist/src/transfer/store/search.js +232 -0
  659. package/dist/src/transfer/store/search.js.map +1 -0
  660. package/dist/src/transfer/store/tests/standalone-test.d.ts +12 -0
  661. package/dist/src/transfer/store/tests/standalone-test.d.ts.map +1 -0
  662. package/dist/src/transfer/store/tests/standalone-test.js +190 -0
  663. package/dist/src/transfer/store/tests/standalone-test.js.map +1 -0
  664. package/dist/src/transfer/store/types.d.ts +193 -0
  665. package/dist/src/transfer/store/types.d.ts.map +1 -0
  666. package/dist/src/transfer/store/types.js +6 -0
  667. package/dist/src/transfer/store/types.js.map +1 -0
  668. package/dist/src/transfer/test-seraphine.d.ts +6 -0
  669. package/dist/src/transfer/test-seraphine.d.ts.map +1 -0
  670. package/dist/src/transfer/test-seraphine.js +105 -0
  671. package/dist/src/transfer/test-seraphine.js.map +1 -0
  672. package/dist/src/transfer/tests/test-store.d.ts +7 -0
  673. package/dist/src/transfer/tests/test-store.d.ts.map +1 -0
  674. package/dist/src/transfer/tests/test-store.js +214 -0
  675. package/dist/src/transfer/tests/test-store.js.map +1 -0
  676. package/dist/src/transfer/types.d.ts +245 -0
  677. package/dist/src/transfer/types.d.ts.map +1 -0
  678. package/dist/src/transfer/types.js +6 -0
  679. package/dist/src/transfer/types.js.map +1 -0
  680. package/dist/tsconfig.tsbuildinfo +1 -1
  681. package/package.json +37 -9
  682. package/.agentic-flow/intelligence.json +0 -17
  683. package/.claude-flow/metrics/task-metrics.json +0 -10
  684. package/__tests__/README.md +0 -140
  685. package/__tests__/TEST_SUMMARY.md +0 -144
  686. package/__tests__/cli.test.ts +0 -558
  687. package/__tests__/commands.test.ts +0 -726
  688. package/__tests__/config-adapter.test.ts +0 -362
  689. package/__tests__/config-loading.test.ts +0 -106
  690. package/__tests__/coverage/.tmp/coverage-0.json +0 -1
  691. package/__tests__/coverage/.tmp/coverage-1.json +0 -1
  692. package/__tests__/coverage/.tmp/coverage-2.json +0 -1
  693. package/__tests__/coverage/.tmp/coverage-3.json +0 -1
  694. package/__tests__/coverage/.tmp/coverage-4.json +0 -1
  695. package/__tests__/coverage/.tmp/coverage-5.json +0 -1
  696. package/__tests__/mcp-client.test.ts +0 -480
  697. package/__tests__/p1-commands.test.ts +0 -1064
  698. package/agents/architect.yaml +0 -11
  699. package/agents/coder.yaml +0 -11
  700. package/agents/reviewer.yaml +0 -10
  701. package/agents/security-architect.yaml +0 -10
  702. package/agents/tester.yaml +0 -10
  703. package/docs/CONFIG_LOADING.md +0 -236
  704. package/docs/IMPLEMENTATION_COMPLETE.md +0 -421
  705. package/docs/MCP_CLIENT_GUIDE.md +0 -620
  706. package/docs/REFACTORING_SUMMARY.md +0 -247
  707. package/src/commands/agent.ts +0 -941
  708. package/src/commands/config.ts +0 -452
  709. package/src/commands/hive-mind.ts +0 -762
  710. package/src/commands/hooks.ts +0 -2603
  711. package/src/commands/index.ts +0 -115
  712. package/src/commands/init.ts +0 -597
  713. package/src/commands/mcp.ts +0 -753
  714. package/src/commands/memory.ts +0 -1161
  715. package/src/commands/migrate.ts +0 -447
  716. package/src/commands/process.ts +0 -695
  717. package/src/commands/session.ts +0 -891
  718. package/src/commands/start.ts +0 -457
  719. package/src/commands/status.ts +0 -736
  720. package/src/commands/swarm.ts +0 -648
  721. package/src/commands/task.ts +0 -792
  722. package/src/commands/workflow.ts +0 -742
  723. package/src/config-adapter.ts +0 -210
  724. package/src/index.ts +0 -400
  725. package/src/infrastructure/in-memory-repositories.ts +0 -310
  726. package/src/init/claudemd-generator.ts +0 -631
  727. package/src/init/executor.ts +0 -762
  728. package/src/init/helpers-generator.ts +0 -628
  729. package/src/init/index.ts +0 -60
  730. package/src/init/mcp-generator.ts +0 -83
  731. package/src/init/settings-generator.ts +0 -274
  732. package/src/init/statusline-generator.ts +0 -211
  733. package/src/init/types.ts +0 -447
  734. package/src/mcp-client.ts +0 -229
  735. package/src/mcp-server.ts +0 -577
  736. package/src/mcp-tools/agent-tools.ts +0 -92
  737. package/src/mcp-tools/config-tools.ts +0 -88
  738. package/src/mcp-tools/hooks-tools.ts +0 -1849
  739. package/src/mcp-tools/index.ts +0 -14
  740. package/src/mcp-tools/memory-tools.ts +0 -270
  741. package/src/mcp-tools/session-tools.ts +0 -102
  742. package/src/mcp-tools/swarm-tools.ts +0 -105
  743. package/src/mcp-tools/task-tools.ts +0 -102
  744. package/src/mcp-tools/types.ts +0 -33
  745. package/src/output.ts +0 -593
  746. package/src/parser.ts +0 -417
  747. package/src/prompt.ts +0 -619
  748. package/src/types.ts +0 -287
  749. package/tsconfig.json +0 -16
  750. package/tsconfig.tsbuildinfo +0 -1
  751. package/vitest.config.ts +0 -13
  752. /package/{tmp.json → .claude/agents/tmp.json} +0 -0
  753. /package/{.claude-flow → .claude/skills/skill-builder/.claude-flow}/metrics/agent-metrics.json +0 -0
@@ -1,2603 +0,0 @@
1
- /**
2
- * V3 CLI Hooks Command
3
- * Self-learning hooks system for intelligent workflow automation
4
- */
5
-
6
- import type { Command, CommandContext, CommandResult } from '../types.js';
7
- import { output } from '../output.js';
8
- import { select, confirm, input } from '../prompt.js';
9
- import { callMCPTool, MCPClientError } from '../mcp-client.js';
10
-
11
- // Hook types
12
- const HOOK_TYPES = [
13
- { value: 'pre-edit', label: 'Pre-Edit', hint: 'Get context before editing files' },
14
- { value: 'post-edit', label: 'Post-Edit', hint: 'Record editing outcomes' },
15
- { value: 'pre-command', label: 'Pre-Command', hint: 'Assess risk before commands' },
16
- { value: 'post-command', label: 'Post-Command', hint: 'Record command outcomes' },
17
- { value: 'route', label: 'Route', hint: 'Route tasks to optimal agents' },
18
- { value: 'explain', label: 'Explain', hint: 'Explain routing decisions' }
19
- ];
20
-
21
- // Agent routing options
22
- const AGENT_TYPES = [
23
- 'coder', 'researcher', 'tester', 'reviewer', 'architect',
24
- 'security-architect', 'security-auditor', 'memory-specialist',
25
- 'swarm-specialist', 'performance-engineer', 'core-architect',
26
- 'test-architect', 'coordinator', 'analyst', 'optimizer'
27
- ];
28
-
29
- // Pre-edit subcommand
30
- const preEditCommand: Command = {
31
- name: 'pre-edit',
32
- description: 'Get context and agent suggestions before editing a file',
33
- options: [
34
- {
35
- name: 'file',
36
- short: 'f',
37
- description: 'File path to edit',
38
- type: 'string',
39
- required: true
40
- },
41
- {
42
- name: 'operation',
43
- short: 'o',
44
- description: 'Type of edit operation (create, update, delete, refactor)',
45
- type: 'string',
46
- default: 'update'
47
- },
48
- {
49
- name: 'context',
50
- short: 'c',
51
- description: 'Additional context about the edit',
52
- type: 'string'
53
- }
54
- ],
55
- examples: [
56
- { command: 'claude-flow hooks pre-edit -f src/utils.ts', description: 'Get context before editing' },
57
- { command: 'claude-flow hooks pre-edit -f src/api.ts -o refactor', description: 'Pre-edit with operation type' }
58
- ],
59
- action: async (ctx: CommandContext): Promise<CommandResult> => {
60
- const filePath = ctx.args[0] || ctx.flags.file as string;
61
- const operation = ctx.flags.operation as string || 'update';
62
-
63
- if (!filePath) {
64
- output.printError('File path is required. Use --file or -f flag.');
65
- return { success: false, exitCode: 1 };
66
- }
67
-
68
- output.printInfo(`Analyzing context for: ${output.highlight(filePath)}`);
69
-
70
- try {
71
- // Call MCP tool for pre-edit hook
72
- const result = await callMCPTool<{
73
- filePath: string;
74
- operation: string;
75
- context: {
76
- fileExists: boolean;
77
- fileType: string;
78
- relatedFiles: string[];
79
- suggestedAgents: string[];
80
- patterns: Array<{ pattern: string; confidence: number }>;
81
- risks: string[];
82
- };
83
- recommendations: string[];
84
- }>('hooks/pre-edit', {
85
- filePath,
86
- operation,
87
- context: ctx.flags.context,
88
- includePatterns: true,
89
- includeRisks: true,
90
- });
91
-
92
- if (ctx.flags.format === 'json') {
93
- output.printJson(result);
94
- return { success: true, data: result };
95
- }
96
-
97
- output.writeln();
98
- output.printBox(
99
- [
100
- `File: ${result.filePath}`,
101
- `Operation: ${result.operation}`,
102
- `Type: ${result.context.fileType}`,
103
- `Exists: ${result.context.fileExists ? 'Yes' : 'No'}`
104
- ].join('\n'),
105
- 'File Context'
106
- );
107
-
108
- if (result.context.suggestedAgents.length > 0) {
109
- output.writeln();
110
- output.writeln(output.bold('Suggested Agents'));
111
- output.printList(result.context.suggestedAgents.map(a => output.highlight(a)));
112
- }
113
-
114
- if (result.context.relatedFiles.length > 0) {
115
- output.writeln();
116
- output.writeln(output.bold('Related Files'));
117
- output.printList(result.context.relatedFiles.slice(0, 5).map(f => output.dim(f)));
118
- }
119
-
120
- if (result.context.patterns.length > 0) {
121
- output.writeln();
122
- output.writeln(output.bold('Learned Patterns'));
123
- output.printTable({
124
- columns: [
125
- { key: 'pattern', header: 'Pattern', width: 40 },
126
- { key: 'confidence', header: 'Confidence', width: 12, align: 'right', format: (v) => `${(Number(v) * 100).toFixed(1)}%` }
127
- ],
128
- data: result.context.patterns
129
- });
130
- }
131
-
132
- if (result.context.risks.length > 0) {
133
- output.writeln();
134
- output.writeln(output.bold(output.error('Potential Risks')));
135
- output.printList(result.context.risks.map(r => output.warning(r)));
136
- }
137
-
138
- if (result.recommendations.length > 0) {
139
- output.writeln();
140
- output.writeln(output.bold('Recommendations'));
141
- output.printList(result.recommendations.map(r => output.success(`• ${r}`)));
142
- }
143
-
144
- return { success: true, data: result };
145
- } catch (error) {
146
- if (error instanceof MCPClientError) {
147
- output.printError(`Pre-edit hook failed: ${error.message}`);
148
- } else {
149
- output.printError(`Unexpected error: ${String(error)}`);
150
- }
151
- return { success: false, exitCode: 1 };
152
- }
153
- }
154
- };
155
-
156
- // Post-edit subcommand
157
- const postEditCommand: Command = {
158
- name: 'post-edit',
159
- description: 'Record editing outcome for learning',
160
- options: [
161
- {
162
- name: 'file',
163
- short: 'f',
164
- description: 'File path that was edited',
165
- type: 'string',
166
- required: true
167
- },
168
- {
169
- name: 'success',
170
- short: 's',
171
- description: 'Whether the edit was successful',
172
- type: 'boolean',
173
- required: true
174
- },
175
- {
176
- name: 'outcome',
177
- short: 'o',
178
- description: 'Outcome description',
179
- type: 'string'
180
- },
181
- {
182
- name: 'metrics',
183
- short: 'm',
184
- description: 'Performance metrics (e.g., "time:500ms,quality:0.95")',
185
- type: 'string'
186
- }
187
- ],
188
- examples: [
189
- { command: 'claude-flow hooks post-edit -f src/utils.ts --success true', description: 'Record successful edit' },
190
- { command: 'claude-flow hooks post-edit -f src/api.ts --success false -o "Type error"', description: 'Record failed edit' }
191
- ],
192
- action: async (ctx: CommandContext): Promise<CommandResult> => {
193
- const filePath = ctx.args[0] || ctx.flags.file as string;
194
- const success = ctx.flags.success as boolean;
195
-
196
- if (!filePath) {
197
- output.printError('File path is required. Use --file or -f flag.');
198
- return { success: false, exitCode: 1 };
199
- }
200
-
201
- if (success === undefined) {
202
- output.printError('Success flag is required. Use --success true/false.');
203
- return { success: false, exitCode: 1 };
204
- }
205
-
206
- output.printInfo(`Recording outcome for: ${output.highlight(filePath)}`);
207
-
208
- try {
209
- // Parse metrics if provided
210
- const metrics: Record<string, number> = {};
211
- if (ctx.flags.metrics) {
212
- const metricsStr = ctx.flags.metrics as string;
213
- metricsStr.split(',').forEach(pair => {
214
- const [key, value] = pair.split(':');
215
- if (key && value) {
216
- metrics[key.trim()] = parseFloat(value);
217
- }
218
- });
219
- }
220
-
221
- // Call MCP tool for post-edit hook
222
- const result = await callMCPTool<{
223
- filePath: string;
224
- success: boolean;
225
- recorded: boolean;
226
- patternId?: string;
227
- learningUpdates: {
228
- patternsUpdated: number;
229
- confidenceAdjusted: number;
230
- newPatterns: number;
231
- };
232
- }>('hooks/post-edit', {
233
- filePath,
234
- success,
235
- outcome: ctx.flags.outcome,
236
- metrics,
237
- timestamp: Date.now(),
238
- });
239
-
240
- if (ctx.flags.format === 'json') {
241
- output.printJson(result);
242
- return { success: true, data: result };
243
- }
244
-
245
- output.writeln();
246
- output.printSuccess(`Outcome recorded for ${filePath}`);
247
-
248
- if (result.learningUpdates) {
249
- output.writeln();
250
- output.writeln(output.bold('Learning Updates'));
251
- output.printTable({
252
- columns: [
253
- { key: 'metric', header: 'Metric', width: 25 },
254
- { key: 'value', header: 'Value', width: 15, align: 'right' }
255
- ],
256
- data: [
257
- { metric: 'Patterns Updated', value: result.learningUpdates.patternsUpdated },
258
- { metric: 'Confidence Adjusted', value: result.learningUpdates.confidenceAdjusted },
259
- { metric: 'New Patterns', value: result.learningUpdates.newPatterns }
260
- ]
261
- });
262
- }
263
-
264
- return { success: true, data: result };
265
- } catch (error) {
266
- if (error instanceof MCPClientError) {
267
- output.printError(`Post-edit hook failed: ${error.message}`);
268
- } else {
269
- output.printError(`Unexpected error: ${String(error)}`);
270
- }
271
- return { success: false, exitCode: 1 };
272
- }
273
- }
274
- };
275
-
276
- // Pre-command subcommand
277
- const preCommandCommand: Command = {
278
- name: 'pre-command',
279
- description: 'Assess risk before executing a command',
280
- options: [
281
- {
282
- name: 'command',
283
- short: 'c',
284
- description: 'Command to execute',
285
- type: 'string',
286
- required: true
287
- },
288
- {
289
- name: 'dry-run',
290
- short: 'd',
291
- description: 'Only analyze, do not execute',
292
- type: 'boolean',
293
- default: true
294
- }
295
- ],
296
- examples: [
297
- { command: 'claude-flow hooks pre-command -c "rm -rf dist"', description: 'Assess command risk' },
298
- { command: 'claude-flow hooks pre-command -c "npm install lodash"', description: 'Check package install' }
299
- ],
300
- action: async (ctx: CommandContext): Promise<CommandResult> => {
301
- const command = ctx.args[0] || ctx.flags.command as string;
302
-
303
- if (!command) {
304
- output.printError('Command is required. Use --command or -c flag.');
305
- return { success: false, exitCode: 1 };
306
- }
307
-
308
- output.printInfo(`Analyzing command: ${output.highlight(command)}`);
309
-
310
- try {
311
- // Call MCP tool for pre-command hook
312
- const result = await callMCPTool<{
313
- command: string;
314
- riskLevel: 'low' | 'medium' | 'high' | 'critical';
315
- risks: Array<{ type: string; severity: string; description: string }>;
316
- recommendations: string[];
317
- safeAlternatives?: string[];
318
- shouldProceed: boolean;
319
- }>('hooks/pre-command', {
320
- command,
321
- includeAlternatives: true,
322
- });
323
-
324
- if (ctx.flags.format === 'json') {
325
- output.printJson(result);
326
- return { success: true, data: result };
327
- }
328
-
329
- output.writeln();
330
-
331
- // Risk level indicator
332
- let riskIndicator: string;
333
- switch (result.riskLevel) {
334
- case 'critical':
335
- riskIndicator = output.error('CRITICAL');
336
- break;
337
- case 'high':
338
- riskIndicator = output.error('HIGH');
339
- break;
340
- case 'medium':
341
- riskIndicator = output.warning('MEDIUM');
342
- break;
343
- default:
344
- riskIndicator = output.success('LOW');
345
- }
346
-
347
- output.printBox(
348
- [
349
- `Risk Level: ${riskIndicator}`,
350
- `Should Proceed: ${result.shouldProceed ? output.success('Yes') : output.error('No')}`
351
- ].join('\n'),
352
- 'Risk Assessment'
353
- );
354
-
355
- if (result.risks.length > 0) {
356
- output.writeln();
357
- output.writeln(output.bold('Identified Risks'));
358
- output.printTable({
359
- columns: [
360
- { key: 'type', header: 'Type', width: 15 },
361
- { key: 'severity', header: 'Severity', width: 10 },
362
- { key: 'description', header: 'Description', width: 40 }
363
- ],
364
- data: result.risks
365
- });
366
- }
367
-
368
- if (result.safeAlternatives && result.safeAlternatives.length > 0) {
369
- output.writeln();
370
- output.writeln(output.bold('Safe Alternatives'));
371
- output.printList(result.safeAlternatives.map(a => output.success(a)));
372
- }
373
-
374
- if (result.recommendations.length > 0) {
375
- output.writeln();
376
- output.writeln(output.bold('Recommendations'));
377
- output.printList(result.recommendations);
378
- }
379
-
380
- return { success: true, data: result };
381
- } catch (error) {
382
- if (error instanceof MCPClientError) {
383
- output.printError(`Pre-command hook failed: ${error.message}`);
384
- } else {
385
- output.printError(`Unexpected error: ${String(error)}`);
386
- }
387
- return { success: false, exitCode: 1 };
388
- }
389
- }
390
- };
391
-
392
- // Post-command subcommand
393
- const postCommandCommand: Command = {
394
- name: 'post-command',
395
- description: 'Record command execution outcome',
396
- options: [
397
- {
398
- name: 'command',
399
- short: 'c',
400
- description: 'Command that was executed',
401
- type: 'string',
402
- required: true
403
- },
404
- {
405
- name: 'success',
406
- short: 's',
407
- description: 'Whether the command succeeded',
408
- type: 'boolean',
409
- required: true
410
- },
411
- {
412
- name: 'exit-code',
413
- short: 'e',
414
- description: 'Command exit code',
415
- type: 'number',
416
- default: 0
417
- },
418
- {
419
- name: 'duration',
420
- short: 'd',
421
- description: 'Execution duration in milliseconds',
422
- type: 'number'
423
- }
424
- ],
425
- examples: [
426
- { command: 'claude-flow hooks post-command -c "npm test" --success true', description: 'Record successful test run' },
427
- { command: 'claude-flow hooks post-command -c "npm build" --success false -e 1', description: 'Record failed build' }
428
- ],
429
- action: async (ctx: CommandContext): Promise<CommandResult> => {
430
- const command = ctx.args[0] || ctx.flags.command as string;
431
- const success = ctx.flags.success as boolean;
432
-
433
- if (!command) {
434
- output.printError('Command is required. Use --command or -c flag.');
435
- return { success: false, exitCode: 1 };
436
- }
437
-
438
- if (success === undefined) {
439
- output.printError('Success flag is required. Use --success true/false.');
440
- return { success: false, exitCode: 1 };
441
- }
442
-
443
- output.printInfo(`Recording command outcome: ${output.highlight(command)}`);
444
-
445
- try {
446
- // Call MCP tool for post-command hook
447
- const result = await callMCPTool<{
448
- command: string;
449
- success: boolean;
450
- recorded: boolean;
451
- learningUpdates: {
452
- commandPatternsUpdated: number;
453
- riskAssessmentUpdated: boolean;
454
- };
455
- }>('hooks/post-command', {
456
- command,
457
- success,
458
- exitCode: ctx.flags.exitCode || 0,
459
- duration: ctx.flags.duration,
460
- timestamp: Date.now(),
461
- });
462
-
463
- if (ctx.flags.format === 'json') {
464
- output.printJson(result);
465
- return { success: true, data: result };
466
- }
467
-
468
- output.writeln();
469
- output.printSuccess('Command outcome recorded');
470
-
471
- if (result.learningUpdates) {
472
- output.writeln();
473
- output.writeln(output.dim(`Patterns updated: ${result.learningUpdates.commandPatternsUpdated}`));
474
- output.writeln(output.dim(`Risk assessment: ${result.learningUpdates.riskAssessmentUpdated ? 'Updated' : 'No change'}`));
475
- }
476
-
477
- return { success: true, data: result };
478
- } catch (error) {
479
- if (error instanceof MCPClientError) {
480
- output.printError(`Post-command hook failed: ${error.message}`);
481
- } else {
482
- output.printError(`Unexpected error: ${String(error)}`);
483
- }
484
- return { success: false, exitCode: 1 };
485
- }
486
- }
487
- };
488
-
489
- // Route subcommand
490
- const routeCommand: Command = {
491
- name: 'route',
492
- description: 'Route task to optimal agent using learned patterns',
493
- options: [
494
- {
495
- name: 'task',
496
- short: 't',
497
- description: 'Task description',
498
- type: 'string',
499
- required: true
500
- },
501
- {
502
- name: 'context',
503
- short: 'c',
504
- description: 'Additional context',
505
- type: 'string'
506
- },
507
- {
508
- name: 'top-k',
509
- short: 'k',
510
- description: 'Number of top agent suggestions',
511
- type: 'number',
512
- default: 3
513
- }
514
- ],
515
- examples: [
516
- { command: 'claude-flow hooks route -t "Fix authentication bug"', description: 'Route task to optimal agent' },
517
- { command: 'claude-flow hooks route -t "Optimize database queries" -k 5', description: 'Get top 5 suggestions' }
518
- ],
519
- action: async (ctx: CommandContext): Promise<CommandResult> => {
520
- const task = ctx.args[0] || ctx.flags.task as string;
521
- const topK = ctx.flags.topK as number || 3;
522
-
523
- if (!task) {
524
- output.printError('Task description is required. Use --task or -t flag.');
525
- return { success: false, exitCode: 1 };
526
- }
527
-
528
- output.printInfo(`Routing task: ${output.highlight(task)}`);
529
-
530
- try {
531
- // Call MCP tool for routing
532
- const result = await callMCPTool<{
533
- task: string;
534
- primaryAgent: {
535
- type: string;
536
- confidence: number;
537
- reason: string;
538
- };
539
- alternativeAgents: Array<{
540
- type: string;
541
- confidence: number;
542
- reason: string;
543
- }>;
544
- estimatedMetrics: {
545
- successProbability: number;
546
- estimatedDuration: string;
547
- complexity: 'low' | 'medium' | 'high';
548
- };
549
- }>('hooks/route', {
550
- task,
551
- context: ctx.flags.context,
552
- topK,
553
- includeEstimates: true,
554
- });
555
-
556
- if (ctx.flags.format === 'json') {
557
- output.printJson(result);
558
- return { success: true, data: result };
559
- }
560
-
561
- output.writeln();
562
- output.printBox(
563
- [
564
- `Agent: ${output.highlight(result.primaryAgent.type)}`,
565
- `Confidence: ${(result.primaryAgent.confidence * 100).toFixed(1)}%`,
566
- `Reason: ${result.primaryAgent.reason}`
567
- ].join('\n'),
568
- 'Primary Recommendation'
569
- );
570
-
571
- if (result.alternativeAgents.length > 0) {
572
- output.writeln();
573
- output.writeln(output.bold('Alternative Agents'));
574
- output.printTable({
575
- columns: [
576
- { key: 'type', header: 'Agent Type', width: 20 },
577
- { key: 'confidence', header: 'Confidence', width: 12, align: 'right', format: (v) => `${(Number(v) * 100).toFixed(1)}%` },
578
- { key: 'reason', header: 'Reason', width: 35 }
579
- ],
580
- data: result.alternativeAgents
581
- });
582
- }
583
-
584
- if (result.estimatedMetrics) {
585
- output.writeln();
586
- output.writeln(output.bold('Estimated Metrics'));
587
- output.printList([
588
- `Success Probability: ${(result.estimatedMetrics.successProbability * 100).toFixed(1)}%`,
589
- `Estimated Duration: ${result.estimatedMetrics.estimatedDuration}`,
590
- `Complexity: ${result.estimatedMetrics.complexity.toUpperCase()}`
591
- ]);
592
- }
593
-
594
- return { success: true, data: result };
595
- } catch (error) {
596
- if (error instanceof MCPClientError) {
597
- output.printError(`Routing failed: ${error.message}`);
598
- } else {
599
- output.printError(`Unexpected error: ${String(error)}`);
600
- }
601
- return { success: false, exitCode: 1 };
602
- }
603
- }
604
- };
605
-
606
- // Explain subcommand
607
- const explainCommand: Command = {
608
- name: 'explain',
609
- description: 'Explain routing decision with transparency',
610
- options: [
611
- {
612
- name: 'task',
613
- short: 't',
614
- description: 'Task description',
615
- type: 'string',
616
- required: true
617
- },
618
- {
619
- name: 'agent',
620
- short: 'a',
621
- description: 'Agent type to explain',
622
- type: 'string'
623
- },
624
- {
625
- name: 'verbose',
626
- short: 'v',
627
- description: 'Verbose explanation',
628
- type: 'boolean',
629
- default: false
630
- }
631
- ],
632
- examples: [
633
- { command: 'claude-flow hooks explain -t "Fix authentication bug"', description: 'Explain routing decision' },
634
- { command: 'claude-flow hooks explain -t "Optimize queries" -a coder --verbose', description: 'Verbose explanation for specific agent' }
635
- ],
636
- action: async (ctx: CommandContext): Promise<CommandResult> => {
637
- const task = ctx.args[0] || ctx.flags.task as string;
638
-
639
- if (!task) {
640
- output.printError('Task description is required. Use --task or -t flag.');
641
- return { success: false, exitCode: 1 };
642
- }
643
-
644
- output.printInfo(`Explaining routing for: ${output.highlight(task)}`);
645
-
646
- try {
647
- // Call MCP tool for explanation
648
- const result = await callMCPTool<{
649
- task: string;
650
- explanation: string;
651
- factors: Array<{
652
- factor: string;
653
- weight: number;
654
- value: number;
655
- impact: string;
656
- }>;
657
- patterns: Array<{
658
- pattern: string;
659
- matchScore: number;
660
- examples: string[];
661
- }>;
662
- decision: {
663
- agent: string;
664
- confidence: number;
665
- reasoning: string[];
666
- };
667
- }>('hooks/explain', {
668
- task,
669
- agent: ctx.flags.agent,
670
- verbose: ctx.flags.verbose || false,
671
- });
672
-
673
- if (ctx.flags.format === 'json') {
674
- output.printJson(result);
675
- return { success: true, data: result };
676
- }
677
-
678
- output.writeln();
679
- output.writeln(output.bold('Decision Explanation'));
680
- output.writeln();
681
- output.writeln(result.explanation);
682
-
683
- output.writeln();
684
- output.printBox(
685
- [
686
- `Agent: ${output.highlight(result.decision.agent)}`,
687
- `Confidence: ${(result.decision.confidence * 100).toFixed(1)}%`
688
- ].join('\n'),
689
- 'Final Decision'
690
- );
691
-
692
- if (result.decision.reasoning.length > 0) {
693
- output.writeln();
694
- output.writeln(output.bold('Reasoning Steps'));
695
- output.printList(result.decision.reasoning.map((r, i) => `${i + 1}. ${r}`));
696
- }
697
-
698
- if (result.factors.length > 0) {
699
- output.writeln();
700
- output.writeln(output.bold('Decision Factors'));
701
- output.printTable({
702
- columns: [
703
- { key: 'factor', header: 'Factor', width: 20 },
704
- { key: 'weight', header: 'Weight', width: 10, align: 'right', format: (v) => `${(Number(v) * 100).toFixed(0)}%` },
705
- { key: 'value', header: 'Value', width: 10, align: 'right', format: (v) => Number(v).toFixed(2) },
706
- { key: 'impact', header: 'Impact', width: 25 }
707
- ],
708
- data: result.factors
709
- });
710
- }
711
-
712
- if (result.patterns.length > 0 && ctx.flags.verbose) {
713
- output.writeln();
714
- output.writeln(output.bold('Matched Patterns'));
715
- result.patterns.forEach((p, i) => {
716
- output.writeln();
717
- output.writeln(`${i + 1}. ${output.highlight(p.pattern)} (${(p.matchScore * 100).toFixed(1)}% match)`);
718
- if (p.examples.length > 0) {
719
- output.printList(p.examples.slice(0, 3).map(e => output.dim(` ${e}`)));
720
- }
721
- });
722
- }
723
-
724
- return { success: true, data: result };
725
- } catch (error) {
726
- if (error instanceof MCPClientError) {
727
- output.printError(`Explanation failed: ${error.message}`);
728
- } else {
729
- output.printError(`Unexpected error: ${String(error)}`);
730
- }
731
- return { success: false, exitCode: 1 };
732
- }
733
- }
734
- };
735
-
736
- // Pretrain subcommand
737
- const pretrainCommand: Command = {
738
- name: 'pretrain',
739
- description: 'Bootstrap intelligence from repository (4-step pipeline)',
740
- options: [
741
- {
742
- name: 'path',
743
- short: 'p',
744
- description: 'Repository path',
745
- type: 'string',
746
- default: '.'
747
- },
748
- {
749
- name: 'depth',
750
- short: 'd',
751
- description: 'Analysis depth (shallow, medium, deep)',
752
- type: 'string',
753
- default: 'medium',
754
- choices: ['shallow', 'medium', 'deep']
755
- },
756
- {
757
- name: 'skip-cache',
758
- description: 'Skip cached analysis',
759
- type: 'boolean',
760
- default: false
761
- }
762
- ],
763
- examples: [
764
- { command: 'claude-flow hooks pretrain', description: 'Pretrain from current repository' },
765
- { command: 'claude-flow hooks pretrain -p ../my-project --depth deep', description: 'Deep analysis of specific project' }
766
- ],
767
- action: async (ctx: CommandContext): Promise<CommandResult> => {
768
- const path = ctx.flags.path as string || '.';
769
- const depth = ctx.flags.depth as string || 'medium';
770
-
771
- output.writeln();
772
- output.writeln(output.bold('Pretraining Intelligence (4-Step Pipeline)'));
773
- output.writeln();
774
-
775
- const steps = [
776
- { name: 'RETRIEVE', desc: 'Top-k memory injection with MMR diversity' },
777
- { name: 'JUDGE', desc: 'LLM-as-judge trajectory evaluation' },
778
- { name: 'DISTILL', desc: 'Extract strategy memories from trajectories' },
779
- { name: 'CONSOLIDATE', desc: 'Dedup, detect contradictions, prune old patterns' }
780
- ];
781
-
782
- const spinner = output.createSpinner({ text: 'Starting pretraining...', spinner: 'dots' });
783
-
784
- try {
785
- spinner.start();
786
-
787
- // Display progress for each step
788
- for (const step of steps) {
789
- spinner.setText(`${step.name}: ${step.desc}`);
790
- await new Promise(resolve => setTimeout(resolve, 800));
791
- }
792
-
793
- // Call MCP tool for pretraining
794
- const result = await callMCPTool<{
795
- path: string;
796
- depth: string;
797
- stats: {
798
- filesAnalyzed: number;
799
- patternsExtracted: number;
800
- strategiesLearned: number;
801
- trajectoriesEvaluated: number;
802
- contradictionsResolved: number;
803
- };
804
- duration: number;
805
- }>('hooks/pretrain', {
806
- path,
807
- depth,
808
- skipCache: ctx.flags.skipCache || false,
809
- });
810
-
811
- spinner.succeed('Pretraining completed');
812
-
813
- if (ctx.flags.format === 'json') {
814
- output.printJson(result);
815
- return { success: true, data: result };
816
- }
817
-
818
- output.writeln();
819
- output.printTable({
820
- columns: [
821
- { key: 'metric', header: 'Metric', width: 30 },
822
- { key: 'value', header: 'Value', width: 15, align: 'right' }
823
- ],
824
- data: [
825
- { metric: 'Files Analyzed', value: result.stats.filesAnalyzed },
826
- { metric: 'Patterns Extracted', value: result.stats.patternsExtracted },
827
- { metric: 'Strategies Learned', value: result.stats.strategiesLearned },
828
- { metric: 'Trajectories Evaluated', value: result.stats.trajectoriesEvaluated },
829
- { metric: 'Contradictions Resolved', value: result.stats.contradictionsResolved },
830
- { metric: 'Duration', value: `${(result.duration / 1000).toFixed(1)}s` }
831
- ]
832
- });
833
-
834
- output.writeln();
835
- output.printSuccess('Repository intelligence bootstrapped successfully');
836
- output.writeln(output.dim(' Next step: Run "claude-flow hooks build-agents" to generate optimized configs'));
837
-
838
- return { success: true, data: result };
839
- } catch (error) {
840
- spinner.fail('Pretraining failed');
841
- if (error instanceof MCPClientError) {
842
- output.printError(`Pretraining error: ${error.message}`);
843
- } else {
844
- output.printError(`Unexpected error: ${String(error)}`);
845
- }
846
- return { success: false, exitCode: 1 };
847
- }
848
- }
849
- };
850
-
851
- // Build agents subcommand
852
- const buildAgentsCommand: Command = {
853
- name: 'build-agents',
854
- description: 'Generate optimized agent configs from pretrain data',
855
- options: [
856
- {
857
- name: 'output',
858
- short: 'o',
859
- description: 'Output directory for agent configs',
860
- type: 'string',
861
- default: './agents'
862
- },
863
- {
864
- name: 'focus',
865
- short: 'f',
866
- description: 'Focus area (v3-implementation, security, performance, all)',
867
- type: 'string',
868
- default: 'all'
869
- },
870
- {
871
- name: 'config-format',
872
- description: 'Config format (yaml, json)',
873
- type: 'string',
874
- default: 'yaml',
875
- choices: ['yaml', 'json']
876
- }
877
- ],
878
- examples: [
879
- { command: 'claude-flow hooks build-agents', description: 'Build all agent configs' },
880
- { command: 'claude-flow hooks build-agents --focus security -o ./config/agents', description: 'Build security-focused configs' }
881
- ],
882
- action: async (ctx: CommandContext): Promise<CommandResult> => {
883
- const output_dir = ctx.flags.output as string || './agents';
884
- const focus = ctx.flags.focus as string || 'all';
885
- const configFormat = ctx.flags.configFormat as string || 'yaml';
886
-
887
- output.printInfo(`Building agent configs (focus: ${output.highlight(focus)})`);
888
-
889
- const spinner = output.createSpinner({ text: 'Generating configs...', spinner: 'dots' });
890
-
891
- try {
892
- spinner.start();
893
-
894
- // Call MCP tool for building agents
895
- const result = await callMCPTool<{
896
- outputDir: string;
897
- focus: string;
898
- agents: Array<{
899
- type: string;
900
- configFile: string;
901
- capabilities: string[];
902
- optimizations: string[];
903
- }>;
904
- stats: {
905
- configsGenerated: number;
906
- patternsApplied: number;
907
- optimizationsIncluded: number;
908
- };
909
- }>('hooks/build-agents', {
910
- outputDir: output_dir,
911
- focus,
912
- format: configFormat,
913
- includePretrained: true,
914
- });
915
-
916
- spinner.succeed(`Generated ${result.agents.length} agent configs`);
917
-
918
- if (ctx.flags.format === 'json') {
919
- output.printJson(result);
920
- return { success: true, data: result };
921
- }
922
-
923
- output.writeln();
924
- output.writeln(output.bold('Generated Agent Configs'));
925
- output.printTable({
926
- columns: [
927
- { key: 'type', header: 'Agent Type', width: 20 },
928
- { key: 'configFile', header: 'Config File', width: 30 },
929
- { key: 'capabilities', header: 'Capabilities', width: 10, align: 'right', format: (v) => String(Array.isArray(v) ? v.length : 0) }
930
- ],
931
- data: result.agents
932
- });
933
-
934
- output.writeln();
935
- output.printTable({
936
- columns: [
937
- { key: 'metric', header: 'Metric', width: 30 },
938
- { key: 'value', header: 'Value', width: 15, align: 'right' }
939
- ],
940
- data: [
941
- { metric: 'Configs Generated', value: result.stats.configsGenerated },
942
- { metric: 'Patterns Applied', value: result.stats.patternsApplied },
943
- { metric: 'Optimizations Included', value: result.stats.optimizationsIncluded }
944
- ]
945
- });
946
-
947
- output.writeln();
948
- output.printSuccess(`Agent configs saved to ${output_dir}`);
949
-
950
- return { success: true, data: result };
951
- } catch (error) {
952
- spinner.fail('Agent config generation failed');
953
- if (error instanceof MCPClientError) {
954
- output.printError(`Build agents error: ${error.message}`);
955
- } else {
956
- output.printError(`Unexpected error: ${String(error)}`);
957
- }
958
- return { success: false, exitCode: 1 };
959
- }
960
- }
961
- };
962
-
963
- // Metrics subcommand
964
- const metricsCommand: Command = {
965
- name: 'metrics',
966
- description: 'View learning metrics dashboard',
967
- options: [
968
- {
969
- name: 'period',
970
- short: 'p',
971
- description: 'Time period (1h, 24h, 7d, 30d, all)',
972
- type: 'string',
973
- default: '24h'
974
- },
975
- {
976
- name: 'v3-dashboard',
977
- description: 'Show V3 performance dashboard',
978
- type: 'boolean',
979
- default: false
980
- },
981
- {
982
- name: 'category',
983
- short: 'c',
984
- description: 'Metric category (patterns, agents, commands, performance)',
985
- type: 'string'
986
- }
987
- ],
988
- examples: [
989
- { command: 'claude-flow hooks metrics', description: 'View 24h metrics' },
990
- { command: 'claude-flow hooks metrics --period 7d --v3-dashboard', description: 'V3 metrics for 7 days' }
991
- ],
992
- action: async (ctx: CommandContext): Promise<CommandResult> => {
993
- const period = ctx.flags.period as string || '24h';
994
- const v3Dashboard = ctx.flags.v3Dashboard as boolean;
995
-
996
- output.writeln();
997
- output.writeln(output.bold(`Learning Metrics Dashboard (${period})`));
998
- output.writeln();
999
-
1000
- try {
1001
- // Call MCP tool for metrics
1002
- const result = await callMCPTool<{
1003
- period: string;
1004
- patterns: {
1005
- total: number;
1006
- successful: number;
1007
- failed: number;
1008
- avgConfidence: number;
1009
- };
1010
- agents: {
1011
- routingAccuracy: number;
1012
- totalRoutes: number;
1013
- topAgent: string;
1014
- };
1015
- commands: {
1016
- totalExecuted: number;
1017
- successRate: number;
1018
- avgRiskScore: number;
1019
- };
1020
- performance: {
1021
- flashAttention: string;
1022
- memoryReduction: string;
1023
- searchImprovement: string;
1024
- tokenReduction: string;
1025
- };
1026
- }>('hooks/metrics', {
1027
- period,
1028
- includeV3: v3Dashboard,
1029
- category: ctx.flags.category,
1030
- });
1031
-
1032
- if (ctx.flags.format === 'json') {
1033
- output.printJson(result);
1034
- return { success: true, data: result };
1035
- }
1036
-
1037
- // Patterns section
1038
- output.writeln(output.bold('📊 Pattern Learning'));
1039
- output.printTable({
1040
- columns: [
1041
- { key: 'metric', header: 'Metric', width: 25 },
1042
- { key: 'value', header: 'Value', width: 20, align: 'right' }
1043
- ],
1044
- data: [
1045
- { metric: 'Total Patterns', value: result.patterns.total },
1046
- { metric: 'Successful', value: output.success(String(result.patterns.successful)) },
1047
- { metric: 'Failed', value: output.error(String(result.patterns.failed)) },
1048
- { metric: 'Avg Confidence', value: `${(result.patterns.avgConfidence * 100).toFixed(1)}%` }
1049
- ]
1050
- });
1051
-
1052
- output.writeln();
1053
-
1054
- // Agent routing section
1055
- output.writeln(output.bold('🤖 Agent Routing'));
1056
- output.printTable({
1057
- columns: [
1058
- { key: 'metric', header: 'Metric', width: 25 },
1059
- { key: 'value', header: 'Value', width: 20, align: 'right' }
1060
- ],
1061
- data: [
1062
- { metric: 'Routing Accuracy', value: `${(result.agents.routingAccuracy * 100).toFixed(1)}%` },
1063
- { metric: 'Total Routes', value: result.agents.totalRoutes },
1064
- { metric: 'Top Agent', value: output.highlight(result.agents.topAgent) }
1065
- ]
1066
- });
1067
-
1068
- output.writeln();
1069
-
1070
- // Command execution section
1071
- output.writeln(output.bold('⚡ Command Execution'));
1072
- output.printTable({
1073
- columns: [
1074
- { key: 'metric', header: 'Metric', width: 25 },
1075
- { key: 'value', header: 'Value', width: 20, align: 'right' }
1076
- ],
1077
- data: [
1078
- { metric: 'Total Executed', value: result.commands.totalExecuted },
1079
- { metric: 'Success Rate', value: `${(result.commands.successRate * 100).toFixed(1)}%` },
1080
- { metric: 'Avg Risk Score', value: result.commands.avgRiskScore.toFixed(2) }
1081
- ]
1082
- });
1083
-
1084
- if (v3Dashboard && result.performance) {
1085
- output.writeln();
1086
- output.writeln(output.bold('🚀 V3 Performance Gains'));
1087
- output.printList([
1088
- `Flash Attention: ${output.success(result.performance.flashAttention)}`,
1089
- `Memory Reduction: ${output.success(result.performance.memoryReduction)}`,
1090
- `Search Improvement: ${output.success(result.performance.searchImprovement)}`,
1091
- `Token Reduction: ${output.success(result.performance.tokenReduction)}`
1092
- ]);
1093
- }
1094
-
1095
- return { success: true, data: result };
1096
- } catch (error) {
1097
- if (error instanceof MCPClientError) {
1098
- output.printError(`Metrics error: ${error.message}`);
1099
- } else {
1100
- output.printError(`Unexpected error: ${String(error)}`);
1101
- }
1102
- return { success: false, exitCode: 1 };
1103
- }
1104
- }
1105
- };
1106
-
1107
- // Transfer subcommand
1108
- const transferCommand: Command = {
1109
- name: 'transfer',
1110
- description: 'Transfer patterns from another project',
1111
- options: [
1112
- {
1113
- name: 'source',
1114
- short: 's',
1115
- description: 'Source project path',
1116
- type: 'string',
1117
- required: true
1118
- },
1119
- {
1120
- name: 'filter',
1121
- short: 'f',
1122
- description: 'Filter patterns by type',
1123
- type: 'string'
1124
- },
1125
- {
1126
- name: 'min-confidence',
1127
- short: 'm',
1128
- description: 'Minimum confidence threshold (0-1)',
1129
- type: 'number',
1130
- default: 0.7
1131
- }
1132
- ],
1133
- examples: [
1134
- { command: 'claude-flow hooks transfer -s ../old-project', description: 'Transfer all patterns' },
1135
- { command: 'claude-flow hooks transfer -s ../prod --filter security -m 0.9', description: 'Transfer high-confidence security patterns' }
1136
- ],
1137
- action: async (ctx: CommandContext): Promise<CommandResult> => {
1138
- const sourcePath = ctx.args[0] || ctx.flags.source as string;
1139
- const minConfidence = ctx.flags.minConfidence as number || 0.7;
1140
-
1141
- if (!sourcePath) {
1142
- output.printError('Source project path is required. Use --source or -s flag.');
1143
- return { success: false, exitCode: 1 };
1144
- }
1145
-
1146
- output.printInfo(`Transferring patterns from: ${output.highlight(sourcePath)}`);
1147
-
1148
- const spinner = output.createSpinner({ text: 'Analyzing source patterns...', spinner: 'dots' });
1149
-
1150
- try {
1151
- spinner.start();
1152
-
1153
- // Call MCP tool for transfer
1154
- const result = await callMCPTool<{
1155
- sourcePath: string;
1156
- transferred: {
1157
- total: number;
1158
- byType: Record<string, number>;
1159
- };
1160
- skipped: {
1161
- lowConfidence: number;
1162
- duplicates: number;
1163
- conflicts: number;
1164
- };
1165
- stats: {
1166
- avgConfidence: number;
1167
- avgAge: string;
1168
- };
1169
- }>('hooks/transfer', {
1170
- sourcePath,
1171
- filter: ctx.flags.filter,
1172
- minConfidence,
1173
- mergeStrategy: 'keep-highest-confidence',
1174
- });
1175
-
1176
- spinner.succeed(`Transferred ${result.transferred.total} patterns`);
1177
-
1178
- if (ctx.flags.format === 'json') {
1179
- output.printJson(result);
1180
- return { success: true, data: result };
1181
- }
1182
-
1183
- output.writeln();
1184
- output.writeln(output.bold('Transfer Summary'));
1185
- output.printTable({
1186
- columns: [
1187
- { key: 'category', header: 'Category', width: 25 },
1188
- { key: 'count', header: 'Count', width: 15, align: 'right' }
1189
- ],
1190
- data: [
1191
- { category: 'Total Transferred', count: output.success(String(result.transferred.total)) },
1192
- { category: 'Skipped (Low Confidence)', count: result.skipped.lowConfidence },
1193
- { category: 'Skipped (Duplicates)', count: result.skipped.duplicates },
1194
- { category: 'Skipped (Conflicts)', count: result.skipped.conflicts }
1195
- ]
1196
- });
1197
-
1198
- if (Object.keys(result.transferred.byType).length > 0) {
1199
- output.writeln();
1200
- output.writeln(output.bold('By Pattern Type'));
1201
- output.printTable({
1202
- columns: [
1203
- { key: 'type', header: 'Type', width: 20 },
1204
- { key: 'count', header: 'Count', width: 15, align: 'right' }
1205
- ],
1206
- data: Object.entries(result.transferred.byType).map(([type, count]) => ({ type, count }))
1207
- });
1208
- }
1209
-
1210
- output.writeln();
1211
- output.printList([
1212
- `Avg Confidence: ${(result.stats.avgConfidence * 100).toFixed(1)}%`,
1213
- `Avg Age: ${result.stats.avgAge}`
1214
- ]);
1215
-
1216
- return { success: true, data: result };
1217
- } catch (error) {
1218
- spinner.fail('Transfer failed');
1219
- if (error instanceof MCPClientError) {
1220
- output.printError(`Transfer error: ${error.message}`);
1221
- } else {
1222
- output.printError(`Unexpected error: ${String(error)}`);
1223
- }
1224
- return { success: false, exitCode: 1 };
1225
- }
1226
- }
1227
- };
1228
-
1229
- // List subcommand
1230
- const listCommand: Command = {
1231
- name: 'list',
1232
- aliases: ['ls'],
1233
- description: 'List all registered hooks',
1234
- options: [
1235
- {
1236
- name: 'enabled',
1237
- short: 'e',
1238
- description: 'Show only enabled hooks',
1239
- type: 'boolean',
1240
- default: false
1241
- },
1242
- {
1243
- name: 'type',
1244
- short: 't',
1245
- description: 'Filter by hook type',
1246
- type: 'string'
1247
- }
1248
- ],
1249
- action: async (ctx: CommandContext): Promise<CommandResult> => {
1250
- try {
1251
- // Call MCP tool for list
1252
- const result = await callMCPTool<{
1253
- hooks: Array<{
1254
- name: string;
1255
- type: string;
1256
- enabled: boolean;
1257
- priority: number;
1258
- executionCount: number;
1259
- lastExecuted?: string;
1260
- }>;
1261
- total: number;
1262
- }>('hooks/list', {
1263
- enabled: ctx.flags.enabled || undefined,
1264
- type: ctx.flags.type || undefined,
1265
- });
1266
-
1267
- if (ctx.flags.format === 'json') {
1268
- output.printJson(result);
1269
- return { success: true, data: result };
1270
- }
1271
-
1272
- output.writeln();
1273
- output.writeln(output.bold('Registered Hooks'));
1274
- output.writeln();
1275
-
1276
- if (result.hooks.length === 0) {
1277
- output.printInfo('No hooks found matching criteria');
1278
- return { success: true, data: result };
1279
- }
1280
-
1281
- output.printTable({
1282
- columns: [
1283
- { key: 'name', header: 'Name', width: 20 },
1284
- { key: 'type', header: 'Type', width: 15 },
1285
- { key: 'enabled', header: 'Enabled', width: 10, format: (v) => v ? output.success('Yes') : output.dim('No') },
1286
- { key: 'priority', header: 'Priority', width: 10, align: 'right' },
1287
- { key: 'executionCount', header: 'Executions', width: 12, align: 'right' },
1288
- { key: 'lastExecuted', header: 'Last Executed', width: 20, format: (v) => v ? new Date(String(v)).toLocaleString() : 'Never' }
1289
- ],
1290
- data: result.hooks
1291
- });
1292
-
1293
- output.writeln();
1294
- output.printInfo(`Total: ${result.total} hooks`);
1295
-
1296
- return { success: true, data: result };
1297
- } catch (error) {
1298
- if (error instanceof MCPClientError) {
1299
- output.printError(`Failed to list hooks: ${error.message}`);
1300
- } else {
1301
- output.printError(`Unexpected error: ${String(error)}`);
1302
- }
1303
- return { success: false, exitCode: 1 };
1304
- }
1305
- }
1306
- };
1307
-
1308
- // Pre-task subcommand
1309
- const preTaskCommand: Command = {
1310
- name: 'pre-task',
1311
- description: 'Record task start and get agent suggestions',
1312
- options: [
1313
- {
1314
- name: 'task-id',
1315
- short: 'i',
1316
- description: 'Unique task identifier',
1317
- type: 'string',
1318
- required: true
1319
- },
1320
- {
1321
- name: 'description',
1322
- short: 'd',
1323
- description: 'Task description',
1324
- type: 'string',
1325
- required: true
1326
- },
1327
- {
1328
- name: 'auto-spawn',
1329
- short: 'a',
1330
- description: 'Auto-spawn suggested agents',
1331
- type: 'boolean',
1332
- default: false
1333
- }
1334
- ],
1335
- examples: [
1336
- { command: 'claude-flow hooks pre-task -i task-123 -d "Fix auth bug"', description: 'Record task start' },
1337
- { command: 'claude-flow hooks pre-task -i task-456 -d "Implement feature" --auto-spawn', description: 'With auto-spawn' }
1338
- ],
1339
- action: async (ctx: CommandContext): Promise<CommandResult> => {
1340
- const taskId = ctx.flags.taskId as string;
1341
- const description = ctx.args[0] || ctx.flags.description as string;
1342
-
1343
- if (!taskId || !description) {
1344
- output.printError('Task ID and description are required.');
1345
- return { success: false, exitCode: 1 };
1346
- }
1347
-
1348
- output.printInfo(`Starting task: ${output.highlight(taskId)}`);
1349
-
1350
- try {
1351
- const result = await callMCPTool<{
1352
- taskId: string;
1353
- description: string;
1354
- suggestedAgents: Array<{
1355
- type: string;
1356
- confidence: number;
1357
- reason: string;
1358
- }>;
1359
- complexity: 'low' | 'medium' | 'high';
1360
- estimatedDuration: string;
1361
- risks: string[];
1362
- recommendations: string[];
1363
- }>('hooks/pre-task', {
1364
- taskId,
1365
- description,
1366
- autoSpawn: ctx.flags.autoSpawn || false,
1367
- timestamp: Date.now(),
1368
- });
1369
-
1370
- if (ctx.flags.format === 'json') {
1371
- output.printJson(result);
1372
- return { success: true, data: result };
1373
- }
1374
-
1375
- output.writeln();
1376
- output.printBox(
1377
- [
1378
- `Task ID: ${result.taskId}`,
1379
- `Description: ${result.description}`,
1380
- `Complexity: ${result.complexity.toUpperCase()}`,
1381
- `Est. Duration: ${result.estimatedDuration}`
1382
- ].join('\n'),
1383
- 'Task Registered'
1384
- );
1385
-
1386
- if (result.suggestedAgents.length > 0) {
1387
- output.writeln();
1388
- output.writeln(output.bold('Suggested Agents'));
1389
- output.printTable({
1390
- columns: [
1391
- { key: 'type', header: 'Agent Type', width: 20 },
1392
- { key: 'confidence', header: 'Confidence', width: 12, align: 'right', format: (v) => `${(Number(v) * 100).toFixed(1)}%` },
1393
- { key: 'reason', header: 'Reason', width: 35 }
1394
- ],
1395
- data: result.suggestedAgents
1396
- });
1397
- }
1398
-
1399
- if (result.risks.length > 0) {
1400
- output.writeln();
1401
- output.writeln(output.bold(output.error('Potential Risks')));
1402
- output.printList(result.risks.map(r => output.warning(r)));
1403
- }
1404
-
1405
- if (result.recommendations.length > 0) {
1406
- output.writeln();
1407
- output.writeln(output.bold('Recommendations'));
1408
- output.printList(result.recommendations);
1409
- }
1410
-
1411
- return { success: true, data: result };
1412
- } catch (error) {
1413
- if (error instanceof MCPClientError) {
1414
- output.printError(`Pre-task hook failed: ${error.message}`);
1415
- } else {
1416
- output.printError(`Unexpected error: ${String(error)}`);
1417
- }
1418
- return { success: false, exitCode: 1 };
1419
- }
1420
- }
1421
- };
1422
-
1423
- // Post-task subcommand
1424
- const postTaskCommand: Command = {
1425
- name: 'post-task',
1426
- description: 'Record task completion for learning',
1427
- options: [
1428
- {
1429
- name: 'task-id',
1430
- short: 'i',
1431
- description: 'Unique task identifier',
1432
- type: 'string',
1433
- required: true
1434
- },
1435
- {
1436
- name: 'success',
1437
- short: 's',
1438
- description: 'Whether the task succeeded',
1439
- type: 'boolean',
1440
- required: true
1441
- },
1442
- {
1443
- name: 'quality',
1444
- short: 'q',
1445
- description: 'Quality score (0-1)',
1446
- type: 'number'
1447
- },
1448
- {
1449
- name: 'agent',
1450
- short: 'a',
1451
- description: 'Agent that executed the task',
1452
- type: 'string'
1453
- }
1454
- ],
1455
- examples: [
1456
- { command: 'claude-flow hooks post-task -i task-123 --success true', description: 'Record successful completion' },
1457
- { command: 'claude-flow hooks post-task -i task-456 --success false -q 0.3', description: 'Record failed task' }
1458
- ],
1459
- action: async (ctx: CommandContext): Promise<CommandResult> => {
1460
- const taskId = ctx.flags.taskId as string;
1461
- const success = ctx.flags.success as boolean;
1462
-
1463
- if (!taskId) {
1464
- output.printError('Task ID is required. Use --task-id or -i flag.');
1465
- return { success: false, exitCode: 1 };
1466
- }
1467
-
1468
- if (success === undefined) {
1469
- output.printError('Success flag is required. Use --success true/false.');
1470
- return { success: false, exitCode: 1 };
1471
- }
1472
-
1473
- output.printInfo(`Recording outcome for task: ${output.highlight(taskId)}`);
1474
-
1475
- try {
1476
- const result = await callMCPTool<{
1477
- taskId: string;
1478
- success: boolean;
1479
- duration: number;
1480
- learningUpdates: {
1481
- patternsUpdated: number;
1482
- newPatterns: number;
1483
- trajectoryId: string;
1484
- };
1485
- }>('hooks/post-task', {
1486
- taskId,
1487
- success,
1488
- quality: ctx.flags.quality,
1489
- agent: ctx.flags.agent,
1490
- timestamp: Date.now(),
1491
- });
1492
-
1493
- if (ctx.flags.format === 'json') {
1494
- output.printJson(result);
1495
- return { success: true, data: result };
1496
- }
1497
-
1498
- output.writeln();
1499
- output.printSuccess(`Task outcome recorded: ${success ? 'SUCCESS' : 'FAILED'}`);
1500
-
1501
- output.writeln();
1502
- output.writeln(output.bold('Learning Updates'));
1503
- output.printTable({
1504
- columns: [
1505
- { key: 'metric', header: 'Metric', width: 25 },
1506
- { key: 'value', header: 'Value', width: 20, align: 'right' }
1507
- ],
1508
- data: [
1509
- { metric: 'Patterns Updated', value: result.learningUpdates.patternsUpdated },
1510
- { metric: 'New Patterns', value: result.learningUpdates.newPatterns },
1511
- { metric: 'Duration', value: `${(result.duration / 1000).toFixed(1)}s` },
1512
- { metric: 'Trajectory ID', value: result.learningUpdates.trajectoryId }
1513
- ]
1514
- });
1515
-
1516
- return { success: true, data: result };
1517
- } catch (error) {
1518
- if (error instanceof MCPClientError) {
1519
- output.printError(`Post-task hook failed: ${error.message}`);
1520
- } else {
1521
- output.printError(`Unexpected error: ${String(error)}`);
1522
- }
1523
- return { success: false, exitCode: 1 };
1524
- }
1525
- }
1526
- };
1527
-
1528
- // Session-end subcommand
1529
- const sessionEndCommand: Command = {
1530
- name: 'session-end',
1531
- description: 'End current session and persist state',
1532
- options: [
1533
- {
1534
- name: 'save-state',
1535
- short: 's',
1536
- description: 'Save session state for later restoration',
1537
- type: 'boolean',
1538
- default: true
1539
- }
1540
- ],
1541
- examples: [
1542
- { command: 'claude-flow hooks session-end', description: 'End and save session' },
1543
- { command: 'claude-flow hooks session-end --save-state false', description: 'End without saving' }
1544
- ],
1545
- action: async (ctx: CommandContext): Promise<CommandResult> => {
1546
- output.printInfo('Ending session...');
1547
-
1548
- try {
1549
- const result = await callMCPTool<{
1550
- sessionId: string;
1551
- duration: number;
1552
- statePath?: string;
1553
- summary: {
1554
- tasksExecuted: number;
1555
- tasksSucceeded: number;
1556
- tasksFailed: number;
1557
- commandsExecuted: number;
1558
- filesModified: number;
1559
- agentsSpawned: number;
1560
- };
1561
- }>('hooks/session-end', {
1562
- saveState: ctx.flags.saveState ?? true,
1563
- timestamp: Date.now(),
1564
- });
1565
-
1566
- if (ctx.flags.format === 'json') {
1567
- output.printJson(result);
1568
- return { success: true, data: result };
1569
- }
1570
-
1571
- output.writeln();
1572
- output.printSuccess(`Session ${result.sessionId} ended`);
1573
-
1574
- output.writeln();
1575
- output.writeln(output.bold('Session Summary'));
1576
- output.printTable({
1577
- columns: [
1578
- { key: 'metric', header: 'Metric', width: 25 },
1579
- { key: 'value', header: 'Value', width: 15, align: 'right' }
1580
- ],
1581
- data: [
1582
- { metric: 'Duration', value: `${(result.duration / 1000 / 60).toFixed(1)} min` },
1583
- { metric: 'Tasks Executed', value: result.summary.tasksExecuted },
1584
- { metric: 'Tasks Succeeded', value: output.success(String(result.summary.tasksSucceeded)) },
1585
- { metric: 'Tasks Failed', value: output.error(String(result.summary.tasksFailed)) },
1586
- { metric: 'Commands Executed', value: result.summary.commandsExecuted },
1587
- { metric: 'Files Modified', value: result.summary.filesModified },
1588
- { metric: 'Agents Spawned', value: result.summary.agentsSpawned }
1589
- ]
1590
- });
1591
-
1592
- if (result.statePath) {
1593
- output.writeln();
1594
- output.writeln(output.dim(`State saved to: ${result.statePath}`));
1595
- }
1596
-
1597
- return { success: true, data: result };
1598
- } catch (error) {
1599
- if (error instanceof MCPClientError) {
1600
- output.printError(`Session-end hook failed: ${error.message}`);
1601
- } else {
1602
- output.printError(`Unexpected error: ${String(error)}`);
1603
- }
1604
- return { success: false, exitCode: 1 };
1605
- }
1606
- }
1607
- };
1608
-
1609
- // Session-restore subcommand
1610
- const sessionRestoreCommand: Command = {
1611
- name: 'session-restore',
1612
- description: 'Restore a previous session',
1613
- options: [
1614
- {
1615
- name: 'session-id',
1616
- short: 'i',
1617
- description: 'Session ID to restore (use "latest" for most recent)',
1618
- type: 'string',
1619
- default: 'latest'
1620
- },
1621
- {
1622
- name: 'restore-agents',
1623
- short: 'a',
1624
- description: 'Restore spawned agents',
1625
- type: 'boolean',
1626
- default: true
1627
- },
1628
- {
1629
- name: 'restore-tasks',
1630
- short: 't',
1631
- description: 'Restore active tasks',
1632
- type: 'boolean',
1633
- default: true
1634
- }
1635
- ],
1636
- examples: [
1637
- { command: 'claude-flow hooks session-restore', description: 'Restore latest session' },
1638
- { command: 'claude-flow hooks session-restore -i session-12345', description: 'Restore specific session' }
1639
- ],
1640
- action: async (ctx: CommandContext): Promise<CommandResult> => {
1641
- const sessionId = ctx.args[0] || ctx.flags.sessionId as string || 'latest';
1642
-
1643
- output.printInfo(`Restoring session: ${output.highlight(sessionId)}`);
1644
-
1645
- try {
1646
- const result = await callMCPTool<{
1647
- sessionId: string;
1648
- originalSessionId: string;
1649
- restoredState: {
1650
- tasksRestored: number;
1651
- agentsRestored: number;
1652
- memoryRestored: number;
1653
- };
1654
- warnings?: string[];
1655
- }>('hooks/session-restore', {
1656
- sessionId,
1657
- restoreAgents: ctx.flags.restoreAgents ?? true,
1658
- restoreTasks: ctx.flags.restoreTasks ?? true,
1659
- timestamp: Date.now(),
1660
- });
1661
-
1662
- if (ctx.flags.format === 'json') {
1663
- output.printJson(result);
1664
- return { success: true, data: result };
1665
- }
1666
-
1667
- output.writeln();
1668
- output.printSuccess(`Session restored from ${result.originalSessionId}`);
1669
- output.writeln(output.dim(`New session ID: ${result.sessionId}`));
1670
-
1671
- output.writeln();
1672
- output.writeln(output.bold('Restored State'));
1673
- output.printTable({
1674
- columns: [
1675
- { key: 'item', header: 'Item', width: 25 },
1676
- { key: 'count', header: 'Count', width: 15, align: 'right' }
1677
- ],
1678
- data: [
1679
- { item: 'Tasks', count: result.restoredState.tasksRestored },
1680
- { item: 'Agents', count: result.restoredState.agentsRestored },
1681
- { item: 'Memory Entries', count: result.restoredState.memoryRestored }
1682
- ]
1683
- });
1684
-
1685
- if (result.warnings && result.warnings.length > 0) {
1686
- output.writeln();
1687
- output.writeln(output.bold(output.warning('Warnings')));
1688
- output.printList(result.warnings.map(w => output.warning(w)));
1689
- }
1690
-
1691
- return { success: true, data: result };
1692
- } catch (error) {
1693
- if (error instanceof MCPClientError) {
1694
- output.printError(`Session-restore hook failed: ${error.message}`);
1695
- } else {
1696
- output.printError(`Unexpected error: ${String(error)}`);
1697
- }
1698
- return { success: false, exitCode: 1 };
1699
- }
1700
- }
1701
- };
1702
-
1703
- // Intelligence subcommand (SONA, MoE, HNSW)
1704
- const intelligenceCommand: Command = {
1705
- name: 'intelligence',
1706
- description: 'RuVector intelligence system (SONA, MoE, HNSW 150x faster)',
1707
- options: [
1708
- {
1709
- name: 'mode',
1710
- short: 'm',
1711
- description: 'Intelligence mode (real-time, batch, edge, research, balanced)',
1712
- type: 'string',
1713
- choices: ['real-time', 'batch', 'edge', 'research', 'balanced'],
1714
- default: 'balanced'
1715
- },
1716
- {
1717
- name: 'enable-sona',
1718
- description: 'Enable SONA sub-0.05ms learning',
1719
- type: 'boolean',
1720
- default: true
1721
- },
1722
- {
1723
- name: 'enable-moe',
1724
- description: 'Enable Mixture of Experts routing',
1725
- type: 'boolean',
1726
- default: true
1727
- },
1728
- {
1729
- name: 'enable-hnsw',
1730
- description: 'Enable HNSW 150x faster search',
1731
- type: 'boolean',
1732
- default: true
1733
- },
1734
- {
1735
- name: 'status',
1736
- short: 's',
1737
- description: 'Show current intelligence status',
1738
- type: 'boolean',
1739
- default: false
1740
- },
1741
- {
1742
- name: 'train',
1743
- short: 't',
1744
- description: 'Force training cycle',
1745
- type: 'boolean',
1746
- default: false
1747
- },
1748
- {
1749
- name: 'reset',
1750
- short: 'r',
1751
- description: 'Reset learning state',
1752
- type: 'boolean',
1753
- default: false
1754
- },
1755
- {
1756
- name: 'embedding-provider',
1757
- description: 'Embedding provider (transformers, openai, mock)',
1758
- type: 'string',
1759
- choices: ['transformers', 'openai', 'mock'],
1760
- default: 'transformers'
1761
- }
1762
- ],
1763
- examples: [
1764
- { command: 'claude-flow hooks intelligence --status', description: 'Show intelligence status' },
1765
- { command: 'claude-flow hooks intelligence -m real-time', description: 'Enable real-time mode' },
1766
- { command: 'claude-flow hooks intelligence --train', description: 'Force training cycle' }
1767
- ],
1768
- action: async (ctx: CommandContext): Promise<CommandResult> => {
1769
- const mode = ctx.flags.mode as string || 'balanced';
1770
- const showStatus = ctx.flags.status as boolean;
1771
- const forceTraining = ctx.flags.train as boolean;
1772
- const reset = ctx.flags.reset as boolean;
1773
- const enableSona = ctx.flags.enableSona as boolean ?? true;
1774
- const enableMoe = ctx.flags.enableMoe as boolean ?? true;
1775
- const enableHnsw = ctx.flags.enableHnsw as boolean ?? true;
1776
- const embeddingProvider = ctx.flags.embeddingProvider as string || 'transformers';
1777
-
1778
- output.writeln();
1779
- output.writeln(output.bold('RuVector Intelligence System'));
1780
- output.writeln();
1781
-
1782
- if (reset) {
1783
- const confirmed = await confirm({
1784
- message: 'Reset all learning state? This cannot be undone.',
1785
- default: false
1786
- });
1787
-
1788
- if (!confirmed) {
1789
- output.printInfo('Reset cancelled');
1790
- return { success: true };
1791
- }
1792
-
1793
- output.printInfo('Resetting learning state...');
1794
- try {
1795
- await callMCPTool('hooks/intelligence-reset', {});
1796
- output.printSuccess('Learning state reset');
1797
- return { success: true };
1798
- } catch (error) {
1799
- output.printError(`Reset failed: ${error}`);
1800
- return { success: false, exitCode: 1 };
1801
- }
1802
- }
1803
-
1804
- const spinner = output.createSpinner({ text: 'Initializing intelligence system...', spinner: 'dots' });
1805
-
1806
- try {
1807
- spinner.start();
1808
-
1809
- // Call MCP tool for intelligence
1810
- const result = await callMCPTool<{
1811
- mode: string;
1812
- status: 'active' | 'idle' | 'training' | 'disabled';
1813
- components: {
1814
- sona: {
1815
- enabled: boolean;
1816
- status: string;
1817
- learningTimeMs: number;
1818
- adaptationTimeMs: number;
1819
- trajectoriesRecorded: number;
1820
- patternsLearned: number;
1821
- avgQuality: number;
1822
- };
1823
- moe: {
1824
- enabled: boolean;
1825
- status: string;
1826
- expertsActive: number;
1827
- routingAccuracy: number;
1828
- loadBalance: number;
1829
- };
1830
- hnsw: {
1831
- enabled: boolean;
1832
- status: string;
1833
- indexSize: number;
1834
- searchSpeedup: string;
1835
- memoryUsage: string;
1836
- dimension: number;
1837
- };
1838
- embeddings: {
1839
- provider: string;
1840
- model: string;
1841
- dimension: number;
1842
- cacheHitRate: number;
1843
- };
1844
- };
1845
- performance: {
1846
- flashAttention: string;
1847
- memoryReduction: string;
1848
- searchImprovement: string;
1849
- tokenReduction: string;
1850
- sweBenchScore: string;
1851
- };
1852
- lastTrainingMs?: number;
1853
- }>('hooks/intelligence', {
1854
- mode,
1855
- enableSona,
1856
- enableMoe,
1857
- enableHnsw,
1858
- embeddingProvider,
1859
- forceTraining,
1860
- showStatus,
1861
- });
1862
-
1863
- if (forceTraining) {
1864
- spinner.setText('Running training cycle...');
1865
- await new Promise(resolve => setTimeout(resolve, 500));
1866
- spinner.succeed('Training cycle completed');
1867
- } else {
1868
- spinner.succeed('Intelligence system active');
1869
- }
1870
-
1871
- if (ctx.flags.format === 'json') {
1872
- output.printJson(result);
1873
- return { success: true, data: result };
1874
- }
1875
-
1876
- // Status display
1877
- output.writeln();
1878
- output.printBox(
1879
- [
1880
- `Mode: ${output.highlight(result.mode)}`,
1881
- `Status: ${formatIntelligenceStatus(result.status)}`,
1882
- `Last Training: ${result.lastTrainingMs ? `${result.lastTrainingMs.toFixed(2)}ms` : 'Never'}`
1883
- ].join('\n'),
1884
- 'Intelligence Status'
1885
- );
1886
-
1887
- // SONA Component
1888
- output.writeln();
1889
- output.writeln(output.bold('🧠 SONA (Sub-0.05ms Learning)'));
1890
- if (result.components.sona.enabled) {
1891
- output.printTable({
1892
- columns: [
1893
- { key: 'metric', header: 'Metric', width: 25 },
1894
- { key: 'value', header: 'Value', width: 20, align: 'right' }
1895
- ],
1896
- data: [
1897
- { metric: 'Status', value: formatIntelligenceStatus(result.components.sona.status) },
1898
- { metric: 'Learning Time', value: `${result.components.sona.learningTimeMs.toFixed(3)}ms` },
1899
- { metric: 'Adaptation Time', value: `${result.components.sona.adaptationTimeMs.toFixed(3)}ms` },
1900
- { metric: 'Trajectories', value: result.components.sona.trajectoriesRecorded },
1901
- { metric: 'Patterns Learned', value: result.components.sona.patternsLearned },
1902
- { metric: 'Avg Quality', value: `${(result.components.sona.avgQuality * 100).toFixed(1)}%` }
1903
- ]
1904
- });
1905
- } else {
1906
- output.writeln(output.dim(' Disabled'));
1907
- }
1908
-
1909
- // MoE Component
1910
- output.writeln();
1911
- output.writeln(output.bold('🔀 Mixture of Experts (MoE)'));
1912
- if (result.components.moe.enabled) {
1913
- output.printTable({
1914
- columns: [
1915
- { key: 'metric', header: 'Metric', width: 25 },
1916
- { key: 'value', header: 'Value', width: 20, align: 'right' }
1917
- ],
1918
- data: [
1919
- { metric: 'Status', value: formatIntelligenceStatus(result.components.moe.status) },
1920
- { metric: 'Active Experts', value: result.components.moe.expertsActive },
1921
- { metric: 'Routing Accuracy', value: `${(result.components.moe.routingAccuracy * 100).toFixed(1)}%` },
1922
- { metric: 'Load Balance', value: `${(result.components.moe.loadBalance * 100).toFixed(1)}%` }
1923
- ]
1924
- });
1925
- } else {
1926
- output.writeln(output.dim(' Disabled'));
1927
- }
1928
-
1929
- // HNSW Component
1930
- output.writeln();
1931
- output.writeln(output.bold('🔍 HNSW (150x Faster Search)'));
1932
- if (result.components.hnsw.enabled) {
1933
- output.printTable({
1934
- columns: [
1935
- { key: 'metric', header: 'Metric', width: 25 },
1936
- { key: 'value', header: 'Value', width: 20, align: 'right' }
1937
- ],
1938
- data: [
1939
- { metric: 'Status', value: formatIntelligenceStatus(result.components.hnsw.status) },
1940
- { metric: 'Index Size', value: result.components.hnsw.indexSize.toLocaleString() },
1941
- { metric: 'Search Speedup', value: output.success(result.components.hnsw.searchSpeedup) },
1942
- { metric: 'Memory Usage', value: result.components.hnsw.memoryUsage },
1943
- { metric: 'Dimension', value: result.components.hnsw.dimension }
1944
- ]
1945
- });
1946
- } else {
1947
- output.writeln(output.dim(' Disabled'));
1948
- }
1949
-
1950
- // Embeddings
1951
- output.writeln();
1952
- output.writeln(output.bold('📦 Embeddings (ONNX)'));
1953
- output.printTable({
1954
- columns: [
1955
- { key: 'metric', header: 'Metric', width: 25 },
1956
- { key: 'value', header: 'Value', width: 20, align: 'right' }
1957
- ],
1958
- data: [
1959
- { metric: 'Provider', value: result.components.embeddings.provider },
1960
- { metric: 'Model', value: result.components.embeddings.model },
1961
- { metric: 'Dimension', value: result.components.embeddings.dimension },
1962
- { metric: 'Cache Hit Rate', value: `${(result.components.embeddings.cacheHitRate * 100).toFixed(1)}%` }
1963
- ]
1964
- });
1965
-
1966
- // V3 Performance
1967
- output.writeln();
1968
- output.writeln(output.bold('🚀 V3 Performance Gains'));
1969
- output.printList([
1970
- `Flash Attention: ${output.success(result.performance.flashAttention)}`,
1971
- `Memory Reduction: ${output.success(result.performance.memoryReduction)}`,
1972
- `Search Improvement: ${output.success(result.performance.searchImprovement)}`,
1973
- `Token Reduction: ${output.success(result.performance.tokenReduction)}`,
1974
- `SWE-Bench Score: ${output.success(result.performance.sweBenchScore)}`
1975
- ]);
1976
-
1977
- return { success: true, data: result };
1978
- } catch (error) {
1979
- spinner.fail('Intelligence system error');
1980
- if (error instanceof MCPClientError) {
1981
- output.printError(`Intelligence error: ${error.message}`);
1982
- } else {
1983
- output.printError(`Unexpected error: ${String(error)}`);
1984
- }
1985
- return { success: false, exitCode: 1 };
1986
- }
1987
- }
1988
- };
1989
-
1990
- function formatIntelligenceStatus(status: string): string {
1991
- switch (status) {
1992
- case 'active':
1993
- case 'ready':
1994
- return output.success(status);
1995
- case 'training':
1996
- return output.highlight(status);
1997
- case 'idle':
1998
- return output.dim(status);
1999
- case 'disabled':
2000
- case 'error':
2001
- return output.error(status);
2002
- default:
2003
- return status;
2004
- }
2005
- }
2006
-
2007
- // =============================================================================
2008
- // Worker Commands (12 Background Workers)
2009
- // =============================================================================
2010
-
2011
- const workerListCommand: Command = {
2012
- name: 'list',
2013
- description: 'List all 12 background workers with capabilities',
2014
- options: [
2015
- { name: 'status', short: 's', type: 'string', description: 'Filter by status (all, running, completed, pending)' },
2016
- { name: 'active', short: 'a', type: 'boolean', description: 'Show active worker instances' },
2017
- ],
2018
- examples: [
2019
- { command: 'claude-flow hooks worker list', description: 'List all workers' },
2020
- { command: 'claude-flow hooks worker list --active', description: 'Show active instances' },
2021
- ],
2022
- action: async (ctx: CommandContext): Promise<CommandResult> => {
2023
- const spinner = output.createSpinner({ text: 'Loading workers...', spinner: 'dots' });
2024
- spinner.start();
2025
-
2026
- try {
2027
- const result = await callMCPTool<{
2028
- workers: Array<{
2029
- trigger: string;
2030
- description: string;
2031
- priority: string;
2032
- estimatedDuration: string;
2033
- capabilities: string[];
2034
- patterns: number;
2035
- }>;
2036
- total: number;
2037
- active: {
2038
- instances: Array<{
2039
- id: string;
2040
- trigger: string;
2041
- status: string;
2042
- progress: number;
2043
- phase: string;
2044
- }>;
2045
- count: number;
2046
- byStatus: Record<string, number>;
2047
- };
2048
- performanceTargets: Record<string, string | number>;
2049
- }>('hooks/worker-list', {
2050
- status: ctx.flags['status'] || 'all',
2051
- includeActive: ctx.flags['active'] !== false,
2052
- });
2053
-
2054
- spinner.succeed('Workers loaded');
2055
-
2056
- output.writeln();
2057
- output.writeln(output.bold('Background Workers (12 Total)'));
2058
- output.writeln();
2059
-
2060
- output.printTable({
2061
- columns: [
2062
- { key: 'trigger', header: 'Worker', width: 14 },
2063
- { key: 'priority', header: 'Priority', width: 10 },
2064
- { key: 'estimatedDuration', header: 'Est. Time', width: 10 },
2065
- { key: 'description', header: 'Description', width: 40 },
2066
- ],
2067
- data: result.workers.map(w => ({
2068
- trigger: output.highlight(w.trigger),
2069
- priority: w.priority === 'critical' ? output.error(w.priority) :
2070
- w.priority === 'high' ? output.warning(w.priority) :
2071
- w.priority,
2072
- estimatedDuration: w.estimatedDuration,
2073
- description: w.description,
2074
- })),
2075
- });
2076
-
2077
- if (ctx.flags['active'] && result.active.count > 0) {
2078
- output.writeln();
2079
- output.writeln(output.bold('Active Instances'));
2080
- output.printTable({
2081
- columns: [
2082
- { key: 'id', header: 'Worker ID', width: 35 },
2083
- { key: 'trigger', header: 'Type', width: 12 },
2084
- { key: 'status', header: 'Status', width: 12 },
2085
- { key: 'progress', header: 'Progress', width: 10 },
2086
- ],
2087
- data: result.active.instances.map(w => ({
2088
- id: w.id,
2089
- trigger: w.trigger,
2090
- status: w.status === 'running' ? output.highlight(w.status) :
2091
- w.status === 'completed' ? output.success(w.status) :
2092
- w.status === 'failed' ? output.error(w.status) : w.status,
2093
- progress: `${w.progress}%`,
2094
- })),
2095
- });
2096
- }
2097
-
2098
- output.writeln();
2099
- output.writeln(output.dim('Performance targets:'));
2100
- output.writeln(output.dim(` Trigger detection: ${result.performanceTargets.triggerDetection}`));
2101
- output.writeln(output.dim(` Worker spawn: ${result.performanceTargets.workerSpawn}`));
2102
- output.writeln(output.dim(` Max concurrent: ${result.performanceTargets.maxConcurrent}`));
2103
-
2104
- return { success: true, data: result };
2105
- } catch (error) {
2106
- spinner.fail('Failed to load workers');
2107
- if (error instanceof MCPClientError) {
2108
- output.printError(`Worker error: ${error.message}`);
2109
- }
2110
- return { success: false, exitCode: 1 };
2111
- }
2112
- }
2113
- };
2114
-
2115
- const workerDispatchCommand: Command = {
2116
- name: 'dispatch',
2117
- description: 'Dispatch a background worker for analysis/optimization',
2118
- options: [
2119
- { name: 'trigger', short: 't', type: 'string', description: 'Worker type (ultralearn, optimize, audit, map, etc.)', required: true },
2120
- { name: 'context', short: 'c', type: 'string', description: 'Context for the worker (file path, topic)' },
2121
- { name: 'priority', short: 'p', type: 'string', description: 'Priority (low, normal, high, critical)' },
2122
- { name: 'sync', short: 's', type: 'boolean', description: 'Wait for completion (synchronous)' },
2123
- ],
2124
- examples: [
2125
- { command: 'claude-flow hooks worker dispatch -t optimize -c src/', description: 'Dispatch optimize worker' },
2126
- { command: 'claude-flow hooks worker dispatch -t audit -p critical', description: 'Security audit with critical priority' },
2127
- { command: 'claude-flow hooks worker dispatch -t testgaps --sync', description: 'Test coverage analysis (sync)' },
2128
- ],
2129
- action: async (ctx: CommandContext): Promise<CommandResult> => {
2130
- const trigger = ctx.flags['trigger'] as string;
2131
- const context = ctx.flags['context'] as string || 'default';
2132
- const priority = ctx.flags['priority'] as string;
2133
- const background = !ctx.flags['sync'];
2134
-
2135
- if (!trigger) {
2136
- output.printError('--trigger is required');
2137
- output.writeln('Available triggers: ultralearn, optimize, consolidate, predict, audit, map, preload, deepdive, document, refactor, benchmark, testgaps');
2138
- return { success: false, exitCode: 1 };
2139
- }
2140
-
2141
- const spinner = output.createSpinner({ text: `Dispatching ${trigger} worker...`, spinner: 'dots' });
2142
- spinner.start();
2143
-
2144
- try {
2145
- const result = await callMCPTool<{
2146
- success: boolean;
2147
- workerId: string;
2148
- trigger: string;
2149
- context: string;
2150
- priority: string;
2151
- config: {
2152
- description: string;
2153
- estimatedDuration: string;
2154
- capabilities: string[];
2155
- };
2156
- status: string;
2157
- error?: string;
2158
- }>('hooks/worker-dispatch', {
2159
- trigger,
2160
- context,
2161
- priority,
2162
- background,
2163
- });
2164
-
2165
- if (!result.success) {
2166
- spinner.fail(`Failed: ${result.error}`);
2167
- return { success: false, exitCode: 1 };
2168
- }
2169
-
2170
- spinner.succeed(`Worker dispatched: ${result.workerId}`);
2171
-
2172
- output.writeln();
2173
- output.printTable({
2174
- columns: [
2175
- { key: 'field', header: 'Field', width: 18 },
2176
- { key: 'value', header: 'Value', width: 50 },
2177
- ],
2178
- data: [
2179
- { field: 'Worker ID', value: output.highlight(result.workerId) },
2180
- { field: 'Trigger', value: result.trigger },
2181
- { field: 'Context', value: result.context },
2182
- { field: 'Priority', value: result.priority },
2183
- { field: 'Description', value: result.config.description },
2184
- { field: 'Est. Duration', value: result.config.estimatedDuration },
2185
- { field: 'Capabilities', value: result.config.capabilities.join(', ') },
2186
- { field: 'Status', value: result.status === 'dispatched' ? output.highlight('dispatched (background)') : output.success('completed') },
2187
- ],
2188
- });
2189
-
2190
- if (background) {
2191
- output.writeln();
2192
- output.writeln(output.dim(`Check status: claude-flow hooks worker status --id ${result.workerId}`));
2193
- }
2194
-
2195
- return { success: true, data: result };
2196
- } catch (error) {
2197
- spinner.fail('Worker dispatch failed');
2198
- if (error instanceof MCPClientError) {
2199
- output.printError(`Dispatch error: ${error.message}`);
2200
- }
2201
- return { success: false, exitCode: 1 };
2202
- }
2203
- }
2204
- };
2205
-
2206
- const workerStatusCommand: Command = {
2207
- name: 'status',
2208
- description: 'Get status of workers',
2209
- options: [
2210
- { name: 'id', type: 'string', description: 'Specific worker ID to check' },
2211
- { name: 'all', short: 'a', type: 'boolean', description: 'Include completed workers' },
2212
- ],
2213
- examples: [
2214
- { command: 'claude-flow hooks worker status', description: 'Show running workers' },
2215
- { command: 'claude-flow hooks worker status --id worker_audit_1', description: 'Check specific worker' },
2216
- { command: 'claude-flow hooks worker status --all', description: 'Include completed workers' },
2217
- ],
2218
- action: async (ctx: CommandContext): Promise<CommandResult> => {
2219
- const workerId = ctx.flags['id'] as string;
2220
- const includeCompleted = ctx.flags['all'] as boolean;
2221
-
2222
- const spinner = output.createSpinner({ text: 'Checking worker status...', spinner: 'dots' });
2223
- spinner.start();
2224
-
2225
- try {
2226
- const result = await callMCPTool<{
2227
- success: boolean;
2228
- worker?: {
2229
- id: string;
2230
- trigger: string;
2231
- context: string;
2232
- status: string;
2233
- progress: number;
2234
- phase: string;
2235
- duration: number;
2236
- };
2237
- workers?: Array<{
2238
- id: string;
2239
- trigger: string;
2240
- status: string;
2241
- progress: number;
2242
- phase: string;
2243
- duration: number;
2244
- }>;
2245
- summary?: {
2246
- total: number;
2247
- running: number;
2248
- completed: number;
2249
- failed: number;
2250
- };
2251
- error?: string;
2252
- }>('hooks/worker-status', {
2253
- workerId,
2254
- includeCompleted,
2255
- });
2256
-
2257
- if (!result.success) {
2258
- spinner.fail(`Failed: ${result.error}`);
2259
- return { success: false, exitCode: 1 };
2260
- }
2261
-
2262
- spinner.succeed('Status retrieved');
2263
-
2264
- if (result.worker) {
2265
- output.writeln();
2266
- output.writeln(output.bold(`Worker: ${result.worker.id}`));
2267
- output.printTable({
2268
- columns: [
2269
- { key: 'field', header: 'Field', width: 15 },
2270
- { key: 'value', header: 'Value', width: 40 },
2271
- ],
2272
- data: [
2273
- { field: 'Trigger', value: result.worker.trigger },
2274
- { field: 'Context', value: result.worker.context },
2275
- { field: 'Status', value: formatWorkerStatus(result.worker.status) },
2276
- { field: 'Progress', value: `${result.worker.progress}%` },
2277
- { field: 'Phase', value: result.worker.phase },
2278
- { field: 'Duration', value: `${result.worker.duration}ms` },
2279
- ],
2280
- });
2281
- } else if (result.workers && result.workers.length > 0) {
2282
- output.writeln();
2283
- output.writeln(output.bold('Active Workers'));
2284
- output.printTable({
2285
- columns: [
2286
- { key: 'id', header: 'Worker ID', width: 35 },
2287
- { key: 'trigger', header: 'Type', width: 12 },
2288
- { key: 'status', header: 'Status', width: 12 },
2289
- { key: 'progress', header: 'Progress', width: 10 },
2290
- { key: 'duration', header: 'Duration', width: 12 },
2291
- ],
2292
- data: result.workers.map(w => ({
2293
- id: w.id,
2294
- trigger: w.trigger,
2295
- status: formatWorkerStatus(w.status),
2296
- progress: `${w.progress}%`,
2297
- duration: `${w.duration}ms`,
2298
- })),
2299
- });
2300
-
2301
- if (result.summary) {
2302
- output.writeln();
2303
- output.writeln(`Total: ${result.summary.total} | Running: ${output.highlight(String(result.summary.running))} | Completed: ${output.success(String(result.summary.completed))} | Failed: ${output.error(String(result.summary.failed))}`);
2304
- }
2305
- } else {
2306
- output.writeln();
2307
- output.writeln(output.dim('No active workers'));
2308
- }
2309
-
2310
- return { success: true, data: result };
2311
- } catch (error) {
2312
- spinner.fail('Status check failed');
2313
- if (error instanceof MCPClientError) {
2314
- output.printError(`Status error: ${error.message}`);
2315
- }
2316
- return { success: false, exitCode: 1 };
2317
- }
2318
- }
2319
- };
2320
-
2321
- const workerDetectCommand: Command = {
2322
- name: 'detect',
2323
- description: 'Detect worker triggers from prompt text',
2324
- options: [
2325
- { name: 'prompt', short: 'p', type: 'string', description: 'Prompt text to analyze', required: true },
2326
- { name: 'auto-dispatch', short: 'a', type: 'boolean', description: 'Automatically dispatch detected workers' },
2327
- { name: 'min-confidence', short: 'm', type: 'string', description: 'Minimum confidence threshold (0-1)' },
2328
- ],
2329
- examples: [
2330
- { command: 'claude-flow hooks worker detect -p "optimize performance"', description: 'Detect triggers in prompt' },
2331
- { command: 'claude-flow hooks worker detect -p "security audit" --auto-dispatch', description: 'Detect and dispatch' },
2332
- ],
2333
- action: async (ctx: CommandContext): Promise<CommandResult> => {
2334
- const prompt = ctx.flags['prompt'] as string;
2335
- const autoDispatch = ctx.flags['auto-dispatch'] as boolean;
2336
- const minConfidence = parseFloat(ctx.flags['min-confidence'] as string || '0.5');
2337
-
2338
- if (!prompt) {
2339
- output.printError('--prompt is required');
2340
- return { success: false, exitCode: 1 };
2341
- }
2342
-
2343
- const spinner = output.createSpinner({ text: 'Analyzing prompt...', spinner: 'dots' });
2344
- spinner.start();
2345
-
2346
- try {
2347
- const result = await callMCPTool<{
2348
- prompt: string;
2349
- detection: {
2350
- detected: boolean;
2351
- triggers: string[];
2352
- confidence: number;
2353
- context: string;
2354
- };
2355
- triggersFound: number;
2356
- triggerDetails?: Array<{
2357
- trigger: string;
2358
- description: string;
2359
- priority: string;
2360
- }>;
2361
- autoDispatched?: boolean;
2362
- workerIds?: string[];
2363
- }>('hooks/worker-detect', {
2364
- prompt,
2365
- autoDispatch,
2366
- minConfidence,
2367
- });
2368
-
2369
- if (result.detection.detected) {
2370
- spinner.succeed(`Detected ${result.triggersFound} worker trigger(s)`);
2371
- } else {
2372
- spinner.succeed('No worker triggers detected');
2373
- }
2374
-
2375
- output.writeln();
2376
- output.writeln(output.bold('Detection Results'));
2377
- output.writeln(`Prompt: ${output.dim(result.prompt)}`);
2378
- output.writeln(`Confidence: ${(result.detection.confidence * 100).toFixed(0)}%`);
2379
-
2380
- if (result.triggerDetails && result.triggerDetails.length > 0) {
2381
- output.writeln();
2382
- output.printTable({
2383
- columns: [
2384
- { key: 'trigger', header: 'Trigger', width: 14 },
2385
- { key: 'priority', header: 'Priority', width: 10 },
2386
- { key: 'description', header: 'Description', width: 45 },
2387
- ],
2388
- data: result.triggerDetails.map(t => ({
2389
- trigger: output.highlight(t.trigger),
2390
- priority: t.priority,
2391
- description: t.description,
2392
- })),
2393
- });
2394
- }
2395
-
2396
- if (result.autoDispatched && result.workerIds) {
2397
- output.writeln();
2398
- output.writeln(output.success('Workers auto-dispatched:'));
2399
- result.workerIds.forEach(id => {
2400
- output.writeln(` - ${id}`);
2401
- });
2402
- }
2403
-
2404
- return { success: true, data: result };
2405
- } catch (error) {
2406
- spinner.fail('Detection failed');
2407
- if (error instanceof MCPClientError) {
2408
- output.printError(`Detection error: ${error.message}`);
2409
- }
2410
- return { success: false, exitCode: 1 };
2411
- }
2412
- }
2413
- };
2414
-
2415
- const workerCancelCommand: Command = {
2416
- name: 'cancel',
2417
- description: 'Cancel a running worker',
2418
- options: [
2419
- { name: 'id', type: 'string', description: 'Worker ID to cancel', required: true },
2420
- ],
2421
- examples: [
2422
- { command: 'claude-flow hooks worker cancel --id worker_audit_1', description: 'Cancel specific worker' },
2423
- ],
2424
- action: async (ctx: CommandContext): Promise<CommandResult> => {
2425
- const workerId = ctx.flags['id'] as string;
2426
-
2427
- if (!workerId) {
2428
- output.printError('--id is required');
2429
- return { success: false, exitCode: 1 };
2430
- }
2431
-
2432
- const spinner = output.createSpinner({ text: `Cancelling worker ${workerId}...`, spinner: 'dots' });
2433
- spinner.start();
2434
-
2435
- try {
2436
- const result = await callMCPTool<{
2437
- success: boolean;
2438
- workerId: string;
2439
- cancelled: boolean;
2440
- error?: string;
2441
- }>('hooks/worker-cancel', { workerId });
2442
-
2443
- if (!result.success) {
2444
- spinner.fail(`Failed: ${result.error}`);
2445
- return { success: false, exitCode: 1 };
2446
- }
2447
-
2448
- spinner.succeed(`Worker ${workerId} cancelled`);
2449
- return { success: true, data: result };
2450
- } catch (error) {
2451
- spinner.fail('Cancel failed');
2452
- if (error instanceof MCPClientError) {
2453
- output.printError(`Cancel error: ${error.message}`);
2454
- }
2455
- return { success: false, exitCode: 1 };
2456
- }
2457
- }
2458
- };
2459
-
2460
- function formatWorkerStatus(status: string): string {
2461
- switch (status) {
2462
- case 'running':
2463
- return output.highlight(status);
2464
- case 'completed':
2465
- return output.success(status);
2466
- case 'failed':
2467
- return output.error(status);
2468
- case 'pending':
2469
- return output.dim(status);
2470
- default:
2471
- return status;
2472
- }
2473
- }
2474
-
2475
- // Worker parent command
2476
- const workerCommand: Command = {
2477
- name: 'worker',
2478
- description: 'Background worker management (12 workers for analysis/optimization)',
2479
- subcommands: [
2480
- workerListCommand,
2481
- workerDispatchCommand,
2482
- workerStatusCommand,
2483
- workerDetectCommand,
2484
- workerCancelCommand,
2485
- ],
2486
- options: [],
2487
- examples: [
2488
- { command: 'claude-flow hooks worker list', description: 'List all workers' },
2489
- { command: 'claude-flow hooks worker dispatch -t optimize', description: 'Dispatch optimizer' },
2490
- { command: 'claude-flow hooks worker detect -p "test coverage"', description: 'Detect from prompt' },
2491
- ],
2492
- action: async (): Promise<CommandResult> => {
2493
- output.writeln();
2494
- output.writeln(output.bold('Background Worker System (12 Workers)'));
2495
- output.writeln();
2496
- output.writeln('Manage and dispatch background workers for analysis and optimization tasks.');
2497
- output.writeln();
2498
- output.writeln('Available Workers:');
2499
- output.printList([
2500
- `${output.highlight('ultralearn')} - Deep knowledge acquisition`,
2501
- `${output.highlight('optimize')} - Performance optimization`,
2502
- `${output.highlight('consolidate')} - Memory consolidation`,
2503
- `${output.highlight('predict')} - Predictive preloading`,
2504
- `${output.highlight('audit')} - Security analysis (critical)`,
2505
- `${output.highlight('map')} - Codebase mapping`,
2506
- `${output.highlight('preload')} - Resource preloading`,
2507
- `${output.highlight('deepdive')} - Deep code analysis`,
2508
- `${output.highlight('document')} - Auto-documentation`,
2509
- `${output.highlight('refactor')} - Refactoring suggestions`,
2510
- `${output.highlight('benchmark')} - Performance benchmarks`,
2511
- `${output.highlight('testgaps')} - Test coverage analysis`,
2512
- ]);
2513
- output.writeln();
2514
- output.writeln('Subcommands:');
2515
- output.printList([
2516
- `${output.highlight('list')} - List all workers with capabilities`,
2517
- `${output.highlight('dispatch')} - Dispatch a worker`,
2518
- `${output.highlight('status')} - Check worker status`,
2519
- `${output.highlight('detect')} - Detect triggers from prompt`,
2520
- `${output.highlight('cancel')} - Cancel a running worker`,
2521
- ]);
2522
- output.writeln();
2523
- output.writeln('Run "claude-flow hooks worker <subcommand> --help" for details');
2524
-
2525
- return { success: true };
2526
- }
2527
- };
2528
-
2529
- // Main hooks command
2530
- export const hooksCommand: Command = {
2531
- name: 'hooks',
2532
- description: 'Self-learning hooks system for intelligent workflow automation',
2533
- subcommands: [
2534
- preEditCommand,
2535
- postEditCommand,
2536
- preCommandCommand,
2537
- postCommandCommand,
2538
- preTaskCommand,
2539
- postTaskCommand,
2540
- sessionEndCommand,
2541
- sessionRestoreCommand,
2542
- routeCommand,
2543
- explainCommand,
2544
- pretrainCommand,
2545
- buildAgentsCommand,
2546
- metricsCommand,
2547
- transferCommand,
2548
- listCommand,
2549
- intelligenceCommand,
2550
- workerCommand,
2551
- ],
2552
- options: [],
2553
- examples: [
2554
- { command: 'claude-flow hooks pre-edit -f src/utils.ts', description: 'Get context before editing' },
2555
- { command: 'claude-flow hooks route -t "Fix authentication bug"', description: 'Route task to optimal agent' },
2556
- { command: 'claude-flow hooks pretrain', description: 'Bootstrap intelligence from repository' },
2557
- { command: 'claude-flow hooks metrics --v3-dashboard', description: 'View V3 performance metrics' }
2558
- ],
2559
- action: async (ctx: CommandContext): Promise<CommandResult> => {
2560
- output.writeln();
2561
- output.writeln(output.bold('Self-Learning Hooks System'));
2562
- output.writeln();
2563
- output.writeln('Intelligent workflow automation with pattern learning and adaptive routing');
2564
- output.writeln();
2565
- output.writeln('Usage: claude-flow hooks <subcommand> [options]');
2566
- output.writeln();
2567
- output.writeln('Subcommands:');
2568
- output.printList([
2569
- `${output.highlight('pre-edit')} - Get context before editing files`,
2570
- `${output.highlight('post-edit')} - Record editing outcomes for learning`,
2571
- `${output.highlight('pre-command')} - Assess risk before executing commands`,
2572
- `${output.highlight('post-command')} - Record command execution outcomes`,
2573
- `${output.highlight('pre-task')} - Record task start and get agent suggestions`,
2574
- `${output.highlight('post-task')} - Record task completion for learning`,
2575
- `${output.highlight('session-end')} - End current session and persist state`,
2576
- `${output.highlight('session-restore')} - Restore a previous session`,
2577
- `${output.highlight('route')} - Route tasks to optimal agents`,
2578
- `${output.highlight('explain')} - Explain routing decisions`,
2579
- `${output.highlight('pretrain')} - Bootstrap intelligence from repository`,
2580
- `${output.highlight('build-agents')} - Generate optimized agent configs`,
2581
- `${output.highlight('metrics')} - View learning metrics dashboard`,
2582
- `${output.highlight('transfer')} - Transfer patterns from another project`,
2583
- `${output.highlight('list')} - List all registered hooks`,
2584
- `${output.highlight('worker')} - Background worker management (12 workers)`
2585
- ]);
2586
- output.writeln();
2587
- output.writeln('Run "claude-flow hooks <subcommand> --help" for subcommand help');
2588
- output.writeln();
2589
- output.writeln(output.bold('V3 Features:'));
2590
- output.printList([
2591
- '🧠 ReasoningBank adaptive learning',
2592
- '⚡ Flash Attention (2.49x-7.47x speedup)',
2593
- '🔍 AgentDB integration (150x faster search)',
2594
- '📊 84.8% SWE-Bench solve rate',
2595
- '🎯 32.3% token reduction',
2596
- '🚀 2.8-4.4x speed improvement'
2597
- ]);
2598
-
2599
- return { success: true };
2600
- }
2601
- };
2602
-
2603
- export default hooksCommand;