claude-flow 2.7.0-alpha ā 2.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/claude-flow +1 -1
- package/dist/src/cli/help-formatter.js +5 -0
- package/dist/src/cli/simple-commands/config.js +115 -257
- package/dist/src/cli/simple-commands/config.js.map +1 -1
- package/dist/src/cli/simple-commands/memory.js +120 -13
- package/dist/src/cli/simple-commands/memory.js.map +1 -1
- package/dist/src/reasoningbank/reasoningbank-adapter.js +144 -0
- package/dist/src/reasoningbank/reasoningbank-adapter.js.map +1 -0
- package/dist/src/utils/key-redactor.js.map +1 -1
- package/dist/src/utils/metrics-reader.js +39 -37
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/REASONINGBANK-INTEGRATION-STATUS.md +179 -0
- package/package.json +1 -1
- package/src/cli/simple-commands/memory.js +148 -14
- package/src/reasoningbank/reasoningbank-adapter.js +191 -0
package/bin/claude-flow
CHANGED
|
@@ -1,265 +1,123 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
break;
|
|
17
|
-
case 'validate':
|
|
18
|
-
await validateConfig(subArgs, flags);
|
|
19
|
-
break;
|
|
20
|
-
case 'reset':
|
|
21
|
-
await resetConfig(subArgs, flags);
|
|
22
|
-
break;
|
|
23
|
-
default:
|
|
24
|
-
showConfigHelp();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function initConfig(subArgs, flags) {
|
|
28
|
-
const force = subArgs.includes('--force') || subArgs.includes('-f');
|
|
29
|
-
const configFile = 'claude-flow.config.json';
|
|
30
|
-
try {
|
|
31
|
-
const exists = await fileExists(configFile);
|
|
32
|
-
if (exists && !force) {
|
|
33
|
-
printWarning('Configuration file already exists');
|
|
34
|
-
console.log('Use --force to overwrite existing configuration');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
printSuccess('Initializing Claude-Flow configuration...');
|
|
38
|
-
const defaultConfig = {
|
|
39
|
-
version: '1.0.71',
|
|
40
|
-
terminal: {
|
|
41
|
-
poolSize: 10,
|
|
42
|
-
recycleAfter: 20,
|
|
43
|
-
healthCheckInterval: 30000,
|
|
44
|
-
type: 'auto'
|
|
45
|
-
},
|
|
46
|
-
orchestrator: {
|
|
47
|
-
maxConcurrentTasks: 10,
|
|
48
|
-
taskTimeout: 300000,
|
|
49
|
-
defaultPriority: 5
|
|
50
|
-
},
|
|
51
|
-
memory: {
|
|
52
|
-
backend: 'json',
|
|
53
|
-
path: './memory/claude-flow-data.json',
|
|
54
|
-
cacheSize: 1000,
|
|
55
|
-
indexing: true
|
|
56
|
-
},
|
|
57
|
-
agents: {
|
|
58
|
-
maxAgents: 20,
|
|
59
|
-
defaultCapabilities: [
|
|
60
|
-
'research',
|
|
61
|
-
'code',
|
|
62
|
-
'terminal'
|
|
63
|
-
],
|
|
64
|
-
resourceLimits: {
|
|
65
|
-
memory: '1GB',
|
|
66
|
-
cpu: '50%'
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
mcp: {
|
|
70
|
-
port: 3000,
|
|
71
|
-
host: 'localhost',
|
|
72
|
-
timeout: 30000
|
|
73
|
-
},
|
|
74
|
-
logging: {
|
|
75
|
-
level: 'info',
|
|
76
|
-
file: './claude-flow.log',
|
|
77
|
-
maxSize: '10MB',
|
|
78
|
-
maxFiles: 5
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { ProviderManager } from '../../execution/provider-manager.js';
|
|
5
|
+
export function createConfigCommand() {
|
|
6
|
+
const config = new Command('config').description('Manage provider configuration');
|
|
7
|
+
config.command('set-provider').description('Set default provider').argument('<provider>', 'Provider name (anthropic, openrouter, onnx, gemini)').option('-m, --model <model>', 'Default model for provider').action(async (provider, options)=>{
|
|
8
|
+
try {
|
|
9
|
+
const manager = new ProviderManager();
|
|
10
|
+
await manager.setDefaultProvider(provider);
|
|
11
|
+
if (options.model) {
|
|
12
|
+
await manager.configureProvider(provider, {
|
|
13
|
+
model: options.model,
|
|
14
|
+
enabled: true
|
|
15
|
+
});
|
|
79
16
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
console.log('ā Default settings configured');
|
|
84
|
-
console.log('\nNext steps:');
|
|
85
|
-
console.log('1. Review settings: claude-flow config show');
|
|
86
|
-
console.log('2. Customize values: claude-flow config set <key> <value>');
|
|
87
|
-
console.log('3. Validate config: claude-flow config validate');
|
|
88
|
-
} catch (err) {
|
|
89
|
-
printError(`Failed to initialize configuration: ${err.message}`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async function showConfig(subArgs, flags) {
|
|
93
|
-
const configFile = 'claude-flow.config.json';
|
|
94
|
-
const format = getFlag(subArgs, '--format') || 'pretty';
|
|
95
|
-
try {
|
|
96
|
-
const config = await readJsonFile(configFile);
|
|
97
|
-
printSuccess('Current configuration:');
|
|
98
|
-
if (format === 'json') {
|
|
99
|
-
console.log(JSON.stringify(config, null, 2));
|
|
100
|
-
} else {
|
|
101
|
-
console.log('\nš System Configuration:');
|
|
102
|
-
console.log(` Version: ${config.version || 'unknown'}`);
|
|
103
|
-
console.log('\nš„ļø Terminal Pool:');
|
|
104
|
-
console.log(` Pool Size: ${config.terminal?.poolSize || 10}`);
|
|
105
|
-
console.log(` Recycle After: ${config.terminal?.recycleAfter || 20} commands`);
|
|
106
|
-
console.log(` Health Check: ${config.terminal?.healthCheckInterval || 30000}ms`);
|
|
107
|
-
console.log('\nš Orchestrator:');
|
|
108
|
-
console.log(` Max Concurrent Tasks: ${config.orchestrator?.maxConcurrentTasks || 10}`);
|
|
109
|
-
console.log(` Task Timeout: ${config.orchestrator?.taskTimeout || 300000}ms`);
|
|
110
|
-
console.log('\nš¾ Memory:');
|
|
111
|
-
console.log(` Backend: ${config.memory?.backend || 'json'}`);
|
|
112
|
-
console.log(` Path: ${config.memory?.path || './memory/claude-flow-data.json'}`);
|
|
113
|
-
console.log('\nš¤ Agents:');
|
|
114
|
-
console.log(` Max Agents: ${config.agents?.maxAgents || 20}`);
|
|
115
|
-
console.log(` Resource Limits: ${JSON.stringify(config.agents?.resourceLimits || {})}`);
|
|
116
|
-
}
|
|
117
|
-
} catch (err) {
|
|
118
|
-
printError('Configuration file not found');
|
|
119
|
-
console.log('Run "claude-flow config init" to create default configuration');
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
async function getConfigValue(subArgs, flags) {
|
|
123
|
-
const key = subArgs[1];
|
|
124
|
-
const configFile = 'claude-flow.config.json';
|
|
125
|
-
if (!key) {
|
|
126
|
-
printError('Usage: config get <key>');
|
|
127
|
-
console.log('Examples:');
|
|
128
|
-
console.log(' claude-flow config get terminal.poolSize');
|
|
129
|
-
console.log(' claude-flow config get orchestrator.maxConcurrentTasks');
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
try {
|
|
133
|
-
const config = await readJsonFile(configFile);
|
|
134
|
-
const value = getNestedValue(config, key);
|
|
135
|
-
if (value !== undefined) {
|
|
136
|
-
console.log(`${key}: ${JSON.stringify(value)}`);
|
|
137
|
-
} else {
|
|
138
|
-
printWarning(`Configuration key '${key}' not found`);
|
|
139
|
-
}
|
|
140
|
-
} catch (err) {
|
|
141
|
-
printError('Configuration file not found');
|
|
142
|
-
console.log('Run "claude-flow config init" to create configuration');
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
async function setConfigValue(subArgs, flags) {
|
|
146
|
-
const key = subArgs[1];
|
|
147
|
-
const value = subArgs[2];
|
|
148
|
-
const configFile = 'claude-flow.config.json';
|
|
149
|
-
if (!key || value === undefined) {
|
|
150
|
-
printError('Usage: config set <key> <value>');
|
|
151
|
-
console.log('Examples:');
|
|
152
|
-
console.log(' claude-flow config set terminal.poolSize 15');
|
|
153
|
-
console.log(' claude-flow config set orchestrator.taskTimeout 600000');
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
let config = await readJsonFile(configFile, {});
|
|
158
|
-
let parsedValue = value;
|
|
159
|
-
if (value === 'true') parsedValue = true;
|
|
160
|
-
else if (value === 'false') parsedValue = false;
|
|
161
|
-
else if (!isNaN(value) && value.trim() !== '') parsedValue = Number(value);
|
|
162
|
-
setNestedValue(config, key, parsedValue);
|
|
163
|
-
await writeJsonFile(configFile, config);
|
|
164
|
-
printSuccess(`Set ${key} = ${JSON.stringify(parsedValue)}`);
|
|
165
|
-
} catch (err) {
|
|
166
|
-
printError(`Failed to set configuration: ${err.message}`);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
async function validateConfig(subArgs, flags) {
|
|
170
|
-
const configFile = 'claude-flow.config.json';
|
|
171
|
-
try {
|
|
172
|
-
const config = await readJsonFile(configFile);
|
|
173
|
-
printSuccess('Validating configuration...');
|
|
174
|
-
const errors = [];
|
|
175
|
-
const warnings = [];
|
|
176
|
-
const requiredSections = [
|
|
177
|
-
'terminal',
|
|
178
|
-
'orchestrator',
|
|
179
|
-
'memory'
|
|
180
|
-
];
|
|
181
|
-
for (const section of requiredSections){
|
|
182
|
-
if (!config[section]) {
|
|
183
|
-
errors.push(`Missing required section: ${section}`);
|
|
17
|
+
console.log(chalk.green(`ā Default provider set to: ${provider}`));
|
|
18
|
+
if (options.model) {
|
|
19
|
+
console.log(chalk.green(`ā Default model set to: ${options.model}`));
|
|
184
20
|
}
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error(chalk.red('ā Error:'), error.message);
|
|
23
|
+
process.exit(1);
|
|
185
24
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
25
|
+
});
|
|
26
|
+
config.command('list-providers').alias('list').description('List configured providers').option('-f, --format <format>', 'Output format (text, json)', 'text').action(async (options)=>{
|
|
27
|
+
try {
|
|
28
|
+
const manager = new ProviderManager();
|
|
29
|
+
const providers = manager.listProviders();
|
|
30
|
+
const defaultProvider = manager.getDefaultProvider();
|
|
31
|
+
if (options.format === 'json') {
|
|
32
|
+
console.log(JSON.stringify({
|
|
33
|
+
defaultProvider,
|
|
34
|
+
providers
|
|
35
|
+
}, null, 2));
|
|
36
|
+
} else {
|
|
37
|
+
console.log(chalk.cyan('\nš Configured Providers:\n'));
|
|
38
|
+
console.log(chalk.white(`Default: ${chalk.bold(defaultProvider)}\n`));
|
|
39
|
+
providers.forEach((provider)=>{
|
|
40
|
+
const isDefault = provider.name === defaultProvider;
|
|
41
|
+
const prefix = isDefault ? chalk.green('ā') : chalk.gray('ā');
|
|
42
|
+
const status = provider.enabled ? chalk.green('enabled') : chalk.gray('disabled');
|
|
43
|
+
console.log(`${prefix} ${chalk.bold(provider.name)}`);
|
|
44
|
+
console.log(` Model: ${provider.model || 'default'}`);
|
|
45
|
+
console.log(` Priority: ${provider.priority || 'balanced'}`);
|
|
46
|
+
console.log(` Status: ${status}`);
|
|
47
|
+
console.log('');
|
|
48
|
+
});
|
|
205
49
|
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(chalk.red('ā Error:'), error.message);
|
|
52
|
+
process.exit(1);
|
|
206
53
|
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
54
|
+
});
|
|
55
|
+
config.command('wizard').description('Interactive provider configuration wizard').action(async ()=>{
|
|
56
|
+
try {
|
|
57
|
+
const manager = new ProviderManager();
|
|
58
|
+
console.log(chalk.cyan('\nš§ Provider Configuration Wizard\n'));
|
|
59
|
+
const answers = await inquirer.prompt([
|
|
60
|
+
{
|
|
61
|
+
type: 'list',
|
|
62
|
+
name: 'defaultProvider',
|
|
63
|
+
message: 'Select default provider:',
|
|
64
|
+
choices: [
|
|
65
|
+
{
|
|
66
|
+
name: 'Anthropic (Highest quality)',
|
|
67
|
+
value: 'anthropic'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'OpenRouter (99% cost savings)',
|
|
71
|
+
value: 'openrouter'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'ONNX (Free local inference)',
|
|
75
|
+
value: 'onnx'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'Gemini (Free tier)',
|
|
79
|
+
value: 'gemini'
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: 'list',
|
|
85
|
+
name: 'optimization',
|
|
86
|
+
message: 'Optimization priority:',
|
|
87
|
+
choices: [
|
|
88
|
+
{
|
|
89
|
+
name: 'Balanced (recommended)',
|
|
90
|
+
value: 'balanced'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'Cost (cheapest)',
|
|
94
|
+
value: 'cost'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'Quality (best results)',
|
|
98
|
+
value: 'quality'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'Speed (fastest)',
|
|
102
|
+
value: 'speed'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'Privacy (local only)',
|
|
106
|
+
value: 'privacy'
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
]);
|
|
111
|
+
await manager.setDefaultProvider(answers.defaultProvider);
|
|
112
|
+
console.log(chalk.green('\nā Configuration saved successfully!'));
|
|
113
|
+
console.log(chalk.gray(`\nDefault provider: ${answers.defaultProvider}`));
|
|
114
|
+
console.log(chalk.gray(`Optimization: ${answers.optimization}`));
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error(chalk.red('\nā Error:'), error.message);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return config;
|
|
263
121
|
}
|
|
264
122
|
|
|
265
123
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/simple-commands/config.js"],"sourcesContent":["// config.js - Configuration management commands\nimport {\n printSuccess,\n printError,\n printWarning,\n readJsonFile,\n writeJsonFile,\n fileExists,\n} from '../utils.js';\n\nexport async function configCommand(subArgs, flags) {\n const configCmd = subArgs[0];\n\n switch (configCmd) {\n case 'init':\n await initConfig(subArgs, flags);\n break;\n\n case 'show':\n await showConfig(subArgs, flags);\n break;\n\n case 'get':\n await getConfigValue(subArgs, flags);\n break;\n\n case 'set':\n await setConfigValue(subArgs, flags);\n break;\n\n case 'validate':\n await validateConfig(subArgs, flags);\n break;\n\n case 'reset':\n await resetConfig(subArgs, flags);\n break;\n\n default:\n showConfigHelp();\n }\n}\n\nasync function initConfig(subArgs, flags) {\n const force = subArgs.includes('--force') || subArgs.includes('-f');\n const configFile = 'claude-flow.config.json';\n\n try {\n // Check if config already exists\n const exists = await fileExists(configFile);\n if (exists && !force) {\n printWarning('Configuration file already exists');\n console.log('Use --force to overwrite existing configuration');\n return;\n }\n\n printSuccess('Initializing Claude-Flow configuration...');\n\n // Create default configuration\n const defaultConfig = {\n version: '1.0.71',\n terminal: {\n poolSize: 10,\n recycleAfter: 20,\n healthCheckInterval: 30000,\n type: 'auto',\n },\n orchestrator: {\n maxConcurrentTasks: 10,\n taskTimeout: 300000,\n defaultPriority: 5,\n },\n memory: {\n backend: 'json',\n path: './memory/claude-flow-data.json',\n cacheSize: 1000,\n indexing: true,\n },\n agents: {\n maxAgents: 20,\n defaultCapabilities: ['research', 'code', 'terminal'],\n resourceLimits: {\n memory: '1GB',\n cpu: '50%',\n },\n },\n mcp: {\n port: 3000,\n host: 'localhost',\n timeout: 30000,\n },\n logging: {\n level: 'info',\n file: './claude-flow.log',\n maxSize: '10MB',\n maxFiles: 5,\n },\n };\n\n await writeJsonFile(configFile, defaultConfig);\n console.log(`ā Created ${configFile}`);\n console.log('ā Default settings configured');\n console.log('\\nNext steps:');\n console.log('1. Review settings: claude-flow config show');\n console.log('2. Customize values: claude-flow config set <key> <value>');\n console.log('3. Validate config: claude-flow config validate');\n } catch (err) {\n printError(`Failed to initialize configuration: ${err.message}`);\n }\n}\n\nasync function showConfig(subArgs, flags) {\n const configFile = 'claude-flow.config.json';\n const format = getFlag(subArgs, '--format') || 'pretty';\n\n try {\n const config = await readJsonFile(configFile);\n\n printSuccess('Current configuration:');\n\n if (format === 'json') {\n console.log(JSON.stringify(config, null, 2));\n } else {\n // Pretty format\n console.log('\\nš System Configuration:');\n console.log(` Version: ${config.version || 'unknown'}`);\n console.log('\\nš„ļø Terminal Pool:');\n console.log(` Pool Size: ${config.terminal?.poolSize || 10}`);\n console.log(` Recycle After: ${config.terminal?.recycleAfter || 20} commands`);\n console.log(` Health Check: ${config.terminal?.healthCheckInterval || 30000}ms`);\n console.log('\\nš Orchestrator:');\n console.log(` Max Concurrent Tasks: ${config.orchestrator?.maxConcurrentTasks || 10}`);\n console.log(` Task Timeout: ${config.orchestrator?.taskTimeout || 300000}ms`);\n console.log('\\nš¾ Memory:');\n console.log(` Backend: ${config.memory?.backend || 'json'}`);\n console.log(` Path: ${config.memory?.path || './memory/claude-flow-data.json'}`);\n console.log('\\nš¤ Agents:');\n console.log(` Max Agents: ${config.agents?.maxAgents || 20}`);\n console.log(` Resource Limits: ${JSON.stringify(config.agents?.resourceLimits || {})}`);\n }\n } catch (err) {\n printError('Configuration file not found');\n console.log('Run \"claude-flow config init\" to create default configuration');\n }\n}\n\nasync function getConfigValue(subArgs, flags) {\n const key = subArgs[1];\n const configFile = 'claude-flow.config.json';\n\n if (!key) {\n printError('Usage: config get <key>');\n console.log('Examples:');\n console.log(' claude-flow config get terminal.poolSize');\n console.log(' claude-flow config get orchestrator.maxConcurrentTasks');\n return;\n }\n\n try {\n const config = await readJsonFile(configFile);\n const value = getNestedValue(config, key);\n\n if (value !== undefined) {\n console.log(`${key}: ${JSON.stringify(value)}`);\n } else {\n printWarning(`Configuration key '${key}' not found`);\n }\n } catch (err) {\n printError('Configuration file not found');\n console.log('Run \"claude-flow config init\" to create configuration');\n }\n}\n\nasync function setConfigValue(subArgs, flags) {\n const key = subArgs[1];\n const value = subArgs[2];\n const configFile = 'claude-flow.config.json';\n\n if (!key || value === undefined) {\n printError('Usage: config set <key> <value>');\n console.log('Examples:');\n console.log(' claude-flow config set terminal.poolSize 15');\n console.log(' claude-flow config set orchestrator.taskTimeout 600000');\n return;\n }\n\n try {\n let config = await readJsonFile(configFile, {});\n\n // Parse value appropriately\n let parsedValue = value;\n if (value === 'true') parsedValue = true;\n else if (value === 'false') parsedValue = false;\n else if (!isNaN(value) && value.trim() !== '') parsedValue = Number(value);\n\n // Set nested value\n setNestedValue(config, key, parsedValue);\n\n await writeJsonFile(configFile, config);\n printSuccess(`Set ${key} = ${JSON.stringify(parsedValue)}`);\n } catch (err) {\n printError(`Failed to set configuration: ${err.message}`);\n }\n}\n\nasync function validateConfig(subArgs, flags) {\n const configFile = 'claude-flow.config.json';\n\n try {\n const config = await readJsonFile(configFile);\n\n printSuccess('Validating configuration...');\n\n const errors = [];\n const warnings = [];\n\n // Validate required sections\n const requiredSections = ['terminal', 'orchestrator', 'memory'];\n for (const section of requiredSections) {\n if (!config[section]) {\n errors.push(`Missing required section: ${section}`);\n }\n }\n\n // Validate specific values\n if (\n config.terminal?.poolSize &&\n (config.terminal.poolSize < 1 || config.terminal.poolSize > 100)\n ) {\n warnings.push('Terminal pool size should be between 1 and 100');\n }\n\n if (config.orchestrator?.maxConcurrentTasks && config.orchestrator.maxConcurrentTasks < 1) {\n errors.push('Max concurrent tasks must be at least 1');\n }\n\n if (config.agents?.maxAgents && config.agents.maxAgents < 1) {\n errors.push('Max agents must be at least 1');\n }\n\n // Report results\n if (errors.length === 0 && warnings.length === 0) {\n printSuccess('ā
Configuration is valid');\n } else {\n if (errors.length > 0) {\n printError(`Found ${errors.length} error(s):`);\n errors.forEach((error) => console.log(` ā ${error}`));\n }\n\n if (warnings.length > 0) {\n printWarning(`Found ${warnings.length} warning(s):`);\n warnings.forEach((warning) => console.log(` ā ļø ${warning}`));\n }\n }\n } catch (err) {\n printError('Configuration file not found or invalid');\n console.log('Run \"claude-flow config init\" to create valid configuration');\n }\n}\n\nasync function resetConfig(subArgs, flags) {\n const force = subArgs.includes('--force') || subArgs.includes('-f');\n\n if (!force) {\n printWarning('This will reset configuration to defaults');\n console.log('Use --force to confirm reset');\n return;\n }\n\n await initConfig(['--force'], flags);\n printSuccess('Configuration reset to defaults');\n}\n\n// Helper functions\nfunction getNestedValue(obj, path) {\n return path.split('.').reduce((current, key) => current?.[key], obj);\n}\n\nfunction setNestedValue(obj, path, value) {\n const keys = path.split('.');\n const last = keys.pop();\n const target = keys.reduce((current, key) => {\n if (!current[key]) current[key] = {};\n return current[key];\n }, obj);\n target[last] = value;\n}\n\nfunction getFlag(args, flagName) {\n const index = args.indexOf(flagName);\n return index !== -1 && index + 1 < args.length ? args[index + 1] : null;\n}\n\n// fileExists is now imported from utils.js\n\nfunction showConfigHelp() {\n console.log('Configuration commands:');\n console.log(' init [--force] Create default configuration');\n console.log(' show [--format json] Display current configuration');\n console.log(' get <key> Get configuration value');\n console.log(' set <key> <value> Set configuration value');\n console.log(' validate Validate configuration');\n console.log(' reset --force Reset to defaults');\n console.log();\n console.log('Configuration Keys:');\n console.log(' terminal.poolSize Terminal pool size');\n console.log(' terminal.recycleAfter Commands before recycle');\n console.log(' orchestrator.maxConcurrentTasks Max parallel tasks');\n console.log(' orchestrator.taskTimeout Task timeout in ms');\n console.log(' memory.backend Memory storage backend');\n console.log(' memory.path Memory database path');\n console.log(' agents.maxAgents Maximum number of agents');\n console.log();\n console.log('Examples:');\n console.log(' claude-flow config init');\n console.log(' claude-flow config set terminal.poolSize 15');\n console.log(' claude-flow config get orchestrator.maxConcurrentTasks');\n console.log(' claude-flow config validate');\n}\n"],"names":["printSuccess","printError","printWarning","readJsonFile","writeJsonFile","fileExists","configCommand","subArgs","flags","configCmd","initConfig","showConfig","getConfigValue","setConfigValue","validateConfig","resetConfig","showConfigHelp","force","includes","configFile","exists","console","log","defaultConfig","version","terminal","poolSize","recycleAfter","healthCheckInterval","type","orchestrator","maxConcurrentTasks","taskTimeout","defaultPriority","memory","backend","path","cacheSize","indexing","agents","maxAgents","defaultCapabilities","resourceLimits","cpu","mcp","port","host","timeout","logging","level","file","maxSize","maxFiles","err","message","format","getFlag","config","JSON","stringify","key","value","getNestedValue","undefined","parsedValue","isNaN","trim","Number","setNestedValue","errors","warnings","requiredSections","section","push","length","forEach","error","warning","obj","split","reduce","current","keys","last","pop","target","args","flagName","index","indexOf"],"mappings":"AACA,SACEA,YAAY,EACZC,UA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,IAAI,EAAEqB,OAAO,CAACrB,IAAI,GAAG,CAAC;QACnC,OAAOqB,OAAO,CAACrB,IAAI;IACrB,GAAGkB;IACHO,MAAM,CAACF,KAAK,GAAGtB;AACjB;AAEA,SAASL,QAAQ8B,IAAI,EAAEC,QAAQ;IAC7B,MAAMC,QAAQF,KAAKG,OAAO,CAACF;IAC3B,OAAOC,UAAU,CAAC,KAAKA,QAAQ,IAAIF,KAAKZ,MAAM,GAAGY,IAAI,CAACE,QAAQ,EAAE,GAAG;AACrE;AAIA,SAASxE;IACPK,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,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;IACZD,QAAQC,GAAG,CAAC;AACd"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/simple-commands/config.ts"],"sourcesContent":["/**\n * Config CLI Commands - Manage provider configuration\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\nimport { ProviderManager } from '../../execution/provider-manager.js';\n\nexport function createConfigCommand(): Command {\n const config = new Command('config')\n .description('Manage provider configuration');\n\n // config set-provider command\n config\n .command('set-provider')\n .description('Set default provider')\n .argument('<provider>', 'Provider name (anthropic, openrouter, onnx, gemini)')\n .option('-m, --model <model>', 'Default model for provider')\n .action(async (provider, options) => {\n try {\n const manager = new ProviderManager();\n\n await manager.setDefaultProvider(provider);\n\n if (options.model) {\n await manager.configureProvider(provider, {\n model: options.model,\n enabled: true,\n } as any);\n }\n\n console.log(chalk.green(`ā Default provider set to: ${provider}`));\n if (options.model) {\n console.log(chalk.green(`ā Default model set to: ${options.model}`));\n }\n } catch (error: any) {\n console.error(chalk.red('ā Error:'), error.message);\n process.exit(1);\n }\n });\n\n // config list-providers command\n config\n .command('list-providers')\n .alias('list')\n .description('List configured providers')\n .option('-f, --format <format>', 'Output format (text, json)', 'text')\n .action(async (options) => {\n try {\n const manager = new ProviderManager();\n const providers = manager.listProviders();\n const defaultProvider = manager.getDefaultProvider();\n\n if (options.format === 'json') {\n console.log(JSON.stringify({ defaultProvider, providers }, null, 2));\n } else {\n console.log(chalk.cyan('\\nš Configured Providers:\\n'));\n console.log(chalk.white(`Default: ${chalk.bold(defaultProvider)}\\n`));\n\n providers.forEach(provider => {\n const isDefault = provider.name === defaultProvider;\n const prefix = isDefault ? chalk.green('ā') : chalk.gray('ā');\n const status = provider.enabled ? chalk.green('enabled') : chalk.gray('disabled');\n\n console.log(`${prefix} ${chalk.bold(provider.name)}`);\n console.log(` Model: ${provider.model || 'default'}`);\n console.log(` Priority: ${provider.priority || 'balanced'}`);\n console.log(` Status: ${status}`);\n console.log('');\n });\n }\n } catch (error: any) {\n console.error(chalk.red('ā Error:'), error.message);\n process.exit(1);\n }\n });\n\n // config wizard command\n config\n .command('wizard')\n .description('Interactive provider configuration wizard')\n .action(async () => {\n try {\n const manager = new ProviderManager();\n\n console.log(chalk.cyan('\\nš§ Provider Configuration Wizard\\n'));\n\n const answers = await inquirer.prompt([\n {\n type: 'list',\n name: 'defaultProvider',\n message: 'Select default provider:',\n choices: [\n { name: 'Anthropic (Highest quality)', value: 'anthropic' },\n { name: 'OpenRouter (99% cost savings)', value: 'openrouter' },\n { name: 'ONNX (Free local inference)', value: 'onnx' },\n { name: 'Gemini (Free tier)', value: 'gemini' },\n ],\n },\n {\n type: 'list',\n name: 'optimization',\n message: 'Optimization priority:',\n choices: [\n { name: 'Balanced (recommended)', value: 'balanced' },\n { name: 'Cost (cheapest)', value: 'cost' },\n { name: 'Quality (best results)', value: 'quality' },\n { name: 'Speed (fastest)', value: 'speed' },\n { name: 'Privacy (local only)', value: 'privacy' },\n ],\n },\n ]);\n\n await manager.setDefaultProvider(answers.defaultProvider);\n\n console.log(chalk.green('\\nā Configuration saved successfully!'));\n console.log(chalk.gray(`\\nDefault provider: ${answers.defaultProvider}`));\n console.log(chalk.gray(`Optimization: ${answers.optimization}`));\n } catch (error: any) {\n console.error(chalk.red('\\nā Error:'), error.message);\n process.exit(1);\n }\n });\n\n return config;\n}\n"],"names":["Command","chalk","inquirer","ProviderManager","createConfigCommand","config","description","command","argument","option","action","provider","options","manager","setDefaultProvider","model","configureProvider","enabled","console","log","green","error","red","message","process","exit","alias","providers","listProviders","defaultProvider","getDefaultProvider","format","JSON","stringify","cyan","white","bold","forEach","isDefault","name","prefix","gray","status","priority","answers","prompt","type","choices","value","optimization"],"mappings":"AAIA,SAASA,OAAO,QAAQ,YAAY;AACpC,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,cAAc,WAAW;AAChC,SAASC,eAAe,QAAQ,sCAAsC;AAEtE,OAAO,SAASC;IACd,MAAMC,SAAS,IAAIL,QAAQ,UACxBM,WAAW,CAAC;IAGfD,OACGE,OAAO,CAAC,gBACRD,WAAW,CAAC,wBACZE,QAAQ,CAAC,cAAc,uDACvBC,MAAM,CAAC,uBAAuB,8BAC9BC,MAAM,CAAC,OAAOC,UAAUC;QACvB,IAAI;YACF,MAAMC,UAAU,IAAIV;YAEpB,MAAMU,QAAQC,kBAAkB,CAACH;YAEjC,IAAIC,QAAQG,KAAK,EAAE;gBACjB,MAAMF,QAAQG,iBAAiB,CAACL,UAAU;oBACxCI,OAAOH,QAAQG,KAAK;oBACpBE,SAAS;gBACX;YACF;YAEAC,QAAQC,GAAG,CAAClB,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AC,oBAAoB,EAAEG,QAAQf,eAAe,EAAE;YACvEX,QAAQC,GAAG,CAAClB,MAAMwC,IAAI,CAAC,CAAC,cAAc,EAAEG,QAAQK,YAAY,EAAE;QAChE,EAAE,OAAO5B,OAAY;YACnBH,QAAQG,KAAK,CAACpB,MAAMqB,GAAG,CAAC,eAAeD,MAAME,OAAO;YACpDC,QAAQC,IAAI,CAAC;QACf;IACF;IAEF,OAAOpB;AACT"}
|
|
@@ -328,6 +328,7 @@ async function isReasoningBankInitialized() {
|
|
|
328
328
|
}
|
|
329
329
|
async function handleReasoningBankCommand(command, subArgs, flags) {
|
|
330
330
|
const initialized = await isReasoningBankInitialized();
|
|
331
|
+
const { initializeReasoningBank, storeMemory, queryMemories, listMemories, getStatus } = await import('../../reasoningbank/reasoningbank-adapter.js');
|
|
331
332
|
if (command === 'init') {
|
|
332
333
|
if (initialized) {
|
|
333
334
|
printWarning('ā ļø ReasoningBank already initialized');
|
|
@@ -338,10 +339,7 @@ async function handleReasoningBankCommand(command, subArgs, flags) {
|
|
|
338
339
|
printInfo('š§ Initializing ReasoningBank...');
|
|
339
340
|
console.log('This will create: .swarm/memory.db\n');
|
|
340
341
|
try {
|
|
341
|
-
|
|
342
|
-
timeout: 30000
|
|
343
|
-
});
|
|
344
|
-
if (stdout) console.log(stdout);
|
|
342
|
+
await initializeReasoningBank();
|
|
345
343
|
printSuccess('ā
ReasoningBank initialized successfully!');
|
|
346
344
|
console.log('\nNext steps:');
|
|
347
345
|
console.log(' 1. Store memories: memory store key "value" --reasoningbank');
|
|
@@ -350,9 +348,6 @@ async function handleReasoningBankCommand(command, subArgs, flags) {
|
|
|
350
348
|
} catch (error) {
|
|
351
349
|
printError('ā Failed to initialize ReasoningBank');
|
|
352
350
|
console.error(error.message);
|
|
353
|
-
if (error.stderr) {
|
|
354
|
-
console.error('Details:', error.stderr);
|
|
355
|
-
}
|
|
356
351
|
}
|
|
357
352
|
return;
|
|
358
353
|
}
|
|
@@ -364,17 +359,128 @@ async function handleReasoningBankCommand(command, subArgs, flags) {
|
|
|
364
359
|
}
|
|
365
360
|
printInfo(`š§ Using ReasoningBank mode...`);
|
|
366
361
|
try {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
362
|
+
switch(command){
|
|
363
|
+
case 'store':
|
|
364
|
+
await handleReasoningBankStore(subArgs, flags, storeMemory);
|
|
365
|
+
break;
|
|
366
|
+
case 'query':
|
|
367
|
+
await handleReasoningBankQuery(subArgs, flags, queryMemories);
|
|
368
|
+
break;
|
|
369
|
+
case 'list':
|
|
370
|
+
await handleReasoningBankList(subArgs, flags, listMemories);
|
|
371
|
+
break;
|
|
372
|
+
case 'status':
|
|
373
|
+
await handleReasoningBankStatus(getStatus);
|
|
374
|
+
break;
|
|
375
|
+
case 'consolidate':
|
|
376
|
+
case 'demo':
|
|
377
|
+
case 'test':
|
|
378
|
+
case 'benchmark':
|
|
379
|
+
const cmd = `npx agentic-flow reasoningbank ${command}`;
|
|
380
|
+
const { stdout } = await execAsync(cmd, {
|
|
381
|
+
timeout: 60000
|
|
382
|
+
});
|
|
383
|
+
if (stdout) console.log(stdout);
|
|
384
|
+
break;
|
|
385
|
+
default:
|
|
386
|
+
printError(`Unknown ReasoningBank command: ${command}`);
|
|
387
|
+
}
|
|
373
388
|
} catch (error) {
|
|
374
389
|
printError(`ā ReasoningBank command failed`);
|
|
375
390
|
console.error(error.message);
|
|
376
391
|
}
|
|
377
392
|
}
|
|
393
|
+
async function handleReasoningBankStore(subArgs, flags, storeMemory) {
|
|
394
|
+
const key = subArgs[1];
|
|
395
|
+
const value = subArgs.slice(2).join(' ');
|
|
396
|
+
if (!key || !value) {
|
|
397
|
+
printError('Usage: memory store <key> <value> --reasoningbank');
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
try {
|
|
401
|
+
const namespace = flags?.namespace || flags?.ns || getArgValue(subArgs, '--namespace') || 'default';
|
|
402
|
+
const memoryId = await storeMemory(key, value, {
|
|
403
|
+
namespace,
|
|
404
|
+
agent: 'memory-agent',
|
|
405
|
+
domain: namespace
|
|
406
|
+
});
|
|
407
|
+
printSuccess('ā
Stored successfully in ReasoningBank');
|
|
408
|
+
console.log(`š Key: ${key}`);
|
|
409
|
+
console.log(`š§ Memory ID: ${memoryId}`);
|
|
410
|
+
console.log(`š¦ Namespace: ${namespace}`);
|
|
411
|
+
console.log(`š¾ Size: ${new TextEncoder().encode(value).length} bytes`);
|
|
412
|
+
console.log(`š Semantic search: enabled`);
|
|
413
|
+
} catch (error) {
|
|
414
|
+
printError(`Failed to store: ${error.message}`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
async function handleReasoningBankQuery(subArgs, flags, queryMemories) {
|
|
418
|
+
const search = subArgs.slice(1).join(' ');
|
|
419
|
+
if (!search) {
|
|
420
|
+
printError('Usage: memory query <search> --reasoningbank');
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
try {
|
|
424
|
+
const namespace = flags?.namespace || flags?.ns || getArgValue(subArgs, '--namespace');
|
|
425
|
+
const results = await queryMemories(search, {
|
|
426
|
+
domain: namespace || 'general',
|
|
427
|
+
limit: 10
|
|
428
|
+
});
|
|
429
|
+
if (results.length === 0) {
|
|
430
|
+
printWarning('No results found');
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
printSuccess(`Found ${results.length} results (semantic search):`);
|
|
434
|
+
for (const entry of results){
|
|
435
|
+
console.log(`\nš ${entry.key}`);
|
|
436
|
+
console.log(` Namespace: ${entry.namespace}`);
|
|
437
|
+
console.log(` Value: ${entry.value.substring(0, 100)}${entry.value.length > 100 ? '...' : ''}`);
|
|
438
|
+
console.log(` Confidence: ${(entry.confidence * 100).toFixed(1)}%`);
|
|
439
|
+
console.log(` Usage: ${entry.usage_count} times`);
|
|
440
|
+
if (entry.score) {
|
|
441
|
+
console.log(` Match Score: ${(entry.score * 100).toFixed(1)}%`);
|
|
442
|
+
}
|
|
443
|
+
console.log(` Stored: ${new Date(entry.created_at).toLocaleString()}`);
|
|
444
|
+
}
|
|
445
|
+
} catch (error) {
|
|
446
|
+
printError(`Failed to query: ${error.message}`);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
async function handleReasoningBankList(subArgs, flags, listMemories) {
|
|
450
|
+
try {
|
|
451
|
+
const sort = flags?.sort || getArgValue(subArgs, '--sort') || 'created_at';
|
|
452
|
+
const limit = parseInt(flags?.limit || getArgValue(subArgs, '--limit') || '10');
|
|
453
|
+
const results = await listMemories({
|
|
454
|
+
sort,
|
|
455
|
+
limit
|
|
456
|
+
});
|
|
457
|
+
if (results.length === 0) {
|
|
458
|
+
printWarning('No memories found');
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
printSuccess(`ReasoningBank memories (${results.length} shown):`);
|
|
462
|
+
for (const entry of results){
|
|
463
|
+
console.log(`\nš ${entry.key}`);
|
|
464
|
+
console.log(` Value: ${entry.value.substring(0, 80)}${entry.value.length > 80 ? '...' : ''}`);
|
|
465
|
+
console.log(` Confidence: ${(entry.confidence * 100).toFixed(1)}% | Usage: ${entry.usage_count}`);
|
|
466
|
+
}
|
|
467
|
+
} catch (error) {
|
|
468
|
+
printError(`Failed to list: ${error.message}`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
async function handleReasoningBankStatus(getStatus) {
|
|
472
|
+
try {
|
|
473
|
+
const stats = await getStatus();
|
|
474
|
+
printSuccess('š ReasoningBank Status:');
|
|
475
|
+
console.log(` Total memories: ${stats.total_memories}`);
|
|
476
|
+
console.log(` Average confidence: ${(stats.avg_confidence * 100).toFixed(1)}%`);
|
|
477
|
+
console.log(` Total usage: ${stats.total_usage}`);
|
|
478
|
+
console.log(` Embeddings: ${stats.total_embeddings}`);
|
|
479
|
+
console.log(` Trajectories: ${stats.total_trajectories}`);
|
|
480
|
+
} catch (error) {
|
|
481
|
+
printError(`Failed to get status: ${error.message}`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
378
484
|
function buildReasoningBankCommand(command, subArgs, flags) {
|
|
379
485
|
const parts = [
|
|
380
486
|
'npx',
|
|
@@ -398,6 +504,7 @@ function buildReasoningBankCommand(command, subArgs, flags) {
|
|
|
398
504
|
parts.push(`"${arg}"`);
|
|
399
505
|
}
|
|
400
506
|
});
|
|
507
|
+
parts.push('--agent', 'memory-agent');
|
|
401
508
|
return parts.join(' ');
|
|
402
509
|
}
|
|
403
510
|
async function handleModeCommand(command, subArgs, flags) {
|