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
|
@@ -3,14 +3,25 @@ import { printSuccess, printError, printWarning, printInfo } from '../utils.js';
|
|
|
3
3
|
import { promises as fs } from 'fs';
|
|
4
4
|
import { cwd, exit, existsSync } from '../node-compat.js';
|
|
5
5
|
import { getUnifiedMemory } from '../../memory/unified-memory-manager.js';
|
|
6
|
+
import { KeyRedactor } from '../../utils/key-redactor.js';
|
|
7
|
+
import { exec } from 'child_process';
|
|
8
|
+
import { promisify } from 'util';
|
|
9
|
+
|
|
10
|
+
const execAsync = promisify(exec);
|
|
6
11
|
|
|
7
12
|
export async function memoryCommand(subArgs, flags) {
|
|
8
13
|
const memorySubcommand = subArgs[0];
|
|
9
14
|
const memoryStore = './memory/memory-store.json';
|
|
10
|
-
|
|
15
|
+
|
|
11
16
|
// Extract namespace from flags or subArgs
|
|
12
17
|
const namespace = flags?.namespace || flags?.ns || getNamespaceFromArgs(subArgs) || 'default';
|
|
13
18
|
|
|
19
|
+
// Check for redaction flag
|
|
20
|
+
const enableRedaction = flags?.redact || subArgs.includes('--redact') || subArgs.includes('--secure');
|
|
21
|
+
|
|
22
|
+
// NEW: Detect memory mode (basic, reasoningbank, auto)
|
|
23
|
+
const mode = await detectMemoryMode(flags, subArgs);
|
|
24
|
+
|
|
14
25
|
// Helper to load memory data
|
|
15
26
|
async function loadMemory() {
|
|
16
27
|
try {
|
|
@@ -27,13 +38,28 @@ export async function memoryCommand(subArgs, flags) {
|
|
|
27
38
|
await fs.writeFile(memoryStore, JSON.stringify(data, null, 2, 'utf8'));
|
|
28
39
|
}
|
|
29
40
|
|
|
41
|
+
// NEW: Handle ReasoningBank-specific commands
|
|
42
|
+
if (mode === 'reasoningbank' && ['init', 'status', 'consolidate', 'demo', 'test', 'benchmark'].includes(memorySubcommand)) {
|
|
43
|
+
return await handleReasoningBankCommand(memorySubcommand, subArgs, flags);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// NEW: Handle new mode management commands
|
|
47
|
+
if (['detect', 'mode', 'migrate'].includes(memorySubcommand)) {
|
|
48
|
+
return await handleModeCommand(memorySubcommand, subArgs, flags);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// NEW: Delegate to ReasoningBank for regular commands if mode is set
|
|
52
|
+
if (mode === 'reasoningbank' && ['store', 'query', 'list'].includes(memorySubcommand)) {
|
|
53
|
+
return await handleReasoningBankCommand(memorySubcommand, subArgs, flags);
|
|
54
|
+
}
|
|
55
|
+
|
|
30
56
|
switch (memorySubcommand) {
|
|
31
57
|
case 'store':
|
|
32
|
-
await storeMemory(subArgs, loadMemory, saveMemory, namespace);
|
|
58
|
+
await storeMemory(subArgs, loadMemory, saveMemory, namespace, enableRedaction);
|
|
33
59
|
break;
|
|
34
60
|
|
|
35
61
|
case 'query':
|
|
36
|
-
await queryMemory(subArgs, loadMemory, namespace);
|
|
62
|
+
await queryMemory(subArgs, loadMemory, namespace, enableRedaction);
|
|
37
63
|
break;
|
|
38
64
|
|
|
39
65
|
case 'stats':
|
|
@@ -61,16 +87,39 @@ export async function memoryCommand(subArgs, flags) {
|
|
|
61
87
|
}
|
|
62
88
|
}
|
|
63
89
|
|
|
64
|
-
async function storeMemory(subArgs, loadMemory, saveMemory, namespace) {
|
|
90
|
+
async function storeMemory(subArgs, loadMemory, saveMemory, namespace, enableRedaction = false) {
|
|
65
91
|
const key = subArgs[1];
|
|
66
|
-
|
|
92
|
+
let value = subArgs.slice(2).join(' ');
|
|
67
93
|
|
|
68
94
|
if (!key || !value) {
|
|
69
|
-
printError('Usage: memory store <key> <value> [--namespace <ns>]');
|
|
95
|
+
printError('Usage: memory store <key> <value> [--namespace <ns>] [--redact]');
|
|
70
96
|
return;
|
|
71
97
|
}
|
|
72
98
|
|
|
73
99
|
try {
|
|
100
|
+
// Apply redaction if enabled
|
|
101
|
+
let redactedValue = value;
|
|
102
|
+
let securityWarnings = [];
|
|
103
|
+
|
|
104
|
+
if (enableRedaction) {
|
|
105
|
+
redactedValue = KeyRedactor.redact(value, true);
|
|
106
|
+
const validation = KeyRedactor.validate(value);
|
|
107
|
+
|
|
108
|
+
if (!validation.safe) {
|
|
109
|
+
securityWarnings = validation.warnings;
|
|
110
|
+
printWarning('🔒 Redaction enabled: Sensitive data detected and redacted');
|
|
111
|
+
securityWarnings.forEach(warning => console.log(` ⚠️ ${warning}`));
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
// Even if redaction is not explicitly enabled, validate and warn
|
|
115
|
+
const validation = KeyRedactor.validate(value);
|
|
116
|
+
if (!validation.safe) {
|
|
117
|
+
printWarning('⚠️ Potential sensitive data detected! Use --redact flag for automatic redaction');
|
|
118
|
+
validation.warnings.forEach(warning => console.log(` ⚠️ ${warning}`));
|
|
119
|
+
console.log(' 💡 Tip: Add --redact flag to automatically redact API keys');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
74
123
|
const data = await loadMemory();
|
|
75
124
|
|
|
76
125
|
if (!data[namespace]) {
|
|
@@ -80,29 +129,33 @@ async function storeMemory(subArgs, loadMemory, saveMemory, namespace) {
|
|
|
80
129
|
// Remove existing entry with same key
|
|
81
130
|
data[namespace] = data[namespace].filter((e) => e.key !== key);
|
|
82
131
|
|
|
83
|
-
// Add new entry
|
|
132
|
+
// Add new entry with redacted value
|
|
84
133
|
data[namespace].push({
|
|
85
134
|
key,
|
|
86
|
-
value,
|
|
135
|
+
value: redactedValue,
|
|
87
136
|
namespace,
|
|
88
137
|
timestamp: Date.now(),
|
|
138
|
+
redacted: enableRedaction && securityWarnings.length > 0,
|
|
89
139
|
});
|
|
90
140
|
|
|
91
141
|
await saveMemory(data);
|
|
92
|
-
printSuccess('Stored successfully');
|
|
142
|
+
printSuccess(enableRedaction && securityWarnings.length > 0 ? '🔒 Stored successfully (with redaction)' : '✅ Stored successfully');
|
|
93
143
|
console.log(`📝 Key: ${key}`);
|
|
94
144
|
console.log(`📦 Namespace: ${namespace}`);
|
|
95
|
-
console.log(`💾 Size: ${new TextEncoder().encode(
|
|
145
|
+
console.log(`💾 Size: ${new TextEncoder().encode(redactedValue).length} bytes`);
|
|
146
|
+
if (enableRedaction && securityWarnings.length > 0) {
|
|
147
|
+
console.log(`🔒 Security: ${securityWarnings.length} sensitive pattern(s) redacted`);
|
|
148
|
+
}
|
|
96
149
|
} catch (err) {
|
|
97
150
|
printError(`Failed to store: ${err.message}`);
|
|
98
151
|
}
|
|
99
152
|
}
|
|
100
153
|
|
|
101
|
-
async function queryMemory(subArgs, loadMemory, namespace) {
|
|
154
|
+
async function queryMemory(subArgs, loadMemory, namespace, enableRedaction = false) {
|
|
102
155
|
const search = subArgs.slice(1).join(' ');
|
|
103
156
|
|
|
104
157
|
if (!search) {
|
|
105
|
-
printError('Usage: memory query <search> [--namespace <ns>]');
|
|
158
|
+
printError('Usage: memory query <search> [--namespace <ns>] [--redact]');
|
|
106
159
|
return;
|
|
107
160
|
}
|
|
108
161
|
|
|
@@ -133,10 +186,24 @@ async function queryMemory(subArgs, loadMemory, namespace) {
|
|
|
133
186
|
for (const entry of results.slice(0, 10)) {
|
|
134
187
|
console.log(`\n📌 ${entry.key}`);
|
|
135
188
|
console.log(` Namespace: ${entry.namespace}`);
|
|
189
|
+
|
|
190
|
+
// Apply redaction to displayed value if requested
|
|
191
|
+
let displayValue = entry.value;
|
|
192
|
+
if (enableRedaction) {
|
|
193
|
+
displayValue = KeyRedactor.redact(displayValue, true);
|
|
194
|
+
}
|
|
195
|
+
|
|
136
196
|
console.log(
|
|
137
|
-
` Value: ${
|
|
197
|
+
` Value: ${displayValue.substring(0, 100)}${displayValue.length > 100 ? '...' : ''}`,
|
|
138
198
|
);
|
|
139
199
|
console.log(` Stored: ${new Date(entry.timestamp).toLocaleString()}`);
|
|
200
|
+
|
|
201
|
+
// Show redaction status
|
|
202
|
+
if (entry.redacted) {
|
|
203
|
+
console.log(` 🔒 Status: Redacted on storage`);
|
|
204
|
+
} else if (enableRedaction) {
|
|
205
|
+
console.log(` 🔒 Status: Redacted for display`);
|
|
206
|
+
}
|
|
140
207
|
}
|
|
141
208
|
|
|
142
209
|
if (results.length > 10) {
|
|
@@ -322,6 +389,248 @@ async function loadMemory() {
|
|
|
322
389
|
}
|
|
323
390
|
}
|
|
324
391
|
|
|
392
|
+
// NEW: Mode detection function
|
|
393
|
+
async function detectMemoryMode(flags, subArgs) {
|
|
394
|
+
// Explicit ReasoningBank flag takes precedence
|
|
395
|
+
if (flags?.reasoningbank || flags?.rb || subArgs.includes('--reasoningbank') || subArgs.includes('--rb')) {
|
|
396
|
+
return 'reasoningbank';
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Auto mode: detect if ReasoningBank is initialized
|
|
400
|
+
if (flags?.auto || subArgs.includes('--auto')) {
|
|
401
|
+
const initialized = await isReasoningBankInitialized();
|
|
402
|
+
return initialized ? 'reasoningbank' : 'basic';
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Default: basic mode (backward compatible)
|
|
406
|
+
return 'basic';
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// NEW: Check if ReasoningBank is initialized
|
|
410
|
+
async function isReasoningBankInitialized() {
|
|
411
|
+
try {
|
|
412
|
+
// Check if .swarm/memory.db exists
|
|
413
|
+
const dbPath = '.swarm/memory.db';
|
|
414
|
+
await fs.access(dbPath);
|
|
415
|
+
return true;
|
|
416
|
+
} catch {
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// NEW: Handle ReasoningBank commands
|
|
422
|
+
async function handleReasoningBankCommand(command, subArgs, flags) {
|
|
423
|
+
const initialized = await isReasoningBankInitialized();
|
|
424
|
+
|
|
425
|
+
// Special handling for 'init' command
|
|
426
|
+
if (command === 'init') {
|
|
427
|
+
if (initialized) {
|
|
428
|
+
printWarning('⚠️ ReasoningBank already initialized');
|
|
429
|
+
console.log('Database: .swarm/memory.db');
|
|
430
|
+
console.log('\nTo reinitialize, delete .swarm/memory.db first');
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
printInfo('🧠 Initializing ReasoningBank...');
|
|
435
|
+
console.log('This will create: .swarm/memory.db\n');
|
|
436
|
+
|
|
437
|
+
try {
|
|
438
|
+
const { stdout, stderr } = await execAsync('npx agentic-flow reasoningbank init', {
|
|
439
|
+
timeout: 30000,
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
if (stdout) console.log(stdout);
|
|
443
|
+
printSuccess('✅ ReasoningBank initialized successfully!');
|
|
444
|
+
console.log('\nNext steps:');
|
|
445
|
+
console.log(' 1. Store memories: memory store key "value" --reasoningbank');
|
|
446
|
+
console.log(' 2. Query memories: memory query "search" --reasoningbank');
|
|
447
|
+
console.log(' 3. Check status: memory status --reasoningbank');
|
|
448
|
+
} catch (error) {
|
|
449
|
+
printError('❌ Failed to initialize ReasoningBank');
|
|
450
|
+
console.error(error.message);
|
|
451
|
+
if (error.stderr) {
|
|
452
|
+
console.error('Details:', error.stderr);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// All other commands require initialization
|
|
459
|
+
if (!initialized) {
|
|
460
|
+
printError('❌ ReasoningBank not initialized');
|
|
461
|
+
console.log('\nTo use ReasoningBank mode, first run:');
|
|
462
|
+
console.log(' memory init --reasoningbank\n');
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Delegate to agentic-flow reasoningbank commands
|
|
467
|
+
printInfo(`🧠 Using ReasoningBank mode...`);
|
|
468
|
+
|
|
469
|
+
try {
|
|
470
|
+
const cmd = buildReasoningBankCommand(command, subArgs, flags);
|
|
471
|
+
const { stdout, stderr } = await execAsync(cmd, { timeout: 30000 });
|
|
472
|
+
|
|
473
|
+
if (stdout) console.log(stdout);
|
|
474
|
+
if (stderr && !stderr.includes('Warning')) console.error(stderr);
|
|
475
|
+
} catch (error) {
|
|
476
|
+
printError(`❌ ReasoningBank command failed`);
|
|
477
|
+
console.error(error.message);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// NEW: Build agentic-flow reasoningbank command
|
|
482
|
+
function buildReasoningBankCommand(command, subArgs, flags) {
|
|
483
|
+
const parts = ['npx', 'agentic-flow', 'reasoningbank'];
|
|
484
|
+
|
|
485
|
+
// Map memory commands to reasoningbank commands
|
|
486
|
+
const commandMap = {
|
|
487
|
+
store: 'store',
|
|
488
|
+
query: 'query',
|
|
489
|
+
list: 'list',
|
|
490
|
+
status: 'status',
|
|
491
|
+
consolidate: 'consolidate',
|
|
492
|
+
demo: 'demo',
|
|
493
|
+
test: 'test',
|
|
494
|
+
benchmark: 'benchmark',
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
parts.push(commandMap[command] || command);
|
|
498
|
+
|
|
499
|
+
// Add arguments (skip the command itself)
|
|
500
|
+
const args = subArgs.slice(1);
|
|
501
|
+
args.forEach((arg) => {
|
|
502
|
+
if (!arg.startsWith('--reasoningbank') && !arg.startsWith('--rb') && !arg.startsWith('--auto')) {
|
|
503
|
+
parts.push(`"${arg}"`);
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
return parts.join(' ');
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// NEW: Handle mode management commands
|
|
511
|
+
async function handleModeCommand(command, subArgs, flags) {
|
|
512
|
+
switch (command) {
|
|
513
|
+
case 'detect':
|
|
514
|
+
await detectModes();
|
|
515
|
+
break;
|
|
516
|
+
|
|
517
|
+
case 'mode':
|
|
518
|
+
await showCurrentMode();
|
|
519
|
+
break;
|
|
520
|
+
|
|
521
|
+
case 'migrate':
|
|
522
|
+
await migrateMemory(subArgs, flags);
|
|
523
|
+
break;
|
|
524
|
+
|
|
525
|
+
default:
|
|
526
|
+
printError(`Unknown mode command: ${command}`);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// NEW: Detect and show available memory modes
|
|
531
|
+
async function detectModes() {
|
|
532
|
+
printInfo('🔍 Detecting memory modes...\n');
|
|
533
|
+
|
|
534
|
+
// Check basic mode
|
|
535
|
+
const basicAvailable = await checkBasicMode();
|
|
536
|
+
console.log(basicAvailable ? '✅ Basic Mode (active)' : '❌ Basic Mode (unavailable)');
|
|
537
|
+
if (basicAvailable) {
|
|
538
|
+
console.log(' Location: ./memory/memory-store.json');
|
|
539
|
+
console.log(' Features: Simple key-value storage, fast');
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
console.log('');
|
|
543
|
+
|
|
544
|
+
// Check ReasoningBank mode
|
|
545
|
+
const rbAvailable = await isReasoningBankInitialized();
|
|
546
|
+
console.log(rbAvailable ? '✅ ReasoningBank Mode (available)' : '⚠️ ReasoningBank Mode (not initialized)');
|
|
547
|
+
if (rbAvailable) {
|
|
548
|
+
console.log(' Location: .swarm/memory.db');
|
|
549
|
+
console.log(' Features: AI-powered semantic search, learning');
|
|
550
|
+
} else {
|
|
551
|
+
console.log(' To enable: memory init --reasoningbank');
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
console.log('\n💡 Usage:');
|
|
555
|
+
console.log(' Basic: memory store key "value"');
|
|
556
|
+
console.log(' ReasoningBank: memory store key "value" --reasoningbank');
|
|
557
|
+
console.log(' Auto-detect: memory query search --auto');
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// NEW: Check if basic mode is available
|
|
561
|
+
async function checkBasicMode() {
|
|
562
|
+
try {
|
|
563
|
+
const memoryDir = './memory';
|
|
564
|
+
await fs.access(memoryDir);
|
|
565
|
+
return true;
|
|
566
|
+
} catch {
|
|
567
|
+
// Create directory if it doesn't exist
|
|
568
|
+
try {
|
|
569
|
+
await fs.mkdir(memoryDir, { recursive: true });
|
|
570
|
+
return true;
|
|
571
|
+
} catch {
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// NEW: Show current default mode
|
|
578
|
+
async function showCurrentMode() {
|
|
579
|
+
const rbInitialized = await isReasoningBankInitialized();
|
|
580
|
+
|
|
581
|
+
printInfo('📊 Current Memory Configuration:\n');
|
|
582
|
+
console.log('Default Mode: Basic (backward compatible)');
|
|
583
|
+
console.log('Available Modes:');
|
|
584
|
+
console.log(' • Basic Mode: Always available');
|
|
585
|
+
console.log(` • ReasoningBank Mode: ${rbInitialized ? 'Initialized ✅' : 'Not initialized ⚠️'}`);
|
|
586
|
+
|
|
587
|
+
console.log('\n💡 To use a specific mode:');
|
|
588
|
+
console.log(' --reasoningbank or --rb → Use ReasoningBank');
|
|
589
|
+
console.log(' --auto → Auto-detect best mode');
|
|
590
|
+
console.log(' (no flag) → Use Basic mode');
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// NEW: Migrate memory between modes
|
|
594
|
+
async function migrateMemory(subArgs, flags) {
|
|
595
|
+
const targetMode = flags?.to || getArgValue(subArgs, '--to');
|
|
596
|
+
|
|
597
|
+
if (!targetMode || !['basic', 'reasoningbank'].includes(targetMode)) {
|
|
598
|
+
printError('Usage: memory migrate --to <basic|reasoningbank>');
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
printInfo(`🔄 Migrating to ${targetMode} mode...\n`);
|
|
603
|
+
|
|
604
|
+
if (targetMode === 'reasoningbank') {
|
|
605
|
+
// Migrate basic → ReasoningBank
|
|
606
|
+
const rbInitialized = await isReasoningBankInitialized();
|
|
607
|
+
if (!rbInitialized) {
|
|
608
|
+
printError('❌ ReasoningBank not initialized');
|
|
609
|
+
console.log('First run: memory init --reasoningbank\n');
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
printWarning('⚠️ Migration from basic to ReasoningBank is not yet implemented');
|
|
614
|
+
console.log('This feature is coming in v2.7.1\n');
|
|
615
|
+
console.log('For now, you can:');
|
|
616
|
+
console.log(' 1. Export basic memory: memory export backup.json');
|
|
617
|
+
console.log(' 2. Manually import to ReasoningBank');
|
|
618
|
+
} else {
|
|
619
|
+
// Migrate ReasoningBank → basic
|
|
620
|
+
printWarning('⚠️ Migration from ReasoningBank to basic is not yet implemented');
|
|
621
|
+
console.log('This feature is coming in v2.7.1\n');
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// Helper to get argument value
|
|
626
|
+
function getArgValue(args, flag) {
|
|
627
|
+
const index = args.indexOf(flag);
|
|
628
|
+
if (index !== -1 && index + 1 < args.length) {
|
|
629
|
+
return args[index + 1];
|
|
630
|
+
}
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
|
|
325
634
|
function showMemoryHelp() {
|
|
326
635
|
console.log('Memory commands:');
|
|
327
636
|
console.log(' store <key> <value> Store a key-value pair');
|
|
@@ -332,14 +641,52 @@ function showMemoryHelp() {
|
|
|
332
641
|
console.log(' clear --namespace <ns> Clear a namespace');
|
|
333
642
|
console.log(' list List all namespaces');
|
|
334
643
|
console.log();
|
|
644
|
+
console.log('🧠 ReasoningBank Commands (NEW in v2.7.0):');
|
|
645
|
+
console.log(' init --reasoningbank Initialize ReasoningBank (AI-powered memory)');
|
|
646
|
+
console.log(' status --reasoningbank Show ReasoningBank statistics');
|
|
647
|
+
console.log(' detect Show available memory modes');
|
|
648
|
+
console.log(' mode Show current memory configuration');
|
|
649
|
+
console.log(' migrate --to <mode> Migrate between basic/reasoningbank');
|
|
650
|
+
console.log();
|
|
335
651
|
console.log('Options:');
|
|
336
652
|
console.log(' --namespace <ns> Specify namespace for operations');
|
|
337
653
|
console.log(' --ns <ns> Short form of --namespace');
|
|
654
|
+
console.log(' --redact 🔒 Enable API key redaction (security feature)');
|
|
655
|
+
console.log(' --secure Alias for --redact');
|
|
656
|
+
console.log();
|
|
657
|
+
console.log('🎯 Mode Selection (NEW):');
|
|
658
|
+
console.log(' --reasoningbank, --rb Use ReasoningBank mode (AI-powered)');
|
|
659
|
+
console.log(' --auto Auto-detect best available mode');
|
|
660
|
+
console.log(' (no flag) Use Basic mode (default, backward compatible)');
|
|
661
|
+
console.log();
|
|
662
|
+
console.log('🔒 Security Features (v2.6.0):');
|
|
663
|
+
console.log(' API Key Protection: Automatically detects and redacts sensitive data');
|
|
664
|
+
console.log(' Patterns Detected: Anthropic, OpenRouter, Gemini, Bearer tokens, etc.');
|
|
665
|
+
console.log(' Auto-Validation: Warns when storing unredacted sensitive data');
|
|
666
|
+
console.log(' Display Redaction: Redact sensitive data when querying with --redact');
|
|
338
667
|
console.log();
|
|
339
668
|
console.log('Examples:');
|
|
669
|
+
console.log(' # Basic mode (default - backward compatible)');
|
|
340
670
|
console.log(' memory store previous_work "Research findings from yesterday"');
|
|
671
|
+
console.log(' memory store api_config "key=sk-ant-..." --redact # 🔒 Redacts API key');
|
|
341
672
|
console.log(' memory query research --namespace sparc');
|
|
342
|
-
console.log(
|
|
343
|
-
console.log('
|
|
344
|
-
console.log(' memory
|
|
673
|
+
console.log();
|
|
674
|
+
console.log(' # ReasoningBank mode (AI-powered, opt-in)');
|
|
675
|
+
console.log(' memory init --reasoningbank # One-time setup');
|
|
676
|
+
console.log(' memory store api_pattern "Always use env vars" --reasoningbank');
|
|
677
|
+
console.log(' memory query "API configuration" --reasoningbank # Semantic search!');
|
|
678
|
+
console.log(' memory status --reasoningbank # Show AI metrics');
|
|
679
|
+
console.log();
|
|
680
|
+
console.log(' # Auto-detect mode (smart selection)');
|
|
681
|
+
console.log(' memory query config --auto # Uses ReasoningBank if available');
|
|
682
|
+
console.log();
|
|
683
|
+
console.log(' # Mode management');
|
|
684
|
+
console.log(' memory detect # Show available modes');
|
|
685
|
+
console.log(' memory mode # Show current configuration');
|
|
686
|
+
console.log();
|
|
687
|
+
console.log('💡 Tips:');
|
|
688
|
+
console.log(' • Use Basic mode for simple key-value storage (fast, always available)');
|
|
689
|
+
console.log(' • Use ReasoningBank for AI-powered semantic search (learns from patterns)');
|
|
690
|
+
console.log(' • Use --auto to let claude-flow choose the best mode for you');
|
|
691
|
+
console.log(' • Always use --redact when storing API keys or secrets!');
|
|
345
692
|
}
|