claude-flow 2.5.0-alpha.141 → 2.7.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/reasoning/README.md +171 -0
- package/.claude/agents/reasoning/agent.md +816 -0
- package/.claude/agents/reasoning/example-reasoning-agent-template.md +362 -0
- package/.claude/agents/reasoning/goal-planner.md +73 -0
- package/.claude/commands/coordination/README.md +9 -0
- package/.claude/commands/memory/README.md +9 -0
- package/.claude/settings.json +3 -3
- package/.claude/sparc-modes.json +108 -0
- package/README.md +1 -6
- package/bin/claude-flow +1 -1
- package/dist/src/cli/command-registry.js +70 -6
- package/dist/src/cli/command-registry.js.map +1 -1
- package/dist/src/cli/help-formatter.js +0 -3
- package/dist/src/cli/help-formatter.js.map +1 -1
- package/dist/src/cli/help-text.js +53 -5
- package/dist/src/cli/help-text.js.map +1 -1
- package/dist/src/cli/simple-cli.js +182 -172
- package/dist/src/cli/simple-cli.js.map +1 -1
- package/dist/src/cli/simple-commands/agent-booster.js +415 -0
- package/dist/src/cli/simple-commands/agent-booster.js.map +1 -0
- package/dist/src/cli/simple-commands/agent.js +856 -13
- package/dist/src/cli/simple-commands/agent.js.map +1 -1
- package/dist/src/cli/simple-commands/env-template.js +180 -0
- package/dist/src/cli/simple-commands/env-template.js.map +1 -0
- package/dist/src/cli/simple-commands/init/help.js +23 -0
- package/dist/src/cli/simple-commands/init/help.js.map +1 -1
- package/dist/src/cli/simple-commands/init/index.js +63 -0
- package/dist/src/cli/simple-commands/init/index.js.map +1 -1
- package/dist/src/cli/simple-commands/memory.js +307 -16
- package/dist/src/cli/simple-commands/memory.js.map +1 -1
- package/dist/src/cli/simple-commands/proxy.js +304 -0
- package/dist/src/cli/simple-commands/proxy.js.map +1 -0
- package/dist/src/cli/simple-commands/sparc.js +16 -19
- package/dist/src/cli/simple-commands/sparc.js.map +1 -1
- package/dist/src/cli/validation-helper.js.map +1 -1
- package/dist/src/core/version.js +1 -1
- package/dist/src/execution/agent-executor.js +181 -0
- package/dist/src/execution/agent-executor.js.map +1 -0
- package/dist/src/execution/index.js +12 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/provider-manager.js +110 -0
- package/dist/src/execution/provider-manager.js.map +1 -0
- package/dist/src/hooks/redaction-hook.js +89 -0
- package/dist/src/hooks/redaction-hook.js.map +1 -0
- package/dist/src/memory/swarm-memory.js +340 -421
- package/dist/src/memory/swarm-memory.js.map +1 -1
- package/dist/src/utils/key-redactor.js +108 -0
- package/dist/src/utils/key-redactor.js.map +1 -0
- package/dist/src/utils/metrics-reader.js +37 -39
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/AGENT-BOOSTER-INTEGRATION.md +407 -0
- package/docs/AGENTIC-FLOW-INTEGRATION-GUIDE.md +753 -0
- package/docs/AGENTIC_FLOW_EXECUTION_FIX_REPORT.md +474 -0
- package/docs/AGENTIC_FLOW_INTEGRATION_STATUS.md +143 -0
- package/docs/AGENTIC_FLOW_MVP_COMPLETE.md +367 -0
- package/docs/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +369 -0
- package/docs/COMMAND-VERIFICATION-REPORT.md +441 -0
- package/docs/COMMIT_SUMMARY.md +247 -0
- package/docs/DEEP_REVIEW_COMPREHENSIVE_REPORT.md +922 -0
- package/docs/DOCKER-VALIDATION-REPORT.md +281 -0
- package/docs/ENV-SETUP-GUIDE.md +270 -0
- package/docs/FINAL_PRE_PUBLISH_VALIDATION.md +823 -0
- package/docs/FINAL_VALIDATION_REPORT.md +165 -0
- package/docs/HOOKS-V2-MODIFICATION.md +146 -0
- package/docs/INDEX.md +568 -0
- package/docs/INTEGRATION_COMPLETE.md +414 -0
- package/docs/MEMORY_REDACTION_TEST_REPORT.md +300 -0
- package/docs/PERFORMANCE-SYSTEMS-STATUS.md +340 -0
- package/docs/PRE_RELEASE_FIXES_REPORT.md +435 -0
- package/docs/README.md +35 -0
- package/docs/REASONING-AGENTS.md +482 -0
- package/docs/REASONINGBANK-AGENT-CREATION-GUIDE.md +813 -0
- package/docs/REASONINGBANK-ANALYSIS-COMPLETE.md +479 -0
- package/docs/REASONINGBANK-BENCHMARK-RESULTS.md +166 -0
- package/docs/REASONINGBANK-BENCHMARK.md +396 -0
- package/docs/REASONINGBANK-CLI-INTEGRATION.md +455 -0
- package/docs/REASONINGBANK-CORE-INTEGRATION.md +658 -0
- package/docs/REASONINGBANK-COST-OPTIMIZATION.md +329 -0
- package/docs/REASONINGBANK-DEMO.md +419 -0
- package/docs/REASONINGBANK-INTEGRATION-COMPLETE.md +249 -0
- package/docs/REASONINGBANK-VALIDATION.md +532 -0
- package/docs/REASONINGBANK_ARCHITECTURE.md +475 -0
- package/docs/REASONINGBANK_INTEGRATION_COMPLETE.md +558 -0
- package/docs/REASONINGBANK_INTEGRATION_PLAN.md +1188 -0
- package/docs/REGRESSION-ANALYSIS-REPORT.md +500 -0
- package/docs/RELEASE_v2.6.0-alpha.2.md +658 -0
- package/docs/api/API_DOCUMENTATION.md +721 -0
- package/docs/architecture/ARCHITECTURE.md +1690 -0
- package/docs/ci-cd/README.md +368 -0
- package/docs/development/DEPLOYMENT.md +2348 -0
- package/docs/development/DEVELOPMENT_WORKFLOW.md +1333 -0
- package/docs/development/build-analysis-report.md +252 -0
- package/docs/development/pair-optimization.md +156 -0
- package/docs/development/token-tracking-status.md +103 -0
- package/docs/development/training-pipeline-demo.md +163 -0
- package/docs/development/training-pipeline-real-only.md +196 -0
- package/docs/epic-sdk-integration.md +1269 -0
- package/docs/experimental/RIEMANN_HYPOTHESIS_PROOF.md +124 -0
- package/docs/experimental/computational_verification.py +436 -0
- package/docs/experimental/novel_approaches.md +560 -0
- package/docs/experimental/riemann_hypothesis_analysis.md +263 -0
- package/docs/experimental/riemann_proof_attempt.md +124 -0
- package/docs/experimental/riemann_synthesis.md +277 -0
- package/docs/experimental/verification_results.json +12 -0
- package/docs/experimental/visualization_insights.md +720 -0
- package/docs/guides/USER_GUIDE.md +1138 -0
- package/docs/guides/token-tracking-guide.md +291 -0
- package/docs/reference/AGENTS.md +1011 -0
- package/docs/reference/MCP_TOOLS.md +2188 -0
- package/docs/reference/SPARC.md +717 -0
- package/docs/reference/SWARM.md +2000 -0
- package/docs/sdk/CLAUDE-CODE-SDK-DEEP-ANALYSIS.md +649 -0
- package/docs/sdk/CLAUDE-FLOW-SDK-INTEGRATION-ANALYSIS.md +242 -0
- package/docs/sdk/INTEGRATION-ROADMAP.md +420 -0
- package/docs/sdk/MCP-TOOLS-UPDATE.md +270 -0
- package/docs/sdk/SDK-ADVANCED-FEATURES-INTEGRATION.md +723 -0
- package/docs/sdk/SDK-ALL-FEATURES-INTEGRATION-MATRIX.md +612 -0
- package/docs/sdk/SDK-INTEGRATION-COMPLETE.md +358 -0
- package/docs/sdk/SDK-INTEGRATION-PHASES-V2.5.md +750 -0
- package/docs/sdk/SDK-LEVERAGE-REAL-FEATURES.md +676 -0
- package/docs/sdk/SDK-VALIDATION-RESULTS.md +400 -0
- package/docs/sdk/epic-sdk-integration.md +1269 -0
- package/docs/setup/remote-setup.md +93 -0
- package/docs/validation/final-validation-summary.md +220 -0
- package/docs/validation/verification-integration.md +190 -0
- package/docs/validation/verification-validation.md +349 -0
- package/docs/wiki/background-commands.md +1213 -0
- package/docs/wiki/session-persistence.md +342 -0
- package/docs/wiki/stream-chain-command.md +537 -0
- package/package.json +4 -2
- package/src/cli/command-registry.js +70 -5
- package/src/cli/help-text.js +26 -5
- package/src/cli/simple-cli.ts +18 -7
- package/src/cli/simple-commands/agent-booster.js +515 -0
- package/src/cli/simple-commands/agent.js +1001 -12
- package/src/cli/simple-commands/agent.ts +137 -0
- package/src/cli/simple-commands/config.ts +127 -0
- package/src/cli/simple-commands/env-template.js +190 -0
- package/src/cli/simple-commands/init/help.js +23 -0
- package/src/cli/simple-commands/init/index.js +84 -6
- package/src/cli/simple-commands/memory.js +363 -16
- package/src/cli/simple-commands/proxy.js +384 -0
- package/src/cli/simple-commands/sparc.js +16 -19
- package/src/execution/agent-executor.ts +306 -0
- package/src/execution/index.ts +19 -0
- package/src/execution/provider-manager.ts +187 -0
- package/src/hooks/redaction-hook.ts +115 -0
- package/src/utils/key-redactor.js +178 -0
- package/src/utils/key-redactor.ts +184 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
# ReasoningBank Integration Architecture
|
|
2
|
+
|
|
3
|
+
## System Overview
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
┌──────────────────────────────────────────────────────────────────┐
|
|
7
|
+
│ claude-flow v2.7.0 │
|
|
8
|
+
│ │
|
|
9
|
+
│ ┌────────────────┐ ┌─────────────────┐ │
|
|
10
|
+
│ │ CLI Layer │────────▶│ Agent Executor │ │
|
|
11
|
+
│ │ (agent.js) │ │ (TypeScript) │ │
|
|
12
|
+
│ └────────────────┘ └─────────────────┘ │
|
|
13
|
+
│ │ │ │
|
|
14
|
+
│ │ ▼ │
|
|
15
|
+
│ │ ┌─────────────────┐ │
|
|
16
|
+
│ │ │ Provider Manager│ │
|
|
17
|
+
│ │ │ + RB Config │ │
|
|
18
|
+
│ │ └─────────────────┘ │
|
|
19
|
+
│ │ │ │
|
|
20
|
+
│ └────────────────────────────┼──────────────────────┐ │
|
|
21
|
+
│ │ │ │
|
|
22
|
+
│ ▼ ▼ │
|
|
23
|
+
└──────────────────────────────────────┼──────────────────────┼──┘
|
|
24
|
+
│ │
|
|
25
|
+
┌───────────────────┴──────────────────────┴────┐
|
|
26
|
+
│ agentic-flow@1.4.11 │
|
|
27
|
+
│ │
|
|
28
|
+
│ ┌──────────────────────────────────────┐ │
|
|
29
|
+
│ │ ReasoningBank Engine │ │
|
|
30
|
+
│ │ │ │
|
|
31
|
+
│ │ ┌─────────────────────────────┐ │ │
|
|
32
|
+
│ │ │ 1. RETRIEVE │ │ │
|
|
33
|
+
│ │ │ • Top-k similarity search │ │ │
|
|
34
|
+
│ │ │ • 4-factor scoring │ │ │
|
|
35
|
+
│ │ │ • Domain filtering │ │ │
|
|
36
|
+
│ │ └─────────────────────────────┘ │ │
|
|
37
|
+
│ │ ▼ │ │
|
|
38
|
+
│ │ ┌─────────────────────────────┐ │ │
|
|
39
|
+
│ │ │ 2. JUDGE │ │ │
|
|
40
|
+
│ │ │ • LLM-based evaluation │ │ │
|
|
41
|
+
│ │ │ • Heuristic fallback │ │ │
|
|
42
|
+
│ │ │ • Confidence scoring │ │ │
|
|
43
|
+
│ │ └─────────────────────────────┘ │ │
|
|
44
|
+
│ │ ▼ │ │
|
|
45
|
+
│ │ ┌─────────────────────────────┐ │ │
|
|
46
|
+
│ │ │ 3. DISTILL │ │ │
|
|
47
|
+
│ │ │ • Extract patterns │ │ │
|
|
48
|
+
│ │ │ • PII scrubbing │ │ │
|
|
49
|
+
│ │ │ • Store with confidence │ │ │
|
|
50
|
+
│ │ └─────────────────────────────┘ │ │
|
|
51
|
+
│ │ ▼ │ │
|
|
52
|
+
│ │ ┌─────────────────────────────┐ │ │
|
|
53
|
+
│ │ │ 4. CONSOLIDATE (every 20) │ │ │
|
|
54
|
+
│ │ │ • Deduplicate │ │ │
|
|
55
|
+
│ │ │ • Detect contradictions │ │ │
|
|
56
|
+
│ │ │ • Prune old memories │ │ │
|
|
57
|
+
│ │ └─────────────────────────────┘ │ │
|
|
58
|
+
│ └──────────────────────────────────────┘ │
|
|
59
|
+
│ │ │
|
|
60
|
+
│ ▼ │
|
|
61
|
+
│ ┌─────────────────────┐ │
|
|
62
|
+
│ │ SQLite Database │ │
|
|
63
|
+
│ │ .swarm/memory.db │ │
|
|
64
|
+
│ │ │ │
|
|
65
|
+
│ │ • patterns │ │
|
|
66
|
+
│ │ • embeddings │ │
|
|
67
|
+
│ │ • trajectories │ │
|
|
68
|
+
│ │ • metrics │ │
|
|
69
|
+
│ └─────────────────────┘ │
|
|
70
|
+
└────────────────────────────────────────────────┘
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Data Flow: Task Execution with Memory
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
┌──────────────────────────────────────────────────────────────────┐
|
|
77
|
+
│ User Executes Command │
|
|
78
|
+
└──────────────────────────┬───────────────────────────────────────┘
|
|
79
|
+
│
|
|
80
|
+
▼
|
|
81
|
+
┌──────────────────────────────────────────────────────────────────┐
|
|
82
|
+
│ claude-flow agent run coder "Build REST API" --enable-memory │
|
|
83
|
+
└──────────────────────────┬───────────────────────────────────────┘
|
|
84
|
+
│
|
|
85
|
+
▼
|
|
86
|
+
┌──────────────────────────────────────────────────────────────────┐
|
|
87
|
+
│ CLI Parser (agent.js) │
|
|
88
|
+
│ • Parses flags: --enable-memory, --memory-domain, etc. │
|
|
89
|
+
│ • Creates AgentExecutionOptions object │
|
|
90
|
+
└──────────────────────────┬───────────────────────────────────────┘
|
|
91
|
+
│
|
|
92
|
+
▼
|
|
93
|
+
┌──────────────────────────────────────────────────────────────────┐
|
|
94
|
+
│ AgentExecutor.execute() │
|
|
95
|
+
│ │
|
|
96
|
+
│ Step 1: Initialize Memory (if first time) │
|
|
97
|
+
│ ┌────────────────────────────────────────────────────────┐ │
|
|
98
|
+
│ │ initializeMemory() │ │
|
|
99
|
+
│ │ • Runs: agentic-flow reasoningbank init │ │
|
|
100
|
+
│ │ • Creates .swarm/memory.db │ │
|
|
101
|
+
│ │ • Sets memoryEnabled = true │ │
|
|
102
|
+
│ └────────────────────────────────────────────────────────┘ │
|
|
103
|
+
│ │ │
|
|
104
|
+
│ ▼ │
|
|
105
|
+
│ Step 2: Retrieve Memories (pre-task) │
|
|
106
|
+
│ ┌────────────────────────────────────────────────────────┐ │
|
|
107
|
+
│ │ retrieveMemories(task, options) │ │
|
|
108
|
+
│ │ • Query: "Build REST API" │ │
|
|
109
|
+
│ │ • Top-k: 3 memories │ │
|
|
110
|
+
│ │ • Domain filter: "api" │ │
|
|
111
|
+
│ │ • Returns: [ │ │
|
|
112
|
+
│ │ {id: "m1", title: "API routing pattern"}, │ │
|
|
113
|
+
│ │ {id: "m2", title: "Auth middleware"}, │ │
|
|
114
|
+
│ │ {id: "m3", title: "Error handling"} │ │
|
|
115
|
+
│ │ ] │ │
|
|
116
|
+
│ └────────────────────────────────────────────────────────┘ │
|
|
117
|
+
│ │ │
|
|
118
|
+
│ ▼ │
|
|
119
|
+
│ Step 3: Inject Memories into Prompt │
|
|
120
|
+
│ ┌────────────────────────────────────────────────────────┐ │
|
|
121
|
+
│ │ buildCommand(options, memories) │ │
|
|
122
|
+
│ │ • Original: "Build REST API" │ │
|
|
123
|
+
│ │ • Enhanced: │ │
|
|
124
|
+
│ │ "Memory 1: API routing pattern │ │
|
|
125
|
+
│ │ Use express.Router() for modularity │ │
|
|
126
|
+
│ │ │ │
|
|
127
|
+
│ │ Memory 2: Auth middleware │ │
|
|
128
|
+
│ │ Apply JWT verification before protected routes │ │
|
|
129
|
+
│ │ │ │
|
|
130
|
+
│ │ Memory 3: Error handling │ │
|
|
131
|
+
│ │ Use async/await with try-catch wrapper │ │
|
|
132
|
+
│ │ │ │
|
|
133
|
+
│ │ --- │ │
|
|
134
|
+
│ │ Task: Build REST API" │ │
|
|
135
|
+
│ └────────────────────────────────────────────────────────┘ │
|
|
136
|
+
│ │ │
|
|
137
|
+
│ ▼ │
|
|
138
|
+
│ Step 4: Execute Agent │
|
|
139
|
+
│ ┌────────────────────────────────────────────────────────┐ │
|
|
140
|
+
│ │ execAsync(command) │ │
|
|
141
|
+
│ │ • Runs: npx agentic-flow --agent coder --task "..." │ │
|
|
142
|
+
│ │ • Agent receives memories in context │ │
|
|
143
|
+
│ │ • Generates code using learned patterns │ │
|
|
144
|
+
│ │ • Returns: { stdout, stderr } │ │
|
|
145
|
+
│ └────────────────────────────────────────────────────────┘ │
|
|
146
|
+
│ │ │
|
|
147
|
+
│ ▼ │
|
|
148
|
+
│ Step 5: Learn from Execution (post-task) │
|
|
149
|
+
│ ┌────────────────────────────────────────────────────────┐ │
|
|
150
|
+
│ │ learnFromExecution(taskId, result, memories) │ │
|
|
151
|
+
│ │ • Verdict: "success" (task completed) │ │
|
|
152
|
+
│ │ • Confidence: 0.7 │ │
|
|
153
|
+
│ │ • Extracts: "REST API with Express boilerplate" │ │
|
|
154
|
+
│ │ • Stores new memory with id: "m47" │ │
|
|
155
|
+
│ │ • Increments usage count for m1, m2, m3 │ │
|
|
156
|
+
│ └────────────────────────────────────────────────────────┘ │
|
|
157
|
+
│ │ │
|
|
158
|
+
│ ▼ │
|
|
159
|
+
│ Step 6: Auto-Consolidation Check │
|
|
160
|
+
│ ┌────────────────────────────────────────────────────────┐ │
|
|
161
|
+
│ │ taskCounter++ → 20 tasks completed │ │
|
|
162
|
+
│ │ • Triggers consolidateMemories() │ │
|
|
163
|
+
│ │ • Deduplicates: 2 similar memories merged │ │
|
|
164
|
+
│ │ • Prunes: 1 old unused memory removed │ │
|
|
165
|
+
│ │ • Duration: 8ms │ │
|
|
166
|
+
│ └────────────────────────────────────────────────────────┘ │
|
|
167
|
+
│ │ │
|
|
168
|
+
│ ▼ │
|
|
169
|
+
│ Step 7: Return Result │
|
|
170
|
+
│ ┌────────────────────────────────────────────────────────┐ │
|
|
171
|
+
│ │ AgentExecutionResult { │ │
|
|
172
|
+
│ │ success: true, │ │
|
|
173
|
+
│ │ output: "REST API code...", │ │
|
|
174
|
+
│ │ duration: 2847ms, │ │
|
|
175
|
+
│ │ memoryEnabled: true, │ │
|
|
176
|
+
│ │ memoriesRetrieved: 3, │ │
|
|
177
|
+
│ │ memoriesUsed: ["m1", "m2", "m3"], │ │
|
|
178
|
+
│ │ memoryLearned: true, │ │
|
|
179
|
+
│ │ newMemoryIds: ["m47"], │ │
|
|
180
|
+
│ │ memoryVerdict: "success", │ │
|
|
181
|
+
│ │ memoryConfidence: 0.7 │ │
|
|
182
|
+
│ │ } │ │
|
|
183
|
+
│ └────────────────────────────────────────────────────────┘ │
|
|
184
|
+
└──────────────────────────┬───────────────────────────────────────┘
|
|
185
|
+
│
|
|
186
|
+
▼
|
|
187
|
+
┌──────────────────────────────────────────────────────────────────┐
|
|
188
|
+
│ CLI Output │
|
|
189
|
+
│ │
|
|
190
|
+
│ 🧠 Retrieved 3 relevant memories │
|
|
191
|
+
│ Memory 1: API routing pattern (confidence: 0.85) │
|
|
192
|
+
│ Memory 2: Auth middleware (confidence: 0.78) │
|
|
193
|
+
│ Memory 3: Error handling (confidence: 0.71) │
|
|
194
|
+
│ │
|
|
195
|
+
│ [Agent generates code output...] │
|
|
196
|
+
│ │
|
|
197
|
+
│ ✅ Task completed successfully │
|
|
198
|
+
│ 📚 Learned 1 new memory: REST API with Express boilerplate │
|
|
199
|
+
│ ⚡ Execution time: 2.8s (46% faster than average) │
|
|
200
|
+
└──────────────────────────────────────────────────────────────────┘
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Memory Scoring Algorithm
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
For each candidate memory:
|
|
207
|
+
|
|
208
|
+
1. Embedding Similarity (α = 0.65)
|
|
209
|
+
┌─────────────────────────────────────┐
|
|
210
|
+
│ similarity = cosine(query, memory) │
|
|
211
|
+
│ = dot(Q, M) / (||Q||·||M||) │
|
|
212
|
+
│ │
|
|
213
|
+
│ Example: │
|
|
214
|
+
│ Query: "Build REST API" │
|
|
215
|
+
│ Memory: "API routing pattern" │
|
|
216
|
+
│ → similarity = 0.87 │
|
|
217
|
+
└─────────────────────────────────────┘
|
|
218
|
+
|
|
219
|
+
2. Recency (β = 0.15)
|
|
220
|
+
┌─────────────────────────────────────┐
|
|
221
|
+
│ recency = exp(-age_days / 30) │
|
|
222
|
+
│ │
|
|
223
|
+
│ Example: │
|
|
224
|
+
│ Memory created 10 days ago │
|
|
225
|
+
│ → recency = exp(-10/30) = 0.72 │
|
|
226
|
+
└─────────────────────────────────────┘
|
|
227
|
+
|
|
228
|
+
3. Reliability (γ = 0.20)
|
|
229
|
+
┌─────────────────────────────────────┐
|
|
230
|
+
│ reliability = min( │
|
|
231
|
+
│ confidence × sqrt(usage / 10), │
|
|
232
|
+
│ 1.0 │
|
|
233
|
+
│ ) │
|
|
234
|
+
│ │
|
|
235
|
+
│ Example: │
|
|
236
|
+
│ confidence = 0.8, usage = 25 │
|
|
237
|
+
│ → reliability = min( │
|
|
238
|
+
│ 0.8 × sqrt(25/10), 1.0 │
|
|
239
|
+
│ ) = min(0.8 × 1.58, 1.0) = 1.0 │
|
|
240
|
+
└─────────────────────────────────────┘
|
|
241
|
+
|
|
242
|
+
4. Diversity Penalty (δ = 0.10)
|
|
243
|
+
┌─────────────────────────────────────┐
|
|
244
|
+
│ diversity = max_similarity_to_ │
|
|
245
|
+
│ already_selected │
|
|
246
|
+
│ │
|
|
247
|
+
│ Prevents redundant memories │
|
|
248
|
+
└─────────────────────────────────────┘
|
|
249
|
+
|
|
250
|
+
5. Final Score
|
|
251
|
+
┌─────────────────────────────────────┐
|
|
252
|
+
│ score = α·similarity + β·recency + │
|
|
253
|
+
│ γ·reliability - δ·diversity │
|
|
254
|
+
│ │
|
|
255
|
+
│ Example: │
|
|
256
|
+
│ = 0.65×0.87 + 0.15×0.72 + │
|
|
257
|
+
│ 0.20×1.0 - 0.10×0.10 │
|
|
258
|
+
│ = 0.566 + 0.108 + 0.20 - 0.01 │
|
|
259
|
+
│ = 0.864 │
|
|
260
|
+
│ │
|
|
261
|
+
│ ✅ High score → Will be retrieved │
|
|
262
|
+
└─────────────────────────────────────┘
|
|
263
|
+
|
|
264
|
+
6. Sort and Select Top-k
|
|
265
|
+
┌─────────────────────────────────────┐
|
|
266
|
+
│ memories.sort(by: score) │
|
|
267
|
+
│ return memories.slice(0, k) │
|
|
268
|
+
│ │
|
|
269
|
+
│ Example (k=3): │
|
|
270
|
+
│ [ │
|
|
271
|
+
│ {score: 0.864, title: "m1"}, │
|
|
272
|
+
│ {score: 0.791, title: "m2"}, │
|
|
273
|
+
│ {score: 0.746, title: "m3"} │
|
|
274
|
+
│ ] │
|
|
275
|
+
└─────────────────────────────────────┘
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Configuration Layers
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
┌────────────────────────────────────────────────────────────────┐
|
|
282
|
+
│ Layer 1: Runtime Flags (Highest Priority) │
|
|
283
|
+
│ • --enable-memory │
|
|
284
|
+
│ • --memory-k 5 │
|
|
285
|
+
│ • --memory-domain web │
|
|
286
|
+
│ Overrides all other layers │
|
|
287
|
+
└────────────────────────┬───────────────────────────────────────┘
|
|
288
|
+
│
|
|
289
|
+
▼
|
|
290
|
+
┌────────────────────────────────────────────────────────────────┐
|
|
291
|
+
│ Layer 2: User Configuration (~/.claude/settings.json) │
|
|
292
|
+
│ { │
|
|
293
|
+
│ "claude-flow": { │
|
|
294
|
+
│ "execution": { │
|
|
295
|
+
│ "reasoningbank": { │
|
|
296
|
+
│ "enabled": true, │
|
|
297
|
+
│ "retrievalK": 3, │
|
|
298
|
+
│ "domains": ["web", "api"] │
|
|
299
|
+
│ } │
|
|
300
|
+
│ } │
|
|
301
|
+
│ } │
|
|
302
|
+
│ } │
|
|
303
|
+
│ Persists across sessions │
|
|
304
|
+
└────────────────────────┬───────────────────────────────────────┘
|
|
305
|
+
│
|
|
306
|
+
▼
|
|
307
|
+
┌────────────────────────────────────────────────────────────────┐
|
|
308
|
+
│ Layer 3: Default Configuration (provider-manager.ts) │
|
|
309
|
+
│ getDefaultConfig() { │
|
|
310
|
+
│ reasoningbank: { │
|
|
311
|
+
│ enabled: false, │
|
|
312
|
+
│ database: '.swarm/memory.db', │
|
|
313
|
+
│ retrievalK: 3, │
|
|
314
|
+
│ autoConsolidate: true, │
|
|
315
|
+
│ consolidateEvery: 20, │
|
|
316
|
+
│ minConfidence: 0.5 │
|
|
317
|
+
│ } │
|
|
318
|
+
│ } │
|
|
319
|
+
│ Fallback when no configuration exists │
|
|
320
|
+
└────────────────────────────────────────────────────────────────┘
|
|
321
|
+
|
|
322
|
+
Resolution Order:
|
|
323
|
+
1. Check runtime flags
|
|
324
|
+
2. If not set, check user config
|
|
325
|
+
3. If not set, use defaults
|
|
326
|
+
|
|
327
|
+
Example:
|
|
328
|
+
$ claude-flow agent run coder "task" --memory-k 5
|
|
329
|
+
|
|
330
|
+
Resolved config:
|
|
331
|
+
{
|
|
332
|
+
enabled: true, // from --enable-memory (implicit)
|
|
333
|
+
retrievalK: 5, // from --memory-k flag
|
|
334
|
+
database: '.swarm/memory.db', // from user config
|
|
335
|
+
autoConsolidate: true // from defaults
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## File Structure After Integration
|
|
340
|
+
|
|
341
|
+
```
|
|
342
|
+
claude-flow/
|
|
343
|
+
├── package.json # agentic-flow@1.4.11
|
|
344
|
+
│
|
|
345
|
+
├── src/
|
|
346
|
+
│ ├── execution/
|
|
347
|
+
│ │ ├── agent-executor.ts # ✅ Extended with RB methods
|
|
348
|
+
│ │ └── provider-manager.ts # ✅ Added RB config
|
|
349
|
+
│ │
|
|
350
|
+
│ ├── cli/
|
|
351
|
+
│ │ └── simple-commands/
|
|
352
|
+
│ │ └── agent.js # ✅ Added --enable-memory flags
|
|
353
|
+
│ │ # ✅ Added memory subcommands
|
|
354
|
+
│ │
|
|
355
|
+
│ └── types/
|
|
356
|
+
│ └── reasoningbank.ts # 🆕 TypeScript interfaces
|
|
357
|
+
│
|
|
358
|
+
├── tests/
|
|
359
|
+
│ ├── unit/
|
|
360
|
+
│ │ ├── agent-executor.test.ts # 🆕 RB unit tests
|
|
361
|
+
│ │ └── provider-manager.test.ts # 🆕 Config tests
|
|
362
|
+
│ │
|
|
363
|
+
│ └── integration/
|
|
364
|
+
│ └── reasoningbank.test.ts # 🆕 E2E tests
|
|
365
|
+
│
|
|
366
|
+
├── docs/
|
|
367
|
+
│ ├── REASONINGBANK_INTEGRATION_PLAN.md # 🆕 This doc
|
|
368
|
+
│ ├── REASONINGBANK_ARCHITECTURE.md # 🆕 Architecture
|
|
369
|
+
│ ├── REASONINGBANK_GUIDE.md # 🆕 User guide
|
|
370
|
+
│ └── examples/
|
|
371
|
+
│ └── reasoningbank/
|
|
372
|
+
│ ├── basic-usage.md # 🆕 Examples
|
|
373
|
+
│ ├── domain-filtering.md # 🆕 Examples
|
|
374
|
+
│ └── team-sharing.md # 🆕 Examples
|
|
375
|
+
│
|
|
376
|
+
└── .swarm/ # Created at runtime
|
|
377
|
+
└── memory.db # SQLite database
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Performance Characteristics
|
|
381
|
+
|
|
382
|
+
```
|
|
383
|
+
┌───────────────────────────────────────────────────────────────┐
|
|
384
|
+
│ Operation Performance (ms) │
|
|
385
|
+
├───────────────────────────────────────────────────────────────┤
|
|
386
|
+
│ │
|
|
387
|
+
│ Database Connection ██ 1ms │
|
|
388
|
+
│ Memory Retrieval (k=3) ████ 3ms │
|
|
389
|
+
│ Memory Insertion ██████ 1-2ms │
|
|
390
|
+
│ Batch Insert (100) ████████████████████ 112ms │
|
|
391
|
+
│ Consolidation ██████ 5-10ms │
|
|
392
|
+
│ Embedding (Claude API) ███████████████████████ 500ms │
|
|
393
|
+
│ Judgment (Claude API) ████████████████████████ 800ms │
|
|
394
|
+
│ │
|
|
395
|
+
└───────────────────────────────────────────────────────────────┘
|
|
396
|
+
|
|
397
|
+
Without API Keys (Heuristic Mode):
|
|
398
|
+
• Retrieval: 1-3ms (local only)
|
|
399
|
+
• Judgment: <1ms (rule-based)
|
|
400
|
+
• Total overhead: <5ms per task
|
|
401
|
+
|
|
402
|
+
With API Keys (LLM Mode):
|
|
403
|
+
• Retrieval: 1-3ms (local)
|
|
404
|
+
• Judgment: 800ms (API call)
|
|
405
|
+
• Total overhead: ~1s per task
|
|
406
|
+
• Accuracy: 95% vs 70% heuristic
|
|
407
|
+
|
|
408
|
+
Memory Growth:
|
|
409
|
+
• 1,000 memories: 1MB storage, 3ms retrieval
|
|
410
|
+
• 10,000 memories: 10MB storage, 8ms retrieval
|
|
411
|
+
• 100,000 memories: 100MB storage, 25ms retrieval
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
## Error Handling Flow
|
|
415
|
+
|
|
416
|
+
```
|
|
417
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
418
|
+
│ Graceful Degradation Strategy │
|
|
419
|
+
└──────────────────────────────────────────────────────────────┘
|
|
420
|
+
|
|
421
|
+
Error: Memory database not found
|
|
422
|
+
↓
|
|
423
|
+
Auto-initialize database
|
|
424
|
+
↓
|
|
425
|
+
If init fails → Disable memory, continue without learning
|
|
426
|
+
✅ Task still executes
|
|
427
|
+
|
|
428
|
+
Error: Memory retrieval fails
|
|
429
|
+
↓
|
|
430
|
+
Log warning
|
|
431
|
+
↓
|
|
432
|
+
Continue with empty memory array
|
|
433
|
+
✅ Task executes without context
|
|
434
|
+
|
|
435
|
+
Error: Learning fails
|
|
436
|
+
↓
|
|
437
|
+
Log warning
|
|
438
|
+
↓
|
|
439
|
+
Skip memory creation
|
|
440
|
+
✅ Task result returned
|
|
441
|
+
|
|
442
|
+
Error: Consolidation fails
|
|
443
|
+
↓
|
|
444
|
+
Log warning
|
|
445
|
+
↓
|
|
446
|
+
Retry on next threshold
|
|
447
|
+
✅ System continues working
|
|
448
|
+
|
|
449
|
+
Error: API key missing (LLM mode)
|
|
450
|
+
↓
|
|
451
|
+
Fallback to heuristic judgment
|
|
452
|
+
↓
|
|
453
|
+
Accuracy: 70% vs 95%
|
|
454
|
+
✅ Learning still works
|
|
455
|
+
|
|
456
|
+
Error: Database corruption
|
|
457
|
+
↓
|
|
458
|
+
Backup and recreate
|
|
459
|
+
↓
|
|
460
|
+
Import from backup if available
|
|
461
|
+
✅ System recovers
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
---
|
|
465
|
+
|
|
466
|
+
**Next Steps:**
|
|
467
|
+
1. Review architecture with team
|
|
468
|
+
2. Approve integration plan
|
|
469
|
+
3. Begin Phase 1: Dependency update
|
|
470
|
+
4. Implement Phase 2: Interface extensions
|
|
471
|
+
5. Test and iterate
|
|
472
|
+
|
|
473
|
+
**Questions?**
|
|
474
|
+
- GitHub: https://github.com/ruvnet/claude-code-flow/issues
|
|
475
|
+
- Discord: https://discord.gg/claude-flow
|