claude-flow-novice 2.0.3 → 2.0.4
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/dist/src/cli/commands/guidance.js +487 -668
- package/dist/src/cli/commands/index-validate.js +18 -29
- package/dist/src/cli/commands/mcp-troubleshoot.js +230 -282
- package/dist/src/cli/commands/neural-goal-init.js +92 -125
- package/dist/src/cli/commands/swarm-exec.js +317 -393
- package/dist/src/cli/commands/swarm.js +1 -1
- package/dist/src/cli/commands/validate-framework.js +983 -1100
- package/dist/src/cli/commands/validate.js +144 -223
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +265 -277
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +6 -7
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +373 -356
- package/dist/src/cli/simple-commands/__tests__/task.test.js +6 -7
- package/dist/src/cli/simple-commands/agent.js +157 -193
- package/dist/src/cli/simple-commands/analysis.js +336 -446
- package/dist/src/cli/simple-commands/automation-executor.js +1095 -1339
- package/dist/src/cli/simple-commands/automation.js +481 -469
- package/dist/src/cli/simple-commands/batch-manager.js +261 -313
- package/dist/src/cli/simple-commands/claude-telemetry.js +241 -267
- package/dist/src/cli/simple-commands/claude-track.js +68 -90
- package/dist/src/cli/simple-commands/concurrent-display.js +266 -320
- package/dist/src/cli/simple-commands/config.js +245 -290
- package/dist/src/cli/simple-commands/coordination.js +182 -234
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +812 -615
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +922 -981
- package/dist/src/cli/simple-commands/fix-hook-variables.js +274 -294
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +378 -457
- package/dist/src/cli/simple-commands/github/github-api.js +535 -574
- package/dist/src/cli/simple-commands/github/init.js +276 -303
- package/dist/src/cli/simple-commands/github.js +222 -247
- package/dist/src/cli/simple-commands/goal.js +51 -63
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +208 -278
- package/dist/src/cli/simple-commands/hive-mind/communication.js +601 -696
- package/dist/src/cli/simple-commands/hive-mind/core.js +907 -979
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +406 -655
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1125 -1245
- package/dist/src/cli/simple-commands/hive-mind/memory.js +854 -1090
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +459 -574
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +263 -347
- package/dist/src/cli/simple-commands/hive-mind/queen.js +727 -768
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +745 -1049
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +227 -283
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +174 -217
- package/dist/src/cli/simple-commands/hive-mind.js +1842 -2283
- package/dist/src/cli/simple-commands/hive.js +90 -79
- package/dist/src/cli/simple-commands/hook-safety.js +431 -521
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +203 -254
- package/dist/src/cli/simple-commands/hooks.js +1064 -1204
- package/dist/src/cli/simple-commands/init/agent-copier.js +294 -319
- package/dist/src/cli/simple-commands/init/batch-init.js +496 -562
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +61 -88
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +125 -150
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +42 -49
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +43 -61
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +141 -147
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +31 -44
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +64 -90
- package/dist/src/cli/simple-commands/init/help.js +104 -107
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +509 -528
- package/dist/src/cli/simple-commands/init/index.js +1510 -1759
- package/dist/src/cli/simple-commands/init/performance-monitor.js +234 -317
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +441 -504
- package/dist/src/cli/simple-commands/init/rollback/index.js +289 -364
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +652 -728
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +416 -481
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +369 -448
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +1 -2
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +122 -99
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +32 -37
- package/dist/src/cli/simple-commands/init/sparc-structure.js +55 -62
- package/dist/src/cli/simple-commands/init/template-copier.js +421 -533
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +344 -318
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +173 -218
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +65 -75
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +2 -4
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +187 -230
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +53 -80
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +101 -85
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +283 -330
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +495 -561
- package/dist/src/cli/simple-commands/init/validation/index.js +302 -358
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +308 -359
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +389 -366
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +270 -268
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +427 -447
- package/dist/src/cli/simple-commands/init.js +1 -2
- package/dist/src/cli/simple-commands/mcp-health.js +131 -158
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +533 -634
- package/dist/src/cli/simple-commands/mcp.js +345 -400
- package/dist/src/cli/simple-commands/memory-consolidation.js +426 -537
- package/dist/src/cli/simple-commands/memory.js +247 -311
- package/dist/src/cli/simple-commands/migrate-hooks.js +39 -46
- package/dist/src/cli/simple-commands/monitor.js +294 -363
- package/dist/src/cli/simple-commands/neural.js +51 -65
- package/dist/src/cli/simple-commands/pair-autofix-only.js +538 -662
- package/dist/src/cli/simple-commands/pair-basic.js +528 -656
- package/dist/src/cli/simple-commands/pair-old.js +430 -543
- package/dist/src/cli/simple-commands/pair-working.js +615 -751
- package/dist/src/cli/simple-commands/pair.js +615 -751
- package/dist/src/cli/simple-commands/performance-hooks.js +83 -111
- package/dist/src/cli/simple-commands/performance-metrics.js +348 -433
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +708 -787
- package/dist/src/cli/simple-commands/process-ui.js +230 -254
- package/dist/src/cli/simple-commands/realtime-update-system.js +525 -611
- package/dist/src/cli/simple-commands/sparc/architecture.js +1704 -1530
- package/dist/src/cli/simple-commands/sparc/commands.js +438 -516
- package/dist/src/cli/simple-commands/sparc/completion.js +1224 -1481
- package/dist/src/cli/simple-commands/sparc/coordinator.js +913 -978
- package/dist/src/cli/simple-commands/sparc/index.js +241 -298
- package/dist/src/cli/simple-commands/sparc/phase-base.js +314 -390
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +965 -869
- package/dist/src/cli/simple-commands/sparc/refinement.js +980 -1273
- package/dist/src/cli/simple-commands/sparc/specification.js +559 -645
- package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/index.js +47 -55
- package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/swarm.js +101 -87
- package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
- package/dist/src/cli/simple-commands/sparc.js +465 -493
- package/dist/src/cli/simple-commands/start-ui.js +108 -132
- package/dist/src/cli/simple-commands/start-wrapper.js +240 -268
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +254 -275
- package/dist/src/cli/simple-commands/stream-chain-clean.js +128 -171
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +61 -82
- package/dist/src/cli/simple-commands/stream-chain-real.js +267 -331
- package/dist/src/cli/simple-commands/stream-chain-working.js +211 -263
- package/dist/src/cli/simple-commands/stream-chain.js +260 -318
- package/dist/src/cli/simple-commands/stream-processor.js +290 -315
- package/dist/src/cli/simple-commands/swarm-executor.js +189 -222
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +208 -300
- package/dist/src/cli/simple-commands/swarm-ui.js +623 -703
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +258 -286
- package/dist/src/cli/simple-commands/swarm.js +887 -1082
- package/dist/src/cli/simple-commands/task.js +161 -206
- package/dist/src/cli/simple-commands/timestamp-fix.js +59 -89
- package/dist/src/cli/simple-commands/token-tracker.js +258 -316
- package/dist/src/cli/simple-commands/tool-execution-framework.js +433 -519
- package/dist/src/cli/simple-commands/train-and-stream.js +275 -331
- package/dist/src/cli/simple-commands/training-pipeline.js +619 -725
- package/dist/src/cli/simple-commands/training.js +170 -227
- package/dist/src/cli/simple-commands/verification-hooks.js +261 -284
- package/dist/src/cli/simple-commands/verification-integration.js +389 -417
- package/dist/src/cli/simple-commands/verification-training-integration.js +486 -606
- package/dist/src/cli/simple-commands/verification.js +493 -513
- package/dist/src/cli/simple-commands/web-server.js +766 -836
- package/dist/src/cli/simple-commands/webui-validator.js +106 -124
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +212 -251
- package/dist/src/coordination/event-bus/qe-event-bus.js +608 -748
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +379 -454
- package/dist/src/coordination/iteration-tracker.js +363 -454
- package/dist/src/enterprise/analytics-manager.js +1135 -0
- package/dist/src/enterprise/audit-manager.js +1115 -0
- package/dist/src/enterprise/cloud-manager.js +891 -0
- package/dist/src/enterprise/deployment-manager.js +966 -0
- package/dist/src/enterprise/index.js +6 -0
- package/dist/src/enterprise/project-manager.js +584 -0
- package/dist/src/enterprise/security-manager.js +991 -0
- package/dist/src/index.js +1 -1
- package/dist/src/mcp/DEPRECATED.js +46 -60
- package/dist/src/mcp/fixes/mcp-error-fixes.js +115 -134
- package/dist/src/mcp/implementations/agent-tracker.js +114 -128
- package/dist/src/mcp/implementations/daa-tools.js +292 -350
- package/dist/src/mcp/implementations/workflow-tools.js +329 -361
- package/dist/src/mcp/mcp-config-manager.js +1183 -1331
- package/dist/src/mcp/mcp-server-novice-simplified.js +11 -17
- package/dist/src/mcp/mcp-server-novice.js +11 -17
- package/dist/src/mcp/mcp-server-sdk.js +11 -17
- package/dist/src/mcp/mcp-server.js +1620 -1484
- package/dist/src/mcp/ruv-swarm-wrapper.js +209 -239
- package/dist/src/memory/advanced-serializer.js +609 -589
- package/dist/src/memory/enhanced-examples.js +220 -305
- package/dist/src/memory/enhanced-memory.js +295 -336
- package/dist/src/memory/enhanced-session-serializer.js +408 -492
- package/dist/src/memory/fallback-memory-system.js +900 -1021
- package/dist/src/memory/fallback-store.js +93 -131
- package/dist/src/memory/high-performance-serialization.js +592 -730
- package/dist/src/memory/in-memory-store.js +161 -213
- package/dist/src/memory/index.js +123 -157
- package/dist/src/memory/lock-free-structures.js +578 -764
- package/dist/src/memory/memory-mapped-persistence.js +585 -766
- package/dist/src/memory/memory-pressure-manager.js +569 -707
- package/dist/src/memory/migration.js +358 -445
- package/dist/src/memory/shared-memory.js +641 -768
- package/dist/src/memory/sqlite-store.js +245 -325
- package/dist/src/memory/sqlite-wrapper.js +122 -151
- package/dist/src/memory/swarm-memory.js +470 -603
- package/dist/src/memory/test-example.js +126 -134
- package/dist/src/memory/ultra-fast-memory-store.js +622 -821
- package/dist/src/memory/unified-memory-manager.js +356 -437
- package/dist/src/migration/index.js +92 -0
- package/dist/src/migration/logger.js +121 -0
- package/dist/src/migration/migration-analyzer.js +268 -0
- package/dist/src/migration/migration-runner.js +522 -0
- package/dist/src/migration/migration-validator.js +285 -0
- package/dist/src/migration/progress-reporter.js +150 -0
- package/dist/src/migration/rollback-manager.js +321 -0
- package/dist/src/migration/tests/migration-system.test.js +7 -0
- package/dist/src/migration/types.js +3 -0
- package/dist/src/swarm/CodeRefactoringSwarm.js +777 -952
- package/dist/src/swarm/__tests__/integration.test.js +227 -0
- package/dist/src/swarm/__tests__/prompt-copier.test.js +344 -0
- package/dist/src/swarm/advanced-orchestrator.js +1095 -0
- package/dist/src/swarm/claude-code-interface.js +961 -0
- package/dist/src/swarm/claude-flow-executor.js +229 -0
- package/dist/src/swarm/consensus-coordinator.js +475 -0
- package/dist/src/swarm/coordinator.js +2993 -0
- package/dist/src/swarm/direct-executor.js +1180 -0
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +691 -0
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +998 -0
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +1197 -0
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +772 -0
- package/dist/src/swarm/error-recovery/resilience-architecture.js +714 -0
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +1319 -0
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +808 -0
- package/dist/src/swarm/executor-v2.js +322 -0
- package/dist/src/swarm/executor.js +815 -0
- package/dist/src/swarm/hive-mind-integration.js +703 -0
- package/dist/src/swarm/index.js +41 -0
- package/dist/src/swarm/json-output-aggregator.js +267 -0
- package/dist/src/swarm/large-scale-coordinator.js +542 -0
- package/dist/src/swarm/mcp-integration-wrapper.js +628 -0
- package/dist/src/swarm/memory.js +1117 -0
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +348 -0
- package/dist/src/swarm/optimizations/async-file-manager.js +285 -0
- package/dist/src/swarm/optimizations/circular-buffer.js +162 -0
- package/dist/src/swarm/optimizations/connection-pool.js +244 -0
- package/dist/src/swarm/optimizations/index.js +28 -0
- package/dist/src/swarm/optimizations/optimized-executor.js +320 -0
- package/dist/src/swarm/optimizations/ttl-map.js +234 -0
- package/dist/src/swarm/prompt-cli.js +200 -0
- package/dist/src/swarm/prompt-copier-enhanced.js +202 -0
- package/dist/src/swarm/prompt-copier.js +381 -0
- package/dist/src/swarm/prompt-manager.js +295 -0
- package/dist/src/swarm/prompt-utils.js +310 -0
- package/dist/src/swarm/result-aggregator.js +718 -0
- package/dist/src/swarm/sparc-executor.js +1568 -0
- package/dist/src/swarm/strategies/auto.js +758 -0
- package/dist/src/swarm/strategies/base.js +128 -0
- package/dist/src/swarm/strategies/research.js +914 -0
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +2 -0
- package/dist/src/swarm/types.js +52 -0
- package/dist/src/swarm/workers/copy-worker.js +56 -0
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +332 -400
- package/dist/src/utils/github-cli-safe.js +56 -64
- package/dist/src/utils/github-cli-safety-wrapper.js +451 -546
- package/dist/src/utils/npx-isolated-cache.js +104 -119
- package/dist/src/utils/preference-manager.js +622 -652
- package/dist/src/utils/timezone-utils.js +86 -105
- package/dist/src/validators/epic-config-schema.js +214 -0
- package/dist/src/validators/index.js +10 -0
- package/dist/src/validators/swarm-init-validator.js +259 -0
- package/dist/src/validators/todowrite-batching-validator.js +215 -0
- package/dist/src/validators/todowrite-integration.js +187 -0
- package/package.json +2 -2
|
@@ -1,530 +1,502 @@
|
|
|
1
1
|
// sparc.js - SPARC development mode commands
|
|
2
|
-
import { printSuccess, printError, printWarning } from
|
|
3
|
-
import { promises as fs } from
|
|
4
|
-
import { spawn } from
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import process from 'process';
|
|
9
|
-
|
|
2
|
+
import { printSuccess, printError, printWarning } from "../utils.js";
|
|
3
|
+
import { promises as fs } from "fs";
|
|
4
|
+
import { spawn } from "child_process";
|
|
5
|
+
import { createSparcPrompt } from "./sparc-modes/index.js";
|
|
6
|
+
import { cwd } from "../node-compat.js";
|
|
7
|
+
import process from "process";
|
|
10
8
|
export async function sparcCommand(subArgs, flags) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
9
|
+
const sparcCmd = subArgs[0];
|
|
10
|
+
// Show help if requested or no args
|
|
11
|
+
if (flags.help || flags.h || sparcCmd === '--help' || sparcCmd === '-h' || !sparcCmd && Object.keys(flags).length === 0) {
|
|
12
|
+
showSparcHelp();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
// Merge flags back into subArgs for backward compatibility
|
|
16
|
+
const mergedArgs = [
|
|
17
|
+
...subArgs
|
|
18
|
+
];
|
|
19
|
+
for (const [key, value] of Object.entries(flags)){
|
|
20
|
+
if (key === 'non-interactive' || key === 'n') {
|
|
21
|
+
mergedArgs.push('--non-interactive');
|
|
22
|
+
} else if (key === 'dry-run' || key === 'd') {
|
|
23
|
+
mergedArgs.push('--dry-run');
|
|
24
|
+
} else if (key === 'verbose' || key === 'v') {
|
|
25
|
+
mergedArgs.push('--verbose');
|
|
26
|
+
} else if (key === 'no-permissions') {
|
|
27
|
+
mergedArgs.push('--no-permissions');
|
|
28
|
+
} else if (key === 'enable-permissions') {
|
|
29
|
+
mergedArgs.push('--enable-permissions');
|
|
30
|
+
} else if (key === 'namespace') {
|
|
31
|
+
mergedArgs.push('--namespace', value);
|
|
32
|
+
} else if (key === 'config') {
|
|
33
|
+
mergedArgs.push('--config', value);
|
|
34
|
+
} else if (key === 'interactive' || key === 'i') {
|
|
35
|
+
mergedArgs.push('--interactive');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Check if first arg is a known subcommand
|
|
39
|
+
const knownSubcommands = [
|
|
40
|
+
'modes',
|
|
41
|
+
'info',
|
|
42
|
+
'run',
|
|
43
|
+
'tdd'
|
|
44
|
+
];
|
|
45
|
+
if (!knownSubcommands.includes(sparcCmd)) {
|
|
46
|
+
// If not a known subcommand, treat it as a task description for sparc orchestrator
|
|
47
|
+
// Insert 'run' and 'sparc' to make it: ['run', 'sparc', ...rest of args]
|
|
48
|
+
mergedArgs.unshift('run', 'sparc');
|
|
49
|
+
}
|
|
50
|
+
// Now process the command
|
|
51
|
+
const actualCmd = mergedArgs[0];
|
|
52
|
+
switch(actualCmd){
|
|
53
|
+
case 'modes':
|
|
54
|
+
await listSparcModes(mergedArgs);
|
|
55
|
+
break;
|
|
56
|
+
case 'info':
|
|
57
|
+
await showModeInfo(mergedArgs);
|
|
58
|
+
break;
|
|
59
|
+
case 'run':
|
|
60
|
+
await runSparcMode(mergedArgs, flags);
|
|
61
|
+
break;
|
|
62
|
+
case 'tdd':
|
|
63
|
+
await runTddWorkflow(mergedArgs);
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
showSparcHelp();
|
|
44
67
|
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Check if first arg is a known subcommand
|
|
48
|
-
const knownSubcommands = ['modes', 'info', 'run', 'tdd'];
|
|
49
|
-
|
|
50
|
-
if (!knownSubcommands.includes(sparcCmd)) {
|
|
51
|
-
// If not a known subcommand, treat it as a task description for sparc orchestrator
|
|
52
|
-
// Insert 'run' and 'sparc' to make it: ['run', 'sparc', ...rest of args]
|
|
53
|
-
mergedArgs.unshift('run', 'sparc');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Now process the command
|
|
57
|
-
const actualCmd = mergedArgs[0];
|
|
58
|
-
|
|
59
|
-
switch (actualCmd) {
|
|
60
|
-
case 'modes':
|
|
61
|
-
await listSparcModes(mergedArgs);
|
|
62
|
-
break;
|
|
63
|
-
|
|
64
|
-
case 'info':
|
|
65
|
-
await showModeInfo(mergedArgs);
|
|
66
|
-
break;
|
|
67
|
-
|
|
68
|
-
case 'run':
|
|
69
|
-
await runSparcMode(mergedArgs, flags);
|
|
70
|
-
break;
|
|
71
|
-
|
|
72
|
-
case 'tdd':
|
|
73
|
-
await runTddWorkflow(mergedArgs);
|
|
74
|
-
break;
|
|
75
|
-
|
|
76
|
-
default:
|
|
77
|
-
showSparcHelp();
|
|
78
|
-
}
|
|
79
68
|
}
|
|
80
|
-
|
|
81
69
|
async function listSparcModes(subArgs) {
|
|
82
|
-
try {
|
|
83
|
-
// Get the actual working directory where the command was run from
|
|
84
|
-
const workingDir = process.env.PWD || cwd();
|
|
85
|
-
const configPath = `${workingDir}/.roomodes`;
|
|
86
|
-
let configContent;
|
|
87
70
|
try {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
console.log(`• ${mode.name} (${mode.slug})`);
|
|
111
|
-
if (verbose) {
|
|
112
|
-
console.log(` ${mode.roleDefinition}`);
|
|
113
|
-
console.log(` Tools: ${mode.groups.join(', ')}`);
|
|
71
|
+
// Get the actual working directory where the command was run from
|
|
72
|
+
const workingDir = process.env.PWD || cwd();
|
|
73
|
+
const configPath = `${workingDir}/.roomodes`;
|
|
74
|
+
let configContent;
|
|
75
|
+
try {
|
|
76
|
+
configContent = await fs.readFile(configPath, 'utf8');
|
|
77
|
+
} catch (error) {
|
|
78
|
+
printError('SPARC configuration file (.roomodes) not found');
|
|
79
|
+
console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
|
|
80
|
+
console.log();
|
|
81
|
+
console.log('To enable SPARC development modes, run:');
|
|
82
|
+
console.log(' npx claude-flow@latest init --sparc');
|
|
83
|
+
console.log();
|
|
84
|
+
console.log('This will create:');
|
|
85
|
+
console.log(' • .roomodes file with 17+ SPARC development modes');
|
|
86
|
+
console.log(' • .roo/ directory with templates and workflows');
|
|
87
|
+
console.log(' • SPARC-enhanced CLAUDE.md configuration');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const config = JSON.parse(configContent);
|
|
91
|
+
const verbose = subArgs.includes('--verbose') || subArgs.includes('-v');
|
|
92
|
+
printSuccess('Available SPARC Modes:');
|
|
114
93
|
console.log();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
94
|
+
for (const mode of config.customModes){
|
|
95
|
+
console.log(`• ${mode.name} (${mode.slug})`);
|
|
96
|
+
if (verbose) {
|
|
97
|
+
console.log(` ${mode.roleDefinition}`);
|
|
98
|
+
console.log(` Tools: ${mode.groups.join(', ')}`);
|
|
99
|
+
console.log();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!verbose) {
|
|
103
|
+
console.log();
|
|
104
|
+
console.log('Use --verbose for detailed descriptions');
|
|
105
|
+
}
|
|
106
|
+
} catch (err) {
|
|
107
|
+
printError(`Failed to list SPARC modes: ${err.message}`);
|
|
121
108
|
}
|
|
122
|
-
} catch (err) {
|
|
123
|
-
printError(`Failed to list SPARC modes: ${err.message}`);
|
|
124
|
-
}
|
|
125
109
|
}
|
|
126
|
-
|
|
127
110
|
async function showModeInfo(subArgs) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
// Get the actual working directory where the command was run from
|
|
136
|
-
const workingDir = process.env.PWD || cwd();
|
|
137
|
-
const configPath = `${workingDir}/.roomodes`;
|
|
138
|
-
let configContent;
|
|
139
|
-
try {
|
|
140
|
-
configContent = await fs.readFile(configPath, 'utf8');
|
|
141
|
-
} catch (error) {
|
|
142
|
-
printError('SPARC configuration file (.roomodes) not found');
|
|
143
|
-
console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
|
|
144
|
-
console.log();
|
|
145
|
-
console.log('To enable SPARC development modes, run:');
|
|
146
|
-
console.log(' npx claude-flow@latest init --sparc');
|
|
147
|
-
return;
|
|
111
|
+
const modeSlug = subArgs[1];
|
|
112
|
+
if (!modeSlug) {
|
|
113
|
+
printError('Usage: sparc info <mode-slug>');
|
|
114
|
+
return;
|
|
148
115
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
116
|
+
try {
|
|
117
|
+
// Get the actual working directory where the command was run from
|
|
118
|
+
const workingDir = process.env.PWD || cwd();
|
|
119
|
+
const configPath = `${workingDir}/.roomodes`;
|
|
120
|
+
let configContent;
|
|
121
|
+
try {
|
|
122
|
+
configContent = await fs.readFile(configPath, 'utf8');
|
|
123
|
+
} catch (error) {
|
|
124
|
+
printError('SPARC configuration file (.roomodes) not found');
|
|
125
|
+
console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
|
|
126
|
+
console.log();
|
|
127
|
+
console.log('To enable SPARC development modes, run:');
|
|
128
|
+
console.log(' npx claude-flow@latest init --sparc');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const config = JSON.parse(configContent);
|
|
132
|
+
const mode = config.customModes.find((m)=>m.slug === modeSlug);
|
|
133
|
+
if (!mode) {
|
|
134
|
+
printError(`Mode not found: ${modeSlug}`);
|
|
135
|
+
console.log('Available modes:');
|
|
136
|
+
for (const m of config.customModes){
|
|
137
|
+
console.log(` ${m.slug} - ${m.name}`);
|
|
138
|
+
}
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
printSuccess(`SPARC Mode: ${mode.name}`);
|
|
142
|
+
console.log();
|
|
143
|
+
console.log('Role Definition:');
|
|
144
|
+
console.log(mode.roleDefinition);
|
|
145
|
+
console.log();
|
|
146
|
+
console.log('Custom Instructions:');
|
|
147
|
+
console.log(mode.customInstructions);
|
|
148
|
+
console.log();
|
|
149
|
+
console.log('Tool Groups:');
|
|
150
|
+
console.log(mode.groups.join(', '));
|
|
151
|
+
console.log();
|
|
152
|
+
console.log('Source:');
|
|
153
|
+
console.log(mode.source);
|
|
154
|
+
} catch (err) {
|
|
155
|
+
printError(`Failed to show mode info: ${err.message}`);
|
|
159
156
|
}
|
|
160
|
-
|
|
161
|
-
printSuccess(`SPARC Mode: ${mode.name}`);
|
|
162
|
-
console.log();
|
|
163
|
-
console.log('Role Definition:');
|
|
164
|
-
console.log(mode.roleDefinition);
|
|
165
|
-
console.log();
|
|
166
|
-
console.log('Custom Instructions:');
|
|
167
|
-
console.log(mode.customInstructions);
|
|
168
|
-
console.log();
|
|
169
|
-
console.log('Tool Groups:');
|
|
170
|
-
console.log(mode.groups.join(', '));
|
|
171
|
-
console.log();
|
|
172
|
-
console.log('Source:');
|
|
173
|
-
console.log(mode.source);
|
|
174
|
-
} catch (err) {
|
|
175
|
-
printError(`Failed to show mode info: ${err.message}`);
|
|
176
|
-
}
|
|
177
157
|
}
|
|
178
|
-
|
|
179
158
|
async function runSparcMode(subArgs, flags) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (!runModeSlug || !taskDescription) {
|
|
187
|
-
printError('Usage: sparc run <mode-slug> <task-description>');
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
try {
|
|
192
|
-
// Get the actual working directory where the command was run from
|
|
193
|
-
const workingDir = process.env.PWD || cwd();
|
|
194
|
-
const configPath = `${workingDir}/.roomodes`;
|
|
195
|
-
let configContent;
|
|
159
|
+
const runModeSlug = subArgs[1];
|
|
160
|
+
const taskDescription = subArgs.slice(2).filter((arg)=>!arg.startsWith('--')).join(' ');
|
|
161
|
+
if (!runModeSlug || !taskDescription) {
|
|
162
|
+
printError('Usage: sparc run <mode-slug> <task-description>');
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
196
165
|
try {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
166
|
+
// Get the actual working directory where the command was run from
|
|
167
|
+
const workingDir = process.env.PWD || cwd();
|
|
168
|
+
const configPath = `${workingDir}/.roomodes`;
|
|
169
|
+
let configContent;
|
|
170
|
+
try {
|
|
171
|
+
configContent = await fs.readFile(configPath, 'utf8');
|
|
172
|
+
} catch (error) {
|
|
173
|
+
printError('SPARC configuration file (.roomodes) not found');
|
|
174
|
+
console.log(`Please ensure .roomodes file exists in: ${workingDir}`);
|
|
175
|
+
console.log();
|
|
176
|
+
console.log('To enable SPARC development modes, run:');
|
|
177
|
+
console.log(' npx claude-flow@latest init --sparc');
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const config = JSON.parse(configContent);
|
|
181
|
+
const mode = config.customModes.find((m)=>m.slug === runModeSlug);
|
|
182
|
+
if (!mode) {
|
|
183
|
+
printError(`Mode not found: ${runModeSlug}`);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
// Build enhanced SPARC prompt
|
|
187
|
+
const memoryNamespace = subArgs.includes('--namespace') ? subArgs[subArgs.indexOf('--namespace') + 1] : mode.slug;
|
|
188
|
+
const enhancedTask = createSparcPrompt(mode, taskDescription, memoryNamespace);
|
|
189
|
+
// Build tools based on mode groups
|
|
190
|
+
const tools = buildToolsFromGroups(mode.groups);
|
|
191
|
+
const toolsList = Array.from(tools).join(',');
|
|
192
|
+
const instanceId = `sparc-${runModeSlug}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
193
|
+
if (subArgs.includes('--dry-run') || subArgs.includes('-d')) {
|
|
194
|
+
printWarning('DRY RUN - SPARC Mode Configuration:');
|
|
195
|
+
console.log(`Mode: ${mode.name} (${mode.slug})`);
|
|
196
|
+
console.log(`Instance ID: ${instanceId}`);
|
|
197
|
+
const enablePermissions = subArgs.includes('--enable-permissions');
|
|
198
|
+
if (!enablePermissions) {
|
|
199
|
+
console.log(`Tools: ALL (via --dangerously-skip-permissions)`);
|
|
200
|
+
console.log(`Permissions: Will be auto-skipped`);
|
|
201
|
+
} else {
|
|
202
|
+
console.log(`Tools: ${toolsList}`);
|
|
203
|
+
console.log(`Permissions: Will prompt for actions`);
|
|
204
|
+
}
|
|
205
|
+
console.log(`Task: ${taskDescription}`);
|
|
206
|
+
console.log();
|
|
207
|
+
console.log('Enhanced prompt preview:');
|
|
208
|
+
console.log(enhancedTask.substring(0, 300) + '...');
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
printSuccess(`Starting SPARC mode: ${mode.name}`);
|
|
212
|
+
console.log(`📝 Instance ID: ${instanceId}`);
|
|
213
|
+
console.log(`🎯 Mode: ${mode.slug}`);
|
|
214
|
+
const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');
|
|
215
|
+
const enablePermissions = subArgs.includes('--enable-permissions');
|
|
216
|
+
if (!enablePermissions) {
|
|
217
|
+
console.log(`🔧 Tools: ALL (including MCP and WebSearch via --dangerously-skip-permissions)`);
|
|
218
|
+
console.log(`⚡ Permissions: Auto-skipped (--dangerously-skip-permissions)`);
|
|
219
|
+
} else {
|
|
220
|
+
console.log(`🔧 Tools: ${toolsList}`);
|
|
221
|
+
console.log(`✅ Permissions: Enabled (will prompt for actions)`);
|
|
222
|
+
}
|
|
223
|
+
console.log(`📋 Task: ${taskDescription}`);
|
|
224
|
+
if (isNonInteractive) {
|
|
225
|
+
console.log(`🚀 Running in non-interactive mode with stream-json output`);
|
|
226
|
+
console.log();
|
|
227
|
+
// Show debug info immediately for non-interactive mode
|
|
228
|
+
console.log('🔍 Debug: Preparing claude command...');
|
|
229
|
+
console.log(`Enhanced prompt length: ${enhancedTask.length} characters`);
|
|
230
|
+
console.log(`First 200 chars of prompt: ${enhancedTask.substring(0, 200)}...`);
|
|
231
|
+
}
|
|
232
|
+
console.log();
|
|
233
|
+
// Execute Claude with SPARC configuration
|
|
234
|
+
await executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs);
|
|
235
|
+
} catch (err) {
|
|
236
|
+
printError(`Failed to run SPARC mode: ${err.message}`);
|
|
205
237
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (!
|
|
210
|
-
|
|
211
|
-
|
|
238
|
+
}
|
|
239
|
+
async function runTddWorkflow(subArgs) {
|
|
240
|
+
const tddTaskDescription = subArgs.slice(1).join(' ');
|
|
241
|
+
if (!tddTaskDescription) {
|
|
242
|
+
printError('Usage: sparc tdd <task-description>');
|
|
243
|
+
return;
|
|
212
244
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
console.log(`Tools: ${toolsList}`);
|
|
237
|
-
console.log(`Permissions: Will prompt for actions`);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
console.log(`Task: ${taskDescription}`);
|
|
241
|
-
console.log();
|
|
242
|
-
console.log('Enhanced prompt preview:');
|
|
243
|
-
console.log(enhancedTask.substring(0, 300) + '...');
|
|
244
|
-
return;
|
|
245
|
+
printSuccess('Starting SPARC TDD Workflow');
|
|
246
|
+
console.log('Following Test-Driven Development with SPARC methodology');
|
|
247
|
+
console.log();
|
|
248
|
+
const phases = [
|
|
249
|
+
{
|
|
250
|
+
name: 'Red',
|
|
251
|
+
description: 'Write failing tests',
|
|
252
|
+
mode: 'tdd'
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'Green',
|
|
256
|
+
description: 'Minimal implementation',
|
|
257
|
+
mode: 'code'
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'Refactor',
|
|
261
|
+
description: 'Optimize and clean',
|
|
262
|
+
mode: 'tdd'
|
|
263
|
+
}
|
|
264
|
+
];
|
|
265
|
+
console.log('TDD Phases:');
|
|
266
|
+
for (const phase of phases){
|
|
267
|
+
console.log(` ${phase.name}: ${phase.description} (${phase.mode} mode)`);
|
|
245
268
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');
|
|
252
|
-
const enablePermissions = subArgs.includes('--enable-permissions');
|
|
253
|
-
|
|
254
|
-
if (!enablePermissions) {
|
|
255
|
-
console.log(`🔧 Tools: ALL (including MCP and WebSearch via --dangerously-skip-permissions)`);
|
|
256
|
-
console.log(`⚡ Permissions: Auto-skipped (--dangerously-skip-permissions)`);
|
|
269
|
+
console.log();
|
|
270
|
+
if (subArgs.includes('--interactive') || subArgs.includes('-i')) {
|
|
271
|
+
printSuccess('Starting interactive TDD workflow');
|
|
272
|
+
console.log('This would walk through each phase interactively');
|
|
273
|
+
console.log('Run each phase with: sparc run <mode> "Phase: <task>"');
|
|
257
274
|
} else {
|
|
258
|
-
|
|
259
|
-
|
|
275
|
+
printSuccess('Starting full TDD workflow');
|
|
276
|
+
console.log('This would execute all phases automatically');
|
|
277
|
+
console.log('Use --interactive for step-by-step control');
|
|
260
278
|
}
|
|
261
|
-
console.log(`📋 Task: ${taskDescription}`);
|
|
262
|
-
|
|
263
|
-
if (isNonInteractive) {
|
|
264
|
-
console.log(`🚀 Running in non-interactive mode with stream-json output`);
|
|
265
|
-
console.log();
|
|
266
|
-
|
|
267
|
-
// Show debug info immediately for non-interactive mode
|
|
268
|
-
console.log('🔍 Debug: Preparing claude command...');
|
|
269
|
-
console.log(`Enhanced prompt length: ${enhancedTask.length} characters`);
|
|
270
|
-
console.log(`First 200 chars of prompt: ${enhancedTask.substring(0, 200)}...`);
|
|
271
|
-
}
|
|
272
|
-
console.log();
|
|
273
|
-
|
|
274
|
-
// Execute Claude with SPARC configuration
|
|
275
|
-
await executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs);
|
|
276
|
-
} catch (err) {
|
|
277
|
-
printError(`Failed to run SPARC mode: ${err.message}`);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
async function runTddWorkflow(subArgs) {
|
|
282
|
-
const tddTaskDescription = subArgs.slice(1).join(' ');
|
|
283
|
-
|
|
284
|
-
if (!tddTaskDescription) {
|
|
285
|
-
printError('Usage: sparc tdd <task-description>');
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
printSuccess('Starting SPARC TDD Workflow');
|
|
290
|
-
console.log('Following Test-Driven Development with SPARC methodology');
|
|
291
|
-
console.log();
|
|
292
|
-
|
|
293
|
-
const phases = [
|
|
294
|
-
{ name: 'Red', description: 'Write failing tests', mode: 'tdd' },
|
|
295
|
-
{ name: 'Green', description: 'Minimal implementation', mode: 'code' },
|
|
296
|
-
{ name: 'Refactor', description: 'Optimize and clean', mode: 'tdd' },
|
|
297
|
-
];
|
|
298
|
-
|
|
299
|
-
console.log('TDD Phases:');
|
|
300
|
-
for (const phase of phases) {
|
|
301
|
-
console.log(` ${phase.name}: ${phase.description} (${phase.mode} mode)`);
|
|
302
|
-
}
|
|
303
|
-
console.log();
|
|
304
|
-
|
|
305
|
-
if (subArgs.includes('--interactive') || subArgs.includes('-i')) {
|
|
306
|
-
printSuccess('Starting interactive TDD workflow');
|
|
307
|
-
console.log('This would walk through each phase interactively');
|
|
308
|
-
console.log('Run each phase with: sparc run <mode> "Phase: <task>"');
|
|
309
|
-
} else {
|
|
310
|
-
printSuccess('Starting full TDD workflow');
|
|
311
|
-
console.log('This would execute all phases automatically');
|
|
312
|
-
console.log('Use --interactive for step-by-step control');
|
|
313
|
-
}
|
|
314
279
|
}
|
|
315
|
-
|
|
316
280
|
// Remove the createSparcPrompt function from here as it's now imported from sparc-modes/index.js
|
|
317
|
-
|
|
318
281
|
function buildToolsFromGroups(groups) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
282
|
+
const toolMappings = {
|
|
283
|
+
read: [
|
|
284
|
+
'View',
|
|
285
|
+
'LS',
|
|
286
|
+
'GlobTool',
|
|
287
|
+
'GrepTool'
|
|
288
|
+
],
|
|
289
|
+
edit: [
|
|
290
|
+
'Edit',
|
|
291
|
+
'Replace',
|
|
292
|
+
'MultiEdit',
|
|
293
|
+
'Write'
|
|
294
|
+
],
|
|
295
|
+
browser: [
|
|
296
|
+
'WebFetch'
|
|
297
|
+
],
|
|
298
|
+
mcp: [
|
|
299
|
+
'mcp_tools'
|
|
300
|
+
],
|
|
301
|
+
command: [
|
|
302
|
+
'Bash',
|
|
303
|
+
'Terminal'
|
|
304
|
+
]
|
|
305
|
+
};
|
|
306
|
+
const tools = new Set([
|
|
307
|
+
'View',
|
|
308
|
+
'Edit',
|
|
309
|
+
'Bash'
|
|
310
|
+
]); // Always include basic tools
|
|
311
|
+
for (const group of groups){
|
|
312
|
+
if (Array.isArray(group)) {
|
|
313
|
+
const groupName = group[0];
|
|
314
|
+
if (toolMappings[groupName]) {
|
|
315
|
+
toolMappings[groupName].forEach((tool)=>tools.add(tool));
|
|
316
|
+
}
|
|
317
|
+
} else if (toolMappings[group]) {
|
|
318
|
+
toolMappings[group].forEach((tool)=>tools.add(tool));
|
|
319
|
+
}
|
|
337
320
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return tools;
|
|
321
|
+
return tools;
|
|
341
322
|
}
|
|
342
|
-
|
|
343
323
|
async function executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (!enablePermissions) {
|
|
354
|
-
claudeArgs.push('--dangerously-skip-permissions');
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
if (isNonInteractive) {
|
|
358
|
-
// Non-interactive mode: add additional flags
|
|
359
|
-
claudeArgs.push('-p'); // Use short form for print
|
|
360
|
-
claudeArgs.push('--output-format', 'stream-json');
|
|
361
|
-
claudeArgs.push('--verbose');
|
|
362
|
-
} else {
|
|
363
|
-
// Interactive mode - check for verbose flag
|
|
364
|
-
if (subArgs.includes('--verbose') || subArgs.includes('-v')) {
|
|
365
|
-
claudeArgs.push('--verbose');
|
|
324
|
+
// Check for non-interactive mode
|
|
325
|
+
const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');
|
|
326
|
+
const enablePermissions = subArgs.includes('--enable-permissions');
|
|
327
|
+
// Build arguments array correctly
|
|
328
|
+
const claudeArgs = [];
|
|
329
|
+
claudeArgs.push(enhancedTask);
|
|
330
|
+
// Add --dangerously-skip-permissions by default unless --enable-permissions is set
|
|
331
|
+
if (!enablePermissions) {
|
|
332
|
+
claudeArgs.push('--dangerously-skip-permissions');
|
|
366
333
|
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// When using --dangerously-skip-permissions, we don't need to specify individual tools
|
|
370
|
-
// as it enables ALL tools including mcp and websearch
|
|
371
|
-
// Only add --allowedTools if permissions are enabled
|
|
372
|
-
if (enablePermissions) {
|
|
373
|
-
claudeArgs.push('--allowedTools', toolsList);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if (subArgs.includes('--config')) {
|
|
377
|
-
const configIndex = subArgs.indexOf('--config');
|
|
378
|
-
claudeArgs.push('--mcp-config', subArgs[configIndex + 1]);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Show debug info for non-interactive mode or when verbose
|
|
382
|
-
if (isNonInteractive || subArgs.includes('--verbose') || subArgs.includes('-v')) {
|
|
383
|
-
console.log('\n🔍 Debug: Executing claude with:');
|
|
384
|
-
console.log('Command: claude');
|
|
385
|
-
console.log(
|
|
386
|
-
'Permissions:',
|
|
387
|
-
enablePermissions
|
|
388
|
-
? '✅ Enabled (will prompt)'
|
|
389
|
-
: '⚡ Skipped (--dangerously-skip-permissions)',
|
|
390
|
-
);
|
|
391
|
-
console.log(
|
|
392
|
-
'Tools:',
|
|
393
|
-
enablePermissions ? `Specified: ${toolsList}` : 'ALL tools enabled (MCP, WebSearch, etc.)',
|
|
394
|
-
);
|
|
395
|
-
console.log('Mode:', isNonInteractive ? '🤖 Non-interactive' : '💬 Interactive');
|
|
396
|
-
console.log('Args array length:', claudeArgs.length);
|
|
397
|
-
console.log('First arg (prompt) length:', claudeArgs[0].length, 'characters');
|
|
398
|
-
|
|
399
334
|
if (isNonInteractive) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
335
|
+
// Non-interactive mode: add additional flags
|
|
336
|
+
claudeArgs.push('-p'); // Use short form for print
|
|
337
|
+
claudeArgs.push('--output-format', 'stream-json');
|
|
338
|
+
claudeArgs.push('--verbose');
|
|
339
|
+
} else {
|
|
340
|
+
// Interactive mode - check for verbose flag
|
|
341
|
+
if (subArgs.includes('--verbose') || subArgs.includes('-v')) {
|
|
342
|
+
claudeArgs.push('--verbose');
|
|
407
343
|
}
|
|
408
|
-
});
|
|
409
|
-
console.log('\nFull command structure:');
|
|
410
|
-
console.log('claude "<SPARC prompt>" ' + claudeArgs.slice(1).join(' '));
|
|
411
344
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
//
|
|
345
|
+
// When using --dangerously-skip-permissions, we don't need to specify individual tools
|
|
346
|
+
// as it enables ALL tools including mcp and websearch
|
|
347
|
+
// Only add --allowedTools if permissions are enabled
|
|
348
|
+
if (enablePermissions) {
|
|
349
|
+
claudeArgs.push('--allowedTools', toolsList);
|
|
350
|
+
}
|
|
351
|
+
if (subArgs.includes('--config')) {
|
|
352
|
+
const configIndex = subArgs.indexOf('--config');
|
|
353
|
+
claudeArgs.push('--mcp-config', subArgs[configIndex + 1]);
|
|
354
|
+
}
|
|
355
|
+
// Show debug info for non-interactive mode or when verbose
|
|
356
|
+
if (isNonInteractive || subArgs.includes('--verbose') || subArgs.includes('-v')) {
|
|
357
|
+
console.log('\n🔍 Debug: Executing claude with:');
|
|
358
|
+
console.log('Command: claude');
|
|
359
|
+
console.log('Permissions:', enablePermissions ? '✅ Enabled (will prompt)' : '⚡ Skipped (--dangerously-skip-permissions)');
|
|
360
|
+
console.log('Tools:', enablePermissions ? `Specified: ${toolsList}` : 'ALL tools enabled (MCP, WebSearch, etc.)');
|
|
361
|
+
console.log('Mode:', isNonInteractive ? '🤖 Non-interactive' : '💬 Interactive');
|
|
362
|
+
console.log('Args array length:', claudeArgs.length);
|
|
363
|
+
console.log('First arg (prompt) length:', claudeArgs[0].length, 'characters');
|
|
364
|
+
if (isNonInteractive) {
|
|
365
|
+
console.log('First 200 chars of prompt:', claudeArgs[0].substring(0, 200) + '...');
|
|
366
|
+
console.log('\nAll arguments:');
|
|
367
|
+
claudeArgs.forEach((arg, i)=>{
|
|
368
|
+
if (i === 0) {
|
|
369
|
+
console.log(` [0] <SPARC prompt with ${arg.length} characters>`);
|
|
370
|
+
} else {
|
|
371
|
+
console.log(` [${i}] ${arg}`);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
console.log('\nFull command structure:');
|
|
375
|
+
console.log('claude "<SPARC prompt>" ' + claudeArgs.slice(1).join(' '));
|
|
376
|
+
}
|
|
377
|
+
console.log();
|
|
378
|
+
}
|
|
423
379
|
try {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
380
|
+
// Log the actual command being executed
|
|
381
|
+
console.log('\n🚀 Executing command:');
|
|
382
|
+
console.log(`Command: claude`);
|
|
383
|
+
console.log(`Working Directory: ${cwd()}`);
|
|
384
|
+
console.log(`Number of args: ${claudeArgs.length}`);
|
|
385
|
+
// Check if claude command exists
|
|
386
|
+
try {
|
|
387
|
+
const checkResult = await new Promise((resolve)=>{
|
|
388
|
+
const child = spawn('which', [
|
|
389
|
+
'claude'
|
|
390
|
+
], {
|
|
391
|
+
stdio: [
|
|
392
|
+
'pipe',
|
|
393
|
+
'pipe',
|
|
394
|
+
'pipe'
|
|
395
|
+
]
|
|
396
|
+
});
|
|
397
|
+
let stdout = '';
|
|
398
|
+
child.stdout?.on('data', (data)=>{
|
|
399
|
+
stdout += data;
|
|
400
|
+
});
|
|
401
|
+
child.on('close', (code)=>{
|
|
402
|
+
resolve({
|
|
403
|
+
success: code === 0,
|
|
404
|
+
stdout: Buffer.from(stdout)
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
if (!checkResult.success) {
|
|
409
|
+
console.error('❌ Error: claude command not found in PATH');
|
|
410
|
+
console.error('Please ensure claude CLI is installed and in your PATH');
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const claudePath = new TextDecoder().decode(checkResult.stdout).trim();
|
|
414
|
+
console.log(`Claude path: ${claudePath}`);
|
|
415
|
+
} catch (e) {
|
|
416
|
+
console.warn('⚠️ Could not verify claude command location');
|
|
417
|
+
}
|
|
418
|
+
// Use spawn for claude command
|
|
419
|
+
const env = {
|
|
420
|
+
...process.env,
|
|
421
|
+
CLAUDE_INSTANCE_ID: instanceId
|
|
422
|
+
};
|
|
423
|
+
console.log('\n📡 Spawning claude process...\n');
|
|
424
|
+
const child = spawn('claude', claudeArgs, {
|
|
425
|
+
cwd: cwd(),
|
|
426
|
+
env: env,
|
|
427
|
+
stdio: 'inherit'
|
|
431
428
|
});
|
|
432
|
-
|
|
433
|
-
|
|
429
|
+
const status = await new Promise((resolve)=>{
|
|
430
|
+
child.on('close', (code)=>{
|
|
431
|
+
resolve({
|
|
432
|
+
code,
|
|
433
|
+
success: code === 0
|
|
434
|
+
});
|
|
435
|
+
});
|
|
434
436
|
});
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
} catch (e) {
|
|
444
|
-
console.warn('⚠️ Could not verify claude command location');
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// Use spawn for claude command
|
|
448
|
-
const env = { ...process.env, CLAUDE_INSTANCE_ID: instanceId };
|
|
449
|
-
|
|
450
|
-
console.log('\n📡 Spawning claude process...\n');
|
|
451
|
-
const child = spawn('claude', claudeArgs, {
|
|
452
|
-
cwd: cwd(),
|
|
453
|
-
env: env,
|
|
454
|
-
stdio: 'inherit',
|
|
455
|
-
});
|
|
456
|
-
const status = await new Promise((resolve) => {
|
|
457
|
-
child.on('close', (code) => {
|
|
458
|
-
resolve({ code, success: code === 0 });
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
if (status.success) {
|
|
463
|
-
printSuccess(`SPARC instance ${instanceId} completed successfully`);
|
|
464
|
-
} else {
|
|
465
|
-
printError(`SPARC instance ${instanceId} exited with code ${status.code}`);
|
|
437
|
+
if (status.success) {
|
|
438
|
+
printSuccess(`SPARC instance ${instanceId} completed successfully`);
|
|
439
|
+
} else {
|
|
440
|
+
printError(`SPARC instance ${instanceId} exited with code ${status.code}`);
|
|
441
|
+
}
|
|
442
|
+
} catch (err) {
|
|
443
|
+
printError(`Failed to execute Claude: ${err.message}`);
|
|
444
|
+
console.error('Stack trace:', err.stack);
|
|
466
445
|
}
|
|
467
|
-
} catch (err) {
|
|
468
|
-
printError(`Failed to execute Claude: ${err.message}`);
|
|
469
|
-
console.error('Stack trace:', err.stack);
|
|
470
|
-
}
|
|
471
446
|
}
|
|
472
|
-
|
|
473
447
|
function showSparcHelp() {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
' --
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
console.log(' Research → Design → Implement → Test → Optimize → Loop back');
|
|
529
|
-
console.log(' Perfect for iterative development with continuous refinement');
|
|
448
|
+
console.log('SPARC commands:');
|
|
449
|
+
console.log(' <task> Run SPARC orchestrator (default mode)');
|
|
450
|
+
console.log(' modes List available SPARC development modes');
|
|
451
|
+
console.log(' info <mode> Show detailed information about a mode');
|
|
452
|
+
console.log(' run <mode> <task> Execute a task in specified SPARC mode');
|
|
453
|
+
console.log(' tdd <task> Run Test-Driven Development workflow');
|
|
454
|
+
console.log();
|
|
455
|
+
console.log('Examples:');
|
|
456
|
+
console.log(' claude-flow-novice sparc "orchestrate app development" # Uses sparc orchestrator');
|
|
457
|
+
console.log(' claude-flow-novice sparc modes --verbose');
|
|
458
|
+
console.log(' claude-flow-novice sparc info architect');
|
|
459
|
+
console.log(' claude-flow-novice sparc run code "implement user authentication"');
|
|
460
|
+
console.log(' claude-flow-novice sparc run code "add login feature" --non-interactive');
|
|
461
|
+
console.log(' claude-flow-novice sparc run tdd "create test suite" --namespace tests');
|
|
462
|
+
console.log(' claude-flow-novice sparc tdd "payment processing system" --interactive');
|
|
463
|
+
console.log();
|
|
464
|
+
console.log('Parallel Execution with BatchTool:');
|
|
465
|
+
console.log(' # Run multiple SPARC modes concurrently');
|
|
466
|
+
console.log(' batchtool run --parallel \\');
|
|
467
|
+
console.log(' "npx claude-flow-novice sparc run code \'user service\' --non-interactive" \\');
|
|
468
|
+
console.log(' "npx claude-flow-novice sparc run code \'auth service\' --non-interactive" \\');
|
|
469
|
+
console.log(' "npx claude-flow-novice sparc run tdd \'test suite\' --non-interactive"');
|
|
470
|
+
console.log();
|
|
471
|
+
console.log(' # Boomerang orchestration pattern');
|
|
472
|
+
console.log(' batchtool orchestrate --boomerang \\');
|
|
473
|
+
console.log(' --research "npx claude-flow-novice sparc run ask \'requirements\' --non-interactive" \\');
|
|
474
|
+
console.log(' --design "npx claude-flow-novice sparc run architect \'system\' --non-interactive" \\');
|
|
475
|
+
console.log(' --implement "npx claude-flow-novice sparc run code \'features\' --non-interactive" \\');
|
|
476
|
+
console.log(' --test "npx claude-flow-novice sparc run tdd \'validation\' --non-interactive"');
|
|
477
|
+
console.log();
|
|
478
|
+
console.log('Flags:');
|
|
479
|
+
console.log(' --dry-run, -d Show configuration without executing');
|
|
480
|
+
console.log(' --verbose, -v Show detailed output');
|
|
481
|
+
console.log(' --interactive, -i Run TDD workflow interactively');
|
|
482
|
+
console.log(' --non-interactive, -n Run in non-interactive mode with stream-json output');
|
|
483
|
+
console.log(' --enable-permissions Enable permission prompts (default: skip permissions)');
|
|
484
|
+
console.log(' --namespace <ns> Use custom memory namespace (default: mode slug)');
|
|
485
|
+
console.log(' --config <path> Use custom MCP configuration file');
|
|
486
|
+
console.log();
|
|
487
|
+
console.log('Permission Behavior:');
|
|
488
|
+
console.log(' By default, SPARC runs with --dangerously-skip-permissions for efficiency');
|
|
489
|
+
console.log(' Use --enable-permissions to restore permission prompts if needed');
|
|
490
|
+
console.log();
|
|
491
|
+
console.log('Non-Interactive Mode:');
|
|
492
|
+
console.log(' When using --non-interactive, claude will be executed with:');
|
|
493
|
+
console.log(' - --dangerously-skip-permissions (unless --enable-permissions is set)');
|
|
494
|
+
console.log(' - -p (print mode for streaming output)');
|
|
495
|
+
console.log(' - --output-format stream-json (structured output format)');
|
|
496
|
+
console.log(' - --verbose (detailed execution logs)');
|
|
497
|
+
console.log();
|
|
498
|
+
console.log('Boomerang Pattern:');
|
|
499
|
+
console.log(' A cyclical orchestration where outputs from one phase feed into the next:');
|
|
500
|
+
console.log(' Research → Design → Implement → Test → Optimize → Loop back');
|
|
501
|
+
console.log(' Perfect for iterative development with continuous refinement');
|
|
530
502
|
}
|