@claude-flow/cli 3.10.46 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (481) hide show
  1. package/.claude/agents/analysis/analyze-code-quality.md +178 -178
  2. package/.claude/agents/analysis/code-analyzer.md +209 -209
  3. package/.claude/agents/analysis/code-review/analyze-code-quality.md +178 -178
  4. package/.claude/agents/architecture/arch-system-design.md +156 -156
  5. package/.claude/agents/architecture/system-design/arch-system-design.md +154 -154
  6. package/.claude/agents/browser/browser-agent.yaml +182 -182
  7. package/.claude/agents/consensus/byzantine-coordinator.md +62 -62
  8. package/.claude/agents/consensus/crdt-synchronizer.md +996 -996
  9. package/.claude/agents/consensus/gossip-coordinator.md +62 -62
  10. package/.claude/agents/consensus/performance-benchmarker.md +850 -850
  11. package/.claude/agents/consensus/quorum-manager.md +822 -822
  12. package/.claude/agents/consensus/raft-manager.md +62 -62
  13. package/.claude/agents/consensus/security-manager.md +621 -621
  14. package/.claude/agents/core/planner.md +374 -374
  15. package/.claude/agents/custom/test-long-runner.md +44 -44
  16. package/.claude/agents/data/data-ml-model.md +444 -444
  17. package/.claude/agents/data/ml/data-ml-model.md +192 -192
  18. package/.claude/agents/development/backend/dev-backend-api.md +141 -141
  19. package/.claude/agents/development/dev-backend-api.md +344 -344
  20. package/.claude/agents/devops/ci-cd/ops-cicd-github.md +163 -163
  21. package/.claude/agents/devops/ops-cicd-github.md +164 -164
  22. package/.claude/agents/documentation/api-docs/docs-api-openapi.md +173 -173
  23. package/.claude/agents/documentation/docs-api-openapi.md +354 -354
  24. package/.claude/agents/flow-nexus/app-store.md +87 -87
  25. package/.claude/agents/flow-nexus/authentication.md +68 -68
  26. package/.claude/agents/flow-nexus/challenges.md +80 -80
  27. package/.claude/agents/flow-nexus/neural-network.md +87 -87
  28. package/.claude/agents/flow-nexus/payments.md +82 -82
  29. package/.claude/agents/flow-nexus/sandbox.md +75 -75
  30. package/.claude/agents/flow-nexus/swarm.md +75 -75
  31. package/.claude/agents/flow-nexus/user-tools.md +95 -95
  32. package/.claude/agents/flow-nexus/workflow.md +83 -83
  33. package/.claude/agents/github/code-review-swarm.md +377 -377
  34. package/.claude/agents/github/github-modes.md +172 -172
  35. package/.claude/agents/github/issue-tracker.md +575 -575
  36. package/.claude/agents/github/multi-repo-swarm.md +552 -552
  37. package/.claude/agents/github/pr-manager.md +437 -437
  38. package/.claude/agents/github/project-board-sync.md +508 -508
  39. package/.claude/agents/github/release-manager.md +604 -604
  40. package/.claude/agents/github/release-swarm.md +582 -582
  41. package/.claude/agents/github/repo-architect.md +397 -397
  42. package/.claude/agents/github/swarm-issue.md +572 -572
  43. package/.claude/agents/github/swarm-pr.md +427 -427
  44. package/.claude/agents/github/sync-coordinator.md +451 -451
  45. package/.claude/agents/github/workflow-automation.md +902 -902
  46. package/.claude/agents/goal/agent.md +815 -815
  47. package/.claude/agents/optimization/benchmark-suite.md +664 -664
  48. package/.claude/agents/optimization/load-balancer.md +430 -430
  49. package/.claude/agents/optimization/performance-monitor.md +671 -671
  50. package/.claude/agents/optimization/resource-allocator.md +673 -673
  51. package/.claude/agents/optimization/topology-optimizer.md +807 -807
  52. package/.claude/agents/payments/agentic-payments.md +126 -126
  53. package/.claude/agents/sona/sona-learning-optimizer.md +74 -74
  54. package/.claude/agents/sparc/architecture.md +698 -698
  55. package/.claude/agents/sparc/pseudocode.md +519 -519
  56. package/.claude/agents/sparc/refinement.md +801 -801
  57. package/.claude/agents/sparc/specification.md +477 -477
  58. package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +224 -224
  59. package/.claude/agents/specialized/spec-mobile-react-native.md +226 -226
  60. package/.claude/agents/sublinear/consensus-coordinator.md +337 -337
  61. package/.claude/agents/sublinear/matrix-optimizer.md +184 -184
  62. package/.claude/agents/sublinear/pagerank-analyzer.md +298 -298
  63. package/.claude/agents/sublinear/performance-optimizer.md +367 -367
  64. package/.claude/agents/sublinear/trading-predictor.md +245 -245
  65. package/.claude/agents/swarm/adaptive-coordinator.md +1126 -1126
  66. package/.claude/agents/swarm/hierarchical-coordinator.md +709 -709
  67. package/.claude/agents/swarm/mesh-coordinator.md +962 -962
  68. package/.claude/agents/templates/automation-smart-agent.md +204 -204
  69. package/.claude/agents/templates/base-template-generator.md +289 -289
  70. package/.claude/agents/templates/coordinator-swarm-init.md +89 -89
  71. package/.claude/agents/templates/github-pr-manager.md +176 -176
  72. package/.claude/agents/templates/implementer-sparc-coder.md +258 -258
  73. package/.claude/agents/templates/memory-coordinator.md +186 -186
  74. package/.claude/agents/templates/orchestrator-task.md +138 -138
  75. package/.claude/agents/templates/performance-analyzer.md +198 -198
  76. package/.claude/agents/templates/sparc-coordinator.md +513 -513
  77. package/.claude/agents/testing/production-validator.md +394 -394
  78. package/.claude/agents/testing/tdd-london-swarm.md +243 -243
  79. package/.claude/agents/v3/aidefence-guardian.md +282 -282
  80. package/.claude/agents/v3/claims-authorizer.md +208 -208
  81. package/.claude/agents/v3/collective-intelligence-coordinator.md +993 -993
  82. package/.claude/agents/v3/ddd-domain-expert.md +220 -220
  83. package/.claude/agents/v3/injection-analyst.md +236 -236
  84. package/.claude/agents/v3/performance-engineer.md +1233 -1233
  85. package/.claude/agents/v3/pii-detector.md +151 -151
  86. package/.claude/agents/v3/reasoningbank-learner.md +213 -213
  87. package/.claude/agents/v3/security-architect-aidefence.md +410 -410
  88. package/.claude/agents/v3/security-architect.md +867 -867
  89. package/.claude/agents/v3/swarm-memory-manager.md +157 -157
  90. package/.claude/agents/v3/v3-integration-architect.md +205 -205
  91. package/.claude/commands/agents/README.md +50 -50
  92. package/.claude/commands/agents/agent-capabilities.md +140 -140
  93. package/.claude/commands/agents/agent-coordination.md +28 -28
  94. package/.claude/commands/agents/agent-spawning.md +28 -28
  95. package/.claude/commands/agents/agent-types.md +216 -216
  96. package/.claude/commands/agents/health.md +139 -139
  97. package/.claude/commands/agents/list.md +100 -100
  98. package/.claude/commands/agents/logs.md +130 -130
  99. package/.claude/commands/agents/metrics.md +122 -122
  100. package/.claude/commands/agents/pool.md +127 -127
  101. package/.claude/commands/agents/spawn.md +140 -140
  102. package/.claude/commands/agents/status.md +115 -115
  103. package/.claude/commands/agents/stop.md +102 -102
  104. package/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +53 -53
  105. package/.claude/commands/analysis/README.md +9 -9
  106. package/.claude/commands/analysis/bottleneck-detect.md +162 -162
  107. package/.claude/commands/analysis/performance-bottlenecks.md +58 -58
  108. package/.claude/commands/analysis/performance-report.md +25 -25
  109. package/.claude/commands/analysis/token-efficiency.md +44 -44
  110. package/.claude/commands/analysis/token-usage.md +25 -25
  111. package/.claude/commands/automation/README.md +9 -9
  112. package/.claude/commands/automation/auto-agent.md +122 -122
  113. package/.claude/commands/automation/self-healing.md +105 -105
  114. package/.claude/commands/automation/session-memory.md +89 -89
  115. package/.claude/commands/automation/smart-agents.md +72 -72
  116. package/.claude/commands/automation/smart-spawn.md +25 -25
  117. package/.claude/commands/automation/workflow-select.md +25 -25
  118. package/.claude/commands/claude-flow-help.md +103 -103
  119. package/.claude/commands/claude-flow-memory.md +107 -107
  120. package/.claude/commands/claude-flow-swarm.md +205 -205
  121. package/.claude/commands/coordination/README.md +9 -9
  122. package/.claude/commands/coordination/agent-spawn.md +25 -25
  123. package/.claude/commands/coordination/init.md +44 -44
  124. package/.claude/commands/coordination/orchestrate.md +43 -43
  125. package/.claude/commands/coordination/spawn.md +45 -45
  126. package/.claude/commands/coordination/swarm-init.md +85 -85
  127. package/.claude/commands/coordination/task-orchestrate.md +25 -25
  128. package/.claude/commands/github/README.md +11 -11
  129. package/.claude/commands/github/code-review-swarm.md +513 -513
  130. package/.claude/commands/github/code-review.md +25 -25
  131. package/.claude/commands/github/github-modes.md +146 -146
  132. package/.claude/commands/github/github-swarm.md +121 -121
  133. package/.claude/commands/github/issue-tracker.md +291 -291
  134. package/.claude/commands/github/issue-triage.md +25 -25
  135. package/.claude/commands/github/multi-repo-swarm.md +518 -518
  136. package/.claude/commands/github/pr-enhance.md +26 -26
  137. package/.claude/commands/github/pr-manager.md +169 -169
  138. package/.claude/commands/github/project-board-sync.md +470 -470
  139. package/.claude/commands/github/release-manager.md +339 -339
  140. package/.claude/commands/github/release-swarm.md +543 -543
  141. package/.claude/commands/github/repo-analyze.md +25 -25
  142. package/.claude/commands/github/repo-architect.md +366 -366
  143. package/.claude/commands/github/swarm-issue.md +484 -484
  144. package/.claude/commands/github/swarm-pr.md +287 -287
  145. package/.claude/commands/github/sync-coordinator.md +302 -302
  146. package/.claude/commands/github/workflow-automation.md +441 -441
  147. package/.claude/commands/hive-mind/README.md +17 -17
  148. package/.claude/commands/hive-mind/hive-mind-consensus.md +8 -8
  149. package/.claude/commands/hive-mind/hive-mind-init.md +18 -18
  150. package/.claude/commands/hive-mind/hive-mind-memory.md +8 -8
  151. package/.claude/commands/hive-mind/hive-mind-metrics.md +8 -8
  152. package/.claude/commands/hive-mind/hive-mind-resume.md +8 -8
  153. package/.claude/commands/hive-mind/hive-mind-sessions.md +8 -8
  154. package/.claude/commands/hive-mind/hive-mind-spawn.md +21 -21
  155. package/.claude/commands/hive-mind/hive-mind-status.md +8 -8
  156. package/.claude/commands/hive-mind/hive-mind-stop.md +8 -8
  157. package/.claude/commands/hive-mind/hive-mind-wizard.md +8 -8
  158. package/.claude/commands/hive-mind/hive-mind.md +27 -27
  159. package/.claude/commands/hooks/README.md +11 -11
  160. package/.claude/commands/hooks/overview.md +57 -57
  161. package/.claude/commands/hooks/post-edit.md +117 -117
  162. package/.claude/commands/hooks/post-task.md +112 -112
  163. package/.claude/commands/hooks/pre-edit.md +113 -113
  164. package/.claude/commands/hooks/pre-task.md +111 -111
  165. package/.claude/commands/hooks/session-end.md +118 -118
  166. package/.claude/commands/hooks/setup.md +102 -102
  167. package/.claude/commands/memory/README.md +9 -9
  168. package/.claude/commands/memory/memory-persist.md +25 -25
  169. package/.claude/commands/memory/memory-search.md +25 -25
  170. package/.claude/commands/memory/memory-usage.md +25 -25
  171. package/.claude/commands/memory/neural.md +47 -47
  172. package/.claude/commands/monitoring/README.md +9 -9
  173. package/.claude/commands/monitoring/agent-metrics.md +25 -25
  174. package/.claude/commands/monitoring/agents.md +44 -44
  175. package/.claude/commands/monitoring/real-time-view.md +25 -25
  176. package/.claude/commands/monitoring/status.md +46 -46
  177. package/.claude/commands/monitoring/swarm-monitor.md +25 -25
  178. package/.claude/commands/optimization/README.md +9 -9
  179. package/.claude/commands/optimization/auto-topology.md +61 -61
  180. package/.claude/commands/optimization/cache-manage.md +25 -25
  181. package/.claude/commands/optimization/parallel-execute.md +25 -25
  182. package/.claude/commands/optimization/parallel-execution.md +49 -49
  183. package/.claude/commands/optimization/topology-optimize.md +25 -25
  184. package/.claude/commands/pair/README.md +260 -260
  185. package/.claude/commands/pair/commands.md +545 -545
  186. package/.claude/commands/pair/config.md +509 -509
  187. package/.claude/commands/pair/examples.md +511 -511
  188. package/.claude/commands/pair/modes.md +347 -347
  189. package/.claude/commands/pair/session.md +406 -406
  190. package/.claude/commands/pair/start.md +208 -208
  191. package/.claude/commands/sparc/analyzer.md +51 -51
  192. package/.claude/commands/sparc/architect.md +53 -53
  193. package/.claude/commands/sparc/ask.md +97 -97
  194. package/.claude/commands/sparc/batch-executor.md +54 -54
  195. package/.claude/commands/sparc/code.md +89 -89
  196. package/.claude/commands/sparc/coder.md +54 -54
  197. package/.claude/commands/sparc/debug.md +83 -83
  198. package/.claude/commands/sparc/debugger.md +54 -54
  199. package/.claude/commands/sparc/designer.md +53 -53
  200. package/.claude/commands/sparc/devops.md +109 -109
  201. package/.claude/commands/sparc/docs-writer.md +80 -80
  202. package/.claude/commands/sparc/documenter.md +54 -54
  203. package/.claude/commands/sparc/innovator.md +54 -54
  204. package/.claude/commands/sparc/integration.md +83 -83
  205. package/.claude/commands/sparc/mcp.md +117 -117
  206. package/.claude/commands/sparc/memory-manager.md +54 -54
  207. package/.claude/commands/sparc/optimizer.md +54 -54
  208. package/.claude/commands/sparc/orchestrator.md +131 -131
  209. package/.claude/commands/sparc/post-deployment-monitoring-mode.md +83 -83
  210. package/.claude/commands/sparc/refinement-optimization-mode.md +83 -83
  211. package/.claude/commands/sparc/researcher.md +54 -54
  212. package/.claude/commands/sparc/reviewer.md +54 -54
  213. package/.claude/commands/sparc/security-review.md +80 -80
  214. package/.claude/commands/sparc/sparc-modes.md +174 -174
  215. package/.claude/commands/sparc/sparc.md +111 -111
  216. package/.claude/commands/sparc/spec-pseudocode.md +80 -80
  217. package/.claude/commands/sparc/supabase-admin.md +348 -348
  218. package/.claude/commands/sparc/swarm-coordinator.md +54 -54
  219. package/.claude/commands/sparc/tdd.md +54 -54
  220. package/.claude/commands/sparc/tester.md +54 -54
  221. package/.claude/commands/sparc/tutorial.md +79 -79
  222. package/.claude/commands/sparc/workflow-manager.md +54 -54
  223. package/.claude/commands/sparc.md +166 -166
  224. package/.claude/commands/stream-chain/pipeline.md +120 -120
  225. package/.claude/commands/stream-chain/run.md +69 -69
  226. package/.claude/commands/swarm/README.md +15 -15
  227. package/.claude/commands/swarm/analysis.md +95 -95
  228. package/.claude/commands/swarm/development.md +96 -96
  229. package/.claude/commands/swarm/examples.md +168 -168
  230. package/.claude/commands/swarm/maintenance.md +102 -102
  231. package/.claude/commands/swarm/optimization.md +117 -117
  232. package/.claude/commands/swarm/research.md +136 -136
  233. package/.claude/commands/swarm/swarm-analysis.md +8 -8
  234. package/.claude/commands/swarm/swarm-background.md +8 -8
  235. package/.claude/commands/swarm/swarm-init.md +19 -19
  236. package/.claude/commands/swarm/swarm-modes.md +8 -8
  237. package/.claude/commands/swarm/swarm-monitor.md +8 -8
  238. package/.claude/commands/swarm/swarm-spawn.md +19 -19
  239. package/.claude/commands/swarm/swarm-status.md +8 -8
  240. package/.claude/commands/swarm/swarm-strategies.md +8 -8
  241. package/.claude/commands/swarm/swarm.md +87 -87
  242. package/.claude/commands/swarm/testing.md +131 -131
  243. package/.claude/commands/training/README.md +9 -9
  244. package/.claude/commands/training/model-update.md +25 -25
  245. package/.claude/commands/training/neural-patterns.md +107 -107
  246. package/.claude/commands/training/neural-train.md +75 -75
  247. package/.claude/commands/training/pattern-learn.md +25 -25
  248. package/.claude/commands/training/specialization.md +62 -62
  249. package/.claude/commands/truth/start.md +142 -142
  250. package/.claude/commands/verify/check.md +49 -49
  251. package/.claude/commands/verify/start.md +127 -127
  252. package/.claude/commands/workflows/README.md +9 -9
  253. package/.claude/commands/workflows/development.md +77 -77
  254. package/.claude/commands/workflows/research.md +62 -62
  255. package/.claude/commands/workflows/workflow-create.md +25 -25
  256. package/.claude/commands/workflows/workflow-execute.md +25 -25
  257. package/.claude/commands/workflows/workflow-export.md +25 -25
  258. package/.claude/helpers/README.md +96 -96
  259. package/.claude/helpers/adr-compliance.sh +186 -186
  260. package/.claude/helpers/auto-commit.sh +178 -178
  261. package/.claude/helpers/auto-memory-hook.mjs +368 -368
  262. package/.claude/helpers/checkpoint-manager.sh +251 -251
  263. package/.claude/helpers/daemon-manager.sh +252 -252
  264. package/.claude/helpers/ddd-tracker.sh +144 -144
  265. package/.claude/helpers/github-safe.js +156 -156
  266. package/.claude/helpers/github-setup.sh +45 -45
  267. package/.claude/helpers/guidance-hook.sh +13 -13
  268. package/.claude/helpers/guidance-hooks.sh +102 -102
  269. package/.claude/helpers/health-monitor.sh +108 -108
  270. package/.claude/helpers/hook-handler.cjs +286 -286
  271. package/.claude/helpers/intelligence.cjs +1031 -1031
  272. package/.claude/helpers/learning-hooks.sh +329 -329
  273. package/.claude/helpers/learning-optimizer.sh +127 -127
  274. package/.claude/helpers/learning-service.mjs +1144 -1144
  275. package/.claude/helpers/memory.js +83 -83
  276. package/.claude/helpers/metrics-db.mjs +488 -488
  277. package/.claude/helpers/pattern-consolidator.sh +86 -86
  278. package/.claude/helpers/perf-worker.sh +160 -160
  279. package/.claude/helpers/post-commit +16 -16
  280. package/.claude/helpers/pre-commit +26 -26
  281. package/.claude/helpers/quick-start.sh +19 -19
  282. package/.claude/helpers/router.js +105 -105
  283. package/.claude/helpers/security-scanner.sh +127 -127
  284. package/.claude/helpers/session.js +157 -157
  285. package/.claude/helpers/setup-mcp.sh +18 -18
  286. package/.claude/helpers/standard-checkpoint-hooks.sh +189 -189
  287. package/.claude/helpers/statusline-hook.sh +21 -21
  288. package/.claude/helpers/statusline.cjs +604 -604
  289. package/.claude/helpers/statusline.js +352 -352
  290. package/.claude/helpers/swarm-comms.sh +353 -353
  291. package/.claude/helpers/swarm-hooks.sh +761 -761
  292. package/.claude/helpers/swarm-monitor.sh +210 -210
  293. package/.claude/helpers/sync-v3-metrics.sh +245 -245
  294. package/.claude/helpers/update-v3-progress.sh +165 -165
  295. package/.claude/helpers/v3-quick-status.sh +57 -57
  296. package/.claude/helpers/v3.sh +110 -110
  297. package/.claude/helpers/validate-v3-config.sh +215 -215
  298. package/.claude/helpers/worker-manager.sh +170 -170
  299. package/.claude/settings.json +182 -182
  300. package/.claude/skills/agentdb-advanced/SKILL.md +550 -550
  301. package/.claude/skills/agentdb-learning/SKILL.md +545 -545
  302. package/.claude/skills/agentdb-memory-patterns/SKILL.md +339 -339
  303. package/.claude/skills/agentdb-optimization/SKILL.md +509 -509
  304. package/.claude/skills/agentdb-vector-search/SKILL.md +339 -339
  305. package/.claude/skills/browser/SKILL.md +204 -204
  306. package/.claude/skills/dual-mode/README.md +71 -71
  307. package/.claude/skills/dual-mode/dual-collect.md +103 -103
  308. package/.claude/skills/dual-mode/dual-coordinate.md +85 -85
  309. package/.claude/skills/dual-mode/dual-spawn.md +81 -81
  310. package/.claude/skills/flow-nexus-neural/SKILL.md +727 -727
  311. package/.claude/skills/flow-nexus-platform/SKILL.md +1154 -1154
  312. package/.claude/skills/flow-nexus-swarm/SKILL.md +604 -604
  313. package/.claude/skills/github-code-review/SKILL.md +1125 -1125
  314. package/.claude/skills/github-multi-repo/SKILL.md +862 -862
  315. package/.claude/skills/github-project-management/SKILL.md +1262 -1262
  316. package/.claude/skills/github-release-management/SKILL.md +1064 -1064
  317. package/.claude/skills/github-workflow-automation/SKILL.md +1047 -1047
  318. package/.claude/skills/hooks-automation/SKILL.md +1201 -1201
  319. package/.claude/skills/pair-programming/SKILL.md +1202 -1202
  320. package/.claude/skills/reasoningbank-agentdb/SKILL.md +446 -446
  321. package/.claude/skills/reasoningbank-intelligence/SKILL.md +201 -201
  322. package/.claude/skills/skill-builder/SKILL.md +910 -910
  323. package/.claude/skills/sparc-methodology/SKILL.md +1106 -1106
  324. package/.claude/skills/stream-chain/SKILL.md +560 -560
  325. package/.claude/skills/swarm-advanced/SKILL.md +970 -970
  326. package/.claude/skills/swarm-orchestration/SKILL.md +179 -179
  327. package/.claude/skills/v3-cli-modernization/SKILL.md +871 -871
  328. package/.claude/skills/v3-core-implementation/SKILL.md +796 -796
  329. package/.claude/skills/v3-ddd-architecture/SKILL.md +441 -441
  330. package/.claude/skills/v3-integration-deep/SKILL.md +240 -240
  331. package/.claude/skills/v3-mcp-optimization/SKILL.md +776 -776
  332. package/.claude/skills/v3-memory-unification/SKILL.md +173 -173
  333. package/.claude/skills/v3-performance-optimization/SKILL.md +389 -389
  334. package/.claude/skills/v3-security-overhaul/SKILL.md +81 -81
  335. package/.claude/skills/v3-swarm-coordination/SKILL.md +339 -339
  336. package/.claude/skills/verification-quality/SKILL.md +691 -691
  337. package/README.md +412 -412
  338. package/bin/cli.js +314 -314
  339. package/bin/mcp-server.js +224 -224
  340. package/bin/preinstall.cjs +2 -2
  341. package/dist/src/benchmarks/gaia-critic.js +24 -24
  342. package/dist/src/commands/completions.js +409 -409
  343. package/dist/src/commands/daemon.js +44 -44
  344. package/dist/src/commands/doctor.d.ts.map +1 -1
  345. package/dist/src/commands/doctor.js +175 -1
  346. package/dist/src/commands/doctor.js.map +1 -1
  347. package/dist/src/commands/eject.d.ts +33 -0
  348. package/dist/src/commands/eject.d.ts.map +1 -0
  349. package/dist/src/commands/eject.js +195 -0
  350. package/dist/src/commands/eject.js.map +1 -0
  351. package/dist/src/commands/embeddings.js +26 -26
  352. package/dist/src/commands/hive-mind.js +97 -97
  353. package/dist/src/commands/hooks.d.ts.map +1 -1
  354. package/dist/src/commands/hooks.js +11 -10
  355. package/dist/src/commands/hooks.js.map +1 -1
  356. package/dist/src/commands/index.d.ts.map +1 -1
  357. package/dist/src/commands/index.js +4 -0
  358. package/dist/src/commands/index.js.map +1 -1
  359. package/dist/src/commands/init.d.ts.map +1 -1
  360. package/dist/src/commands/init.js +3 -0
  361. package/dist/src/commands/init.js.map +1 -1
  362. package/dist/src/commands/metaharness.d.ts +39 -0
  363. package/dist/src/commands/metaharness.d.ts.map +1 -0
  364. package/dist/src/commands/metaharness.js +194 -0
  365. package/dist/src/commands/metaharness.js.map +1 -0
  366. package/dist/src/commands/neural.d.ts.map +1 -1
  367. package/dist/src/commands/neural.js +2351 -1
  368. package/dist/src/commands/neural.js.map +1 -1
  369. package/dist/src/commands/ruvector/backup.js +23 -23
  370. package/dist/src/commands/ruvector/benchmark.js +31 -31
  371. package/dist/src/commands/ruvector/import.js +14 -14
  372. package/dist/src/commands/ruvector/init.js +115 -115
  373. package/dist/src/commands/ruvector/migrate.js +99 -99
  374. package/dist/src/commands/ruvector/optimize.js +51 -51
  375. package/dist/src/commands/ruvector/setup.js +624 -624
  376. package/dist/src/commands/ruvector/status.js +38 -38
  377. package/dist/src/init/claudemd-generator.js +231 -231
  378. package/dist/src/init/executor.js +453 -453
  379. package/dist/src/init/helpers-generator.js +727 -727
  380. package/dist/src/init/statusline-generator.js +717 -717
  381. package/dist/src/mcp-client.d.ts.map +1 -1
  382. package/dist/src/mcp-client.js +4 -0
  383. package/dist/src/mcp-client.js.map +1 -1
  384. package/dist/src/mcp-tools/agent-execute-core.d.ts +23 -1
  385. package/dist/src/mcp-tools/agent-execute-core.d.ts.map +1 -1
  386. package/dist/src/mcp-tools/agent-execute-core.js +136 -9
  387. package/dist/src/mcp-tools/agent-execute-core.js.map +1 -1
  388. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
  389. package/dist/src/mcp-tools/agent-tools.js +48 -4
  390. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  391. package/dist/src/mcp-tools/agentdb-tools.js +15 -15
  392. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  393. package/dist/src/mcp-tools/hooks-tools.js +196 -0
  394. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  395. package/dist/src/mcp-tools/index.d.ts +1 -0
  396. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  397. package/dist/src/mcp-tools/index.js +2 -0
  398. package/dist/src/mcp-tools/index.js.map +1 -1
  399. package/dist/src/mcp-tools/metaharness-tools.d.ts +31 -0
  400. package/dist/src/mcp-tools/metaharness-tools.d.ts.map +1 -0
  401. package/dist/src/mcp-tools/metaharness-tools.js +372 -0
  402. package/dist/src/mcp-tools/metaharness-tools.js.map +1 -0
  403. package/dist/src/memory/graph-edge-writer.js +18 -18
  404. package/dist/src/memory/memory-bridge.js +84 -84
  405. package/dist/src/memory/memory-initializer.js +393 -393
  406. package/dist/src/memory/rabitq-index.js +5 -5
  407. package/dist/src/plugins/store/discovery.d.ts.map +1 -1
  408. package/dist/src/plugins/store/discovery.js +3 -0
  409. package/dist/src/plugins/store/discovery.js.map +1 -1
  410. package/dist/src/plugins/store/types.d.ts +6 -1
  411. package/dist/src/plugins/store/types.d.ts.map +1 -1
  412. package/dist/src/runtime/headless.js +28 -28
  413. package/dist/src/ruvector/enhanced-model-router.d.ts +5 -0
  414. package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -1
  415. package/dist/src/ruvector/enhanced-model-router.js +18 -1
  416. package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
  417. package/dist/src/ruvector/model-prices.d.ts +50 -0
  418. package/dist/src/ruvector/model-prices.d.ts.map +1 -0
  419. package/dist/src/ruvector/model-prices.js +72 -0
  420. package/dist/src/ruvector/model-prices.js.map +1 -0
  421. package/dist/src/ruvector/model-router.d.ts +147 -8
  422. package/dist/src/ruvector/model-router.d.ts.map +1 -1
  423. package/dist/src/ruvector/model-router.js +455 -18
  424. package/dist/src/ruvector/model-router.js.map +1 -1
  425. package/dist/src/ruvector/neural-router.d.ts +172 -39
  426. package/dist/src/ruvector/neural-router.d.ts.map +1 -1
  427. package/dist/src/ruvector/neural-router.js +780 -91
  428. package/dist/src/ruvector/neural-router.js.map +1 -1
  429. package/dist/src/ruvector/router-calibrator.d.ts +65 -0
  430. package/dist/src/ruvector/router-calibrator.d.ts.map +1 -0
  431. package/dist/src/ruvector/router-calibrator.js +120 -0
  432. package/dist/src/ruvector/router-calibrator.js.map +1 -0
  433. package/dist/src/ruvector/router-parallel-recorder.d.ts +127 -0
  434. package/dist/src/ruvector/router-parallel-recorder.d.ts.map +1 -0
  435. package/dist/src/ruvector/router-parallel-recorder.js +183 -0
  436. package/dist/src/ruvector/router-parallel-recorder.js.map +1 -0
  437. package/dist/src/ruvector/router-trajectory.d.ts +137 -45
  438. package/dist/src/ruvector/router-trajectory.d.ts.map +1 -1
  439. package/dist/src/ruvector/router-trajectory.js +226 -63
  440. package/dist/src/ruvector/router-trajectory.js.map +1 -1
  441. package/dist/src/ruvector/task-embedder.d.ts +56 -0
  442. package/dist/src/ruvector/task-embedder.d.ts.map +1 -0
  443. package/dist/src/ruvector/task-embedder.js +237 -0
  444. package/dist/src/ruvector/task-embedder.js.map +1 -0
  445. package/dist/src/services/headless-worker-executor.js +84 -84
  446. package/dist/src/transfer/deploy-seraphine.js +23 -23
  447. package/dist/tsconfig.tsbuildinfo +1 -1
  448. package/package.json +138 -134
  449. package/scripts/beir-bootstrap-significance.mjs +162 -162
  450. package/scripts/bench-rvagent.mjs +312 -312
  451. package/scripts/benchmark-codemods.mjs +127 -127
  452. package/scripts/benchmark-cross-repo.mjs +206 -206
  453. package/scripts/benchmark-pretrained-retrieval.mjs +305 -305
  454. package/scripts/benchmark-self-learning.mjs +241 -241
  455. package/scripts/benchmark-trajectory-mrr.mjs +191 -191
  456. package/scripts/deploy-ipfs-node.sh +153 -153
  457. package/scripts/grid-search-retrieval.mjs +216 -216
  458. package/scripts/postinstall.cjs +153 -153
  459. package/scripts/pretrain-from-github.mjs +358 -358
  460. package/scripts/publish-registry.ts +345 -345
  461. package/scripts/publish.sh +57 -57
  462. package/scripts/run-beir-bge.mjs +324 -324
  463. package/scripts/run-beir-hybrid.mjs +261 -261
  464. package/scripts/run-beir-lucene-bm25.mjs +154 -154
  465. package/scripts/run-beir-nfcorpus.mjs +231 -231
  466. package/scripts/run-beir-rrf-ablation.mjs +221 -221
  467. package/scripts/setup-ipfs-registry.md +366 -366
  468. package/dist/src/ruvector/flash-attention.d.ts +0 -195
  469. package/dist/src/ruvector/flash-attention.d.ts.map +0 -1
  470. package/dist/src/ruvector/flash-attention.js +0 -643
  471. package/dist/src/ruvector/flash-attention.js.map +0 -1
  472. package/dist/src/ruvector/moe-router.d.ts +0 -206
  473. package/dist/src/ruvector/moe-router.d.ts.map +0 -1
  474. package/dist/src/ruvector/moe-router.js +0 -626
  475. package/dist/src/ruvector/moe-router.js.map +0 -1
  476. package/dist/src/services/event-stream.d.ts +0 -25
  477. package/dist/src/services/event-stream.js +0 -27
  478. package/dist/src/services/loop-worker-runner.d.ts +0 -16
  479. package/dist/src/services/loop-worker-runner.js +0 -34
  480. package/dist/src/services/runtime-capabilities.d.ts +0 -22
  481. package/dist/src/services/runtime-capabilities.js +0 -45
@@ -1,604 +1,604 @@
1
- #!/usr/bin/env node
2
- /**
3
- * RuFlo V3.5 Statusline Generator
4
- * Displays real-time V3 implementation progress and system status
5
- *
6
- * Usage: node statusline.cjs [options]
7
- *
8
- * Options:
9
- * (default) Safe multi-line output with collision zone avoidance
10
- * --single Single-line output (completely avoids collision)
11
- * --unsafe Legacy multi-line without collision avoidance
12
- * --legacy Alias for --unsafe
13
- * --json JSON output with pretty printing
14
- * --compact JSON output without formatting
15
- *
16
- * Collision Zone Fix (Issue #985):
17
- * Claude Code writes its internal status (e.g., "7s • 1p") at absolute
18
- * terminal coordinates (columns 15-25 on second-to-last line). The safe
19
- * mode pads the collision line with spaces to push content past column 25.
20
- *
21
- * IMPORTANT: This file uses .cjs extension to work in ES module projects.
22
- * The require() syntax is intentional for CommonJS compatibility.
23
- */
24
-
25
- /* eslint-disable @typescript-eslint/no-var-requires */
26
- const fs = require('fs');
27
- const path = require('path');
28
- const os = require('os');
29
- const { execSync, execFileSync } = require('child_process');
30
-
31
- // Read the installed plugin version once at startup. Probe the plugin's own
32
- // install location first (`~/.claude/plugins/marketplaces/ruflo/package.json`),
33
- // then npm-style installs, then the source-checkout location. The previous
34
- // code hardcoded `RuFlo V3.5` in the header — so users on alpha.27+ still
35
- // saw V3.5 in the statusline even though `ruflo doctor` reported the real
36
- // version (#1951).
37
- let RUFLO_VERSION = '3.6';
38
- try {
39
- const home = os.homedir();
40
- const cwd = process.cwd();
41
- const pkgPaths = [
42
- path.join(home, '.claude', 'plugins', 'marketplaces', 'ruflo', 'package.json'),
43
- path.join(cwd, 'node_modules', '@claude-flow', 'cli', 'package.json'),
44
- path.join(cwd, 'node_modules', 'ruflo', 'package.json'),
45
- path.join(cwd, 'v3', '@claude-flow', 'cli', 'package.json'),
46
- ];
47
- for (const p of pkgPaths) {
48
- if (!fs.existsSync(p)) continue;
49
- try {
50
- const pkg = JSON.parse(fs.readFileSync(p, 'utf-8'));
51
- if (pkg && typeof pkg.version === 'string' && pkg.version.length > 0) {
52
- RUFLO_VERSION = pkg.version;
53
- break;
54
- }
55
- } catch { /* malformed package.json — try next */ }
56
- }
57
- } catch { /* fall through to the hardcoded default */ }
58
-
59
- // Configuration
60
- const CONFIG = {
61
- enabled: true,
62
- showProgress: true,
63
- showSecurity: true,
64
- showSwarm: true,
65
- showHooks: true,
66
- showPerformance: true,
67
- refreshInterval: 5000,
68
- maxAgents: 15,
69
- topology: 'hierarchical-mesh',
70
- };
71
-
72
- // Cross-platform helpers
73
- const isWindows = process.platform === 'win32';
74
- const nullDevice = isWindows ? 'NUL' : '/dev/null';
75
-
76
- // ANSI colors
77
- const c = {
78
- reset: '\x1b[0m',
79
- bold: '\x1b[1m',
80
- dim: '\x1b[2m',
81
- red: '\x1b[0;31m',
82
- green: '\x1b[0;32m',
83
- yellow: '\x1b[0;33m',
84
- blue: '\x1b[0;34m',
85
- purple: '\x1b[0;35m',
86
- cyan: '\x1b[0;36m',
87
- brightRed: '\x1b[1;31m',
88
- brightGreen: '\x1b[1;32m',
89
- brightYellow: '\x1b[1;33m',
90
- brightBlue: '\x1b[1;34m',
91
- brightPurple: '\x1b[1;35m',
92
- brightCyan: '\x1b[1;36m',
93
- brightWhite: '\x1b[1;37m',
94
- };
95
-
96
- // Get user info
97
- function getUserInfo() {
98
- let name = 'user';
99
- let gitBranch = '';
100
- let modelName = 'Unknown';
101
-
102
- // audit_1776853149979: previously used execSync with a shell string. Switched
103
- // to execFileSync('git', argv) on both platforms so there is no shell
104
- // interpretation. Cross-platform behavior is preserved by relying on git's
105
- // own exit code instead of `|| echo` fallbacks: missing repo / no user.name
106
- // throws, caught below, defaults retained.
107
- try {
108
- name = execFileSync('git', ['config', 'user.name'], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || 'user';
109
- } catch { /* keep default */ }
110
- try {
111
- gitBranch = execFileSync('git', ['branch', '--show-current'], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
112
- } catch { /* keep empty */ }
113
-
114
- // Auto-detect model from Claude Code's config
115
- try {
116
- const homedir = require('os').homedir();
117
- const claudeConfigPath = path.join(homedir, '.claude.json');
118
- if (fs.existsSync(claudeConfigPath)) {
119
- const claudeConfig = JSON.parse(fs.readFileSync(claudeConfigPath, 'utf-8'));
120
- // Try to find lastModelUsage - check current dir and parent dirs
121
- let lastModelUsage = null;
122
- const cwd = process.cwd();
123
- if (claudeConfig.projects) {
124
- // Try exact match first, then check if cwd starts with any project path
125
- for (const [projectPath, projectConfig] of Object.entries(claudeConfig.projects)) {
126
- if (cwd === projectPath || cwd.startsWith(projectPath + '/')) {
127
- lastModelUsage = projectConfig.lastModelUsage;
128
- break;
129
- }
130
- }
131
- }
132
- if (lastModelUsage) {
133
- const modelIds = Object.keys(lastModelUsage);
134
- if (modelIds.length > 0) {
135
- // Take the last model (most recently added to the object)
136
- // Or find the one with most tokens (most actively used this session)
137
- let modelId = modelIds[modelIds.length - 1];
138
- if (modelIds.length > 1) {
139
- // If multiple models, pick the one with most total tokens
140
- let maxTokens = 0;
141
- for (const id of modelIds) {
142
- const usage = lastModelUsage[id];
143
- const total = (usage.inputTokens || 0) + (usage.outputTokens || 0);
144
- if (total > maxTokens) {
145
- maxTokens = total;
146
- modelId = id;
147
- }
148
- }
149
- }
150
- // Parse model ID to human-readable name
151
- if (modelId.includes('opus')) modelName = 'Opus 4.6 (1M context)';
152
- else if (modelId.includes('sonnet')) modelName = 'Sonnet 4.6';
153
- else if (modelId.includes('haiku')) modelName = 'Haiku 4.5';
154
- else modelName = modelId.split('-').slice(1, 3).join(' ');
155
- }
156
- }
157
- }
158
- } catch (e) {
159
- // Fallback to Unknown if can't read config
160
- }
161
-
162
- return { name, gitBranch, modelName };
163
- }
164
-
165
- // Get learning stats from intelligence loop data (ADR-050)
166
- function getLearningStats() {
167
- let patterns = 0;
168
- let sessions = 0;
169
- let trajectories = 0;
170
- let edges = 0;
171
- let confidenceMean = 0;
172
- let accessedCount = 0;
173
- let trend = 'STABLE';
174
-
175
- // PRIMARY: Read from intelligence loop data files
176
- const dataDir = path.join(process.cwd(), '.claude-flow', 'data');
177
-
178
- // 1. graph-state.json — authoritative node/edge counts
179
- const graphPath = path.join(dataDir, 'graph-state.json');
180
- if (fs.existsSync(graphPath)) {
181
- try {
182
- const graph = JSON.parse(fs.readFileSync(graphPath, 'utf-8'));
183
- patterns = graph.nodes ? Object.keys(graph.nodes).length : 0;
184
- edges = Array.isArray(graph.edges) ? graph.edges.length : 0;
185
- } catch (e) { /* ignore */ }
186
- }
187
-
188
- // 2. ranked-context.json — confidence and access data
189
- const rankedPath = path.join(dataDir, 'ranked-context.json');
190
- if (fs.existsSync(rankedPath)) {
191
- try {
192
- const ranked = JSON.parse(fs.readFileSync(rankedPath, 'utf-8'));
193
- if (ranked.entries && ranked.entries.length > 0) {
194
- patterns = Math.max(patterns, ranked.entries.length);
195
- let confSum = 0;
196
- let accCount = 0;
197
- for (let i = 0; i < ranked.entries.length; i++) {
198
- confSum += (ranked.entries[i].confidence || 0);
199
- if ((ranked.entries[i].accessCount || 0) > 0) accCount++;
200
- }
201
- confidenceMean = confSum / ranked.entries.length;
202
- accessedCount = accCount;
203
- }
204
- } catch (e) { /* ignore */ }
205
- }
206
-
207
- // 3. intelligence-snapshot.json — trend history
208
- const snapshotPath = path.join(dataDir, 'intelligence-snapshot.json');
209
- if (fs.existsSync(snapshotPath)) {
210
- try {
211
- const snapshot = JSON.parse(fs.readFileSync(snapshotPath, 'utf-8'));
212
- if (snapshot.history && snapshot.history.length >= 2) {
213
- const first = snapshot.history[0];
214
- const last = snapshot.history[snapshot.history.length - 1];
215
- const confDrift = (last.confidenceMean || 0) - (first.confidenceMean || 0);
216
- trend = confDrift > 0.01 ? 'IMPROVING' : confDrift < -0.01 ? 'DECLINING' : 'STABLE';
217
- sessions = Math.max(sessions, snapshot.history.length);
218
- }
219
- } catch (e) { /* ignore */ }
220
- }
221
-
222
- // 4. auto-memory-store.json — fallback entry count
223
- if (patterns === 0) {
224
- const autoMemPath = path.join(dataDir, 'auto-memory-store.json');
225
- if (fs.existsSync(autoMemPath)) {
226
- try {
227
- const data = JSON.parse(fs.readFileSync(autoMemPath, 'utf-8'));
228
- patterns = Array.isArray(data) ? data.length : (data.entries ? data.entries.length : 0);
229
- } catch (e) { /* ignore */ }
230
- }
231
- }
232
-
233
- // FALLBACK: Legacy memory.db file-size estimation
234
- if (patterns === 0) {
235
- const memoryPaths = [
236
- path.join(process.cwd(), '.swarm', 'memory.db'),
237
- path.join(process.cwd(), '.claude', 'memory.db'),
238
- path.join(process.cwd(), 'data', 'memory.db'),
239
- ];
240
- for (let j = 0; j < memoryPaths.length; j++) {
241
- if (fs.existsSync(memoryPaths[j])) {
242
- try {
243
- const dbStats = fs.statSync(memoryPaths[j]);
244
- patterns = Math.floor(dbStats.size / 1024 / 2);
245
- break;
246
- } catch (e) { /* ignore */ }
247
- }
248
- }
249
- }
250
-
251
- // Session count from session files
252
- const sessionsPath = path.join(process.cwd(), '.claude', 'sessions');
253
- if (fs.existsSync(sessionsPath)) {
254
- try {
255
- const sessionFiles = fs.readdirSync(sessionsPath).filter(f => f.endsWith('.json'));
256
- sessions = Math.max(sessions, sessionFiles.length);
257
- } catch (e) { /* ignore */ }
258
- }
259
-
260
- trajectories = Math.floor(patterns / 5);
261
-
262
- return { patterns, sessions, trajectories, edges, confidenceMean, accessedCount, trend };
263
- }
264
-
265
- // Get V3 progress from learning state (grows as system learns)
266
- function getV3Progress() {
267
- const learning = getLearningStats();
268
-
269
- // DDD progress based on actual learned patterns
270
- // New install: 0 patterns = 0/5 domains, 0% DDD
271
- // As patterns grow: 10+ patterns = 1 domain, 50+ = 2, 100+ = 3, 200+ = 4, 500+ = 5
272
- let domainsCompleted = 0;
273
- if (learning.patterns >= 500) domainsCompleted = 5;
274
- else if (learning.patterns >= 200) domainsCompleted = 4;
275
- else if (learning.patterns >= 100) domainsCompleted = 3;
276
- else if (learning.patterns >= 50) domainsCompleted = 2;
277
- else if (learning.patterns >= 10) domainsCompleted = 1;
278
-
279
- const totalDomains = 5;
280
- const dddProgress = Math.min(100, Math.floor((domainsCompleted / totalDomains) * 100));
281
-
282
- return {
283
- domainsCompleted,
284
- totalDomains,
285
- dddProgress,
286
- patternsLearned: learning.patterns,
287
- sessionsCompleted: learning.sessions
288
- };
289
- }
290
-
291
- // Get security status based on actual scans
292
- function getSecurityStatus() {
293
- // Check for security scan results in memory
294
- const scanResultsPath = path.join(process.cwd(), '.claude', 'security-scans');
295
- let cvesFixed = 0;
296
- const totalCves = 3;
297
-
298
- if (fs.existsSync(scanResultsPath)) {
299
- try {
300
- const scans = fs.readdirSync(scanResultsPath).filter(f => f.endsWith('.json'));
301
- // Each successful scan file = 1 CVE addressed
302
- cvesFixed = Math.min(totalCves, scans.length);
303
- } catch (e) {
304
- // Ignore
305
- }
306
- }
307
-
308
- // Also check .swarm/security for audit results
309
- const auditPath = path.join(process.cwd(), '.swarm', 'security');
310
- if (fs.existsSync(auditPath)) {
311
- try {
312
- const audits = fs.readdirSync(auditPath).filter(f => f.includes('audit'));
313
- cvesFixed = Math.min(totalCves, Math.max(cvesFixed, audits.length));
314
- } catch (e) {
315
- // Ignore
316
- }
317
- }
318
-
319
- const status = cvesFixed >= totalCves ? 'CLEAN' : cvesFixed > 0 ? 'IN_PROGRESS' : 'PENDING';
320
-
321
- return {
322
- status,
323
- cvesFixed,
324
- totalCves,
325
- };
326
- }
327
-
328
- // Get swarm status
329
- function getSwarmStatus() {
330
- let activeAgents = 0;
331
- let coordinationActive = false;
332
-
333
- try {
334
- if (isWindows) {
335
- // Windows: use tasklist and findstr
336
- const ps = execSync('tasklist 2>NUL | findstr /I "agentic-flow" 2>NUL | find /C /V "" 2>NUL || echo 0', { encoding: 'utf-8' });
337
- activeAgents = Math.max(0, parseInt(ps.trim()) || 0);
338
- } else {
339
- const ps = execSync('ps aux 2>/dev/null | grep -c agentic-flow || echo "0"', { encoding: 'utf-8' });
340
- activeAgents = Math.max(0, parseInt(ps.trim()) - 1);
341
- }
342
- coordinationActive = activeAgents > 0;
343
- } catch (e) {
344
- // Ignore errors - default to 0 agents
345
- }
346
-
347
- return {
348
- activeAgents,
349
- maxAgents: CONFIG.maxAgents,
350
- coordinationActive,
351
- };
352
- }
353
-
354
- // Get system metrics (dynamic based on actual state)
355
- function getSystemMetrics() {
356
- let memoryMB = 0;
357
- let subAgents = 0;
358
-
359
- try {
360
- if (isWindows) {
361
- // Windows: use tasklist for memory info, fallback to process.memoryUsage
362
- // tasklist memory column is complex to parse, use Node.js API instead
363
- memoryMB = Math.floor(process.memoryUsage().heapUsed / 1024 / 1024);
364
- } else {
365
- const mem = execSync('ps aux | grep -E "(node|agentic|claude)" | grep -v grep | awk \'{sum += $6} END {print int(sum/1024)}\'', { encoding: 'utf-8' });
366
- memoryMB = parseInt(mem.trim()) || 0;
367
- }
368
- } catch (e) {
369
- // Fallback
370
- memoryMB = Math.floor(process.memoryUsage().heapUsed / 1024 / 1024);
371
- }
372
-
373
- // Get learning stats for intelligence %
374
- const learning = getLearningStats();
375
-
376
- // Intelligence % from REAL intelligence loop data (ADR-050)
377
- // Composite: 40% confidence mean + 30% access ratio + 30% pattern density
378
- let intelligencePct = 0;
379
- if (learning.confidenceMean > 0 || (learning.patterns > 0 && learning.accessedCount > 0)) {
380
- const confScore = Math.min(100, Math.floor(learning.confidenceMean * 100));
381
- const accessRatio = learning.patterns > 0 ? (learning.accessedCount / learning.patterns) : 0;
382
- const accessScore = Math.min(100, Math.floor(accessRatio * 100));
383
- const densityScore = Math.min(100, Math.floor(learning.patterns / 5));
384
- intelligencePct = Math.floor(confScore * 0.4 + accessScore * 0.3 + densityScore * 0.3);
385
- }
386
- // Fallback: legacy pattern count
387
- if (intelligencePct === 0 && learning.patterns > 0) {
388
- intelligencePct = Math.min(100, Math.floor(learning.patterns / 10));
389
- }
390
-
391
- // Context % based on session history
392
- const contextPct = Math.min(100, Math.floor(learning.sessions * 5));
393
-
394
- // Count active sub-agents from process list
395
- try {
396
- if (isWindows) {
397
- // Windows: use tasklist and findstr for agent counting
398
- const agents = execSync('tasklist 2>NUL | findstr /I "claude-flow" 2>NUL | find /C /V "" 2>NUL || echo 0', { encoding: 'utf-8' });
399
- subAgents = Math.max(0, parseInt(agents.trim()) || 0);
400
- } else {
401
- const agents = execSync('ps aux 2>/dev/null | grep -c "claude-flow.*agent" || echo "0"', { encoding: 'utf-8' });
402
- subAgents = Math.max(0, parseInt(agents.trim()) - 1);
403
- }
404
- } catch (e) {
405
- // Ignore - default to 0
406
- }
407
-
408
- return {
409
- memoryMB,
410
- contextPct,
411
- intelligencePct,
412
- subAgents,
413
- };
414
- }
415
-
416
- // Generate progress bar
417
- function progressBar(current, total) {
418
- const width = 5;
419
- const filled = Math.round((current / total) * width);
420
- const empty = width - filled;
421
- return '[' + '\u25CF'.repeat(filled) + '\u25CB'.repeat(empty) + ']';
422
- }
423
-
424
- // Generate full statusline
425
- function generateStatusline() {
426
- const user = getUserInfo();
427
- const progress = getV3Progress();
428
- const security = getSecurityStatus();
429
- const swarm = getSwarmStatus();
430
- const system = getSystemMetrics();
431
- const lines = [];
432
-
433
- // Header Line
434
- let header = `${c.bold}${c.brightPurple}▊ RuFlo V${RUFLO_VERSION} ${c.reset}`;
435
- header += `${swarm.coordinationActive ? c.brightCyan : c.dim}● ${c.brightCyan}${user.name}${c.reset}`;
436
- if (user.gitBranch) {
437
- header += ` ${c.dim}│${c.reset} ${c.brightBlue}⎇ ${user.gitBranch}${c.reset}`;
438
- }
439
- header += ` ${c.dim}│${c.reset} ${c.purple}${user.modelName}${c.reset}`;
440
- lines.push(header);
441
-
442
- // Separator
443
- lines.push(`${c.dim}─────────────────────────────────────────────────────${c.reset}`);
444
-
445
- // Line 1: DDD Domain Progress
446
- const domainsColor = progress.domainsCompleted >= 3 ? c.brightGreen : progress.domainsCompleted > 0 ? c.yellow : c.red;
447
- lines.push(
448
- `${c.brightCyan}🏗️ DDD Domains${c.reset} ${progressBar(progress.domainsCompleted, progress.totalDomains)} ` +
449
- `${domainsColor}${progress.domainsCompleted}${c.reset}/${c.brightWhite}${progress.totalDomains}${c.reset} ` +
450
- `${c.brightYellow}⚡ 1.0x${c.reset} ${c.dim}→${c.reset} ${c.brightYellow}2.49x-7.47x${c.reset}`
451
- );
452
-
453
- // Line 2: Swarm + CVE + Memory + Context + Intelligence
454
- const swarmIndicator = swarm.coordinationActive ? `${c.brightGreen}◉${c.reset}` : `${c.dim}○${c.reset}`;
455
- const agentsColor = swarm.activeAgents > 0 ? c.brightGreen : c.red;
456
- let securityIcon = security.status === 'CLEAN' ? '🟢' : security.status === 'IN_PROGRESS' ? '🟡' : '🔴';
457
- let securityColor = security.status === 'CLEAN' ? c.brightGreen : security.status === 'IN_PROGRESS' ? c.brightYellow : c.brightRed;
458
-
459
- lines.push(
460
- `${c.brightYellow}🤖 Swarm${c.reset} ${swarmIndicator} [${agentsColor}${String(swarm.activeAgents).padStart(2)}${c.reset}/${c.brightWhite}${swarm.maxAgents}${c.reset}] ` +
461
- `${c.brightPurple}👥 ${system.subAgents}${c.reset} ` +
462
- `${securityIcon} ${securityColor}CVE ${security.cvesFixed}${c.reset}/${c.brightWhite}${security.totalCves}${c.reset} ` +
463
- `${c.brightCyan}💾 ${system.memoryMB}MB${c.reset} ` +
464
- `${c.brightGreen}📂 ${String(system.contextPct).padStart(3)}%${c.reset} ` +
465
- `${c.dim}🧠 ${String(system.intelligencePct).padStart(3)}%${c.reset}`
466
- );
467
-
468
- // Line 3: Architecture status
469
- const dddColor = progress.dddProgress >= 50 ? c.brightGreen : progress.dddProgress > 0 ? c.yellow : c.red;
470
- lines.push(
471
- `${c.brightPurple}🔧 Architecture${c.reset} ` +
472
- `${c.cyan}DDD${c.reset} ${dddColor}●${String(progress.dddProgress).padStart(3)}%${c.reset} ${c.dim}│${c.reset} ` +
473
- `${c.cyan}Security${c.reset} ${securityColor}●${security.status}${c.reset} ${c.dim}│${c.reset} ` +
474
- `${c.cyan}Memory${c.reset} ${c.brightGreen}●AgentDB${c.reset} ${c.dim}│${c.reset} ` +
475
- `${c.cyan}Integration${c.reset} ${swarm.coordinationActive ? c.brightCyan : c.dim}●${c.reset}`
476
- );
477
-
478
- return lines.join('\n');
479
- }
480
-
481
- // Generate JSON data
482
- function generateJSON() {
483
- return {
484
- user: getUserInfo(),
485
- v3Progress: getV3Progress(),
486
- security: getSecurityStatus(),
487
- swarm: getSwarmStatus(),
488
- system: getSystemMetrics(),
489
- performance: {
490
- flashAttentionTarget: '2.49x-7.47x',
491
- searchImprovement: '150x-12,500x',
492
- memoryReduction: '50-75%',
493
- },
494
- lastUpdated: new Date().toISOString(),
495
- };
496
- }
497
-
498
- /**
499
- * Generate single-line output for Claude Code compatibility
500
- * This avoids the collision zone issue entirely by using one line
501
- * @see https://github.com/ruvnet/claude-flow/issues/985
502
- */
503
- function generateSingleLine() {
504
- if (!CONFIG.enabled) return '';
505
-
506
- const user = getUserInfo();
507
- const progress = getV3Progress();
508
- const security = getSecurityStatus();
509
- const swarm = getSwarmStatus();
510
- const system = getSystemMetrics();
511
-
512
- const swarmIndicator = swarm.coordinationActive ? '●' : '○';
513
- const securityStatus = security.status === 'CLEAN' ? '✓' :
514
- security.cvesFixed > 0 ? '~' : '✗';
515
-
516
- return `${c.brightPurple}RuFlo${c.reset} ${c.dim}|${c.reset} ` +
517
- `${c.cyan}D:${progress.domainsCompleted}/${progress.totalDomains}${c.reset} ${c.dim}|${c.reset} ` +
518
- `${c.yellow}S:${swarmIndicator}${swarm.activeAgents}/${swarm.maxAgents}${c.reset} ${c.dim}|${c.reset} ` +
519
- `${security.status === 'CLEAN' ? c.green : c.red}CVE:${securityStatus}${security.cvesFixed}/${security.totalCves}${c.reset} ${c.dim}|${c.reset} ` +
520
- `${c.dim}🧠${system.intelligencePct}%${c.reset}`;
521
- }
522
-
523
- /**
524
- * Generate safe multi-line statusline that avoids Claude Code collision zone
525
- * The collision zone is columns 15-25 on the second-to-last line.
526
- * We pad that line with spaces to push content past column 25.
527
- * @see https://github.com/ruvnet/claude-flow/issues/985
528
- */
529
- function generateSafeStatusline() {
530
- if (!CONFIG.enabled) return '';
531
-
532
- const user = getUserInfo();
533
- const progress = getV3Progress();
534
- const security = getSecurityStatus();
535
- const swarm = getSwarmStatus();
536
- const system = getSystemMetrics();
537
- const lines = [];
538
-
539
- // Header Line
540
- let header = `${c.bold}${c.brightPurple}▊ RuFlo V${RUFLO_VERSION} ${c.reset}`;
541
- header += `${swarm.coordinationActive ? c.brightCyan : c.dim}● ${c.brightCyan}${user.name}${c.reset}`;
542
- if (user.gitBranch) {
543
- header += ` ${c.dim}│${c.reset} ${c.brightBlue}⎇ ${user.gitBranch}${c.reset}`;
544
- }
545
- header += ` ${c.dim}│${c.reset} ${c.purple}${user.modelName}${c.reset}`;
546
- lines.push(header);
547
-
548
- // Separator
549
- lines.push(`${c.dim}─────────────────────────────────────────────────────${c.reset}`);
550
-
551
- // Line 1: DDD Domain Progress
552
- const domainsColor = progress.domainsCompleted >= 3 ? c.brightGreen : progress.domainsCompleted > 0 ? c.yellow : c.red;
553
- lines.push(
554
- `${c.brightCyan}🏗️ DDD Domains${c.reset} ${progressBar(progress.domainsCompleted, progress.totalDomains)} ` +
555
- `${domainsColor}${progress.domainsCompleted}${c.reset}/${c.brightWhite}${progress.totalDomains}${c.reset} ` +
556
- `${c.brightYellow}⚡ 1.0x${c.reset} ${c.dim}→${c.reset} ${c.brightYellow}2.49x-7.47x${c.reset}`
557
- );
558
-
559
- // Line 2 (COLLISION LINE): Swarm status with padding after label
560
- // The emoji+label is ~10 columns. Padding pushes content past collision zone (cols 15-25)
561
- const swarmIndicator = swarm.coordinationActive ? `${c.brightGreen}◉${c.reset}` : `${c.dim}○${c.reset}`;
562
- const agentsColor = swarm.activeAgents > 0 ? c.brightGreen : c.red;
563
- let securityIcon = security.status === 'CLEAN' ? '🟢' : security.status === 'IN_PROGRESS' ? '🟡' : '🔴';
564
- let securityColor = security.status === 'CLEAN' ? c.brightGreen : security.status === 'IN_PROGRESS' ? c.brightYellow : c.brightRed;
565
-
566
- // Padding after "🤖 Swarm" (emoji 2 cols + " Swarm" 6 cols = 8, pad 18 to reach col 26)
567
- lines.push(
568
- `${c.brightYellow}🤖 Swarm${c.reset} ` + // 18 spaces padding
569
- `${swarmIndicator} [${agentsColor}${String(swarm.activeAgents).padStart(2)}${c.reset}/${c.brightWhite}${swarm.maxAgents}${c.reset}] ` +
570
- `${c.brightPurple}👥 ${system.subAgents}${c.reset} ` +
571
- `${securityIcon} ${securityColor}CVE ${security.cvesFixed}${c.reset}/${c.brightWhite}${security.totalCves}${c.reset} ` +
572
- `${c.brightCyan}💾 ${system.memoryMB}MB${c.reset} ` +
573
- `${c.dim}🧠 ${system.intelligencePct}%${c.reset}`
574
- );
575
-
576
- // Line 3: Architecture status (this is the last line, not in collision zone)
577
- const dddColor = progress.dddProgress >= 50 ? c.brightGreen : progress.dddProgress > 0 ? c.yellow : c.red;
578
- lines.push(
579
- `${c.brightPurple}🔧 Architecture${c.reset} ` +
580
- `${c.cyan}DDD${c.reset} ${dddColor}●${String(progress.dddProgress).padStart(3)}%${c.reset} ${c.dim}│${c.reset} ` +
581
- `${c.cyan}Security${c.reset} ${securityColor}●${security.status}${c.reset} ${c.dim}│${c.reset} ` +
582
- `${c.cyan}Memory${c.reset} ${c.brightGreen}●AgentDB${c.reset} ${c.dim}│${c.reset} ` +
583
- `${c.cyan}Integration${c.reset} ${swarm.coordinationActive ? c.brightCyan : c.dim}●${c.reset}`
584
- );
585
-
586
- return lines.join('\n');
587
- }
588
-
589
- // Main
590
- if (process.argv.includes('--json')) {
591
- console.log(JSON.stringify(generateJSON(), null, 2));
592
- } else if (process.argv.includes('--compact')) {
593
- console.log(JSON.stringify(generateJSON()));
594
- } else if (process.argv.includes('--single')) {
595
- // Single-line mode - completely avoids collision zone
596
- console.log(generateSingleLine());
597
- } else if (process.argv.includes('--unsafe') || process.argv.includes('--legacy')) {
598
- // Legacy mode - original multi-line without collision avoidance
599
- console.log(generateStatusline());
600
- } else {
601
- // Default: Safe multi-line mode with collision zone avoidance
602
- // Use --unsafe or --legacy to get the original behavior
603
- console.log(generateSafeStatusline());
604
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * RuFlo V3.5 Statusline Generator
4
+ * Displays real-time V3 implementation progress and system status
5
+ *
6
+ * Usage: node statusline.cjs [options]
7
+ *
8
+ * Options:
9
+ * (default) Safe multi-line output with collision zone avoidance
10
+ * --single Single-line output (completely avoids collision)
11
+ * --unsafe Legacy multi-line without collision avoidance
12
+ * --legacy Alias for --unsafe
13
+ * --json JSON output with pretty printing
14
+ * --compact JSON output without formatting
15
+ *
16
+ * Collision Zone Fix (Issue #985):
17
+ * Claude Code writes its internal status (e.g., "7s • 1p") at absolute
18
+ * terminal coordinates (columns 15-25 on second-to-last line). The safe
19
+ * mode pads the collision line with spaces to push content past column 25.
20
+ *
21
+ * IMPORTANT: This file uses .cjs extension to work in ES module projects.
22
+ * The require() syntax is intentional for CommonJS compatibility.
23
+ */
24
+
25
+ /* eslint-disable @typescript-eslint/no-var-requires */
26
+ const fs = require('fs');
27
+ const path = require('path');
28
+ const os = require('os');
29
+ const { execSync, execFileSync } = require('child_process');
30
+
31
+ // Read the installed plugin version once at startup. Probe the plugin's own
32
+ // install location first (`~/.claude/plugins/marketplaces/ruflo/package.json`),
33
+ // then npm-style installs, then the source-checkout location. The previous
34
+ // code hardcoded `RuFlo V3.5` in the header — so users on alpha.27+ still
35
+ // saw V3.5 in the statusline even though `ruflo doctor` reported the real
36
+ // version (#1951).
37
+ let RUFLO_VERSION = '3.6';
38
+ try {
39
+ const home = os.homedir();
40
+ const cwd = process.cwd();
41
+ const pkgPaths = [
42
+ path.join(home, '.claude', 'plugins', 'marketplaces', 'ruflo', 'package.json'),
43
+ path.join(cwd, 'node_modules', '@claude-flow', 'cli', 'package.json'),
44
+ path.join(cwd, 'node_modules', 'ruflo', 'package.json'),
45
+ path.join(cwd, 'v3', '@claude-flow', 'cli', 'package.json'),
46
+ ];
47
+ for (const p of pkgPaths) {
48
+ if (!fs.existsSync(p)) continue;
49
+ try {
50
+ const pkg = JSON.parse(fs.readFileSync(p, 'utf-8'));
51
+ if (pkg && typeof pkg.version === 'string' && pkg.version.length > 0) {
52
+ RUFLO_VERSION = pkg.version;
53
+ break;
54
+ }
55
+ } catch { /* malformed package.json — try next */ }
56
+ }
57
+ } catch { /* fall through to the hardcoded default */ }
58
+
59
+ // Configuration
60
+ const CONFIG = {
61
+ enabled: true,
62
+ showProgress: true,
63
+ showSecurity: true,
64
+ showSwarm: true,
65
+ showHooks: true,
66
+ showPerformance: true,
67
+ refreshInterval: 5000,
68
+ maxAgents: 15,
69
+ topology: 'hierarchical-mesh',
70
+ };
71
+
72
+ // Cross-platform helpers
73
+ const isWindows = process.platform === 'win32';
74
+ const nullDevice = isWindows ? 'NUL' : '/dev/null';
75
+
76
+ // ANSI colors
77
+ const c = {
78
+ reset: '\x1b[0m',
79
+ bold: '\x1b[1m',
80
+ dim: '\x1b[2m',
81
+ red: '\x1b[0;31m',
82
+ green: '\x1b[0;32m',
83
+ yellow: '\x1b[0;33m',
84
+ blue: '\x1b[0;34m',
85
+ purple: '\x1b[0;35m',
86
+ cyan: '\x1b[0;36m',
87
+ brightRed: '\x1b[1;31m',
88
+ brightGreen: '\x1b[1;32m',
89
+ brightYellow: '\x1b[1;33m',
90
+ brightBlue: '\x1b[1;34m',
91
+ brightPurple: '\x1b[1;35m',
92
+ brightCyan: '\x1b[1;36m',
93
+ brightWhite: '\x1b[1;37m',
94
+ };
95
+
96
+ // Get user info
97
+ function getUserInfo() {
98
+ let name = 'user';
99
+ let gitBranch = '';
100
+ let modelName = 'Unknown';
101
+
102
+ // audit_1776853149979: previously used execSync with a shell string. Switched
103
+ // to execFileSync('git', argv) on both platforms so there is no shell
104
+ // interpretation. Cross-platform behavior is preserved by relying on git's
105
+ // own exit code instead of `|| echo` fallbacks: missing repo / no user.name
106
+ // throws, caught below, defaults retained.
107
+ try {
108
+ name = execFileSync('git', ['config', 'user.name'], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || 'user';
109
+ } catch { /* keep default */ }
110
+ try {
111
+ gitBranch = execFileSync('git', ['branch', '--show-current'], { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
112
+ } catch { /* keep empty */ }
113
+
114
+ // Auto-detect model from Claude Code's config
115
+ try {
116
+ const homedir = require('os').homedir();
117
+ const claudeConfigPath = path.join(homedir, '.claude.json');
118
+ if (fs.existsSync(claudeConfigPath)) {
119
+ const claudeConfig = JSON.parse(fs.readFileSync(claudeConfigPath, 'utf-8'));
120
+ // Try to find lastModelUsage - check current dir and parent dirs
121
+ let lastModelUsage = null;
122
+ const cwd = process.cwd();
123
+ if (claudeConfig.projects) {
124
+ // Try exact match first, then check if cwd starts with any project path
125
+ for (const [projectPath, projectConfig] of Object.entries(claudeConfig.projects)) {
126
+ if (cwd === projectPath || cwd.startsWith(projectPath + '/')) {
127
+ lastModelUsage = projectConfig.lastModelUsage;
128
+ break;
129
+ }
130
+ }
131
+ }
132
+ if (lastModelUsage) {
133
+ const modelIds = Object.keys(lastModelUsage);
134
+ if (modelIds.length > 0) {
135
+ // Take the last model (most recently added to the object)
136
+ // Or find the one with most tokens (most actively used this session)
137
+ let modelId = modelIds[modelIds.length - 1];
138
+ if (modelIds.length > 1) {
139
+ // If multiple models, pick the one with most total tokens
140
+ let maxTokens = 0;
141
+ for (const id of modelIds) {
142
+ const usage = lastModelUsage[id];
143
+ const total = (usage.inputTokens || 0) + (usage.outputTokens || 0);
144
+ if (total > maxTokens) {
145
+ maxTokens = total;
146
+ modelId = id;
147
+ }
148
+ }
149
+ }
150
+ // Parse model ID to human-readable name
151
+ if (modelId.includes('opus')) modelName = 'Opus 4.6 (1M context)';
152
+ else if (modelId.includes('sonnet')) modelName = 'Sonnet 4.6';
153
+ else if (modelId.includes('haiku')) modelName = 'Haiku 4.5';
154
+ else modelName = modelId.split('-').slice(1, 3).join(' ');
155
+ }
156
+ }
157
+ }
158
+ } catch (e) {
159
+ // Fallback to Unknown if can't read config
160
+ }
161
+
162
+ return { name, gitBranch, modelName };
163
+ }
164
+
165
+ // Get learning stats from intelligence loop data (ADR-050)
166
+ function getLearningStats() {
167
+ let patterns = 0;
168
+ let sessions = 0;
169
+ let trajectories = 0;
170
+ let edges = 0;
171
+ let confidenceMean = 0;
172
+ let accessedCount = 0;
173
+ let trend = 'STABLE';
174
+
175
+ // PRIMARY: Read from intelligence loop data files
176
+ const dataDir = path.join(process.cwd(), '.claude-flow', 'data');
177
+
178
+ // 1. graph-state.json — authoritative node/edge counts
179
+ const graphPath = path.join(dataDir, 'graph-state.json');
180
+ if (fs.existsSync(graphPath)) {
181
+ try {
182
+ const graph = JSON.parse(fs.readFileSync(graphPath, 'utf-8'));
183
+ patterns = graph.nodes ? Object.keys(graph.nodes).length : 0;
184
+ edges = Array.isArray(graph.edges) ? graph.edges.length : 0;
185
+ } catch (e) { /* ignore */ }
186
+ }
187
+
188
+ // 2. ranked-context.json — confidence and access data
189
+ const rankedPath = path.join(dataDir, 'ranked-context.json');
190
+ if (fs.existsSync(rankedPath)) {
191
+ try {
192
+ const ranked = JSON.parse(fs.readFileSync(rankedPath, 'utf-8'));
193
+ if (ranked.entries && ranked.entries.length > 0) {
194
+ patterns = Math.max(patterns, ranked.entries.length);
195
+ let confSum = 0;
196
+ let accCount = 0;
197
+ for (let i = 0; i < ranked.entries.length; i++) {
198
+ confSum += (ranked.entries[i].confidence || 0);
199
+ if ((ranked.entries[i].accessCount || 0) > 0) accCount++;
200
+ }
201
+ confidenceMean = confSum / ranked.entries.length;
202
+ accessedCount = accCount;
203
+ }
204
+ } catch (e) { /* ignore */ }
205
+ }
206
+
207
+ // 3. intelligence-snapshot.json — trend history
208
+ const snapshotPath = path.join(dataDir, 'intelligence-snapshot.json');
209
+ if (fs.existsSync(snapshotPath)) {
210
+ try {
211
+ const snapshot = JSON.parse(fs.readFileSync(snapshotPath, 'utf-8'));
212
+ if (snapshot.history && snapshot.history.length >= 2) {
213
+ const first = snapshot.history[0];
214
+ const last = snapshot.history[snapshot.history.length - 1];
215
+ const confDrift = (last.confidenceMean || 0) - (first.confidenceMean || 0);
216
+ trend = confDrift > 0.01 ? 'IMPROVING' : confDrift < -0.01 ? 'DECLINING' : 'STABLE';
217
+ sessions = Math.max(sessions, snapshot.history.length);
218
+ }
219
+ } catch (e) { /* ignore */ }
220
+ }
221
+
222
+ // 4. auto-memory-store.json — fallback entry count
223
+ if (patterns === 0) {
224
+ const autoMemPath = path.join(dataDir, 'auto-memory-store.json');
225
+ if (fs.existsSync(autoMemPath)) {
226
+ try {
227
+ const data = JSON.parse(fs.readFileSync(autoMemPath, 'utf-8'));
228
+ patterns = Array.isArray(data) ? data.length : (data.entries ? data.entries.length : 0);
229
+ } catch (e) { /* ignore */ }
230
+ }
231
+ }
232
+
233
+ // FALLBACK: Legacy memory.db file-size estimation
234
+ if (patterns === 0) {
235
+ const memoryPaths = [
236
+ path.join(process.cwd(), '.swarm', 'memory.db'),
237
+ path.join(process.cwd(), '.claude', 'memory.db'),
238
+ path.join(process.cwd(), 'data', 'memory.db'),
239
+ ];
240
+ for (let j = 0; j < memoryPaths.length; j++) {
241
+ if (fs.existsSync(memoryPaths[j])) {
242
+ try {
243
+ const dbStats = fs.statSync(memoryPaths[j]);
244
+ patterns = Math.floor(dbStats.size / 1024 / 2);
245
+ break;
246
+ } catch (e) { /* ignore */ }
247
+ }
248
+ }
249
+ }
250
+
251
+ // Session count from session files
252
+ const sessionsPath = path.join(process.cwd(), '.claude', 'sessions');
253
+ if (fs.existsSync(sessionsPath)) {
254
+ try {
255
+ const sessionFiles = fs.readdirSync(sessionsPath).filter(f => f.endsWith('.json'));
256
+ sessions = Math.max(sessions, sessionFiles.length);
257
+ } catch (e) { /* ignore */ }
258
+ }
259
+
260
+ trajectories = Math.floor(patterns / 5);
261
+
262
+ return { patterns, sessions, trajectories, edges, confidenceMean, accessedCount, trend };
263
+ }
264
+
265
+ // Get V3 progress from learning state (grows as system learns)
266
+ function getV3Progress() {
267
+ const learning = getLearningStats();
268
+
269
+ // DDD progress based on actual learned patterns
270
+ // New install: 0 patterns = 0/5 domains, 0% DDD
271
+ // As patterns grow: 10+ patterns = 1 domain, 50+ = 2, 100+ = 3, 200+ = 4, 500+ = 5
272
+ let domainsCompleted = 0;
273
+ if (learning.patterns >= 500) domainsCompleted = 5;
274
+ else if (learning.patterns >= 200) domainsCompleted = 4;
275
+ else if (learning.patterns >= 100) domainsCompleted = 3;
276
+ else if (learning.patterns >= 50) domainsCompleted = 2;
277
+ else if (learning.patterns >= 10) domainsCompleted = 1;
278
+
279
+ const totalDomains = 5;
280
+ const dddProgress = Math.min(100, Math.floor((domainsCompleted / totalDomains) * 100));
281
+
282
+ return {
283
+ domainsCompleted,
284
+ totalDomains,
285
+ dddProgress,
286
+ patternsLearned: learning.patterns,
287
+ sessionsCompleted: learning.sessions
288
+ };
289
+ }
290
+
291
+ // Get security status based on actual scans
292
+ function getSecurityStatus() {
293
+ // Check for security scan results in memory
294
+ const scanResultsPath = path.join(process.cwd(), '.claude', 'security-scans');
295
+ let cvesFixed = 0;
296
+ const totalCves = 3;
297
+
298
+ if (fs.existsSync(scanResultsPath)) {
299
+ try {
300
+ const scans = fs.readdirSync(scanResultsPath).filter(f => f.endsWith('.json'));
301
+ // Each successful scan file = 1 CVE addressed
302
+ cvesFixed = Math.min(totalCves, scans.length);
303
+ } catch (e) {
304
+ // Ignore
305
+ }
306
+ }
307
+
308
+ // Also check .swarm/security for audit results
309
+ const auditPath = path.join(process.cwd(), '.swarm', 'security');
310
+ if (fs.existsSync(auditPath)) {
311
+ try {
312
+ const audits = fs.readdirSync(auditPath).filter(f => f.includes('audit'));
313
+ cvesFixed = Math.min(totalCves, Math.max(cvesFixed, audits.length));
314
+ } catch (e) {
315
+ // Ignore
316
+ }
317
+ }
318
+
319
+ const status = cvesFixed >= totalCves ? 'CLEAN' : cvesFixed > 0 ? 'IN_PROGRESS' : 'PENDING';
320
+
321
+ return {
322
+ status,
323
+ cvesFixed,
324
+ totalCves,
325
+ };
326
+ }
327
+
328
+ // Get swarm status
329
+ function getSwarmStatus() {
330
+ let activeAgents = 0;
331
+ let coordinationActive = false;
332
+
333
+ try {
334
+ if (isWindows) {
335
+ // Windows: use tasklist and findstr
336
+ const ps = execSync('tasklist 2>NUL | findstr /I "agentic-flow" 2>NUL | find /C /V "" 2>NUL || echo 0', { encoding: 'utf-8' });
337
+ activeAgents = Math.max(0, parseInt(ps.trim()) || 0);
338
+ } else {
339
+ const ps = execSync('ps aux 2>/dev/null | grep -c agentic-flow || echo "0"', { encoding: 'utf-8' });
340
+ activeAgents = Math.max(0, parseInt(ps.trim()) - 1);
341
+ }
342
+ coordinationActive = activeAgents > 0;
343
+ } catch (e) {
344
+ // Ignore errors - default to 0 agents
345
+ }
346
+
347
+ return {
348
+ activeAgents,
349
+ maxAgents: CONFIG.maxAgents,
350
+ coordinationActive,
351
+ };
352
+ }
353
+
354
+ // Get system metrics (dynamic based on actual state)
355
+ function getSystemMetrics() {
356
+ let memoryMB = 0;
357
+ let subAgents = 0;
358
+
359
+ try {
360
+ if (isWindows) {
361
+ // Windows: use tasklist for memory info, fallback to process.memoryUsage
362
+ // tasklist memory column is complex to parse, use Node.js API instead
363
+ memoryMB = Math.floor(process.memoryUsage().heapUsed / 1024 / 1024);
364
+ } else {
365
+ const mem = execSync('ps aux | grep -E "(node|agentic|claude)" | grep -v grep | awk \'{sum += $6} END {print int(sum/1024)}\'', { encoding: 'utf-8' });
366
+ memoryMB = parseInt(mem.trim()) || 0;
367
+ }
368
+ } catch (e) {
369
+ // Fallback
370
+ memoryMB = Math.floor(process.memoryUsage().heapUsed / 1024 / 1024);
371
+ }
372
+
373
+ // Get learning stats for intelligence %
374
+ const learning = getLearningStats();
375
+
376
+ // Intelligence % from REAL intelligence loop data (ADR-050)
377
+ // Composite: 40% confidence mean + 30% access ratio + 30% pattern density
378
+ let intelligencePct = 0;
379
+ if (learning.confidenceMean > 0 || (learning.patterns > 0 && learning.accessedCount > 0)) {
380
+ const confScore = Math.min(100, Math.floor(learning.confidenceMean * 100));
381
+ const accessRatio = learning.patterns > 0 ? (learning.accessedCount / learning.patterns) : 0;
382
+ const accessScore = Math.min(100, Math.floor(accessRatio * 100));
383
+ const densityScore = Math.min(100, Math.floor(learning.patterns / 5));
384
+ intelligencePct = Math.floor(confScore * 0.4 + accessScore * 0.3 + densityScore * 0.3);
385
+ }
386
+ // Fallback: legacy pattern count
387
+ if (intelligencePct === 0 && learning.patterns > 0) {
388
+ intelligencePct = Math.min(100, Math.floor(learning.patterns / 10));
389
+ }
390
+
391
+ // Context % based on session history
392
+ const contextPct = Math.min(100, Math.floor(learning.sessions * 5));
393
+
394
+ // Count active sub-agents from process list
395
+ try {
396
+ if (isWindows) {
397
+ // Windows: use tasklist and findstr for agent counting
398
+ const agents = execSync('tasklist 2>NUL | findstr /I "claude-flow" 2>NUL | find /C /V "" 2>NUL || echo 0', { encoding: 'utf-8' });
399
+ subAgents = Math.max(0, parseInt(agents.trim()) || 0);
400
+ } else {
401
+ const agents = execSync('ps aux 2>/dev/null | grep -c "claude-flow.*agent" || echo "0"', { encoding: 'utf-8' });
402
+ subAgents = Math.max(0, parseInt(agents.trim()) - 1);
403
+ }
404
+ } catch (e) {
405
+ // Ignore - default to 0
406
+ }
407
+
408
+ return {
409
+ memoryMB,
410
+ contextPct,
411
+ intelligencePct,
412
+ subAgents,
413
+ };
414
+ }
415
+
416
+ // Generate progress bar
417
+ function progressBar(current, total) {
418
+ const width = 5;
419
+ const filled = Math.round((current / total) * width);
420
+ const empty = width - filled;
421
+ return '[' + '\u25CF'.repeat(filled) + '\u25CB'.repeat(empty) + ']';
422
+ }
423
+
424
+ // Generate full statusline
425
+ function generateStatusline() {
426
+ const user = getUserInfo();
427
+ const progress = getV3Progress();
428
+ const security = getSecurityStatus();
429
+ const swarm = getSwarmStatus();
430
+ const system = getSystemMetrics();
431
+ const lines = [];
432
+
433
+ // Header Line
434
+ let header = `${c.bold}${c.brightPurple}▊ RuFlo V${RUFLO_VERSION} ${c.reset}`;
435
+ header += `${swarm.coordinationActive ? c.brightCyan : c.dim}● ${c.brightCyan}${user.name}${c.reset}`;
436
+ if (user.gitBranch) {
437
+ header += ` ${c.dim}│${c.reset} ${c.brightBlue}⎇ ${user.gitBranch}${c.reset}`;
438
+ }
439
+ header += ` ${c.dim}│${c.reset} ${c.purple}${user.modelName}${c.reset}`;
440
+ lines.push(header);
441
+
442
+ // Separator
443
+ lines.push(`${c.dim}─────────────────────────────────────────────────────${c.reset}`);
444
+
445
+ // Line 1: DDD Domain Progress
446
+ const domainsColor = progress.domainsCompleted >= 3 ? c.brightGreen : progress.domainsCompleted > 0 ? c.yellow : c.red;
447
+ lines.push(
448
+ `${c.brightCyan}🏗️ DDD Domains${c.reset} ${progressBar(progress.domainsCompleted, progress.totalDomains)} ` +
449
+ `${domainsColor}${progress.domainsCompleted}${c.reset}/${c.brightWhite}${progress.totalDomains}${c.reset} ` +
450
+ `${c.brightYellow}⚡ 1.0x${c.reset} ${c.dim}→${c.reset} ${c.brightYellow}2.49x-7.47x${c.reset}`
451
+ );
452
+
453
+ // Line 2: Swarm + CVE + Memory + Context + Intelligence
454
+ const swarmIndicator = swarm.coordinationActive ? `${c.brightGreen}◉${c.reset}` : `${c.dim}○${c.reset}`;
455
+ const agentsColor = swarm.activeAgents > 0 ? c.brightGreen : c.red;
456
+ let securityIcon = security.status === 'CLEAN' ? '🟢' : security.status === 'IN_PROGRESS' ? '🟡' : '🔴';
457
+ let securityColor = security.status === 'CLEAN' ? c.brightGreen : security.status === 'IN_PROGRESS' ? c.brightYellow : c.brightRed;
458
+
459
+ lines.push(
460
+ `${c.brightYellow}🤖 Swarm${c.reset} ${swarmIndicator} [${agentsColor}${String(swarm.activeAgents).padStart(2)}${c.reset}/${c.brightWhite}${swarm.maxAgents}${c.reset}] ` +
461
+ `${c.brightPurple}👥 ${system.subAgents}${c.reset} ` +
462
+ `${securityIcon} ${securityColor}CVE ${security.cvesFixed}${c.reset}/${c.brightWhite}${security.totalCves}${c.reset} ` +
463
+ `${c.brightCyan}💾 ${system.memoryMB}MB${c.reset} ` +
464
+ `${c.brightGreen}📂 ${String(system.contextPct).padStart(3)}%${c.reset} ` +
465
+ `${c.dim}🧠 ${String(system.intelligencePct).padStart(3)}%${c.reset}`
466
+ );
467
+
468
+ // Line 3: Architecture status
469
+ const dddColor = progress.dddProgress >= 50 ? c.brightGreen : progress.dddProgress > 0 ? c.yellow : c.red;
470
+ lines.push(
471
+ `${c.brightPurple}🔧 Architecture${c.reset} ` +
472
+ `${c.cyan}DDD${c.reset} ${dddColor}●${String(progress.dddProgress).padStart(3)}%${c.reset} ${c.dim}│${c.reset} ` +
473
+ `${c.cyan}Security${c.reset} ${securityColor}●${security.status}${c.reset} ${c.dim}│${c.reset} ` +
474
+ `${c.cyan}Memory${c.reset} ${c.brightGreen}●AgentDB${c.reset} ${c.dim}│${c.reset} ` +
475
+ `${c.cyan}Integration${c.reset} ${swarm.coordinationActive ? c.brightCyan : c.dim}●${c.reset}`
476
+ );
477
+
478
+ return lines.join('\n');
479
+ }
480
+
481
+ // Generate JSON data
482
+ function generateJSON() {
483
+ return {
484
+ user: getUserInfo(),
485
+ v3Progress: getV3Progress(),
486
+ security: getSecurityStatus(),
487
+ swarm: getSwarmStatus(),
488
+ system: getSystemMetrics(),
489
+ performance: {
490
+ flashAttentionTarget: '2.49x-7.47x',
491
+ searchImprovement: '150x-12,500x',
492
+ memoryReduction: '50-75%',
493
+ },
494
+ lastUpdated: new Date().toISOString(),
495
+ };
496
+ }
497
+
498
+ /**
499
+ * Generate single-line output for Claude Code compatibility
500
+ * This avoids the collision zone issue entirely by using one line
501
+ * @see https://github.com/ruvnet/claude-flow/issues/985
502
+ */
503
+ function generateSingleLine() {
504
+ if (!CONFIG.enabled) return '';
505
+
506
+ const user = getUserInfo();
507
+ const progress = getV3Progress();
508
+ const security = getSecurityStatus();
509
+ const swarm = getSwarmStatus();
510
+ const system = getSystemMetrics();
511
+
512
+ const swarmIndicator = swarm.coordinationActive ? '●' : '○';
513
+ const securityStatus = security.status === 'CLEAN' ? '✓' :
514
+ security.cvesFixed > 0 ? '~' : '✗';
515
+
516
+ return `${c.brightPurple}RuFlo${c.reset} ${c.dim}|${c.reset} ` +
517
+ `${c.cyan}D:${progress.domainsCompleted}/${progress.totalDomains}${c.reset} ${c.dim}|${c.reset} ` +
518
+ `${c.yellow}S:${swarmIndicator}${swarm.activeAgents}/${swarm.maxAgents}${c.reset} ${c.dim}|${c.reset} ` +
519
+ `${security.status === 'CLEAN' ? c.green : c.red}CVE:${securityStatus}${security.cvesFixed}/${security.totalCves}${c.reset} ${c.dim}|${c.reset} ` +
520
+ `${c.dim}🧠${system.intelligencePct}%${c.reset}`;
521
+ }
522
+
523
+ /**
524
+ * Generate safe multi-line statusline that avoids Claude Code collision zone
525
+ * The collision zone is columns 15-25 on the second-to-last line.
526
+ * We pad that line with spaces to push content past column 25.
527
+ * @see https://github.com/ruvnet/claude-flow/issues/985
528
+ */
529
+ function generateSafeStatusline() {
530
+ if (!CONFIG.enabled) return '';
531
+
532
+ const user = getUserInfo();
533
+ const progress = getV3Progress();
534
+ const security = getSecurityStatus();
535
+ const swarm = getSwarmStatus();
536
+ const system = getSystemMetrics();
537
+ const lines = [];
538
+
539
+ // Header Line
540
+ let header = `${c.bold}${c.brightPurple}▊ RuFlo V${RUFLO_VERSION} ${c.reset}`;
541
+ header += `${swarm.coordinationActive ? c.brightCyan : c.dim}● ${c.brightCyan}${user.name}${c.reset}`;
542
+ if (user.gitBranch) {
543
+ header += ` ${c.dim}│${c.reset} ${c.brightBlue}⎇ ${user.gitBranch}${c.reset}`;
544
+ }
545
+ header += ` ${c.dim}│${c.reset} ${c.purple}${user.modelName}${c.reset}`;
546
+ lines.push(header);
547
+
548
+ // Separator
549
+ lines.push(`${c.dim}─────────────────────────────────────────────────────${c.reset}`);
550
+
551
+ // Line 1: DDD Domain Progress
552
+ const domainsColor = progress.domainsCompleted >= 3 ? c.brightGreen : progress.domainsCompleted > 0 ? c.yellow : c.red;
553
+ lines.push(
554
+ `${c.brightCyan}🏗️ DDD Domains${c.reset} ${progressBar(progress.domainsCompleted, progress.totalDomains)} ` +
555
+ `${domainsColor}${progress.domainsCompleted}${c.reset}/${c.brightWhite}${progress.totalDomains}${c.reset} ` +
556
+ `${c.brightYellow}⚡ 1.0x${c.reset} ${c.dim}→${c.reset} ${c.brightYellow}2.49x-7.47x${c.reset}`
557
+ );
558
+
559
+ // Line 2 (COLLISION LINE): Swarm status with padding after label
560
+ // The emoji+label is ~10 columns. Padding pushes content past collision zone (cols 15-25)
561
+ const swarmIndicator = swarm.coordinationActive ? `${c.brightGreen}◉${c.reset}` : `${c.dim}○${c.reset}`;
562
+ const agentsColor = swarm.activeAgents > 0 ? c.brightGreen : c.red;
563
+ let securityIcon = security.status === 'CLEAN' ? '🟢' : security.status === 'IN_PROGRESS' ? '🟡' : '🔴';
564
+ let securityColor = security.status === 'CLEAN' ? c.brightGreen : security.status === 'IN_PROGRESS' ? c.brightYellow : c.brightRed;
565
+
566
+ // Padding after "🤖 Swarm" (emoji 2 cols + " Swarm" 6 cols = 8, pad 18 to reach col 26)
567
+ lines.push(
568
+ `${c.brightYellow}🤖 Swarm${c.reset} ` + // 18 spaces padding
569
+ `${swarmIndicator} [${agentsColor}${String(swarm.activeAgents).padStart(2)}${c.reset}/${c.brightWhite}${swarm.maxAgents}${c.reset}] ` +
570
+ `${c.brightPurple}👥 ${system.subAgents}${c.reset} ` +
571
+ `${securityIcon} ${securityColor}CVE ${security.cvesFixed}${c.reset}/${c.brightWhite}${security.totalCves}${c.reset} ` +
572
+ `${c.brightCyan}💾 ${system.memoryMB}MB${c.reset} ` +
573
+ `${c.dim}🧠 ${system.intelligencePct}%${c.reset}`
574
+ );
575
+
576
+ // Line 3: Architecture status (this is the last line, not in collision zone)
577
+ const dddColor = progress.dddProgress >= 50 ? c.brightGreen : progress.dddProgress > 0 ? c.yellow : c.red;
578
+ lines.push(
579
+ `${c.brightPurple}🔧 Architecture${c.reset} ` +
580
+ `${c.cyan}DDD${c.reset} ${dddColor}●${String(progress.dddProgress).padStart(3)}%${c.reset} ${c.dim}│${c.reset} ` +
581
+ `${c.cyan}Security${c.reset} ${securityColor}●${security.status}${c.reset} ${c.dim}│${c.reset} ` +
582
+ `${c.cyan}Memory${c.reset} ${c.brightGreen}●AgentDB${c.reset} ${c.dim}│${c.reset} ` +
583
+ `${c.cyan}Integration${c.reset} ${swarm.coordinationActive ? c.brightCyan : c.dim}●${c.reset}`
584
+ );
585
+
586
+ return lines.join('\n');
587
+ }
588
+
589
+ // Main
590
+ if (process.argv.includes('--json')) {
591
+ console.log(JSON.stringify(generateJSON(), null, 2));
592
+ } else if (process.argv.includes('--compact')) {
593
+ console.log(JSON.stringify(generateJSON()));
594
+ } else if (process.argv.includes('--single')) {
595
+ // Single-line mode - completely avoids collision zone
596
+ console.log(generateSingleLine());
597
+ } else if (process.argv.includes('--unsafe') || process.argv.includes('--legacy')) {
598
+ // Legacy mode - original multi-line without collision avoidance
599
+ console.log(generateStatusline());
600
+ } else {
601
+ // Default: Safe multi-line mode with collision zone avoidance
602
+ // Use --unsafe or --legacy to get the original behavior
603
+ console.log(generateSafeStatusline());
604
+ }