claude-flow 3.71.4 → 3.72.1

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 (118) hide show
  1. package/.claude/helpers/hook-handler.cjs +23 -10
  2. package/.claude/helpers/statusline.cjs +29 -14
  3. package/README.md +18 -3
  4. package/README.zh-CN.md +16 -3
  5. package/node_modules/@claude-flow/codex/.agents/skills/fast-code-edits/SKILL.md +42 -0
  6. package/node_modules/@claude-flow/codex/.agents/skills/graph-mincut/SKILL.md +42 -0
  7. package/node_modules/@claude-flow/codex/.agents/skills/injection-defense/SKILL.md +45 -0
  8. package/node_modules/@claude-flow/codex/.agents/skills/lora-learning/SKILL.md +39 -0
  9. package/node_modules/@claude-flow/codex/.agents/skills/sublinear-solver/SKILL.md +38 -0
  10. package/node_modules/@claude-flow/codex/.agents/skills/vector-quantization/SKILL.md +49 -0
  11. package/node_modules/@claude-flow/codex/dist/generators/skill-md.d.ts.map +1 -1
  12. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js +6 -0
  13. package/node_modules/@claude-flow/codex/dist/generators/skill-md.js.map +1 -1
  14. package/node_modules/@claude-flow/codex/dist/index.d.ts +3 -3
  15. package/node_modules/@claude-flow/codex/dist/index.js +1 -1
  16. package/node_modules/@claude-flow/codex/dist/templates/index.d.ts.map +1 -1
  17. package/node_modules/@claude-flow/codex/dist/templates/index.js +37 -0
  18. package/node_modules/@claude-flow/codex/dist/templates/index.js.map +1 -1
  19. package/node_modules/@claude-flow/codex/dist/types.d.ts +1 -1
  20. package/node_modules/@claude-flow/codex/dist/types.d.ts.map +1 -1
  21. package/node_modules/@claude-flow/codex/package.json +1 -1
  22. package/package.json +9 -6
  23. package/v3/@claude-flow/cli/README.md +18 -3
  24. package/v3/@claude-flow/cli/bin/cli.js +13 -18
  25. package/v3/@claude-flow/cli/bin/mcp-server.js +13 -18
  26. package/v3/@claude-flow/cli/catalog-manifest.json +4 -4
  27. package/v3/@claude-flow/cli/dist/src/appliance/ruvllm-bridge.d.ts +6 -2
  28. package/v3/@claude-flow/cli/dist/src/appliance/ruvllm-bridge.js +13 -8
  29. package/v3/@claude-flow/cli/dist/src/appliance/rvfa-distribution.js +2 -2
  30. package/v3/@claude-flow/cli/dist/src/benchmarks/gaia-critic.d.ts +1 -7
  31. package/v3/@claude-flow/cli/dist/src/benchmarks/gaia-critic.js +1 -7
  32. package/v3/@claude-flow/cli/dist/src/benchmarks/gaia-decomposer.d.ts +1 -8
  33. package/v3/@claude-flow/cli/dist/src/benchmarks/gaia-decomposer.js +1 -8
  34. package/v3/@claude-flow/cli/dist/src/commands/agent-wasm.js +2 -2
  35. package/v3/@claude-flow/cli/dist/src/commands/analyze.js +1 -1
  36. package/v3/@claude-flow/cli/dist/src/commands/daemon.js +1 -1
  37. package/v3/@claude-flow/cli/dist/src/commands/doctor.js +3 -2
  38. package/v3/@claude-flow/cli/dist/src/commands/guidance.js +9 -9
  39. package/v3/@claude-flow/cli/dist/src/commands/hooks.js +13 -8
  40. package/v3/@claude-flow/cli/dist/src/commands/init.js +16 -16
  41. package/v3/@claude-flow/cli/dist/src/commands/neural.js +87 -77
  42. package/v3/@claude-flow/cli/dist/src/commands/route.js +1 -1
  43. package/v3/@claude-flow/cli/dist/src/commands/ruvector/backup.js +7 -5
  44. package/v3/@claude-flow/cli/dist/src/commands/ruvector/benchmark.js +6 -1
  45. package/v3/@claude-flow/cli/dist/src/commands/ruvector/import.js +19 -5
  46. package/v3/@claude-flow/cli/dist/src/commands/ruvector/init.js +1 -1
  47. package/v3/@claude-flow/cli/dist/src/commands/start.js +1 -1
  48. package/v3/@claude-flow/cli/dist/src/commands/status.js +1 -1
  49. package/v3/@claude-flow/cli/dist/src/commands/task.js +18 -1
  50. package/v3/@claude-flow/cli/dist/src/commands/update.js +1 -1
  51. package/v3/@claude-flow/cli/dist/src/funnel/local-signals.js +7 -2
  52. package/v3/@claude-flow/cli/dist/src/init/executor.js +13 -0
  53. package/v3/@claude-flow/cli/dist/src/init/types.d.ts +6 -0
  54. package/v3/@claude-flow/cli/dist/src/init/types.js +3 -0
  55. package/v3/@claude-flow/cli/dist/src/mcp-client.js +2 -0
  56. package/v3/@claude-flow/cli/dist/src/mcp-protocol.d.ts +90 -0
  57. package/v3/@claude-flow/cli/dist/src/mcp-protocol.js +179 -0
  58. package/v3/@claude-flow/cli/dist/src/mcp-server.d.ts +1 -0
  59. package/v3/@claude-flow/cli/dist/src/mcp-server.js +20 -22
  60. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-execute-core.js +9 -1
  61. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.d.ts +13 -0
  62. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.js +59 -8
  63. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-tools.js +34 -2
  64. package/v3/@claude-flow/cli/dist/src/mcp-tools/browser-argv.d.ts +9 -0
  65. package/v3/@claude-flow/cli/dist/src/mcp-tools/browser-argv.js +33 -0
  66. package/v3/@claude-flow/cli/dist/src/mcp-tools/browser-session-tools.js +4 -0
  67. package/v3/@claude-flow/cli/dist/src/mcp-tools/browser-tools.js +12 -2
  68. package/v3/@claude-flow/cli/dist/src/mcp-tools/coordination-tools.js +5 -4
  69. package/v3/@claude-flow/cli/dist/src/mcp-tools/embeddings-tools.js +12 -4
  70. package/v3/@claude-flow/cli/dist/src/mcp-tools/fast-apply-tools.d.ts +4 -0
  71. package/v3/@claude-flow/cli/dist/src/mcp-tools/fast-apply-tools.js +85 -0
  72. package/v3/@claude-flow/cli/dist/src/mcp-tools/glob-exclusions.d.ts +6 -0
  73. package/v3/@claude-flow/cli/dist/src/mcp-tools/glob-exclusions.js +81 -0
  74. package/v3/@claude-flow/cli/dist/src/mcp-tools/hive-mind-tools.js +104 -35
  75. package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +14 -38
  76. package/v3/@claude-flow/cli/dist/src/mcp-tools/import-limits.d.ts +4 -0
  77. package/v3/@claude-flow/cli/dist/src/mcp-tools/import-limits.js +28 -0
  78. package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +21 -42
  79. package/v3/@claude-flow/cli/dist/src/mcp-tools/metaharness-tools.js +1 -1
  80. package/v3/@claude-flow/cli/dist/src/mcp-tools/performance-tools.js +7 -2
  81. package/v3/@claude-flow/cli/dist/src/mcp-tools/realpath-containment.d.ts +3 -0
  82. package/v3/@claude-flow/cli/dist/src/mcp-tools/realpath-containment.js +39 -0
  83. package/v3/@claude-flow/cli/dist/src/mcp-tools/record-store.d.ts +8 -0
  84. package/v3/@claude-flow/cli/dist/src/mcp-tools/record-store.js +98 -1
  85. package/v3/@claude-flow/cli/dist/src/mcp-tools/security-tools.d.ts +9 -0
  86. package/v3/@claude-flow/cli/dist/src/mcp-tools/security-tools.js +39 -3
  87. package/v3/@claude-flow/cli/dist/src/mcp-tools/session-tools.js +5 -3
  88. package/v3/@claude-flow/cli/dist/src/mcp-tools/swarm-tools.js +35 -17
  89. package/v3/@claude-flow/cli/dist/src/mcp-tools/task-tools.js +68 -5
  90. package/v3/@claude-flow/cli/dist/src/mcp-tools/terminal-tools.js +9 -0
  91. package/v3/@claude-flow/cli/dist/src/mcp-tools/workflow-tools.js +13 -12
  92. package/v3/@claude-flow/cli/dist/src/mcp-tools/x-federation-join.js +55 -14
  93. package/v3/@claude-flow/cli/dist/src/memory/intelligence.d.ts +11 -0
  94. package/v3/@claude-flow/cli/dist/src/memory/intelligence.js +84 -6
  95. package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.d.ts +6 -2
  96. package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +15 -6
  97. package/v3/@claude-flow/cli/dist/src/mods/command-registry/schema.d.ts +12 -12
  98. package/v3/@claude-flow/cli/dist/src/ruvector/ast-analyzer.d.ts +1 -2
  99. package/v3/@claude-flow/cli/dist/src/ruvector/ast-analyzer.js +4 -12
  100. package/v3/@claude-flow/cli/dist/src/ruvector/coverage-router.d.ts +1 -2
  101. package/v3/@claude-flow/cli/dist/src/ruvector/coverage-router.js +4 -12
  102. package/v3/@claude-flow/cli/dist/src/ruvector/diff-classifier.d.ts +1 -2
  103. package/v3/@claude-flow/cli/dist/src/ruvector/diff-classifier.js +3 -12
  104. package/v3/@claude-flow/cli/dist/src/ruvector/fast-apply.d.ts +46 -0
  105. package/v3/@claude-flow/cli/dist/src/ruvector/fast-apply.js +73 -0
  106. package/v3/@claude-flow/cli/dist/src/ruvector/graph-analyzer.d.ts +11 -1
  107. package/v3/@claude-flow/cli/dist/src/ruvector/graph-analyzer.js +22 -36
  108. package/v3/@claude-flow/cli/dist/src/ruvector/mincut-bridge.d.ts +70 -0
  109. package/v3/@claude-flow/cli/dist/src/ruvector/mincut-bridge.js +172 -0
  110. package/v3/@claude-flow/cli/dist/src/ruvector/model-router.d.ts +6 -1
  111. package/v3/@claude-flow/cli/dist/src/ruvector/model-router.js +16 -4
  112. package/v3/@claude-flow/cli/dist/src/services/distill-oracle.d.ts +1 -1
  113. package/v3/@claude-flow/cli/dist/src/services/distill-oracle.js +2 -2
  114. package/v3/@claude-flow/cli/dist/src/services/worker-daemon.js +30 -12
  115. package/v3/@claude-flow/cli/dist/src/transfer/storage/gcs.js +3 -2
  116. package/v3/@claude-flow/cli/package.json +11 -9
  117. package/.claude/.proven-config-version +0 -1
  118. package/.claude/proven-config.json +0 -42
@@ -11,9 +11,7 @@
11
11
  * Expected L1 lift: +5-10pp on multi-step questions (~30-40% of L1 set).
12
12
  *
13
13
  * Design:
14
- * - NEW standalone file only; NOT wired into gaia-bench.ts to avoid merge
15
- * conflicts with in-flight iter 29/31/34/35/36 branches.
16
- * Wiring is a small follow-up PR.
14
+ * - gaia-bench.ts loads the decomposer when decomposition is enabled.
17
15
  * - `decomposeQuestion()` — Haiku-cheap classification + decomposition
18
16
  * (~$0.0003 per question).
19
17
  * - `synthesizeFromSubAnswers()` — Sonnet synthesis from sub-answers
@@ -26,11 +24,6 @@
26
24
  * - Synthesis uses claude-sonnet-4-6 (~$0.002/question).
27
25
  * - Total overhead per question (when decomposed): ~$0.002-0.003.
28
26
  *
29
- * Plugin sync TODO (follow-up PR after gaia-bench wiring):
30
- * - Update plugins/ruflo-workflows/commands/gaia-run.md with --decompose flag.
31
- * - Update plugins/ruflo-workflows/skills/gaia-debugging/SKILL.md: add
32
- * decomposition as a recommended strategy for multi-step failures.
33
- *
34
27
  * Refs: ADR-135, ADR-133, iter 29 finding, #2156
35
28
  */
36
29
  export interface DecomposedQuestion {
@@ -11,9 +11,7 @@
11
11
  * Expected L1 lift: +5-10pp on multi-step questions (~30-40% of L1 set).
12
12
  *
13
13
  * Design:
14
- * - NEW standalone file only; NOT wired into gaia-bench.ts to avoid merge
15
- * conflicts with in-flight iter 29/31/34/35/36 branches.
16
- * Wiring is a small follow-up PR.
14
+ * - gaia-bench.ts loads the decomposer when decomposition is enabled.
17
15
  * - `decomposeQuestion()` — Haiku-cheap classification + decomposition
18
16
  * (~$0.0003 per question).
19
17
  * - `synthesizeFromSubAnswers()` — Sonnet synthesis from sub-answers
@@ -26,11 +24,6 @@
26
24
  * - Synthesis uses claude-sonnet-4-6 (~$0.002/question).
27
25
  * - Total overhead per question (when decomposed): ~$0.002-0.003.
28
26
  *
29
- * Plugin sync TODO (follow-up PR after gaia-bench wiring):
30
- * - Update plugins/ruflo-workflows/commands/gaia-run.md with --decompose flag.
31
- * - Update plugins/ruflo-workflows/skills/gaia-debugging/SKILL.md: add
32
- * decomposition as a recommended strategy for multi-step failures.
33
- *
34
27
  * Refs: ADR-135, ADR-133, iter 29 finding, #2156
35
28
  */
36
29
  import { execSync } from 'node:child_process';
@@ -146,7 +146,7 @@ export const wasmCreateCommand = {
146
146
  info = await wasm.createWasmAgent({
147
147
  model: ctx.flags.model,
148
148
  instructions: ctx.flags.instructions,
149
- maxTurns: ctx.flags['max-turns'],
149
+ maxTurns: ctx.flags.maxTurns,
150
150
  });
151
151
  }
152
152
  if (ctx.flags.format === 'json') {
@@ -201,7 +201,7 @@ export const wasmPromptCommand = {
201
201
  { command: 'claude-flow agent wasm-prompt -a wasm-agent-1-abc -i "Write a hello world"', description: 'Send prompt to WASM agent' },
202
202
  ],
203
203
  action: async (ctx) => {
204
- const agentId = ctx.flags['agent-id'] || ctx.args[0];
204
+ const agentId = ctx.flags.agentId || ctx.args[0];
205
205
  const promptInput = ctx.flags.input || ctx.args[1];
206
206
  if (!agentId) {
207
207
  output.printError('Agent ID is required. Use --agent-id or -a');
@@ -1556,7 +1556,7 @@ const modulesCommand = {
1556
1556
  const targetDir = ctx.args[0] || ctx.cwd;
1557
1557
  const outputFile = ctx.flags.output;
1558
1558
  const format = ctx.flags.format || 'text';
1559
- const minSize = ctx.flags['min-size'] || 2;
1559
+ const minSize = ctx.flags.minSize || 2;
1560
1560
  output.printInfo(`Detecting module communities in: ${output.highlight(targetDir)}`);
1561
1561
  output.writeln();
1562
1562
  const spinner = output.createSpinner({ text: 'Building dependency graph...', spinner: 'dots' });
@@ -1247,7 +1247,7 @@ const statusCommand = {
1247
1247
  ],
1248
1248
  action: async (ctx) => {
1249
1249
  const verbose = ctx.flags.verbose;
1250
- const showModes = ctx.flags['show-modes'];
1250
+ const showModes = ctx.flags.showModes;
1251
1251
  // #2356: global view across every workspace, not just cwd.
1252
1252
  if (ctx.flags.all) {
1253
1253
  return renderAllDaemonsStatus();
@@ -7,6 +7,7 @@
7
7
  import { output } from '../output.js';
8
8
  import { existsSync, readFileSync, statSync, openSync, readSync, closeSync } from 'fs';
9
9
  import { join, dirname } from 'path';
10
+ import { homedir } from 'node:os';
10
11
  import { fileURLToPath, pathToFileURL } from 'url';
11
12
  import { createHash } from 'crypto';
12
13
  import { ownInstallAncestors } from '../plugins/own-install.js';
@@ -182,7 +183,7 @@ async function checkStaleSettingsNpx() {
182
183
  // Look in both project-local and home-dir settings.
183
184
  const candidates = [
184
185
  join(process.cwd(), '.claude', 'settings.json'),
185
- join(process.env.HOME ?? '', '.claude', 'settings.json'),
186
+ join(homedir(), '.claude', 'settings.json'),
186
187
  ].filter((p, i, a) => p && a.indexOf(p) === i);
187
188
  const offenders = [];
188
189
  for (const settingsPath of candidates) {
@@ -248,7 +249,7 @@ export async function checkHelperIntegrity(opts = {}) {
248
249
  const { verifyInstalledCriticalHelpers } = await import('../init/helper-integrity.js');
249
250
  const { CRITICAL_HELPERS, findPackageHelpersDir } = await import('../init/helper-refresh.js');
250
251
  const envLocked = /^(1|true|on|yes)$/i.test(String(process.env.RUFLO_HELPERS_LOCKED || ''));
251
- const home = opts.homeDir ?? process.env.HOME ?? '';
252
+ const home = opts.homeDir ?? homedir();
252
253
  const dirs = [
253
254
  join(opts.cwd ?? process.cwd(), '.claude', 'helpers'),
254
255
  ...(home ? [join(home, '.claude', 'helpers')] : []),
@@ -34,7 +34,7 @@ const compileCommand = {
34
34
  output.writeln(output.error(`Root guidance file not found: ${rootPath}`));
35
35
  return { success: false, message: `File not found: ${rootPath}` };
36
36
  }
37
- const modExport = ctx.flags['mod-projection'] === true;
37
+ const modExport = (ctx.flags.modProjection ?? ctx.flags['mod-projection']) === true;
38
38
  const checked = modExport ? await (await import('../guidance/mod-sources.js')).readModGuidanceSources({
39
39
  rootPath, localPath, revision: String(ctx.flags.revision || ''),
40
40
  }) : undefined;
@@ -112,7 +112,7 @@ const retrieveCommand = {
112
112
  const task = ctx.flags.task;
113
113
  const rootPath = ctx.flags.root || './CLAUDE.md';
114
114
  const localPath = ctx.flags.local;
115
- const maxShards = parseInt(ctx.flags['max-shards'] || '5', 10);
115
+ const maxShards = parseInt(String(ctx.flags.maxShards ?? ctx.flags['max-shards'] ?? 5), 10);
116
116
  const intentOverride = ctx.flags.intent;
117
117
  const jsonOutput = ctx.flags.json === true;
118
118
  if (!task) {
@@ -338,9 +338,9 @@ const optimizeCommand = {
338
338
  const rootPath = ctx.flags.root || './CLAUDE.md';
339
339
  const localPath = ctx.flags.local;
340
340
  const applyChanges = ctx.flags.apply === true;
341
- const contextSize = (ctx.flags['context-size'] || 'standard');
342
- const targetScore = parseInt(ctx.flags['target-score'] || '90', 10);
343
- const maxIterations = parseInt(ctx.flags['max-iterations'] || '5', 10);
341
+ const contextSize = (ctx.flags.contextSize ?? ctx.flags['context-size'] ?? 'standard');
342
+ const targetScore = parseInt(String(ctx.flags.targetScore ?? ctx.flags['target-score'] ?? 90), 10);
343
+ const maxIterations = parseInt(String(ctx.flags.maxIterations ?? ctx.flags['max-iterations'] ?? 5), 10);
344
344
  const jsonOutput = ctx.flags.json === true;
345
345
  output.writeln();
346
346
  output.writeln(output.bold('Guidance Optimizer'));
@@ -437,10 +437,10 @@ const abTestCommand = {
437
437
  { command: 'claude-flow guidance ab-test --json', description: 'Output full report as JSON' },
438
438
  ],
439
439
  action: async (ctx) => {
440
- const configAPath = ctx.flags['config-a'];
441
- const configBPath = ctx.flags['config-b'] || './CLAUDE.md';
440
+ const configAPath = (ctx.flags.configA ?? ctx.flags['config-a']);
441
+ const configBPath = (ctx.flags.configB ?? ctx.flags['config-b'] ?? './CLAUDE.md');
442
442
  const tasksPath = ctx.flags.tasks;
443
- const workDir = ctx.flags['work-dir'];
443
+ const workDir = (ctx.flags.workDir ?? ctx.flags['work-dir']);
444
444
  const jsonOutput = ctx.flags.json === true;
445
445
  output.writeln();
446
446
  output.writeln(output.bold('A/B Behavioral Benchmark'));
@@ -541,7 +541,7 @@ const modCandidatesCommand = {
541
541
  action: async (ctx) => {
542
542
  try {
543
543
  const { collectModCandidates } = await import('../guidance/mod-projection.js');
544
- const data = await collectModCandidates(String(ctx.flags.directory || '.claude-flow/mods/guidance/observations'), ctx.flags['bundle-id']);
544
+ const data = await collectModCandidates(String(ctx.flags.directory || '.claude-flow/mods/guidance/observations'), (ctx.flags.bundleId ?? ctx.flags['bundle-id']));
545
545
  output.writeln(JSON.stringify(data, null, ctx.flags.json === true ? undefined : 2));
546
546
  return { success: true, data };
547
547
  }
@@ -2529,8 +2529,8 @@ const workerDetectCommand = {
2529
2529
  ],
2530
2530
  action: async (ctx) => {
2531
2531
  const prompt = ctx.flags['prompt'];
2532
- const autoDispatch = ctx.flags['auto-dispatch'];
2533
- const minConfidence = parseFloat(ctx.flags['min-confidence'] || '0.5');
2532
+ const autoDispatch = (ctx.flags.autoDispatch ?? ctx.flags['auto-dispatch']);
2533
+ const minConfidence = parseFloat(String(ctx.flags.minConfidence ?? ctx.flags['min-confidence'] ?? 0.5) || '0.5');
2534
2534
  if (!prompt) {
2535
2535
  output.printError('--prompt is required');
2536
2536
  return { success: false, exitCode: 1 };
@@ -2570,7 +2570,12 @@ const workerDetectCommand = {
2570
2570
  }
2571
2571
  if (result.autoDispatched && result.workerIds) {
2572
2572
  output.writeln();
2573
- output.writeln(output.success('Workers auto-dispatched:'));
2573
+ if (result.autoDispatchStatus === 'synthetic-completed') {
2574
+ output.printWarning(result.note ?? 'No executor ran. Worker records are synthetic placeholders.');
2575
+ }
2576
+ else {
2577
+ output.writeln(output.success('Workers auto-dispatched:'));
2578
+ }
2574
2579
  result.workerIds.forEach(id => {
2575
2580
  output.writeln(` - ${id}`);
2576
2581
  });
@@ -3079,8 +3084,8 @@ const coverageGapsCommand = {
3079
3084
  ],
3080
3085
  action: async (ctx) => {
3081
3086
  const threshold = ctx.flags.threshold ?? 80;
3082
- const groupByAgent = ctx.flags['group-by-agent'] !== false;
3083
- const criticalOnly = ctx.flags['critical-only'] || false;
3087
+ const groupByAgent = (ctx.flags.groupByAgent ?? ctx.flags['group-by-agent']) !== false;
3088
+ const criticalOnly = (ctx.flags.criticalOnly ?? ctx.flags['critical-only']) === true;
3084
3089
  const spinner = output.createSpinner({ text: 'Analyzing project coverage gaps...' });
3085
3090
  spinner.start();
3086
3091
  // Try reading coverage from disk first
@@ -4161,7 +4166,7 @@ const modelRouteCommand = {
4161
4166
  { name: 'task', short: 't', type: 'string', description: 'Task description to route', required: true },
4162
4167
  { name: 'context', short: 'c', type: 'string', description: 'Additional context' },
4163
4168
  { name: 'prefer-cost', type: 'boolean', description: 'Prefer lower cost models' },
4164
- { name: 'prefer-quality', type: 'boolean', description: 'Prefer higher quality models' },
4169
+ { name: 'prefer-speed', type: 'boolean', description: 'Prefer faster models when possible' },
4165
4170
  ],
4166
4171
  examples: [
4167
4172
  { command: 'claude-flow hooks model-route -t "fix typo"', description: 'Route simple task (likely haiku)' },
@@ -4178,8 +4183,8 @@ const modelRouteCommand = {
4178
4183
  const result = await callMCPTool('hooks_model-route', {
4179
4184
  task,
4180
4185
  context: ctx.flags.context,
4181
- preferCost: ctx.flags['prefer-cost'],
4182
- preferQuality: ctx.flags['prefer-quality'],
4186
+ preferCost: ctx.flags.preferCost,
4187
+ preferSpeed: ctx.flags.preferSpeed,
4183
4188
  });
4184
4189
  if (ctx.flags.format === 'json') {
4185
4190
  output.printJson(result);
@@ -816,16 +816,22 @@ const initClaudeAction = async (ctx) => {
816
816
  if (startDaemon || startAll) {
817
817
  output.writeln();
818
818
  output.printInfo('Starting services...');
819
- const { execSync } = await import('child_process');
819
+ const { execFileSync } = await import('child_process');
820
+ // #4770: drop stderr via stdio, not a shell redirect (breaks on cmd.exe).
821
+ // shell on win32 so npx.cmd resolves (#2770); args are fixed literals.
822
+ const runCli = (args) => {
823
+ execFileSync('npx', ['@claude-flow/cli@latest', ...args], {
824
+ stdio: ['ignore', 'pipe', 'ignore'],
825
+ cwd: ctx.cwd,
826
+ timeout: 30000,
827
+ shell: process.platform === 'win32',
828
+ });
829
+ };
820
830
  // Initialize memory database
821
831
  if (startAll) {
822
832
  try {
823
833
  output.writeln(output.dim(' Initializing memory database...'));
824
- execSync('npx @claude-flow/cli@latest memory init 2>/dev/null', {
825
- stdio: 'pipe',
826
- cwd: ctx.cwd,
827
- timeout: 30000
828
- });
834
+ runCli(['memory', 'init']);
829
835
  output.writeln(output.success(' ✓ Memory initialized'));
830
836
  }
831
837
  catch {
@@ -854,11 +860,7 @@ const initClaudeAction = async (ctx) => {
854
860
  if (startDaemon) {
855
861
  try {
856
862
  output.writeln(output.dim(' Starting daemon...'));
857
- execSync('npx @claude-flow/cli@latest daemon start 2>/dev/null', {
858
- stdio: 'pipe',
859
- cwd: ctx.cwd,
860
- timeout: 30000
861
- });
863
+ runCli(['daemon', 'start']);
862
864
  output.writeln(output.success(' ✓ Daemon started'));
863
865
  }
864
866
  catch {
@@ -872,11 +874,7 @@ const initClaudeAction = async (ctx) => {
872
874
  if (startAll) {
873
875
  try {
874
876
  output.writeln(output.dim(' Initializing swarm...'));
875
- execSync('npx @claude-flow/cli@latest swarm init --topology hierarchical 2>/dev/null', {
876
- stdio: 'pipe',
877
- cwd: ctx.cwd,
878
- timeout: 30000
879
- });
877
+ runCli(['swarm', 'init', '--topology', 'hierarchical']);
880
878
  output.writeln(output.success(' ✓ Swarm initialized'));
881
879
  }
882
880
  catch {
@@ -1357,6 +1355,7 @@ const skillsCommand = {
1357
1355
  { name: 'github', description: 'Install GitHub skills', type: 'boolean', default: false },
1358
1356
  { name: 'v3', description: 'Install V3 skills', type: 'boolean', default: false },
1359
1357
  { name: 'legacy', description: 'Install skills that document commands v3 does not ship (stream-chain, sparc)', type: 'boolean', default: false },
1358
+ { name: 'ecosystem', description: 'Install ecosystem skills (vector quantization, graph min-cut, sublinear solving, injection defense, fast edits, LoRA learning)', type: 'boolean', default: true },
1360
1359
  ],
1361
1360
  action: async (ctx) => {
1362
1361
  const options = {
@@ -1384,6 +1383,7 @@ const skillsCommand = {
1384
1383
  v3: ctx.flags.v3,
1385
1384
  dualMode: false,
1386
1385
  legacy: ctx.flags.legacy,
1386
+ ecosystem: ctx.flags.ecosystem,
1387
1387
  },
1388
1388
  };
1389
1389
  const spinner = output.createSpinner({ text: 'Installing skills...' });
@@ -35,8 +35,8 @@ const trainCommand = {
35
35
  action: async (ctx) => {
36
36
  const patternType = (ctx.flags.pattern || ctx.flags.patternType || ctx.flags['pattern-type']) || 'coordination';
37
37
  const epochs = parseInt(ctx.flags.epochs || '50', 10);
38
- const learningRate = parseFloat(ctx.flags['learning-rate'] || '0.01');
39
- const batchSize = parseInt(ctx.flags['batch-size'] || '32', 10);
38
+ const learningRate = parseFloat((ctx.flags.learningRate ?? ctx.flags['learning-rate']) || '0.01');
39
+ const batchSize = parseInt((ctx.flags.batchSize ?? ctx.flags['batch-size']) || '32', 10);
40
40
  const dim = Math.min(parseInt(ctx.flags.dim || '256', 10), 256);
41
41
  // #2549 follow-up — backend routing: 'native' = @ruvector/ruvllm
42
42
  // TrainingPipeline (real epochs/early-stopping/disk checkpoints),
@@ -44,7 +44,7 @@ const trainCommand = {
44
44
  // 'auto' = native when the module resolves, else wasm.
45
45
  const backendFlag = String(ctx.flags.backend || 'auto');
46
46
  // Feature: validation split + resume (native TrainingPipeline leg).
47
- const valSplitRaw = parseFloat(ctx.flags['val-split'] ?? '0.1');
47
+ const valSplitRaw = parseFloat((ctx.flags.valSplit ?? ctx.flags['val-split']) ?? '0.1');
48
48
  const valSplit = Number.isFinite(valSplitRaw) ? Math.max(0, Math.min(1, valSplitRaw)) : 0.1;
49
49
  const resumePath = ctx.flags.resume ? String(ctx.flags.resume) : undefined;
50
50
  // --resume is a native-only capability; refuse the WASM combination up
@@ -1023,7 +1023,7 @@ const exportCommand = {
1023
1023
  const outputFile = ctx.flags.output;
1024
1024
  const pinToIpfs = ctx.flags.ipfs;
1025
1025
  const signExport = ctx.flags.sign !== false;
1026
- const stripPii = ctx.flags['strip-pii'] !== false;
1026
+ const stripPii = (ctx.flags.stripPii ?? ctx.flags['strip-pii']) !== false;
1027
1027
  const customName = ctx.flags.name;
1028
1028
  output.writeln();
1029
1029
  output.writeln(output.bold('Secure Model Export'));
@@ -1516,81 +1516,89 @@ const benchmarkCommand = {
1516
1516
  const spinner = output.createSpinner({ text: 'Running benchmarks...', spinner: 'dots' });
1517
1517
  spinner.start();
1518
1518
  try {
1519
- // Indirect the specifier through a string variable so tsc doesn't
1520
- // statically resolve this optional dependency at build time (TS2307
1521
- // when it isn't installed — install-safety / Build V3 pattern from #2586).
1522
- const attentionPkg = '@ruvector/attention';
1523
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic import of optional native WASM module with no type declarations
1524
- const attention = await import(attentionPkg);
1525
- // Manual benchmark since benchmarkAttention has a binding bug
1526
- const benchmarkMechanism = async (name, mechanism) => {
1527
- const query = new Float32Array(dim);
1528
- const keys = [];
1529
- const values = [];
1530
- for (let i = 0; i < dim; i++)
1531
- query[i] = Math.random();
1532
- for (let k = 0; k < numKeys; k++) {
1533
- const key = new Float32Array(dim);
1534
- const val = new Float32Array(dim);
1535
- for (let i = 0; i < dim; i++) {
1536
- key[i] = Math.random();
1537
- val[i] = Math.random();
1519
+ const results = [];
1520
+ // The attention and MicroLoRA benchmarks are independent: a missing or
1521
+ // API-incompatible @ruvector/attention must not hide the
1522
+ // @ruvector/learning-wasm MicroLoRA numbers below.
1523
+ try {
1524
+ // Indirect the specifier through a string variable so tsc doesn't
1525
+ // statically resolve this optional dependency at build time (TS2307
1526
+ // when it isn't installed — install-safety / Build V3 pattern from #2586).
1527
+ const attentionPkg = '@ruvector/attention';
1528
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- dynamic import of optional native WASM module with no type declarations
1529
+ const attention = await import(attentionPkg);
1530
+ // Manual benchmark since benchmarkAttention has a binding bug
1531
+ const benchmarkMechanism = async (name, mechanism) => {
1532
+ const query = new Float32Array(dim);
1533
+ const keys = [];
1534
+ const values = [];
1535
+ for (let i = 0; i < dim; i++)
1536
+ query[i] = Math.random();
1537
+ for (let k = 0; k < numKeys; k++) {
1538
+ const key = new Float32Array(dim);
1539
+ const val = new Float32Array(dim);
1540
+ for (let i = 0; i < dim; i++) {
1541
+ key[i] = Math.random();
1542
+ val[i] = Math.random();
1543
+ }
1544
+ keys.push(key);
1545
+ values.push(val);
1538
1546
  }
1539
- keys.push(key);
1540
- values.push(val);
1541
- }
1542
- // Warmup
1543
- for (let i = 0; i < 10; i++)
1544
- mechanism.computeRaw(query, keys, values);
1545
- const start = performance.now();
1546
- for (let i = 0; i < iterations; i++) {
1547
- mechanism.computeRaw(query, keys, values);
1548
- }
1549
- const elapsed = performance.now() - start;
1550
- return {
1551
- name,
1552
- averageTimeMs: elapsed / iterations,
1553
- opsPerSecond: Math.round((iterations / elapsed) * 1000),
1547
+ // Warmup
1548
+ for (let i = 0; i < 10; i++)
1549
+ mechanism.computeRaw(query, keys, values);
1550
+ const start = performance.now();
1551
+ for (let i = 0; i < iterations; i++) {
1552
+ mechanism.computeRaw(query, keys, values);
1553
+ }
1554
+ const elapsed = performance.now() - start;
1555
+ return {
1556
+ name,
1557
+ averageTimeMs: elapsed / iterations,
1558
+ opsPerSecond: Math.round((iterations / elapsed) * 1000),
1559
+ };
1554
1560
  };
1555
- };
1556
- spinner.setText(`Benchmarking attention mechanisms (dim=${dim}, keys=${numKeys}, iter=${iterations})...`);
1557
- const results = [];
1558
- // Benchmark each mechanism
1559
- const dotProduct = new attention.DotProductAttention(dim);
1560
- results.push(await benchmarkMechanism('DotProduct', dotProduct));
1561
- const flash = new attention.FlashAttention(dim, 64);
1562
- results.push(await benchmarkMechanism('FlashAttention', flash));
1563
- const multiHead = new attention.MultiHeadAttention(dim, 4);
1564
- results.push(await benchmarkMechanism('MultiHead (4 heads)', multiHead));
1565
- const hyperbolic = new attention.HyperbolicAttention(dim, 1.0);
1566
- results.push(await benchmarkMechanism('Hyperbolic', hyperbolic));
1567
- const linear = new attention.LinearAttention(dim, dim);
1568
- results.push(await benchmarkMechanism('Linear', linear));
1569
- spinner.succeed('Benchmark complete');
1570
- output.writeln();
1571
- output.printTable({
1572
- columns: [
1573
- { key: 'name', header: 'Mechanism', width: 25 },
1574
- { key: 'avgTime', header: 'Avg Time (ms)', width: 15 },
1575
- { key: 'opsPerSec', header: 'Ops/sec', width: 15 },
1576
- ],
1577
- data: results.map(r => ({
1578
- name: r.name,
1579
- avgTime: r.averageTimeMs.toFixed(4),
1580
- opsPerSec: r.opsPerSecond.toLocaleString(),
1581
- })),
1582
- });
1583
- // Show speedup comparisons
1584
- const dotProductResult = results.find(r => r.name.includes('DotProduct'));
1585
- const flashResult = results.find(r => r.name.includes('Flash'));
1586
- const hyperbolicResult = results.find(r => r.name.includes('Hyperbolic'));
1587
- if (dotProductResult && flashResult) {
1588
- const speedup = dotProductResult.averageTimeMs / flashResult.averageTimeMs;
1561
+ spinner.setText(`Benchmarking attention mechanisms (dim=${dim}, keys=${numKeys}, iter=${iterations})...`);
1562
+ // Benchmark each mechanism
1563
+ const dotProduct = new attention.DotProductAttention(dim);
1564
+ results.push(await benchmarkMechanism('DotProduct', dotProduct));
1565
+ const flash = new attention.FlashAttention(dim, 64);
1566
+ results.push(await benchmarkMechanism('FlashAttention', flash));
1567
+ const multiHead = new attention.MultiHeadAttention(dim, 4);
1568
+ results.push(await benchmarkMechanism('MultiHead (4 heads)', multiHead));
1569
+ const hyperbolic = new attention.HyperbolicAttention(dim, 1.0);
1570
+ results.push(await benchmarkMechanism('Hyperbolic', hyperbolic));
1571
+ const linear = new attention.LinearAttention(dim, dim);
1572
+ results.push(await benchmarkMechanism('Linear', linear));
1573
+ spinner.succeed('Benchmark complete');
1589
1574
  output.writeln();
1590
- output.writeln(output.highlight(`Flash Attention speedup: ${speedup.toFixed(2)}x faster than DotProduct`));
1575
+ output.printTable({
1576
+ columns: [
1577
+ { key: 'name', header: 'Mechanism', width: 25 },
1578
+ { key: 'avgTime', header: 'Avg Time (ms)', width: 15 },
1579
+ { key: 'opsPerSec', header: 'Ops/sec', width: 15 },
1580
+ ],
1581
+ data: results.map(r => ({
1582
+ name: r.name,
1583
+ avgTime: r.averageTimeMs.toFixed(4),
1584
+ opsPerSec: r.opsPerSecond.toLocaleString(),
1585
+ })),
1586
+ });
1587
+ // Show speedup comparisons
1588
+ const dotProductResult = results.find(r => r.name.includes('DotProduct'));
1589
+ const flashResult = results.find(r => r.name.includes('Flash'));
1590
+ const hyperbolicResult = results.find(r => r.name.includes('Hyperbolic'));
1591
+ if (dotProductResult && flashResult) {
1592
+ const speedup = dotProductResult.averageTimeMs / flashResult.averageTimeMs;
1593
+ output.writeln();
1594
+ output.writeln(output.highlight(`Flash Attention speedup: ${speedup.toFixed(2)}x faster than DotProduct`));
1595
+ }
1596
+ if (dotProductResult && hyperbolicResult) {
1597
+ output.writeln(output.dim(`Hyperbolic overhead: ${(hyperbolicResult.averageTimeMs / dotProductResult.averageTimeMs).toFixed(2)}x (expected for manifold ops)`));
1598
+ }
1591
1599
  }
1592
- if (dotProductResult && hyperbolicResult) {
1593
- output.writeln(output.dim(`Hyperbolic overhead: ${(hyperbolicResult.averageTimeMs / dotProductResult.averageTimeMs).toFixed(2)}x (expected for manifold ops)`));
1600
+ catch (attentionError) {
1601
+ spinner.fail(`Attention benchmark skipped: ${attentionError instanceof Error ? attentionError.message : String(attentionError)}`);
1594
1602
  }
1595
1603
  // Also benchmark MicroLoRA
1596
1604
  spinner.start();
@@ -1703,7 +1711,8 @@ const routerTrainCommand = {
1703
1711
  action: async (ctx) => {
1704
1712
  const corpusPath = ctx.flags.corpus;
1705
1713
  const outPath = ctx.flags.out || './router.krr.json';
1706
- const qualityBar = parseFloat(ctx.flags['quality-bar'] || '0.8') || 0.8;
1714
+ const requestedQualityBar = parseFloat(String(ctx.flags.qualityBar ?? ctx.flags['quality-bar'] ?? 0.8));
1715
+ const qualityBar = Number.isNaN(requestedQualityBar) ? 0.8 : requestedQualityBar;
1707
1716
  // Indirect the optional-dep specifier through a string variable so tsc
1708
1717
  // doesn't statically resolve `@metaharness/router` at build time (TS2307
1709
1718
  // when it isn't installed — #2586 pattern). The dep is optional at
@@ -3464,7 +3473,8 @@ const routerBanditStateCommand = {
3464
3473
  const statePath = ctx.flags.path
3465
3474
  ?? path.resolve(process.cwd(), '.swarm', 'model-router-state.json');
3466
3475
  const fmt = ctx.flags.format || 'table';
3467
- const coldThreshold = parseInt(ctx.flags['cold-threshold'] || '4', 10) || 4;
3476
+ const requestedColdThreshold = parseInt(String(ctx.flags.coldThreshold ?? ctx.flags['cold-threshold'] ?? 4), 10);
3477
+ const coldThreshold = Number.isNaN(requestedColdThreshold) ? 4 : requestedColdThreshold;
3468
3478
  if (!fs.existsSync(statePath)) {
3469
3479
  const msg = `Bandit state file not found at ${statePath}`;
3470
3480
  if (fmt === 'json')
@@ -367,7 +367,7 @@ const feedbackCommand = {
367
367
  const taskDescription = ctx.flags.task;
368
368
  const agentId = ctx.flags.agent;
369
369
  const reward = ctx.flags.reward;
370
- const nextTask = ctx.flags['next-task'];
370
+ const nextTask = ctx.flags.nextTask;
371
371
  if (!taskDescription || !agentId) {
372
372
  output.printError('Task description and agent are required');
373
373
  return { success: false, exitCode: 1 };
@@ -53,10 +53,10 @@ const backupSubcommand = {
53
53
  {
54
54
  name: 'format',
55
55
  short: 'f',
56
- description: 'Output format',
56
+ description: 'Output format (defaults to SQL)',
57
57
  type: 'string',
58
- default: 'sql',
59
- choices: ['sql', 'json', 'csv'],
58
+ default: 'text',
59
+ choices: ['text', 'sql', 'json', 'csv'],
60
60
  },
61
61
  {
62
62
  name: 'compress',
@@ -125,9 +125,11 @@ const backupSubcommand = {
125
125
  const config = getConnectionConfig(ctx);
126
126
  let outputPath = ctx.flags.output;
127
127
  const tablesFilter = ctx.flags.tables;
128
- const format = ctx.flags.format || 'sql';
128
+ // The CLI validates the shared --format flag against its global choices.
129
+ const requestedFormat = ctx.flags.format;
130
+ const format = !requestedFormat || requestedFormat === 'text' ? 'sql' : requestedFormat;
129
131
  const compress = ctx.flags.compress;
130
- const includeIndexes = ctx.flags['include-indexes'] !== false;
132
+ const includeIndexes = (ctx.flags.includeIndexes ?? ctx.flags['include-indexes']) !== false;
131
133
  output.writeln();
132
134
  output.writeln(output.bold('RuVector Backup'));
133
135
  output.writeln(output.dim('='.repeat(60)));
@@ -158,7 +158,8 @@ export const benchmarkCommand = {
158
158
  const topK = parseInt(ctx.flags.k || '10', 10);
159
159
  const metric = ctx.flags.metric || 'cosine';
160
160
  const indexType = ctx.flags.index || 'hnsw';
161
- const batchSize = parseInt(ctx.flags['batch-size'] || '1000', 10);
161
+ const batchSizeFlag = ctx.flags.batchSize ?? ctx.flags['batch-size'] ?? 1000;
162
+ const batchSize = typeof batchSizeFlag === 'string' ? Number(batchSizeFlag) : batchSizeFlag;
162
163
  const cleanup = ctx.flags.cleanup !== false;
163
164
  output.writeln();
164
165
  output.writeln(output.bold('RuVector Performance Benchmark'));
@@ -168,6 +169,10 @@ export const benchmarkCommand = {
168
169
  output.printError('Database name is required. Use --database or -d flag, or set PGDATABASE env.');
169
170
  return { success: false, exitCode: 1 };
170
171
  }
172
+ if (typeof batchSize !== 'number' || !Number.isSafeInteger(batchSize) || batchSize < 1) {
173
+ output.printError('--batch-size must be a positive integer');
174
+ return { success: false, exitCode: 1 };
175
+ }
171
176
  // Show benchmark configuration
172
177
  output.writeln(output.highlight('Benchmark Configuration:'));
173
178
  output.printTable({
@@ -166,15 +166,21 @@ export const importCommand = {
166
166
  ],
167
167
  action: async (ctx) => {
168
168
  const inputFile = ctx.flags.input;
169
- const fromMemory = ctx.flags['from-memory'];
169
+ const fromMemory = (ctx.flags.fromMemory ?? ctx.flags['from-memory']);
170
170
  const outputFile = ctx.flags.output;
171
- const batchSize = ctx.flags['batch-size'] || 100;
171
+ const batchSizeFlag = ctx.flags.batchSize ?? ctx.flags['batch-size'] ?? 100;
172
+ const batchSize = typeof batchSizeFlag === 'string' ? Number(batchSizeFlag) : batchSizeFlag;
172
173
  const containerName = ctx.flags.container || 'ruvector-postgres';
173
174
  const verbose = ctx.flags.verbose;
174
175
  output.writeln();
175
176
  output.writeln(output.bold('RuVector PostgreSQL Import'));
176
177
  output.writeln(output.dim('='.repeat(50)));
177
178
  output.writeln();
179
+ if (typeof batchSize !== 'number' || !Number.isSafeInteger(batchSize) || batchSize < 1) {
180
+ const message = '--batch-size must be a positive integer';
181
+ output.printError(message);
182
+ return { success: false, message };
183
+ }
178
184
  // Validate input
179
185
  if (!inputFile && !fromMemory) {
180
186
  output.printError('Either --input <file> or --from-memory is required');
@@ -248,6 +254,7 @@ export const importCommand = {
248
254
  sqlStatements.push('');
249
255
  sqlStatements.push('BEGIN;');
250
256
  sqlStatements.push('');
257
+ const inserts = [];
251
258
  for (const entry of entries) {
252
259
  try {
253
260
  // Track statistics
@@ -256,9 +263,7 @@ export const importCommand = {
256
263
  if (entry.embedding && entry.embedding.length > 0) {
257
264
  stats.withEmbeddings++;
258
265
  }
259
- const sql = generateInsertSQL(entry);
260
- sqlStatements.push(sql);
261
- sqlStatements.push('');
266
+ inserts.push(generateInsertSQL(entry));
262
267
  stats.imported++;
263
268
  if (verbose) {
264
269
  output.writeln(output.dim(` Processed: ${entry.key} (${ns})`));
@@ -270,6 +275,15 @@ export const importCommand = {
270
275
  output.printWarning(`Skipped entry "${entry.key}": ${errorMessage}`);
271
276
  }
272
277
  }
278
+ // Send each batch as one statement while keeping ordered upserts in the same transaction.
279
+ for (let offset = 0; offset < inserts.length; offset += batchSize) {
280
+ const batch = inserts.slice(offset, offset + batchSize).join('\n\n');
281
+ let tag = 'ruvector_batch';
282
+ // A value containing the delimiter must stay inside the block.
283
+ while (batch.includes(`$${tag}$`))
284
+ tag += '_';
285
+ sqlStatements.push(`DO $${tag}$\nBEGIN\n${batch}\nEND;\n$${tag}$;`, '');
286
+ }
273
287
  sqlStatements.push('COMMIT;');
274
288
  sqlStatements.push('');
275
289
  sqlStatements.push(`-- Import complete: ${stats.imported} entries`);