@claude-flow/cli 3.7.0-alpha.7 → 3.7.0-alpha.70

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 (262) 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 +51 -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/benchmark-cosign.d.ts +29 -0
  14. package/dist/src/commands/benchmark-cosign.d.ts.map +1 -0
  15. package/dist/src/commands/benchmark-cosign.js +222 -0
  16. package/dist/src/commands/benchmark-cosign.js.map +1 -0
  17. package/dist/src/commands/benchmark-verify.d.ts +21 -0
  18. package/dist/src/commands/benchmark-verify.d.ts.map +1 -0
  19. package/dist/src/commands/benchmark-verify.js +202 -0
  20. package/dist/src/commands/benchmark-verify.js.map +1 -0
  21. package/dist/src/commands/daemon.d.ts +20 -0
  22. package/dist/src/commands/daemon.d.ts.map +1 -1
  23. package/dist/src/commands/daemon.js +366 -7
  24. package/dist/src/commands/daemon.js.map +1 -1
  25. package/dist/src/commands/doctor.d.ts.map +1 -1
  26. package/dist/src/commands/doctor.js +224 -46
  27. package/dist/src/commands/doctor.js.map +1 -1
  28. package/dist/src/commands/embeddings.d.ts.map +1 -1
  29. package/dist/src/commands/embeddings.js +18 -9
  30. package/dist/src/commands/embeddings.js.map +1 -1
  31. package/dist/src/commands/hive-mind.d.ts.map +1 -1
  32. package/dist/src/commands/hive-mind.js +25 -7
  33. package/dist/src/commands/hive-mind.js.map +1 -1
  34. package/dist/src/commands/hooks.d.ts.map +1 -1
  35. package/dist/src/commands/hooks.js +56 -29
  36. package/dist/src/commands/hooks.js.map +1 -1
  37. package/dist/src/commands/memory.d.ts.map +1 -1
  38. package/dist/src/commands/memory.js +104 -3
  39. package/dist/src/commands/memory.js.map +1 -1
  40. package/dist/src/commands/start.js +1 -1
  41. package/dist/src/commands/start.js.map +1 -1
  42. package/dist/src/commands/swarm.js +1 -1
  43. package/dist/src/commands/swarm.js.map +1 -1
  44. package/dist/src/commands/task.d.ts.map +1 -1
  45. package/dist/src/commands/task.js +8 -4
  46. package/dist/src/commands/task.js.map +1 -1
  47. package/dist/src/config-adapter.js +1 -1
  48. package/dist/src/config-adapter.js.map +1 -1
  49. package/dist/src/index.d.ts +5 -1
  50. package/dist/src/index.d.ts.map +1 -1
  51. package/dist/src/index.js +61 -18
  52. package/dist/src/index.js.map +1 -1
  53. package/dist/src/init/executor.d.ts.map +1 -1
  54. package/dist/src/init/executor.js +92 -0
  55. package/dist/src/init/executor.js.map +1 -1
  56. package/dist/src/init/helpers-generator.d.ts.map +1 -1
  57. package/dist/src/init/helpers-generator.js +6 -2
  58. package/dist/src/init/helpers-generator.js.map +1 -1
  59. package/dist/src/init/mcp-generator.js +4 -4
  60. package/dist/src/init/mcp-generator.js.map +1 -1
  61. package/dist/src/init/settings-generator.d.ts.map +1 -1
  62. package/dist/src/init/settings-generator.js +78 -19
  63. package/dist/src/init/settings-generator.js.map +1 -1
  64. package/dist/src/init/statusline-generator.d.ts.map +1 -1
  65. package/dist/src/init/statusline-generator.js +75 -31
  66. package/dist/src/init/statusline-generator.js.map +1 -1
  67. package/dist/src/init/types.d.ts +7 -0
  68. package/dist/src/init/types.d.ts.map +1 -1
  69. package/dist/src/init/types.js.map +1 -1
  70. package/dist/src/mcp-client.d.ts.map +1 -1
  71. package/dist/src/mcp-client.js +12 -0
  72. package/dist/src/mcp-client.js.map +1 -1
  73. package/dist/src/mcp-server.d.ts.map +1 -1
  74. package/dist/src/mcp-server.js +38 -5
  75. package/dist/src/mcp-server.js.map +1 -1
  76. package/dist/src/mcp-tools/agent-execute-core.d.ts +3 -2
  77. package/dist/src/mcp-tools/agent-execute-core.d.ts.map +1 -1
  78. package/dist/src/mcp-tools/agent-execute-core.js +16 -9
  79. package/dist/src/mcp-tools/agent-execute-core.js.map +1 -1
  80. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
  81. package/dist/src/mcp-tools/agent-tools.js +88 -11
  82. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  83. package/dist/src/mcp-tools/agentdb-tools.d.ts +3 -0
  84. package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -1
  85. package/dist/src/mcp-tools/agentdb-tools.js +206 -21
  86. package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
  87. package/dist/src/mcp-tools/analyze-tools.js +6 -6
  88. package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
  89. package/dist/src/mcp-tools/autopilot-tools.js +10 -10
  90. package/dist/src/mcp-tools/autopilot-tools.js.map +1 -1
  91. package/dist/src/mcp-tools/browser-session-tools.d.ts.map +1 -1
  92. package/dist/src/mcp-tools/browser-session-tools.js +18 -7
  93. package/dist/src/mcp-tools/browser-session-tools.js.map +1 -1
  94. package/dist/src/mcp-tools/browser-tools.js +23 -23
  95. package/dist/src/mcp-tools/browser-tools.js.map +1 -1
  96. package/dist/src/mcp-tools/claims-tools.js +12 -12
  97. package/dist/src/mcp-tools/claims-tools.js.map +1 -1
  98. package/dist/src/mcp-tools/config-tools.js +6 -6
  99. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  100. package/dist/src/mcp-tools/coordination-tools.js +7 -7
  101. package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
  102. package/dist/src/mcp-tools/daa-tools.js +8 -8
  103. package/dist/src/mcp-tools/daa-tools.js.map +1 -1
  104. package/dist/src/mcp-tools/embeddings-tools.js +10 -10
  105. package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
  106. package/dist/src/mcp-tools/github-tools.js +5 -5
  107. package/dist/src/mcp-tools/github-tools.js.map +1 -1
  108. package/dist/src/mcp-tools/guidance-tools.js +21 -21
  109. package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
  110. package/dist/src/mcp-tools/hive-consensus-runtime.d.ts +149 -0
  111. package/dist/src/mcp-tools/hive-consensus-runtime.d.ts.map +1 -0
  112. package/dist/src/mcp-tools/hive-consensus-runtime.js +296 -0
  113. package/dist/src/mcp-tools/hive-consensus-runtime.js.map +1 -0
  114. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
  115. package/dist/src/mcp-tools/hive-mind-tools.js +53 -9
  116. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
  117. package/dist/src/mcp-tools/hooks-tools.d.ts +2 -0
  118. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  119. package/dist/src/mcp-tools/hooks-tools.js +179 -46
  120. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  121. package/dist/src/mcp-tools/managed-agent-tools.d.ts +22 -0
  122. package/dist/src/mcp-tools/managed-agent-tools.d.ts.map +1 -0
  123. package/dist/src/mcp-tools/managed-agent-tools.js +357 -0
  124. package/dist/src/mcp-tools/managed-agent-tools.js.map +1 -0
  125. package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
  126. package/dist/src/mcp-tools/memory-tools.js +490 -68
  127. package/dist/src/mcp-tools/memory-tools.js.map +1 -1
  128. package/dist/src/mcp-tools/neural-tools.js +6 -6
  129. package/dist/src/mcp-tools/neural-tools.js.map +1 -1
  130. package/dist/src/mcp-tools/performance-tools.js +6 -6
  131. package/dist/src/mcp-tools/performance-tools.js.map +1 -1
  132. package/dist/src/mcp-tools/progress-tools.js +4 -4
  133. package/dist/src/mcp-tools/progress-tools.js.map +1 -1
  134. package/dist/src/mcp-tools/ruvllm-tools.js +10 -10
  135. package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
  136. package/dist/src/mcp-tools/security-tools.d.ts.map +1 -1
  137. package/dist/src/mcp-tools/security-tools.js +34 -9
  138. package/dist/src/mcp-tools/security-tools.js.map +1 -1
  139. package/dist/src/mcp-tools/session-tools.d.ts.map +1 -1
  140. package/dist/src/mcp-tools/session-tools.js +130 -6
  141. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  142. package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
  143. package/dist/src/mcp-tools/swarm-tools.js +76 -7
  144. package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
  145. package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
  146. package/dist/src/mcp-tools/system-tools.js +91 -18
  147. package/dist/src/mcp-tools/system-tools.js.map +1 -1
  148. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
  149. package/dist/src/mcp-tools/task-tools.js +55 -7
  150. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  151. package/dist/src/mcp-tools/terminal-tools.js +5 -5
  152. package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
  153. package/dist/src/mcp-tools/transfer-tools.js +11 -11
  154. package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
  155. package/dist/src/mcp-tools/wasm-agent-tools.js +11 -11
  156. package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
  157. package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -1
  158. package/dist/src/mcp-tools/workflow-tools.js +118 -10
  159. package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
  160. package/dist/src/memory/ann-router-registry.d.ts +61 -0
  161. package/dist/src/memory/ann-router-registry.d.ts.map +1 -0
  162. package/dist/src/memory/ann-router-registry.js +72 -0
  163. package/dist/src/memory/ann-router-registry.js.map +1 -0
  164. package/dist/src/memory/diskann-registry.d.ts +56 -0
  165. package/dist/src/memory/diskann-registry.d.ts.map +1 -0
  166. package/dist/src/memory/diskann-registry.js +88 -0
  167. package/dist/src/memory/diskann-registry.js.map +1 -0
  168. package/dist/src/memory/memory-bridge.d.ts +69 -0
  169. package/dist/src/memory/memory-bridge.d.ts.map +1 -1
  170. package/dist/src/memory/memory-bridge.js +293 -5
  171. package/dist/src/memory/memory-bridge.js.map +1 -1
  172. package/dist/src/memory/memory-initializer.d.ts +8 -0
  173. package/dist/src/memory/memory-initializer.d.ts.map +1 -1
  174. package/dist/src/memory/memory-initializer.js +89 -16
  175. package/dist/src/memory/memory-initializer.js.map +1 -1
  176. package/dist/src/memory/sona-optimizer.d.ts.map +1 -1
  177. package/dist/src/memory/sona-optimizer.js +3 -0
  178. package/dist/src/memory/sona-optimizer.js.map +1 -1
  179. package/dist/src/parser.d.ts +9 -0
  180. package/dist/src/parser.d.ts.map +1 -1
  181. package/dist/src/parser.js +11 -0
  182. package/dist/src/parser.js.map +1 -1
  183. package/dist/src/plugins/store/discovery.d.ts +15 -4
  184. package/dist/src/plugins/store/discovery.d.ts.map +1 -1
  185. package/dist/src/plugins/store/discovery.js +40 -18
  186. package/dist/src/plugins/store/discovery.js.map +1 -1
  187. package/dist/src/ruvector/agent-wasm.d.ts.map +1 -1
  188. package/dist/src/ruvector/agent-wasm.js +4 -1
  189. package/dist/src/ruvector/agent-wasm.js.map +1 -1
  190. package/dist/src/ruvector/coverage-tools.js +6 -6
  191. package/dist/src/ruvector/coverage-tools.js.map +1 -1
  192. package/dist/src/services/headless-worker-executor.d.ts +6 -0
  193. package/dist/src/services/headless-worker-executor.d.ts.map +1 -1
  194. package/dist/src/services/headless-worker-executor.js +37 -3
  195. package/dist/src/services/headless-worker-executor.js.map +1 -1
  196. package/dist/src/services/worker-daemon.d.ts +80 -2
  197. package/dist/src/services/worker-daemon.d.ts.map +1 -1
  198. package/dist/src/services/worker-daemon.js +372 -11
  199. package/dist/src/services/worker-daemon.js.map +1 -1
  200. package/dist/tsconfig.tsbuildinfo +1 -1
  201. package/package.json +12 -8
  202. package/.claude/skills/agentdb-advanced/SKILL.md +0 -550
  203. package/.claude/skills/agentdb-learning/SKILL.md +0 -545
  204. package/.claude/skills/agentdb-memory-patterns/SKILL.md +0 -339
  205. package/.claude/skills/agentdb-optimization/SKILL.md +0 -509
  206. package/.claude/skills/agentdb-vector-search/SKILL.md +0 -339
  207. package/.claude/skills/agentic-jujutsu/SKILL.md +0 -645
  208. package/.claude/skills/aidefence-scan.md +0 -151
  209. package/.claude/skills/aidefence.yaml +0 -297
  210. package/.claude/skills/browser/SKILL.md +0 -204
  211. package/.claude/skills/flow-nexus-neural/SKILL.md +0 -738
  212. package/.claude/skills/flow-nexus-platform/SKILL.md +0 -1157
  213. package/.claude/skills/flow-nexus-swarm/SKILL.md +0 -610
  214. package/.claude/skills/github-code-review/SKILL.md +0 -1140
  215. package/.claude/skills/github-multi-repo/SKILL.md +0 -874
  216. package/.claude/skills/github-project-management/SKILL.md +0 -1277
  217. package/.claude/skills/github-release-management/SKILL.md +0 -1081
  218. package/.claude/skills/github-workflow-automation/SKILL.md +0 -1065
  219. package/.claude/skills/hive-mind-advanced/SKILL.md +0 -712
  220. package/.claude/skills/hooks-automation/SKILL.md +0 -1201
  221. package/.claude/skills/pair-programming/SKILL.md +0 -1202
  222. package/.claude/skills/performance-analysis/SKILL.md +0 -563
  223. package/.claude/skills/reasoningbank-agentdb/SKILL.md +0 -446
  224. package/.claude/skills/reasoningbank-intelligence/SKILL.md +0 -201
  225. package/.claude/skills/secure-review.md +0 -181
  226. package/.claude/skills/skill-builder/SKILL.md +0 -910
  227. package/.claude/skills/sparc-methodology/SKILL.md +0 -1115
  228. package/.claude/skills/stream-chain/SKILL.md +0 -563
  229. package/.claude/skills/swarm-advanced/SKILL.md +0 -973
  230. package/.claude/skills/swarm-orchestration/SKILL.md +0 -179
  231. package/.claude/skills/v3-cli-modernization/SKILL.md +0 -872
  232. package/.claude/skills/v3-core-implementation/SKILL.md +0 -797
  233. package/.claude/skills/v3-ddd-architecture/SKILL.md +0 -442
  234. package/.claude/skills/v3-integration-deep/SKILL.md +0 -241
  235. package/.claude/skills/v3-mcp-optimization/SKILL.md +0 -777
  236. package/.claude/skills/v3-memory-unification/SKILL.md +0 -174
  237. package/.claude/skills/v3-performance-optimization/SKILL.md +0 -390
  238. package/.claude/skills/v3-security-overhaul/SKILL.md +0 -82
  239. package/.claude/skills/v3-swarm-coordination/SKILL.md +0 -340
  240. package/.claude/skills/verification-quality/SKILL.md +0 -649
  241. package/.claude/skills/worker-benchmarks/skill.md +0 -135
  242. package/.claude/skills/worker-integration/skill.md +0 -154
  243. package/dist/src/ruvector/flash-attention.d.ts +0 -195
  244. package/dist/src/ruvector/flash-attention.d.ts.map +0 -1
  245. package/dist/src/ruvector/flash-attention.js +0 -643
  246. package/dist/src/ruvector/flash-attention.js.map +0 -1
  247. package/dist/src/ruvector/moe-router.d.ts +0 -206
  248. package/dist/src/ruvector/moe-router.d.ts.map +0 -1
  249. package/dist/src/ruvector/moe-router.js +0 -626
  250. package/dist/src/ruvector/moe-router.js.map +0 -1
  251. package/dist/src/services/event-stream.d.ts +0 -25
  252. package/dist/src/services/event-stream.d.ts.map +0 -1
  253. package/dist/src/services/event-stream.js +0 -27
  254. package/dist/src/services/event-stream.js.map +0 -1
  255. package/dist/src/services/loop-worker-runner.d.ts +0 -16
  256. package/dist/src/services/loop-worker-runner.d.ts.map +0 -1
  257. package/dist/src/services/loop-worker-runner.js +0 -34
  258. package/dist/src/services/loop-worker-runner.js.map +0 -1
  259. package/dist/src/services/runtime-capabilities.d.ts +0 -22
  260. package/dist/src/services/runtime-capabilities.d.ts.map +0 -1
  261. package/dist/src/services/runtime-capabilities.js +0 -45
  262. package/dist/src/services/runtime-capabilities.js.map +0 -1
@@ -571,7 +571,7 @@ function assessCommandRisk(command) {
571
571
  // MCP Tool implementations - return raw data for direct CLI use
572
572
  export const hooksPreEdit = {
573
573
  name: 'hooks_pre-edit',
574
- 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.',
575
575
  inputSchema: {
576
576
  type: 'object',
577
577
  properties: {
@@ -613,7 +613,7 @@ export const hooksPreEdit = {
613
613
  };
614
614
  export const hooksPostEdit = {
615
615
  name: 'hooks_post-edit',
616
- 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.',
617
617
  inputSchema: {
618
618
  type: 'object',
619
619
  properties: {
@@ -667,7 +667,7 @@ export const hooksPostEdit = {
667
667
  };
668
668
  export const hooksPreCommand = {
669
669
  name: 'hooks_pre-command',
670
- 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.',
671
671
  inputSchema: {
672
672
  type: 'object',
673
673
  properties: {
@@ -705,7 +705,7 @@ export const hooksPreCommand = {
705
705
  };
706
706
  export const hooksPostCommand = {
707
707
  name: 'hooks_post-command',
708
- 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.',
709
709
  inputSchema: {
710
710
  type: 'object',
711
711
  properties: {
@@ -761,7 +761,7 @@ export const hooksPostCommand = {
761
761
  };
762
762
  export const hooksRoute = {
763
763
  name: 'hooks_route',
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.',
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.',
765
765
  inputSchema: {
766
766
  type: 'object',
767
767
  properties: {
@@ -937,7 +937,7 @@ export const hooksRoute = {
937
937
  };
938
938
  export const hooksMetrics = {
939
939
  name: 'hooks_metrics',
940
- 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.',
941
941
  inputSchema: {
942
942
  type: 'object',
943
943
  properties: {
@@ -1002,7 +1002,7 @@ export const hooksMetrics = {
1002
1002
  };
1003
1003
  export const hooksList = {
1004
1004
  name: 'hooks_list',
1005
- 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.',
1006
1006
  inputSchema: {
1007
1007
  type: 'object',
1008
1008
  properties: {},
@@ -1049,7 +1049,7 @@ export const hooksList = {
1049
1049
  };
1050
1050
  export const hooksPreTask = {
1051
1051
  name: 'hooks_pre-task',
1052
- 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.',
1053
1053
  inputSchema: {
1054
1054
  type: 'object',
1055
1055
  properties: {
@@ -1147,7 +1147,7 @@ export const hooksPreTask = {
1147
1147
  };
1148
1148
  export const hooksPostTask = {
1149
1149
  name: 'hooks_post-task',
1150
- 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.',
1151
1151
  inputSchema: {
1152
1152
  type: 'object',
1153
1153
  properties: {
@@ -1299,7 +1299,7 @@ export const hooksPostTask = {
1299
1299
  // Explain hook - transparent routing explanation
1300
1300
  export const hooksExplain = {
1301
1301
  name: 'hooks_explain',
1302
- 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.',
1303
1303
  inputSchema: {
1304
1304
  type: 'object',
1305
1305
  properties: {
@@ -1377,7 +1377,7 @@ export const hooksExplain = {
1377
1377
  // Pretrain hook - repository analysis for intelligence bootstrap
1378
1378
  export const hooksPretrain = {
1379
1379
  name: 'hooks_pretrain',
1380
- 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.',
1381
1381
  inputSchema: {
1382
1382
  type: 'object',
1383
1383
  properties: {
@@ -1394,14 +1394,44 @@ export const hooksPretrain = {
1394
1394
  // (readdirSync/statSync already imported statically at the top.)
1395
1395
  const extCounts = {};
1396
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;
1397
1404
  let totalLines = 0;
1398
1405
  const maxDepth = depth === 'shallow' ? 2 : depth === 'deep' ? 6 : 4;
1399
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
+ };
1400
1423
  const scan = (dir, currentDepth) => {
1401
1424
  if (currentDepth > maxDepth)
1402
1425
  return;
1403
1426
  try {
1404
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
+ });
1405
1435
  for (const entry of entries) {
1406
1436
  if (entry.name.startsWith('.') || entry.name === 'node_modules' || entry.name === 'dist')
1407
1437
  continue;
@@ -1415,15 +1445,18 @@ export const hooksPretrain = {
1415
1445
  extCounts[ext] = (extCounts[ext] || 0) + 1;
1416
1446
  filesAnalyzed++;
1417
1447
  // For code files, count lines and extract imports
1418
- if (['.ts', '.js', '.py', '.go', '.rs', '.java'].includes(ext)) {
1448
+ if (['.ts', '.js', '.tsx', '.jsx', '.mjs', '.cjs', '.py', '.go', '.rs', '.java'].includes(ext)) {
1419
1449
  try {
1420
1450
  const content = readFileSync(full, 'utf-8');
1421
1451
  const lines = content.split('\n');
1422
1452
  totalLines += lines.length;
1423
- // Extract import patterns (first 50 files max for performance)
1424
- if (filesAnalyzed <= 50) {
1425
- for (const line of lines.slice(0, 30)) {
1426
- 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('))) {
1427
1460
  const trimmed = line.trim();
1428
1461
  if (trimmed.length < 120 && !patterns.includes(trimmed))
1429
1462
  patterns.push(trimmed);
@@ -1455,6 +1488,17 @@ export const hooksPretrain = {
1455
1488
  patternsStored = patterns.length;
1456
1489
  }
1457
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
+ }
1458
1502
  return {
1459
1503
  success: true,
1460
1504
  _real: true,
@@ -1467,14 +1511,21 @@ export const hooksPretrain = {
1467
1511
  patternsExtracted: patterns.length,
1468
1512
  patternsStored,
1469
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
+ },
1470
1520
  },
1521
+ ...(note ? { note } : {}),
1471
1522
  };
1472
1523
  },
1473
1524
  };
1474
1525
  // Build agents hook - generate optimized agent configs
1475
1526
  export const hooksBuildAgents = {
1476
1527
  name: 'hooks_build-agents',
1477
- 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.',
1478
1529
  inputSchema: {
1479
1530
  type: 'object',
1480
1531
  properties: {
@@ -1537,7 +1588,7 @@ export const hooksBuildAgents = {
1537
1588
  // Transfer hook - transfer patterns from another project
1538
1589
  export const hooksTransfer = {
1539
1590
  name: 'hooks_transfer',
1540
- 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.',
1541
1592
  inputSchema: {
1542
1593
  type: 'object',
1543
1594
  properties: {
@@ -1619,7 +1670,7 @@ export const hooksTransfer = {
1619
1670
  // Session start hook - auto-starts daemon
1620
1671
  export const hooksSessionStart = {
1621
1672
  name: 'hooks_session-start',
1622
- 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.',
1623
1674
  inputSchema: {
1624
1675
  type: 'object',
1625
1676
  properties: {
@@ -1762,7 +1813,7 @@ export const hooksSessionStart = {
1762
1813
  // Session end hook - stops daemon
1763
1814
  export const hooksSessionEnd = {
1764
1815
  name: 'hooks_session-end',
1765
- 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.',
1766
1817
  inputSchema: {
1767
1818
  type: 'object',
1768
1819
  properties: {
@@ -1849,7 +1900,7 @@ export const hooksSessionEnd = {
1849
1900
  // Session restore hook
1850
1901
  export const hooksSessionRestore = {
1851
1902
  name: 'hooks_session-restore',
1852
- 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.',
1853
1904
  inputSchema: {
1854
1905
  type: 'object',
1855
1906
  properties: {
@@ -1891,7 +1942,7 @@ export const hooksSessionRestore = {
1891
1942
  // Notify hook - cross-agent notifications
1892
1943
  export const hooksNotify = {
1893
1944
  name: 'hooks_notify',
1894
- 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.',
1895
1946
  inputSchema: {
1896
1947
  type: 'object',
1897
1948
  properties: {
@@ -1930,7 +1981,7 @@ export const hooksNotify = {
1930
1981
  // Init hook - initialize hooks in project
1931
1982
  export const hooksInit = {
1932
1983
  name: 'hooks_init',
1933
- 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.',
1934
1985
  inputSchema: {
1935
1986
  type: 'object',
1936
1987
  properties: {
@@ -1968,7 +2019,7 @@ export const hooksInit = {
1968
2019
  // Intelligence hook - RuVector intelligence system
1969
2020
  export const hooksIntelligence = {
1970
2021
  name: 'hooks_intelligence',
1971
- 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.',
1972
2023
  inputSchema: {
1973
2024
  type: 'object',
1974
2025
  properties: {
@@ -2109,7 +2160,7 @@ export const hooksIntelligence = {
2109
2160
  // Intelligence reset hook
2110
2161
  export const hooksIntelligenceReset = {
2111
2162
  name: 'hooks_intelligence-reset',
2112
- 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.',
2113
2164
  inputSchema: {
2114
2165
  type: 'object',
2115
2166
  properties: {},
@@ -2176,7 +2227,7 @@ export const hooksIntelligenceReset = {
2176
2227
  // Intelligence trajectory hooks - REAL implementation using activeTrajectories
2177
2228
  export const hooksTrajectoryStart = {
2178
2229
  name: 'hooks_intelligence_trajectory-start',
2179
- 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.',
2180
2231
  inputSchema: {
2181
2232
  type: 'object',
2182
2233
  properties: {
@@ -2237,7 +2288,7 @@ export const hooksTrajectoryStart = {
2237
2288
  };
2238
2289
  export const hooksTrajectoryStep = {
2239
2290
  name: 'hooks_intelligence_trajectory-step',
2240
- 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.',
2241
2292
  inputSchema: {
2242
2293
  type: 'object',
2243
2294
  properties: {
@@ -2290,7 +2341,7 @@ export const hooksTrajectoryStep = {
2290
2341
  };
2291
2342
  export const hooksTrajectoryEnd = {
2292
2343
  name: 'hooks_intelligence_trajectory-end',
2293
- 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.',
2294
2345
  inputSchema: {
2295
2346
  type: 'object',
2296
2347
  properties: {
@@ -2434,7 +2485,7 @@ export const hooksTrajectoryEnd = {
2434
2485
  // Pattern store/search hooks - REAL implementation using storeEntry
2435
2486
  export const hooksPatternStore = {
2436
2487
  name: 'hooks_intelligence_pattern-store',
2437
- 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.',
2438
2489
  inputSchema: {
2439
2490
  type: 'object',
2440
2491
  properties: {
@@ -2516,7 +2567,7 @@ export const hooksPatternStore = {
2516
2567
  };
2517
2568
  export const hooksPatternSearch = {
2518
2569
  name: 'hooks_intelligence_pattern-search',
2519
- 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.',
2520
2571
  inputSchema: {
2521
2572
  type: 'object',
2522
2573
  properties: {
@@ -2625,7 +2676,7 @@ export const hooksPatternSearch = {
2625
2676
  // Intelligence stats hook
2626
2677
  export const hooksIntelligenceStats = {
2627
2678
  name: 'hooks_intelligence_stats',
2628
- 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.',
2629
2680
  inputSchema: {
2630
2681
  type: 'object',
2631
2682
  properties: {
@@ -2828,7 +2879,7 @@ export const hooksIntelligenceStats = {
2828
2879
  // Intelligence learn hook
2829
2880
  export const hooksIntelligenceLearn = {
2830
2881
  name: 'hooks_intelligence_learn',
2831
- 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.',
2832
2883
  inputSchema: {
2833
2884
  type: 'object',
2834
2885
  properties: {
@@ -2899,7 +2950,7 @@ export const hooksIntelligenceLearn = {
2899
2950
  // Intelligence attention hook
2900
2951
  export const hooksIntelligenceAttention = {
2901
2952
  name: 'hooks_intelligence_attention',
2902
- 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.',
2903
2954
  inputSchema: {
2904
2955
  type: 'object',
2905
2956
  properties: {
@@ -3311,7 +3362,7 @@ function detectWorkerTriggers(text) {
3311
3362
  // Worker list tool
3312
3363
  export const hooksWorkerList = {
3313
3364
  name: 'hooks_worker-list',
3314
- 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.',
3315
3366
  inputSchema: {
3316
3367
  type: 'object',
3317
3368
  properties: {
@@ -3354,7 +3405,7 @@ export const hooksWorkerList = {
3354
3405
  // Worker dispatch tool
3355
3406
  export const hooksWorkerDispatch = {
3356
3407
  name: 'hooks_worker-dispatch',
3357
- 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.',
3358
3409
  inputSchema: {
3359
3410
  type: 'object',
3360
3411
  properties: {
@@ -3424,16 +3475,37 @@ export const hooksWorkerDispatch = {
3424
3475
  activeWorkers.set(workerId, worker);
3425
3476
  // Determine honest status
3426
3477
  let reportedStatus;
3427
- let note;
3478
+ let note = '';
3428
3479
  if (!daemonAlive) {
3429
3480
  reportedStatus = 'no-daemon';
3430
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.';
3431
3482
  }
3432
3483
  else if (background) {
3433
- // Daemon is alive record the queued worker. The daemon polls activeWorkers
3434
- // via its own state file, so this constitutes a real queue entry.
3435
- reportedStatus = 'queued';
3436
- 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
+ }
3437
3509
  }
3438
3510
  else {
3439
3511
  // Synchronous mode without a runner — be honest about it
@@ -3467,7 +3539,7 @@ export const hooksWorkerDispatch = {
3467
3539
  // Worker status tool
3468
3540
  export const hooksWorkerStatus = {
3469
3541
  name: 'hooks_worker-status',
3470
- 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.',
3471
3543
  inputSchema: {
3472
3544
  type: 'object',
3473
3545
  properties: {
@@ -3524,7 +3596,7 @@ export const hooksWorkerStatus = {
3524
3596
  // Worker detect tool - detect triggers from prompt
3525
3597
  export const hooksWorkerDetect = {
3526
3598
  name: 'hooks_worker-detect',
3527
- 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.',
3528
3600
  inputSchema: {
3529
3601
  type: 'object',
3530
3602
  properties: {
@@ -3603,7 +3675,7 @@ async function getModelRouterInstance() {
3603
3675
  // Model route tool - intelligent model selection
3604
3676
  export const hooksModelRoute = {
3605
3677
  name: 'hooks_model-route',
3606
- 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.',
3607
3679
  inputSchema: {
3608
3680
  type: 'object',
3609
3681
  properties: {
@@ -3649,7 +3721,7 @@ export const hooksModelRoute = {
3649
3721
  // Model route outcome - record outcome for learning
3650
3722
  export const hooksModelOutcome = {
3651
3723
  name: 'hooks_model-outcome',
3652
- 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.',
3653
3725
  inputSchema: {
3654
3726
  type: 'object',
3655
3727
  properties: {
@@ -3684,7 +3756,7 @@ export const hooksModelOutcome = {
3684
3756
  // Model router stats
3685
3757
  export const hooksModelStats = {
3686
3758
  name: 'hooks_model-stats',
3687
- 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.',
3688
3760
  inputSchema: {
3689
3761
  type: 'object',
3690
3762
  properties: {},
@@ -3721,7 +3793,7 @@ function analyzeComplexityFallback(task) {
3721
3793
  // Worker cancel tool
3722
3794
  export const hooksWorkerCancel = {
3723
3795
  name: 'hooks_worker-cancel',
3724
- 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.',
3725
3797
  inputSchema: {
3726
3798
  type: 'object',
3727
3799
  properties: {
@@ -3760,8 +3832,69 @@ export const hooksWorkerCancel = {
3760
3832
  };
3761
3833
  },
3762
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
+ };
3763
3894
  // Export all hooks tools
3764
3895
  export const hooksTools = [
3896
+ hooksTeammateIdle,
3897
+ hooksTaskCompleted,
3765
3898
  hooksPreEdit,
3766
3899
  hooksPostEdit,
3767
3900
  hooksPreCommand,