claude-flow 2.0.0-alpha.62 → 2.0.0-alpha.64
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/.claude/commands/analysis/COMMAND_COMPLIANCE_REPORT.md +54 -0
- package/.claude/commands/analysis/token-efficiency.md +2 -1
- package/.claude/commands/automation/self-healing.md +47 -2
- package/.claude/commands/automation/session-memory.md +39 -10
- package/.claude/commands/automation/smart-agents.md +36 -8
- package/.claude/commands/github/code-review-swarm.md +80 -15
- package/.claude/commands/github/github-modes.md +14 -14
- package/.claude/commands/github/issue-tracker.md +19 -16
- package/.claude/commands/github/multi-repo-swarm.md +114 -16
- package/.claude/commands/github/pr-manager.md +5 -4
- package/.claude/commands/github/project-board-sync.md +38 -5
- package/.claude/commands/github/release-manager.md +19 -19
- package/.claude/commands/github/release-swarm.md +102 -13
- package/.claude/commands/github/repo-architect.md +6 -6
- package/.claude/commands/github/swarm-issue.md +139 -17
- package/.claude/commands/github/swarm-pr.md +49 -15
- package/.claude/commands/github/sync-coordinator.md +33 -33
- package/.claude/commands/github/workflow-automation.md +37 -10
- package/.claude/commands/hooks/overview.md +2 -2
- package/.claude/commands/hooks/setup.md +7 -7
- package/.claude/commands/memory/neural.md +10 -5
- package/.claude/commands/memory/usage.md +9 -5
- package/.claude/commands/monitoring/agents.md +7 -5
- package/.claude/commands/monitoring/status.md +8 -5
- package/.claude/commands/optimization/auto-topology.md +13 -1
- package/.claude/commands/optimization/parallel-execution.md +7 -1
- package/.claude/commands/sparc/analyzer.md +28 -2
- package/.claude/commands/sparc/architect.md +27 -1
- package/.claude/commands/sparc/batch-executor.md +27 -1
- package/.claude/commands/sparc/coder.md +27 -1
- package/.claude/commands/sparc/debugger.md +27 -1
- package/.claude/commands/sparc/designer.md +27 -1
- package/.claude/commands/sparc/documenter.md +27 -1
- package/.claude/commands/sparc/innovator.md +27 -1
- package/.claude/commands/sparc/memory-manager.md +27 -1
- package/.claude/commands/sparc/optimizer.md +27 -1
- package/.claude/commands/sparc/orchestrator.md +106 -2
- package/.claude/commands/sparc/researcher.md +27 -1
- package/.claude/commands/sparc/reviewer.md +27 -1
- package/.claude/commands/sparc/sparc-modes.md +137 -5
- package/.claude/commands/sparc/swarm-coordinator.md +27 -1
- package/.claude/commands/sparc/tdd.md +27 -1
- package/.claude/commands/sparc/tester.md +27 -1
- package/.claude/commands/sparc/workflow-manager.md +27 -1
- package/.claude/commands/swarm/analysis.md +82 -5
- package/.claude/commands/swarm/development.md +83 -6
- package/.claude/commands/swarm/examples.md +141 -3
- package/.claude/commands/swarm/maintenance.md +92 -8
- package/.claude/commands/swarm/optimization.md +107 -9
- package/.claude/commands/swarm/research.md +126 -8
- package/.claude/commands/swarm/testing.md +121 -9
- package/.claude/commands/training/neural-patterns.md +27 -2
- package/.claude/commands/training/specialization.md +13 -3
- package/.claude/commands/workflows/development.md +43 -4
- package/.claude/commands/workflows/research.md +26 -2
- package/CHANGELOG.md +34 -0
- package/README.md +8 -0
- package/bin/claude-flow +1 -1
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts +66 -0
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.d.ts.map +1 -1
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js +220 -2
- package/dist/cli/simple-commands/hive-mind/mcp-wrapper.js.map +1 -1
- package/dist/cli/simple-commands/hive-mind.d.ts.map +1 -1
- package/dist/cli/simple-commands/hive-mind.js +83 -5
- package/dist/cli/simple-commands/hive-mind.js.map +1 -1
- package/dist/memory/fallback-store.d.ts +1 -0
- package/dist/memory/fallback-store.d.ts.map +1 -1
- package/dist/memory/fallback-store.js +25 -3
- package/dist/memory/fallback-store.js.map +1 -1
- package/dist/memory/sqlite-store.d.ts +34 -0
- package/dist/memory/sqlite-store.d.ts.map +1 -0
- package/dist/memory/sqlite-store.js +2 -3
- package/dist/memory/sqlite-store.js.map +1 -1
- package/dist/memory/sqlite-wrapper.d.ts +38 -0
- package/dist/memory/sqlite-wrapper.d.ts.map +1 -0
- package/dist/memory/sqlite-wrapper.js +157 -0
- package/dist/memory/sqlite-wrapper.js.map +1 -0
- package/package.json +1 -1
- package/src/api/claude-api-errors.ts +248 -0
- package/src/api/claude-client-enhanced.ts +616 -0
- package/src/api/claude-client.ts +282 -14
- package/src/cli/help-text.js +4 -3
- package/src/cli/simple-cli.js +1 -1
- package/src/cli/simple-commands/coordination.js +73 -49
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +6 -6
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +327 -8
- package/src/cli/simple-commands/hive-mind/session-manager.js +330 -108
- package/src/cli/simple-commands/hive-mind.js +192 -11
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +53 -28
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +36 -14
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +107 -30
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/index.js +156 -235
- package/src/cli/simple-commands/init/template-copier.js +583 -0
- package/src/cli/simple-commands/init/templates/claude-flow-universal +1 -1
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +634 -23
- package/src/hive-mind/core/DatabaseManager.ts +75 -16
- package/src/memory/backends/sqlite.ts +21 -3
- package/src/memory/fallback-store.js +35 -3
- package/src/memory/sqlite-store.js +2 -3
- package/src/memory/sqlite-wrapper.js +173 -0
|
@@ -308,8 +308,10 @@ const hiveMindWizard = safeInteractive(
|
|
|
308
308
|
name: flags.name || `swarm-${Date.now()}`,
|
|
309
309
|
queenType: flags.queenType || flags['queen-type'] || 'strategic',
|
|
310
310
|
maxWorkers: parseInt(flags.maxWorkers || flags['max-workers'] || '8'),
|
|
311
|
-
consensusAlgorithm: flags.consensus || 'majority',
|
|
311
|
+
consensusAlgorithm: flags.consensus || flags.consensusAlgorithm || 'majority',
|
|
312
312
|
autoScale: flags.autoScale || flags['auto-scale'] || false,
|
|
313
|
+
namespace: flags.namespace || 'default',
|
|
314
|
+
verbose: flags.verbose || false,
|
|
313
315
|
encryption: flags.encryption || false,
|
|
314
316
|
};
|
|
315
317
|
|
|
@@ -405,11 +407,16 @@ async function spawnSwarmWizard() {
|
|
|
405
407
|
await spawnSwarm([answers.objective], {
|
|
406
408
|
name: answers.name,
|
|
407
409
|
queenType: answers.queenType,
|
|
410
|
+
'queen-type': answers.queenType,
|
|
408
411
|
maxWorkers: answers.maxWorkers,
|
|
412
|
+
'max-workers': answers.maxWorkers,
|
|
409
413
|
workerTypes: answers.workerTypes.join(','),
|
|
410
414
|
consensus: answers.consensusAlgorithm,
|
|
411
415
|
autoScale: answers.autoScale,
|
|
416
|
+
'auto-scale': answers.autoScale,
|
|
412
417
|
monitor: answers.monitor,
|
|
418
|
+
namespace: answers.namespace || 'default',
|
|
419
|
+
verbose: answers.verbose || false,
|
|
413
420
|
});
|
|
414
421
|
}
|
|
415
422
|
|
|
@@ -425,6 +432,35 @@ async function spawnSwarm(args, flags) {
|
|
|
425
432
|
return;
|
|
426
433
|
}
|
|
427
434
|
|
|
435
|
+
// Validate parameters
|
|
436
|
+
if (flags.verbose) {
|
|
437
|
+
console.log(chalk.gray('🔍 Debug: Parsed flags:'));
|
|
438
|
+
console.log(chalk.gray(JSON.stringify(flags, null, 2)));
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Validate queen type
|
|
442
|
+
const validQueenTypes = ['strategic', 'tactical', 'adaptive'];
|
|
443
|
+
const queenType = flags.queenType || flags['queen-type'] || 'strategic';
|
|
444
|
+
if (!validQueenTypes.includes(queenType)) {
|
|
445
|
+
console.error(chalk.red(`Error: Invalid queen type '${queenType}'. Must be one of: ${validQueenTypes.join(', ')}`));
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Validate max workers
|
|
450
|
+
const maxWorkers = parseInt(flags.maxWorkers || flags['max-workers'] || '8');
|
|
451
|
+
if (isNaN(maxWorkers) || maxWorkers < 1 || maxWorkers > 20) {
|
|
452
|
+
console.error(chalk.red('Error: max-workers must be a number between 1 and 20'));
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Validate consensus algorithm
|
|
457
|
+
const validConsensusTypes = ['majority', 'weighted', 'byzantine'];
|
|
458
|
+
const consensusAlgorithm = flags.consensus || flags.consensusAlgorithm || 'majority';
|
|
459
|
+
if (!validConsensusTypes.includes(consensusAlgorithm)) {
|
|
460
|
+
console.error(chalk.red(`Error: Invalid consensus algorithm '${consensusAlgorithm}'. Must be one of: ${validConsensusTypes.join(', ')}`));
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
|
|
428
464
|
const spinner = ora('Spawning Hive Mind swarm...').start();
|
|
429
465
|
|
|
430
466
|
try {
|
|
@@ -435,10 +471,11 @@ async function spawnSwarm(args, flags) {
|
|
|
435
471
|
hiveMind = new HiveMindCore({
|
|
436
472
|
objective,
|
|
437
473
|
name: flags.name || `hive-${Date.now()}`,
|
|
438
|
-
queenType: flags.queenType || 'strategic',
|
|
439
|
-
maxWorkers: flags.maxWorkers || 8,
|
|
440
|
-
consensusAlgorithm: flags.consensus || 'majority',
|
|
441
|
-
autoScale: flags.autoScale !==
|
|
474
|
+
queenType: flags.queenType || flags['queen-type'] || 'strategic',
|
|
475
|
+
maxWorkers: parseInt(flags.maxWorkers || flags['max-workers'] || '8'),
|
|
476
|
+
consensusAlgorithm: flags.consensus || flags.consensusAlgorithm || 'majority',
|
|
477
|
+
autoScale: flags.autoScale !== undefined ? flags.autoScale : (flags['auto-scale'] !== undefined ? flags['auto-scale'] : true),
|
|
478
|
+
namespace: flags.namespace || 'default',
|
|
442
479
|
encryption: flags.encryption || false,
|
|
443
480
|
});
|
|
444
481
|
} catch (error) {
|
|
@@ -574,7 +611,7 @@ async function spawnSwarm(args, flags) {
|
|
|
574
611
|
// Create session for this swarm
|
|
575
612
|
spinner.text = 'Creating session tracking...';
|
|
576
613
|
const sessionManager = new HiveMindSessionManager();
|
|
577
|
-
const sessionId = sessionManager.createSession(swarmId, hiveMind.config.name, objective, {
|
|
614
|
+
const sessionId = await sessionManager.createSession(swarmId, hiveMind.config.name, objective, {
|
|
578
615
|
queenType: hiveMind.config.queenType,
|
|
579
616
|
maxWorkers: hiveMind.config.maxWorkers,
|
|
580
617
|
consensusAlgorithm: hiveMind.config.consensusAlgorithm,
|
|
@@ -584,14 +621,16 @@ async function spawnSwarm(args, flags) {
|
|
|
584
621
|
});
|
|
585
622
|
|
|
586
623
|
spinner.text = 'Session tracking established...';
|
|
587
|
-
sessionManager.close();
|
|
588
624
|
|
|
589
|
-
// Initialize auto-save middleware
|
|
590
|
-
const autoSave = createAutoSaveMiddleware(sessionId, {
|
|
625
|
+
// Initialize auto-save middleware (use the same session manager)
|
|
626
|
+
const autoSave = createAutoSaveMiddleware(sessionId, sessionManager, {
|
|
591
627
|
saveInterval: 30000, // Save every 30 seconds
|
|
592
628
|
autoStart: true,
|
|
593
629
|
});
|
|
594
630
|
|
|
631
|
+
// Close session manager after auto-save is set up
|
|
632
|
+
// sessionManager.close(); // Don't close yet as auto-save needs it
|
|
633
|
+
|
|
595
634
|
// Track initial swarm creation
|
|
596
635
|
autoSave.trackChange('swarm_created', {
|
|
597
636
|
swarmId,
|
|
@@ -719,6 +758,59 @@ async function spawnSwarm(args, flags) {
|
|
|
719
758
|
console.log(chalk.blue('💡 To pause:') + ' Press Ctrl+C to safely pause and resume later');
|
|
720
759
|
console.log(chalk.blue('💡 To resume:') + ' claude-flow hive-mind resume ' + sessionId);
|
|
721
760
|
|
|
761
|
+
// Set up SIGINT handler for automatic session pausing
|
|
762
|
+
let isExiting = false;
|
|
763
|
+
const sigintHandler = async () => {
|
|
764
|
+
if (isExiting) return;
|
|
765
|
+
isExiting = true;
|
|
766
|
+
|
|
767
|
+
console.log('\n\n' + chalk.yellow('⏸️ Pausing session...'));
|
|
768
|
+
|
|
769
|
+
try {
|
|
770
|
+
// Save current checkpoint using the existing session manager
|
|
771
|
+
// const sessionManager = new HiveMindSessionManager(); // Use existing one
|
|
772
|
+
|
|
773
|
+
// Create checkpoint data
|
|
774
|
+
const checkpointData = {
|
|
775
|
+
timestamp: new Date().toISOString(),
|
|
776
|
+
swarmId,
|
|
777
|
+
objective,
|
|
778
|
+
workerCount: workers.length,
|
|
779
|
+
workerTypes,
|
|
780
|
+
status: 'paused_by_user',
|
|
781
|
+
reason: 'User pressed Ctrl+C',
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
// Save checkpoint
|
|
785
|
+
await sessionManager.saveCheckpoint(sessionId, 'auto-pause', checkpointData);
|
|
786
|
+
|
|
787
|
+
// Pause the session
|
|
788
|
+
await sessionManager.pauseSession(sessionId);
|
|
789
|
+
|
|
790
|
+
// Close session manager
|
|
791
|
+
sessionManager.close();
|
|
792
|
+
|
|
793
|
+
console.log(chalk.green('✓') + ' Session paused successfully');
|
|
794
|
+
console.log(chalk.cyan('\nTo resume this session, run:'));
|
|
795
|
+
console.log(chalk.bold(` claude-flow hive-mind resume ${sessionId}`));
|
|
796
|
+
console.log();
|
|
797
|
+
|
|
798
|
+
// Clean up auto-save if active
|
|
799
|
+
if (global.autoSaveInterval) {
|
|
800
|
+
clearInterval(global.autoSaveInterval);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
process.exit(0);
|
|
804
|
+
} catch (error) {
|
|
805
|
+
console.error(chalk.red('Error pausing session:'), error.message);
|
|
806
|
+
process.exit(1);
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
// Register SIGINT handler
|
|
811
|
+
process.on('SIGINT', sigintHandler);
|
|
812
|
+
process.on('SIGTERM', sigintHandler);
|
|
813
|
+
|
|
722
814
|
// Offer to spawn Claude Code instances with coordination instructions
|
|
723
815
|
if (flags.claude || flags.spawn) {
|
|
724
816
|
await spawnClaudeCodeInstances(swarmId, hiveMind.config.name, objective, workers, flags);
|
|
@@ -1771,6 +1863,20 @@ async function exportMemoryBackup() {
|
|
|
1771
1863
|
}
|
|
1772
1864
|
}
|
|
1773
1865
|
|
|
1866
|
+
/**
|
|
1867
|
+
* Get active session ID for a swarm
|
|
1868
|
+
*/
|
|
1869
|
+
async function getActiveSessionId(swarmId) {
|
|
1870
|
+
const sessionManager = new HiveMindSessionManager();
|
|
1871
|
+
try {
|
|
1872
|
+
const sessions = sessionManager.getActiveSessions();
|
|
1873
|
+
const activeSession = sessions.find(s => s.swarm_id === swarmId && s.status === 'active');
|
|
1874
|
+
return activeSession ? activeSession.id : null;
|
|
1875
|
+
} finally {
|
|
1876
|
+
sessionManager.close();
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1774
1880
|
/**
|
|
1775
1881
|
* Spawn Claude Code with Hive Mind coordination instructions
|
|
1776
1882
|
*/
|
|
@@ -1850,6 +1956,59 @@ async function spawnClaudeCodeInstances(swarmId, swarmName, objective, workers,
|
|
|
1850
1956
|
shell: false,
|
|
1851
1957
|
});
|
|
1852
1958
|
|
|
1959
|
+
// Track child process PID in session
|
|
1960
|
+
const sessionManager = new HiveMindSessionManager();
|
|
1961
|
+
const sessionId = await getActiveSessionId(swarmId);
|
|
1962
|
+
if (sessionId && claudeProcess.pid) {
|
|
1963
|
+
sessionManager.addChildPid(sessionId, claudeProcess.pid);
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
// Set up SIGINT handler for automatic session pausing
|
|
1967
|
+
let isExiting = false;
|
|
1968
|
+
const sigintHandler = async () => {
|
|
1969
|
+
if (isExiting) return;
|
|
1970
|
+
isExiting = true;
|
|
1971
|
+
|
|
1972
|
+
console.log('\n\n' + chalk.yellow('⏸️ Pausing session and terminating Claude Code...'));
|
|
1973
|
+
|
|
1974
|
+
try {
|
|
1975
|
+
// Terminate Claude Code process
|
|
1976
|
+
if (claudeProcess && !claudeProcess.killed) {
|
|
1977
|
+
claudeProcess.kill('SIGTERM');
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
// Save checkpoint and pause session
|
|
1981
|
+
if (sessionId) {
|
|
1982
|
+
const checkpointData = {
|
|
1983
|
+
timestamp: new Date().toISOString(),
|
|
1984
|
+
swarmId,
|
|
1985
|
+
objective,
|
|
1986
|
+
status: 'paused_by_user',
|
|
1987
|
+
reason: 'User pressed Ctrl+C during Claude Code execution',
|
|
1988
|
+
claudePid: claudeProcess.pid,
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1991
|
+
await sessionManager.saveCheckpoint(sessionId, 'auto-pause-claude', checkpointData);
|
|
1992
|
+
await sessionManager.pauseSession(sessionId);
|
|
1993
|
+
|
|
1994
|
+
console.log(chalk.green('✓') + ' Session paused successfully');
|
|
1995
|
+
console.log(chalk.cyan('\nTo resume this session, run:'));
|
|
1996
|
+
console.log(chalk.bold(` claude-flow hive-mind resume ${sessionId}`));
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
sessionManager.close();
|
|
2000
|
+
process.exit(0);
|
|
2001
|
+
} catch (error) {
|
|
2002
|
+
console.error(chalk.red('Error pausing session:'), error.message);
|
|
2003
|
+
sessionManager.close();
|
|
2004
|
+
process.exit(1);
|
|
2005
|
+
}
|
|
2006
|
+
};
|
|
2007
|
+
|
|
2008
|
+
// Register SIGINT handler
|
|
2009
|
+
process.on('SIGINT', sigintHandler);
|
|
2010
|
+
process.on('SIGTERM', sigintHandler);
|
|
2011
|
+
|
|
1853
2012
|
// Handle stdout
|
|
1854
2013
|
if (claudeProcess.stdout) {
|
|
1855
2014
|
claudeProcess.stdout.on('data', (data) => {
|
|
@@ -1866,9 +2025,15 @@ async function spawnClaudeCodeInstances(swarmId, swarmName, objective, workers,
|
|
|
1866
2025
|
|
|
1867
2026
|
// Handle process exit
|
|
1868
2027
|
claudeProcess.on('exit', (code) => {
|
|
2028
|
+
// Remove child PID from session
|
|
2029
|
+
if (sessionId && claudeProcess.pid) {
|
|
2030
|
+
sessionManager.removeChildPid(sessionId, claudeProcess.pid);
|
|
2031
|
+
sessionManager.close();
|
|
2032
|
+
}
|
|
2033
|
+
|
|
1869
2034
|
if (code === 0) {
|
|
1870
2035
|
console.log(chalk.green('\n✓ Claude Code completed successfully'));
|
|
1871
|
-
} else {
|
|
2036
|
+
} else if (code !== null) {
|
|
1872
2037
|
console.log(chalk.red(`\n✗ Claude Code exited with code ${code}`));
|
|
1873
2038
|
}
|
|
1874
2039
|
});
|
|
@@ -2574,6 +2739,18 @@ async function launchClaudeWithContext(prompt, flags) {
|
|
|
2574
2739
|
shell: false,
|
|
2575
2740
|
});
|
|
2576
2741
|
|
|
2742
|
+
// Set up SIGINT handler for clean termination (no session pausing here since we're resuming)
|
|
2743
|
+
const sigintHandler = () => {
|
|
2744
|
+
console.log('\n\n' + chalk.yellow('⏹️ Terminating Claude Code...'));
|
|
2745
|
+
if (claudeProcess && !claudeProcess.killed) {
|
|
2746
|
+
claudeProcess.kill('SIGTERM');
|
|
2747
|
+
}
|
|
2748
|
+
process.exit(0);
|
|
2749
|
+
};
|
|
2750
|
+
|
|
2751
|
+
process.on('SIGINT', sigintHandler);
|
|
2752
|
+
process.on('SIGTERM', sigintHandler);
|
|
2753
|
+
|
|
2577
2754
|
// Handle stdout
|
|
2578
2755
|
if (claudeProcess.stdout) {
|
|
2579
2756
|
claudeProcess.stdout.on('data', (data) => {
|
|
@@ -2592,9 +2769,13 @@ async function launchClaudeWithContext(prompt, flags) {
|
|
|
2592
2769
|
claudeProcess.on('exit', (code) => {
|
|
2593
2770
|
if (code === 0) {
|
|
2594
2771
|
console.log(chalk.green('\n✓ Claude Code completed successfully'));
|
|
2595
|
-
} else {
|
|
2772
|
+
} else if (code !== null) {
|
|
2596
2773
|
console.log(chalk.red(`\n✗ Claude Code exited with code ${code}`));
|
|
2597
2774
|
}
|
|
2775
|
+
|
|
2776
|
+
// Clean up signal handlers
|
|
2777
|
+
process.removeListener('SIGINT', sigintHandler);
|
|
2778
|
+
process.removeListener('SIGTERM', sigintHandler);
|
|
2598
2779
|
});
|
|
2599
2780
|
|
|
2600
2781
|
console.log(chalk.green('\n✓ Claude Code launched with restored session context'));
|
|
@@ -5,39 +5,65 @@ import {
|
|
|
5
5
|
createOptimizedMainSparcCommand,
|
|
6
6
|
} from './optimized-sparc-commands.js';
|
|
7
7
|
import { createOptimizedClaudeFlowCommands } from './optimized-claude-flow-commands.js';
|
|
8
|
+
import { copyTemplates } from '../template-copier.js';
|
|
9
|
+
import { promises as fs } from 'fs';
|
|
10
|
+
import { join } from 'path';
|
|
8
11
|
|
|
9
12
|
// Create batchtools-optimized Claude Code slash commands for SPARC modes
|
|
10
13
|
export async function createOptimizedClaudeSlashCommands(workingDir, selectedModes = null) {
|
|
11
14
|
try {
|
|
12
15
|
console.log('\n🚀 Creating batchtools-optimized Claude Code slash commands...');
|
|
13
16
|
|
|
14
|
-
//
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
17
|
+
// Use template copier with optimized flag
|
|
18
|
+
const optimizedOptions = {
|
|
19
|
+
sparc: true,
|
|
20
|
+
optimized: true,
|
|
21
|
+
force: true,
|
|
22
|
+
dryRun: false,
|
|
23
|
+
selectedModes: selectedModes,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Check if .roomodes exists for dynamic generation
|
|
27
|
+
const roomodesPath = `${workingDir}/.roomodes`;
|
|
28
|
+
try {
|
|
29
|
+
const roomodesContent = await fs.readFile(roomodesPath, 'utf8');
|
|
30
|
+
const roomodes = JSON.parse(roomodesContent);
|
|
31
|
+
|
|
32
|
+
// Filter modes if selective initialization is requested
|
|
33
|
+
const modesToCreate = selectedModes
|
|
34
|
+
? roomodes.customModes.filter((mode) => selectedModes.includes(mode.slug))
|
|
35
|
+
: roomodes.customModes;
|
|
36
|
+
|
|
37
|
+
console.log(` 📝 Creating optimized commands for ${modesToCreate.length} modes...`);
|
|
38
|
+
|
|
39
|
+
// Create slash commands for each SPARC mode with batchtools optimization
|
|
40
|
+
const commandPromises = modesToCreate.map(async (mode) => {
|
|
41
|
+
const commandPath = join(workingDir, '.claude', 'commands', 'sparc', `${mode.slug}.md`);
|
|
42
|
+
const commandContent = createOptimizedSparcSlashCommand(mode);
|
|
43
|
+
|
|
44
|
+
await fs.mkdir(join(workingDir, '.claude', 'commands', 'sparc'), { recursive: true });
|
|
45
|
+
await fs.writeFile(commandPath, commandContent);
|
|
46
|
+
console.log(` ✓ Created optimized slash command: /sparc-${mode.slug} (Batchtools enhanced)`);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Execute all command creations in parallel
|
|
50
|
+
await Promise.all(commandPromises);
|
|
51
|
+
|
|
52
|
+
// Create main SPARC command with batchtools optimization
|
|
53
|
+
const mainSparcCommand = createOptimizedMainSparcCommand(roomodes.customModes);
|
|
54
|
+
await fs.writeFile(join(workingDir, '.claude', 'commands', 'sparc.md'), mainSparcCommand);
|
|
55
|
+
console.log(' ✅ Created optimized main slash command: /sparc (Batchtools enhanced)');
|
|
56
|
+
|
|
57
|
+
console.log(` 🎯 Total optimized commands created: ${modesToCreate.length + 5}`);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
// Fallback to template copier if .roomodes doesn't exist
|
|
60
|
+
console.log(' 🔄 Using template copier for optimized SPARC commands...');
|
|
61
|
+
const copyResults = await copyTemplates(workingDir, optimizedOptions);
|
|
62
|
+
|
|
63
|
+
if (!copyResults.success) {
|
|
64
|
+
console.log(` ⚠️ Template copier failed: ${copyResults.errors.join(', ')}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
41
67
|
|
|
42
68
|
// Create claude-flow specific commands with batchtools optimization
|
|
43
69
|
await createOptimizedClaudeFlowCommands(workingDir);
|
|
@@ -45,7 +71,6 @@ export async function createOptimizedClaudeSlashCommands(workingDir, selectedMod
|
|
|
45
71
|
// Create batchtools-specific commands
|
|
46
72
|
await createBatchtoolsCommands(workingDir);
|
|
47
73
|
|
|
48
|
-
console.log(` 🎯 Total optimized commands created: ${modesToCreate.length + 5}`);
|
|
49
74
|
console.log(' 💡 All commands include parallel processing and performance optimizations');
|
|
50
75
|
} catch (err) {
|
|
51
76
|
console.log(` ⚠️ Could not create optimized Claude Code slash commands: ${err.message}`);
|
|
@@ -2,29 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
import { createSparcSlashCommand, createMainSparcCommand } from './sparc-commands.js';
|
|
4
4
|
import { createClaudeFlowCommands } from './claude-flow-commands.js';
|
|
5
|
+
import { copyTemplates } from '../template-copier.js';
|
|
6
|
+
import { promises as fs } from 'fs';
|
|
7
|
+
import { join } from 'path';
|
|
5
8
|
|
|
6
9
|
// Create Claude Code slash commands for SPARC modes
|
|
7
10
|
export async function createClaudeSlashCommands(workingDir) {
|
|
8
11
|
try {
|
|
9
12
|
console.log('\n📝 Creating Claude Code slash commands...');
|
|
10
13
|
|
|
11
|
-
//
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
+
// Use template copier for SPARC slash commands
|
|
15
|
+
const slashCommandOptions = {
|
|
16
|
+
sparc: true,
|
|
17
|
+
force: true,
|
|
18
|
+
dryRun: false,
|
|
19
|
+
};
|
|
14
20
|
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
21
|
+
// Check if .roomodes exists for dynamic generation
|
|
22
|
+
const roomodesPath = `${workingDir}/.roomodes`;
|
|
23
|
+
try {
|
|
24
|
+
const roomodesContent = await fs.readFile(roomodesPath, 'utf8');
|
|
25
|
+
const roomodes = JSON.parse(roomodesContent);
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
// Create slash commands for each SPARC mode
|
|
28
|
+
for (const mode of roomodes.customModes) {
|
|
29
|
+
const commandPath = join(workingDir, '.claude', 'commands', 'sparc', `${mode.slug}.md`);
|
|
30
|
+
const commandContent = createSparcSlashCommand(mode);
|
|
31
|
+
|
|
32
|
+
await fs.mkdir(join(workingDir, '.claude', 'commands', 'sparc'), { recursive: true });
|
|
33
|
+
await fs.writeFile(commandPath, commandContent);
|
|
34
|
+
console.log(` ✓ Created slash command: /sparc-${mode.slug}`);
|
|
35
|
+
}
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
// Create main SPARC command
|
|
38
|
+
const mainSparcCommand = createMainSparcCommand(roomodes.customModes);
|
|
39
|
+
await fs.writeFile(join(workingDir, '.claude', 'commands', 'sparc.md'), mainSparcCommand);
|
|
40
|
+
console.log(' ✓ Created main slash command: /sparc');
|
|
41
|
+
} catch (err) {
|
|
42
|
+
// Fallback to template copier if .roomodes doesn't exist
|
|
43
|
+
console.log(' 🔄 Using template copier for SPARC commands...');
|
|
44
|
+
const copyResults = await copyTemplates(workingDir, slashCommandOptions);
|
|
45
|
+
|
|
46
|
+
if (!copyResults.success) {
|
|
47
|
+
console.log(` ⚠️ Template copier failed: ${copyResults.errors.join(', ')}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
28
50
|
|
|
29
51
|
// Create claude-flow specific commands
|
|
30
52
|
await createClaudeFlowCommands(workingDir);
|
|
@@ -39,34 +39,66 @@ ${
|
|
|
39
39
|
|
|
40
40
|
## Usage
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
### Option 1: Using MCP Tools (Preferred in Claude Code)
|
|
43
|
+
\`\`\`javascript
|
|
44
|
+
mcp__claude-flow__sparc_mode {
|
|
45
|
+
mode: "${mode.slug}",
|
|
46
|
+
task_description: "${getExampleTask(mode.slug)}",
|
|
47
|
+
options: {
|
|
48
|
+
namespace: "${mode.slug}",
|
|
49
|
+
non_interactive: false
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
\`\`\`
|
|
43
53
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
### Option 2: Using NPX CLI (Fallback when MCP not available)
|
|
55
|
+
\`\`\`bash
|
|
56
|
+
# Use when running from terminal or MCP tools unavailable
|
|
57
|
+
npx claude-flow sparc run ${mode.slug} "${getExampleTask(mode.slug)}"
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
# For alpha features
|
|
60
|
+
npx claude-flow@alpha sparc run ${mode.slug} "${getExampleTask(mode.slug)}"
|
|
50
61
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
./claude-flow sparc run ${mode.slug} "${getExampleTask(mode.slug)}"
|
|
62
|
+
# With namespace
|
|
63
|
+
npx claude-flow sparc run ${mode.slug} "your task" --namespace ${mode.slug}
|
|
54
64
|
|
|
55
|
-
#
|
|
56
|
-
|
|
65
|
+
# Non-interactive mode
|
|
66
|
+
npx claude-flow sparc run ${mode.slug} "your task" --non-interactive
|
|
67
|
+
\`\`\`
|
|
57
68
|
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
### Option 3: Local Installation
|
|
70
|
+
\`\`\`bash
|
|
71
|
+
# If claude-flow is installed locally
|
|
72
|
+
./claude-flow sparc run ${mode.slug} "${getExampleTask(mode.slug)}"
|
|
60
73
|
\`\`\`
|
|
61
74
|
|
|
62
75
|
## Memory Integration
|
|
63
76
|
|
|
77
|
+
### Using MCP Tools (Preferred)
|
|
78
|
+
\`\`\`javascript
|
|
79
|
+
// Store mode-specific context
|
|
80
|
+
mcp__claude-flow__memory_usage {
|
|
81
|
+
action: "store",
|
|
82
|
+
key: "${mode.slug}_context",
|
|
83
|
+
value: "important decisions",
|
|
84
|
+
namespace: "${mode.slug}"
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Query previous work
|
|
88
|
+
mcp__claude-flow__memory_search {
|
|
89
|
+
pattern: "${mode.slug}",
|
|
90
|
+
namespace: "${mode.slug}",
|
|
91
|
+
limit: 5
|
|
92
|
+
}
|
|
93
|
+
\`\`\`
|
|
94
|
+
|
|
95
|
+
### Using NPX CLI (Fallback)
|
|
64
96
|
\`\`\`bash
|
|
65
97
|
# Store mode-specific context
|
|
66
|
-
|
|
98
|
+
npx claude-flow memory store "${mode.slug}_context" "important decisions" --namespace ${mode.slug}
|
|
67
99
|
|
|
68
100
|
# Query previous work
|
|
69
|
-
|
|
101
|
+
npx claude-flow memory query "${mode.slug}" --limit 5
|
|
70
102
|
\`\`\`
|
|
71
103
|
`;
|
|
72
104
|
}
|
|
@@ -137,26 +169,52 @@ ${modeList}
|
|
|
137
169
|
|
|
138
170
|
## Quick Start
|
|
139
171
|
|
|
140
|
-
###
|
|
141
|
-
\`\`\`
|
|
142
|
-
|
|
143
|
-
|
|
172
|
+
### Option 1: Using MCP Tools (Preferred in Claude Code)
|
|
173
|
+
\`\`\`javascript
|
|
174
|
+
// Run SPARC orchestrator (default)
|
|
175
|
+
mcp__claude-flow__sparc_mode {
|
|
176
|
+
mode: "sparc",
|
|
177
|
+
task_description: "build complete authentication system"
|
|
178
|
+
}
|
|
144
179
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
180
|
+
// Run a specific mode
|
|
181
|
+
mcp__claude-flow__sparc_mode {
|
|
182
|
+
mode: "architect",
|
|
183
|
+
task_description: "design API structure"
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// TDD workflow
|
|
187
|
+
mcp__claude-flow__sparc_mode {
|
|
188
|
+
mode: "tdd",
|
|
189
|
+
task_description: "implement user authentication",
|
|
190
|
+
options: {workflow: "full"}
|
|
191
|
+
}
|
|
150
192
|
\`\`\`
|
|
151
193
|
|
|
152
|
-
###
|
|
194
|
+
### Option 2: Using NPX CLI (Fallback when MCP not available)
|
|
153
195
|
\`\`\`bash
|
|
154
|
-
|
|
196
|
+
# Run SPARC orchestrator (default)
|
|
197
|
+
npx claude-flow sparc "build complete authentication system"
|
|
198
|
+
|
|
199
|
+
# Run a specific mode
|
|
200
|
+
npx claude-flow sparc run architect "design API structure"
|
|
201
|
+
npx claude-flow sparc run tdd "implement user service"
|
|
202
|
+
|
|
203
|
+
# Execute full TDD workflow
|
|
204
|
+
npx claude-flow sparc tdd "implement user authentication"
|
|
205
|
+
|
|
206
|
+
# List all modes with details
|
|
207
|
+
npx claude-flow sparc modes --verbose
|
|
208
|
+
|
|
209
|
+
# For alpha features
|
|
210
|
+
npx claude-flow@alpha sparc run <mode> "your task"
|
|
155
211
|
\`\`\`
|
|
156
212
|
|
|
157
|
-
###
|
|
213
|
+
### Option 3: Local Installation
|
|
158
214
|
\`\`\`bash
|
|
159
|
-
|
|
215
|
+
# If claude-flow is installed locally
|
|
216
|
+
./claude-flow sparc "build complete authentication system"
|
|
217
|
+
./claude-flow sparc run architect "design API structure"
|
|
160
218
|
\`\`\`
|
|
161
219
|
|
|
162
220
|
## SPARC Methodology Phases
|
|
@@ -169,10 +227,29 @@ ${modeList}
|
|
|
169
227
|
|
|
170
228
|
## Memory Integration
|
|
171
229
|
|
|
172
|
-
|
|
230
|
+
### Using MCP Tools (Preferred)
|
|
231
|
+
\`\`\`javascript
|
|
232
|
+
// Store specifications
|
|
233
|
+
mcp__claude-flow__memory_usage {
|
|
234
|
+
action: "store",
|
|
235
|
+
key: "spec_auth",
|
|
236
|
+
value: "OAuth2 + JWT requirements",
|
|
237
|
+
namespace: "spec"
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Store architectural decisions
|
|
241
|
+
mcp__claude-flow__memory_usage {
|
|
242
|
+
action: "store",
|
|
243
|
+
key: "arch_decisions",
|
|
244
|
+
value: "Microservices with API Gateway",
|
|
245
|
+
namespace: "architecture"
|
|
246
|
+
}
|
|
247
|
+
\`\`\`
|
|
248
|
+
|
|
249
|
+
### Using NPX CLI (Fallback)
|
|
173
250
|
\`\`\`bash
|
|
174
251
|
# Store specifications
|
|
175
|
-
|
|
252
|
+
npx claude-flow memory store "spec_auth" "OAuth2 + JWT requirements" --namespace spec
|
|
176
253
|
|
|
177
254
|
# Store architectural decisions
|
|
178
255
|
./claude-flow memory store "arch_api" "RESTful microservices design" --namespace arch
|