claude-flow 2.5.0-alpha.141 ā 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/.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 +5 -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/config.js +115 -257
- package/dist/src/cli/simple-commands/config.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 +414 -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/reasoningbank/reasoningbank-adapter.js +144 -0
- package/dist/src/reasoningbank/reasoningbank-adapter.js.map +1 -0
- 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.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-INTEGRATION-STATUS.md +179 -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 +497 -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/reasoningbank/reasoningbank-adapter.js +191 -0
- package/src/utils/key-redactor.js +178 -0
- package/src/utils/key-redactor.ts +184 -0
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { printSuccess, printError, printWarning } from '../utils.js';
|
|
1
|
+
import { printSuccess, printError, printWarning, printInfo } from '../utils.js';
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
|
+
import { KeyRedactor } from '../../utils/key-redactor.js';
|
|
4
|
+
import { exec } from 'child_process';
|
|
5
|
+
import { promisify } from 'util';
|
|
6
|
+
const execAsync = promisify(exec);
|
|
3
7
|
export async function memoryCommand(subArgs, flags) {
|
|
4
8
|
const memorySubcommand = subArgs[0];
|
|
5
9
|
const memoryStore = './memory/memory-store.json';
|
|
6
10
|
const namespace = flags?.namespace || flags?.ns || getNamespaceFromArgs(subArgs) || 'default';
|
|
11
|
+
const enableRedaction = flags?.redact || subArgs.includes('--redact') || subArgs.includes('--secure');
|
|
12
|
+
const mode = await detectMemoryMode(flags, subArgs);
|
|
7
13
|
async function loadMemory() {
|
|
8
14
|
try {
|
|
9
15
|
const content = await fs.readFile(memoryStore, 'utf8');
|
|
@@ -18,12 +24,36 @@ export async function memoryCommand(subArgs, flags) {
|
|
|
18
24
|
});
|
|
19
25
|
await fs.writeFile(memoryStore, JSON.stringify(data, null, 2, 'utf8'));
|
|
20
26
|
}
|
|
27
|
+
if (mode === 'reasoningbank' && [
|
|
28
|
+
'init',
|
|
29
|
+
'status',
|
|
30
|
+
'consolidate',
|
|
31
|
+
'demo',
|
|
32
|
+
'test',
|
|
33
|
+
'benchmark'
|
|
34
|
+
].includes(memorySubcommand)) {
|
|
35
|
+
return await handleReasoningBankCommand(memorySubcommand, subArgs, flags);
|
|
36
|
+
}
|
|
37
|
+
if ([
|
|
38
|
+
'detect',
|
|
39
|
+
'mode',
|
|
40
|
+
'migrate'
|
|
41
|
+
].includes(memorySubcommand)) {
|
|
42
|
+
return await handleModeCommand(memorySubcommand, subArgs, flags);
|
|
43
|
+
}
|
|
44
|
+
if (mode === 'reasoningbank' && [
|
|
45
|
+
'store',
|
|
46
|
+
'query',
|
|
47
|
+
'list'
|
|
48
|
+
].includes(memorySubcommand)) {
|
|
49
|
+
return await handleReasoningBankCommand(memorySubcommand, subArgs, flags);
|
|
50
|
+
}
|
|
21
51
|
switch(memorySubcommand){
|
|
22
52
|
case 'store':
|
|
23
|
-
await storeMemory(subArgs, loadMemory, saveMemory, namespace);
|
|
53
|
+
await storeMemory(subArgs, loadMemory, saveMemory, namespace, enableRedaction);
|
|
24
54
|
break;
|
|
25
55
|
case 'query':
|
|
26
|
-
await queryMemory(subArgs, loadMemory, namespace);
|
|
56
|
+
await queryMemory(subArgs, loadMemory, namespace, enableRedaction);
|
|
27
57
|
break;
|
|
28
58
|
case 'stats':
|
|
29
59
|
await showMemoryStats(loadMemory);
|
|
@@ -44,14 +74,32 @@ export async function memoryCommand(subArgs, flags) {
|
|
|
44
74
|
showMemoryHelp();
|
|
45
75
|
}
|
|
46
76
|
}
|
|
47
|
-
async function storeMemory(subArgs, loadMemory, saveMemory, namespace) {
|
|
77
|
+
async function storeMemory(subArgs, loadMemory, saveMemory, namespace, enableRedaction = false) {
|
|
48
78
|
const key = subArgs[1];
|
|
49
|
-
|
|
79
|
+
let value = subArgs.slice(2).join(' ');
|
|
50
80
|
if (!key || !value) {
|
|
51
|
-
printError('Usage: memory store <key> <value> [--namespace <ns>]');
|
|
81
|
+
printError('Usage: memory store <key> <value> [--namespace <ns>] [--redact]');
|
|
52
82
|
return;
|
|
53
83
|
}
|
|
54
84
|
try {
|
|
85
|
+
let redactedValue = value;
|
|
86
|
+
let securityWarnings = [];
|
|
87
|
+
if (enableRedaction) {
|
|
88
|
+
redactedValue = KeyRedactor.redact(value, true);
|
|
89
|
+
const validation = KeyRedactor.validate(value);
|
|
90
|
+
if (!validation.safe) {
|
|
91
|
+
securityWarnings = validation.warnings;
|
|
92
|
+
printWarning('š Redaction enabled: Sensitive data detected and redacted');
|
|
93
|
+
securityWarnings.forEach((warning)=>console.log(` ā ļø ${warning}`));
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
const validation = KeyRedactor.validate(value);
|
|
97
|
+
if (!validation.safe) {
|
|
98
|
+
printWarning('ā ļø Potential sensitive data detected! Use --redact flag for automatic redaction');
|
|
99
|
+
validation.warnings.forEach((warning)=>console.log(` ā ļø ${warning}`));
|
|
100
|
+
console.log(' š” Tip: Add --redact flag to automatically redact API keys');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
55
103
|
const data = await loadMemory();
|
|
56
104
|
if (!data[namespace]) {
|
|
57
105
|
data[namespace] = [];
|
|
@@ -59,23 +107,27 @@ async function storeMemory(subArgs, loadMemory, saveMemory, namespace) {
|
|
|
59
107
|
data[namespace] = data[namespace].filter((e)=>e.key !== key);
|
|
60
108
|
data[namespace].push({
|
|
61
109
|
key,
|
|
62
|
-
value,
|
|
110
|
+
value: redactedValue,
|
|
63
111
|
namespace,
|
|
64
|
-
timestamp: Date.now()
|
|
112
|
+
timestamp: Date.now(),
|
|
113
|
+
redacted: enableRedaction && securityWarnings.length > 0
|
|
65
114
|
});
|
|
66
115
|
await saveMemory(data);
|
|
67
|
-
printSuccess('Stored successfully');
|
|
116
|
+
printSuccess(enableRedaction && securityWarnings.length > 0 ? 'š Stored successfully (with redaction)' : 'ā
Stored successfully');
|
|
68
117
|
console.log(`š Key: ${key}`);
|
|
69
118
|
console.log(`š¦ Namespace: ${namespace}`);
|
|
70
|
-
console.log(`š¾ Size: ${new TextEncoder().encode(
|
|
119
|
+
console.log(`š¾ Size: ${new TextEncoder().encode(redactedValue).length} bytes`);
|
|
120
|
+
if (enableRedaction && securityWarnings.length > 0) {
|
|
121
|
+
console.log(`š Security: ${securityWarnings.length} sensitive pattern(s) redacted`);
|
|
122
|
+
}
|
|
71
123
|
} catch (err) {
|
|
72
124
|
printError(`Failed to store: ${err.message}`);
|
|
73
125
|
}
|
|
74
126
|
}
|
|
75
|
-
async function queryMemory(subArgs, loadMemory, namespace) {
|
|
127
|
+
async function queryMemory(subArgs, loadMemory, namespace, enableRedaction = false) {
|
|
76
128
|
const search = subArgs.slice(1).join(' ');
|
|
77
129
|
if (!search) {
|
|
78
|
-
printError('Usage: memory query <search> [--namespace <ns>]');
|
|
130
|
+
printError('Usage: memory query <search> [--namespace <ns>] [--redact]');
|
|
79
131
|
return;
|
|
80
132
|
}
|
|
81
133
|
try {
|
|
@@ -98,8 +150,17 @@ async function queryMemory(subArgs, loadMemory, namespace) {
|
|
|
98
150
|
for (const entry of results.slice(0, 10)){
|
|
99
151
|
console.log(`\nš ${entry.key}`);
|
|
100
152
|
console.log(` Namespace: ${entry.namespace}`);
|
|
101
|
-
|
|
153
|
+
let displayValue = entry.value;
|
|
154
|
+
if (enableRedaction) {
|
|
155
|
+
displayValue = KeyRedactor.redact(displayValue, true);
|
|
156
|
+
}
|
|
157
|
+
console.log(` Value: ${displayValue.substring(0, 100)}${displayValue.length > 100 ? '...' : ''}`);
|
|
102
158
|
console.log(` Stored: ${new Date(entry.timestamp).toLocaleString()}`);
|
|
159
|
+
if (entry.redacted) {
|
|
160
|
+
console.log(` š Status: Redacted on storage`);
|
|
161
|
+
} else if (enableRedaction) {
|
|
162
|
+
console.log(` š Status: Redacted for display`);
|
|
163
|
+
}
|
|
103
164
|
}
|
|
104
165
|
if (results.length > 10) {
|
|
105
166
|
console.log(`\n... and ${results.length - 10} more results`);
|
|
@@ -246,6 +307,305 @@ async function loadMemory() {
|
|
|
246
307
|
return {};
|
|
247
308
|
}
|
|
248
309
|
}
|
|
310
|
+
async function detectMemoryMode(flags, subArgs) {
|
|
311
|
+
if (flags?.reasoningbank || flags?.rb || subArgs.includes('--reasoningbank') || subArgs.includes('--rb')) {
|
|
312
|
+
return 'reasoningbank';
|
|
313
|
+
}
|
|
314
|
+
if (flags?.auto || subArgs.includes('--auto')) {
|
|
315
|
+
const initialized = await isReasoningBankInitialized();
|
|
316
|
+
return initialized ? 'reasoningbank' : 'basic';
|
|
317
|
+
}
|
|
318
|
+
return 'basic';
|
|
319
|
+
}
|
|
320
|
+
async function isReasoningBankInitialized() {
|
|
321
|
+
try {
|
|
322
|
+
const dbPath = '.swarm/memory.db';
|
|
323
|
+
await fs.access(dbPath);
|
|
324
|
+
return true;
|
|
325
|
+
} catch {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
async function handleReasoningBankCommand(command, subArgs, flags) {
|
|
330
|
+
const initialized = await isReasoningBankInitialized();
|
|
331
|
+
const { initializeReasoningBank, storeMemory, queryMemories, listMemories, getStatus } = await import('../../reasoningbank/reasoningbank-adapter.js');
|
|
332
|
+
if (command === 'init') {
|
|
333
|
+
if (initialized) {
|
|
334
|
+
printWarning('ā ļø ReasoningBank already initialized');
|
|
335
|
+
console.log('Database: .swarm/memory.db');
|
|
336
|
+
console.log('\nTo reinitialize, delete .swarm/memory.db first');
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
printInfo('š§ Initializing ReasoningBank...');
|
|
340
|
+
console.log('This will create: .swarm/memory.db\n');
|
|
341
|
+
try {
|
|
342
|
+
await initializeReasoningBank();
|
|
343
|
+
printSuccess('ā
ReasoningBank initialized successfully!');
|
|
344
|
+
console.log('\nNext steps:');
|
|
345
|
+
console.log(' 1. Store memories: memory store key "value" --reasoningbank');
|
|
346
|
+
console.log(' 2. Query memories: memory query "search" --reasoningbank');
|
|
347
|
+
console.log(' 3. Check status: memory status --reasoningbank');
|
|
348
|
+
} catch (error) {
|
|
349
|
+
printError('ā Failed to initialize ReasoningBank');
|
|
350
|
+
console.error(error.message);
|
|
351
|
+
}
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (!initialized) {
|
|
355
|
+
printError('ā ReasoningBank not initialized');
|
|
356
|
+
console.log('\nTo use ReasoningBank mode, first run:');
|
|
357
|
+
console.log(' memory init --reasoningbank\n');
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
printInfo(`š§ Using ReasoningBank mode...`);
|
|
361
|
+
try {
|
|
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
|
+
}
|
|
388
|
+
} catch (error) {
|
|
389
|
+
printError(`ā ReasoningBank command failed`);
|
|
390
|
+
console.error(error.message);
|
|
391
|
+
}
|
|
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
|
+
}
|
|
484
|
+
function buildReasoningBankCommand(command, subArgs, flags) {
|
|
485
|
+
const parts = [
|
|
486
|
+
'npx',
|
|
487
|
+
'agentic-flow',
|
|
488
|
+
'reasoningbank'
|
|
489
|
+
];
|
|
490
|
+
const commandMap = {
|
|
491
|
+
store: 'store',
|
|
492
|
+
query: 'query',
|
|
493
|
+
list: 'list',
|
|
494
|
+
status: 'status',
|
|
495
|
+
consolidate: 'consolidate',
|
|
496
|
+
demo: 'demo',
|
|
497
|
+
test: 'test',
|
|
498
|
+
benchmark: 'benchmark'
|
|
499
|
+
};
|
|
500
|
+
parts.push(commandMap[command] || command);
|
|
501
|
+
const args = subArgs.slice(1);
|
|
502
|
+
args.forEach((arg)=>{
|
|
503
|
+
if (!arg.startsWith('--reasoningbank') && !arg.startsWith('--rb') && !arg.startsWith('--auto')) {
|
|
504
|
+
parts.push(`"${arg}"`);
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
parts.push('--agent', 'memory-agent');
|
|
508
|
+
return parts.join(' ');
|
|
509
|
+
}
|
|
510
|
+
async function handleModeCommand(command, subArgs, flags) {
|
|
511
|
+
switch(command){
|
|
512
|
+
case 'detect':
|
|
513
|
+
await detectModes();
|
|
514
|
+
break;
|
|
515
|
+
case 'mode':
|
|
516
|
+
await showCurrentMode();
|
|
517
|
+
break;
|
|
518
|
+
case 'migrate':
|
|
519
|
+
await migrateMemory(subArgs, flags);
|
|
520
|
+
break;
|
|
521
|
+
default:
|
|
522
|
+
printError(`Unknown mode command: ${command}`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
async function detectModes() {
|
|
526
|
+
printInfo('š Detecting memory modes...\n');
|
|
527
|
+
const basicAvailable = await checkBasicMode();
|
|
528
|
+
console.log(basicAvailable ? 'ā
Basic Mode (active)' : 'ā Basic Mode (unavailable)');
|
|
529
|
+
if (basicAvailable) {
|
|
530
|
+
console.log(' Location: ./memory/memory-store.json');
|
|
531
|
+
console.log(' Features: Simple key-value storage, fast');
|
|
532
|
+
}
|
|
533
|
+
console.log('');
|
|
534
|
+
const rbAvailable = await isReasoningBankInitialized();
|
|
535
|
+
console.log(rbAvailable ? 'ā
ReasoningBank Mode (available)' : 'ā ļø ReasoningBank Mode (not initialized)');
|
|
536
|
+
if (rbAvailable) {
|
|
537
|
+
console.log(' Location: .swarm/memory.db');
|
|
538
|
+
console.log(' Features: AI-powered semantic search, learning');
|
|
539
|
+
} else {
|
|
540
|
+
console.log(' To enable: memory init --reasoningbank');
|
|
541
|
+
}
|
|
542
|
+
console.log('\nš” Usage:');
|
|
543
|
+
console.log(' Basic: memory store key "value"');
|
|
544
|
+
console.log(' ReasoningBank: memory store key "value" --reasoningbank');
|
|
545
|
+
console.log(' Auto-detect: memory query search --auto');
|
|
546
|
+
}
|
|
547
|
+
async function checkBasicMode() {
|
|
548
|
+
try {
|
|
549
|
+
const memoryDir1 = './memory';
|
|
550
|
+
await fs.access(memoryDir1);
|
|
551
|
+
return true;
|
|
552
|
+
} catch {
|
|
553
|
+
try {
|
|
554
|
+
await fs.mkdir(memoryDir, {
|
|
555
|
+
recursive: true
|
|
556
|
+
});
|
|
557
|
+
return true;
|
|
558
|
+
} catch {
|
|
559
|
+
return false;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
async function showCurrentMode() {
|
|
564
|
+
const rbInitialized = await isReasoningBankInitialized();
|
|
565
|
+
printInfo('š Current Memory Configuration:\n');
|
|
566
|
+
console.log('Default Mode: Basic (backward compatible)');
|
|
567
|
+
console.log('Available Modes:');
|
|
568
|
+
console.log(' ⢠Basic Mode: Always available');
|
|
569
|
+
console.log(` ⢠ReasoningBank Mode: ${rbInitialized ? 'Initialized ā
' : 'Not initialized ā ļø'}`);
|
|
570
|
+
console.log('\nš” To use a specific mode:');
|
|
571
|
+
console.log(' --reasoningbank or --rb ā Use ReasoningBank');
|
|
572
|
+
console.log(' --auto ā Auto-detect best mode');
|
|
573
|
+
console.log(' (no flag) ā Use Basic mode');
|
|
574
|
+
}
|
|
575
|
+
async function migrateMemory(subArgs, flags) {
|
|
576
|
+
const targetMode = flags?.to || getArgValue(subArgs, '--to');
|
|
577
|
+
if (!targetMode || ![
|
|
578
|
+
'basic',
|
|
579
|
+
'reasoningbank'
|
|
580
|
+
].includes(targetMode)) {
|
|
581
|
+
printError('Usage: memory migrate --to <basic|reasoningbank>');
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
printInfo(`š Migrating to ${targetMode} mode...\n`);
|
|
585
|
+
if (targetMode === 'reasoningbank') {
|
|
586
|
+
const rbInitialized = await isReasoningBankInitialized();
|
|
587
|
+
if (!rbInitialized) {
|
|
588
|
+
printError('ā ReasoningBank not initialized');
|
|
589
|
+
console.log('First run: memory init --reasoningbank\n');
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
printWarning('ā ļø Migration from basic to ReasoningBank is not yet implemented');
|
|
593
|
+
console.log('This feature is coming in v2.7.1\n');
|
|
594
|
+
console.log('For now, you can:');
|
|
595
|
+
console.log(' 1. Export basic memory: memory export backup.json');
|
|
596
|
+
console.log(' 2. Manually import to ReasoningBank');
|
|
597
|
+
} else {
|
|
598
|
+
printWarning('ā ļø Migration from ReasoningBank to basic is not yet implemented');
|
|
599
|
+
console.log('This feature is coming in v2.7.1\n');
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function getArgValue(args, flag) {
|
|
603
|
+
const index = args.indexOf(flag);
|
|
604
|
+
if (index !== -1 && index + 1 < args.length) {
|
|
605
|
+
return args[index + 1];
|
|
606
|
+
}
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
249
609
|
function showMemoryHelp() {
|
|
250
610
|
console.log('Memory commands:');
|
|
251
611
|
console.log(' store <key> <value> Store a key-value pair');
|
|
@@ -256,16 +616,54 @@ function showMemoryHelp() {
|
|
|
256
616
|
console.log(' clear --namespace <ns> Clear a namespace');
|
|
257
617
|
console.log(' list List all namespaces');
|
|
258
618
|
console.log();
|
|
619
|
+
console.log('š§ ReasoningBank Commands (NEW in v2.7.0):');
|
|
620
|
+
console.log(' init --reasoningbank Initialize ReasoningBank (AI-powered memory)');
|
|
621
|
+
console.log(' status --reasoningbank Show ReasoningBank statistics');
|
|
622
|
+
console.log(' detect Show available memory modes');
|
|
623
|
+
console.log(' mode Show current memory configuration');
|
|
624
|
+
console.log(' migrate --to <mode> Migrate between basic/reasoningbank');
|
|
625
|
+
console.log();
|
|
259
626
|
console.log('Options:');
|
|
260
627
|
console.log(' --namespace <ns> Specify namespace for operations');
|
|
261
628
|
console.log(' --ns <ns> Short form of --namespace');
|
|
629
|
+
console.log(' --redact š Enable API key redaction (security feature)');
|
|
630
|
+
console.log(' --secure Alias for --redact');
|
|
631
|
+
console.log();
|
|
632
|
+
console.log('šÆ Mode Selection (NEW):');
|
|
633
|
+
console.log(' --reasoningbank, --rb Use ReasoningBank mode (AI-powered)');
|
|
634
|
+
console.log(' --auto Auto-detect best available mode');
|
|
635
|
+
console.log(' (no flag) Use Basic mode (default, backward compatible)');
|
|
636
|
+
console.log();
|
|
637
|
+
console.log('š Security Features (v2.6.0):');
|
|
638
|
+
console.log(' API Key Protection: Automatically detects and redacts sensitive data');
|
|
639
|
+
console.log(' Patterns Detected: Anthropic, OpenRouter, Gemini, Bearer tokens, etc.');
|
|
640
|
+
console.log(' Auto-Validation: Warns when storing unredacted sensitive data');
|
|
641
|
+
console.log(' Display Redaction: Redact sensitive data when querying with --redact');
|
|
262
642
|
console.log();
|
|
263
643
|
console.log('Examples:');
|
|
644
|
+
console.log(' # Basic mode (default - backward compatible)');
|
|
264
645
|
console.log(' memory store previous_work "Research findings from yesterday"');
|
|
646
|
+
console.log(' memory store api_config "key=sk-ant-..." --redact # š Redacts API key');
|
|
265
647
|
console.log(' memory query research --namespace sparc');
|
|
266
|
-
console.log(
|
|
267
|
-
console.log('
|
|
268
|
-
console.log(' memory
|
|
648
|
+
console.log();
|
|
649
|
+
console.log(' # ReasoningBank mode (AI-powered, opt-in)');
|
|
650
|
+
console.log(' memory init --reasoningbank # One-time setup');
|
|
651
|
+
console.log(' memory store api_pattern "Always use env vars" --reasoningbank');
|
|
652
|
+
console.log(' memory query "API configuration" --reasoningbank # Semantic search!');
|
|
653
|
+
console.log(' memory status --reasoningbank # Show AI metrics');
|
|
654
|
+
console.log();
|
|
655
|
+
console.log(' # Auto-detect mode (smart selection)');
|
|
656
|
+
console.log(' memory query config --auto # Uses ReasoningBank if available');
|
|
657
|
+
console.log();
|
|
658
|
+
console.log(' # Mode management');
|
|
659
|
+
console.log(' memory detect # Show available modes');
|
|
660
|
+
console.log(' memory mode # Show current configuration');
|
|
661
|
+
console.log();
|
|
662
|
+
console.log('š” Tips:');
|
|
663
|
+
console.log(' ⢠Use Basic mode for simple key-value storage (fast, always available)');
|
|
664
|
+
console.log(' ⢠Use ReasoningBank for AI-powered semantic search (learns from patterns)');
|
|
665
|
+
console.log(' ⢠Use --auto to let claude-flow choose the best mode for you');
|
|
666
|
+
console.log(' ⢠Always use --redact when storing API keys or secrets!');
|
|
269
667
|
}
|
|
270
668
|
|
|
271
669
|
//# sourceMappingURL=memory.js.map
|