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
|
@@ -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,198 @@ 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
|
+
if (command === 'init') {
|
|
332
|
+
if (initialized) {
|
|
333
|
+
printWarning('ā ļø ReasoningBank already initialized');
|
|
334
|
+
console.log('Database: .swarm/memory.db');
|
|
335
|
+
console.log('\nTo reinitialize, delete .swarm/memory.db first');
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
printInfo('š§ Initializing ReasoningBank...');
|
|
339
|
+
console.log('This will create: .swarm/memory.db\n');
|
|
340
|
+
try {
|
|
341
|
+
const { stdout, stderr } = await execAsync('npx agentic-flow reasoningbank init', {
|
|
342
|
+
timeout: 30000
|
|
343
|
+
});
|
|
344
|
+
if (stdout) console.log(stdout);
|
|
345
|
+
printSuccess('ā
ReasoningBank initialized successfully!');
|
|
346
|
+
console.log('\nNext steps:');
|
|
347
|
+
console.log(' 1. Store memories: memory store key "value" --reasoningbank');
|
|
348
|
+
console.log(' 2. Query memories: memory query "search" --reasoningbank');
|
|
349
|
+
console.log(' 3. Check status: memory status --reasoningbank');
|
|
350
|
+
} catch (error) {
|
|
351
|
+
printError('ā Failed to initialize ReasoningBank');
|
|
352
|
+
console.error(error.message);
|
|
353
|
+
if (error.stderr) {
|
|
354
|
+
console.error('Details:', error.stderr);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (!initialized) {
|
|
360
|
+
printError('ā ReasoningBank not initialized');
|
|
361
|
+
console.log('\nTo use ReasoningBank mode, first run:');
|
|
362
|
+
console.log(' memory init --reasoningbank\n');
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
printInfo(`š§ Using ReasoningBank mode...`);
|
|
366
|
+
try {
|
|
367
|
+
const cmd = buildReasoningBankCommand(command, subArgs, flags);
|
|
368
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
369
|
+
timeout: 30000
|
|
370
|
+
});
|
|
371
|
+
if (stdout) console.log(stdout);
|
|
372
|
+
if (stderr && !stderr.includes('Warning')) console.error(stderr);
|
|
373
|
+
} catch (error) {
|
|
374
|
+
printError(`ā ReasoningBank command failed`);
|
|
375
|
+
console.error(error.message);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
function buildReasoningBankCommand(command, subArgs, flags) {
|
|
379
|
+
const parts = [
|
|
380
|
+
'npx',
|
|
381
|
+
'agentic-flow',
|
|
382
|
+
'reasoningbank'
|
|
383
|
+
];
|
|
384
|
+
const commandMap = {
|
|
385
|
+
store: 'store',
|
|
386
|
+
query: 'query',
|
|
387
|
+
list: 'list',
|
|
388
|
+
status: 'status',
|
|
389
|
+
consolidate: 'consolidate',
|
|
390
|
+
demo: 'demo',
|
|
391
|
+
test: 'test',
|
|
392
|
+
benchmark: 'benchmark'
|
|
393
|
+
};
|
|
394
|
+
parts.push(commandMap[command] || command);
|
|
395
|
+
const args = subArgs.slice(1);
|
|
396
|
+
args.forEach((arg)=>{
|
|
397
|
+
if (!arg.startsWith('--reasoningbank') && !arg.startsWith('--rb') && !arg.startsWith('--auto')) {
|
|
398
|
+
parts.push(`"${arg}"`);
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
return parts.join(' ');
|
|
402
|
+
}
|
|
403
|
+
async function handleModeCommand(command, subArgs, flags) {
|
|
404
|
+
switch(command){
|
|
405
|
+
case 'detect':
|
|
406
|
+
await detectModes();
|
|
407
|
+
break;
|
|
408
|
+
case 'mode':
|
|
409
|
+
await showCurrentMode();
|
|
410
|
+
break;
|
|
411
|
+
case 'migrate':
|
|
412
|
+
await migrateMemory(subArgs, flags);
|
|
413
|
+
break;
|
|
414
|
+
default:
|
|
415
|
+
printError(`Unknown mode command: ${command}`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
async function detectModes() {
|
|
419
|
+
printInfo('š Detecting memory modes...\n');
|
|
420
|
+
const basicAvailable = await checkBasicMode();
|
|
421
|
+
console.log(basicAvailable ? 'ā
Basic Mode (active)' : 'ā Basic Mode (unavailable)');
|
|
422
|
+
if (basicAvailable) {
|
|
423
|
+
console.log(' Location: ./memory/memory-store.json');
|
|
424
|
+
console.log(' Features: Simple key-value storage, fast');
|
|
425
|
+
}
|
|
426
|
+
console.log('');
|
|
427
|
+
const rbAvailable = await isReasoningBankInitialized();
|
|
428
|
+
console.log(rbAvailable ? 'ā
ReasoningBank Mode (available)' : 'ā ļø ReasoningBank Mode (not initialized)');
|
|
429
|
+
if (rbAvailable) {
|
|
430
|
+
console.log(' Location: .swarm/memory.db');
|
|
431
|
+
console.log(' Features: AI-powered semantic search, learning');
|
|
432
|
+
} else {
|
|
433
|
+
console.log(' To enable: memory init --reasoningbank');
|
|
434
|
+
}
|
|
435
|
+
console.log('\nš” Usage:');
|
|
436
|
+
console.log(' Basic: memory store key "value"');
|
|
437
|
+
console.log(' ReasoningBank: memory store key "value" --reasoningbank');
|
|
438
|
+
console.log(' Auto-detect: memory query search --auto');
|
|
439
|
+
}
|
|
440
|
+
async function checkBasicMode() {
|
|
441
|
+
try {
|
|
442
|
+
const memoryDir1 = './memory';
|
|
443
|
+
await fs.access(memoryDir1);
|
|
444
|
+
return true;
|
|
445
|
+
} catch {
|
|
446
|
+
try {
|
|
447
|
+
await fs.mkdir(memoryDir, {
|
|
448
|
+
recursive: true
|
|
449
|
+
});
|
|
450
|
+
return true;
|
|
451
|
+
} catch {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
async function showCurrentMode() {
|
|
457
|
+
const rbInitialized = await isReasoningBankInitialized();
|
|
458
|
+
printInfo('š Current Memory Configuration:\n');
|
|
459
|
+
console.log('Default Mode: Basic (backward compatible)');
|
|
460
|
+
console.log('Available Modes:');
|
|
461
|
+
console.log(' ⢠Basic Mode: Always available');
|
|
462
|
+
console.log(` ⢠ReasoningBank Mode: ${rbInitialized ? 'Initialized ā
' : 'Not initialized ā ļø'}`);
|
|
463
|
+
console.log('\nš” To use a specific mode:');
|
|
464
|
+
console.log(' --reasoningbank or --rb ā Use ReasoningBank');
|
|
465
|
+
console.log(' --auto ā Auto-detect best mode');
|
|
466
|
+
console.log(' (no flag) ā Use Basic mode');
|
|
467
|
+
}
|
|
468
|
+
async function migrateMemory(subArgs, flags) {
|
|
469
|
+
const targetMode = flags?.to || getArgValue(subArgs, '--to');
|
|
470
|
+
if (!targetMode || ![
|
|
471
|
+
'basic',
|
|
472
|
+
'reasoningbank'
|
|
473
|
+
].includes(targetMode)) {
|
|
474
|
+
printError('Usage: memory migrate --to <basic|reasoningbank>');
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
printInfo(`š Migrating to ${targetMode} mode...\n`);
|
|
478
|
+
if (targetMode === 'reasoningbank') {
|
|
479
|
+
const rbInitialized = await isReasoningBankInitialized();
|
|
480
|
+
if (!rbInitialized) {
|
|
481
|
+
printError('ā ReasoningBank not initialized');
|
|
482
|
+
console.log('First run: memory init --reasoningbank\n');
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
printWarning('ā ļø Migration from basic to ReasoningBank is not yet implemented');
|
|
486
|
+
console.log('This feature is coming in v2.7.1\n');
|
|
487
|
+
console.log('For now, you can:');
|
|
488
|
+
console.log(' 1. Export basic memory: memory export backup.json');
|
|
489
|
+
console.log(' 2. Manually import to ReasoningBank');
|
|
490
|
+
} else {
|
|
491
|
+
printWarning('ā ļø Migration from ReasoningBank to basic is not yet implemented');
|
|
492
|
+
console.log('This feature is coming in v2.7.1\n');
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
function getArgValue(args, flag) {
|
|
496
|
+
const index = args.indexOf(flag);
|
|
497
|
+
if (index !== -1 && index + 1 < args.length) {
|
|
498
|
+
return args[index + 1];
|
|
499
|
+
}
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
249
502
|
function showMemoryHelp() {
|
|
250
503
|
console.log('Memory commands:');
|
|
251
504
|
console.log(' store <key> <value> Store a key-value pair');
|
|
@@ -256,16 +509,54 @@ function showMemoryHelp() {
|
|
|
256
509
|
console.log(' clear --namespace <ns> Clear a namespace');
|
|
257
510
|
console.log(' list List all namespaces');
|
|
258
511
|
console.log();
|
|
512
|
+
console.log('š§ ReasoningBank Commands (NEW in v2.7.0):');
|
|
513
|
+
console.log(' init --reasoningbank Initialize ReasoningBank (AI-powered memory)');
|
|
514
|
+
console.log(' status --reasoningbank Show ReasoningBank statistics');
|
|
515
|
+
console.log(' detect Show available memory modes');
|
|
516
|
+
console.log(' mode Show current memory configuration');
|
|
517
|
+
console.log(' migrate --to <mode> Migrate between basic/reasoningbank');
|
|
518
|
+
console.log();
|
|
259
519
|
console.log('Options:');
|
|
260
520
|
console.log(' --namespace <ns> Specify namespace for operations');
|
|
261
521
|
console.log(' --ns <ns> Short form of --namespace');
|
|
522
|
+
console.log(' --redact š Enable API key redaction (security feature)');
|
|
523
|
+
console.log(' --secure Alias for --redact');
|
|
524
|
+
console.log();
|
|
525
|
+
console.log('šÆ Mode Selection (NEW):');
|
|
526
|
+
console.log(' --reasoningbank, --rb Use ReasoningBank mode (AI-powered)');
|
|
527
|
+
console.log(' --auto Auto-detect best available mode');
|
|
528
|
+
console.log(' (no flag) Use Basic mode (default, backward compatible)');
|
|
529
|
+
console.log();
|
|
530
|
+
console.log('š Security Features (v2.6.0):');
|
|
531
|
+
console.log(' API Key Protection: Automatically detects and redacts sensitive data');
|
|
532
|
+
console.log(' Patterns Detected: Anthropic, OpenRouter, Gemini, Bearer tokens, etc.');
|
|
533
|
+
console.log(' Auto-Validation: Warns when storing unredacted sensitive data');
|
|
534
|
+
console.log(' Display Redaction: Redact sensitive data when querying with --redact');
|
|
262
535
|
console.log();
|
|
263
536
|
console.log('Examples:');
|
|
537
|
+
console.log(' # Basic mode (default - backward compatible)');
|
|
264
538
|
console.log(' memory store previous_work "Research findings from yesterday"');
|
|
539
|
+
console.log(' memory store api_config "key=sk-ant-..." --redact # š Redacts API key');
|
|
265
540
|
console.log(' memory query research --namespace sparc');
|
|
266
|
-
console.log(
|
|
267
|
-
console.log('
|
|
268
|
-
console.log(' memory
|
|
541
|
+
console.log();
|
|
542
|
+
console.log(' # ReasoningBank mode (AI-powered, opt-in)');
|
|
543
|
+
console.log(' memory init --reasoningbank # One-time setup');
|
|
544
|
+
console.log(' memory store api_pattern "Always use env vars" --reasoningbank');
|
|
545
|
+
console.log(' memory query "API configuration" --reasoningbank # Semantic search!');
|
|
546
|
+
console.log(' memory status --reasoningbank # Show AI metrics');
|
|
547
|
+
console.log();
|
|
548
|
+
console.log(' # Auto-detect mode (smart selection)');
|
|
549
|
+
console.log(' memory query config --auto # Uses ReasoningBank if available');
|
|
550
|
+
console.log();
|
|
551
|
+
console.log(' # Mode management');
|
|
552
|
+
console.log(' memory detect # Show available modes');
|
|
553
|
+
console.log(' memory mode # Show current configuration');
|
|
554
|
+
console.log();
|
|
555
|
+
console.log('š” Tips:');
|
|
556
|
+
console.log(' ⢠Use Basic mode for simple key-value storage (fast, always available)');
|
|
557
|
+
console.log(' ⢠Use ReasoningBank for AI-powered semantic search (learns from patterns)');
|
|
558
|
+
console.log(' ⢠Use --auto to let claude-flow choose the best mode for you');
|
|
559
|
+
console.log(' ⢠Always use --redact when storing API keys or secrets!');
|
|
269
560
|
}
|
|
270
561
|
|
|
271
562
|
//# sourceMappingURL=memory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/cli/simple-commands/memory.js"],"sourcesContent":["// memory.js - Memory management commands\nimport { printSuccess, printError, printWarning, printInfo } from '../utils.js';\nimport { promises as fs } from 'fs';\nimport { cwd, exit, existsSync } from '../node-compat.js';\nimport { getUnifiedMemory } from '../../memory/unified-memory-manager.js';\n\nexport async function memoryCommand(subArgs, flags) {\n const memorySubcommand = subArgs[0];\n const memoryStore = './memory/memory-store.json';\n \n // Extract namespace from flags or subArgs\n const namespace = flags?.namespace || flags?.ns || getNamespaceFromArgs(subArgs) || 'default';\n\n // Helper to load memory data\n async function loadMemory() {\n try {\n const content = await fs.readFile(memoryStore, 'utf8');\n return JSON.parse(content);\n } catch {\n return {};\n }\n }\n\n // Helper to save memory data\n async function saveMemory(data) {\n await fs.mkdir('./memory', { recursive: true });\n await fs.writeFile(memoryStore, JSON.stringify(data, null, 2, 'utf8'));\n }\n\n switch (memorySubcommand) {\n case 'store':\n await storeMemory(subArgs, loadMemory, saveMemory, namespace);\n break;\n\n case 'query':\n await queryMemory(subArgs, loadMemory, namespace);\n break;\n\n case 'stats':\n await showMemoryStats(loadMemory);\n break;\n\n case 'export':\n await exportMemory(subArgs, loadMemory, namespace);\n break;\n\n case 'import':\n await importMemory(subArgs, saveMemory, loadMemory);\n break;\n\n case 'clear':\n await clearMemory(subArgs, saveMemory, namespace);\n break;\n\n case 'list':\n await listNamespaces(loadMemory);\n break;\n\n default:\n showMemoryHelp();\n }\n}\n\nasync function storeMemory(subArgs, loadMemory, saveMemory, namespace) {\n const key = subArgs[1];\n const value = subArgs.slice(2).join(' ');\n\n if (!key || !value) {\n printError('Usage: memory store <key> <value> [--namespace <ns>]');\n return;\n }\n\n try {\n const data = await loadMemory();\n\n if (!data[namespace]) {\n data[namespace] = [];\n }\n\n // Remove existing entry with same key\n data[namespace] = data[namespace].filter((e) => e.key !== key);\n\n // Add new entry\n data[namespace].push({\n key,\n value,\n namespace,\n timestamp: Date.now(),\n });\n\n await saveMemory(data);\n printSuccess('Stored successfully');\n console.log(`š Key: ${key}`);\n console.log(`š¦ Namespace: ${namespace}`);\n console.log(`š¾ Size: ${new TextEncoder().encode(value).length} bytes`);\n } catch (err) {\n printError(`Failed to store: ${err.message}`);\n }\n}\n\nasync function queryMemory(subArgs, loadMemory, namespace) {\n const search = subArgs.slice(1).join(' ');\n\n if (!search) {\n printError('Usage: memory query <search> [--namespace <ns>]');\n return;\n }\n\n try {\n const data = await loadMemory();\n const results = [];\n\n for (const [ns, entries] of Object.entries(data)) {\n if (namespace && ns !== namespace) continue;\n\n for (const entry of entries) {\n if (entry.key.includes(search) || entry.value.includes(search)) {\n results.push(entry);\n }\n }\n }\n\n if (results.length === 0) {\n printWarning('No results found');\n return;\n }\n\n printSuccess(`Found ${results.length} results:`);\n\n // Sort by timestamp (newest first)\n results.sort((a, b) => b.timestamp - a.timestamp);\n\n for (const entry of results.slice(0, 10)) {\n console.log(`\\nš ${entry.key}`);\n console.log(` Namespace: ${entry.namespace}`);\n console.log(\n ` Value: ${entry.value.substring(0, 100)}${entry.value.length > 100 ? '...' : ''}`,\n );\n console.log(` Stored: ${new Date(entry.timestamp).toLocaleString()}`);\n }\n\n if (results.length > 10) {\n console.log(`\\n... and ${results.length - 10} more results`);\n }\n } catch (err) {\n printError(`Failed to query: ${err.message}`);\n }\n}\n\nasync function showMemoryStats(loadMemory) {\n try {\n const data = await loadMemory();\n let totalEntries = 0;\n const namespaceStats = {};\n\n for (const [namespace, entries] of Object.entries(data)) {\n namespaceStats[namespace] = entries.length;\n totalEntries += entries.length;\n }\n\n printSuccess('Memory Bank Statistics:');\n console.log(` Total Entries: ${totalEntries}`);\n console.log(` Namespaces: ${Object.keys(data).length}`);\n console.log(\n ` Size: ${(new TextEncoder().encode(JSON.stringify(data)).length / 1024).toFixed(2)} KB`,\n );\n\n if (Object.keys(data).length > 0) {\n console.log('\\nš Namespace Breakdown:');\n for (const [namespace, count] of Object.entries(namespaceStats)) {\n console.log(` ${namespace}: ${count} entries`);\n }\n }\n } catch (err) {\n printError(`Failed to get stats: ${err.message}`);\n }\n}\n\nasync function exportMemory(subArgs, loadMemory, namespace) {\n const filename = subArgs[1] || `memory-export-${Date.now()}.json`;\n\n try {\n const data = await loadMemory();\n\n let exportData = data;\n if (namespace) {\n exportData = { [namespace]: data[namespace] || [] };\n }\n\n await fs.writeFile(filename, JSON.stringify(exportData, null, 2, 'utf8'));\n printSuccess(`Memory exported to ${filename}`);\n\n let totalEntries = 0;\n for (const entries of Object.values(exportData)) {\n totalEntries += entries.length;\n }\n console.log(\n `š¦ Exported ${totalEntries} entries from ${Object.keys(exportData).length} namespace(s)`,\n );\n } catch (err) {\n printError(`Failed to export memory: ${err.message}`);\n }\n}\n\nasync function importMemory(subArgs, saveMemory, loadMemory) {\n const filename = subArgs[1];\n\n if (!filename) {\n printError('Usage: memory import <filename>');\n return;\n }\n\n try {\n const importContent = await fs.readFile(filename, 'utf8');\n const importData = JSON.parse(importContent);\n\n // Load existing memory\n const existingData = await loadMemory();\n\n // Merge imported data\n let totalImported = 0;\n for (const [namespace, entries] of Object.entries(importData)) {\n if (!existingData[namespace]) {\n existingData[namespace] = [];\n }\n\n // Add entries that don't already exist (by key)\n const existingKeys = new Set(existingData[namespace].map((e) => e.key));\n const newEntries = entries.filter((e) => !existingKeys.has(e.key));\n\n existingData[namespace].push(...newEntries);\n totalImported += newEntries.length;\n }\n\n await saveMemory(existingData);\n printSuccess(`Imported ${totalImported} new entries from ${filename}`);\n } catch (err) {\n printError(`Failed to import memory: ${err.message}`);\n }\n}\n\nasync function clearMemory(subArgs, saveMemory, namespace) {\n if (!namespace || namespace === 'default') {\n const nsFromArgs = getNamespaceFromArgs(subArgs);\n if (!nsFromArgs) {\n printError('Usage: memory clear --namespace <namespace>');\n printWarning('This will clear all entries in the specified namespace');\n return;\n }\n namespace = nsFromArgs;\n }\n\n try {\n // Helper to load memory data\n async function loadMemory() {\n try {\n const content = await fs.readFile('./memory/memory-store.json', 'utf8');\n return JSON.parse(content);\n } catch {\n return {};\n }\n }\n \n const data = await loadMemory();\n\n if (!data[namespace]) {\n printWarning(`Namespace '${namespace}' does not exist`);\n return;\n }\n\n const entryCount = data[namespace].length;\n delete data[namespace];\n\n await saveMemory(data);\n printSuccess(`Cleared ${entryCount} entries from namespace '${namespace}'`);\n } catch (err) {\n printError(`Failed to clear memory: ${err.message}`);\n }\n}\n\nasync function listNamespaces(loadMemory) {\n try {\n const data = await loadMemory();\n const namespaces = Object.keys(data);\n\n if (namespaces.length === 0) {\n printWarning('No namespaces found');\n return;\n }\n\n printSuccess('Available namespaces:');\n for (const namespace of namespaces) {\n const count = data[namespace].length;\n console.log(` ${namespace} (${count} entries)`);\n }\n } catch (err) {\n printError(`Failed to list namespaces: ${err.message}`);\n }\n}\n\nfunction getNamespaceFromArgs(subArgs) {\n const namespaceIndex = subArgs.indexOf('--namespace');\n if (namespaceIndex !== -1 && namespaceIndex + 1 < subArgs.length) {\n return subArgs[namespaceIndex + 1];\n }\n\n const nsIndex = subArgs.indexOf('--ns');\n if (nsIndex !== -1 && nsIndex + 1 < subArgs.length) {\n return subArgs[nsIndex + 1];\n }\n\n return null;\n}\n\n// Helper to load memory data (needed for import function)\nasync function loadMemory() {\n try {\n const content = await fs.readFile('./memory/memory-store.json', 'utf8');\n return JSON.parse(content);\n } catch {\n return {};\n }\n}\n\nfunction showMemoryHelp() {\n console.log('Memory commands:');\n console.log(' store <key> <value> Store a key-value pair');\n console.log(' query <search> Search for entries');\n console.log(' stats Show memory statistics');\n console.log(' export [filename] Export memory to file');\n console.log(' import <filename> Import memory from file');\n console.log(' clear --namespace <ns> Clear a namespace');\n console.log(' list List all namespaces');\n console.log();\n console.log('Options:');\n console.log(' --namespace <ns> Specify namespace for operations');\n console.log(' --ns <ns> Short form of --namespace');\n console.log();\n console.log('Examples:');\n console.log(' memory store previous_work \"Research findings from yesterday\"');\n console.log(' memory query research --namespace sparc');\n console.log(' memory export backup.json --namespace default');\n console.log(' memory import project-memory.json');\n console.log(' memory stats');\n}\n"],"names":["printSuccess","printError","printWarning","promises","fs","memoryCommand","subArgs","flags","memorySubcommand","memoryStore","namespace","ns","getNamespaceFromArgs","loadMemory","content","readFile","JSON","parse","saveMemory","data","mkdir","recursive","writeFile","stringify","storeMemory","queryMemory","showMemoryStats","exportMemory","importMemory","clearMemory","listNamespaces","showMemoryHelp","key","value","slice","join","filter","e","push","timestamp","Date","now","console","log","TextEncoder","encode","length","err","message","search","results","entries","Object","entry","includes","sort","a","b","substring","toLocaleString","totalEntries","namespaceStats","keys","toFixed","count","filename","exportData","values","importContent","importData","existingData","totalImported","existingKeys","Set","map","newEntries","has","nsFromArgs","entryCount","namespaces","namespaceIndex","indexOf","nsIndex"],"mappings":"AACA,SAASA,YAAY,EAAEC,UAAU,EAAEC,YAAY,QAAmB,cAAc;AAChF,SAASC,YAAYC,EAAE,QAAQ,KAAK;AAIpC,OAAO,eAAeC,cAAcC,OAAO,EAAEC,KAAK;IAChD,MAAMC,mBAAmBF,OAAO,CAAC,EAAE;IACnC,MAAMG,cAAc;IAGpB,MAAMC,YAAYH,OAAOG,aAAaH,OAAOI,MAAMC,qBAAqBN,YAAY;IAGpF,eAAeO;QACb,IAAI;YACF,MAAMC,UAAU,MAAMV,GAAGW,QAAQ,CAACN,aAAa;YAC/C,OAAOO,KAAKC,KAAK,CAACH;QACpB,EAAE,OAAM;YACN,OAAO,CAAC;QACV;IACF;IAGA,eAAeI,WAAWC,IAAI;QAC5B,MAAMf,GAAGgB,KAAK,CAAC,YAAY;YAAEC,WAAW;QAAK;QAC7C,MAAMjB,GAAGkB,SAAS,CAACb,aAAaO,KAAKO,SAAS,CAACJ,MAAM,MAAM,GAAG;IAChE;IAEA,OAAQX;QACN,KAAK;YACH,MAAMgB,YAAYlB,SAASO,YAAYK,YAAYR;YACnD;QAEF,KAAK;YACH,MAAMe,YAAYnB,SAASO,YAAYH;YACvC;QAEF,KAAK;YACH,MAAMgB,gBAAgBb;YACtB;QAEF,KAAK;YACH,MAAMc,aAAarB,SAASO,YAAYH;YACxC;QAEF,KAAK;YACH,MAAMkB,aAAatB,SAASY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sources":["../../../../src/cli/simple-commands/memory.js"],"sourcesContent":["// memory.js - Memory management commands\nimport { printSuccess, printError, printWarning, printInfo } from '../utils.js';\nimport { promises as fs } from 'fs';\nimport { cwd, exit, existsSync } from '../node-compat.js';\nimport { getUnifiedMemory } from '../../memory/unified-memory-manager.js';\nimport { KeyRedactor } from '../../utils/key-redactor.js';\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\n\nconst execAsync = promisify(exec);\n\nexport async function memoryCommand(subArgs, flags) {\n const memorySubcommand = subArgs[0];\n const memoryStore = './memory/memory-store.json';\n\n // Extract namespace from flags or subArgs\n const namespace = flags?.namespace || flags?.ns || getNamespaceFromArgs(subArgs) || 'default';\n\n // Check for redaction flag\n const enableRedaction = flags?.redact || subArgs.includes('--redact') || subArgs.includes('--secure');\n\n // NEW: Detect memory mode (basic, reasoningbank, auto)\n const mode = await detectMemoryMode(flags, subArgs);\n\n // Helper to load memory data\n async function loadMemory() {\n try {\n const content = await fs.readFile(memoryStore, 'utf8');\n return JSON.parse(content);\n } catch {\n return {};\n }\n }\n\n // Helper to save memory data\n async function saveMemory(data) {\n await fs.mkdir('./memory', { recursive: true });\n await fs.writeFile(memoryStore, JSON.stringify(data, null, 2, 'utf8'));\n }\n\n // NEW: Handle ReasoningBank-specific commands\n if (mode === 'reasoningbank' && ['init', 'status', 'consolidate', 'demo', 'test', 'benchmark'].includes(memorySubcommand)) {\n return await handleReasoningBankCommand(memorySubcommand, subArgs, flags);\n }\n\n // NEW: Handle new mode management commands\n if (['detect', 'mode', 'migrate'].includes(memorySubcommand)) {\n return await handleModeCommand(memorySubcommand, subArgs, flags);\n }\n\n // NEW: Delegate to ReasoningBank for regular commands if mode is set\n if (mode === 'reasoningbank' && ['store', 'query', 'list'].includes(memorySubcommand)) {\n return await handleReasoningBankCommand(memorySubcommand, subArgs, flags);\n }\n\n switch (memorySubcommand) {\n case 'store':\n await storeMemory(subArgs, loadMemory, saveMemory, namespace, enableRedaction);\n break;\n\n case 'query':\n await queryMemory(subArgs, loadMemory, namespace, enableRedaction);\n break;\n\n case 'stats':\n await showMemoryStats(loadMemory);\n break;\n\n case 'export':\n await exportMemory(subArgs, loadMemory, namespace);\n break;\n\n case 'import':\n await importMemory(subArgs, saveMemory, loadMemory);\n break;\n\n case 'clear':\n await clearMemory(subArgs, saveMemory, namespace);\n break;\n\n case 'list':\n await listNamespaces(loadMemory);\n break;\n\n default:\n showMemoryHelp();\n }\n}\n\nasync function storeMemory(subArgs, loadMemory, saveMemory, namespace, enableRedaction = false) {\n const key = subArgs[1];\n let value = subArgs.slice(2).join(' ');\n\n if (!key || !value) {\n printError('Usage: memory store <key> <value> [--namespace <ns>] [--redact]');\n return;\n }\n\n try {\n // Apply redaction if enabled\n let redactedValue = value;\n let securityWarnings = [];\n\n if (enableRedaction) {\n redactedValue = KeyRedactor.redact(value, true);\n const validation = KeyRedactor.validate(value);\n\n if (!validation.safe) {\n securityWarnings = validation.warnings;\n printWarning('š Redaction enabled: Sensitive data detected and redacted');\n securityWarnings.forEach(warning => console.log(` ā ļø ${warning}`));\n }\n } else {\n // Even if redaction is not explicitly enabled, validate and warn\n const validation = KeyRedactor.validate(value);\n if (!validation.safe) {\n printWarning('ā ļø Potential sensitive data detected! Use --redact flag for automatic redaction');\n validation.warnings.forEach(warning => console.log(` ā ļø ${warning}`));\n console.log(' š” Tip: Add --redact flag to automatically redact API keys');\n }\n }\n\n const data = await loadMemory();\n\n if (!data[namespace]) {\n data[namespace] = [];\n }\n\n // Remove existing entry with same key\n data[namespace] = data[namespace].filter((e) => e.key !== key);\n\n // Add new entry with redacted value\n data[namespace].push({\n key,\n value: redactedValue,\n namespace,\n timestamp: Date.now(),\n redacted: enableRedaction && securityWarnings.length > 0,\n });\n\n await saveMemory(data);\n printSuccess(enableRedaction && securityWarnings.length > 0 ? 'š Stored successfully (with redaction)' : 'ā
Stored successfully');\n console.log(`š Key: ${key}`);\n console.log(`š¦ Namespace: ${namespace}`);\n console.log(`š¾ Size: ${new TextEncoder().encode(redactedValue).length} bytes`);\n if (enableRedaction && securityWarnings.length > 0) {\n console.log(`š Security: ${securityWarnings.length} sensitive pattern(s) redacted`);\n }\n } catch (err) {\n printError(`Failed to store: ${err.message}`);\n }\n}\n\nasync function queryMemory(subArgs, loadMemory, namespace, enableRedaction = false) {\n const search = subArgs.slice(1).join(' ');\n\n if (!search) {\n printError('Usage: memory query <search> [--namespace <ns>] [--redact]');\n return;\n }\n\n try {\n const data = await loadMemory();\n const results = [];\n\n for (const [ns, entries] of Object.entries(data)) {\n if (namespace && ns !== namespace) continue;\n\n for (const entry of entries) {\n if (entry.key.includes(search) || entry.value.includes(search)) {\n results.push(entry);\n }\n }\n }\n\n if (results.length === 0) {\n printWarning('No results found');\n return;\n }\n\n printSuccess(`Found ${results.length} results:`);\n\n // Sort by timestamp (newest first)\n results.sort((a, b) => b.timestamp - a.timestamp);\n\n for (const entry of results.slice(0, 10)) {\n console.log(`\\nš ${entry.key}`);\n console.log(` Namespace: ${entry.namespace}`);\n\n // Apply redaction to displayed value if requested\n let displayValue = entry.value;\n if (enableRedaction) {\n displayValue = KeyRedactor.redact(displayValue, true);\n }\n\n console.log(\n ` Value: ${displayValue.substring(0, 100)}${displayValue.length > 100 ? '...' : ''}`,\n );\n console.log(` Stored: ${new Date(entry.timestamp).toLocaleString()}`);\n\n // Show redaction status\n if (entry.redacted) {\n console.log(` š Status: Redacted on storage`);\n } else if (enableRedaction) {\n console.log(` š Status: Redacted for display`);\n }\n }\n\n if (results.length > 10) {\n console.log(`\\n... and ${results.length - 10} more results`);\n }\n } catch (err) {\n printError(`Failed to query: ${err.message}`);\n }\n}\n\nasync function showMemoryStats(loadMemory) {\n try {\n const data = await loadMemory();\n let totalEntries = 0;\n const namespaceStats = {};\n\n for (const [namespace, entries] of Object.entries(data)) {\n namespaceStats[namespace] = entries.length;\n totalEntries += entries.length;\n }\n\n printSuccess('Memory Bank Statistics:');\n console.log(` Total Entries: ${totalEntries}`);\n console.log(` Namespaces: ${Object.keys(data).length}`);\n console.log(\n ` Size: ${(new TextEncoder().encode(JSON.stringify(data)).length / 1024).toFixed(2)} KB`,\n );\n\n if (Object.keys(data).length > 0) {\n console.log('\\nš Namespace Breakdown:');\n for (const [namespace, count] of Object.entries(namespaceStats)) {\n console.log(` ${namespace}: ${count} entries`);\n }\n }\n } catch (err) {\n printError(`Failed to get stats: ${err.message}`);\n }\n}\n\nasync function exportMemory(subArgs, loadMemory, namespace) {\n const filename = subArgs[1] || `memory-export-${Date.now()}.json`;\n\n try {\n const data = await loadMemory();\n\n let exportData = data;\n if (namespace) {\n exportData = { [namespace]: data[namespace] || [] };\n }\n\n await fs.writeFile(filename, JSON.stringify(exportData, null, 2, 'utf8'));\n printSuccess(`Memory exported to ${filename}`);\n\n let totalEntries = 0;\n for (const entries of Object.values(exportData)) {\n totalEntries += entries.length;\n }\n console.log(\n `š¦ Exported ${totalEntries} entries from ${Object.keys(exportData).length} namespace(s)`,\n );\n } catch (err) {\n printError(`Failed to export memory: ${err.message}`);\n }\n}\n\nasync function importMemory(subArgs, saveMemory, loadMemory) {\n const filename = subArgs[1];\n\n if (!filename) {\n printError('Usage: memory import <filename>');\n return;\n }\n\n try {\n const importContent = await fs.readFile(filename, 'utf8');\n const importData = JSON.parse(importContent);\n\n // Load existing memory\n const existingData = await loadMemory();\n\n // Merge imported data\n let totalImported = 0;\n for (const [namespace, entries] of Object.entries(importData)) {\n if (!existingData[namespace]) {\n existingData[namespace] = [];\n }\n\n // Add entries that don't already exist (by key)\n const existingKeys = new Set(existingData[namespace].map((e) => e.key));\n const newEntries = entries.filter((e) => !existingKeys.has(e.key));\n\n existingData[namespace].push(...newEntries);\n totalImported += newEntries.length;\n }\n\n await saveMemory(existingData);\n printSuccess(`Imported ${totalImported} new entries from ${filename}`);\n } catch (err) {\n printError(`Failed to import memory: ${err.message}`);\n }\n}\n\nasync function clearMemory(subArgs, saveMemory, namespace) {\n if (!namespace || namespace === 'default') {\n const nsFromArgs = getNamespaceFromArgs(subArgs);\n if (!nsFromArgs) {\n printError('Usage: memory clear --namespace <namespace>');\n printWarning('This will clear all entries in the specified namespace');\n return;\n }\n namespace = nsFromArgs;\n }\n\n try {\n // Helper to load memory data\n async function loadMemory() {\n try {\n const content = await fs.readFile('./memory/memory-store.json', 'utf8');\n return JSON.parse(content);\n } catch {\n return {};\n }\n }\n \n const data = await loadMemory();\n\n if (!data[namespace]) {\n printWarning(`Namespace '${namespace}' does not exist`);\n return;\n }\n\n const entryCount = data[namespace].length;\n delete data[namespace];\n\n await saveMemory(data);\n printSuccess(`Cleared ${entryCount} entries from namespace '${namespace}'`);\n } catch (err) {\n printError(`Failed to clear memory: ${err.message}`);\n }\n}\n\nasync function listNamespaces(loadMemory) {\n try {\n const data = await loadMemory();\n const namespaces = Object.keys(data);\n\n if (namespaces.length === 0) {\n printWarning('No namespaces found');\n return;\n }\n\n printSuccess('Available namespaces:');\n for (const namespace of namespaces) {\n const count = data[namespace].length;\n console.log(` ${namespace} (${count} entries)`);\n }\n } catch (err) {\n printError(`Failed to list namespaces: ${err.message}`);\n }\n}\n\nfunction getNamespaceFromArgs(subArgs) {\n const namespaceIndex = subArgs.indexOf('--namespace');\n if (namespaceIndex !== -1 && namespaceIndex + 1 < subArgs.length) {\n return subArgs[namespaceIndex + 1];\n }\n\n const nsIndex = subArgs.indexOf('--ns');\n if (nsIndex !== -1 && nsIndex + 1 < subArgs.length) {\n return subArgs[nsIndex + 1];\n }\n\n return null;\n}\n\n// Helper to load memory data (needed for import function)\nasync function loadMemory() {\n try {\n const content = await fs.readFile('./memory/memory-store.json', 'utf8');\n return JSON.parse(content);\n } catch {\n return {};\n }\n}\n\n// NEW: Mode detection function\nasync function detectMemoryMode(flags, subArgs) {\n // Explicit ReasoningBank flag takes precedence\n if (flags?.reasoningbank || flags?.rb || subArgs.includes('--reasoningbank') || subArgs.includes('--rb')) {\n return 'reasoningbank';\n }\n\n // Auto mode: detect if ReasoningBank is initialized\n if (flags?.auto || subArgs.includes('--auto')) {\n const initialized = await isReasoningBankInitialized();\n return initialized ? 'reasoningbank' : 'basic';\n }\n\n // Default: basic mode (backward compatible)\n return 'basic';\n}\n\n// NEW: Check if ReasoningBank is initialized\nasync function isReasoningBankInitialized() {\n try {\n // Check if .swarm/memory.db exists\n const dbPath = '.swarm/memory.db';\n await fs.access(dbPath);\n return true;\n } catch {\n return false;\n }\n}\n\n// NEW: Handle ReasoningBank commands\nasync function handleReasoningBankCommand(command, subArgs, flags) {\n const initialized = await isReasoningBankInitialized();\n\n // Special handling for 'init' command\n if (command === 'init') {\n if (initialized) {\n printWarning('ā ļø ReasoningBank already initialized');\n console.log('Database: .swarm/memory.db');\n console.log('\\nTo reinitialize, delete .swarm/memory.db first');\n return;\n }\n\n printInfo('š§ Initializing ReasoningBank...');\n console.log('This will create: .swarm/memory.db\\n');\n\n try {\n const { stdout, stderr } = await execAsync('npx agentic-flow reasoningbank init', {\n timeout: 30000,\n });\n\n if (stdout) console.log(stdout);\n printSuccess('ā
ReasoningBank initialized successfully!');\n console.log('\\nNext steps:');\n console.log(' 1. Store memories: memory store key \"value\" --reasoningbank');\n console.log(' 2. Query memories: memory query \"search\" --reasoningbank');\n console.log(' 3. Check status: memory status --reasoningbank');\n } catch (error) {\n printError('ā Failed to initialize ReasoningBank');\n console.error(error.message);\n if (error.stderr) {\n console.error('Details:', error.stderr);\n }\n }\n return;\n }\n\n // All other commands require initialization\n if (!initialized) {\n printError('ā ReasoningBank not initialized');\n console.log('\\nTo use ReasoningBank mode, first run:');\n console.log(' memory init --reasoningbank\\n');\n return;\n }\n\n // Delegate to agentic-flow reasoningbank commands\n printInfo(`š§ Using ReasoningBank mode...`);\n\n try {\n const cmd = buildReasoningBankCommand(command, subArgs, flags);\n const { stdout, stderr } = await execAsync(cmd, { timeout: 30000 });\n\n if (stdout) console.log(stdout);\n if (stderr && !stderr.includes('Warning')) console.error(stderr);\n } catch (error) {\n printError(`ā ReasoningBank command failed`);\n console.error(error.message);\n }\n}\n\n// NEW: Build agentic-flow reasoningbank command\nfunction buildReasoningBankCommand(command, subArgs, flags) {\n const parts = ['npx', 'agentic-flow', 'reasoningbank'];\n\n // Map memory commands to reasoningbank commands\n const commandMap = {\n store: 'store',\n query: 'query',\n list: 'list',\n status: 'status',\n consolidate: 'consolidate',\n demo: 'demo',\n test: 'test',\n benchmark: 'benchmark',\n };\n\n parts.push(commandMap[command] || command);\n\n // Add arguments (skip the command itself)\n const args = subArgs.slice(1);\n args.forEach((arg) => {\n if (!arg.startsWith('--reasoningbank') && !arg.startsWith('--rb') && !arg.startsWith('--auto')) {\n parts.push(`\"${arg}\"`);\n }\n });\n\n return parts.join(' ');\n}\n\n// NEW: Handle mode management commands\nasync function handleModeCommand(command, subArgs, flags) {\n switch (command) {\n case 'detect':\n await detectModes();\n break;\n\n case 'mode':\n await showCurrentMode();\n break;\n\n case 'migrate':\n await migrateMemory(subArgs, flags);\n break;\n\n default:\n printError(`Unknown mode command: ${command}`);\n }\n}\n\n// NEW: Detect and show available memory modes\nasync function detectModes() {\n printInfo('š Detecting memory modes...\\n');\n\n // Check basic mode\n const basicAvailable = await checkBasicMode();\n console.log(basicAvailable ? 'ā
Basic Mode (active)' : 'ā Basic Mode (unavailable)');\n if (basicAvailable) {\n console.log(' Location: ./memory/memory-store.json');\n console.log(' Features: Simple key-value storage, fast');\n }\n\n console.log('');\n\n // Check ReasoningBank mode\n const rbAvailable = await isReasoningBankInitialized();\n console.log(rbAvailable ? 'ā
ReasoningBank Mode (available)' : 'ā ļø ReasoningBank Mode (not initialized)');\n if (rbAvailable) {\n console.log(' Location: .swarm/memory.db');\n console.log(' Features: AI-powered semantic search, learning');\n } else {\n console.log(' To enable: memory init --reasoningbank');\n }\n\n console.log('\\nš” Usage:');\n console.log(' Basic: memory store key \"value\"');\n console.log(' ReasoningBank: memory store key \"value\" --reasoningbank');\n console.log(' Auto-detect: memory query search --auto');\n}\n\n// NEW: Check if basic mode is available\nasync function checkBasicMode() {\n try {\n const memoryDir = './memory';\n await fs.access(memoryDir);\n return true;\n } catch {\n // Create directory if it doesn't exist\n try {\n await fs.mkdir(memoryDir, { recursive: true });\n return true;\n } catch {\n return false;\n }\n }\n}\n\n// NEW: Show current default mode\nasync function showCurrentMode() {\n const rbInitialized = await isReasoningBankInitialized();\n\n printInfo('š Current Memory Configuration:\\n');\n console.log('Default Mode: Basic (backward compatible)');\n console.log('Available Modes:');\n console.log(' ⢠Basic Mode: Always available');\n console.log(` ⢠ReasoningBank Mode: ${rbInitialized ? 'Initialized ā
' : 'Not initialized ā ļø'}`);\n\n console.log('\\nš” To use a specific mode:');\n console.log(' --reasoningbank or --rb ā Use ReasoningBank');\n console.log(' --auto ā Auto-detect best mode');\n console.log(' (no flag) ā Use Basic mode');\n}\n\n// NEW: Migrate memory between modes\nasync function migrateMemory(subArgs, flags) {\n const targetMode = flags?.to || getArgValue(subArgs, '--to');\n\n if (!targetMode || !['basic', 'reasoningbank'].includes(targetMode)) {\n printError('Usage: memory migrate --to <basic|reasoningbank>');\n return;\n }\n\n printInfo(`š Migrating to ${targetMode} mode...\\n`);\n\n if (targetMode === 'reasoningbank') {\n // Migrate basic ā ReasoningBank\n const rbInitialized = await isReasoningBankInitialized();\n if (!rbInitialized) {\n printError('ā ReasoningBank not initialized');\n console.log('First run: memory init --reasoningbank\\n');\n return;\n }\n\n printWarning('ā ļø Migration from basic to ReasoningBank is not yet implemented');\n console.log('This feature is coming in v2.7.1\\n');\n console.log('For now, you can:');\n console.log(' 1. Export basic memory: memory export backup.json');\n console.log(' 2. Manually import to ReasoningBank');\n } else {\n // Migrate ReasoningBank ā basic\n printWarning('ā ļø Migration from ReasoningBank to basic is not yet implemented');\n console.log('This feature is coming in v2.7.1\\n');\n }\n}\n\n// Helper to get argument value\nfunction getArgValue(args, flag) {\n const index = args.indexOf(flag);\n if (index !== -1 && index + 1 < args.length) {\n return args[index + 1];\n }\n return null;\n}\n\nfunction showMemoryHelp() {\n console.log('Memory commands:');\n console.log(' store <key> <value> Store a key-value pair');\n console.log(' query <search> Search for entries');\n console.log(' stats Show memory statistics');\n console.log(' export [filename] Export memory to file');\n console.log(' import <filename> Import memory from file');\n console.log(' clear --namespace <ns> Clear a namespace');\n console.log(' list List all namespaces');\n console.log();\n console.log('š§ ReasoningBank Commands (NEW in v2.7.0):');\n console.log(' init --reasoningbank Initialize ReasoningBank (AI-powered memory)');\n console.log(' status --reasoningbank Show ReasoningBank statistics');\n console.log(' detect Show available memory modes');\n console.log(' mode Show current memory configuration');\n console.log(' migrate --to <mode> Migrate between basic/reasoningbank');\n console.log();\n console.log('Options:');\n console.log(' --namespace <ns> Specify namespace for operations');\n console.log(' --ns <ns> Short form of --namespace');\n console.log(' --redact š Enable API key redaction (security feature)');\n console.log(' --secure Alias for --redact');\n console.log();\n console.log('šÆ Mode Selection (NEW):');\n console.log(' --reasoningbank, --rb Use ReasoningBank mode (AI-powered)');\n console.log(' --auto Auto-detect best available mode');\n console.log(' (no flag) Use Basic mode (default, backward compatible)');\n console.log();\n console.log('š Security Features (v2.6.0):');\n console.log(' API Key Protection: Automatically detects and redacts sensitive data');\n console.log(' Patterns Detected: Anthropic, OpenRouter, Gemini, Bearer tokens, etc.');\n console.log(' Auto-Validation: Warns when storing unredacted sensitive data');\n console.log(' Display Redaction: Redact sensitive data when querying with --redact');\n console.log();\n console.log('Examples:');\n console.log(' # Basic mode (default - backward compatible)');\n console.log(' memory store previous_work \"Research findings from yesterday\"');\n console.log(' memory store api_config \"key=sk-ant-...\" --redact # š Redacts API key');\n console.log(' memory query research --namespace sparc');\n console.log();\n console.log(' # ReasoningBank mode (AI-powered, opt-in)');\n console.log(' memory init --reasoningbank # One-time setup');\n console.log(' memory store api_pattern \"Always use env vars\" --reasoningbank');\n console.log(' memory query \"API configuration\" --reasoningbank # Semantic search!');\n console.log(' memory status --reasoningbank # Show AI metrics');\n console.log();\n console.log(' # Auto-detect mode (smart selection)');\n console.log(' memory query config --auto # Uses ReasoningBank if available');\n console.log();\n console.log(' # Mode management');\n console.log(' memory detect # Show available modes');\n console.log(' memory mode # Show current configuration');\n console.log();\n console.log('š” Tips:');\n console.log(' ⢠Use Basic mode for simple key-value storage (fast, always available)');\n console.log(' ⢠Use ReasoningBank for AI-powered semantic search (learns from patterns)');\n console.log(' ⢠Use --auto to let claude-flow choose the best mode for you');\n console.log(' ⢠Always use --redact when storing API keys or secrets!');\n}\n"],"names":["printSuccess","printError","printWarning","printInfo","promises","fs","KeyRedactor","exec","promisify","execAsync","memoryCommand","subArgs","flags","memorySubcommand","memoryStore","namespace","ns","getNamespaceFromArgs","enableRedaction","redact","includes","mode","detectMemoryMode","loadMemory","content","readFile","JSON","parse","saveMemory","data","mkdir","recursive","writeFile","stringify","handleReasoningBankCommand","handleModeCommand","storeMemory","queryMemory","showMemoryStats","exportMemory","importMemory","clearMemory","listNamespaces","showMemoryHelp","key","value","slice","join","redactedValue","securityWarnings","validation","validate","safe","warnings","forEach","warning","console","log","filter","e","push","timestamp","Date","now","redacted","length","TextEncoder","encode","err","message","search","results","entries","Object","entry","sort","a","b","displayValue","substring","toLocaleString","totalEntries","namespaceStats","keys","toFixed","count","filename","exportData","values","importContent","importData","existingData","totalImported","existingKeys","Set","map","newEntries","has","nsFromArgs","entryCount","namespaces","namespaceIndex","indexOf","nsIndex","reasoningbank","rb","auto","initialized","isReasoningBankInitialized","dbPath","access","command","stdout","stderr","timeout","error","cmd","buildReasoningBankCommand","parts","commandMap","store","query","list","status","consolidate","demo","test","benchmark","args","arg","startsWith","detectModes","showCurrentMode","migrateMemory","basicAvailable","checkBasicMode","rbAvailable","memoryDir","rbInitialized","targetMode","to","getArgValue","flag","index"],"mappings":"AACA,SAASA,YAAY,EAAEC,UAAU,EAAEC,YAAY,EAAEC,SAAS,QAAQ,cAAc;AAChF,SAASC,YAAYC,EAAE,QAAQ,KAAK;AAGpC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,SAAS,QAAQ,OAAO;AAEjC,MAAMC,YAA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