@claude-flow/cli 3.7.0-alpha.6 → 3.7.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 (261) hide show
  1. package/.claude/helpers/hook-handler.cjs +12 -4
  2. package/.claude/helpers/statusline.cjs +31 -2
  3. package/.claude/helpers/statusline.js +35 -4
  4. package/README.md +60 -34
  5. package/bin/cli.js +15 -2
  6. package/bin/mcp-server.js +1 -1
  7. package/dist/src/__probe.d.ts +2 -0
  8. package/dist/src/__probe.d.ts.map +1 -0
  9. package/dist/src/__probe.js +5 -0
  10. package/dist/src/__probe.js.map +1 -0
  11. package/dist/src/commands/agent-wasm.js +2 -2
  12. package/dist/src/commands/agent-wasm.js.map +1 -1
  13. package/dist/src/commands/daemon.d.ts +20 -0
  14. package/dist/src/commands/daemon.d.ts.map +1 -1
  15. package/dist/src/commands/daemon.js +366 -7
  16. package/dist/src/commands/daemon.js.map +1 -1
  17. package/dist/src/commands/doctor.d.ts.map +1 -1
  18. package/dist/src/commands/doctor.js +224 -46
  19. package/dist/src/commands/doctor.js.map +1 -1
  20. package/dist/src/commands/embeddings.d.ts.map +1 -1
  21. package/dist/src/commands/embeddings.js +18 -9
  22. package/dist/src/commands/embeddings.js.map +1 -1
  23. package/dist/src/commands/hive-mind.d.ts.map +1 -1
  24. package/dist/src/commands/hive-mind.js +25 -7
  25. package/dist/src/commands/hive-mind.js.map +1 -1
  26. package/dist/src/commands/hooks.d.ts.map +1 -1
  27. package/dist/src/commands/hooks.js +56 -29
  28. package/dist/src/commands/hooks.js.map +1 -1
  29. package/dist/src/commands/memory.d.ts.map +1 -1
  30. package/dist/src/commands/memory.js +104 -3
  31. package/dist/src/commands/memory.js.map +1 -1
  32. package/dist/src/commands/start.js +1 -1
  33. package/dist/src/commands/start.js.map +1 -1
  34. package/dist/src/commands/swarm.js +1 -1
  35. package/dist/src/commands/swarm.js.map +1 -1
  36. package/dist/src/commands/task.d.ts.map +1 -1
  37. package/dist/src/commands/task.js +8 -4
  38. package/dist/src/commands/task.js.map +1 -1
  39. package/dist/src/config-adapter.js +1 -1
  40. package/dist/src/config-adapter.js.map +1 -1
  41. package/dist/src/index.d.ts +5 -1
  42. package/dist/src/index.d.ts.map +1 -1
  43. package/dist/src/index.js +61 -18
  44. package/dist/src/index.js.map +1 -1
  45. package/dist/src/init/executor.d.ts.map +1 -1
  46. package/dist/src/init/executor.js +92 -0
  47. package/dist/src/init/executor.js.map +1 -1
  48. package/dist/src/init/helpers-generator.d.ts.map +1 -1
  49. package/dist/src/init/helpers-generator.js +6 -2
  50. package/dist/src/init/helpers-generator.js.map +1 -1
  51. package/dist/src/init/mcp-generator.js +4 -4
  52. package/dist/src/init/mcp-generator.js.map +1 -1
  53. package/dist/src/init/settings-generator.d.ts.map +1 -1
  54. package/dist/src/init/settings-generator.js +78 -19
  55. package/dist/src/init/settings-generator.js.map +1 -1
  56. package/dist/src/init/statusline-generator.d.ts.map +1 -1
  57. package/dist/src/init/statusline-generator.js +75 -31
  58. package/dist/src/init/statusline-generator.js.map +1 -1
  59. package/dist/src/init/types.d.ts +7 -0
  60. package/dist/src/init/types.d.ts.map +1 -1
  61. package/dist/src/init/types.js.map +1 -1
  62. package/dist/src/mcp-client.d.ts.map +1 -1
  63. package/dist/src/mcp-client.js +12 -0
  64. package/dist/src/mcp-client.js.map +1 -1
  65. package/dist/src/mcp-server.d.ts.map +1 -1
  66. package/dist/src/mcp-server.js +38 -5
  67. package/dist/src/mcp-server.js.map +1 -1
  68. package/dist/src/mcp-tools/agent-execute-core.d.ts +3 -2
  69. package/dist/src/mcp-tools/agent-execute-core.d.ts.map +1 -1
  70. package/dist/src/mcp-tools/agent-execute-core.js +16 -9
  71. package/dist/src/mcp-tools/agent-execute-core.js.map +1 -1
  72. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
  73. package/dist/src/mcp-tools/agent-tools.js +88 -11
  74. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  75. package/dist/src/mcp-tools/agentdb-tools.d.ts +3 -0
  76. package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -1
  77. package/dist/src/mcp-tools/agentdb-tools.js +206 -21
  78. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
  79. package/dist/src/mcp-tools/analyze-tools.js +6 -6
  80. package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
  81. package/dist/src/mcp-tools/autopilot-tools.js +10 -10
  82. package/dist/src/mcp-tools/autopilot-tools.js.map +1 -1
  83. package/dist/src/mcp-tools/browser-session-tools.d.ts.map +1 -1
  84. package/dist/src/mcp-tools/browser-session-tools.js +18 -7
  85. package/dist/src/mcp-tools/browser-session-tools.js.map +1 -1
  86. package/dist/src/mcp-tools/browser-tools.js +23 -23
  87. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  88. package/dist/src/mcp-tools/claims-tools.js +12 -12
  89. package/dist/src/mcp-tools/claims-tools.js.map +1 -1
  90. package/dist/src/mcp-tools/config-tools.js +6 -6
  91. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  92. package/dist/src/mcp-tools/coordination-tools.js +7 -7
  93. package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
  94. package/dist/src/mcp-tools/daa-tools.js +8 -8
  95. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  96. package/dist/src/mcp-tools/embeddings-tools.d.ts.map +1 -1
  97. package/dist/src/mcp-tools/embeddings-tools.js +807 -10
  98. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  99. package/dist/src/mcp-tools/github-tools.js +5 -5
  100. package/dist/src/mcp-tools/github-tools.js.map +1 -1
  101. package/dist/src/mcp-tools/guidance-tools.js +21 -21
  102. package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
  103. package/dist/src/mcp-tools/hive-consensus-runtime.d.ts +149 -0
  104. package/dist/src/mcp-tools/hive-consensus-runtime.d.ts.map +1 -0
  105. package/dist/src/mcp-tools/hive-consensus-runtime.js +296 -0
  106. package/dist/src/mcp-tools/hive-consensus-runtime.js.map +1 -0
  107. package/dist/src/mcp-tools/hive-mind-tools.d.ts +7 -0
  108. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
  109. package/dist/src/mcp-tools/hive-mind-tools.js +238 -13
  110. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  111. package/dist/src/mcp-tools/hooks-tools.d.ts +2 -0
  112. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  113. package/dist/src/mcp-tools/hooks-tools.js +183 -48
  114. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  115. package/dist/src/mcp-tools/managed-agent-tools.d.ts +22 -0
  116. package/dist/src/mcp-tools/managed-agent-tools.d.ts.map +1 -0
  117. package/dist/src/mcp-tools/managed-agent-tools.js +357 -0
  118. package/dist/src/mcp-tools/managed-agent-tools.js.map +1 -0
  119. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
  120. package/dist/src/mcp-tools/memory-tools.js +490 -68
  121. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  122. package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
  123. package/dist/src/mcp-tools/neural-tools.js +8 -7
  124. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  125. package/dist/src/mcp-tools/performance-tools.js +6 -6
  126. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  127. package/dist/src/mcp-tools/progress-tools.js +4 -4
  128. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  129. package/dist/src/mcp-tools/ruvllm-tools.js +10 -10
  130. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
  131. package/dist/src/mcp-tools/security-tools.d.ts.map +1 -1
  132. package/dist/src/mcp-tools/security-tools.js +34 -9
  133. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  134. package/dist/src/mcp-tools/session-tools.d.ts.map +1 -1
  135. package/dist/src/mcp-tools/session-tools.js +130 -6
  136. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  137. package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
  138. package/dist/src/mcp-tools/swarm-tools.js +76 -7
  139. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  140. package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
  141. package/dist/src/mcp-tools/system-tools.js +91 -18
  142. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  143. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
  144. package/dist/src/mcp-tools/task-tools.js +55 -7
  145. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  146. package/dist/src/mcp-tools/terminal-tools.js +5 -5
  147. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  148. package/dist/src/mcp-tools/transfer-tools.js +11 -11
  149. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  150. package/dist/src/mcp-tools/wasm-agent-tools.js +11 -11
  151. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
  152. package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -1
  153. package/dist/src/mcp-tools/workflow-tools.js +118 -10
  154. package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
  155. package/dist/src/memory/ann-router-registry.d.ts +61 -0
  156. package/dist/src/memory/ann-router-registry.d.ts.map +1 -0
  157. package/dist/src/memory/ann-router-registry.js +72 -0
  158. package/dist/src/memory/ann-router-registry.js.map +1 -0
  159. package/dist/src/memory/diskann-registry.d.ts +56 -0
  160. package/dist/src/memory/diskann-registry.d.ts.map +1 -0
  161. package/dist/src/memory/diskann-registry.js +88 -0
  162. package/dist/src/memory/diskann-registry.js.map +1 -0
  163. package/dist/src/memory/memory-bridge.d.ts +69 -0
  164. package/dist/src/memory/memory-bridge.d.ts.map +1 -1
  165. package/dist/src/memory/memory-bridge.js +293 -5
  166. package/dist/src/memory/memory-bridge.js.map +1 -1
  167. package/dist/src/memory/memory-initializer.d.ts +8 -0
  168. package/dist/src/memory/memory-initializer.d.ts.map +1 -1
  169. package/dist/src/memory/memory-initializer.js +89 -16
  170. package/dist/src/memory/memory-initializer.js.map +1 -1
  171. package/dist/src/memory/sona-optimizer.d.ts.map +1 -1
  172. package/dist/src/memory/sona-optimizer.js +3 -0
  173. package/dist/src/memory/sona-optimizer.js.map +1 -1
  174. package/dist/src/parser.d.ts +9 -0
  175. package/dist/src/parser.d.ts.map +1 -1
  176. package/dist/src/parser.js +11 -0
  177. package/dist/src/parser.js.map +1 -1
  178. package/dist/src/plugins/store/discovery.d.ts +6 -3
  179. package/dist/src/plugins/store/discovery.d.ts.map +1 -1
  180. package/dist/src/plugins/store/discovery.js +11 -8
  181. package/dist/src/plugins/store/discovery.js.map +1 -1
  182. package/dist/src/ruvector/agent-wasm.d.ts.map +1 -1
  183. package/dist/src/ruvector/agent-wasm.js +4 -1
  184. package/dist/src/ruvector/agent-wasm.js.map +1 -1
  185. package/dist/src/ruvector/coverage-tools.js +6 -6
  186. package/dist/src/ruvector/coverage-tools.js.map +1 -1
  187. package/dist/src/ruvector/index.d.ts +0 -2
  188. package/dist/src/ruvector/index.d.ts.map +1 -1
  189. package/dist/src/ruvector/index.js +8 -2
  190. package/dist/src/ruvector/index.js.map +1 -1
  191. package/dist/src/services/headless-worker-executor.d.ts +6 -0
  192. package/dist/src/services/headless-worker-executor.d.ts.map +1 -1
  193. package/dist/src/services/headless-worker-executor.js +37 -3
  194. package/dist/src/services/headless-worker-executor.js.map +1 -1
  195. package/dist/src/services/worker-daemon.d.ts +80 -2
  196. package/dist/src/services/worker-daemon.d.ts.map +1 -1
  197. package/dist/src/services/worker-daemon.js +372 -11
  198. package/dist/src/services/worker-daemon.js.map +1 -1
  199. package/dist/tsconfig.tsbuildinfo +1 -1
  200. package/package.json +13 -8
  201. package/.claude/skills/agentdb-advanced/SKILL.md +0 -550
  202. package/.claude/skills/agentdb-learning/SKILL.md +0 -545
  203. package/.claude/skills/agentdb-memory-patterns/SKILL.md +0 -339
  204. package/.claude/skills/agentdb-optimization/SKILL.md +0 -509
  205. package/.claude/skills/agentdb-vector-search/SKILL.md +0 -339
  206. package/.claude/skills/agentic-jujutsu/SKILL.md +0 -645
  207. package/.claude/skills/aidefence-scan.md +0 -151
  208. package/.claude/skills/aidefence.yaml +0 -297
  209. package/.claude/skills/browser/SKILL.md +0 -204
  210. package/.claude/skills/flow-nexus-neural/SKILL.md +0 -738
  211. package/.claude/skills/flow-nexus-platform/SKILL.md +0 -1157
  212. package/.claude/skills/flow-nexus-swarm/SKILL.md +0 -610
  213. package/.claude/skills/github-code-review/SKILL.md +0 -1140
  214. package/.claude/skills/github-multi-repo/SKILL.md +0 -874
  215. package/.claude/skills/github-project-management/SKILL.md +0 -1277
  216. package/.claude/skills/github-release-management/SKILL.md +0 -1081
  217. package/.claude/skills/github-workflow-automation/SKILL.md +0 -1065
  218. package/.claude/skills/hive-mind-advanced/SKILL.md +0 -712
  219. package/.claude/skills/hooks-automation/SKILL.md +0 -1201
  220. package/.claude/skills/pair-programming/SKILL.md +0 -1202
  221. package/.claude/skills/performance-analysis/SKILL.md +0 -563
  222. package/.claude/skills/reasoningbank-agentdb/SKILL.md +0 -446
  223. package/.claude/skills/reasoningbank-intelligence/SKILL.md +0 -201
  224. package/.claude/skills/secure-review.md +0 -181
  225. package/.claude/skills/skill-builder/SKILL.md +0 -910
  226. package/.claude/skills/sparc-methodology/SKILL.md +0 -1115
  227. package/.claude/skills/stream-chain/SKILL.md +0 -563
  228. package/.claude/skills/swarm-advanced/SKILL.md +0 -973
  229. package/.claude/skills/swarm-orchestration/SKILL.md +0 -179
  230. package/.claude/skills/v3-cli-modernization/SKILL.md +0 -872
  231. package/.claude/skills/v3-core-implementation/SKILL.md +0 -797
  232. package/.claude/skills/v3-ddd-architecture/SKILL.md +0 -442
  233. package/.claude/skills/v3-integration-deep/SKILL.md +0 -241
  234. package/.claude/skills/v3-mcp-optimization/SKILL.md +0 -777
  235. package/.claude/skills/v3-memory-unification/SKILL.md +0 -174
  236. package/.claude/skills/v3-performance-optimization/SKILL.md +0 -390
  237. package/.claude/skills/v3-security-overhaul/SKILL.md +0 -82
  238. package/.claude/skills/v3-swarm-coordination/SKILL.md +0 -340
  239. package/.claude/skills/verification-quality/SKILL.md +0 -649
  240. package/.claude/skills/worker-benchmarks/skill.md +0 -135
  241. package/.claude/skills/worker-integration/skill.md +0 -154
  242. package/dist/src/ruvector/flash-attention.d.ts +0 -195
  243. package/dist/src/ruvector/flash-attention.d.ts.map +0 -1
  244. package/dist/src/ruvector/flash-attention.js +0 -643
  245. package/dist/src/ruvector/flash-attention.js.map +0 -1
  246. package/dist/src/ruvector/moe-router.d.ts +0 -206
  247. package/dist/src/ruvector/moe-router.d.ts.map +0 -1
  248. package/dist/src/ruvector/moe-router.js +0 -626
  249. package/dist/src/ruvector/moe-router.js.map +0 -1
  250. package/dist/src/services/event-stream.d.ts +0 -25
  251. package/dist/src/services/event-stream.d.ts.map +0 -1
  252. package/dist/src/services/event-stream.js +0 -27
  253. package/dist/src/services/event-stream.js.map +0 -1
  254. package/dist/src/services/loop-worker-runner.d.ts +0 -16
  255. package/dist/src/services/loop-worker-runner.d.ts.map +0 -1
  256. package/dist/src/services/loop-worker-runner.js +0 -34
  257. package/dist/src/services/loop-worker-runner.js.map +0 -1
  258. package/dist/src/services/runtime-capabilities.d.ts +0 -22
  259. package/dist/src/services/runtime-capabilities.d.ts.map +0 -1
  260. package/dist/src/services/runtime-capabilities.js +0 -45
  261. package/dist/src/services/runtime-capabilities.js.map +0 -1
@@ -66,11 +66,12 @@ async function getEWCConsolidator() {
66
66
  return ewcConsolidator;
67
67
  }
68
68
  // MoE Router - lazy loaded
69
+ // #1773 item 4 — moe-router migrated to @claude-flow/neural
69
70
  let moeRouter = null;
70
71
  async function getMoERouter() {
71
72
  if (!moeRouter) {
72
73
  try {
73
- const { getMoERouter: getMoE } = await import('../ruvector/moe-router.js');
74
+ const { getMoERouter: getMoE } = await import('@claude-flow/neural');
74
75
  moeRouter = await getMoE();
75
76
  }
76
77
  catch {
@@ -336,11 +337,12 @@ function getRouterBackendInfo() {
336
337
  }
337
338
  }
338
339
  // Flash Attention - lazy loaded
340
+ // #1773 item 4 — flash-attention migrated to @claude-flow/neural
339
341
  let flashAttention = null;
340
342
  async function getFlashAttention() {
341
343
  if (!flashAttention) {
342
344
  try {
343
- const { getFlashAttention: getFlash } = await import('../ruvector/flash-attention.js');
345
+ const { getFlashAttention: getFlash } = await import('@claude-flow/neural');
344
346
  flashAttention = await getFlash();
345
347
  }
346
348
  catch {
@@ -569,7 +571,7 @@ function assessCommandRisk(command) {
569
571
  // MCP Tool implementations - return raw data for direct CLI use
570
572
  export const hooksPreEdit = {
571
573
  name: 'hooks_pre-edit',
572
- description: 'Get context and agent suggestions before editing a file',
574
+ description: 'Get context and agent suggestions before editing a file Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
573
575
  inputSchema: {
574
576
  type: 'object',
575
577
  properties: {
@@ -611,7 +613,7 @@ export const hooksPreEdit = {
611
613
  };
612
614
  export const hooksPostEdit = {
613
615
  name: 'hooks_post-edit',
614
- description: 'Record editing outcome for learning',
616
+ description: 'Record editing outcome for learning Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
615
617
  inputSchema: {
616
618
  type: 'object',
617
619
  properties: {
@@ -665,7 +667,7 @@ export const hooksPostEdit = {
665
667
  };
666
668
  export const hooksPreCommand = {
667
669
  name: 'hooks_pre-command',
668
- description: 'Assess risk before executing a command',
670
+ description: 'Assess risk before executing a command Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
669
671
  inputSchema: {
670
672
  type: 'object',
671
673
  properties: {
@@ -703,7 +705,7 @@ export const hooksPreCommand = {
703
705
  };
704
706
  export const hooksPostCommand = {
705
707
  name: 'hooks_post-command',
706
- description: 'Record command execution outcome',
708
+ description: 'Record command execution outcome Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
707
709
  inputSchema: {
708
710
  type: 'object',
709
711
  properties: {
@@ -759,7 +761,7 @@ export const hooksPostCommand = {
759
761
  };
760
762
  export const hooksRoute = {
761
763
  name: 'hooks_route',
762
- description: 'Get a 3-tier routing recommendation for a task: Tier 1 (Agent Booster, 0ms / $0 — for var-to-const, add-types, etc.), Tier 2 (Haiku — simple), Tier 3 (Sonnet/Opus — complex). Use this BEFORE spawning an agent to avoid sending simple transforms to Sonnet. Native tools have no equivalent — Claude Code does not introspect its own model-selection cost. Returns the recommended model + a `[AGENT_BOOSTER_AVAILABLE]` literal when the WASM bypass applies.',
764
+ description: 'Get a 3-tier routing recommendation for a task: Tier 1 (Agent Booster, 0ms / $0 — for var-to-const, add-types, etc.), Tier 2 (Haiku — simple), Tier 3 (Sonnet/Opus — complex). Use this BEFORE spawning an agent to avoid sending simple transforms to Sonnet. Native tools have no equivalent — Claude Code does not introspect its own model-selection cost. Returns the recommended model + a `[AGENT_BOOSTER_AVAILABLE]` literal when the WASM bypass applies. Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
763
765
  inputSchema: {
764
766
  type: 'object',
765
767
  properties: {
@@ -935,7 +937,7 @@ export const hooksRoute = {
935
937
  };
936
938
  export const hooksMetrics = {
937
939
  name: 'hooks_metrics',
938
- description: 'View learning metrics dashboard',
940
+ description: 'View learning metrics dashboard Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
939
941
  inputSchema: {
940
942
  type: 'object',
941
943
  properties: {
@@ -1000,7 +1002,7 @@ export const hooksMetrics = {
1000
1002
  };
1001
1003
  export const hooksList = {
1002
1004
  name: 'hooks_list',
1003
- description: 'List all registered hooks',
1005
+ description: 'List all registered hooks Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1004
1006
  inputSchema: {
1005
1007
  type: 'object',
1006
1008
  properties: {},
@@ -1047,7 +1049,7 @@ export const hooksList = {
1047
1049
  };
1048
1050
  export const hooksPreTask = {
1049
1051
  name: 'hooks_pre-task',
1050
- description: 'Record task start and get agent suggestions with intelligent model routing (ADR-026)',
1052
+ description: 'Record task start and get agent suggestions with intelligent model routing (ADR-026) Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1051
1053
  inputSchema: {
1052
1054
  type: 'object',
1053
1055
  properties: {
@@ -1145,7 +1147,7 @@ export const hooksPreTask = {
1145
1147
  };
1146
1148
  export const hooksPostTask = {
1147
1149
  name: 'hooks_post-task',
1148
- description: 'Record task completion for learning',
1150
+ description: 'Record task completion for learning Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1149
1151
  inputSchema: {
1150
1152
  type: 'object',
1151
1153
  properties: {
@@ -1297,7 +1299,7 @@ export const hooksPostTask = {
1297
1299
  // Explain hook - transparent routing explanation
1298
1300
  export const hooksExplain = {
1299
1301
  name: 'hooks_explain',
1300
- description: 'Explain routing decision with full transparency',
1302
+ description: 'Explain routing decision with full transparency Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1301
1303
  inputSchema: {
1302
1304
  type: 'object',
1303
1305
  properties: {
@@ -1375,7 +1377,7 @@ export const hooksExplain = {
1375
1377
  // Pretrain hook - repository analysis for intelligence bootstrap
1376
1378
  export const hooksPretrain = {
1377
1379
  name: 'hooks_pretrain',
1378
- description: 'Analyze repository to bootstrap intelligence (4-step pipeline)',
1380
+ description: 'Analyze repository to bootstrap intelligence (4-step pipeline) Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1379
1381
  inputSchema: {
1380
1382
  type: 'object',
1381
1383
  properties: {
@@ -1392,14 +1394,44 @@ export const hooksPretrain = {
1392
1394
  // (readdirSync/statSync already imported statically at the top.)
1393
1395
  const extCounts = {};
1394
1396
  let filesAnalyzed = 0;
1397
+ // #1953: separate budget for code files. The old code gated the
1398
+ // import-pattern extraction on `filesAnalyzed <= 50`, which counts
1399
+ // EVERY directory entry (including .md/.yaml/.db/.log). In any
1400
+ // markdown/docs-heavy repo, the depth-first walker burned through the
1401
+ // 50-file budget on non-code files before reaching any source — so
1402
+ // `patternsExtracted: 0` even when hundreds of `.ts`/`.js` files existed.
1403
+ let codeFilesScanned = 0;
1395
1404
  let totalLines = 0;
1396
1405
  const maxDepth = depth === 'shallow' ? 2 : depth === 'deep' ? 6 : 4;
1397
1406
  const patterns = [];
1407
+ // #1953: recurse into directories that typically contain code first
1408
+ // (`src/`, `apps/`, `packages/`, `lib/`, `crates/`, `workers/`, `server/`)
1409
+ // before docs / specs / planning dirs, so the import-extraction budget
1410
+ // is spent on the highest-signal directories even in mixed repos.
1411
+ const CODE_DIR_PREFIXES = new Set([
1412
+ 'src', 'apps', 'packages', 'lib', 'crates', 'workers',
1413
+ 'server', 'backend', 'frontend', 'app', 'cli', 'core',
1414
+ ]);
1415
+ const scoreEntry = (name) => {
1416
+ if (CODE_DIR_PREFIXES.has(name))
1417
+ return 0;
1418
+ // Deprioritise common docs / output directories.
1419
+ if (/^(docs?|specs?|_.*|examples?|samples?|out|build|target|coverage|tests?)$/.test(name))
1420
+ return 2;
1421
+ return 1;
1422
+ };
1398
1423
  const scan = (dir, currentDepth) => {
1399
1424
  if (currentDepth > maxDepth)
1400
1425
  return;
1401
1426
  try {
1402
1427
  const entries = readdirSync(dir, { withFileTypes: true });
1428
+ // Sort: code-likely dirs first, files mixed in by name, deprioritised
1429
+ // dirs last. Stable for deterministic test behaviour.
1430
+ entries.sort((a, b) => {
1431
+ const sa = a.isDirectory() ? scoreEntry(a.name) : 1;
1432
+ const sb = b.isDirectory() ? scoreEntry(b.name) : 1;
1433
+ return sa - sb;
1434
+ });
1403
1435
  for (const entry of entries) {
1404
1436
  if (entry.name.startsWith('.') || entry.name === 'node_modules' || entry.name === 'dist')
1405
1437
  continue;
@@ -1413,15 +1445,18 @@ export const hooksPretrain = {
1413
1445
  extCounts[ext] = (extCounts[ext] || 0) + 1;
1414
1446
  filesAnalyzed++;
1415
1447
  // For code files, count lines and extract imports
1416
- if (['.ts', '.js', '.py', '.go', '.rs', '.java'].includes(ext)) {
1448
+ if (['.ts', '.js', '.tsx', '.jsx', '.mjs', '.cjs', '.py', '.go', '.rs', '.java'].includes(ext)) {
1417
1449
  try {
1418
1450
  const content = readFileSync(full, 'utf-8');
1419
1451
  const lines = content.split('\n');
1420
1452
  totalLines += lines.length;
1421
- // Extract import patterns (first 50 files max for performance)
1422
- if (filesAnalyzed <= 50) {
1423
- for (const line of lines.slice(0, 30)) {
1424
- if (line.startsWith('import ') || line.startsWith('from ') || line.startsWith('const ') && line.includes('require(')) {
1453
+ // #1953: gate on the code-file count, not every-file count.
1454
+ // Also widened the per-file scan window from 30 → 80 lines:
1455
+ // modern TS files often have license headers + JSDoc + type
1456
+ // imports before the first `import` statement.
1457
+ if (++codeFilesScanned <= 50) {
1458
+ for (const line of lines.slice(0, 80)) {
1459
+ if (line.startsWith('import ') || line.startsWith('from ') || (line.startsWith('const ') && line.includes('require('))) {
1425
1460
  const trimmed = line.trim();
1426
1461
  if (trimmed.length < 120 && !patterns.includes(trimmed))
1427
1462
  patterns.push(trimmed);
@@ -1453,6 +1488,17 @@ export const hooksPretrain = {
1453
1488
  patternsStored = patterns.length;
1454
1489
  }
1455
1490
  catch { /* AgentDB not available */ }
1491
+ // #1847: when the corpus contains files but no patterns were extracted
1492
+ // (typical for Markdown vaults), make the source-code-only extraction
1493
+ // contract explicit so users don't conclude the hook system is broken.
1494
+ const SUPPORTED_EXTRACTION_EXTS = ['.ts', '.js', '.tsx', '.jsx', '.mjs', '.cjs', '.py', '.go', '.rs', '.java'];
1495
+ let note;
1496
+ if (filesAnalyzed > 0 && patterns.length === 0) {
1497
+ const codeFileCount = SUPPORTED_EXTRACTION_EXTS.reduce((sum, ext) => sum + (extCounts[ext] ?? 0), 0);
1498
+ note = codeFileCount === 0
1499
+ ? `No source-code patterns found. hooks_pretrain extracts import/require lines from ${SUPPORTED_EXTRACTION_EXTS.join('/')} files only — Markdown/text/asset corpora produce zero patterns by design. This is not a hook-system failure; live trajectories and statusline are independent.`
1500
+ : `Found ${codeFileCount} source-code file(s) but extracted zero import/require patterns. They may be empty, generated, or use non-standard module syntax.`;
1501
+ }
1456
1502
  return {
1457
1503
  success: true,
1458
1504
  _real: true,
@@ -1465,14 +1511,21 @@ export const hooksPretrain = {
1465
1511
  patternsExtracted: patterns.length,
1466
1512
  patternsStored,
1467
1513
  fileTypes: Object.entries(extCounts).sort((a, b) => b[1] - a[1]).slice(0, 15).map(([ext, count]) => ({ ext, count })),
1514
+ // #1847: explicit extraction contract so callers can tell pretrain
1515
+ // patterns apart from live trajectories and hook statusline state.
1516
+ sources: {
1517
+ extractedFrom: SUPPORTED_EXTRACTION_EXTS,
1518
+ scope: 'pretrain-only (live trajectories + statusline are tracked separately)',
1519
+ },
1468
1520
  },
1521
+ ...(note ? { note } : {}),
1469
1522
  };
1470
1523
  },
1471
1524
  };
1472
1525
  // Build agents hook - generate optimized agent configs
1473
1526
  export const hooksBuildAgents = {
1474
1527
  name: 'hooks_build-agents',
1475
- description: 'Generate optimized agent configurations from pretrain data',
1528
+ description: 'Generate optimized agent configurations from pretrain data Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1476
1529
  inputSchema: {
1477
1530
  type: 'object',
1478
1531
  properties: {
@@ -1535,7 +1588,7 @@ export const hooksBuildAgents = {
1535
1588
  // Transfer hook - transfer patterns from another project
1536
1589
  export const hooksTransfer = {
1537
1590
  name: 'hooks_transfer',
1538
- description: 'Transfer learned patterns from another project',
1591
+ description: 'Transfer learned patterns from another project Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1539
1592
  inputSchema: {
1540
1593
  type: 'object',
1541
1594
  properties: {
@@ -1617,7 +1670,7 @@ export const hooksTransfer = {
1617
1670
  // Session start hook - auto-starts daemon
1618
1671
  export const hooksSessionStart = {
1619
1672
  name: 'hooks_session-start',
1620
- description: 'Initialize a new session and auto-start daemon',
1673
+ description: 'Initialize a new session and auto-start daemon Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1621
1674
  inputSchema: {
1622
1675
  type: 'object',
1623
1676
  properties: {
@@ -1760,7 +1813,7 @@ export const hooksSessionStart = {
1760
1813
  // Session end hook - stops daemon
1761
1814
  export const hooksSessionEnd = {
1762
1815
  name: 'hooks_session-end',
1763
- description: 'End current session, stop daemon, and persist state',
1816
+ description: 'End current session, stop daemon, and persist state Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1764
1817
  inputSchema: {
1765
1818
  type: 'object',
1766
1819
  properties: {
@@ -1847,7 +1900,7 @@ export const hooksSessionEnd = {
1847
1900
  // Session restore hook
1848
1901
  export const hooksSessionRestore = {
1849
1902
  name: 'hooks_session-restore',
1850
- description: 'Restore a previous session',
1903
+ description: 'Restore a previous session Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1851
1904
  inputSchema: {
1852
1905
  type: 'object',
1853
1906
  properties: {
@@ -1889,7 +1942,7 @@ export const hooksSessionRestore = {
1889
1942
  // Notify hook - cross-agent notifications
1890
1943
  export const hooksNotify = {
1891
1944
  name: 'hooks_notify',
1892
- description: 'Send cross-agent notification',
1945
+ description: 'Send cross-agent notification Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1893
1946
  inputSchema: {
1894
1947
  type: 'object',
1895
1948
  properties: {
@@ -1928,7 +1981,7 @@ export const hooksNotify = {
1928
1981
  // Init hook - initialize hooks in project
1929
1982
  export const hooksInit = {
1930
1983
  name: 'hooks_init',
1931
- description: 'Initialize hooks in project with .claude/settings.json',
1984
+ description: 'Initialize hooks in project with .claude/settings.json Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1932
1985
  inputSchema: {
1933
1986
  type: 'object',
1934
1987
  properties: {
@@ -1966,7 +2019,7 @@ export const hooksInit = {
1966
2019
  // Intelligence hook - RuVector intelligence system
1967
2020
  export const hooksIntelligence = {
1968
2021
  name: 'hooks_intelligence',
1969
- description: 'RuVector intelligence system status (shows REAL metrics from memory store)',
2022
+ description: 'RuVector intelligence system status (shows REAL metrics from memory store) Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
1970
2023
  inputSchema: {
1971
2024
  type: 'object',
1972
2025
  properties: {
@@ -2107,7 +2160,7 @@ export const hooksIntelligence = {
2107
2160
  // Intelligence reset hook
2108
2161
  export const hooksIntelligenceReset = {
2109
2162
  name: 'hooks_intelligence-reset',
2110
- description: 'Reset intelligence learning state',
2163
+ description: 'Reset intelligence learning state Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
2111
2164
  inputSchema: {
2112
2165
  type: 'object',
2113
2166
  properties: {},
@@ -2174,7 +2227,7 @@ export const hooksIntelligenceReset = {
2174
2227
  // Intelligence trajectory hooks - REAL implementation using activeTrajectories
2175
2228
  export const hooksTrajectoryStart = {
2176
2229
  name: 'hooks_intelligence_trajectory-start',
2177
- description: 'Begin SONA trajectory for reinforcement learning',
2230
+ description: 'Begin SONA trajectory for reinforcement learning Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
2178
2231
  inputSchema: {
2179
2232
  type: 'object',
2180
2233
  properties: {
@@ -2235,7 +2288,7 @@ export const hooksTrajectoryStart = {
2235
2288
  };
2236
2289
  export const hooksTrajectoryStep = {
2237
2290
  name: 'hooks_intelligence_trajectory-step',
2238
- description: 'Record step in trajectory for reinforcement learning',
2291
+ description: 'Record step in trajectory for reinforcement learning Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
2239
2292
  inputSchema: {
2240
2293
  type: 'object',
2241
2294
  properties: {
@@ -2288,7 +2341,7 @@ export const hooksTrajectoryStep = {
2288
2341
  };
2289
2342
  export const hooksTrajectoryEnd = {
2290
2343
  name: 'hooks_intelligence_trajectory-end',
2291
- description: 'End trajectory and trigger SONA learning with EWC++',
2344
+ description: 'End trajectory and trigger SONA learning with EWC++ Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
2292
2345
  inputSchema: {
2293
2346
  type: 'object',
2294
2347
  properties: {
@@ -2432,7 +2485,7 @@ export const hooksTrajectoryEnd = {
2432
2485
  // Pattern store/search hooks - REAL implementation using storeEntry
2433
2486
  export const hooksPatternStore = {
2434
2487
  name: 'hooks_intelligence_pattern-store',
2435
- description: 'Store pattern in ReasoningBank (HNSW-indexed)',
2488
+ description: 'Store pattern in ReasoningBank (HNSW-indexed) Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
2436
2489
  inputSchema: {
2437
2490
  type: 'object',
2438
2491
  properties: {
@@ -2514,7 +2567,7 @@ export const hooksPatternStore = {
2514
2567
  };
2515
2568
  export const hooksPatternSearch = {
2516
2569
  name: 'hooks_intelligence_pattern-search',
2517
- description: 'Search patterns using REAL vector search (HNSW when available, brute-force fallback)',
2570
+ description: 'Search patterns using REAL vector search (HNSW when available, brute-force fallback) Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
2518
2571
  inputSchema: {
2519
2572
  type: 'object',
2520
2573
  properties: {
@@ -2623,7 +2676,7 @@ export const hooksPatternSearch = {
2623
2676
  // Intelligence stats hook
2624
2677
  export const hooksIntelligenceStats = {
2625
2678
  name: 'hooks_intelligence_stats',
2626
- description: 'Get RuVector intelligence layer statistics',
2679
+ description: 'Get RuVector intelligence layer statistics Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
2627
2680
  inputSchema: {
2628
2681
  type: 'object',
2629
2682
  properties: {
@@ -2826,7 +2879,7 @@ export const hooksIntelligenceStats = {
2826
2879
  // Intelligence learn hook
2827
2880
  export const hooksIntelligenceLearn = {
2828
2881
  name: 'hooks_intelligence_learn',
2829
- description: 'Force immediate SONA learning cycle with EWC++ consolidation',
2882
+ description: 'Force immediate SONA learning cycle with EWC++ consolidation Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
2830
2883
  inputSchema: {
2831
2884
  type: 'object',
2832
2885
  properties: {
@@ -2897,7 +2950,7 @@ export const hooksIntelligenceLearn = {
2897
2950
  // Intelligence attention hook
2898
2951
  export const hooksIntelligenceAttention = {
2899
2952
  name: 'hooks_intelligence_attention',
2900
- description: 'Compute attention-weighted similarity using MoE/Flash/Hyperbolic',
2953
+ description: 'Compute attention-weighted similarity using MoE/Flash/Hyperbolic Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
2901
2954
  inputSchema: {
2902
2955
  type: 'object',
2903
2956
  properties: {
@@ -3309,7 +3362,7 @@ function detectWorkerTriggers(text) {
3309
3362
  // Worker list tool
3310
3363
  export const hooksWorkerList = {
3311
3364
  name: 'hooks_worker-list',
3312
- description: 'List all 12 background workers with status and capabilities',
3365
+ description: 'List all 12 background workers with status and capabilities Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
3313
3366
  inputSchema: {
3314
3367
  type: 'object',
3315
3368
  properties: {
@@ -3352,7 +3405,7 @@ export const hooksWorkerList = {
3352
3405
  // Worker dispatch tool
3353
3406
  export const hooksWorkerDispatch = {
3354
3407
  name: 'hooks_worker-dispatch',
3355
- description: 'Dispatch a background worker for analysis/optimization tasks',
3408
+ description: 'Dispatch a background worker for analysis/optimization tasks Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
3356
3409
  inputSchema: {
3357
3410
  type: 'object',
3358
3411
  properties: {
@@ -3422,16 +3475,37 @@ export const hooksWorkerDispatch = {
3422
3475
  activeWorkers.set(workerId, worker);
3423
3476
  // Determine honest status
3424
3477
  let reportedStatus;
3425
- let note;
3478
+ let note = '';
3426
3479
  if (!daemonAlive) {
3427
3480
  reportedStatus = 'no-daemon';
3428
3481
  note = 'No worker daemon detected. Run `claude-flow daemon start` to enable real worker execution. The dispatch was recorded in-process but no actual work will run.';
3429
3482
  }
3430
3483
  else if (background) {
3431
- // Daemon is alive record the queued worker. The daemon polls activeWorkers
3432
- // via its own state file, so this constitutes a real queue entry.
3433
- reportedStatus = 'queued';
3434
- note = `Worker queued for daemon (pid ${daemonPid}). Poll hooks_worker-status to track progression do not assume completion until status === "completed".`;
3484
+ // #1845: write a durable queue file the daemon polls every 5s. Until
3485
+ // 3.7.0-alpha.11 the dispatch only updated a process-local Map that
3486
+ // the daemon (separate process) could never see, so `queued` was a
3487
+ // lie. The queue file makes it real and inspectable on disk.
3488
+ const queueDir = join(cwd, '.claude-flow', 'daemon-queue');
3489
+ const queuePath = join(queueDir, `${workerId}.json`);
3490
+ let queueWritten = false;
3491
+ try {
3492
+ if (!existsSync(queueDir))
3493
+ mkdirSync(queueDir, { recursive: true });
3494
+ writeFileSync(queuePath, JSON.stringify({ workerId, trigger, context, priority, enqueuedAt: new Date().toISOString() }, null, 2));
3495
+ queueWritten = true;
3496
+ }
3497
+ catch (err) {
3498
+ // Filesystem error — fall back to mcp-only status so we never
3499
+ // claim queued without proof.
3500
+ note = `Daemon detected (pid ${daemonPid}) but queue write to ${queuePath} failed: ${err.message}. Worker recorded in-process only; use \`ruflo daemon trigger -w ${trigger}\` to run synchronously.`;
3501
+ }
3502
+ if (queueWritten) {
3503
+ reportedStatus = 'queued';
3504
+ note = `Worker queued for daemon (pid ${daemonPid}) at ${queuePath}. Daemon polls every 5s; processed entries move to .claude-flow/daemon-queue/.processed/. Poll hooks_worker-status until status === "completed".`;
3505
+ }
3506
+ else {
3507
+ reportedStatus = 'mcp-only';
3508
+ }
3435
3509
  }
3436
3510
  else {
3437
3511
  // Synchronous mode without a runner — be honest about it
@@ -3465,7 +3539,7 @@ export const hooksWorkerDispatch = {
3465
3539
  // Worker status tool
3466
3540
  export const hooksWorkerStatus = {
3467
3541
  name: 'hooks_worker-status',
3468
- description: 'Get status of a specific worker or all active workers',
3542
+ description: 'Get status of a specific worker or all active workers Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
3469
3543
  inputSchema: {
3470
3544
  type: 'object',
3471
3545
  properties: {
@@ -3522,7 +3596,7 @@ export const hooksWorkerStatus = {
3522
3596
  // Worker detect tool - detect triggers from prompt
3523
3597
  export const hooksWorkerDetect = {
3524
3598
  name: 'hooks_worker-detect',
3525
- description: 'Detect worker triggers from user prompt (for UserPromptSubmit hook)',
3599
+ description: 'Detect worker triggers from user prompt (for UserPromptSubmit hook) Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
3526
3600
  inputSchema: {
3527
3601
  type: 'object',
3528
3602
  properties: {
@@ -3601,7 +3675,7 @@ async function getModelRouterInstance() {
3601
3675
  // Model route tool - intelligent model selection
3602
3676
  export const hooksModelRoute = {
3603
3677
  name: 'hooks_model-route',
3604
- description: 'Route task to optimal Claude model (haiku/sonnet/opus) based on complexity',
3678
+ description: 'Route task to optimal Claude model (haiku/sonnet/opus) based on complexity Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
3605
3679
  inputSchema: {
3606
3680
  type: 'object',
3607
3681
  properties: {
@@ -3647,7 +3721,7 @@ export const hooksModelRoute = {
3647
3721
  // Model route outcome - record outcome for learning
3648
3722
  export const hooksModelOutcome = {
3649
3723
  name: 'hooks_model-outcome',
3650
- description: 'Record model routing outcome for learning',
3724
+ description: 'Record model routing outcome for learning Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
3651
3725
  inputSchema: {
3652
3726
  type: 'object',
3653
3727
  properties: {
@@ -3682,7 +3756,7 @@ export const hooksModelOutcome = {
3682
3756
  // Model router stats
3683
3757
  export const hooksModelStats = {
3684
3758
  name: 'hooks_model-stats',
3685
- description: 'Get model routing statistics',
3759
+ description: 'Get model routing statistics Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
3686
3760
  inputSchema: {
3687
3761
  type: 'object',
3688
3762
  properties: {},
@@ -3719,7 +3793,7 @@ function analyzeComplexityFallback(task) {
3719
3793
  // Worker cancel tool
3720
3794
  export const hooksWorkerCancel = {
3721
3795
  name: 'hooks_worker-cancel',
3722
- description: 'Cancel a running worker',
3796
+ description: 'Cancel a running worker Use when native Bash hooks (via Claude Code\'s settings.json) are wrong because you need Ruflo-side state — pattern persistence, neural training signals, model-routing learning, cost tracking, audit chain. For one-off shell commands, plain Bash hooks are fine.',
3723
3797
  inputSchema: {
3724
3798
  type: 'object',
3725
3799
  properties: {
@@ -3758,8 +3832,69 @@ export const hooksWorkerCancel = {
3758
3832
  };
3759
3833
  },
3760
3834
  };
3835
+ // #1916: the `ruflo hooks teammate-idle` / `ruflo hooks task-completed` CLI
3836
+ // subcommands (Agent Teams hooks) referenced unregistered tools. Minimal
3837
+ // acknowledgement handlers with the shapes the CLI expects — auto-assignment
3838
+ // and pattern-learning are delegated to the task-queue consumer / intelligence
3839
+ // pipeline (a tracked #1916 follow-up).
3840
+ export const hooksTeammateIdle = {
3841
+ name: 'hooks_teammate-idle',
3842
+ description: 'Agent Teams hook — fired when a teammate agent finishes its turn; reports whether a pending task can be auto-assigned. Use when native Task is wrong because you have a persistent multi-agent team with a shared task list and want idle workers picked up automatically rather than re-spawning subagents. For a one-shot Task, native Task is fine. (Auto-assignment is delegated to the task-queue consumer — this acknowledges the event today.)',
3843
+ category: 'hooks',
3844
+ inputSchema: {
3845
+ type: 'object',
3846
+ properties: {
3847
+ teammateId: { type: 'string', description: 'ID of the idle teammate' },
3848
+ teamName: { type: 'string', description: 'Team name' },
3849
+ autoAssign: { type: 'boolean', description: 'Auto-assign a pending task if available' },
3850
+ checkTaskList: { type: 'boolean', description: 'Consult the shared task list' },
3851
+ timestamp: { type: 'number', description: 'Event timestamp (ms)' },
3852
+ },
3853
+ },
3854
+ handler: async (input) => {
3855
+ const teammateId = String(input.teammateId ?? '');
3856
+ return {
3857
+ success: true,
3858
+ teammateId,
3859
+ action: 'waiting',
3860
+ pendingTasks: 0,
3861
+ message: 'teammate-idle acknowledged; auto-assignment requires the task-queue consumer (#1916 follow-up)',
3862
+ };
3863
+ },
3864
+ };
3865
+ export const hooksTaskCompleted = {
3866
+ name: 'hooks_task-completed',
3867
+ description: 'Agent Teams hook — fired when a task is marked complete; records completion and (eventually) trains patterns + notifies the team lead. Use when native TodoWrite is wrong because the work was a persisted, agent-assigned task whose outcome should feed cross-session learning and team coordination. For an in-session checklist tick, native TodoWrite is fine. (Pattern-learning is delegated to the intelligence pipeline — this records the completion today.)',
3868
+ category: 'hooks',
3869
+ inputSchema: {
3870
+ type: 'object',
3871
+ properties: {
3872
+ taskId: { type: 'string', description: 'ID of the completed task' },
3873
+ teammateId: { type: 'string', description: 'Teammate that completed it' },
3874
+ success: { type: 'boolean', description: 'Whether the task succeeded' },
3875
+ quality: { type: 'number', description: 'Quality score 0-1' },
3876
+ trainPatterns: { type: 'boolean', description: 'Feed the outcome to the learning pipeline' },
3877
+ notifyLead: { type: 'boolean', description: 'Notify the team lead' },
3878
+ },
3879
+ required: ['taskId'],
3880
+ },
3881
+ handler: async (input) => {
3882
+ const taskId = String(input.taskId ?? '');
3883
+ const quality = typeof input.quality === 'number' ? input.quality : (input.success === false ? 0 : 1);
3884
+ return {
3885
+ success: true,
3886
+ taskId,
3887
+ patternsLearned: 0,
3888
+ leadNotified: input.notifyLead === true,
3889
+ metrics: { duration: 0, quality, learningUpdates: 0 },
3890
+ note: 'completion recorded; pattern-learning is delegated to the intelligence pipeline (#1916 follow-up)',
3891
+ };
3892
+ },
3893
+ };
3761
3894
  // Export all hooks tools
3762
3895
  export const hooksTools = [
3896
+ hooksTeammateIdle,
3897
+ hooksTaskCompleted,
3763
3898
  hooksPreEdit,
3764
3899
  hooksPostEdit,
3765
3900
  hooksPreCommand,