claude-flow 2.5.0-alpha.141 → 2.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/reasoning/README.md +171 -0
- package/.claude/agents/reasoning/agent.md +816 -0
- package/.claude/agents/reasoning/example-reasoning-agent-template.md +362 -0
- package/.claude/agents/reasoning/goal-planner.md +73 -0
- package/.claude/commands/coordination/README.md +9 -0
- package/.claude/commands/memory/README.md +9 -0
- package/.claude/settings.json +3 -3
- package/.claude/sparc-modes.json +108 -0
- package/README.md +1 -6
- package/bin/claude-flow +1 -1
- package/dist/src/cli/command-registry.js +70 -6
- package/dist/src/cli/command-registry.js.map +1 -1
- package/dist/src/cli/help-formatter.js +5 -3
- package/dist/src/cli/help-formatter.js.map +1 -1
- package/dist/src/cli/help-text.js +53 -5
- package/dist/src/cli/help-text.js.map +1 -1
- package/dist/src/cli/simple-cli.js +182 -172
- package/dist/src/cli/simple-cli.js.map +1 -1
- package/dist/src/cli/simple-commands/agent-booster.js +415 -0
- package/dist/src/cli/simple-commands/agent-booster.js.map +1 -0
- package/dist/src/cli/simple-commands/agent.js +856 -13
- package/dist/src/cli/simple-commands/agent.js.map +1 -1
- package/dist/src/cli/simple-commands/config.js +115 -257
- package/dist/src/cli/simple-commands/config.js.map +1 -1
- package/dist/src/cli/simple-commands/env-template.js +180 -0
- package/dist/src/cli/simple-commands/env-template.js.map +1 -0
- package/dist/src/cli/simple-commands/init/help.js +23 -0
- package/dist/src/cli/simple-commands/init/help.js.map +1 -1
- package/dist/src/cli/simple-commands/init/index.js +63 -0
- package/dist/src/cli/simple-commands/init/index.js.map +1 -1
- package/dist/src/cli/simple-commands/memory.js +414 -16
- package/dist/src/cli/simple-commands/memory.js.map +1 -1
- package/dist/src/cli/simple-commands/proxy.js +304 -0
- package/dist/src/cli/simple-commands/proxy.js.map +1 -0
- package/dist/src/cli/simple-commands/sparc.js +16 -19
- package/dist/src/cli/simple-commands/sparc.js.map +1 -1
- package/dist/src/cli/validation-helper.js.map +1 -1
- package/dist/src/core/version.js +1 -1
- package/dist/src/execution/agent-executor.js +181 -0
- package/dist/src/execution/agent-executor.js.map +1 -0
- package/dist/src/execution/index.js +12 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/provider-manager.js +110 -0
- package/dist/src/execution/provider-manager.js.map +1 -0
- package/dist/src/hooks/redaction-hook.js +89 -0
- package/dist/src/hooks/redaction-hook.js.map +1 -0
- package/dist/src/memory/swarm-memory.js +340 -421
- package/dist/src/memory/swarm-memory.js.map +1 -1
- package/dist/src/reasoningbank/reasoningbank-adapter.js +144 -0
- package/dist/src/reasoningbank/reasoningbank-adapter.js.map +1 -0
- package/dist/src/utils/key-redactor.js +108 -0
- package/dist/src/utils/key-redactor.js.map +1 -0
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/AGENT-BOOSTER-INTEGRATION.md +407 -0
- package/docs/AGENTIC-FLOW-INTEGRATION-GUIDE.md +753 -0
- package/docs/AGENTIC_FLOW_EXECUTION_FIX_REPORT.md +474 -0
- package/docs/AGENTIC_FLOW_INTEGRATION_STATUS.md +143 -0
- package/docs/AGENTIC_FLOW_MVP_COMPLETE.md +367 -0
- package/docs/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +369 -0
- package/docs/COMMAND-VERIFICATION-REPORT.md +441 -0
- package/docs/COMMIT_SUMMARY.md +247 -0
- package/docs/DEEP_REVIEW_COMPREHENSIVE_REPORT.md +922 -0
- package/docs/DOCKER-VALIDATION-REPORT.md +281 -0
- package/docs/ENV-SETUP-GUIDE.md +270 -0
- package/docs/FINAL_PRE_PUBLISH_VALIDATION.md +823 -0
- package/docs/FINAL_VALIDATION_REPORT.md +165 -0
- package/docs/HOOKS-V2-MODIFICATION.md +146 -0
- package/docs/INDEX.md +568 -0
- package/docs/INTEGRATION_COMPLETE.md +414 -0
- package/docs/MEMORY_REDACTION_TEST_REPORT.md +300 -0
- package/docs/PERFORMANCE-SYSTEMS-STATUS.md +340 -0
- package/docs/PRE_RELEASE_FIXES_REPORT.md +435 -0
- package/docs/README.md +35 -0
- package/docs/REASONING-AGENTS.md +482 -0
- package/docs/REASONINGBANK-AGENT-CREATION-GUIDE.md +813 -0
- package/docs/REASONINGBANK-ANALYSIS-COMPLETE.md +479 -0
- package/docs/REASONINGBANK-BENCHMARK-RESULTS.md +166 -0
- package/docs/REASONINGBANK-BENCHMARK.md +396 -0
- package/docs/REASONINGBANK-CLI-INTEGRATION.md +455 -0
- package/docs/REASONINGBANK-CORE-INTEGRATION.md +658 -0
- package/docs/REASONINGBANK-COST-OPTIMIZATION.md +329 -0
- package/docs/REASONINGBANK-DEMO.md +419 -0
- package/docs/REASONINGBANK-INTEGRATION-COMPLETE.md +249 -0
- package/docs/REASONINGBANK-INTEGRATION-STATUS.md +179 -0
- package/docs/REASONINGBANK-VALIDATION.md +532 -0
- package/docs/REASONINGBANK_ARCHITECTURE.md +475 -0
- package/docs/REASONINGBANK_INTEGRATION_COMPLETE.md +558 -0
- package/docs/REASONINGBANK_INTEGRATION_PLAN.md +1188 -0
- package/docs/REGRESSION-ANALYSIS-REPORT.md +500 -0
- package/docs/RELEASE_v2.6.0-alpha.2.md +658 -0
- package/docs/api/API_DOCUMENTATION.md +721 -0
- package/docs/architecture/ARCHITECTURE.md +1690 -0
- package/docs/ci-cd/README.md +368 -0
- package/docs/development/DEPLOYMENT.md +2348 -0
- package/docs/development/DEVELOPMENT_WORKFLOW.md +1333 -0
- package/docs/development/build-analysis-report.md +252 -0
- package/docs/development/pair-optimization.md +156 -0
- package/docs/development/token-tracking-status.md +103 -0
- package/docs/development/training-pipeline-demo.md +163 -0
- package/docs/development/training-pipeline-real-only.md +196 -0
- package/docs/epic-sdk-integration.md +1269 -0
- package/docs/experimental/RIEMANN_HYPOTHESIS_PROOF.md +124 -0
- package/docs/experimental/computational_verification.py +436 -0
- package/docs/experimental/novel_approaches.md +560 -0
- package/docs/experimental/riemann_hypothesis_analysis.md +263 -0
- package/docs/experimental/riemann_proof_attempt.md +124 -0
- package/docs/experimental/riemann_synthesis.md +277 -0
- package/docs/experimental/verification_results.json +12 -0
- package/docs/experimental/visualization_insights.md +720 -0
- package/docs/guides/USER_GUIDE.md +1138 -0
- package/docs/guides/token-tracking-guide.md +291 -0
- package/docs/reference/AGENTS.md +1011 -0
- package/docs/reference/MCP_TOOLS.md +2188 -0
- package/docs/reference/SPARC.md +717 -0
- package/docs/reference/SWARM.md +2000 -0
- package/docs/sdk/CLAUDE-CODE-SDK-DEEP-ANALYSIS.md +649 -0
- package/docs/sdk/CLAUDE-FLOW-SDK-INTEGRATION-ANALYSIS.md +242 -0
- package/docs/sdk/INTEGRATION-ROADMAP.md +420 -0
- package/docs/sdk/MCP-TOOLS-UPDATE.md +270 -0
- package/docs/sdk/SDK-ADVANCED-FEATURES-INTEGRATION.md +723 -0
- package/docs/sdk/SDK-ALL-FEATURES-INTEGRATION-MATRIX.md +612 -0
- package/docs/sdk/SDK-INTEGRATION-COMPLETE.md +358 -0
- package/docs/sdk/SDK-INTEGRATION-PHASES-V2.5.md +750 -0
- package/docs/sdk/SDK-LEVERAGE-REAL-FEATURES.md +676 -0
- package/docs/sdk/SDK-VALIDATION-RESULTS.md +400 -0
- package/docs/sdk/epic-sdk-integration.md +1269 -0
- package/docs/setup/remote-setup.md +93 -0
- package/docs/validation/final-validation-summary.md +220 -0
- package/docs/validation/verification-integration.md +190 -0
- package/docs/validation/verification-validation.md +349 -0
- package/docs/wiki/background-commands.md +1213 -0
- package/docs/wiki/session-persistence.md +342 -0
- package/docs/wiki/stream-chain-command.md +537 -0
- package/package.json +4 -2
- package/src/cli/command-registry.js +70 -5
- package/src/cli/help-text.js +26 -5
- package/src/cli/simple-cli.ts +18 -7
- package/src/cli/simple-commands/agent-booster.js +515 -0
- package/src/cli/simple-commands/agent.js +1001 -12
- package/src/cli/simple-commands/agent.ts +137 -0
- package/src/cli/simple-commands/config.ts +127 -0
- package/src/cli/simple-commands/env-template.js +190 -0
- package/src/cli/simple-commands/init/help.js +23 -0
- package/src/cli/simple-commands/init/index.js +84 -6
- package/src/cli/simple-commands/memory.js +497 -16
- package/src/cli/simple-commands/proxy.js +384 -0
- package/src/cli/simple-commands/sparc.js +16 -19
- package/src/execution/agent-executor.ts +306 -0
- package/src/execution/index.ts +19 -0
- package/src/execution/provider-manager.ts +187 -0
- package/src/hooks/redaction-hook.ts +115 -0
- package/src/reasoningbank/reasoningbank-adapter.js +191 -0
- package/src/utils/key-redactor.js +178 -0
- package/src/utils/key-redactor.ts +184 -0
|
@@ -1 +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,OAA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IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;AACd"}
|
|
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';\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 // Lazy load the adapter (ES modules)\n const { initializeReasoningBank, storeMemory, queryMemories, listMemories, getStatus } = await import('../../reasoningbank/reasoningbank-adapter.js');\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 await initializeReasoningBank();\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 }\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 printInfo(`🧠 Using ReasoningBank mode...`);\n\n try {\n // Handle different commands\n switch (command) {\n case 'store':\n await handleReasoningBankStore(subArgs, flags, storeMemory);\n break;\n\n case 'query':\n await handleReasoningBankQuery(subArgs, flags, queryMemories);\n break;\n\n case 'list':\n await handleReasoningBankList(subArgs, flags, listMemories);\n break;\n\n case 'status':\n await handleReasoningBankStatus(getStatus);\n break;\n\n case 'consolidate':\n case 'demo':\n case 'test':\n case 'benchmark':\n // These still use CLI commands\n const cmd = `npx agentic-flow reasoningbank ${command}`;\n const { stdout } = await execAsync(cmd, { timeout: 60000 });\n if (stdout) console.log(stdout);\n break;\n\n default:\n printError(`Unknown ReasoningBank command: ${command}`);\n }\n } catch (error) {\n printError(`❌ ReasoningBank command failed`);\n console.error(error.message);\n }\n}\n\n// NEW: Handle ReasoningBank store\nasync function handleReasoningBankStore(subArgs, flags, storeMemory) {\n const key = subArgs[1];\n const value = subArgs.slice(2).join(' ');\n\n if (!key || !value) {\n printError('Usage: memory store <key> <value> --reasoningbank');\n return;\n }\n\n try {\n const namespace = flags?.namespace || flags?.ns || getArgValue(subArgs, '--namespace') || 'default';\n\n const memoryId = await storeMemory(key, value, {\n namespace,\n agent: 'memory-agent',\n domain: namespace,\n });\n\n printSuccess('✅ Stored successfully in ReasoningBank');\n console.log(`📝 Key: ${key}`);\n console.log(`🧠 Memory ID: ${memoryId}`);\n console.log(`📦 Namespace: ${namespace}`);\n console.log(`💾 Size: ${new TextEncoder().encode(value).length} bytes`);\n console.log(`🔍 Semantic search: enabled`);\n } catch (error) {\n printError(`Failed to store: ${error.message}`);\n }\n}\n\n// NEW: Handle ReasoningBank query\nasync function handleReasoningBankQuery(subArgs, flags, queryMemories) {\n const search = subArgs.slice(1).join(' ');\n\n if (!search) {\n printError('Usage: memory query <search> --reasoningbank');\n return;\n }\n\n try {\n const namespace = flags?.namespace || flags?.ns || getArgValue(subArgs, '--namespace');\n const results = await queryMemories(search, {\n domain: namespace || 'general',\n limit: 10,\n });\n\n if (results.length === 0) {\n printWarning('No results found');\n return;\n }\n\n printSuccess(`Found ${results.length} results (semantic search):`);\n\n for (const entry of results) {\n console.log(`\\n📌 ${entry.key}`);\n console.log(` Namespace: ${entry.namespace}`);\n console.log(` Value: ${entry.value.substring(0, 100)}${entry.value.length > 100 ? '...' : ''}`);\n console.log(` Confidence: ${(entry.confidence * 100).toFixed(1)}%`);\n console.log(` Usage: ${entry.usage_count} times`);\n if (entry.score) {\n console.log(` Match Score: ${(entry.score * 100).toFixed(1)}%`);\n }\n console.log(` Stored: ${new Date(entry.created_at).toLocaleString()}`);\n }\n } catch (error) {\n printError(`Failed to query: ${error.message}`);\n }\n}\n\n// NEW: Handle ReasoningBank list\nasync function handleReasoningBankList(subArgs, flags, listMemories) {\n try {\n const sort = flags?.sort || getArgValue(subArgs, '--sort') || 'created_at';\n const limit = parseInt(flags?.limit || getArgValue(subArgs, '--limit') || '10');\n\n const results = await listMemories({ sort, limit });\n\n if (results.length === 0) {\n printWarning('No memories found');\n return;\n }\n\n printSuccess(`ReasoningBank memories (${results.length} shown):`);\n\n for (const entry of results) {\n console.log(`\\n📌 ${entry.key}`);\n console.log(` Value: ${entry.value.substring(0, 80)}${entry.value.length > 80 ? '...' : ''}`);\n console.log(` Confidence: ${(entry.confidence * 100).toFixed(1)}% | Usage: ${entry.usage_count}`);\n }\n } catch (error) {\n printError(`Failed to list: ${error.message}`);\n }\n}\n\n// NEW: Handle ReasoningBank status\nasync function handleReasoningBankStatus(getStatus) {\n try {\n const stats = await getStatus();\n\n printSuccess('📊 ReasoningBank Status:');\n console.log(` Total memories: ${stats.total_memories}`);\n console.log(` Average confidence: ${(stats.avg_confidence * 100).toFixed(1)}%`);\n console.log(` Total usage: ${stats.total_usage}`);\n console.log(` Embeddings: ${stats.total_embeddings}`);\n console.log(` Trajectories: ${stats.total_trajectories}`);\n } catch (error) {\n printError(`Failed to get status: ${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 // Add required --agent parameter\n parts.push('--agent', 'memory-agent');\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","initializeReasoningBank","queryMemories","listMemories","getStatus","error","handleReasoningBankStore","handleReasoningBankQuery","handleReasoningBankList","handleReasoningBankStatus","cmd","stdout","timeout","getArgValue","memoryId","agent","domain","limit","confidence","usage_count","score","created_at","parseInt","stats","total_memories","avg_confidence","total_usage","total_embeddings","total_trajectories","buildReasoningBankCommand","parts","commandMap","store","query","list","status","consolidate","demo","test","benchmark","args","arg","startsWith","detectModes","showCurrentMode","migrateMemory","basicAvailable","checkBasicMode","rbAvailable","memoryDir","rbInitialized","targetMode","to","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,YAAYD,UAAUD;AAE5B,OAAO,eAAeG,cAAcC,OAAO,EAAEC,KAAK;IAChD,MAAMC,mBAAmBF,OAAO,CAAC,EAAE;IACnC,MAAMG,cAAc;IAGpB,MAAMC,YAAYH,OAAOG,aAAaH,OAAOI,MAAMC,qBAAqBN,YAAY;IAGpF,MAAMO,kBAAkBN,OAAOO,UAAUR,QAAQS,QAAQ,CAAC,eAAeT,QAAQS,QAAQ,CAAC;IAG1F,MAAMC,OAAO,MAAMC,iBAAiBV,OAAOD;IAG3C,eAAeY;QACb,IAAI;YACF,MAAMC,UAAU,MAAMnB,GAAGoB,QAAQ,CAACX,aAAa;YAC/C,OAAOY,KAAKC,KAAK,CAACH;QACpB,EAAE,OAAM;YACN,OAAO,CAAC;QACV;IACF;IAGA,eAAeI,WAAWC,IAAI;QAC5B,MAAMxB,GAAGyB,KAAK,CAAC,YAAY;YAAEC,WAAW;QAAK;QAC7C,MAAM1B,GAAG2B,SAAS,CAAClB,aAAaY,KAAKO,SAAS,CAACJ,MAAM,MAAM,GAAG;IAChE;IAGA,IAAIR,SAAS,mBAAmB;QAAC;QAAQ;QAAU;QAAe;QAAQ;QAAQ;KAAY,CAACD,QAAQ,CAACP,mBAAmB;QACzH,OAAO,MAAMqB,2BAA2BrB,kBAAkBF,SAASC;IACrE;IAGA,IAAI;QAAC;QAAU;QAAQ;KAAU,CAACQ,QAA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C;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG;IACXD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;AACd"}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { printSuccess, printError, printWarning } from '../utils.js';
|
|
2
|
+
import { exec } from 'child_process';
|
|
3
|
+
import { promisify } from 'util';
|
|
4
|
+
const execAsync = promisify(exec);
|
|
5
|
+
export async function proxyCommand(subArgs, flags) {
|
|
6
|
+
const proxyCmd = subArgs[0];
|
|
7
|
+
switch(proxyCmd){
|
|
8
|
+
case 'start':
|
|
9
|
+
await startProxy(subArgs, flags);
|
|
10
|
+
break;
|
|
11
|
+
case 'stop':
|
|
12
|
+
await stopProxy(subArgs, flags);
|
|
13
|
+
break;
|
|
14
|
+
case 'status':
|
|
15
|
+
await getProxyStatus(subArgs, flags);
|
|
16
|
+
break;
|
|
17
|
+
case 'logs':
|
|
18
|
+
await getProxyLogs(subArgs, flags);
|
|
19
|
+
break;
|
|
20
|
+
case 'restart':
|
|
21
|
+
await restartProxy(subArgs, flags);
|
|
22
|
+
break;
|
|
23
|
+
case 'config':
|
|
24
|
+
case 'configure':
|
|
25
|
+
await configureProxy(subArgs, flags);
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
showProxyHelp();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function startProxy(subArgs, flags) {
|
|
32
|
+
printSuccess('🚀 Starting OpenRouter proxy server...');
|
|
33
|
+
console.log('This proxy enables Claude Code to use OpenRouter models');
|
|
34
|
+
console.log('Potential cost savings: 85-98% vs direct Anthropic API\n');
|
|
35
|
+
try {
|
|
36
|
+
let cmd = 'npx agentic-flow proxy';
|
|
37
|
+
if (flags.port) {
|
|
38
|
+
cmd += ` --port ${flags.port}`;
|
|
39
|
+
}
|
|
40
|
+
if (flags.host) {
|
|
41
|
+
cmd += ` --host ${flags.host}`;
|
|
42
|
+
}
|
|
43
|
+
if (flags.daemon || flags.background) {
|
|
44
|
+
cmd += ' &';
|
|
45
|
+
}
|
|
46
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
47
|
+
timeout: flags.daemon ? 10000 : 0,
|
|
48
|
+
maxBuffer: 10 * 1024 * 1024
|
|
49
|
+
});
|
|
50
|
+
if (stdout) {
|
|
51
|
+
console.log(stdout);
|
|
52
|
+
}
|
|
53
|
+
printSuccess('✅ OpenRouter proxy started successfully!');
|
|
54
|
+
console.log('\n📋 Next steps:');
|
|
55
|
+
console.log(' 1. Set environment variable:');
|
|
56
|
+
console.log(` export ANTHROPIC_BASE_URL=http://localhost:${flags.port || 8080}`);
|
|
57
|
+
console.log(' 2. Configure Claude Code to use the proxy');
|
|
58
|
+
console.log(' 3. Your OpenRouter key will be used automatically');
|
|
59
|
+
console.log(' 4. Check status: claude-flow proxy status');
|
|
60
|
+
console.log('\n💰 Cost Savings:');
|
|
61
|
+
console.log(' - Anthropic Claude 3.5 Sonnet: ~$3 per million tokens');
|
|
62
|
+
console.log(' - OpenRouter Claude 3.5 Sonnet: ~$0.30 per million tokens');
|
|
63
|
+
console.log(' - Savings: ~90% (10x cheaper!)');
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error.killed && flags.daemon) {
|
|
66
|
+
printSuccess('✅ Proxy started in background!');
|
|
67
|
+
console.log('Check status: claude-flow proxy status');
|
|
68
|
+
} else {
|
|
69
|
+
printError('❌ Failed to start proxy server');
|
|
70
|
+
console.error(error.message);
|
|
71
|
+
if (error.stderr) {
|
|
72
|
+
console.error('Details:', error.stderr);
|
|
73
|
+
}
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function stopProxy(subArgs, flags) {
|
|
79
|
+
printWarning('🛑 Stopping OpenRouter proxy server...');
|
|
80
|
+
try {
|
|
81
|
+
const { stdout } = await execAsync('npx agentic-flow proxy stop', {
|
|
82
|
+
timeout: 30000
|
|
83
|
+
});
|
|
84
|
+
console.log(stdout);
|
|
85
|
+
printSuccess('✅ Proxy server stopped');
|
|
86
|
+
console.log('\nRemember to unset ANTHROPIC_BASE_URL if needed:');
|
|
87
|
+
console.log(' unset ANTHROPIC_BASE_URL');
|
|
88
|
+
} catch (error) {
|
|
89
|
+
printError('❌ Failed to stop proxy server');
|
|
90
|
+
console.error(error.message);
|
|
91
|
+
console.log('\nTip: You can also stop it manually:');
|
|
92
|
+
console.log(' ps aux | grep "agentic-flow proxy"');
|
|
93
|
+
console.log(' kill -9 <PID>');
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function getProxyStatus(subArgs, flags) {
|
|
98
|
+
printSuccess('📊 Getting OpenRouter proxy status...');
|
|
99
|
+
try {
|
|
100
|
+
const { stdout } = await execAsync('npx agentic-flow proxy status', {
|
|
101
|
+
timeout: 30000
|
|
102
|
+
});
|
|
103
|
+
console.log(stdout);
|
|
104
|
+
if (flags.verbose || flags.detailed) {
|
|
105
|
+
console.log('\n🔧 Configuration:');
|
|
106
|
+
console.log(' Base URL: http://localhost:8080 (default)');
|
|
107
|
+
console.log(' Protocol: HTTP/1.1');
|
|
108
|
+
console.log(' Translation: Anthropic API → OpenRouter API');
|
|
109
|
+
console.log('\n📝 Usage:');
|
|
110
|
+
console.log(' 1. export ANTHROPIC_BASE_URL=http://localhost:8080');
|
|
111
|
+
console.log(' 2. Use Claude Code normally');
|
|
112
|
+
console.log(' 3. All requests route through OpenRouter');
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
printError('❌ Failed to get proxy status');
|
|
116
|
+
console.error(error.message);
|
|
117
|
+
console.log('\nTip: Proxy may not be running. Start it with:');
|
|
118
|
+
console.log(' claude-flow proxy start');
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function getProxyLogs(subArgs, flags) {
|
|
123
|
+
printSuccess('📄 Getting OpenRouter proxy logs...');
|
|
124
|
+
try {
|
|
125
|
+
let cmd = 'npx agentic-flow proxy logs';
|
|
126
|
+
if (flags.lines) {
|
|
127
|
+
cmd += ` --lines ${flags.lines}`;
|
|
128
|
+
}
|
|
129
|
+
if (flags.follow || flags.f) {
|
|
130
|
+
cmd += ' --follow';
|
|
131
|
+
}
|
|
132
|
+
if (flags.error) {
|
|
133
|
+
cmd += ' --error';
|
|
134
|
+
}
|
|
135
|
+
const { stdout } = await execAsync(cmd, {
|
|
136
|
+
timeout: flags.follow ? 0 : 30000,
|
|
137
|
+
maxBuffer: 10 * 1024 * 1024
|
|
138
|
+
});
|
|
139
|
+
console.log(stdout);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
printError('❌ Failed to get proxy logs');
|
|
142
|
+
console.error(error.message);
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async function restartProxy(subArgs, flags) {
|
|
147
|
+
printWarning('🔄 Restarting OpenRouter proxy server...');
|
|
148
|
+
try {
|
|
149
|
+
await stopProxy(subArgs, {
|
|
150
|
+
...flags,
|
|
151
|
+
quiet: true
|
|
152
|
+
});
|
|
153
|
+
await new Promise((resolve)=>setTimeout(resolve, 2000));
|
|
154
|
+
await startProxy(subArgs, flags);
|
|
155
|
+
printSuccess('✅ Proxy server restarted successfully!');
|
|
156
|
+
} catch (error) {
|
|
157
|
+
printError('❌ Failed to restart proxy server');
|
|
158
|
+
console.error(error.message);
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
async function configureProxy(subArgs, flags) {
|
|
163
|
+
printSuccess('🔧 OpenRouter Proxy Configuration');
|
|
164
|
+
console.log('\n📋 Current Setup:');
|
|
165
|
+
console.log(' 1. Proxy translates Anthropic API calls to OpenRouter');
|
|
166
|
+
console.log(' 2. Default port: 8080');
|
|
167
|
+
console.log(' 3. Requires OPENROUTER_API_KEY environment variable');
|
|
168
|
+
console.log('\n🔑 API Key Setup:');
|
|
169
|
+
console.log(' export OPENROUTER_API_KEY="sk-or-v1-..."');
|
|
170
|
+
console.log('\n🌐 Claude Code Integration:');
|
|
171
|
+
console.log(' export ANTHROPIC_BASE_URL="http://localhost:8080"');
|
|
172
|
+
console.log('\n💡 Recommended Models:');
|
|
173
|
+
console.log(' - anthropic/claude-3.5-sonnet:beta (90% cheaper)');
|
|
174
|
+
console.log(' - anthropic/claude-3-opus:beta (85% cheaper)');
|
|
175
|
+
console.log(' - deepseek/deepseek-r1-0528:free (100% free!)');
|
|
176
|
+
console.log('\n⚙️ Advanced Configuration:');
|
|
177
|
+
console.log(' export PROXY_PORT=8080 # Custom port');
|
|
178
|
+
console.log(' export PROXY_HOST=0.0.0.0 # Allow external connections');
|
|
179
|
+
console.log(' export PROXY_LOG_LEVEL=debug # Verbose logging');
|
|
180
|
+
console.log('\n🚀 Quick Start:');
|
|
181
|
+
console.log(' 1. claude-flow agent config set OPENROUTER_API_KEY sk-or-v1-...');
|
|
182
|
+
console.log(' 2. claude-flow proxy start --daemon');
|
|
183
|
+
console.log(' 3. export ANTHROPIC_BASE_URL=http://localhost:8080');
|
|
184
|
+
console.log(' 4. Use Claude Code normally → automatic 90% savings!');
|
|
185
|
+
if (flags.test) {
|
|
186
|
+
printSuccess('\n🧪 Testing proxy connection...');
|
|
187
|
+
try {
|
|
188
|
+
const { stdout } = await execAsync('curl -s http://localhost:8080/health', {
|
|
189
|
+
timeout: 5000
|
|
190
|
+
});
|
|
191
|
+
console.log('✅ Proxy is responding:', stdout);
|
|
192
|
+
} catch (error) {
|
|
193
|
+
printWarning('⚠️ Proxy not responding. Start it with: claude-flow proxy start');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function showProxyHelp() {
|
|
198
|
+
console.log(`
|
|
199
|
+
OpenRouter Proxy Server Commands
|
|
200
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
201
|
+
|
|
202
|
+
Standalone proxy server that translates Anthropic API calls to OpenRouter.
|
|
203
|
+
Enables 85-98% cost savings with Claude Code integration.
|
|
204
|
+
|
|
205
|
+
USAGE:
|
|
206
|
+
claude-flow proxy <command> [options]
|
|
207
|
+
|
|
208
|
+
COMMANDS:
|
|
209
|
+
start Start OpenRouter proxy server
|
|
210
|
+
stop Stop proxy server
|
|
211
|
+
restart Restart proxy server
|
|
212
|
+
status Get proxy server status
|
|
213
|
+
logs View proxy server logs
|
|
214
|
+
config Show proxy configuration guide
|
|
215
|
+
|
|
216
|
+
OPTIONS:
|
|
217
|
+
--port <number> Server port (default: 8080)
|
|
218
|
+
--host <string> Server host (default: localhost)
|
|
219
|
+
--daemon Run in background
|
|
220
|
+
--background Same as --daemon
|
|
221
|
+
--lines <number> Number of log lines (default: 100)
|
|
222
|
+
--follow, -f Follow log output in real-time
|
|
223
|
+
--error Show only error logs
|
|
224
|
+
--test Test proxy connection
|
|
225
|
+
--verbose Verbose output
|
|
226
|
+
|
|
227
|
+
EXAMPLES:
|
|
228
|
+
# Start proxy server
|
|
229
|
+
claude-flow proxy start
|
|
230
|
+
claude-flow proxy start --port 8080 --daemon
|
|
231
|
+
|
|
232
|
+
# Configure Claude Code to use proxy
|
|
233
|
+
export ANTHROPIC_BASE_URL=http://localhost:8080
|
|
234
|
+
|
|
235
|
+
# Check status
|
|
236
|
+
claude-flow proxy status
|
|
237
|
+
claude-flow proxy status --verbose
|
|
238
|
+
|
|
239
|
+
# View logs
|
|
240
|
+
claude-flow proxy logs
|
|
241
|
+
claude-flow proxy logs --lines 50 --follow
|
|
242
|
+
claude-flow proxy logs --error
|
|
243
|
+
|
|
244
|
+
# Stop/restart proxy
|
|
245
|
+
claude-flow proxy stop
|
|
246
|
+
claude-flow proxy restart
|
|
247
|
+
|
|
248
|
+
# Configuration guide
|
|
249
|
+
claude-flow proxy config
|
|
250
|
+
claude-flow proxy config --test
|
|
251
|
+
|
|
252
|
+
SETUP GUIDE:
|
|
253
|
+
1. Get OpenRouter API key: https://openrouter.ai/keys
|
|
254
|
+
2. Set environment variable:
|
|
255
|
+
claude-flow agent config set OPENROUTER_API_KEY sk-or-v1-...
|
|
256
|
+
|
|
257
|
+
3. Start proxy server:
|
|
258
|
+
claude-flow proxy start --daemon
|
|
259
|
+
|
|
260
|
+
4. Configure Claude Code:
|
|
261
|
+
export ANTHROPIC_BASE_URL=http://localhost:8080
|
|
262
|
+
|
|
263
|
+
5. Use Claude Code normally - all requests route through OpenRouter!
|
|
264
|
+
|
|
265
|
+
COST SAVINGS:
|
|
266
|
+
┌────────────────────────────────────────────────────────┐
|
|
267
|
+
│ │
|
|
268
|
+
│ Model: Claude 3.5 Sonnet │
|
|
269
|
+
│ ━━━━━━━━━━━━━━━━━━━━━━━━━ │
|
|
270
|
+
│ │
|
|
271
|
+
│ Anthropic Direct: $3.00 per million tokens │
|
|
272
|
+
│ OpenRouter Proxy: $0.30 per million tokens │
|
|
273
|
+
│ ━━━━━━━━━━━━━━━━━━━━━━━━━ │
|
|
274
|
+
│ Savings: 90% (10x cheaper!) │
|
|
275
|
+
│ │
|
|
276
|
+
│ For 100M tokens: │
|
|
277
|
+
│ - Anthropic: $300 │
|
|
278
|
+
│ - OpenRouter: $30 │
|
|
279
|
+
│ - You save: $270 │
|
|
280
|
+
│ │
|
|
281
|
+
└────────────────────────────────────────────────────────┘
|
|
282
|
+
|
|
283
|
+
FREE MODELS:
|
|
284
|
+
- deepseek/deepseek-r1-0528:free (100% free, high quality)
|
|
285
|
+
- meta-llama/llama-3.1-8b-instruct:free
|
|
286
|
+
- google/gemma-2-9b-it:free
|
|
287
|
+
|
|
288
|
+
FEATURES:
|
|
289
|
+
✅ Transparent API translation (Anthropic → OpenRouter)
|
|
290
|
+
✅ Works with Claude Code out of the box
|
|
291
|
+
✅ Automatic model mapping
|
|
292
|
+
✅ Request/response logging
|
|
293
|
+
✅ Error handling and retries
|
|
294
|
+
✅ Health check endpoint
|
|
295
|
+
✅ Zero code changes required
|
|
296
|
+
|
|
297
|
+
For more information, visit:
|
|
298
|
+
https://github.com/ruvnet/agentic-flow
|
|
299
|
+
https://www.npmjs.com/package/agentic-flow
|
|
300
|
+
https://openrouter.ai
|
|
301
|
+
`);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/cli/simple-commands/proxy.js"],"sourcesContent":["/**\n * OpenRouter Proxy Server Commands\n * Standalone proxy server that translates Anthropic API calls to OpenRouter\n * Enables 85-98% cost savings with Claude Code integration\n * NEW in v2.6.0 - Full integration with agentic-flow v1.5.5+\n */\n\nimport { printSuccess, printError, printWarning } from '../utils.js';\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\n\nconst execAsync = promisify(exec);\n\n/**\n * Main proxy command handler\n */\nexport async function proxyCommand(subArgs, flags) {\n const proxyCmd = subArgs[0];\n\n switch (proxyCmd) {\n case 'start':\n await startProxy(subArgs, flags);\n break;\n\n case 'stop':\n await stopProxy(subArgs, flags);\n break;\n\n case 'status':\n await getProxyStatus(subArgs, flags);\n break;\n\n case 'logs':\n await getProxyLogs(subArgs, flags);\n break;\n\n case 'restart':\n await restartProxy(subArgs, flags);\n break;\n\n case 'config':\n case 'configure':\n await configureProxy(subArgs, flags);\n break;\n\n default:\n showProxyHelp();\n }\n}\n\n/**\n * Start OpenRouter proxy server\n * Usage: claude-flow proxy start [--port 8080]\n */\nasync function startProxy(subArgs, flags) {\n printSuccess('🚀 Starting OpenRouter proxy server...');\n console.log('This proxy enables Claude Code to use OpenRouter models');\n console.log('Potential cost savings: 85-98% vs direct Anthropic API\\n');\n\n try {\n let cmd = 'npx agentic-flow proxy';\n\n if (flags.port) {\n cmd += ` --port ${flags.port}`;\n }\n\n if (flags.host) {\n cmd += ` --host ${flags.host}`;\n }\n\n if (flags.daemon || flags.background) {\n cmd += ' &';\n }\n\n const { stdout, stderr } = await execAsync(cmd, {\n timeout: flags.daemon ? 10000 : 0, // Short timeout for daemon mode\n maxBuffer: 10 * 1024 * 1024,\n });\n\n if (stdout) {\n console.log(stdout);\n }\n\n printSuccess('✅ OpenRouter proxy started successfully!');\n console.log('\\n📋 Next steps:');\n console.log(' 1. Set environment variable:');\n console.log(` export ANTHROPIC_BASE_URL=http://localhost:${flags.port || 8080}`);\n console.log(' 2. Configure Claude Code to use the proxy');\n console.log(' 3. Your OpenRouter key will be used automatically');\n console.log(' 4. Check status: claude-flow proxy status');\n console.log('\\n💰 Cost Savings:');\n console.log(' - Anthropic Claude 3.5 Sonnet: ~$3 per million tokens');\n console.log(' - OpenRouter Claude 3.5 Sonnet: ~$0.30 per million tokens');\n console.log(' - Savings: ~90% (10x cheaper!)');\n } catch (error) {\n if (error.killed && flags.daemon) {\n printSuccess('✅ Proxy started in background!');\n console.log('Check status: claude-flow proxy status');\n } else {\n printError('❌ Failed to start proxy server');\n console.error(error.message);\n if (error.stderr) {\n console.error('Details:', error.stderr);\n }\n process.exit(1);\n }\n }\n}\n\n/**\n * Stop OpenRouter proxy server\n * Usage: claude-flow proxy stop\n */\nasync function stopProxy(subArgs, flags) {\n printWarning('🛑 Stopping OpenRouter proxy server...');\n\n try {\n const { stdout } = await execAsync('npx agentic-flow proxy stop', {\n timeout: 30000,\n });\n\n console.log(stdout);\n printSuccess('✅ Proxy server stopped');\n console.log('\\nRemember to unset ANTHROPIC_BASE_URL if needed:');\n console.log(' unset ANTHROPIC_BASE_URL');\n } catch (error) {\n printError('❌ Failed to stop proxy server');\n console.error(error.message);\n console.log('\\nTip: You can also stop it manually:');\n console.log(' ps aux | grep \"agentic-flow proxy\"');\n console.log(' kill -9 <PID>');\n process.exit(1);\n }\n}\n\n/**\n * Get proxy server status\n * Usage: claude-flow proxy status\n */\nasync function getProxyStatus(subArgs, flags) {\n printSuccess('📊 Getting OpenRouter proxy status...');\n\n try {\n const { stdout } = await execAsync('npx agentic-flow proxy status', {\n timeout: 30000,\n });\n\n console.log(stdout);\n\n if (flags.verbose || flags.detailed) {\n console.log('\\n🔧 Configuration:');\n console.log(' Base URL: http://localhost:8080 (default)');\n console.log(' Protocol: HTTP/1.1');\n console.log(' Translation: Anthropic API → OpenRouter API');\n console.log('\\n📝 Usage:');\n console.log(' 1. export ANTHROPIC_BASE_URL=http://localhost:8080');\n console.log(' 2. Use Claude Code normally');\n console.log(' 3. All requests route through OpenRouter');\n }\n } catch (error) {\n printError('❌ Failed to get proxy status');\n console.error(error.message);\n console.log('\\nTip: Proxy may not be running. Start it with:');\n console.log(' claude-flow proxy start');\n process.exit(1);\n }\n}\n\n/**\n * Get proxy server logs\n * Usage: claude-flow proxy logs [--lines 100] [--follow]\n */\nasync function getProxyLogs(subArgs, flags) {\n printSuccess('📄 Getting OpenRouter proxy logs...');\n\n try {\n let cmd = 'npx agentic-flow proxy logs';\n\n if (flags.lines) {\n cmd += ` --lines ${flags.lines}`;\n }\n\n if (flags.follow || flags.f) {\n cmd += ' --follow';\n }\n\n if (flags.error) {\n cmd += ' --error';\n }\n\n const { stdout } = await execAsync(cmd, {\n timeout: flags.follow ? 0 : 30000, // No timeout for follow mode\n maxBuffer: 10 * 1024 * 1024,\n });\n\n console.log(stdout);\n } catch (error) {\n printError('❌ Failed to get proxy logs');\n console.error(error.message);\n process.exit(1);\n }\n}\n\n/**\n * Restart proxy server\n * Usage: claude-flow proxy restart\n */\nasync function restartProxy(subArgs, flags) {\n printWarning('🔄 Restarting OpenRouter proxy server...');\n\n try {\n // Stop first\n await stopProxy(subArgs, { ...flags, quiet: true });\n\n // Wait a moment\n await new Promise((resolve) => setTimeout(resolve, 2000));\n\n // Start again\n await startProxy(subArgs, flags);\n\n printSuccess('✅ Proxy server restarted successfully!');\n } catch (error) {\n printError('❌ Failed to restart proxy server');\n console.error(error.message);\n process.exit(1);\n }\n}\n\n/**\n * Configure proxy server\n * Usage: claude-flow proxy config\n */\nasync function configureProxy(subArgs, flags) {\n printSuccess('🔧 OpenRouter Proxy Configuration');\n\n console.log('\\n📋 Current Setup:');\n console.log(' 1. Proxy translates Anthropic API calls to OpenRouter');\n console.log(' 2. Default port: 8080');\n console.log(' 3. Requires OPENROUTER_API_KEY environment variable');\n\n console.log('\\n🔑 API Key Setup:');\n console.log(' export OPENROUTER_API_KEY=\"sk-or-v1-...\"');\n\n console.log('\\n🌐 Claude Code Integration:');\n console.log(' export ANTHROPIC_BASE_URL=\"http://localhost:8080\"');\n\n console.log('\\n💡 Recommended Models:');\n console.log(' - anthropic/claude-3.5-sonnet:beta (90% cheaper)');\n console.log(' - anthropic/claude-3-opus:beta (85% cheaper)');\n console.log(' - deepseek/deepseek-r1-0528:free (100% free!)');\n\n console.log('\\n⚙️ Advanced Configuration:');\n console.log(' export PROXY_PORT=8080 # Custom port');\n console.log(' export PROXY_HOST=0.0.0.0 # Allow external connections');\n console.log(' export PROXY_LOG_LEVEL=debug # Verbose logging');\n\n console.log('\\n🚀 Quick Start:');\n console.log(' 1. claude-flow agent config set OPENROUTER_API_KEY sk-or-v1-...');\n console.log(' 2. claude-flow proxy start --daemon');\n console.log(' 3. export ANTHROPIC_BASE_URL=http://localhost:8080');\n console.log(' 4. Use Claude Code normally → automatic 90% savings!');\n\n if (flags.test) {\n printSuccess('\\n🧪 Testing proxy connection...');\n try {\n const { stdout } = await execAsync('curl -s http://localhost:8080/health', {\n timeout: 5000,\n });\n console.log('✅ Proxy is responding:', stdout);\n } catch (error) {\n printWarning('⚠️ Proxy not responding. Start it with: claude-flow proxy start');\n }\n }\n}\n\n/**\n * Show proxy command help\n */\nfunction showProxyHelp() {\n console.log(`\nOpenRouter Proxy Server Commands\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nStandalone proxy server that translates Anthropic API calls to OpenRouter.\nEnables 85-98% cost savings with Claude Code integration.\n\nUSAGE:\n claude-flow proxy <command> [options]\n\nCOMMANDS:\n start Start OpenRouter proxy server\n stop Stop proxy server\n restart Restart proxy server\n status Get proxy server status\n logs View proxy server logs\n config Show proxy configuration guide\n\nOPTIONS:\n --port <number> Server port (default: 8080)\n --host <string> Server host (default: localhost)\n --daemon Run in background\n --background Same as --daemon\n --lines <number> Number of log lines (default: 100)\n --follow, -f Follow log output in real-time\n --error Show only error logs\n --test Test proxy connection\n --verbose Verbose output\n\nEXAMPLES:\n # Start proxy server\n claude-flow proxy start\n claude-flow proxy start --port 8080 --daemon\n\n # Configure Claude Code to use proxy\n export ANTHROPIC_BASE_URL=http://localhost:8080\n\n # Check status\n claude-flow proxy status\n claude-flow proxy status --verbose\n\n # View logs\n claude-flow proxy logs\n claude-flow proxy logs --lines 50 --follow\n claude-flow proxy logs --error\n\n # Stop/restart proxy\n claude-flow proxy stop\n claude-flow proxy restart\n\n # Configuration guide\n claude-flow proxy config\n claude-flow proxy config --test\n\nSETUP GUIDE:\n 1. Get OpenRouter API key: https://openrouter.ai/keys\n 2. Set environment variable:\n claude-flow agent config set OPENROUTER_API_KEY sk-or-v1-...\n\n 3. Start proxy server:\n claude-flow proxy start --daemon\n\n 4. Configure Claude Code:\n export ANTHROPIC_BASE_URL=http://localhost:8080\n\n 5. Use Claude Code normally - all requests route through OpenRouter!\n\nCOST SAVINGS:\n ┌────────────────────────────────────────────────────────┐\n │ │\n │ Model: Claude 3.5 Sonnet │\n │ ━━━━━━━━━━━━━━━━━━━━━━━━━ │\n │ │\n │ Anthropic Direct: $3.00 per million tokens │\n │ OpenRouter Proxy: $0.30 per million tokens │\n │ ━━━━━━━━━━━━━━━━━━━━━━━━━ │\n │ Savings: 90% (10x cheaper!) │\n │ │\n │ For 100M tokens: │\n │ - Anthropic: $300 │\n │ - OpenRouter: $30 │\n │ - You save: $270 │\n │ │\n └────────────────────────────────────────────────────────┘\n\nFREE MODELS:\n - deepseek/deepseek-r1-0528:free (100% free, high quality)\n - meta-llama/llama-3.1-8b-instruct:free\n - google/gemma-2-9b-it:free\n\nFEATURES:\n ✅ Transparent API translation (Anthropic → OpenRouter)\n ✅ Works with Claude Code out of the box\n ✅ Automatic model mapping\n ✅ Request/response logging\n ✅ Error handling and retries\n ✅ Health check endpoint\n ✅ Zero code changes required\n\nFor more information, visit:\n https://github.com/ruvnet/agentic-flow\n https://www.npmjs.com/package/agentic-flow\n https://openrouter.ai\n`);\n}\n"],"names":["printSuccess","printError","printWarning","exec","promisify","execAsync","proxyCommand","subArgs","flags","proxyCmd","startProxy","stopProxy","getProxyStatus","getProxyLogs","restartProxy","configureProxy","showProxyHelp","console","log","cmd","port","host","daemon","background","stdout","stderr","timeout","maxBuffer","error","killed","message","process","exit","verbose","detailed","lines","follow","f","quiet","Promise","resolve","setTimeout","test"],"mappings":"AAOA,SAASA,YAAY,EAAEC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AACrE,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,SAAS,QAAQ,OAAO;AAEjC,MAAMC,YAAY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AAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IACZD,QAAQC,GAAG,CAAC;IAEZ,IAAIV,MAAMkC,IAAI,EAAE;QACd1C,aAAa;QACb,IAAI;YACF,MAAM,EAAEwB,MAAM,EAAE,GAAG,MAAMnB,UAAU,wCAAwC;gBACzEqB,SAAS;YACX;YACAT,QAAQC,GAAG,CAAC,0BAA0BM;QACxC,EAAE,OAAOI,OAAO;YACd1B,aAAa;QACf;IACF;AACF;AAKA,SAASc;IACPC,QAAQC,GAAG,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuGf,CAAC;AACD"}
|
|
@@ -62,21 +62,18 @@ export async function sparcCommand(subArgs, flags) {
|
|
|
62
62
|
async function listSparcModes(subArgs) {
|
|
63
63
|
try {
|
|
64
64
|
const workingDir = process.env.PWD || cwd();
|
|
65
|
-
const configPath = `${workingDir}/.
|
|
65
|
+
const configPath = `${workingDir}/.claude/sparc-modes.json`;
|
|
66
66
|
let configContent;
|
|
67
67
|
try {
|
|
68
68
|
configContent = await fs.readFile(configPath, 'utf8');
|
|
69
69
|
} catch (error) {
|
|
70
|
-
printError('SPARC configuration file
|
|
71
|
-
console.log(`
|
|
70
|
+
printError('SPARC configuration file not found');
|
|
71
|
+
console.log(`Looking for: ${configPath}`);
|
|
72
72
|
console.log();
|
|
73
|
-
console.log('
|
|
74
|
-
console.log('
|
|
73
|
+
console.log('✅ SPARC modes are now part of .claude/ folder structure');
|
|
74
|
+
console.log('Run `claude-flow init` to set up the .claude/ folder with SPARC modes');
|
|
75
75
|
console.log();
|
|
76
|
-
console.log('
|
|
77
|
-
console.log(' • .roomodes file with 17+ SPARC development modes');
|
|
78
|
-
console.log(' • .roo/ directory with templates and workflows');
|
|
79
|
-
console.log(' • SPARC-enhanced CLAUDE.md configuration');
|
|
76
|
+
console.log('Or manually ensure .claude/sparc-modes.json exists');
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
82
79
|
const config = JSON.parse(configContent);
|
|
@@ -107,16 +104,16 @@ async function showModeInfo(subArgs) {
|
|
|
107
104
|
}
|
|
108
105
|
try {
|
|
109
106
|
const workingDir = process.env.PWD || cwd();
|
|
110
|
-
const configPath = `${workingDir}/.
|
|
107
|
+
const configPath = `${workingDir}/.claude/sparc-modes.json`;
|
|
111
108
|
let configContent;
|
|
112
109
|
try {
|
|
113
110
|
configContent = await fs.readFile(configPath, 'utf8');
|
|
114
111
|
} catch (error) {
|
|
115
|
-
printError('SPARC configuration file
|
|
116
|
-
console.log(`
|
|
112
|
+
printError('SPARC configuration file not found');
|
|
113
|
+
console.log(`Looking for: ${configPath}`);
|
|
117
114
|
console.log();
|
|
118
|
-
console.log('
|
|
119
|
-
console.log('
|
|
115
|
+
console.log('✅ SPARC modes are now part of .claude/ folder structure');
|
|
116
|
+
console.log('Run `claude-flow init` to set up the .claude/ folder with SPARC modes');
|
|
120
117
|
return;
|
|
121
118
|
}
|
|
122
119
|
const config = JSON.parse(configContent);
|
|
@@ -155,16 +152,16 @@ async function runSparcMode(subArgs, flags) {
|
|
|
155
152
|
}
|
|
156
153
|
try {
|
|
157
154
|
const workingDir = process.env.PWD || cwd();
|
|
158
|
-
const configPath = `${workingDir}/.
|
|
155
|
+
const configPath = `${workingDir}/.claude/sparc-modes.json`;
|
|
159
156
|
let configContent;
|
|
160
157
|
try {
|
|
161
158
|
configContent = await fs.readFile(configPath, 'utf8');
|
|
162
159
|
} catch (error) {
|
|
163
|
-
printError('SPARC configuration file
|
|
164
|
-
console.log(`
|
|
160
|
+
printError('SPARC configuration file not found');
|
|
161
|
+
console.log(`Looking for: ${configPath}`);
|
|
165
162
|
console.log();
|
|
166
|
-
console.log('
|
|
167
|
-
console.log('
|
|
163
|
+
console.log('✅ SPARC modes are now part of .claude/ folder structure');
|
|
164
|
+
console.log('Run `claude-flow init` to set up the .claude/ folder with SPARC modes');
|
|
168
165
|
return;
|
|
169
166
|
}
|
|
170
167
|
const config = JSON.parse(configContent);
|