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.
Files changed (154) hide show
  1. package/.claude/agents/reasoning/README.md +171 -0
  2. package/.claude/agents/reasoning/agent.md +816 -0
  3. package/.claude/agents/reasoning/example-reasoning-agent-template.md +362 -0
  4. package/.claude/agents/reasoning/goal-planner.md +73 -0
  5. package/.claude/commands/coordination/README.md +9 -0
  6. package/.claude/commands/memory/README.md +9 -0
  7. package/.claude/settings.json +3 -3
  8. package/.claude/sparc-modes.json +108 -0
  9. package/README.md +1 -6
  10. package/bin/claude-flow +1 -1
  11. package/dist/src/cli/command-registry.js +70 -6
  12. package/dist/src/cli/command-registry.js.map +1 -1
  13. package/dist/src/cli/help-formatter.js +5 -3
  14. package/dist/src/cli/help-formatter.js.map +1 -1
  15. package/dist/src/cli/help-text.js +53 -5
  16. package/dist/src/cli/help-text.js.map +1 -1
  17. package/dist/src/cli/simple-cli.js +182 -172
  18. package/dist/src/cli/simple-cli.js.map +1 -1
  19. package/dist/src/cli/simple-commands/agent-booster.js +415 -0
  20. package/dist/src/cli/simple-commands/agent-booster.js.map +1 -0
  21. package/dist/src/cli/simple-commands/agent.js +856 -13
  22. package/dist/src/cli/simple-commands/agent.js.map +1 -1
  23. package/dist/src/cli/simple-commands/config.js +115 -257
  24. package/dist/src/cli/simple-commands/config.js.map +1 -1
  25. package/dist/src/cli/simple-commands/env-template.js +180 -0
  26. package/dist/src/cli/simple-commands/env-template.js.map +1 -0
  27. package/dist/src/cli/simple-commands/init/help.js +23 -0
  28. package/dist/src/cli/simple-commands/init/help.js.map +1 -1
  29. package/dist/src/cli/simple-commands/init/index.js +63 -0
  30. package/dist/src/cli/simple-commands/init/index.js.map +1 -1
  31. package/dist/src/cli/simple-commands/memory.js +414 -16
  32. package/dist/src/cli/simple-commands/memory.js.map +1 -1
  33. package/dist/src/cli/simple-commands/proxy.js +304 -0
  34. package/dist/src/cli/simple-commands/proxy.js.map +1 -0
  35. package/dist/src/cli/simple-commands/sparc.js +16 -19
  36. package/dist/src/cli/simple-commands/sparc.js.map +1 -1
  37. package/dist/src/cli/validation-helper.js.map +1 -1
  38. package/dist/src/core/version.js +1 -1
  39. package/dist/src/execution/agent-executor.js +181 -0
  40. package/dist/src/execution/agent-executor.js.map +1 -0
  41. package/dist/src/execution/index.js +12 -0
  42. package/dist/src/execution/index.js.map +1 -0
  43. package/dist/src/execution/provider-manager.js +110 -0
  44. package/dist/src/execution/provider-manager.js.map +1 -0
  45. package/dist/src/hooks/redaction-hook.js +89 -0
  46. package/dist/src/hooks/redaction-hook.js.map +1 -0
  47. package/dist/src/memory/swarm-memory.js +340 -421
  48. package/dist/src/memory/swarm-memory.js.map +1 -1
  49. package/dist/src/reasoningbank/reasoningbank-adapter.js +144 -0
  50. package/dist/src/reasoningbank/reasoningbank-adapter.js.map +1 -0
  51. package/dist/src/utils/key-redactor.js +108 -0
  52. package/dist/src/utils/key-redactor.js.map +1 -0
  53. package/dist/src/utils/metrics-reader.js.map +1 -1
  54. package/docs/AGENT-BOOSTER-INTEGRATION.md +407 -0
  55. package/docs/AGENTIC-FLOW-INTEGRATION-GUIDE.md +753 -0
  56. package/docs/AGENTIC_FLOW_EXECUTION_FIX_REPORT.md +474 -0
  57. package/docs/AGENTIC_FLOW_INTEGRATION_STATUS.md +143 -0
  58. package/docs/AGENTIC_FLOW_MVP_COMPLETE.md +367 -0
  59. package/docs/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +369 -0
  60. package/docs/COMMAND-VERIFICATION-REPORT.md +441 -0
  61. package/docs/COMMIT_SUMMARY.md +247 -0
  62. package/docs/DEEP_REVIEW_COMPREHENSIVE_REPORT.md +922 -0
  63. package/docs/DOCKER-VALIDATION-REPORT.md +281 -0
  64. package/docs/ENV-SETUP-GUIDE.md +270 -0
  65. package/docs/FINAL_PRE_PUBLISH_VALIDATION.md +823 -0
  66. package/docs/FINAL_VALIDATION_REPORT.md +165 -0
  67. package/docs/HOOKS-V2-MODIFICATION.md +146 -0
  68. package/docs/INDEX.md +568 -0
  69. package/docs/INTEGRATION_COMPLETE.md +414 -0
  70. package/docs/MEMORY_REDACTION_TEST_REPORT.md +300 -0
  71. package/docs/PERFORMANCE-SYSTEMS-STATUS.md +340 -0
  72. package/docs/PRE_RELEASE_FIXES_REPORT.md +435 -0
  73. package/docs/README.md +35 -0
  74. package/docs/REASONING-AGENTS.md +482 -0
  75. package/docs/REASONINGBANK-AGENT-CREATION-GUIDE.md +813 -0
  76. package/docs/REASONINGBANK-ANALYSIS-COMPLETE.md +479 -0
  77. package/docs/REASONINGBANK-BENCHMARK-RESULTS.md +166 -0
  78. package/docs/REASONINGBANK-BENCHMARK.md +396 -0
  79. package/docs/REASONINGBANK-CLI-INTEGRATION.md +455 -0
  80. package/docs/REASONINGBANK-CORE-INTEGRATION.md +658 -0
  81. package/docs/REASONINGBANK-COST-OPTIMIZATION.md +329 -0
  82. package/docs/REASONINGBANK-DEMO.md +419 -0
  83. package/docs/REASONINGBANK-INTEGRATION-COMPLETE.md +249 -0
  84. package/docs/REASONINGBANK-INTEGRATION-STATUS.md +179 -0
  85. package/docs/REASONINGBANK-VALIDATION.md +532 -0
  86. package/docs/REASONINGBANK_ARCHITECTURE.md +475 -0
  87. package/docs/REASONINGBANK_INTEGRATION_COMPLETE.md +558 -0
  88. package/docs/REASONINGBANK_INTEGRATION_PLAN.md +1188 -0
  89. package/docs/REGRESSION-ANALYSIS-REPORT.md +500 -0
  90. package/docs/RELEASE_v2.6.0-alpha.2.md +658 -0
  91. package/docs/api/API_DOCUMENTATION.md +721 -0
  92. package/docs/architecture/ARCHITECTURE.md +1690 -0
  93. package/docs/ci-cd/README.md +368 -0
  94. package/docs/development/DEPLOYMENT.md +2348 -0
  95. package/docs/development/DEVELOPMENT_WORKFLOW.md +1333 -0
  96. package/docs/development/build-analysis-report.md +252 -0
  97. package/docs/development/pair-optimization.md +156 -0
  98. package/docs/development/token-tracking-status.md +103 -0
  99. package/docs/development/training-pipeline-demo.md +163 -0
  100. package/docs/development/training-pipeline-real-only.md +196 -0
  101. package/docs/epic-sdk-integration.md +1269 -0
  102. package/docs/experimental/RIEMANN_HYPOTHESIS_PROOF.md +124 -0
  103. package/docs/experimental/computational_verification.py +436 -0
  104. package/docs/experimental/novel_approaches.md +560 -0
  105. package/docs/experimental/riemann_hypothesis_analysis.md +263 -0
  106. package/docs/experimental/riemann_proof_attempt.md +124 -0
  107. package/docs/experimental/riemann_synthesis.md +277 -0
  108. package/docs/experimental/verification_results.json +12 -0
  109. package/docs/experimental/visualization_insights.md +720 -0
  110. package/docs/guides/USER_GUIDE.md +1138 -0
  111. package/docs/guides/token-tracking-guide.md +291 -0
  112. package/docs/reference/AGENTS.md +1011 -0
  113. package/docs/reference/MCP_TOOLS.md +2188 -0
  114. package/docs/reference/SPARC.md +717 -0
  115. package/docs/reference/SWARM.md +2000 -0
  116. package/docs/sdk/CLAUDE-CODE-SDK-DEEP-ANALYSIS.md +649 -0
  117. package/docs/sdk/CLAUDE-FLOW-SDK-INTEGRATION-ANALYSIS.md +242 -0
  118. package/docs/sdk/INTEGRATION-ROADMAP.md +420 -0
  119. package/docs/sdk/MCP-TOOLS-UPDATE.md +270 -0
  120. package/docs/sdk/SDK-ADVANCED-FEATURES-INTEGRATION.md +723 -0
  121. package/docs/sdk/SDK-ALL-FEATURES-INTEGRATION-MATRIX.md +612 -0
  122. package/docs/sdk/SDK-INTEGRATION-COMPLETE.md +358 -0
  123. package/docs/sdk/SDK-INTEGRATION-PHASES-V2.5.md +750 -0
  124. package/docs/sdk/SDK-LEVERAGE-REAL-FEATURES.md +676 -0
  125. package/docs/sdk/SDK-VALIDATION-RESULTS.md +400 -0
  126. package/docs/sdk/epic-sdk-integration.md +1269 -0
  127. package/docs/setup/remote-setup.md +93 -0
  128. package/docs/validation/final-validation-summary.md +220 -0
  129. package/docs/validation/verification-integration.md +190 -0
  130. package/docs/validation/verification-validation.md +349 -0
  131. package/docs/wiki/background-commands.md +1213 -0
  132. package/docs/wiki/session-persistence.md +342 -0
  133. package/docs/wiki/stream-chain-command.md +537 -0
  134. package/package.json +4 -2
  135. package/src/cli/command-registry.js +70 -5
  136. package/src/cli/help-text.js +26 -5
  137. package/src/cli/simple-cli.ts +18 -7
  138. package/src/cli/simple-commands/agent-booster.js +515 -0
  139. package/src/cli/simple-commands/agent.js +1001 -12
  140. package/src/cli/simple-commands/agent.ts +137 -0
  141. package/src/cli/simple-commands/config.ts +127 -0
  142. package/src/cli/simple-commands/env-template.js +190 -0
  143. package/src/cli/simple-commands/init/help.js +23 -0
  144. package/src/cli/simple-commands/init/index.js +84 -6
  145. package/src/cli/simple-commands/memory.js +497 -16
  146. package/src/cli/simple-commands/proxy.js +384 -0
  147. package/src/cli/simple-commands/sparc.js +16 -19
  148. package/src/execution/agent-executor.ts +306 -0
  149. package/src/execution/index.ts +19 -0
  150. package/src/execution/provider-manager.ts +187 -0
  151. package/src/hooks/redaction-hook.ts +115 -0
  152. package/src/reasoningbank/reasoningbank-adapter.js +191 -0
  153. package/src/utils/key-redactor.js +178 -0
  154. 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
- const value = subArgs.slice(2).join(' ');
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(value).length} bytes`);
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
- console.log(` Value: ${entry.value.substring(0, 100)}${entry.value.length > 100 ? '...' : ''}`);
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(' memory export backup.json --namespace default');
267
- console.log(' memory import project-memory.json');
268
- console.log(' memory stats');
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