claude-flow 2.7.19 → 2.7.21

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.
package/bin/claude-flow CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
  # Claude-Flow Smart Dispatcher - Detects and uses the best available runtime
3
3
 
4
- VERSION="2.7.19"
4
+ VERSION="2.7.21"
5
5
 
6
6
  # Determine the correct path based on how the script is invoked
7
7
  if [ -L "$0" ]; then
@@ -1,18 +1,47 @@
1
- #!/usr/bin/env -S deno run --allow-all
2
- import { promises as fs } from 'node:fs';
1
+ #!/usr/bin/env node
3
2
  import { executeCommand, hasCommand, showCommandHelp, listCommands } from './command-registry.js';
4
3
  import { parseFlags } from './utils.js';
4
+ import { args, cwd, isMainModule, exit, readTextFile, writeTextFile, mkdirAsync, errors } from './node-compat.js';
5
+ import { spawn } from 'child_process';
6
+ import process from 'process';
7
+ import readline from 'readline';
8
+ import { getMainHelp, getCommandHelp, getStandardizedCommandHelp } from './help-text.js';
5
9
  import { VERSION } from '../core/version.js';
6
- function printHelp() {
10
+ const LEGACY_AGENT_MAPPING = {
11
+ analyst: 'code-analyzer',
12
+ coordinator: 'task-orchestrator',
13
+ optimizer: 'perf-analyzer',
14
+ documenter: 'api-docs',
15
+ monitor: 'performance-benchmarker',
16
+ specialist: 'system-architect',
17
+ architect: 'system-architect'
18
+ };
19
+ function resolveLegacyAgentType(legacyType) {
20
+ return LEGACY_AGENT_MAPPING[legacyType] || legacyType;
21
+ }
22
+ function printHelp(plain = false) {
23
+ console.log(getMainHelp(plain));
24
+ }
25
+ function printCommandHelp(command) {
26
+ const standardCommands = [
27
+ 'agent',
28
+ 'sparc',
29
+ 'memory'
30
+ ];
31
+ if (standardCommands.includes(command)) {
32
+ const help = getStandardizedCommandHelp(command);
33
+ console.log(help);
34
+ } else {
35
+ const help = getCommandHelp(command);
36
+ console.log(help);
37
+ }
38
+ }
39
+ function printLegacyHelp() {
7
40
  console.log(`
8
41
  🌊 Claude-Flow v${VERSION} - Enterprise-Grade AI Agent Orchestration Platform
9
42
 
10
- 🎯 NEW IN v2.6.0: Multi-Provider Execution Engine with Agentic-Flow Integration
11
- 66+ specialized agents with multi-provider support (Anthropic, OpenRouter, ONNX, Gemini)
12
- • 99% cost savings with OpenRouter, 352x faster local edits with Agent Booster
13
- • Complete backwards compatibility with existing features
14
-
15
- 🎯 ENTERPRISE FEATURES: Complete ruv-swarm integration with 27 MCP tools, neural networking, and production-ready infrastructure
43
+ 🎯 ENTERPRISE FEATURES: Complete ruv-swarm integration with 90+ MCP tools, neural networking, and production-ready infrastructure
44
+ ALPHA 85: Advanced automation capabilities & stream-JSON chaining for multi-agent pipelines
16
45
 
17
46
  USAGE:
18
47
  claude-flow <command> [options]
@@ -48,10 +77,9 @@ USAGE:
48
77
  init [--sparc] # Initialize with enterprise environment + ruv-swarm
49
78
  start [--ui] [--swarm] # Start orchestration with swarm intelligence
50
79
  spawn <type> [--name] # Create AI agent with swarm coordination
51
- agent <subcommand> # 🆕 Multi-provider agent execution + management
80
+ agent <subcommand> # Advanced agent management with neural patterns
52
81
  sparc <subcommand> # 17 SPARC modes with neural enhancement
53
82
  memory <subcommand> # Cross-session persistent memory with neural learning
54
- config <subcommand> # 🆕 Provider configuration management
55
83
  status # Comprehensive system status with performance metrics
56
84
 
57
85
  🤖 NEURAL AGENT TYPES (ruv-swarm Integration):
@@ -66,25 +94,20 @@ USAGE:
66
94
 
67
95
  🎮 ENTERPRISE QUICK START:
68
96
  # Initialize enterprise environment
69
- npx claude-flow@2.6.0-alpha.1 init --sparc
70
-
71
- # 🆕 Execute agents with multi-provider support
72
- ./claude-flow agent run coder "Build REST API with auth" --provider anthropic
73
- ./claude-flow agent run researcher "Research React 19" --provider openrouter # 99% cost savings
74
- ./claude-flow agent agents # List all 66+ available agents
75
-
97
+ npx claude-flow@2.0.0 init --sparc
98
+
76
99
  # Start enterprise orchestration with swarm intelligence
77
100
  ./claude-flow start --ui --swarm
78
-
101
+
79
102
  # Deploy intelligent multi-agent development workflow
80
103
  ./claude-flow swarm "build enterprise API" --strategy development --parallel --monitor
81
-
104
+
82
105
  # GitHub workflow automation
83
106
  ./claude-flow github pr-manager "coordinate release with automated testing"
84
-
107
+
85
108
  # Neural memory management
86
109
  ./claude-flow memory store "architecture" "microservices with API gateway pattern"
87
-
110
+
88
111
  # Real-time system monitoring
89
112
  ./claude-flow status --verbose
90
113
 
@@ -152,8 +175,8 @@ function printSuccess(message) {
152
175
  function printWarning(message) {
153
176
  console.warn(`⚠️ Warning: ${message}`);
154
177
  }
155
- function showHelpWithCommands() {
156
- printHelp();
178
+ function showHelpWithCommands(plain = false) {
179
+ printHelp(plain);
157
180
  console.log('\nRegistered Commands:');
158
181
  const commands = listCommands();
159
182
  for (const command of commands){
@@ -162,14 +185,58 @@ function showHelpWithCommands() {
162
185
  console.log('\nUse "claude-flow help <command>" for detailed usage information');
163
186
  }
164
187
  async function main() {
165
- const args = Deno.args;
166
188
  if (args.length === 0) {
167
- printHelp();
189
+ printHelp(usePlainHelp);
168
190
  return;
169
191
  }
170
192
  const command = args[0];
171
193
  const { flags, args: parsedArgs } = parseFlags(args.slice(1));
194
+ const usePlainHelp = args.includes('--plain');
195
+ let enhancedFlags = flags;
196
+ try {
197
+ const { detectExecutionEnvironment, applySmartDefaults } = await import('./utils/environment-detector.js');
198
+ enhancedFlags = applySmartDefaults(flags);
199
+ enhancedFlags._environment = detectExecutionEnvironment({
200
+ skipWarnings: true
201
+ });
202
+ } catch (e) {
203
+ enhancedFlags = flags;
204
+ }
205
+ if (command !== 'help' && command !== '--help' && command !== '-h' && (enhancedFlags.help || enhancedFlags.h)) {
206
+ const detailedHelp = getCommandHelp(command);
207
+ if (detailedHelp && !detailedHelp.includes('Help not available')) {
208
+ printCommandHelp(command);
209
+ } else if (hasCommand(command)) {
210
+ showCommandHelp(command);
211
+ } else {
212
+ printError(`Unknown command: ${command}`);
213
+ console.log('\nRun "claude-flow --help" to see available commands.');
214
+ }
215
+ return;
216
+ }
172
217
  switch(command){
218
+ case 'env-check':
219
+ case 'environment':
220
+ if (enhancedFlags._environment) {
221
+ const env = enhancedFlags._environment;
222
+ console.log(`\n🖥️ Environment Detection Results:`);
223
+ console.log(` Terminal: ${env.terminalType}`);
224
+ console.log(` Interactive: ${env.isInteractive ? 'Yes' : 'No'}`);
225
+ console.log(` TTY Support: ${env.supportsRawMode ? 'Yes' : 'No'}`);
226
+ console.log(` Detected: ${env.isVSCode ? 'VS Code' : env.isCI ? 'CI/CD' : env.isDocker ? 'Docker' : env.isSSH ? 'SSH' : 'Standard Terminal'}`);
227
+ if (env.recommendedFlags.length > 0) {
228
+ console.log(`\n💡 Recommended flags:`);
229
+ console.log(` ${env.recommendedFlags.join(' ')}`);
230
+ }
231
+ if (enhancedFlags.appliedDefaults && enhancedFlags.appliedDefaults.length > 0) {
232
+ console.log(`\n✅ Auto-applied:`);
233
+ console.log(` ${enhancedFlags.appliedDefaults.join(' ')}`);
234
+ }
235
+ console.log();
236
+ } else {
237
+ console.log('Environment detection not available');
238
+ }
239
+ return;
173
240
  case 'version':
174
241
  case '--version':
175
242
  case '-v':
@@ -179,9 +246,14 @@ async function main() {
179
246
  case '--help':
180
247
  case '-h':
181
248
  if (parsedArgs.length > 0) {
182
- showCommandHelp(parsedArgs[0]);
249
+ const detailedHelp = getCommandHelp(parsedArgs[0]);
250
+ if (detailedHelp && !detailedHelp.includes('Help not available')) {
251
+ printCommandHelp(parsedArgs[0]);
252
+ } else {
253
+ showCommandHelp(parsedArgs[0]);
254
+ }
183
255
  } else {
184
- showHelpWithCommands();
256
+ printHelp(usePlainHelp);
185
257
  }
186
258
  return;
187
259
  }
@@ -191,6 +263,7 @@ async function main() {
191
263
  return;
192
264
  } catch (err) {
193
265
  printError(err.message);
266
+ console.log(`\nRun "claude-flow ${command} --help" for usage information.`);
194
267
  return;
195
268
  }
196
269
  }
@@ -210,11 +283,12 @@ async function main() {
210
283
  console.log('📊 Real-time monitoring would display here');
211
284
  break;
212
285
  case 'spawn':
213
- const spawnType = subArgs[0] || 'general';
286
+ const rawSpawnType = subArgs[0] || 'general';
287
+ const spawnType = resolveLegacyAgentType(rawSpawnType);
214
288
  const spawnName = flags.name || `agent-${Date.now()}`;
215
289
  printSuccess(`Spawning ${spawnType} agent: ${spawnName}`);
216
290
  console.log('🤖 Agent would be created with the following configuration:');
217
- console.log(` Type: ${spawnType}`);
291
+ console.log(` Type: ${spawnType}${rawSpawnType !== spawnType ? ` (resolved from: ${rawSpawnType})` : ''}`);
218
292
  console.log(` Name: ${spawnName}`);
219
293
  console.log(' Capabilities: Research, Analysis, Code Generation');
220
294
  console.log(' Status: Ready');
@@ -239,7 +313,7 @@ async function main() {
239
313
  console.log(' • Max Pool Size: 10');
240
314
  console.log(' • Idle Timeout: 5 minutes');
241
315
  console.log(' • Shell: /bin/bash');
242
- console.log(' • Working Directory: ' + process.cwd());
316
+ console.log(' • Working Directory: ' + cwd());
243
317
  console.log(' Performance:');
244
318
  console.log(' • Average Response Time: N/A');
245
319
  console.log(' • Terminal Creation Time: N/A');
@@ -288,7 +362,7 @@ async function main() {
288
362
  const terminalConfig = {
289
363
  name: nameIndex >= 0 ? subArgs[nameIndex + 1] : 'terminal-' + Date.now(),
290
364
  shell: shellIndex >= 0 ? subArgs[shellIndex + 1] : 'bash',
291
- workingDirectory: wdIndex >= 0 ? subArgs[wdIndex + 1] : process.cwd(),
365
+ workingDirectory: wdIndex >= 0 ? subArgs[wdIndex + 1] : cwd(),
292
366
  env: envIndex >= 0 ? subArgs[envIndex + 1] : '',
293
367
  persistent: persistentIndex >= 0
294
368
  };
@@ -1245,10 +1319,9 @@ ${flags1.mode === 'full' || !flags1.mode ? `Full-stack development covering all
1245
1319
  console.log('Debug - Executing command:');
1246
1320
  console.log(`claude ${claudeArgs.map((arg)=>arg.includes(' ') || arg.includes('\n') ? `"${arg}"` : arg).join(' ')}`);
1247
1321
  }
1248
- const command = new Deno.Command('claude', {
1249
- args: claudeArgs,
1322
+ const child = spawn('claude', claudeArgs, {
1250
1323
  env: {
1251
- ...Deno.env.toObject(),
1324
+ ...process.env,
1252
1325
  CLAUDE_INSTANCE_ID: instanceId,
1253
1326
  CLAUDE_FLOW_MODE: flags1.mode || 'full',
1254
1327
  CLAUDE_FLOW_COVERAGE: (flags1.coverage || 80).toString(),
@@ -1258,17 +1331,18 @@ ${flags1.mode === 'full' || !flags1.mode ? `Full-stack development covering all
1258
1331
  CLAUDE_FLOW_COORDINATION_ENABLED: flags1.parallel ? 'true' : 'false',
1259
1332
  CLAUDE_FLOW_FEATURES: 'memory,coordination,swarm'
1260
1333
  },
1261
- stdin: 'inherit',
1262
- stdout: 'inherit',
1263
- stderr: 'inherit'
1334
+ stdio: 'inherit'
1335
+ });
1336
+ await new Promise((resolve)=>{
1337
+ child.on('exit', (code)=>{
1338
+ if (code === 0) {
1339
+ printSuccess(`Claude instance ${instanceId} completed successfully`);
1340
+ } else {
1341
+ printError(`Claude instance ${instanceId} exited with code ${code}`);
1342
+ }
1343
+ resolve();
1344
+ });
1264
1345
  });
1265
- const child = command.spawn();
1266
- const status = await child.status;
1267
- if (status.success) {
1268
- printSuccess(`Claude instance ${instanceId} completed successfully`);
1269
- } else {
1270
- printError(`Claude instance ${instanceId} exited with code ${status.code}`);
1271
- }
1272
1346
  } catch (err) {
1273
1347
  printError(`Failed to spawn Claude: ${err.message}`);
1274
1348
  console.log('Make sure you have the Claude CLI installed.');
@@ -1821,7 +1895,7 @@ ${flags1.mode === 'full' || !flags1.mode ? `Full-stack development covering all
1821
1895
  console.log('\nDid you mean:');
1822
1896
  suggestions.forEach((cmd)=>console.log(` claude-flow ${cmd}`));
1823
1897
  }
1824
- process.exit(1);
1898
+ exit(1);
1825
1899
  }
1826
1900
  }
1827
1901
  async function startRepl() {
@@ -1899,7 +1973,7 @@ Shortcuts:
1899
1973
  },
1900
1974
  config: async (key)=>{
1901
1975
  try {
1902
- const config = JSON.parse(await fs.readFile('claude-flow.config.json', 'utf-8'));
1976
+ const config = JSON.parse(await readTextFile('claude-flow.config.json'));
1903
1977
  if (key) {
1904
1978
  const keys = key.split('.');
1905
1979
  let value = config;
@@ -1927,21 +2001,25 @@ Shortcuts:
1927
2001
  if (trimmed.startsWith('!')) {
1928
2002
  const shellCmd = trimmed.substring(1);
1929
2003
  try {
1930
- const command = new Deno.Command('sh', {
1931
- args: [
2004
+ await new Promise((resolve)=>{
2005
+ const proc = spawn('sh', [
1932
2006
  '-c',
1933
2007
  shellCmd
1934
- ],
1935
- stdout: 'piped',
1936
- stderr: 'piped'
2008
+ ], {
2009
+ stdio: [
2010
+ 'inherit',
2011
+ 'pipe',
2012
+ 'pipe'
2013
+ ]
2014
+ });
2015
+ proc.stdout.on('data', (data)=>{
2016
+ console.log(data.toString());
2017
+ });
2018
+ proc.stderr.on('data', (data)=>{
2019
+ console.error(data.toString());
2020
+ });
2021
+ proc.on('exit', resolve);
1937
2022
  });
1938
- const { stdout, stderr } = await command.output();
1939
- if (stdout.length > 0) {
1940
- console.log(new TextDecoder().decode(stdout));
1941
- }
1942
- if (stderr.length > 0) {
1943
- console.error(new TextDecoder().decode(stderr));
1944
- }
1945
2023
  } catch (err) {
1946
2024
  console.error(`Shell error: ${err.message}`);
1947
2025
  }
@@ -1961,7 +2039,7 @@ Shortcuts:
1961
2039
  const parts = trimmed.split(' ');
1962
2040
  const command = parts[0];
1963
2041
  const args = parts.slice(1);
1964
- if (command in replCommands) {
2042
+ if (replCommands[command]) {
1965
2043
  await replCommands[command](...args);
1966
2044
  return true;
1967
2045
  }
@@ -1982,7 +2060,8 @@ Shortcuts:
1982
2060
  const subCmd = args[0];
1983
2061
  switch(subCmd){
1984
2062
  case 'spawn':
1985
- const type = args[1] || 'researcher';
2063
+ const rawType = args[1] || 'researcher';
2064
+ const type = resolveLegacyAgentType(rawType);
1986
2065
  const name = args[2] || `agent-${Date.now()}`;
1987
2066
  const agent = {
1988
2067
  id: `agent-${Date.now()}`,
@@ -2187,18 +2266,33 @@ Shortcuts:
2187
2266
  console.log('Terminal commands: create, list, exec, attach, detach');
2188
2267
  }
2189
2268
  }
2190
- const decoder = new TextDecoder();
2191
- const encoder = new TextEncoder();
2192
- while(true){
2193
- const prompt = replState.currentSession ? `claude-flow:${replState.currentSession}> ` : 'claude-flow> ';
2194
- await Deno.stdout.write(encoder.encode(prompt));
2195
- const buf = new Uint8Array(1024);
2196
- const n = await Deno.stdin.read(buf);
2197
- if (n === null) break;
2198
- const input = decoder.decode(buf.subarray(0, n)).trim();
2199
- const shouldContinue = await processReplCommand(input);
2200
- if (!shouldContinue) break;
2269
+ const rl = readline.createInterface({
2270
+ input: process.stdin,
2271
+ output: process.stdout
2272
+ });
2273
+ function updatePrompt() {
2274
+ rl.setPrompt(replState.currentSession ? `claude-flow:${replState.currentSession}> ` : 'claude-flow> ');
2201
2275
  }
2276
+ updatePrompt();
2277
+ rl.prompt();
2278
+ rl.on('line', async (input)=>{
2279
+ input = input.trim();
2280
+ const shouldContinue = await processReplCommand(input);
2281
+ if (!shouldContinue) {
2282
+ rl.close();
2283
+ } else {
2284
+ updatePrompt();
2285
+ rl.prompt();
2286
+ }
2287
+ });
2288
+ rl.on('SIGINT', ()=>{
2289
+ console.log('\nExiting Claude-Flow...');
2290
+ rl.close();
2291
+ process.exit(0);
2292
+ });
2293
+ return new Promise((resolve)=>{
2294
+ rl.on('close', resolve);
2295
+ });
2202
2296
  }
2203
2297
  function createMinimalClaudeMd() {
2204
2298
  return `# Claude Code Integration
@@ -2515,30 +2609,30 @@ async function createSparcStructureManually() {
2515
2609
  ];
2516
2610
  for (const dir of rooDirectories){
2517
2611
  try {
2518
- await Deno.mkdir(dir, {
2612
+ await mkdirAsync(dir, {
2519
2613
  recursive: true
2520
2614
  });
2521
2615
  console.log(` ✓ Created ${dir}/`);
2522
2616
  } catch (err) {
2523
- if (!(err instanceof Deno.errors.AlreadyExists)) {
2617
+ if (!(err instanceof errors.AlreadyExists)) {
2524
2618
  throw err;
2525
2619
  }
2526
2620
  }
2527
2621
  }
2528
2622
  let roomodesContent;
2529
2623
  try {
2530
- roomodesContent = await fs.readFile('.roomodes');
2624
+ roomodesContent = await readTextFile('.roomodes');
2531
2625
  console.log(' ✓ Using existing .roomodes configuration');
2532
2626
  } catch {
2533
2627
  roomodesContent = createBasicRoomodesConfig();
2534
- await fs.writeFile('.roomodes', roomodesContent);
2628
+ await writeTextFile('.roomodes', roomodesContent);
2535
2629
  console.log(' ✓ Created .roomodes configuration');
2536
2630
  }
2537
2631
  const basicWorkflow = createBasicSparcWorkflow();
2538
- await fs.writeFile('.roo/workflows/basic-tdd.json', basicWorkflow);
2632
+ await writeTextFile('.roo/workflows/basic-tdd.json', basicWorkflow);
2539
2633
  console.log(' ✓ Created .roo/workflows/basic-tdd.json');
2540
2634
  const rooReadme = createRooReadme();
2541
- await fs.writeFile('.roo/README.md', rooReadme);
2635
+ await writeTextFile('.roo/README.md', rooReadme);
2542
2636
  console.log(' ✓ Created .roo/README.md');
2543
2637
  console.log(' ✅ Basic SPARC structure created successfully');
2544
2638
  } catch (err) {
@@ -2969,7 +3063,7 @@ This SPARC-enabled project follows a systematic development approach:
2969
3063
  For more information about SPARC methodology, see: https://github.com/ruvnet/claude-code-flow/docs/sparc.md
2970
3064
  `;
2971
3065
  }
2972
- if (import.meta.url === `file://${process.argv[1]}`) {
3066
+ if (isMainModule(import.meta.url)) {
2973
3067
  await main();
2974
3068
  }
2975
3069