claude-flow 2.5.0-alpha.139 → 2.7.0-alpha
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/agents/reasoning/README.md +171 -0
- package/.claude/agents/reasoning/agent.md +816 -0
- package/.claude/agents/reasoning/example-reasoning-agent-template.md +362 -0
- package/.claude/agents/reasoning/goal-planner.md +73 -0
- package/.claude/settings.json +2 -1
- package/.claude/sparc-modes.json +108 -0
- package/README.md +45 -55
- package/bin/claude-flow +1 -1
- package/dist/src/cli/command-registry.js +70 -6
- package/dist/src/cli/command-registry.js.map +1 -1
- package/dist/src/cli/commands/hive-mind/pause.js +2 -9
- package/dist/src/cli/commands/hive-mind/pause.js.map +1 -1
- package/dist/src/cli/commands/index.js +1 -114
- package/dist/src/cli/commands/index.js.map +1 -1
- package/dist/src/cli/commands/swarm-spawn.js +5 -33
- package/dist/src/cli/commands/swarm-spawn.js.map +1 -1
- package/dist/src/cli/help-formatter.js +0 -3
- package/dist/src/cli/help-formatter.js.map +1 -1
- package/dist/src/cli/help-text.js +69 -7
- package/dist/src/cli/help-text.js.map +1 -1
- package/dist/src/cli/simple-cli.js +182 -172
- package/dist/src/cli/simple-cli.js.map +1 -1
- package/dist/src/cli/simple-commands/agent-booster.js +415 -0
- package/dist/src/cli/simple-commands/agent-booster.js.map +1 -0
- package/dist/src/cli/simple-commands/agent.js +856 -13
- package/dist/src/cli/simple-commands/agent.js.map +1 -1
- package/dist/src/cli/simple-commands/env-template.js +180 -0
- package/dist/src/cli/simple-commands/env-template.js.map +1 -0
- package/dist/src/cli/simple-commands/hooks.js +233 -0
- package/dist/src/cli/simple-commands/hooks.js.map +1 -1
- package/dist/src/cli/simple-commands/init/help.js +23 -0
- package/dist/src/cli/simple-commands/init/help.js.map +1 -1
- package/dist/src/cli/simple-commands/init/index.js +63 -0
- package/dist/src/cli/simple-commands/init/index.js.map +1 -1
- package/dist/src/cli/simple-commands/memory.js +307 -16
- package/dist/src/cli/simple-commands/memory.js.map +1 -1
- package/dist/src/cli/simple-commands/proxy.js +304 -0
- package/dist/src/cli/simple-commands/proxy.js.map +1 -0
- package/dist/src/cli/simple-commands/sparc.js +16 -19
- package/dist/src/cli/simple-commands/sparc.js.map +1 -1
- package/dist/src/cli/validation-helper.js.map +1 -1
- package/dist/src/execution/agent-executor.js +181 -0
- package/dist/src/execution/agent-executor.js.map +1 -0
- package/dist/src/execution/index.js +12 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/provider-manager.js +110 -0
- package/dist/src/execution/provider-manager.js.map +1 -0
- package/dist/src/hooks/index.js +0 -3
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/redaction-hook.js +89 -0
- package/dist/src/hooks/redaction-hook.js.map +1 -0
- package/dist/src/mcp/claude-flow-tools.js +205 -150
- package/dist/src/mcp/claude-flow-tools.js.map +1 -1
- package/dist/src/mcp/mcp-server.js +125 -0
- package/dist/src/mcp/mcp-server.js.map +1 -1
- package/dist/src/sdk/query-control.js +293 -139
- package/dist/src/sdk/query-control.js.map +1 -1
- package/dist/src/sdk/session-forking.js +206 -129
- package/dist/src/sdk/session-forking.js.map +1 -1
- package/dist/src/utils/key-redactor.js +108 -0
- package/dist/src/utils/key-redactor.js.map +1 -0
- package/dist/src/utils/metrics-reader.js +37 -39
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/AGENT-BOOSTER-INTEGRATION.md +407 -0
- package/docs/AGENTIC-FLOW-INTEGRATION-GUIDE.md +753 -0
- package/docs/AGENTIC_FLOW_EXECUTION_FIX_REPORT.md +474 -0
- package/docs/AGENTIC_FLOW_INTEGRATION_STATUS.md +143 -0
- package/docs/AGENTIC_FLOW_MVP_COMPLETE.md +367 -0
- package/docs/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +369 -0
- package/docs/COMMAND-VERIFICATION-REPORT.md +441 -0
- package/docs/COMMIT_SUMMARY.md +247 -0
- package/docs/DEEP_REVIEW_COMPREHENSIVE_REPORT.md +922 -0
- package/docs/DOCKER-VALIDATION-REPORT.md +281 -0
- package/docs/ENV-SETUP-GUIDE.md +270 -0
- package/docs/FINAL_PRE_PUBLISH_VALIDATION.md +823 -0
- package/docs/FINAL_VALIDATION_REPORT.md +165 -0
- package/docs/HOOKS-V2-MODIFICATION.md +146 -0
- package/docs/INDEX.md +568 -0
- package/docs/INTEGRATION_COMPLETE.md +414 -0
- package/docs/MEMORY_REDACTION_TEST_REPORT.md +300 -0
- package/docs/PERFORMANCE-SYSTEMS-STATUS.md +340 -0
- package/docs/PRE_RELEASE_FIXES_REPORT.md +435 -0
- package/docs/README.md +35 -0
- package/docs/REASONING-AGENTS.md +482 -0
- package/docs/REASONINGBANK-AGENT-CREATION-GUIDE.md +813 -0
- package/docs/REASONINGBANK-ANALYSIS-COMPLETE.md +479 -0
- package/docs/REASONINGBANK-BENCHMARK-RESULTS.md +166 -0
- package/docs/REASONINGBANK-BENCHMARK.md +396 -0
- package/docs/REASONINGBANK-CLI-INTEGRATION.md +455 -0
- package/docs/REASONINGBANK-CORE-INTEGRATION.md +658 -0
- package/docs/REASONINGBANK-COST-OPTIMIZATION.md +329 -0
- package/docs/REASONINGBANK-DEMO.md +419 -0
- package/docs/REASONINGBANK-INTEGRATION-COMPLETE.md +249 -0
- package/docs/REASONINGBANK-VALIDATION.md +532 -0
- package/docs/REASONINGBANK_ARCHITECTURE.md +475 -0
- package/docs/REASONINGBANK_INTEGRATION_COMPLETE.md +558 -0
- package/docs/REASONINGBANK_INTEGRATION_PLAN.md +1188 -0
- package/docs/REGRESSION-ANALYSIS-REPORT.md +500 -0
- package/docs/RELEASE_v2.6.0-alpha.2.md +658 -0
- package/docs/api/API_DOCUMENTATION.md +721 -0
- package/docs/architecture/ARCHITECTURE.md +1690 -0
- package/docs/ci-cd/README.md +368 -0
- package/docs/development/DEPLOYMENT.md +2348 -0
- package/docs/development/DEVELOPMENT_WORKFLOW.md +1333 -0
- package/docs/development/build-analysis-report.md +252 -0
- package/docs/development/pair-optimization.md +156 -0
- package/docs/development/token-tracking-status.md +103 -0
- package/docs/development/training-pipeline-demo.md +163 -0
- package/docs/development/training-pipeline-real-only.md +196 -0
- package/docs/epic-sdk-integration.md +1269 -0
- package/docs/experimental/RIEMANN_HYPOTHESIS_PROOF.md +124 -0
- package/docs/experimental/computational_verification.py +436 -0
- package/docs/experimental/novel_approaches.md +560 -0
- package/docs/experimental/riemann_hypothesis_analysis.md +263 -0
- package/docs/experimental/riemann_proof_attempt.md +124 -0
- package/docs/experimental/riemann_synthesis.md +277 -0
- package/docs/experimental/verification_results.json +12 -0
- package/docs/experimental/visualization_insights.md +720 -0
- package/docs/guides/USER_GUIDE.md +1138 -0
- package/docs/guides/token-tracking-guide.md +291 -0
- package/docs/reference/AGENTS.md +1011 -0
- package/docs/reference/MCP_TOOLS.md +2188 -0
- package/docs/reference/SPARC.md +717 -0
- package/docs/reference/SWARM.md +2000 -0
- package/docs/sdk/CLAUDE-CODE-SDK-DEEP-ANALYSIS.md +649 -0
- package/docs/sdk/CLAUDE-FLOW-SDK-INTEGRATION-ANALYSIS.md +242 -0
- package/docs/sdk/INTEGRATION-ROADMAP.md +420 -0
- package/docs/sdk/MCP-TOOLS-UPDATE.md +270 -0
- package/docs/sdk/SDK-ADVANCED-FEATURES-INTEGRATION.md +723 -0
- package/docs/sdk/SDK-ALL-FEATURES-INTEGRATION-MATRIX.md +612 -0
- package/docs/sdk/SDK-INTEGRATION-COMPLETE.md +358 -0
- package/docs/sdk/SDK-INTEGRATION-PHASES-V2.5.md +750 -0
- package/docs/sdk/SDK-LEVERAGE-REAL-FEATURES.md +676 -0
- package/docs/sdk/SDK-VALIDATION-RESULTS.md +400 -0
- package/docs/sdk/epic-sdk-integration.md +1269 -0
- package/docs/setup/remote-setup.md +93 -0
- package/docs/validation/final-validation-summary.md +220 -0
- package/docs/validation/verification-integration.md +190 -0
- package/docs/validation/verification-validation.md +349 -0
- package/docs/wiki/background-commands.md +1213 -0
- package/docs/wiki/session-persistence.md +342 -0
- package/docs/wiki/stream-chain-command.md +537 -0
- package/package.json +4 -2
- package/src/cli/command-registry.js +70 -5
- package/src/cli/commands/hive-mind/pause.ts +2 -15
- package/src/cli/commands/index.ts +1 -84
- package/src/cli/commands/swarm-spawn.ts +3 -47
- package/src/cli/help-text.js +42 -7
- package/src/cli/simple-cli.ts +18 -8
- package/src/cli/simple-commands/agent-booster.js +515 -0
- package/src/cli/simple-commands/agent.js +1001 -12
- package/src/cli/simple-commands/agent.ts +137 -0
- package/src/cli/simple-commands/config.ts +127 -0
- package/src/cli/simple-commands/env-template.js +190 -0
- package/src/cli/simple-commands/hooks.js +310 -0
- package/src/cli/simple-commands/init/help.js +23 -0
- package/src/cli/simple-commands/init/index.js +84 -6
- package/src/cli/simple-commands/memory.js +363 -16
- package/src/cli/simple-commands/proxy.js +384 -0
- package/src/cli/simple-commands/sparc.js +16 -19
- package/src/execution/agent-executor.ts +306 -0
- package/src/execution/index.ts +19 -0
- package/src/execution/provider-manager.ts +187 -0
- package/src/hooks/index.ts +0 -5
- package/src/hooks/redaction-hook.ts +115 -0
- package/src/mcp/claude-flow-tools.ts +203 -120
- package/src/mcp/mcp-server.js +86 -0
- package/src/sdk/query-control.ts +377 -223
- package/src/sdk/session-forking.ts +312 -207
- package/src/utils/key-redactor.js +178 -0
- package/src/utils/key-redactor.ts +184 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { printSuccess, printError, printWarning } from '../utils.js';
|
|
2
|
+
import { exec } from 'child_process';
|
|
3
|
+
import { promisify } from 'util';
|
|
4
|
+
const execAsync = promisify(exec);
|
|
5
|
+
export async function proxyCommand(subArgs, flags) {
|
|
6
|
+
const proxyCmd = subArgs[0];
|
|
7
|
+
switch(proxyCmd){
|
|
8
|
+
case 'start':
|
|
9
|
+
await startProxy(subArgs, flags);
|
|
10
|
+
break;
|
|
11
|
+
case 'stop':
|
|
12
|
+
await stopProxy(subArgs, flags);
|
|
13
|
+
break;
|
|
14
|
+
case 'status':
|
|
15
|
+
await getProxyStatus(subArgs, flags);
|
|
16
|
+
break;
|
|
17
|
+
case 'logs':
|
|
18
|
+
await getProxyLogs(subArgs, flags);
|
|
19
|
+
break;
|
|
20
|
+
case 'restart':
|
|
21
|
+
await restartProxy(subArgs, flags);
|
|
22
|
+
break;
|
|
23
|
+
case 'config':
|
|
24
|
+
case 'configure':
|
|
25
|
+
await configureProxy(subArgs, flags);
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
showProxyHelp();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function startProxy(subArgs, flags) {
|
|
32
|
+
printSuccess('🚀 Starting OpenRouter proxy server...');
|
|
33
|
+
console.log('This proxy enables Claude Code to use OpenRouter models');
|
|
34
|
+
console.log('Potential cost savings: 85-98% vs direct Anthropic API\n');
|
|
35
|
+
try {
|
|
36
|
+
let cmd = 'npx agentic-flow proxy';
|
|
37
|
+
if (flags.port) {
|
|
38
|
+
cmd += ` --port ${flags.port}`;
|
|
39
|
+
}
|
|
40
|
+
if (flags.host) {
|
|
41
|
+
cmd += ` --host ${flags.host}`;
|
|
42
|
+
}
|
|
43
|
+
if (flags.daemon || flags.background) {
|
|
44
|
+
cmd += ' &';
|
|
45
|
+
}
|
|
46
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
47
|
+
timeout: flags.daemon ? 10000 : 0,
|
|
48
|
+
maxBuffer: 10 * 1024 * 1024
|
|
49
|
+
});
|
|
50
|
+
if (stdout) {
|
|
51
|
+
console.log(stdout);
|
|
52
|
+
}
|
|
53
|
+
printSuccess('✅ OpenRouter proxy started successfully!');
|
|
54
|
+
console.log('\n📋 Next steps:');
|
|
55
|
+
console.log(' 1. Set environment variable:');
|
|
56
|
+
console.log(` export ANTHROPIC_BASE_URL=http://localhost:${flags.port || 8080}`);
|
|
57
|
+
console.log(' 2. Configure Claude Code to use the proxy');
|
|
58
|
+
console.log(' 3. Your OpenRouter key will be used automatically');
|
|
59
|
+
console.log(' 4. Check status: claude-flow proxy status');
|
|
60
|
+
console.log('\n💰 Cost Savings:');
|
|
61
|
+
console.log(' - Anthropic Claude 3.5 Sonnet: ~$3 per million tokens');
|
|
62
|
+
console.log(' - OpenRouter Claude 3.5 Sonnet: ~$0.30 per million tokens');
|
|
63
|
+
console.log(' - Savings: ~90% (10x cheaper!)');
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error.killed && flags.daemon) {
|
|
66
|
+
printSuccess('✅ Proxy started in background!');
|
|
67
|
+
console.log('Check status: claude-flow proxy status');
|
|
68
|
+
} else {
|
|
69
|
+
printError('❌ Failed to start proxy server');
|
|
70
|
+
console.error(error.message);
|
|
71
|
+
if (error.stderr) {
|
|
72
|
+
console.error('Details:', error.stderr);
|
|
73
|
+
}
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function stopProxy(subArgs, flags) {
|
|
79
|
+
printWarning('🛑 Stopping OpenRouter proxy server...');
|
|
80
|
+
try {
|
|
81
|
+
const { stdout } = await execAsync('npx agentic-flow proxy stop', {
|
|
82
|
+
timeout: 30000
|
|
83
|
+
});
|
|
84
|
+
console.log(stdout);
|
|
85
|
+
printSuccess('✅ Proxy server stopped');
|
|
86
|
+
console.log('\nRemember to unset ANTHROPIC_BASE_URL if needed:');
|
|
87
|
+
console.log(' unset ANTHROPIC_BASE_URL');
|
|
88
|
+
} catch (error) {
|
|
89
|
+
printError('❌ Failed to stop proxy server');
|
|
90
|
+
console.error(error.message);
|
|
91
|
+
console.log('\nTip: You can also stop it manually:');
|
|
92
|
+
console.log(' ps aux | grep "agentic-flow proxy"');
|
|
93
|
+
console.log(' kill -9 <PID>');
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function getProxyStatus(subArgs, flags) {
|
|
98
|
+
printSuccess('📊 Getting OpenRouter proxy status...');
|
|
99
|
+
try {
|
|
100
|
+
const { stdout } = await execAsync('npx agentic-flow proxy status', {
|
|
101
|
+
timeout: 30000
|
|
102
|
+
});
|
|
103
|
+
console.log(stdout);
|
|
104
|
+
if (flags.verbose || flags.detailed) {
|
|
105
|
+
console.log('\n🔧 Configuration:');
|
|
106
|
+
console.log(' Base URL: http://localhost:8080 (default)');
|
|
107
|
+
console.log(' Protocol: HTTP/1.1');
|
|
108
|
+
console.log(' Translation: Anthropic API → OpenRouter API');
|
|
109
|
+
console.log('\n📝 Usage:');
|
|
110
|
+
console.log(' 1. export ANTHROPIC_BASE_URL=http://localhost:8080');
|
|
111
|
+
console.log(' 2. Use Claude Code normally');
|
|
112
|
+
console.log(' 3. All requests route through OpenRouter');
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
printError('❌ Failed to get proxy status');
|
|
116
|
+
console.error(error.message);
|
|
117
|
+
console.log('\nTip: Proxy may not be running. Start it with:');
|
|
118
|
+
console.log(' claude-flow proxy start');
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function getProxyLogs(subArgs, flags) {
|
|
123
|
+
printSuccess('📄 Getting OpenRouter proxy logs...');
|
|
124
|
+
try {
|
|
125
|
+
let cmd = 'npx agentic-flow proxy logs';
|
|
126
|
+
if (flags.lines) {
|
|
127
|
+
cmd += ` --lines ${flags.lines}`;
|
|
128
|
+
}
|
|
129
|
+
if (flags.follow || flags.f) {
|
|
130
|
+
cmd += ' --follow';
|
|
131
|
+
}
|
|
132
|
+
if (flags.error) {
|
|
133
|
+
cmd += ' --error';
|
|
134
|
+
}
|
|
135
|
+
const { stdout } = await execAsync(cmd, {
|
|
136
|
+
timeout: flags.follow ? 0 : 30000,
|
|
137
|
+
maxBuffer: 10 * 1024 * 1024
|
|
138
|
+
});
|
|
139
|
+
console.log(stdout);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
printError('❌ Failed to get proxy logs');
|
|
142
|
+
console.error(error.message);
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async function restartProxy(subArgs, flags) {
|
|
147
|
+
printWarning('🔄 Restarting OpenRouter proxy server...');
|
|
148
|
+
try {
|
|
149
|
+
await stopProxy(subArgs, {
|
|
150
|
+
...flags,
|
|
151
|
+
quiet: true
|
|
152
|
+
});
|
|
153
|
+
await new Promise((resolve)=>setTimeout(resolve, 2000));
|
|
154
|
+
await startProxy(subArgs, flags);
|
|
155
|
+
printSuccess('✅ Proxy server restarted successfully!');
|
|
156
|
+
} catch (error) {
|
|
157
|
+
printError('❌ Failed to restart proxy server');
|
|
158
|
+
console.error(error.message);
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async function configureProxy(subArgs, flags) {
|
|
163
|
+
printSuccess('🔧 OpenRouter Proxy Configuration');
|
|
164
|
+
console.log('\n📋 Current Setup:');
|
|
165
|
+
console.log(' 1. Proxy translates Anthropic API calls to OpenRouter');
|
|
166
|
+
console.log(' 2. Default port: 8080');
|
|
167
|
+
console.log(' 3. Requires OPENROUTER_API_KEY environment variable');
|
|
168
|
+
console.log('\n🔑 API Key Setup:');
|
|
169
|
+
console.log(' export OPENROUTER_API_KEY="sk-or-v1-..."');
|
|
170
|
+
console.log('\n🌐 Claude Code Integration:');
|
|
171
|
+
console.log(' export ANTHROPIC_BASE_URL="http://localhost:8080"');
|
|
172
|
+
console.log('\n💡 Recommended Models:');
|
|
173
|
+
console.log(' - anthropic/claude-3.5-sonnet:beta (90% cheaper)');
|
|
174
|
+
console.log(' - anthropic/claude-3-opus:beta (85% cheaper)');
|
|
175
|
+
console.log(' - deepseek/deepseek-r1-0528:free (100% free!)');
|
|
176
|
+
console.log('\n⚙️ Advanced Configuration:');
|
|
177
|
+
console.log(' export PROXY_PORT=8080 # Custom port');
|
|
178
|
+
console.log(' export PROXY_HOST=0.0.0.0 # Allow external connections');
|
|
179
|
+
console.log(' export PROXY_LOG_LEVEL=debug # Verbose logging');
|
|
180
|
+
console.log('\n🚀 Quick Start:');
|
|
181
|
+
console.log(' 1. claude-flow agent config set OPENROUTER_API_KEY sk-or-v1-...');
|
|
182
|
+
console.log(' 2. claude-flow proxy start --daemon');
|
|
183
|
+
console.log(' 3. export ANTHROPIC_BASE_URL=http://localhost:8080');
|
|
184
|
+
console.log(' 4. Use Claude Code normally → automatic 90% savings!');
|
|
185
|
+
if (flags.test) {
|
|
186
|
+
printSuccess('\n🧪 Testing proxy connection...');
|
|
187
|
+
try {
|
|
188
|
+
const { stdout } = await execAsync('curl -s http://localhost:8080/health', {
|
|
189
|
+
timeout: 5000
|
|
190
|
+
});
|
|
191
|
+
console.log('✅ Proxy is responding:', stdout);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
printWarning('⚠️ Proxy not responding. Start it with: claude-flow proxy start');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function showProxyHelp() {
|
|
198
|
+
console.log(`
|
|
199
|
+
OpenRouter Proxy Server Commands
|
|
200
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
201
|
+
|
|
202
|
+
Standalone proxy server that translates Anthropic API calls to OpenRouter.
|
|
203
|
+
Enables 85-98% cost savings with Claude Code integration.
|
|
204
|
+
|
|
205
|
+
USAGE:
|
|
206
|
+
claude-flow proxy <command> [options]
|
|
207
|
+
|
|
208
|
+
COMMANDS:
|
|
209
|
+
start Start OpenRouter proxy server
|
|
210
|
+
stop Stop proxy server
|
|
211
|
+
restart Restart proxy server
|
|
212
|
+
status Get proxy server status
|
|
213
|
+
logs View proxy server logs
|
|
214
|
+
config Show proxy configuration guide
|
|
215
|
+
|
|
216
|
+
OPTIONS:
|
|
217
|
+
--port <number> Server port (default: 8080)
|
|
218
|
+
--host <string> Server host (default: localhost)
|
|
219
|
+
--daemon Run in background
|
|
220
|
+
--background Same as --daemon
|
|
221
|
+
--lines <number> Number of log lines (default: 100)
|
|
222
|
+
--follow, -f Follow log output in real-time
|
|
223
|
+
--error Show only error logs
|
|
224
|
+
--test Test proxy connection
|
|
225
|
+
--verbose Verbose output
|
|
226
|
+
|
|
227
|
+
EXAMPLES:
|
|
228
|
+
# Start proxy server
|
|
229
|
+
claude-flow proxy start
|
|
230
|
+
claude-flow proxy start --port 8080 --daemon
|
|
231
|
+
|
|
232
|
+
# Configure Claude Code to use proxy
|
|
233
|
+
export ANTHROPIC_BASE_URL=http://localhost:8080
|
|
234
|
+
|
|
235
|
+
# Check status
|
|
236
|
+
claude-flow proxy status
|
|
237
|
+
claude-flow proxy status --verbose
|
|
238
|
+
|
|
239
|
+
# View logs
|
|
240
|
+
claude-flow proxy logs
|
|
241
|
+
claude-flow proxy logs --lines 50 --follow
|
|
242
|
+
claude-flow proxy logs --error
|
|
243
|
+
|
|
244
|
+
# Stop/restart proxy
|
|
245
|
+
claude-flow proxy stop
|
|
246
|
+
claude-flow proxy restart
|
|
247
|
+
|
|
248
|
+
# Configuration guide
|
|
249
|
+
claude-flow proxy config
|
|
250
|
+
claude-flow proxy config --test
|
|
251
|
+
|
|
252
|
+
SETUP GUIDE:
|
|
253
|
+
1. Get OpenRouter API key: https://openrouter.ai/keys
|
|
254
|
+
2. Set environment variable:
|
|
255
|
+
claude-flow agent config set OPENROUTER_API_KEY sk-or-v1-...
|
|
256
|
+
|
|
257
|
+
3. Start proxy server:
|
|
258
|
+
claude-flow proxy start --daemon
|
|
259
|
+
|
|
260
|
+
4. Configure Claude Code:
|
|
261
|
+
export ANTHROPIC_BASE_URL=http://localhost:8080
|
|
262
|
+
|
|
263
|
+
5. Use Claude Code normally - all requests route through OpenRouter!
|
|
264
|
+
|
|
265
|
+
COST SAVINGS:
|
|
266
|
+
┌────────────────────────────────────────────────────────┐
|
|
267
|
+
│ │
|
|
268
|
+
│ Model: Claude 3.5 Sonnet │
|
|
269
|
+
│ ━━━━━━━━━━━━━━━━━━━━━━━━━ │
|
|
270
|
+
│ │
|
|
271
|
+
│ Anthropic Direct: $3.00 per million tokens │
|
|
272
|
+
│ OpenRouter Proxy: $0.30 per million tokens │
|
|
273
|
+
│ ━━━━━━━━━━━━━━━━━━━━━━━━━ │
|
|
274
|
+
│ Savings: 90% (10x cheaper!) │
|
|
275
|
+
│ │
|
|
276
|
+
│ For 100M tokens: │
|
|
277
|
+
│ - Anthropic: $300 │
|
|
278
|
+
│ - OpenRouter: $30 │
|
|
279
|
+
│ - You save: $270 │
|
|
280
|
+
│ │
|
|
281
|
+
└────────────────────────────────────────────────────────┘
|
|
282
|
+
|
|
283
|
+
FREE MODELS:
|
|
284
|
+
- deepseek/deepseek-r1-0528:free (100% free, high quality)
|
|
285
|
+
- meta-llama/llama-3.1-8b-instruct:free
|
|
286
|
+
- google/gemma-2-9b-it:free
|
|
287
|
+
|
|
288
|
+
FEATURES:
|
|
289
|
+
✅ Transparent API translation (Anthropic → OpenRouter)
|
|
290
|
+
✅ Works with Claude Code out of the box
|
|
291
|
+
✅ Automatic model mapping
|
|
292
|
+
✅ Request/response logging
|
|
293
|
+
✅ Error handling and retries
|
|
294
|
+
✅ Health check endpoint
|
|
295
|
+
✅ Zero code changes required
|
|
296
|
+
|
|
297
|
+
For more information, visit:
|
|
298
|
+
https://github.com/ruvnet/agentic-flow
|
|
299
|
+
https://www.npmjs.com/package/agentic-flow
|
|
300
|
+
https://openrouter.ai
|
|
301
|
+
`);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/simple-commands/proxy.js"],"sourcesContent":["/**\n * OpenRouter Proxy Server Commands\n * Standalone proxy server that translates Anthropic API calls to OpenRouter\n * Enables 85-98% cost savings with Claude Code integration\n * NEW in v2.6.0 - Full integration with agentic-flow v1.5.5+\n */\n\nimport { printSuccess, printError, printWarning } from '../utils.js';\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\n\nconst execAsync = promisify(exec);\n\n/**\n * Main proxy command handler\n */\nexport async function proxyCommand(subArgs, flags) {\n const proxyCmd = subArgs[0];\n\n switch (proxyCmd) {\n case 'start':\n await startProxy(subArgs, flags);\n break;\n\n case 'stop':\n await stopProxy(subArgs, flags);\n break;\n\n case 'status':\n await getProxyStatus(subArgs, flags);\n break;\n\n case 'logs':\n await getProxyLogs(subArgs, flags);\n break;\n\n case 'restart':\n await restartProxy(subArgs, flags);\n break;\n\n case 'config':\n case 'configure':\n await configureProxy(subArgs, flags);\n break;\n\n default:\n showProxyHelp();\n }\n}\n\n/**\n * Start OpenRouter proxy server\n * Usage: claude-flow proxy start [--port 8080]\n */\nasync function startProxy(subArgs, flags) {\n printSuccess('🚀 Starting OpenRouter proxy server...');\n console.log('This proxy enables Claude Code to use OpenRouter models');\n console.log('Potential cost savings: 85-98% vs direct Anthropic API\\n');\n\n try {\n let cmd = 'npx agentic-flow proxy';\n\n if (flags.port) {\n cmd += ` --port ${flags.port}`;\n }\n\n if (flags.host) {\n cmd += ` --host ${flags.host}`;\n }\n\n if (flags.daemon || flags.background) {\n cmd += ' &';\n }\n\n const { stdout, stderr } = await execAsync(cmd, {\n timeout: flags.daemon ? 10000 : 0, // Short timeout for daemon mode\n maxBuffer: 10 * 1024 * 1024,\n });\n\n if (stdout) {\n console.log(stdout);\n }\n\n printSuccess('✅ OpenRouter proxy started successfully!');\n console.log('\\n📋 Next steps:');\n console.log(' 1. Set environment variable:');\n console.log(` export ANTHROPIC_BASE_URL=http://localhost:${flags.port || 8080}`);\n console.log(' 2. Configure Claude Code to use the proxy');\n console.log(' 3. Your OpenRouter key will be used automatically');\n console.log(' 4. Check status: claude-flow proxy status');\n console.log('\\n💰 Cost Savings:');\n console.log(' - Anthropic Claude 3.5 Sonnet: ~$3 per million tokens');\n console.log(' - OpenRouter Claude 3.5 Sonnet: ~$0.30 per million tokens');\n console.log(' - Savings: ~90% (10x cheaper!)');\n } catch (error) {\n if (error.killed && flags.daemon) {\n printSuccess('✅ Proxy started in background!');\n console.log('Check status: claude-flow proxy status');\n } else {\n printError('❌ Failed to start proxy server');\n console.error(error.message);\n if (error.stderr) {\n console.error('Details:', error.stderr);\n }\n process.exit(1);\n }\n }\n}\n\n/**\n * Stop OpenRouter proxy server\n * Usage: claude-flow proxy stop\n */\nasync function stopProxy(subArgs, flags) {\n printWarning('🛑 Stopping OpenRouter proxy server...');\n\n try {\n const { stdout } = await execAsync('npx agentic-flow proxy stop', {\n timeout: 30000,\n });\n\n console.log(stdout);\n printSuccess('✅ Proxy server stopped');\n console.log('\\nRemember to unset ANTHROPIC_BASE_URL if needed:');\n console.log(' unset ANTHROPIC_BASE_URL');\n } catch (error) {\n printError('❌ Failed to stop proxy server');\n console.error(error.message);\n console.log('\\nTip: You can also stop it manually:');\n console.log(' ps aux | grep \"agentic-flow proxy\"');\n console.log(' kill -9 <PID>');\n process.exit(1);\n }\n}\n\n/**\n * Get proxy server status\n * Usage: claude-flow proxy status\n */\nasync function getProxyStatus(subArgs, flags) {\n printSuccess('📊 Getting OpenRouter proxy status...');\n\n try {\n const { stdout } = await execAsync('npx agentic-flow proxy status', {\n timeout: 30000,\n });\n\n console.log(stdout);\n\n if (flags.verbose || flags.detailed) {\n console.log('\\n🔧 Configuration:');\n console.log(' Base URL: http://localhost:8080 (default)');\n console.log(' Protocol: HTTP/1.1');\n console.log(' Translation: Anthropic API → OpenRouter API');\n console.log('\\n📝 Usage:');\n console.log(' 1. export ANTHROPIC_BASE_URL=http://localhost:8080');\n console.log(' 2. Use Claude Code normally');\n console.log(' 3. All requests route through OpenRouter');\n }\n } catch (error) {\n printError('❌ Failed to get proxy status');\n console.error(error.message);\n console.log('\\nTip: Proxy may not be running. Start it with:');\n console.log(' claude-flow proxy start');\n process.exit(1);\n }\n}\n\n/**\n * Get proxy server logs\n * Usage: claude-flow proxy logs [--lines 100] [--follow]\n */\nasync function getProxyLogs(subArgs, flags) {\n printSuccess('📄 Getting OpenRouter proxy logs...');\n\n try {\n let cmd = 'npx agentic-flow proxy logs';\n\n if (flags.lines) {\n cmd += ` --lines ${flags.lines}`;\n }\n\n if (flags.follow || flags.f) {\n cmd += ' --follow';\n }\n\n if (flags.error) {\n cmd += ' --error';\n }\n\n const { stdout } = await execAsync(cmd, {\n timeout: flags.follow ? 0 : 30000, // No timeout for follow mode\n maxBuffer: 10 * 1024 * 1024,\n });\n\n console.log(stdout);\n } catch (error) {\n printError('❌ Failed to get proxy logs');\n console.error(error.message);\n process.exit(1);\n }\n}\n\n/**\n * Restart proxy server\n * Usage: claude-flow proxy restart\n */\nasync function restartProxy(subArgs, flags) {\n printWarning('🔄 Restarting OpenRouter proxy server...');\n\n try {\n // Stop first\n await stopProxy(subArgs, { ...flags, quiet: true });\n\n // Wait a moment\n await new Promise((resolve) => setTimeout(resolve, 2000));\n\n // Start again\n await startProxy(subArgs, flags);\n\n printSuccess('✅ Proxy server restarted successfully!');\n } catch (error) {\n printError('❌ Failed to restart proxy server');\n console.error(error.message);\n process.exit(1);\n }\n}\n\n/**\n * Configure proxy server\n * Usage: claude-flow proxy config\n */\nasync function configureProxy(subArgs, flags) {\n printSuccess('🔧 OpenRouter Proxy Configuration');\n\n console.log('\\n📋 Current Setup:');\n console.log(' 1. Proxy translates Anthropic API calls to OpenRouter');\n console.log(' 2. Default port: 8080');\n console.log(' 3. Requires OPENROUTER_API_KEY environment variable');\n\n console.log('\\n🔑 API Key Setup:');\n console.log(' export OPENROUTER_API_KEY=\"sk-or-v1-...\"');\n\n console.log('\\n🌐 Claude Code Integration:');\n console.log(' export ANTHROPIC_BASE_URL=\"http://localhost:8080\"');\n\n console.log('\\n💡 Recommended Models:');\n console.log(' - anthropic/claude-3.5-sonnet:beta (90% cheaper)');\n console.log(' - anthropic/claude-3-opus:beta (85% cheaper)');\n console.log(' - deepseek/deepseek-r1-0528:free (100% free!)');\n\n console.log('\\n⚙️ Advanced Configuration:');\n console.log(' export PROXY_PORT=8080 # Custom port');\n console.log(' export PROXY_HOST=0.0.0.0 # Allow external connections');\n console.log(' export PROXY_LOG_LEVEL=debug # Verbose logging');\n\n console.log('\\n🚀 Quick Start:');\n console.log(' 1. claude-flow agent config set OPENROUTER_API_KEY sk-or-v1-...');\n console.log(' 2. claude-flow proxy start --daemon');\n console.log(' 3. export ANTHROPIC_BASE_URL=http://localhost:8080');\n console.log(' 4. Use Claude Code normally → automatic 90% savings!');\n\n if (flags.test) {\n printSuccess('\\n🧪 Testing proxy connection...');\n try {\n const { stdout } = await execAsync('curl -s http://localhost:8080/health', {\n timeout: 5000,\n });\n console.log('✅ Proxy is responding:', stdout);\n } catch (error) {\n printWarning('⚠️ Proxy not responding. Start it with: claude-flow proxy start');\n }\n }\n}\n\n/**\n * Show proxy command help\n */\nfunction showProxyHelp() {\n console.log(`\nOpenRouter Proxy Server Commands\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nStandalone proxy server that translates Anthropic API calls to OpenRouter.\nEnables 85-98% cost savings with Claude Code integration.\n\nUSAGE:\n claude-flow proxy <command> [options]\n\nCOMMANDS:\n start Start OpenRouter proxy server\n stop Stop proxy server\n restart Restart proxy server\n status Get proxy server status\n logs View proxy server logs\n config Show proxy configuration guide\n\nOPTIONS:\n --port <number> Server port (default: 8080)\n --host <string> Server host (default: localhost)\n --daemon Run in background\n --background Same as --daemon\n --lines <number> Number of log lines (default: 100)\n --follow, -f Follow log output in real-time\n --error Show only error logs\n --test Test proxy connection\n --verbose Verbose output\n\nEXAMPLES:\n # Start proxy server\n claude-flow proxy start\n claude-flow proxy start --port 8080 --daemon\n\n # Configure Claude Code to use proxy\n export ANTHROPIC_BASE_URL=http://localhost:8080\n\n # Check status\n claude-flow proxy status\n claude-flow proxy status --verbose\n\n # View logs\n claude-flow proxy logs\n claude-flow proxy logs --lines 50 --follow\n claude-flow proxy logs --error\n\n # Stop/restart proxy\n claude-flow proxy stop\n claude-flow proxy restart\n\n # Configuration guide\n claude-flow proxy config\n claude-flow proxy config --test\n\nSETUP GUIDE:\n 1. Get OpenRouter API key: https://openrouter.ai/keys\n 2. Set environment variable:\n claude-flow agent config set OPENROUTER_API_KEY sk-or-v1-...\n\n 3. Start proxy server:\n claude-flow proxy start --daemon\n\n 4. Configure Claude Code:\n export ANTHROPIC_BASE_URL=http://localhost:8080\n\n 5. Use Claude Code normally - all requests route through OpenRouter!\n\nCOST SAVINGS:\n ┌────────────────────────────────────────────────────────┐\n │ │\n │ Model: Claude 3.5 Sonnet │\n │ ━━━━━━━━━━━━━━━━━━━━━━━━━ │\n │ │\n │ Anthropic Direct: $3.00 per million tokens │\n │ OpenRouter Proxy: $0.30 per million tokens │\n │ ━━━━━━━━━━━━━━━━━━━━━━━━━ │\n │ Savings: 90% (10x cheaper!) │\n │ │\n │ For 100M tokens: │\n │ - Anthropic: $300 │\n │ - OpenRouter: $30 │\n │ - You save: $270 │\n │ │\n └────────────────────────────────────────────────────────┘\n\nFREE MODELS:\n - deepseek/deepseek-r1-0528:free (100% free, high quality)\n - meta-llama/llama-3.1-8b-instruct:free\n - google/gemma-2-9b-it:free\n\nFEATURES:\n ✅ Transparent API translation (Anthropic → OpenRouter)\n ✅ Works with Claude Code out of the box\n ✅ Automatic model mapping\n ✅ Request/response logging\n ✅ Error handling and retries\n ✅ Health check endpoint\n ✅ Zero code changes required\n\nFor more information, visit:\n https://github.com/ruvnet/agentic-flow\n https://www.npmjs.com/package/agentic-flow\n https://openrouter.ai\n`);\n}\n"],"names":["printSuccess","printError","printWarning","exec","promisify","execAsync","proxyCommand","subArgs","flags","proxyCmd","startProxy","stopProxy","getProxyStatus","getProxyLogs","restartProxy","configureProxy","showProxyHelp","console","log","cmd","port","host","daemon","background","stdout","stderr","timeout","maxBuffer","error","killed","message","process","exit","verbose","detailed","lines","follow","f","quiet","Promise","resolve","setTimeout","test"],"mappings":"AAOA,SAASA,YAAY,EAAEC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AACrE,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,SAAS,QAAQ,OAAO;AAEjC,M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D,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZ,IAAIV,MAAMkC,IAAI,EAAE;QACd1C,aAAa;QACb,IAAI;YACF,MAAM,EAAEwB,MAAM,EAAE,GAAG,MAAMnB,UAAU,wCAAwC;gBACzEqB,SAAS;YACX;YACAT,QAAQC,GAAG,CAAC,0BAA0BM;QACxC,EAAE,OAAOI,OAAO;YACd1B,aAAa;QACf;IACF;AACF;AAKA,SAASc;IACPC,QAAQC,GAAG,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGf,CAAC;AACD"}
|
|
@@ -62,21 +62,18 @@ export async function sparcCommand(subArgs, flags) {
|
|
|
62
62
|
async function listSparcModes(subArgs) {
|
|
63
63
|
try {
|
|
64
64
|
const workingDir = process.env.PWD || cwd();
|
|
65
|
-
const configPath = `${workingDir}/.
|
|
65
|
+
const configPath = `${workingDir}/.claude/sparc-modes.json`;
|
|
66
66
|
let configContent;
|
|
67
67
|
try {
|
|
68
68
|
configContent = await fs.readFile(configPath, 'utf8');
|
|
69
69
|
} catch (error) {
|
|
70
|
-
printError('SPARC configuration file
|
|
71
|
-
console.log(`
|
|
70
|
+
printError('SPARC configuration file not found');
|
|
71
|
+
console.log(`Looking for: ${configPath}`);
|
|
72
72
|
console.log();
|
|
73
|
-
console.log('
|
|
74
|
-
console.log('
|
|
73
|
+
console.log('✅ SPARC modes are now part of .claude/ folder structure');
|
|
74
|
+
console.log('Run `claude-flow init` to set up the .claude/ folder with SPARC modes');
|
|
75
75
|
console.log();
|
|
76
|
-
console.log('
|
|
77
|
-
console.log(' • .roomodes file with 17+ SPARC development modes');
|
|
78
|
-
console.log(' • .roo/ directory with templates and workflows');
|
|
79
|
-
console.log(' • SPARC-enhanced CLAUDE.md configuration');
|
|
76
|
+
console.log('Or manually ensure .claude/sparc-modes.json exists');
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
82
79
|
const config = JSON.parse(configContent);
|
|
@@ -107,16 +104,16 @@ async function showModeInfo(subArgs) {
|
|
|
107
104
|
}
|
|
108
105
|
try {
|
|
109
106
|
const workingDir = process.env.PWD || cwd();
|
|
110
|
-
const configPath = `${workingDir}/.
|
|
107
|
+
const configPath = `${workingDir}/.claude/sparc-modes.json`;
|
|
111
108
|
let configContent;
|
|
112
109
|
try {
|
|
113
110
|
configContent = await fs.readFile(configPath, 'utf8');
|
|
114
111
|
} catch (error) {
|
|
115
|
-
printError('SPARC configuration file
|
|
116
|
-
console.log(`
|
|
112
|
+
printError('SPARC configuration file not found');
|
|
113
|
+
console.log(`Looking for: ${configPath}`);
|
|
117
114
|
console.log();
|
|
118
|
-
console.log('
|
|
119
|
-
console.log('
|
|
115
|
+
console.log('✅ SPARC modes are now part of .claude/ folder structure');
|
|
116
|
+
console.log('Run `claude-flow init` to set up the .claude/ folder with SPARC modes');
|
|
120
117
|
return;
|
|
121
118
|
}
|
|
122
119
|
const config = JSON.parse(configContent);
|
|
@@ -155,16 +152,16 @@ async function runSparcMode(subArgs, flags) {
|
|
|
155
152
|
}
|
|
156
153
|
try {
|
|
157
154
|
const workingDir = process.env.PWD || cwd();
|
|
158
|
-
const configPath = `${workingDir}/.
|
|
155
|
+
const configPath = `${workingDir}/.claude/sparc-modes.json`;
|
|
159
156
|
let configContent;
|
|
160
157
|
try {
|
|
161
158
|
configContent = await fs.readFile(configPath, 'utf8');
|
|
162
159
|
} catch (error) {
|
|
163
|
-
printError('SPARC configuration file
|
|
164
|
-
console.log(`
|
|
160
|
+
printError('SPARC configuration file not found');
|
|
161
|
+
console.log(`Looking for: ${configPath}`);
|
|
165
162
|
console.log();
|
|
166
|
-
console.log('
|
|
167
|
-
console.log('
|
|
163
|
+
console.log('✅ SPARC modes are now part of .claude/ folder structure');
|
|
164
|
+
console.log('Run `claude-flow init` to set up the .claude/ folder with SPARC modes');
|
|
168
165
|
return;
|
|
169
166
|
}
|
|
170
167
|
const config = JSON.parse(configContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/simple-commands/sparc.js"],"sourcesContent":["// sparc.js - SPARC development mode commands\nimport { printSuccess, printError, printWarning } from '../utils.js';\nimport { promises as fs } from 'fs';\nimport { spawn } from 'child_process';\nimport { promisify } from 'util';\nimport { createSparcPrompt } from './sparc-modes/index.js';\nimport { cwd, exit, existsSync } from '../node-compat.js';\nimport process from 'process';\n\nexport async function sparcCommand(subArgs, flags) {\n const sparcCmd = subArgs[0];\n\n // Show help if requested or no args\n if (\n flags.help ||\n flags.h ||\n sparcCmd === '--help' ||\n sparcCmd === '-h' ||\n (!sparcCmd && Object.keys(flags).length === 0)\n ) {\n showSparcHelp();\n return;\n }\n\n // Merge flags back into subArgs for backward compatibility\n const mergedArgs = [...subArgs];\n for (const [key, value] of Object.entries(flags)) {\n if (key === 'non-interactive' || key === 'n') {\n mergedArgs.push('--non-interactive');\n } else if (key === 'dry-run' || key === 'd') {\n mergedArgs.push('--dry-run');\n } else if (key === 'verbose' || key === 'v') {\n mergedArgs.push('--verbose');\n } else if (key === 'no-permissions') {\n mergedArgs.push('--no-permissions');\n } else if (key === 'enable-permissions') {\n mergedArgs.push('--enable-permissions');\n } else if (key === 'namespace') {\n mergedArgs.push('--namespace', value);\n } else if (key === 'config') {\n mergedArgs.push('--config', value);\n } else if (key === 'interactive' || key === 'i') {\n mergedArgs.push('--interactive');\n }\n }\n\n // Check if first arg is a known subcommand\n const knownSubcommands = ['modes', 'info', 'run', 'tdd'];\n\n if (!knownSubcommands.includes(sparcCmd)) {\n // If not a known subcommand, treat it as a task description for sparc orchestrator\n // Insert 'run' and 'sparc' to make it: ['run', 'sparc', ...rest of args]\n mergedArgs.unshift('run', 'sparc');\n }\n\n // Now process the command\n const actualCmd = mergedArgs[0];\n\n switch (actualCmd) {\n case 'modes':\n await listSparcModes(mergedArgs);\n break;\n\n case 'info':\n await showModeInfo(mergedArgs);\n break;\n\n case 'run':\n await runSparcMode(mergedArgs, flags);\n break;\n\n case 'tdd':\n await runTddWorkflow(mergedArgs);\n break;\n\n default:\n showSparcHelp();\n }\n}\n\nasync function listSparcModes(subArgs) {\n try {\n // Get the actual working directory where the command was run from\n const workingDir = process.env.PWD || cwd();\n const configPath = `${workingDir}/.roomodes`;\n let configContent;\n try {\n configContent = await fs.readFile(configPath, 'utf8');\n } catch (error) {\n printError('SPARC configuration file (.roomodes) not found');\n console.log(`Please ensure .roomodes file exists in: ${workingDir}`);\n console.log();\n console.log('To enable SPARC development modes, run:');\n console.log(' npx claude-flow@latest init --sparc');\n console.log();\n console.log('This will create:');\n console.log(' • .roomodes file with 17+ SPARC development modes');\n console.log(' • .roo/ directory with templates and workflows');\n console.log(' • SPARC-enhanced CLAUDE.md configuration');\n return;\n }\n\n const config = JSON.parse(configContent);\n const verbose = subArgs.includes('--verbose') || subArgs.includes('-v');\n\n printSuccess('Available SPARC Modes:');\n console.log();\n\n for (const mode of config.customModes) {\n console.log(`• ${mode.name} (${mode.slug})`);\n if (verbose) {\n console.log(` ${mode.roleDefinition}`);\n console.log(` Tools: ${mode.groups.join(', ')}`);\n console.log();\n }\n }\n\n if (!verbose) {\n console.log();\n console.log('Use --verbose for detailed descriptions');\n }\n } catch (err) {\n printError(`Failed to list SPARC modes: ${err.message}`);\n }\n}\n\nasync function showModeInfo(subArgs) {\n const modeSlug = subArgs[1];\n if (!modeSlug) {\n printError('Usage: sparc info <mode-slug>');\n return;\n }\n\n try {\n // Get the actual working directory where the command was run from\n const workingDir = process.env.PWD || cwd();\n const configPath = `${workingDir}/.roomodes`;\n let configContent;\n try {\n configContent = await fs.readFile(configPath, 'utf8');\n } catch (error) {\n printError('SPARC configuration file (.roomodes) not found');\n console.log(`Please ensure .roomodes file exists in: ${workingDir}`);\n console.log();\n console.log('To enable SPARC development modes, run:');\n console.log(' npx claude-flow@latest init --sparc');\n return;\n }\n const config = JSON.parse(configContent);\n const mode = config.customModes.find((m) => m.slug === modeSlug);\n\n if (!mode) {\n printError(`Mode not found: ${modeSlug}`);\n console.log('Available modes:');\n for (const m of config.customModes) {\n console.log(` ${m.slug} - ${m.name}`);\n }\n return;\n }\n\n printSuccess(`SPARC Mode: ${mode.name}`);\n console.log();\n console.log('Role Definition:');\n console.log(mode.roleDefinition);\n console.log();\n console.log('Custom Instructions:');\n console.log(mode.customInstructions);\n console.log();\n console.log('Tool Groups:');\n console.log(mode.groups.join(', '));\n console.log();\n console.log('Source:');\n console.log(mode.source);\n } catch (err) {\n printError(`Failed to show mode info: ${err.message}`);\n }\n}\n\nasync function runSparcMode(subArgs, flags) {\n const runModeSlug = subArgs[1];\n const taskDescription = subArgs\n .slice(2)\n .filter((arg) => !arg.startsWith('--'))\n .join(' ');\n\n if (!runModeSlug || !taskDescription) {\n printError('Usage: sparc run <mode-slug> <task-description>');\n return;\n }\n\n try {\n // Get the actual working directory where the command was run from\n const workingDir = process.env.PWD || cwd();\n const configPath = `${workingDir}/.roomodes`;\n let configContent;\n try {\n configContent = await fs.readFile(configPath, 'utf8');\n } catch (error) {\n printError('SPARC configuration file (.roomodes) not found');\n console.log(`Please ensure .roomodes file exists in: ${workingDir}`);\n console.log();\n console.log('To enable SPARC development modes, run:');\n console.log(' npx claude-flow@latest init --sparc');\n return;\n }\n const config = JSON.parse(configContent);\n const mode = config.customModes.find((m) => m.slug === runModeSlug);\n\n if (!mode) {\n printError(`Mode not found: ${runModeSlug}`);\n return;\n }\n\n // Build enhanced SPARC prompt\n const memoryNamespace = subArgs.includes('--namespace')\n ? subArgs[subArgs.indexOf('--namespace') + 1]\n : mode.slug;\n\n const enhancedTask = createSparcPrompt(mode, taskDescription, memoryNamespace);\n\n // Build tools based on mode groups\n const tools = buildToolsFromGroups(mode.groups);\n const toolsList = Array.from(tools).join(',');\n const instanceId = `sparc-${runModeSlug}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n\n if (subArgs.includes('--dry-run') || subArgs.includes('-d')) {\n printWarning('DRY RUN - SPARC Mode Configuration:');\n console.log(`Mode: ${mode.name} (${mode.slug})`);\n console.log(`Instance ID: ${instanceId}`);\n\n const enablePermissions = subArgs.includes('--enable-permissions');\n if (!enablePermissions) {\n console.log(`Tools: ALL (via --dangerously-skip-permissions)`);\n console.log(`Permissions: Will be auto-skipped`);\n } else {\n console.log(`Tools: ${toolsList}`);\n console.log(`Permissions: Will prompt for actions`);\n }\n\n console.log(`Task: ${taskDescription}`);\n console.log();\n console.log('Enhanced prompt preview:');\n console.log(enhancedTask.substring(0, 300) + '...');\n return;\n }\n\n printSuccess(`Starting SPARC mode: ${mode.name}`);\n console.log(`📝 Instance ID: ${instanceId}`);\n console.log(`🎯 Mode: ${mode.slug}`);\n\n const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');\n const enablePermissions = subArgs.includes('--enable-permissions');\n\n if (!enablePermissions) {\n console.log(`🔧 Tools: ALL (including MCP and WebSearch via --dangerously-skip-permissions)`);\n console.log(`⚡ Permissions: Auto-skipped (--dangerously-skip-permissions)`);\n } else {\n console.log(`🔧 Tools: ${toolsList}`);\n console.log(`✅ Permissions: Enabled (will prompt for actions)`);\n }\n console.log(`📋 Task: ${taskDescription}`);\n\n if (isNonInteractive) {\n console.log(`🚀 Running in non-interactive mode with stream-json output`);\n console.log();\n\n // Show debug info immediately for non-interactive mode\n console.log('🔍 Debug: Preparing claude command...');\n console.log(`Enhanced prompt length: ${enhancedTask.length} characters`);\n console.log(`First 200 chars of prompt: ${enhancedTask.substring(0, 200)}...`);\n }\n console.log();\n\n // Execute Claude with SPARC configuration\n await executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs);\n } catch (err) {\n printError(`Failed to run SPARC mode: ${err.message}`);\n }\n}\n\nasync function runTddWorkflow(subArgs) {\n const tddTaskDescription = subArgs.slice(1).join(' ');\n\n if (!tddTaskDescription) {\n printError('Usage: sparc tdd <task-description>');\n return;\n }\n\n printSuccess('Starting SPARC TDD Workflow');\n console.log('Following Test-Driven Development with SPARC methodology');\n console.log();\n\n const phases = [\n { name: 'Red', description: 'Write failing tests', mode: 'tdd' },\n { name: 'Green', description: 'Minimal implementation', mode: 'code' },\n { name: 'Refactor', description: 'Optimize and clean', mode: 'tdd' },\n ];\n\n console.log('TDD Phases:');\n for (const phase of phases) {\n console.log(` ${phase.name}: ${phase.description} (${phase.mode} mode)`);\n }\n console.log();\n\n if (subArgs.includes('--interactive') || subArgs.includes('-i')) {\n printSuccess('Starting interactive TDD workflow');\n console.log('This would walk through each phase interactively');\n console.log('Run each phase with: sparc run <mode> \"Phase: <task>\"');\n } else {\n printSuccess('Starting full TDD workflow');\n console.log('This would execute all phases automatically');\n console.log('Use --interactive for step-by-step control');\n }\n}\n\n// Remove the createSparcPrompt function from here as it's now imported from sparc-modes/index.js\n\nfunction buildToolsFromGroups(groups) {\n const toolMappings = {\n read: ['View', 'LS', 'GlobTool', 'GrepTool'],\n edit: ['Edit', 'Replace', 'MultiEdit', 'Write'],\n browser: ['WebFetch'],\n mcp: ['mcp_tools'],\n command: ['Bash', 'Terminal'],\n };\n\n const tools = new Set(['View', 'Edit', 'Bash']); // Always include basic tools\n\n for (const group of groups) {\n if (Array.isArray(group)) {\n const groupName = group[0];\n if (toolMappings[groupName]) {\n toolMappings[groupName].forEach((tool) => tools.add(tool));\n }\n } else if (toolMappings[group]) {\n toolMappings[group].forEach((tool) => tools.add(tool));\n }\n }\n\n return tools;\n}\n\nasync function executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs) {\n // Check for non-interactive mode\n const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');\n const enablePermissions = subArgs.includes('--enable-permissions');\n\n // Build arguments array correctly\n const claudeArgs = [];\n claudeArgs.push(enhancedTask);\n\n // Add --dangerously-skip-permissions by default unless --enable-permissions is set\n if (!enablePermissions) {\n claudeArgs.push('--dangerously-skip-permissions');\n }\n\n if (isNonInteractive) {\n // Non-interactive mode: add additional flags\n claudeArgs.push('-p'); // Use short form for print\n claudeArgs.push('--output-format', 'stream-json');\n claudeArgs.push('--verbose');\n } else {\n // Interactive mode - check for verbose flag\n if (subArgs.includes('--verbose') || subArgs.includes('-v')) {\n claudeArgs.push('--verbose');\n }\n }\n\n // When using --dangerously-skip-permissions, we don't need to specify individual tools\n // as it enables ALL tools including mcp and websearch\n // Only add --allowedTools if permissions are enabled\n if (enablePermissions) {\n claudeArgs.push('--allowedTools', toolsList);\n }\n\n if (subArgs.includes('--config')) {\n const configIndex = subArgs.indexOf('--config');\n claudeArgs.push('--mcp-config', subArgs[configIndex + 1]);\n }\n\n // Show debug info for non-interactive mode or when verbose\n if (isNonInteractive || subArgs.includes('--verbose') || subArgs.includes('-v')) {\n console.log('\\n🔍 Debug: Executing claude with:');\n console.log('Command: claude');\n console.log(\n 'Permissions:',\n enablePermissions\n ? '✅ Enabled (will prompt)'\n : '⚡ Skipped (--dangerously-skip-permissions)',\n );\n console.log(\n 'Tools:',\n enablePermissions ? `Specified: ${toolsList}` : 'ALL tools enabled (MCP, WebSearch, etc.)',\n );\n console.log('Mode:', isNonInteractive ? '🤖 Non-interactive' : '💬 Interactive');\n console.log('Args array length:', claudeArgs.length);\n console.log('First arg (prompt) length:', claudeArgs[0].length, 'characters');\n\n if (isNonInteractive) {\n console.log('First 200 chars of prompt:', claudeArgs[0].substring(0, 200) + '...');\n console.log('\\nAll arguments:');\n claudeArgs.forEach((arg, i) => {\n if (i === 0) {\n console.log(` [0] <SPARC prompt with ${arg.length} characters>`);\n } else {\n console.log(` [${i}] ${arg}`);\n }\n });\n console.log('\\nFull command structure:');\n console.log('claude \"<SPARC prompt>\" ' + claudeArgs.slice(1).join(' '));\n }\n console.log();\n }\n\n try {\n // Log the actual command being executed\n console.log('\\n🚀 Executing command:');\n console.log(`Command: claude`);\n console.log(`Working Directory: ${cwd()}`);\n console.log(`Number of args: ${claudeArgs.length}`);\n\n // Check if claude command exists\n try {\n const checkResult = await new Promise((resolve) => {\n const child = spawn('which', ['claude'], {\n stdio: ['pipe', 'pipe', 'pipe']\n });\n let stdout = '';\n child.stdout?.on('data', (data) => { stdout += data; });\n child.on('close', (code) => {\n resolve({ success: code === 0, stdout: Buffer.from(stdout) });\n });\n });\n if (!checkResult.success) {\n console.error('❌ Error: claude command not found in PATH');\n console.error('Please ensure claude CLI is installed and in your PATH');\n return;\n }\n const claudePath = new TextDecoder().decode(checkResult.stdout).trim();\n console.log(`Claude path: ${claudePath}`);\n } catch (e) {\n console.warn('⚠️ Could not verify claude command location');\n }\n\n // Use spawn for claude command\n const env = { ...process.env, CLAUDE_INSTANCE_ID: instanceId };\n\n console.log('\\n📡 Spawning claude process...\\n');\n const child = spawn('claude', claudeArgs, {\n cwd: cwd(),\n env: env,\n stdio: 'inherit'\n });\n const status = await new Promise((resolve) => {\n child.on('close', (code) => {\n resolve({ code, success: code === 0 });\n });\n });\n\n if (status.success) {\n printSuccess(`SPARC instance ${instanceId} completed successfully`);\n } else {\n printError(`SPARC instance ${instanceId} exited with code ${status.code}`);\n }\n } catch (err) {\n printError(`Failed to execute Claude: ${err.message}`);\n console.error('Stack trace:', err.stack);\n }\n}\n\nfunction showSparcHelp() {\n console.log('SPARC commands:');\n console.log(' <task> Run SPARC orchestrator (default mode)');\n console.log(' modes List available SPARC development modes');\n console.log(' info <mode> Show detailed information about a mode');\n console.log(' run <mode> <task> Execute a task in specified SPARC mode');\n console.log(' tdd <task> Run Test-Driven Development workflow');\n console.log();\n console.log('Examples:');\n console.log(' claude-flow sparc \"orchestrate app development\" # Uses sparc orchestrator');\n console.log(' claude-flow sparc modes --verbose');\n console.log(' claude-flow sparc info architect');\n console.log(' claude-flow sparc run code \"implement user authentication\"');\n console.log(' claude-flow sparc run code \"add login feature\" --non-interactive');\n console.log(' claude-flow sparc run tdd \"create test suite\" --namespace tests');\n console.log(' claude-flow sparc tdd \"payment processing system\" --interactive');\n console.log();\n console.log('Parallel Execution with BatchTool:');\n console.log(' # Run multiple SPARC modes concurrently');\n console.log(' batchtool run --parallel \\\\');\n console.log(' \"npx claude-flow sparc run code \\'user service\\' --non-interactive\" \\\\');\n console.log(' \"npx claude-flow sparc run code \\'auth service\\' --non-interactive\" \\\\');\n console.log(' \"npx claude-flow sparc run tdd \\'test suite\\' --non-interactive\"');\n console.log();\n console.log(' # Boomerang orchestration pattern');\n console.log(' batchtool orchestrate --boomerang \\\\');\n console.log(\n ' --research \"npx claude-flow sparc run ask \\'requirements\\' --non-interactive\" \\\\',\n );\n console.log(' --design \"npx claude-flow sparc run architect \\'system\\' --non-interactive\" \\\\');\n console.log(' --implement \"npx claude-flow sparc run code \\'features\\' --non-interactive\" \\\\');\n console.log(' --test \"npx claude-flow sparc run tdd \\'validation\\' --non-interactive\"');\n console.log();\n console.log('Flags:');\n console.log(' --dry-run, -d Show configuration without executing');\n console.log(' --verbose, -v Show detailed output');\n console.log(' --interactive, -i Run TDD workflow interactively');\n console.log(' --non-interactive, -n Run in non-interactive mode with stream-json output');\n console.log(' --enable-permissions Enable permission prompts (default: skip permissions)');\n console.log(' --namespace <ns> Use custom memory namespace (default: mode slug)');\n console.log(' --config <path> Use custom MCP configuration file');\n console.log();\n console.log('Permission Behavior:');\n console.log(' By default, SPARC runs with --dangerously-skip-permissions for efficiency');\n console.log(' Use --enable-permissions to restore permission prompts if needed');\n console.log();\n console.log('Non-Interactive Mode:');\n console.log(' When using --non-interactive, claude will be executed with:');\n console.log(' - --dangerously-skip-permissions (unless --enable-permissions is set)');\n console.log(' - -p (print mode for streaming output)');\n console.log(' - --output-format stream-json (structured output format)');\n console.log(' - --verbose (detailed execution logs)');\n console.log();\n console.log('Boomerang Pattern:');\n console.log(' A cyclical orchestration where outputs from one phase feed into the next:');\n console.log(' Research → Design → Implement → Test → Optimize → Loop back');\n console.log(' Perfect for iterative development with continuous refinement');\n}\n"],"names":["printSuccess","printError","printWarning","promises","fs","spawn","createSparcPrompt","cwd","process","sparcCommand","subArgs","flags","sparcCmd","help","h","Object","keys","length","showSparcHelp","mergedArgs","key","value","entries","push","knownSubcommands","includes","unshift","actualCmd","listSparcModes","showModeInfo","runSparcMode","runTddWorkflow","workingDir","env","PWD","configPath","configContent","readFile","error","console","log","config","JSON","parse","verbose","mode","customModes","name","slug","roleDefinition","groups","join","err","message","modeSlug","find","m","customInstructions","source","runModeSlug","taskDescription","slice","filter","arg","startsWith","memoryNamespace","indexOf","enhancedTask","tools","buildToolsFromGroups","toolsList","Array","from","instanceId","Date","now","Math","random","toString","substr","enablePermissions","substring","isNonInteractive","executeClaude","tddTaskDescription","phases","description","phase","toolMappings","read","edit","browser","mcp","command","Set","group","isArray","groupName","forEach","tool","add","claudeArgs","configIndex","i","checkResult","Promise","resolve","child","stdio","stdout","on","data","code","success","Buffer","claudePath","TextDecoder","decode","trim","e","warn","CLAUDE_INSTANCE_ID","status","stack"],"mappings":"AACA,SAASA,YAAY,EAAEC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AACrE,SAASC,YAAYC,EAAE,QAAQ,KAAK;AACpC,SAASC,KAAK,QAAQ,gBAAgB;AAEtC,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,GAAG,QAA0B,oBAAoB;AAC1D,OAAOC,aAAa,UAAU;AAE9B,OAAO,eAAeC,aAAaC,OAAO,EAAEC,KAAK;IAC/C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C,GAAG,CACT;IAEFD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;AACd"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/simple-commands/sparc.js"],"sourcesContent":["// sparc.js - SPARC development mode commands\nimport { printSuccess, printError, printWarning } from '../utils.js';\nimport { promises as fs } from 'fs';\nimport { spawn } from 'child_process';\nimport { promisify } from 'util';\nimport { createSparcPrompt } from './sparc-modes/index.js';\nimport { cwd, exit, existsSync } from '../node-compat.js';\nimport process from 'process';\n\nexport async function sparcCommand(subArgs, flags) {\n const sparcCmd = subArgs[0];\n\n // Show help if requested or no args\n if (\n flags.help ||\n flags.h ||\n sparcCmd === '--help' ||\n sparcCmd === '-h' ||\n (!sparcCmd && Object.keys(flags).length === 0)\n ) {\n showSparcHelp();\n return;\n }\n\n // Merge flags back into subArgs for backward compatibility\n const mergedArgs = [...subArgs];\n for (const [key, value] of Object.entries(flags)) {\n if (key === 'non-interactive' || key === 'n') {\n mergedArgs.push('--non-interactive');\n } else if (key === 'dry-run' || key === 'd') {\n mergedArgs.push('--dry-run');\n } else if (key === 'verbose' || key === 'v') {\n mergedArgs.push('--verbose');\n } else if (key === 'no-permissions') {\n mergedArgs.push('--no-permissions');\n } else if (key === 'enable-permissions') {\n mergedArgs.push('--enable-permissions');\n } else if (key === 'namespace') {\n mergedArgs.push('--namespace', value);\n } else if (key === 'config') {\n mergedArgs.push('--config', value);\n } else if (key === 'interactive' || key === 'i') {\n mergedArgs.push('--interactive');\n }\n }\n\n // Check if first arg is a known subcommand\n const knownSubcommands = ['modes', 'info', 'run', 'tdd'];\n\n if (!knownSubcommands.includes(sparcCmd)) {\n // If not a known subcommand, treat it as a task description for sparc orchestrator\n // Insert 'run' and 'sparc' to make it: ['run', 'sparc', ...rest of args]\n mergedArgs.unshift('run', 'sparc');\n }\n\n // Now process the command\n const actualCmd = mergedArgs[0];\n\n switch (actualCmd) {\n case 'modes':\n await listSparcModes(mergedArgs);\n break;\n\n case 'info':\n await showModeInfo(mergedArgs);\n break;\n\n case 'run':\n await runSparcMode(mergedArgs, flags);\n break;\n\n case 'tdd':\n await runTddWorkflow(mergedArgs);\n break;\n\n default:\n showSparcHelp();\n }\n}\n\nasync function listSparcModes(subArgs) {\n try {\n // Get the actual working directory where the command was run from\n const workingDir = process.env.PWD || cwd();\n const configPath = `${workingDir}/.claude/sparc-modes.json`;\n let configContent;\n try {\n configContent = await fs.readFile(configPath, 'utf8');\n } catch (error) {\n printError('SPARC configuration file not found');\n console.log(`Looking for: ${configPath}`);\n console.log();\n console.log('✅ SPARC modes are now part of .claude/ folder structure');\n console.log('Run `claude-flow init` to set up the .claude/ folder with SPARC modes');\n console.log();\n console.log('Or manually ensure .claude/sparc-modes.json exists');\n return;\n }\n\n const config = JSON.parse(configContent);\n const verbose = subArgs.includes('--verbose') || subArgs.includes('-v');\n\n printSuccess('Available SPARC Modes:');\n console.log();\n\n for (const mode of config.customModes) {\n console.log(`• ${mode.name} (${mode.slug})`);\n if (verbose) {\n console.log(` ${mode.roleDefinition}`);\n console.log(` Tools: ${mode.groups.join(', ')}`);\n console.log();\n }\n }\n\n if (!verbose) {\n console.log();\n console.log('Use --verbose for detailed descriptions');\n }\n } catch (err) {\n printError(`Failed to list SPARC modes: ${err.message}`);\n }\n}\n\nasync function showModeInfo(subArgs) {\n const modeSlug = subArgs[1];\n if (!modeSlug) {\n printError('Usage: sparc info <mode-slug>');\n return;\n }\n\n try {\n // Get the actual working directory where the command was run from\n const workingDir = process.env.PWD || cwd();\n const configPath = `${workingDir}/.claude/sparc-modes.json`;\n let configContent;\n try {\n configContent = await fs.readFile(configPath, 'utf8');\n } catch (error) {\n printError('SPARC configuration file not found');\n console.log(`Looking for: ${configPath}`);\n console.log();\n console.log('✅ SPARC modes are now part of .claude/ folder structure');\n console.log('Run `claude-flow init` to set up the .claude/ folder with SPARC modes');\n return;\n }\n const config = JSON.parse(configContent);\n const mode = config.customModes.find((m) => m.slug === modeSlug);\n\n if (!mode) {\n printError(`Mode not found: ${modeSlug}`);\n console.log('Available modes:');\n for (const m of config.customModes) {\n console.log(` ${m.slug} - ${m.name}`);\n }\n return;\n }\n\n printSuccess(`SPARC Mode: ${mode.name}`);\n console.log();\n console.log('Role Definition:');\n console.log(mode.roleDefinition);\n console.log();\n console.log('Custom Instructions:');\n console.log(mode.customInstructions);\n console.log();\n console.log('Tool Groups:');\n console.log(mode.groups.join(', '));\n console.log();\n console.log('Source:');\n console.log(mode.source);\n } catch (err) {\n printError(`Failed to show mode info: ${err.message}`);\n }\n}\n\nasync function runSparcMode(subArgs, flags) {\n const runModeSlug = subArgs[1];\n const taskDescription = subArgs\n .slice(2)\n .filter((arg) => !arg.startsWith('--'))\n .join(' ');\n\n if (!runModeSlug || !taskDescription) {\n printError('Usage: sparc run <mode-slug> <task-description>');\n return;\n }\n\n try {\n // Get the actual working directory where the command was run from\n const workingDir = process.env.PWD || cwd();\n const configPath = `${workingDir}/.claude/sparc-modes.json`;\n let configContent;\n try {\n configContent = await fs.readFile(configPath, 'utf8');\n } catch (error) {\n printError('SPARC configuration file not found');\n console.log(`Looking for: ${configPath}`);\n console.log();\n console.log('✅ SPARC modes are now part of .claude/ folder structure');\n console.log('Run `claude-flow init` to set up the .claude/ folder with SPARC modes');\n return;\n }\n const config = JSON.parse(configContent);\n const mode = config.customModes.find((m) => m.slug === runModeSlug);\n\n if (!mode) {\n printError(`Mode not found: ${runModeSlug}`);\n return;\n }\n\n // Build enhanced SPARC prompt\n const memoryNamespace = subArgs.includes('--namespace')\n ? subArgs[subArgs.indexOf('--namespace') + 1]\n : mode.slug;\n\n const enhancedTask = createSparcPrompt(mode, taskDescription, memoryNamespace);\n\n // Build tools based on mode groups\n const tools = buildToolsFromGroups(mode.groups);\n const toolsList = Array.from(tools).join(',');\n const instanceId = `sparc-${runModeSlug}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;\n\n if (subArgs.includes('--dry-run') || subArgs.includes('-d')) {\n printWarning('DRY RUN - SPARC Mode Configuration:');\n console.log(`Mode: ${mode.name} (${mode.slug})`);\n console.log(`Instance ID: ${instanceId}`);\n\n const enablePermissions = subArgs.includes('--enable-permissions');\n if (!enablePermissions) {\n console.log(`Tools: ALL (via --dangerously-skip-permissions)`);\n console.log(`Permissions: Will be auto-skipped`);\n } else {\n console.log(`Tools: ${toolsList}`);\n console.log(`Permissions: Will prompt for actions`);\n }\n\n console.log(`Task: ${taskDescription}`);\n console.log();\n console.log('Enhanced prompt preview:');\n console.log(enhancedTask.substring(0, 300) + '...');\n return;\n }\n\n printSuccess(`Starting SPARC mode: ${mode.name}`);\n console.log(`📝 Instance ID: ${instanceId}`);\n console.log(`🎯 Mode: ${mode.slug}`);\n\n const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');\n const enablePermissions = subArgs.includes('--enable-permissions');\n\n if (!enablePermissions) {\n console.log(`🔧 Tools: ALL (including MCP and WebSearch via --dangerously-skip-permissions)`);\n console.log(`⚡ Permissions: Auto-skipped (--dangerously-skip-permissions)`);\n } else {\n console.log(`🔧 Tools: ${toolsList}`);\n console.log(`✅ Permissions: Enabled (will prompt for actions)`);\n }\n console.log(`📋 Task: ${taskDescription}`);\n\n if (isNonInteractive) {\n console.log(`🚀 Running in non-interactive mode with stream-json output`);\n console.log();\n\n // Show debug info immediately for non-interactive mode\n console.log('🔍 Debug: Preparing claude command...');\n console.log(`Enhanced prompt length: ${enhancedTask.length} characters`);\n console.log(`First 200 chars of prompt: ${enhancedTask.substring(0, 200)}...`);\n }\n console.log();\n\n // Execute Claude with SPARC configuration\n await executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs);\n } catch (err) {\n printError(`Failed to run SPARC mode: ${err.message}`);\n }\n}\n\nasync function runTddWorkflow(subArgs) {\n const tddTaskDescription = subArgs.slice(1).join(' ');\n\n if (!tddTaskDescription) {\n printError('Usage: sparc tdd <task-description>');\n return;\n }\n\n printSuccess('Starting SPARC TDD Workflow');\n console.log('Following Test-Driven Development with SPARC methodology');\n console.log();\n\n const phases = [\n { name: 'Red', description: 'Write failing tests', mode: 'tdd' },\n { name: 'Green', description: 'Minimal implementation', mode: 'code' },\n { name: 'Refactor', description: 'Optimize and clean', mode: 'tdd' },\n ];\n\n console.log('TDD Phases:');\n for (const phase of phases) {\n console.log(` ${phase.name}: ${phase.description} (${phase.mode} mode)`);\n }\n console.log();\n\n if (subArgs.includes('--interactive') || subArgs.includes('-i')) {\n printSuccess('Starting interactive TDD workflow');\n console.log('This would walk through each phase interactively');\n console.log('Run each phase with: sparc run <mode> \"Phase: <task>\"');\n } else {\n printSuccess('Starting full TDD workflow');\n console.log('This would execute all phases automatically');\n console.log('Use --interactive for step-by-step control');\n }\n}\n\n// Remove the createSparcPrompt function from here as it's now imported from sparc-modes/index.js\n\nfunction buildToolsFromGroups(groups) {\n const toolMappings = {\n read: ['View', 'LS', 'GlobTool', 'GrepTool'],\n edit: ['Edit', 'Replace', 'MultiEdit', 'Write'],\n browser: ['WebFetch'],\n mcp: ['mcp_tools'],\n command: ['Bash', 'Terminal'],\n };\n\n const tools = new Set(['View', 'Edit', 'Bash']); // Always include basic tools\n\n for (const group of groups) {\n if (Array.isArray(group)) {\n const groupName = group[0];\n if (toolMappings[groupName]) {\n toolMappings[groupName].forEach((tool) => tools.add(tool));\n }\n } else if (toolMappings[group]) {\n toolMappings[group].forEach((tool) => tools.add(tool));\n }\n }\n\n return tools;\n}\n\nasync function executeClaude(enhancedTask, toolsList, instanceId, memoryNamespace, subArgs) {\n // Check for non-interactive mode\n const isNonInteractive = subArgs.includes('--non-interactive') || subArgs.includes('-n');\n const enablePermissions = subArgs.includes('--enable-permissions');\n\n // Build arguments array correctly\n const claudeArgs = [];\n claudeArgs.push(enhancedTask);\n\n // Add --dangerously-skip-permissions by default unless --enable-permissions is set\n if (!enablePermissions) {\n claudeArgs.push('--dangerously-skip-permissions');\n }\n\n if (isNonInteractive) {\n // Non-interactive mode: add additional flags\n claudeArgs.push('-p'); // Use short form for print\n claudeArgs.push('--output-format', 'stream-json');\n claudeArgs.push('--verbose');\n } else {\n // Interactive mode - check for verbose flag\n if (subArgs.includes('--verbose') || subArgs.includes('-v')) {\n claudeArgs.push('--verbose');\n }\n }\n\n // When using --dangerously-skip-permissions, we don't need to specify individual tools\n // as it enables ALL tools including mcp and websearch\n // Only add --allowedTools if permissions are enabled\n if (enablePermissions) {\n claudeArgs.push('--allowedTools', toolsList);\n }\n\n if (subArgs.includes('--config')) {\n const configIndex = subArgs.indexOf('--config');\n claudeArgs.push('--mcp-config', subArgs[configIndex + 1]);\n }\n\n // Show debug info for non-interactive mode or when verbose\n if (isNonInteractive || subArgs.includes('--verbose') || subArgs.includes('-v')) {\n console.log('\\n🔍 Debug: Executing claude with:');\n console.log('Command: claude');\n console.log(\n 'Permissions:',\n enablePermissions\n ? '✅ Enabled (will prompt)'\n : '⚡ Skipped (--dangerously-skip-permissions)',\n );\n console.log(\n 'Tools:',\n enablePermissions ? `Specified: ${toolsList}` : 'ALL tools enabled (MCP, WebSearch, etc.)',\n );\n console.log('Mode:', isNonInteractive ? '🤖 Non-interactive' : '💬 Interactive');\n console.log('Args array length:', claudeArgs.length);\n console.log('First arg (prompt) length:', claudeArgs[0].length, 'characters');\n\n if (isNonInteractive) {\n console.log('First 200 chars of prompt:', claudeArgs[0].substring(0, 200) + '...');\n console.log('\\nAll arguments:');\n claudeArgs.forEach((arg, i) => {\n if (i === 0) {\n console.log(` [0] <SPARC prompt with ${arg.length} characters>`);\n } else {\n console.log(` [${i}] ${arg}`);\n }\n });\n console.log('\\nFull command structure:');\n console.log('claude \"<SPARC prompt>\" ' + claudeArgs.slice(1).join(' '));\n }\n console.log();\n }\n\n try {\n // Log the actual command being executed\n console.log('\\n🚀 Executing command:');\n console.log(`Command: claude`);\n console.log(`Working Directory: ${cwd()}`);\n console.log(`Number of args: ${claudeArgs.length}`);\n\n // Check if claude command exists\n try {\n const checkResult = await new Promise((resolve) => {\n const child = spawn('which', ['claude'], {\n stdio: ['pipe', 'pipe', 'pipe']\n });\n let stdout = '';\n child.stdout?.on('data', (data) => { stdout += data; });\n child.on('close', (code) => {\n resolve({ success: code === 0, stdout: Buffer.from(stdout) });\n });\n });\n if (!checkResult.success) {\n console.error('❌ Error: claude command not found in PATH');\n console.error('Please ensure claude CLI is installed and in your PATH');\n return;\n }\n const claudePath = new TextDecoder().decode(checkResult.stdout).trim();\n console.log(`Claude path: ${claudePath}`);\n } catch (e) {\n console.warn('⚠️ Could not verify claude command location');\n }\n\n // Use spawn for claude command\n const env = { ...process.env, CLAUDE_INSTANCE_ID: instanceId };\n\n console.log('\\n📡 Spawning claude process...\\n');\n const child = spawn('claude', claudeArgs, {\n cwd: cwd(),\n env: env,\n stdio: 'inherit'\n });\n const status = await new Promise((resolve) => {\n child.on('close', (code) => {\n resolve({ code, success: code === 0 });\n });\n });\n\n if (status.success) {\n printSuccess(`SPARC instance ${instanceId} completed successfully`);\n } else {\n printError(`SPARC instance ${instanceId} exited with code ${status.code}`);\n }\n } catch (err) {\n printError(`Failed to execute Claude: ${err.message}`);\n console.error('Stack trace:', err.stack);\n }\n}\n\nfunction showSparcHelp() {\n console.log('SPARC commands:');\n console.log(' <task> Run SPARC orchestrator (default mode)');\n console.log(' modes List available SPARC development modes');\n console.log(' info <mode> Show detailed information about a mode');\n console.log(' run <mode> <task> Execute a task in specified SPARC mode');\n console.log(' tdd <task> Run Test-Driven Development workflow');\n console.log();\n console.log('Examples:');\n console.log(' claude-flow sparc \"orchestrate app development\" # Uses sparc orchestrator');\n console.log(' claude-flow sparc modes --verbose');\n console.log(' claude-flow sparc info architect');\n console.log(' claude-flow sparc run code \"implement user authentication\"');\n console.log(' claude-flow sparc run code \"add login feature\" --non-interactive');\n console.log(' claude-flow sparc run tdd \"create test suite\" --namespace tests');\n console.log(' claude-flow sparc tdd \"payment processing system\" --interactive');\n console.log();\n console.log('Parallel Execution with BatchTool:');\n console.log(' # Run multiple SPARC modes concurrently');\n console.log(' batchtool run --parallel \\\\');\n console.log(' \"npx claude-flow sparc run code \\'user service\\' --non-interactive\" \\\\');\n console.log(' \"npx claude-flow sparc run code \\'auth service\\' --non-interactive\" \\\\');\n console.log(' \"npx claude-flow sparc run tdd \\'test suite\\' --non-interactive\"');\n console.log();\n console.log(' # Boomerang orchestration pattern');\n console.log(' batchtool orchestrate --boomerang \\\\');\n console.log(\n ' --research \"npx claude-flow sparc run ask \\'requirements\\' --non-interactive\" \\\\',\n );\n console.log(' --design \"npx claude-flow sparc run architect \\'system\\' --non-interactive\" \\\\');\n console.log(' --implement \"npx claude-flow sparc run code \\'features\\' --non-interactive\" \\\\');\n console.log(' --test \"npx claude-flow sparc run tdd \\'validation\\' --non-interactive\"');\n console.log();\n console.log('Flags:');\n console.log(' --dry-run, -d Show configuration without executing');\n console.log(' --verbose, -v Show detailed output');\n console.log(' --interactive, -i Run TDD workflow interactively');\n console.log(' --non-interactive, -n Run in non-interactive mode with stream-json output');\n console.log(' --enable-permissions Enable permission prompts (default: skip permissions)');\n console.log(' --namespace <ns> Use custom memory namespace (default: mode slug)');\n console.log(' --config <path> Use custom MCP configuration file');\n console.log();\n console.log('Permission Behavior:');\n console.log(' By default, SPARC runs with --dangerously-skip-permissions for efficiency');\n console.log(' Use --enable-permissions to restore permission prompts if needed');\n console.log();\n console.log('Non-Interactive Mode:');\n console.log(' When using --non-interactive, claude will be executed with:');\n console.log(' - --dangerously-skip-permissions (unless --enable-permissions is set)');\n console.log(' - -p (print mode for streaming output)');\n console.log(' - --output-format stream-json (structured output format)');\n console.log(' - --verbose (detailed execution logs)');\n console.log();\n console.log('Boomerang Pattern:');\n console.log(' A cyclical orchestration where outputs from one phase feed into the next:');\n console.log(' Research → Design → Implement → Test → Optimize → Loop back');\n console.log(' Perfect for iterative development with continuous refinement');\n}\n"],"names":["printSuccess","printError","printWarning","promises","fs","spawn","createSparcPrompt","cwd","process","sparcCommand","subArgs","flags","sparcCmd","help","h","Object","keys","length","showSparcHelp","mergedArgs","key","value","entries","push","knownSubcommands","includes","unshift","actualCmd","listSparcModes","showModeInfo","runSparcMode","runTddWorkflow","workingDir","env","PWD","configPath","configContent","readFile","error","console","log","config","JSON","parse","verbose","mode","customModes","name","slug","roleDefinition","groups","join","err","message","modeSlug","find","m","customInstructions","source","runModeSlug","taskDescription","slice","filter","arg","startsWith","memoryNamespace","indexOf","enhancedTask","tools","buildToolsFromGroups","toolsList","Array","from","instanceId","Date","now","Math","random","toString","substr","enablePermissions","substring","isNonInteractive","executeClaude","tddTaskDescription","phases","description","phase","toolMappings","read","edit","browser","mcp","command","Set","group","isArray","groupName","forEach","tool","add","claudeArgs","configIndex","i","checkResult","Promise","resolve","child","stdio","stdout","on","data","code","success","Buffer","claudePath","TextDecoder","decode","trim","e","warn","CLAUDE_INSTANCE_ID","status","stack"],"mappings":"AACA,SAASA,YAAY,EAAEC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AACrE,SAASC,YAAYC,EAAE,QAAQ,KAAK;AACpC,SAASC,KAAK,QAAQ,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,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CACT;IAEFD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/validation-helper.js"],"sourcesContent":["/**\n * CLI Parameter Validation Helper\n * Provides standardized error messages for invalid parameters\n */\n\nimport { HelpFormatter } from './help-formatter.js';\n\nexport class ValidationHelper {\n /**\n * Validate enum parameter\n */\n static validateEnum(value, paramName, validOptions, commandPath) {\n if (!validOptions.includes(value)) {\n console.error(\n HelpFormatter.formatValidationError(value, paramName, validOptions, commandPath),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate numeric parameter\n */\n static validateNumber(value, paramName, min, max, commandPath) {\n const num = parseInt(value, 10);\n\n if (isNaN(num)) {\n console.error(\n HelpFormatter.formatError(\n `'${value}' is not a valid number for ${paramName}.`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n if (min !== undefined && num < min) {\n console.error(\n HelpFormatter.formatError(\n `${paramName} must be at least ${min}. Got: ${num}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n if (max !== undefined && num > max) {\n console.error(\n HelpFormatter.formatError(\n `${paramName} must be at most ${max}. Got: ${num}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n return num;\n }\n\n /**\n * Validate required parameter\n */\n static validateRequired(value, paramName, commandPath) {\n if (!value || (typeof value === 'string' && value.trim() === '')) {\n console.error(\n HelpFormatter.formatError(\n `Missing required parameter: ${paramName}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate file path exists\n */\n static async validateFilePath(path, paramName, commandPath) {\n try {\n const fs = await import('fs/promises');\n await fs.access(path);\n } catch (error) {\n console.error(\n HelpFormatter.formatError(\n `File not found for ${paramName}: ${path}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate boolean flag\n */\n static validateBoolean(value, paramName, commandPath) {\n const lowerValue = value.toLowerCase();\n if (lowerValue === 'true' || lowerValue === '1' || lowerValue === 'yes') {\n return true;\n }\n if (lowerValue === 'false' || lowerValue === '0' || lowerValue === 'no') {\n return false;\n }\n\n console.error(\n HelpFormatter.formatError(\n `'${value}' is not a valid boolean for ${paramName}. Use: true, false, yes, no, 1, or 0.`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n}\n"],"names":["HelpFormatter","ValidationHelper","validateEnum","value","paramName","validOptions","commandPath","includes","console","error","formatValidationError","process","exit","validateNumber","min","max","num","parseInt","isNaN","formatError","undefined","validateRequired","trim","validateFilePath","path","fs","access","validateBoolean","lowerValue","toLowerCase"],"mappings":"AAKA,SAASA,aAAa,QAAQ,sBAAsB;AAEpD,OAAO,MAAMC;IAIX,OAAOC,aAAaC,KAAK,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F,MAAMmB,KAAK,MAAM,MAAM,CAAC;YACxB,MAAMA,GAAGC,MAAM,CAACF;QAClB,EAAE,OAAOf,OAAO;YACdD,QAAQC,KAAK,CACXT,cAAcmB,WAAW,CACvB,CAAC,mBAAmB,EAAEf,UAAU,EAAE,EAAEoB,MAAM,EAC1ClB,eAAe;YAGnBK,QAAQC,IAAI,CAAC;QACf;IACF;IAKA,OAAOe,gBAAgBxB,KAAK,EAAEC,SAAS,EAAEE,WAAW,EAAE;QACpD,MAAMsB,aAAazB,MAAM0B,WAAW;QACpC,IAAID,eAAe,UAAUA,eAAe,OAAOA,eAAe,OAAO;YACvE,OAAO;QACT;QACA,IAAIA,eAAe,WAAWA,eAAe,OAAOA,eAAe,MAAM;YACvE,OAAO;QACT;QAEApB,QAAQC,KAAK,CACXT,cAAcmB,WAAW,CACvB,CAAC,CAAC,EAAEhB,MAAM,6BAA6B,EAAEC,UAAU,qCAAqC,CAAC,EACzFE,eAAe;QAGnBK,QAAQC,IAAI,CAAC;IACf;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/validation-helper.js"],"sourcesContent":["/**\n * CLI Parameter Validation Helper\n * Provides standardized error messages for invalid parameters\n */\n\nimport { HelpFormatter } from './help-formatter.js';\n\nexport class ValidationHelper {\n /**\n * Validate enum parameter\n */\n static validateEnum(value, paramName, validOptions, commandPath) {\n if (!validOptions.includes(value)) {\n console.error(\n HelpFormatter.formatValidationError(value, paramName, validOptions, commandPath),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate numeric parameter\n */\n static validateNumber(value, paramName, min, max, commandPath) {\n const num = parseInt(value, 10);\n\n if (isNaN(num)) {\n console.error(\n HelpFormatter.formatError(\n `'${value}' is not a valid number for ${paramName}.`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n if (min !== undefined && num < min) {\n console.error(\n HelpFormatter.formatError(\n `${paramName} must be at least ${min}. Got: ${num}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n if (max !== undefined && num > max) {\n console.error(\n HelpFormatter.formatError(\n `${paramName} must be at most ${max}. Got: ${num}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n\n return num;\n }\n\n /**\n * Validate required parameter\n */\n static validateRequired(value, paramName, commandPath) {\n if (!value || (typeof value === 'string' && value.trim() === '')) {\n console.error(\n HelpFormatter.formatError(\n `Missing required parameter: ${paramName}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate file path exists\n */\n static async validateFilePath(path, paramName, commandPath) {\n try {\n const fs = await import('fs/promises');\n await fs.access(path);\n } catch (error) {\n console.error(\n HelpFormatter.formatError(\n `File not found for ${paramName}: ${path}`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n }\n\n /**\n * Validate boolean flag\n */\n static validateBoolean(value, paramName, commandPath) {\n const lowerValue = value.toLowerCase();\n if (lowerValue === 'true' || lowerValue === '1' || lowerValue === 'yes') {\n return true;\n }\n if (lowerValue === 'false' || lowerValue === '0' || lowerValue === 'no') {\n return false;\n }\n\n console.error(\n HelpFormatter.formatError(\n `'${value}' is not a valid boolean for ${paramName}. Use: true, false, yes, no, 1, or 0.`,\n commandPath || 'claude-flow',\n ),\n );\n process.exit(1);\n }\n}\n"],"names":["HelpFormatter","ValidationHelper","validateEnum","value","paramName","validOptions","commandPath","includes","console","error","formatValidationError","process","exit","validateNumber","min","max","num","parseInt","isNaN","formatError","undefined","validateRequired","trim","validateFilePath","path","fs","access","validateBoolean","lowerValue","toLowerCase"],"mappings":"AAKA,SAASA,aAAa,QAAQ,sBAAsB;AAEpD,OAAO,MAAMC;IAIX,OAAOC,aAAaC,KAAK,EAAEC,SAAS,EAAEC,YAAY,EAAEC,WAAW,EAAE;QAC/D,IAAI,CAACD,aAAaE,QAAQ,CAACJ,QAAQ;YACjCK,QAAQC,KAAK,CACXT,cAAcU,qBAAqB,CAACP,OAAOC,WAAWC,cAAcC;YAEtEK,QAAQC,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