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