claude-flow 2.5.0-alpha.141 ā 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/commands/coordination/README.md +9 -0
- package/.claude/commands/memory/README.md +9 -0
- package/.claude/settings.json +3 -3
- package/.claude/sparc-modes.json +108 -0
- package/README.md +1 -6
- 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/help-formatter.js +0 -3
- package/dist/src/cli/help-formatter.js.map +1 -1
- package/dist/src/cli/help-text.js +53 -5
- 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/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/core/version.js +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/redaction-hook.js +89 -0
- package/dist/src/hooks/redaction-hook.js.map +1 -0
- package/dist/src/memory/swarm-memory.js +340 -421
- package/dist/src/memory/swarm-memory.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/help-text.js +26 -5
- package/src/cli/simple-cli.ts +18 -7
- 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/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/redaction-hook.ts +115 -0
- package/src/utils/key-redactor.js +178 -0
- package/src/utils/key-redactor.ts +184 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent CLI Commands - Execute agents with agentic-flow
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import ora from 'ora';
|
|
8
|
+
import { AgentExecutor } from '../../execution/agent-executor.js';
|
|
9
|
+
import { ProviderManager } from '../../execution/provider-manager.js';
|
|
10
|
+
|
|
11
|
+
export function createAgentCommand(): Command {
|
|
12
|
+
const agent = new Command('agent')
|
|
13
|
+
.description('Execute and manage AI agents with multi-provider support');
|
|
14
|
+
|
|
15
|
+
// agent run command
|
|
16
|
+
agent
|
|
17
|
+
.command('run')
|
|
18
|
+
.description('Execute an agent with a specific task')
|
|
19
|
+
.argument('<agent-name>', 'Agent to execute (e.g., coder, researcher)')
|
|
20
|
+
.argument('<task>', 'Task description for the agent')
|
|
21
|
+
.option('-p, --provider <provider>', 'Provider to use (anthropic, openrouter, onnx, gemini)')
|
|
22
|
+
.option('-m, --model <model>', 'Model to use')
|
|
23
|
+
.option('-t, --temperature <temp>', 'Temperature (0.0-1.0)', parseFloat)
|
|
24
|
+
.option('--max-tokens <tokens>', 'Maximum tokens', parseInt)
|
|
25
|
+
.option('-f, --format <format>', 'Output format (text, json, markdown)', 'text')
|
|
26
|
+
.option('--stream', 'Enable streaming output')
|
|
27
|
+
.option('-v, --verbose', 'Verbose output')
|
|
28
|
+
.action(async (agentName, task, options) => {
|
|
29
|
+
const spinner = ora('Executing agent...').start();
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const executor = new AgentExecutor();
|
|
33
|
+
const providerManager = new ProviderManager();
|
|
34
|
+
|
|
35
|
+
// Use specified provider or default
|
|
36
|
+
const provider = options.provider || providerManager.getDefaultProvider();
|
|
37
|
+
|
|
38
|
+
const result = await executor.execute({
|
|
39
|
+
agent: agentName,
|
|
40
|
+
task: task,
|
|
41
|
+
provider: provider as any,
|
|
42
|
+
model: options.model,
|
|
43
|
+
temperature: options.temperature,
|
|
44
|
+
maxTokens: options.maxTokens,
|
|
45
|
+
outputFormat: options.format,
|
|
46
|
+
stream: options.stream,
|
|
47
|
+
verbose: options.verbose,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
spinner.stop();
|
|
51
|
+
|
|
52
|
+
if (result.success) {
|
|
53
|
+
console.log(chalk.green('ā Agent execution completed\n'));
|
|
54
|
+
console.log(result.output);
|
|
55
|
+
|
|
56
|
+
if (options.verbose) {
|
|
57
|
+
console.log(chalk.gray(`\nProvider: ${result.provider}`));
|
|
58
|
+
console.log(chalk.gray(`Duration: ${result.duration}ms`));
|
|
59
|
+
if (result.tokens) console.log(chalk.gray(`Tokens: ${result.tokens}`));
|
|
60
|
+
if (result.cost) console.log(chalk.gray(`Cost: $${result.cost.toFixed(4)}`));
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
console.error(chalk.red('ā Agent execution failed'));
|
|
64
|
+
console.error(result.error);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
} catch (error: any) {
|
|
68
|
+
spinner.stop();
|
|
69
|
+
console.error(chalk.red('ā Error:'), error.message);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// agent list command
|
|
75
|
+
agent
|
|
76
|
+
.command('list')
|
|
77
|
+
.description('List available agents')
|
|
78
|
+
.option('-s, --source <source>', 'Filter by source (all, package, local)', 'all')
|
|
79
|
+
.option('-f, --format <format>', 'Output format (text, json)', 'text')
|
|
80
|
+
.action(async (options) => {
|
|
81
|
+
const spinner = ora('Loading agents...').start();
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const executor = new AgentExecutor();
|
|
85
|
+
const agents = await executor.listAgents(options.source as any);
|
|
86
|
+
|
|
87
|
+
spinner.stop();
|
|
88
|
+
|
|
89
|
+
if (options.format === 'json') {
|
|
90
|
+
console.log(JSON.stringify(agents, null, 2));
|
|
91
|
+
} else {
|
|
92
|
+
console.log(chalk.cyan(`\nš Available Agents (${agents.length}):\n`));
|
|
93
|
+
agents.forEach(agent => {
|
|
94
|
+
console.log(chalk.white(` ⢠${agent}`));
|
|
95
|
+
});
|
|
96
|
+
console.log('');
|
|
97
|
+
}
|
|
98
|
+
} catch (error: any) {
|
|
99
|
+
spinner.stop();
|
|
100
|
+
console.error(chalk.red('ā Error:'), error.message);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// agent info command
|
|
106
|
+
agent
|
|
107
|
+
.command('info')
|
|
108
|
+
.description('Get information about a specific agent')
|
|
109
|
+
.argument('<agent-name>', 'Agent name')
|
|
110
|
+
.action(async (agentName) => {
|
|
111
|
+
const spinner = ora('Loading agent info...').start();
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
const executor = new AgentExecutor();
|
|
115
|
+
const info = await executor.getAgentInfo(agentName);
|
|
116
|
+
|
|
117
|
+
spinner.stop();
|
|
118
|
+
|
|
119
|
+
if (info) {
|
|
120
|
+
console.log(chalk.cyan(`\nš Agent: ${agentName}\n`));
|
|
121
|
+
console.log(chalk.white(`Description: ${info.description || 'N/A'}`));
|
|
122
|
+
console.log(chalk.white(`Category: ${info.category || 'N/A'}`));
|
|
123
|
+
console.log(chalk.white(`Source: ${info.source || 'N/A'}`));
|
|
124
|
+
console.log('');
|
|
125
|
+
} else {
|
|
126
|
+
console.error(chalk.red('ā Agent not found'));
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
} catch (error: any) {
|
|
130
|
+
spinner.stop();
|
|
131
|
+
console.error(chalk.red('ā Error:'), error.message);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return agent;
|
|
137
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config CLI Commands - Manage provider configuration
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import inquirer from 'inquirer';
|
|
8
|
+
import { ProviderManager } from '../../execution/provider-manager.js';
|
|
9
|
+
|
|
10
|
+
export function createConfigCommand(): Command {
|
|
11
|
+
const config = new Command('config')
|
|
12
|
+
.description('Manage provider configuration');
|
|
13
|
+
|
|
14
|
+
// config set-provider command
|
|
15
|
+
config
|
|
16
|
+
.command('set-provider')
|
|
17
|
+
.description('Set default provider')
|
|
18
|
+
.argument('<provider>', 'Provider name (anthropic, openrouter, onnx, gemini)')
|
|
19
|
+
.option('-m, --model <model>', 'Default model for provider')
|
|
20
|
+
.action(async (provider, options) => {
|
|
21
|
+
try {
|
|
22
|
+
const manager = new ProviderManager();
|
|
23
|
+
|
|
24
|
+
await manager.setDefaultProvider(provider);
|
|
25
|
+
|
|
26
|
+
if (options.model) {
|
|
27
|
+
await manager.configureProvider(provider, {
|
|
28
|
+
model: options.model,
|
|
29
|
+
enabled: true,
|
|
30
|
+
} as any);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log(chalk.green(`ā Default provider set to: ${provider}`));
|
|
34
|
+
if (options.model) {
|
|
35
|
+
console.log(chalk.green(`ā Default model set to: ${options.model}`));
|
|
36
|
+
}
|
|
37
|
+
} catch (error: any) {
|
|
38
|
+
console.error(chalk.red('ā Error:'), error.message);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// config list-providers command
|
|
44
|
+
config
|
|
45
|
+
.command('list-providers')
|
|
46
|
+
.alias('list')
|
|
47
|
+
.description('List configured providers')
|
|
48
|
+
.option('-f, --format <format>', 'Output format (text, json)', 'text')
|
|
49
|
+
.action(async (options) => {
|
|
50
|
+
try {
|
|
51
|
+
const manager = new ProviderManager();
|
|
52
|
+
const providers = manager.listProviders();
|
|
53
|
+
const defaultProvider = manager.getDefaultProvider();
|
|
54
|
+
|
|
55
|
+
if (options.format === 'json') {
|
|
56
|
+
console.log(JSON.stringify({ defaultProvider, providers }, null, 2));
|
|
57
|
+
} else {
|
|
58
|
+
console.log(chalk.cyan('\nš Configured Providers:\n'));
|
|
59
|
+
console.log(chalk.white(`Default: ${chalk.bold(defaultProvider)}\n`));
|
|
60
|
+
|
|
61
|
+
providers.forEach(provider => {
|
|
62
|
+
const isDefault = provider.name === defaultProvider;
|
|
63
|
+
const prefix = isDefault ? chalk.green('ā') : chalk.gray('ā');
|
|
64
|
+
const status = provider.enabled ? chalk.green('enabled') : chalk.gray('disabled');
|
|
65
|
+
|
|
66
|
+
console.log(`${prefix} ${chalk.bold(provider.name)}`);
|
|
67
|
+
console.log(` Model: ${provider.model || 'default'}`);
|
|
68
|
+
console.log(` Priority: ${provider.priority || 'balanced'}`);
|
|
69
|
+
console.log(` Status: ${status}`);
|
|
70
|
+
console.log('');
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
} catch (error: any) {
|
|
74
|
+
console.error(chalk.red('ā Error:'), error.message);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// config wizard command
|
|
80
|
+
config
|
|
81
|
+
.command('wizard')
|
|
82
|
+
.description('Interactive provider configuration wizard')
|
|
83
|
+
.action(async () => {
|
|
84
|
+
try {
|
|
85
|
+
const manager = new ProviderManager();
|
|
86
|
+
|
|
87
|
+
console.log(chalk.cyan('\nš§ Provider Configuration Wizard\n'));
|
|
88
|
+
|
|
89
|
+
const answers = await inquirer.prompt([
|
|
90
|
+
{
|
|
91
|
+
type: 'list',
|
|
92
|
+
name: 'defaultProvider',
|
|
93
|
+
message: 'Select default provider:',
|
|
94
|
+
choices: [
|
|
95
|
+
{ name: 'Anthropic (Highest quality)', value: 'anthropic' },
|
|
96
|
+
{ name: 'OpenRouter (99% cost savings)', value: 'openrouter' },
|
|
97
|
+
{ name: 'ONNX (Free local inference)', value: 'onnx' },
|
|
98
|
+
{ name: 'Gemini (Free tier)', value: 'gemini' },
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: 'list',
|
|
103
|
+
name: 'optimization',
|
|
104
|
+
message: 'Optimization priority:',
|
|
105
|
+
choices: [
|
|
106
|
+
{ name: 'Balanced (recommended)', value: 'balanced' },
|
|
107
|
+
{ name: 'Cost (cheapest)', value: 'cost' },
|
|
108
|
+
{ name: 'Quality (best results)', value: 'quality' },
|
|
109
|
+
{ name: 'Speed (fastest)', value: 'speed' },
|
|
110
|
+
{ name: 'Privacy (local only)', value: 'privacy' },
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
await manager.setDefaultProvider(answers.defaultProvider);
|
|
116
|
+
|
|
117
|
+
console.log(chalk.green('\nā Configuration saved successfully!'));
|
|
118
|
+
console.log(chalk.gray(`\nDefault provider: ${answers.defaultProvider}`));
|
|
119
|
+
console.log(chalk.gray(`Optimization: ${answers.optimization}`));
|
|
120
|
+
} catch (error: any) {
|
|
121
|
+
console.error(chalk.red('\nā Error:'), error.message);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return config;
|
|
127
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// env-template.js - Environment template generator
|
|
2
|
+
import { printSuccess, printError, printWarning } from '../utils.js';
|
|
3
|
+
import { existsSync } from 'fs';
|
|
4
|
+
import { promises as fs } from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generate .env template with configuration instructions
|
|
9
|
+
*/
|
|
10
|
+
export async function generateEnvTemplate(workingDir = process.cwd(), force = false) {
|
|
11
|
+
const envPath = path.join(workingDir, '.env');
|
|
12
|
+
|
|
13
|
+
// Check if .env already exists
|
|
14
|
+
if (existsSync(envPath) && !force) {
|
|
15
|
+
printWarning('ā ļø .env file already exists');
|
|
16
|
+
console.log('Use --force to overwrite existing .env file');
|
|
17
|
+
return { exists: true, created: false };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const template = `# Agentic Flow Configuration
|
|
21
|
+
# Generated by claude-flow init --env
|
|
22
|
+
# Created: ${new Date().toISOString()}
|
|
23
|
+
|
|
24
|
+
# ============================================
|
|
25
|
+
# REQUIRED FOR REASONINGBANK MEMORY
|
|
26
|
+
# ============================================
|
|
27
|
+
# Without these, ReasoningBank will fall back to heuristic mode (regex matching)
|
|
28
|
+
# For actual learning and memory consolidation, you MUST provide API keys
|
|
29
|
+
|
|
30
|
+
# Anthropic API key for Claude models (sk-ant-...)
|
|
31
|
+
# Get your key: https://console.anthropic.com/settings/keys
|
|
32
|
+
ANTHROPIC_API_KEY=
|
|
33
|
+
|
|
34
|
+
# OpenRouter API key for alternative models (sk-or-v1-...)
|
|
35
|
+
# Get your key: https://openrouter.ai/keys
|
|
36
|
+
# Enables 99% cost savings with DeepSeek R1 for judge/distill
|
|
37
|
+
OPENROUTER_API_KEY=
|
|
38
|
+
|
|
39
|
+
# Google Gemini API key (optional, for free tier)
|
|
40
|
+
# Get your key: https://aistudio.google.com/app/apikey
|
|
41
|
+
GOOGLE_GEMINI_API_KEY=
|
|
42
|
+
|
|
43
|
+
# ============================================
|
|
44
|
+
# MODEL CONFIGURATION
|
|
45
|
+
# ============================================
|
|
46
|
+
# Default model for completions (Claude 3.5 Sonnet v2 - latest)
|
|
47
|
+
COMPLETION_MODEL=claude-3-5-sonnet-20241022
|
|
48
|
+
|
|
49
|
+
# Default provider (anthropic, openrouter, onnx, gemini)
|
|
50
|
+
PROVIDER=anthropic
|
|
51
|
+
|
|
52
|
+
# ============================================
|
|
53
|
+
# ADVANCED: REASONINGBANK COST OPTIMIZATION
|
|
54
|
+
# ============================================
|
|
55
|
+
# To use cheap models for memory operations (46% savings):
|
|
56
|
+
# 1. Set OPENROUTER_API_KEY above
|
|
57
|
+
# 2. Create .swarm/reasoningbank.yaml with:
|
|
58
|
+
#
|
|
59
|
+
# reasoningbank:
|
|
60
|
+
# judge:
|
|
61
|
+
# model: "deepseek/deepseek-r1"
|
|
62
|
+
# max_tokens: 512
|
|
63
|
+
# temperature: 0
|
|
64
|
+
# distill:
|
|
65
|
+
# model: "deepseek/deepseek-r1"
|
|
66
|
+
# max_tokens: 2048
|
|
67
|
+
# temperature: 0.3
|
|
68
|
+
# embeddings:
|
|
69
|
+
# provider: "openrouter"
|
|
70
|
+
# model: "deepseek/deepseek-r1"
|
|
71
|
+
# dimensions: 1024
|
|
72
|
+
#
|
|
73
|
+
# This keeps Claude for main work but uses DeepSeek for memory (99% cheaper)
|
|
74
|
+
# Result: $0.37 ā $0.20 per task with memory (46% savings!)
|
|
75
|
+
|
|
76
|
+
# ============================================
|
|
77
|
+
# OPTIONAL API KEYS
|
|
78
|
+
# ============================================
|
|
79
|
+
# Perplexity API key (for GOAP search integration)
|
|
80
|
+
PERPLEXITY_API_KEY=
|
|
81
|
+
|
|
82
|
+
# Hugging Face API key (for ONNX models)
|
|
83
|
+
HUGGINGFACE_API_KEY=
|
|
84
|
+
|
|
85
|
+
# E2B API keys (for Flow Nexus sandbox deployment)
|
|
86
|
+
E2B_API_KEY=
|
|
87
|
+
E2B_ACCESS_TOKEN=
|
|
88
|
+
|
|
89
|
+
# Supabase configuration (for Flow Nexus cloud features)
|
|
90
|
+
SUPABASE_URL=
|
|
91
|
+
SUPABASE_ANON_KEY=
|
|
92
|
+
SUPABASE_ACCESS_TOKEN=
|
|
93
|
+
SUPABASE_PROJECT_ID=
|
|
94
|
+
|
|
95
|
+
# ============================================
|
|
96
|
+
# WHAT HAPPENS WITHOUT .env?
|
|
97
|
+
# ============================================
|
|
98
|
+
# Without this file:
|
|
99
|
+
# 1. No automatic environment variable loading
|
|
100
|
+
# 2. ReasoningBank falls back to heuristic judgment (regex-based)
|
|
101
|
+
# 3. No actual learning or memory consolidation
|
|
102
|
+
# 4. Demo will appear to work but uses pattern matching only
|
|
103
|
+
#
|
|
104
|
+
# You can still work without .env by:
|
|
105
|
+
# - Manually exporting environment variables
|
|
106
|
+
# - Or passing inline with commands
|
|
107
|
+
#
|
|
108
|
+
# But using .env is recommended for convenience and security.
|
|
109
|
+
|
|
110
|
+
# ============================================
|
|
111
|
+
# SECURITY NOTES
|
|
112
|
+
# ============================================
|
|
113
|
+
# 1. NEVER commit this file to git (it's in .gitignore)
|
|
114
|
+
# 2. Use different keys for dev/staging/production
|
|
115
|
+
# 3. Rotate keys regularly
|
|
116
|
+
# 4. Use key-specific permissions when possible
|
|
117
|
+
`;
|
|
118
|
+
|
|
119
|
+
// Write template
|
|
120
|
+
try {
|
|
121
|
+
await fs.writeFile(envPath, template, 'utf8');
|
|
122
|
+
printSuccess('ā
Created .env template file');
|
|
123
|
+
return { exists: false, created: true, path: envPath };
|
|
124
|
+
} catch (error) {
|
|
125
|
+
printError(`ā Failed to create .env template: ${error.message}`);
|
|
126
|
+
return { exists: false, created: false, error: error.message };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Check if .env exists and has required keys
|
|
132
|
+
*/
|
|
133
|
+
export async function checkEnvConfig(workingDir = process.cwd()) {
|
|
134
|
+
const envPath = path.join(workingDir, '.env');
|
|
135
|
+
|
|
136
|
+
if (!existsSync(envPath)) {
|
|
137
|
+
return {
|
|
138
|
+
exists: false,
|
|
139
|
+
hasApiKeys: false,
|
|
140
|
+
message: '.env file not found'
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
const envContent = await fs.readFile(envPath, 'utf8');
|
|
146
|
+
|
|
147
|
+
// Check for API keys (not commented out and not empty)
|
|
148
|
+
const hasAnthropicKey = /^ANTHROPIC_API_KEY=[^\s]+$/m.test(envContent);
|
|
149
|
+
const hasOpenRouterKey = /^OPENROUTER_API_KEY=[^\s]+$/m.test(envContent);
|
|
150
|
+
const hasGeminiKey = /^GOOGLE_GEMINI_API_KEY=[^\s]+$/m.test(envContent);
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
exists: true,
|
|
154
|
+
hasApiKeys: hasAnthropicKey || hasOpenRouterKey || hasGeminiKey,
|
|
155
|
+
keys: {
|
|
156
|
+
anthropic: hasAnthropicKey,
|
|
157
|
+
openrouter: hasOpenRouterKey,
|
|
158
|
+
gemini: hasGeminiKey
|
|
159
|
+
},
|
|
160
|
+
message: 'Configuration found'
|
|
161
|
+
};
|
|
162
|
+
} catch (error) {
|
|
163
|
+
return {
|
|
164
|
+
exists: true,
|
|
165
|
+
hasApiKeys: false,
|
|
166
|
+
message: `Error reading .env: ${error.message}`
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Show .env setup instructions
|
|
173
|
+
*/
|
|
174
|
+
export function showEnvSetupInstructions() {
|
|
175
|
+
console.log('\nš Setting up .env for ReasoningBank capabilities:\n');
|
|
176
|
+
console.log('1. Create .env file:');
|
|
177
|
+
console.log(' claude-flow init --env\n');
|
|
178
|
+
console.log('2. Add your API keys to .env:');
|
|
179
|
+
console.log(' ANTHROPIC_API_KEY=sk-ant-...');
|
|
180
|
+
console.log(' OPENROUTER_API_KEY=sk-or-v1-... # Optional: 99% cost savings\n');
|
|
181
|
+
console.log('3. Get API keys:');
|
|
182
|
+
console.log(' ⢠Anthropic: https://console.anthropic.com/settings/keys');
|
|
183
|
+
console.log(' ⢠OpenRouter: https://openrouter.ai/keys (for cost optimization)\n');
|
|
184
|
+
console.log('š” Without API keys:');
|
|
185
|
+
console.log(' ⢠ReasoningBank falls back to regex pattern matching (no learning)');
|
|
186
|
+
console.log(' ⢠Memory operations will appear to work but won\'t actually learn\n');
|
|
187
|
+
console.log('š° Cost optimization:');
|
|
188
|
+
console.log(' ⢠Use OpenRouter + DeepSeek R1 for judge/distill (99% cheaper)');
|
|
189
|
+
console.log(' ⢠See: docs/REASONINGBANK-COST-OPTIMIZATION.md\n');
|
|
190
|
+
}
|
|
@@ -14,6 +14,19 @@ export function showInitHelp() {
|
|
|
14
14
|
console.log(' --dry-run, -d Preview what would be created without making changes');
|
|
15
15
|
console.log(' --help, -h Show this help message');
|
|
16
16
|
console.log();
|
|
17
|
+
console.log('Environment Configuration:');
|
|
18
|
+
console.log(' --env Generate .env template for API keys');
|
|
19
|
+
console.log(' ⢠Required for ReasoningBank memory');
|
|
20
|
+
console.log(' ⢠Includes setup instructions');
|
|
21
|
+
console.log(' ⢠Cost optimization guide');
|
|
22
|
+
console.log();
|
|
23
|
+
console.log('Specialized Agent Setup:');
|
|
24
|
+
console.log(' --agent reasoning Setup ReasoningBank agents with closed-loop learning');
|
|
25
|
+
console.log(' Includes goal-planner and sublinear-goal-planner agents');
|
|
26
|
+
console.log(' ⢠+26% success rate (70% ā 88%)');
|
|
27
|
+
console.log(' ⢠-25% token usage (cost savings)');
|
|
28
|
+
console.log(' ⢠3.2x learning velocity (faster improvement)');
|
|
29
|
+
console.log();
|
|
17
30
|
console.log('Alternative Initialization Modes:');
|
|
18
31
|
console.log(' --basic Use basic initialization (pre-v2.0.0 behavior)');
|
|
19
32
|
console.log(' --sparc, -s Initialize with SPARC development environment');
|
|
@@ -44,6 +57,10 @@ export function showInitHelp() {
|
|
|
44
57
|
console.log(' --validate --skip-mode-test Skip SPARC mode testing');
|
|
45
58
|
console.log();
|
|
46
59
|
console.log('Examples:');
|
|
60
|
+
console.log('š ENVIRONMENT SETUP:');
|
|
61
|
+
console.log(' claude-flow init --env # Generate .env template');
|
|
62
|
+
console.log(' claude-flow init --env --force # Overwrite existing .env');
|
|
63
|
+
console.log();
|
|
47
64
|
console.log('š CLAUDE FLOW v2.0.0 (DEFAULT):');
|
|
48
65
|
console.log(' claude-flow init # ā DEFAULT: Full Claude Flow v2.0.0 setup');
|
|
49
66
|
console.log(' claude-flow init --force # Overwrite existing configuration');
|
|
@@ -60,6 +77,12 @@ export function showInitHelp() {
|
|
|
60
77
|
console.log(' claude-flow init --dry-run --sparc # Preview initialization');
|
|
61
78
|
console.log(' claude-flow init --minimal # Minimal setup');
|
|
62
79
|
console.log();
|
|
80
|
+
console.log('š§ REASONING AGENTS WITH REASONINGBANK:');
|
|
81
|
+
console.log(' claude-flow init --agent reasoning # Setup ReasoningBank agents');
|
|
82
|
+
console.log(' claude-flow init --agent reasoning --force # Overwrite existing setup');
|
|
83
|
+
console.log(' # Note: Requires .env with API keys for actual learning');
|
|
84
|
+
console.log(' # Use: npx agentic-flow --agent goal-planner --task "your task"');
|
|
85
|
+
console.log();
|
|
63
86
|
console.log('š VERIFICATION & PAIR PROGRAMMING:');
|
|
64
87
|
console.log(' claude-flow init --verify # Truth Verification System setup');
|
|
65
88
|
console.log(' claude-flow init --pair # Pair Programming mode setup');
|
|
@@ -340,10 +340,34 @@ export async function initCommand(subArgs, flags) {
|
|
|
340
340
|
return;
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
// Handle --env flag for .env template generation
|
|
344
|
+
if (flags.env || subArgs.includes('--env')) {
|
|
345
|
+
const { generateEnvTemplate } = await import('../env-template.js');
|
|
346
|
+
const workingDir = process.env.PWD || process.cwd();
|
|
347
|
+
const force = flags.force || flags.f;
|
|
348
|
+
|
|
349
|
+
console.log('š Generating .env template file...\n');
|
|
350
|
+
const result = await generateEnvTemplate(workingDir, force);
|
|
351
|
+
|
|
352
|
+
if (result.created) {
|
|
353
|
+
console.log('\nš Next steps:');
|
|
354
|
+
console.log('1. Open .env file and add your API keys');
|
|
355
|
+
console.log('2. Get keys from:');
|
|
356
|
+
console.log(' ⢠Anthropic: https://console.anthropic.com/settings/keys');
|
|
357
|
+
console.log(' ⢠OpenRouter: https://openrouter.ai/keys');
|
|
358
|
+
console.log('3. Enable memory: claude-flow agent run coder "task" --enable-memory\n');
|
|
359
|
+
console.log('š” See docs/REASONINGBANK-COST-OPTIMIZATION.md for cost savings tips');
|
|
360
|
+
} else if (result.exists) {
|
|
361
|
+
console.log('š” To overwrite: claude-flow init --env --force');
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
|
|
343
367
|
// Check for verification flags first
|
|
344
|
-
const hasVerificationFlags = subArgs.includes('--verify') || subArgs.includes('--pair') ||
|
|
368
|
+
const hasVerificationFlags = subArgs.includes('--verify') || subArgs.includes('--pair') ||
|
|
345
369
|
flags.verify || flags.pair;
|
|
346
|
-
|
|
370
|
+
|
|
347
371
|
// Handle Flow Nexus minimal init
|
|
348
372
|
if (flags['flow-nexus']) {
|
|
349
373
|
return await flowNexusMinimalInit(flags, subArgs);
|
|
@@ -1299,6 +1323,10 @@ async function enhancedClaudeFlowInit(flags, subArgs = []) {
|
|
|
1299
1323
|
const dryRun = flags.dryRun || flags['dry-run'] || flags.d;
|
|
1300
1324
|
const initSparc = flags.roo || (subArgs && subArgs.includes('--roo')); // SPARC only with --roo flag
|
|
1301
1325
|
|
|
1326
|
+
// Parse --agent flag for specialized agent setup
|
|
1327
|
+
const agentType = flags.agent || (subArgs && subArgs.find(arg => arg.startsWith('--agent='))?.split('=')[1]);
|
|
1328
|
+
const initReasoning = agentType === 'reasoning' || (subArgs && subArgs.includes('--agent') && subArgs.includes('reasoning'));
|
|
1329
|
+
|
|
1302
1330
|
// Store parameters to avoid scope issues in async context
|
|
1303
1331
|
const args = subArgs || [];
|
|
1304
1332
|
const options = flags || {};
|
|
@@ -1668,29 +1696,79 @@ ${commands.map((cmd) => `- [${cmd}](./${cmd}.md)`).join('\n')}
|
|
|
1668
1696
|
force: force,
|
|
1669
1697
|
dryRun: dryRun
|
|
1670
1698
|
});
|
|
1671
|
-
|
|
1699
|
+
|
|
1672
1700
|
if (agentResult.success) {
|
|
1673
1701
|
await validateAgentSystem(workingDir);
|
|
1674
|
-
|
|
1702
|
+
|
|
1675
1703
|
// Copy command files including Flow Nexus commands
|
|
1676
1704
|
console.log('\nš Setting up command system...');
|
|
1677
1705
|
const commandResult = await copyCommandFiles(workingDir, {
|
|
1678
1706
|
force: force,
|
|
1679
1707
|
dryRun: dryRun
|
|
1680
1708
|
});
|
|
1681
|
-
|
|
1709
|
+
|
|
1682
1710
|
if (commandResult.success) {
|
|
1683
1711
|
console.log('ā
ā Command system setup complete with Flow Nexus integration');
|
|
1684
1712
|
} else {
|
|
1685
1713
|
console.log('ā ļø Command system setup failed:', commandResult.error);
|
|
1686
1714
|
}
|
|
1687
|
-
|
|
1715
|
+
|
|
1688
1716
|
console.log('ā
ā Agent system setup complete with 64 specialized agents');
|
|
1689
1717
|
} else {
|
|
1690
1718
|
console.log('ā ļø Agent system setup failed:', agentResult.error);
|
|
1691
1719
|
}
|
|
1720
|
+
|
|
1721
|
+
// Setup reasoning agents if --agent reasoning flag is used
|
|
1722
|
+
if (initReasoning) {
|
|
1723
|
+
console.log('\nš§ Setting up reasoning agents with ReasoningBank integration...');
|
|
1724
|
+
try {
|
|
1725
|
+
const reasoningAgentsDir = `${workingDir}/.claude/agents/reasoning`;
|
|
1726
|
+
await fs.mkdir(reasoningAgentsDir, { recursive: true });
|
|
1727
|
+
|
|
1728
|
+
// Import path module
|
|
1729
|
+
const path = await import('path');
|
|
1730
|
+
const { fileURLToPath } = await import('url');
|
|
1731
|
+
const { dirname, join } = path.default;
|
|
1732
|
+
|
|
1733
|
+
// Get the source reasoning agents directory
|
|
1734
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
1735
|
+
const __dirname = dirname(__filename);
|
|
1736
|
+
const sourceReasoningDir = join(__dirname, '../../../../.claude/agents/reasoning');
|
|
1737
|
+
|
|
1738
|
+
// Copy reasoning agent files
|
|
1739
|
+
try {
|
|
1740
|
+
const reasoningFiles = await fs.readdir(sourceReasoningDir);
|
|
1741
|
+
let copiedReasoningAgents = 0;
|
|
1742
|
+
|
|
1743
|
+
for (const file of reasoningFiles) {
|
|
1744
|
+
if (file.endsWith('.md')) {
|
|
1745
|
+
const sourcePath = join(sourceReasoningDir, file);
|
|
1746
|
+
const destPath = join(reasoningAgentsDir, file);
|
|
1747
|
+
const content = await fs.readFile(sourcePath, 'utf8');
|
|
1748
|
+
await fs.writeFile(destPath, content);
|
|
1749
|
+
copiedReasoningAgents++;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
printSuccess(`ā Copied ${copiedReasoningAgents} reasoning agent files`);
|
|
1754
|
+
console.log(' š Reasoning agents available:');
|
|
1755
|
+
console.log(' ⢠goal-planner - Goal-Oriented Action Planning specialist');
|
|
1756
|
+
console.log(' ⢠sublinear-goal-planner - Sub-linear complexity goal planning');
|
|
1757
|
+
console.log(' š” Use: npx agentic-flow --agent goal-planner --task "your task"');
|
|
1758
|
+
console.log(' š Documentation: .claude/agents/reasoning/README.md');
|
|
1759
|
+
} catch (err) {
|
|
1760
|
+
console.log(` ā ļø Could not copy reasoning agents: ${err.message}`);
|
|
1761
|
+
console.log(' Reasoning agents may not be available yet');
|
|
1762
|
+
}
|
|
1763
|
+
} catch (err) {
|
|
1764
|
+
console.log(` ā ļø Reasoning agent setup failed: ${err.message}`);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1692
1767
|
} else {
|
|
1693
1768
|
console.log(' [DRY RUN] Would create agent system with 64 specialized agents');
|
|
1769
|
+
if (initReasoning) {
|
|
1770
|
+
console.log(' [DRY RUN] Would also setup reasoning agents with ReasoningBank integration');
|
|
1771
|
+
}
|
|
1694
1772
|
}
|
|
1695
1773
|
|
|
1696
1774
|
// Optional: Setup monitoring and telemetry
|