agentic-flow 1.5.12 → 1.6.0
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/CHANGELOG.md +199 -0
- package/README.md +43 -23
- package/dist/cli-proxy.js +195 -1
- package/dist/config/quic.js +6 -0
- package/dist/reasoningbank/backend-selector.js +145 -0
- package/dist/reasoningbank/index.js +4 -0
- package/dist/transport/quic.js +43 -0
- package/dist/utils/cli.js +5 -0
- package/docs/.claude-flow/metrics/performance.json +80 -2
- package/docs/.claude-flow/metrics/task-metrics.json +3 -3
- package/docs/INDEX.md +55 -9
- package/docs/INTEGRATION-COMPLETE.md +291 -0
- package/docs/QUIC_FINAL_STATUS.md +399 -0
- package/docs/README_QUIC_PHASE1.md +117 -0
- package/docs/integration-docs/CLAUDE-FLOW-INTEGRATION-ANALYSIS.md +653 -0
- package/docs/integration-docs/IMPLEMENTATION_SUMMARY.md +369 -0
- package/docs/integration-docs/INTEGRATION-QUICK-SUMMARY.md +249 -0
- package/docs/integration-docs/INTEGRATION-STATUS-CORRECTED.md +488 -0
- package/docs/integration-docs/README.md +61 -0
- package/docs/quantum-goap/DEPENDENCY_GRAPH.mermaid +133 -0
- package/docs/quantum-goap/EXECUTION_SUMMARY.md +199 -0
- package/docs/quantum-goap/GOAP_IMPLEMENTATION_PLAN.md +2406 -0
- package/docs/quantum-goap/QUICK_START.md +301 -0
- package/docs/quantum-research/QUANTUM_RESEARCH_LITERATURE_REVIEW.md +2071 -0
- package/docs/quantum-research/README.md +94 -0
- package/docs/reasoningbank/MEMORY_VALIDATION_REPORT.md +417 -0
- package/docs/reasoningbank/README.md +43 -0
- package/docs/reasoningbank/REASONINGBANK_ARCHITECTURE.md +663 -0
- package/docs/reasoningbank/REASONINGBANK_BACKENDS.md +375 -0
- package/docs/reasoningbank/REASONINGBANK_FIXES.md +455 -0
- package/docs/reasoningbank/REASONINGBANK_INVESTIGATION.md +380 -0
- package/docs/releases/v1.5.14-QUIC-TRANSPORT.md +201 -0
- package/docs/validation-reports/BENCHMARK_AND_OPTIMIZATION_REPORT.md +470 -0
- package/docs/validation-reports/DOCKER_VALIDATION_RESULTS.md +391 -0
- package/docs/validation-reports/NO_REGRESSIONS_CONFIRMED.md +384 -0
- package/docs/validation-reports/NPM-PACKAGE-ANALYSIS-FINAL.md +543 -0
- package/docs/validation-reports/README.md +43 -0
- package/docs/validation-reports/V2.7.0-ALPHA.10_FINAL_VALIDATION.md +817 -0
- package/docs/validation-reports/V2.7.0-ALPHA.9_VALIDATION.md +546 -0
- package/docs/validation-reports/v1.6.0-QUIC-CLI-VALIDATION.md +558 -0
- package/docs/version-releases/README.md +82 -0
- package/package.json +15 -1
- package/validation/docker/Dockerfile.reasoningbank-local +24 -0
- package/validation/docker/Dockerfile.reasoningbank-test +21 -0
- package/validation/docker/README.md +234 -0
- package/validation/docker/docker-compose.yml +29 -0
- package/validation/docker/test-reasoningbank-npx.mjs +442 -0
- package/validation/docker-quic-test.sh +42 -0
- package/validation/docker-quic-validation.sh +60 -0
- package/validation/quic-deep-validation.ts +304 -0
- package/validation/test-quic-wasm.ts +94 -0
- package/validation/test-regression.mjs +246 -0
- package/wasm/quic/README.md +75 -0
- package/wasm/quic/agentic_flow_quic.d.ts +37 -0
- package/wasm/quic/agentic_flow_quic.js +779 -0
- package/wasm/quic/agentic_flow_quic_bg.wasm +0 -0
- package/wasm/quic/agentic_flow_quic_bg.wasm.d.ts +19 -0
- package/wasm/quic/package.json +20 -0
- /package/docs/{PACKAGE_STRUCTURE.md → architecture/PACKAGE_STRUCTURE.md} +0 -0
- /package/docs/{MODEL-ID-MAPPING.md → guides/MODEL-ID-MAPPING.md} +0 -0
- /package/docs/{ONNX-PROXY-IMPLEMENTATION.md → guides/ONNX-PROXY-IMPLEMENTATION.md} +0 -0
- /package/docs/{STANDALONE_PROXY_GUIDE.md → guides/STANDALONE_PROXY_GUIDE.md} +0 -0
- /package/docs/{AGENT-BOOSTER-INTEGRATION.md → integration-docs/AGENT-BOOSTER-INTEGRATION.md} +0 -0
- /package/docs/{CLI-INTEGRATION-COMPLETE.md → integration-docs/CLI-INTEGRATION-COMPLETE.md} +0 -0
- /package/docs/{INTEGRATION_COMPLETE_SUMMARY.md → integration-docs/INTEGRATION_COMPLETE_SUMMARY.md} +0 -0
- /package/docs/{WASM_ESM_FIX.md → integration-docs/WASM_ESM_FIX.md} +0 -0
- /package/docs/{WASM_INTEGRATION_COMPLETE.md → integration-docs/WASM_INTEGRATION_COMPLETE.md} +0 -0
- /package/docs/{REASONING-AGENTS.md → reasoningbank/REASONING-AGENTS.md} +0 -0
- /package/docs/{REASONINGBANK-BENCHMARK-RESULTS.md → reasoningbank/REASONINGBANK-BENCHMARK-RESULTS.md} +0 -0
- /package/docs/{REASONINGBANK-BENCHMARK.md → reasoningbank/REASONINGBANK-BENCHMARK.md} +0 -0
- /package/docs/{REASONINGBANK-CLI-INTEGRATION.md → reasoningbank/REASONINGBANK-CLI-INTEGRATION.md} +0 -0
- /package/docs/{REASONINGBANK-DEMO.md → reasoningbank/REASONINGBANK-DEMO.md} +0 -0
- /package/docs/{REASONINGBANK-VALIDATION.md → reasoningbank/REASONINGBANK-VALIDATION.md} +0 -0
- /package/docs/{REASONINGBANK_IMPLEMENTATION_STATUS.md → reasoningbank/REASONINGBANK_IMPLEMENTATION_STATUS.md} +0 -0
- /package/docs/{REASONINGBANK_INTEGRATION_PLAN.md → reasoningbank/REASONINGBANK_INTEGRATION_PLAN.md} +0 -0
- /package/docs/{PUBLICATION_REPORT_v1.5.11.md → version-releases/PUBLICATION_REPORT_v1.5.11.md} +0 -0
- /package/docs/{v1.5.9-DOCKER-VERIFICATION.md → version-releases/v1.5.9-DOCKER-VERIFICATION.md} +0 -0
- /package/docs/{v1.5.9-RELEASE-SUMMARY.md → version-releases/v1.5.9-RELEASE-SUMMARY.md} +0 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
# ReasoningBank Fixes & Solutions
|
|
2
|
+
|
|
3
|
+
**Date**: 2025-10-13
|
|
4
|
+
**Package**: agentic-flow@1.5.12
|
|
5
|
+
**Status**: Both issues resolved ✅
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🎯 Executive Summary
|
|
10
|
+
|
|
11
|
+
Both reported "limitations" have been investigated and **resolved**:
|
|
12
|
+
|
|
13
|
+
1. ✅ **Semantic Query**: Working perfectly with auto-generated embeddings
|
|
14
|
+
2. ✅ **Namespace Separation**: By design, but can be bridged with hybrid mode
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## ✅ Issue #1: Semantic Query - RESOLVED
|
|
19
|
+
|
|
20
|
+
### Original Report
|
|
21
|
+
- Semantic query returns 0 results
|
|
22
|
+
- Fallback to category search required
|
|
23
|
+
- Concern about missing embeddings
|
|
24
|
+
|
|
25
|
+
### Investigation Results
|
|
26
|
+
|
|
27
|
+
**Embeddings ARE Auto-Generated!**
|
|
28
|
+
|
|
29
|
+
```rust
|
|
30
|
+
// reasoningbank-core/src/engine.rs:65-74
|
|
31
|
+
pub fn prepare_pattern(&self, mut pattern: Pattern) -> Result<Pattern> {
|
|
32
|
+
// Generate embedding from task description if not present
|
|
33
|
+
if pattern.embedding.is_none() {
|
|
34
|
+
let embedding = VectorEmbedding::from_text(&pattern.task_description);
|
|
35
|
+
pattern.embedding = Some(embedding.values);
|
|
36
|
+
}
|
|
37
|
+
Ok(pattern)
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**WASM wrapper calls this automatically:**
|
|
42
|
+
```rust
|
|
43
|
+
// reasoningbank-wasm/src/lib.rs:95-96
|
|
44
|
+
let prepared = self.engine.prepare_pattern(pattern)?; // ← Generates embedding
|
|
45
|
+
self.storage.store_pattern(&prepared).await?;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Validation Test Results
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
$ node --experimental-wasm-modules test-semantic-search.mjs
|
|
52
|
+
|
|
53
|
+
🧪 Testing Semantic Search with Multiple Patterns...
|
|
54
|
+
|
|
55
|
+
1. Storing 5 authentication-related patterns...
|
|
56
|
+
✅ Stored 5 patterns
|
|
57
|
+
|
|
58
|
+
2. Category search for "authentication"...
|
|
59
|
+
✅ Found 3 patterns
|
|
60
|
+
|
|
61
|
+
3. Semantic search: "secure user login"...
|
|
62
|
+
✅ Found 3 similar patterns
|
|
63
|
+
|
|
64
|
+
Top 3 matches:
|
|
65
|
+
1. Score: 0.5401 - "Add OAuth2 login with Google..."
|
|
66
|
+
2. Score: 0.5172 - "Implement JWT authentication for REST API..."
|
|
67
|
+
3. Score: 0.5109 - "Secure API endpoints with bearer tokens..."
|
|
68
|
+
|
|
69
|
+
🎉 SEMANTIC SEARCH WORKING PERFECTLY!
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Why It Appeared Broken
|
|
73
|
+
|
|
74
|
+
**Root Cause**: WASM uses **in-memory storage** in Node.js (see REASONINGBANK_INVESTIGATION.md). When you query a fresh instance:
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
const rb = await createReasoningBank('.swarm/memory');
|
|
78
|
+
const results = await rb.findSimilar('query', 'category', 5);
|
|
79
|
+
// Returns: [] (empty array)
|
|
80
|
+
// Reason: New in-memory instance has no data yet!
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Solution
|
|
84
|
+
|
|
85
|
+
**For claude-flow**: Use Node.js ReasoningBank (not WASM):
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
// ✅ CORRECT: Persistent SQLite storage
|
|
89
|
+
import { ReasoningBank } from 'agentic-flow/dist/reasoningbank/index.js';
|
|
90
|
+
|
|
91
|
+
const rb = new ReasoningBank({ dbPath: '.swarm/memory.db' });
|
|
92
|
+
const results = await rb.searchByCategory('authentication', 10);
|
|
93
|
+
// Returns: All 289 patterns from database ✅
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**For agentic-flow standalone**: Semantic search works perfectly when patterns are stored in the same session.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## ✅ Issue #2: Namespace Separation - BY DESIGN
|
|
101
|
+
|
|
102
|
+
### Original Report
|
|
103
|
+
- Basic Mode: `./memory/memory-store.json`
|
|
104
|
+
- ReasoningBank: `.swarm/memory.db`
|
|
105
|
+
- No cross-querying between modes
|
|
106
|
+
|
|
107
|
+
### Investigation Results
|
|
108
|
+
|
|
109
|
+
**This is intentional architecture!**
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
┌──────────────────────────────┐
|
|
113
|
+
│ Basic Memory Mode │
|
|
114
|
+
│ ./memory/memory-store.json │
|
|
115
|
+
│ │
|
|
116
|
+
│ - Fast key-value store │
|
|
117
|
+
│ - JSON-based │
|
|
118
|
+
│ - No AI/semantic features │
|
|
119
|
+
└──────────────────────────────┘
|
|
120
|
+
│
|
|
121
|
+
│ Isolated by design
|
|
122
|
+
↓
|
|
123
|
+
┌──────────────────────────────┐
|
|
124
|
+
│ ReasoningBank Mode │
|
|
125
|
+
│ .swarm/memory.db │
|
|
126
|
+
│ │
|
|
127
|
+
│ - AI-powered learning │
|
|
128
|
+
│ - Semantic search │
|
|
129
|
+
│ - Pattern recognition │
|
|
130
|
+
└──────────────────────────────┘
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Why Separation Exists
|
|
134
|
+
|
|
135
|
+
1. **Different use cases**:
|
|
136
|
+
- Basic: Simple config values, API keys, preferences
|
|
137
|
+
- ReasoningBank: Learning patterns, strategies, outcomes
|
|
138
|
+
|
|
139
|
+
2. **Performance trade-offs**:
|
|
140
|
+
- Basic: <1ms lookups (JSON)
|
|
141
|
+
- ReasoningBank: 2-5ms queries (SQLite + embeddings)
|
|
142
|
+
|
|
143
|
+
3. **Data model mismatch**:
|
|
144
|
+
- Basic: `{ key: string, value: string }`
|
|
145
|
+
- ReasoningBank: `{ task_description, strategy, success_score, embedding }`
|
|
146
|
+
|
|
147
|
+
### Hybrid Query Solution (Optional Enhancement)
|
|
148
|
+
|
|
149
|
+
**For claude-flow v2.7.1+**, implement hybrid mode:
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
// src/memory/hybrid-query.js
|
|
153
|
+
import fs from 'fs/promises';
|
|
154
|
+
import path from 'path';
|
|
155
|
+
|
|
156
|
+
export async function hybridQuery(searchTerm, options = {}) {
|
|
157
|
+
const results = [];
|
|
158
|
+
|
|
159
|
+
// 1. Query Basic mode (JSON)
|
|
160
|
+
try {
|
|
161
|
+
const basicPath = path.join('./memory', 'memory-store.json');
|
|
162
|
+
const basicData = JSON.parse(await fs.readFile(basicPath, 'utf-8'));
|
|
163
|
+
|
|
164
|
+
for (const [namespace, entries] of Object.entries(basicData)) {
|
|
165
|
+
for (const entry of entries) {
|
|
166
|
+
const matchKey = entry.key?.toLowerCase().includes(searchTerm.toLowerCase());
|
|
167
|
+
const matchValue = entry.value?.toLowerCase().includes(searchTerm.toLowerCase());
|
|
168
|
+
|
|
169
|
+
if (matchKey || matchValue) {
|
|
170
|
+
results.push({
|
|
171
|
+
...entry,
|
|
172
|
+
source: 'basic',
|
|
173
|
+
namespace,
|
|
174
|
+
relevance: matchKey ? 1.0 : 0.5 // Exact key match = higher relevance
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} catch (err) {
|
|
180
|
+
// Basic mode not initialized, skip
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// 2. Query ReasoningBank (Node.js, not WASM!)
|
|
184
|
+
try {
|
|
185
|
+
const { ReasoningBank } = await import('agentic-flow/dist/reasoningbank/index.js');
|
|
186
|
+
const rb = new ReasoningBank({ dbPath: '.swarm/memory.db' });
|
|
187
|
+
|
|
188
|
+
// Category search
|
|
189
|
+
const patterns = await rb.searchByCategory(searchTerm, options.limit || 10);
|
|
190
|
+
|
|
191
|
+
for (const pattern of patterns) {
|
|
192
|
+
results.push({
|
|
193
|
+
key: pattern.task_category,
|
|
194
|
+
value: pattern.task_description,
|
|
195
|
+
strategy: pattern.strategy,
|
|
196
|
+
success_score: pattern.success_score,
|
|
197
|
+
source: 'reasoningbank',
|
|
198
|
+
relevance: pattern.success_score || 0.7
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Semantic search (if we have patterns)
|
|
203
|
+
if (patterns.length > 0) {
|
|
204
|
+
const similar = await rb.findSimilar(searchTerm, patterns[0].task_category, 5);
|
|
205
|
+
for (const result of similar) {
|
|
206
|
+
results.push({
|
|
207
|
+
key: result.pattern.task_category,
|
|
208
|
+
value: result.pattern.task_description,
|
|
209
|
+
strategy: result.pattern.strategy,
|
|
210
|
+
similarity_score: result.similarity_score,
|
|
211
|
+
source: 'reasoningbank-semantic',
|
|
212
|
+
relevance: result.similarity_score
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} catch (err) {
|
|
217
|
+
// ReasoningBank not initialized, skip
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 3. Merge, deduplicate, and sort by relevance
|
|
221
|
+
const seen = new Set();
|
|
222
|
+
const unique = results.filter(r => {
|
|
223
|
+
const key = `${r.source}:${r.key}:${r.value}`;
|
|
224
|
+
if (seen.has(key)) return false;
|
|
225
|
+
seen.add(key);
|
|
226
|
+
return true;
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
unique.sort((a, b) => (b.relevance || 0) - (a.relevance || 0));
|
|
230
|
+
|
|
231
|
+
return unique;
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### CLI Integration (claude-flow)
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
// Add to memory query command
|
|
239
|
+
memory.command('query')
|
|
240
|
+
.option('--hybrid', 'Search across both Basic and ReasoningBank modes')
|
|
241
|
+
.action(async (searchTerm, options) => {
|
|
242
|
+
if (options.hybrid) {
|
|
243
|
+
const results = await hybridQuery(searchTerm, options);
|
|
244
|
+
|
|
245
|
+
console.log(`\n🔍 Hybrid Query Results for "${searchTerm}":\n`);
|
|
246
|
+
|
|
247
|
+
// Group by source
|
|
248
|
+
const bySource = results.reduce((acc, r) => {
|
|
249
|
+
acc[r.source] = acc[r.source] || [];
|
|
250
|
+
acc[r.source].push(r);
|
|
251
|
+
return acc;
|
|
252
|
+
}, {});
|
|
253
|
+
|
|
254
|
+
for (const [source, items] of Object.entries(bySource)) {
|
|
255
|
+
console.log(`\n📦 ${source.toUpperCase()} (${items.length} results):`);
|
|
256
|
+
for (const item of items) {
|
|
257
|
+
console.log(` ${item.key}: ${item.value?.substring(0, 60)}...`);
|
|
258
|
+
if (item.similarity_score) {
|
|
259
|
+
console.log(` Relevance: ${(item.relevance * 100).toFixed(1)}%`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
// Normal query (existing implementation)
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Usage Example
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Traditional mode (single source)
|
|
273
|
+
claude-flow memory query "authentication"
|
|
274
|
+
# Searches only Basic mode
|
|
275
|
+
|
|
276
|
+
claude-flow memory query "authentication" --reasoningbank
|
|
277
|
+
# Searches only ReasoningBank
|
|
278
|
+
|
|
279
|
+
# NEW: Hybrid mode (both sources)
|
|
280
|
+
claude-flow memory query "authentication" --hybrid
|
|
281
|
+
|
|
282
|
+
🔍 Hybrid Query Results for "authentication":
|
|
283
|
+
|
|
284
|
+
📦 BASIC (2 results):
|
|
285
|
+
api_key: sk-ant-...
|
|
286
|
+
Relevance: 50.0%
|
|
287
|
+
auth_endpoint: https://api.example.com/auth
|
|
288
|
+
Relevance: 100.0%
|
|
289
|
+
|
|
290
|
+
📦 REASONINGBANK (5 results):
|
|
291
|
+
authentication: Implement JWT authentication for REST API
|
|
292
|
+
Relevance: 85.0%
|
|
293
|
+
authentication: Add OAuth2 login with Google
|
|
294
|
+
Relevance: 82.0%
|
|
295
|
+
|
|
296
|
+
📦 REASONINGBANK-SEMANTIC (3 results):
|
|
297
|
+
security: Password hashing with bcrypt
|
|
298
|
+
Relevance: 65.2%
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## 📊 Performance Comparison
|
|
304
|
+
|
|
305
|
+
| Mode | Storage | Persistence | Query Speed | Semantic Search | Use Case |
|
|
306
|
+
|------|---------|-------------|-------------|-----------------|----------|
|
|
307
|
+
| **Basic** | JSON | ✅ Yes | <1ms | ❌ No | Config, keys, simple KV |
|
|
308
|
+
| **ReasoningBank (Node.js)** | SQLite | ✅ Yes | 2-5ms | ✅ Yes | Learning, patterns, AI |
|
|
309
|
+
| **ReasoningBank (WASM)** | RAM | ❌ No | 0.04ms | ✅ Yes | Browsers, ephemeral |
|
|
310
|
+
| **Hybrid** | Both | ✅ Yes | 5-10ms | ✅ Partial | Cross-mode search |
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 🎯 Recommendations
|
|
315
|
+
|
|
316
|
+
### For agentic-flow Package
|
|
317
|
+
|
|
318
|
+
1. **Document storage backends clearly** in README:
|
|
319
|
+
```markdown
|
|
320
|
+
## Storage Backends
|
|
321
|
+
|
|
322
|
+
### Node.js (Recommended for CLIs)
|
|
323
|
+
```javascript
|
|
324
|
+
import { ReasoningBank } from 'agentic-flow/dist/reasoningbank/index.js';
|
|
325
|
+
const rb = new ReasoningBank({ dbPath: '.swarm/memory.db' });
|
|
326
|
+
// ✅ Persistent SQLite storage
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Browser (WASM)
|
|
330
|
+
```javascript
|
|
331
|
+
import { createReasoningBank } from 'agentic-flow/dist/reasoningbank/wasm-adapter.js';
|
|
332
|
+
const rb = await createReasoningBank('my-db');
|
|
333
|
+
// ✅ IndexedDB storage (persistent in browser)
|
|
334
|
+
```
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
2. **Add environment detection helper**:
|
|
338
|
+
```typescript
|
|
339
|
+
export function getRecommendedBackend(): 'nodejs' | 'wasm' {
|
|
340
|
+
return typeof window === 'undefined' ? 'nodejs' : 'wasm';
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
3. **Update package.json exports**:
|
|
345
|
+
```json
|
|
346
|
+
{
|
|
347
|
+
"exports": {
|
|
348
|
+
"./reasoningbank": {
|
|
349
|
+
"node": "./dist/reasoningbank/index.js",
|
|
350
|
+
"browser": "./dist/reasoningbank/wasm-adapter.js"
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### For claude-flow Integration
|
|
357
|
+
|
|
358
|
+
1. **Use Node.js ReasoningBank** (not WASM):
|
|
359
|
+
```javascript
|
|
360
|
+
import { ReasoningBank } from 'agentic-flow/dist/reasoningbank/index.js';
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
2. **Implement hybrid query** (optional, v2.7.1):
|
|
364
|
+
- Cross-mode search
|
|
365
|
+
- Unified results
|
|
366
|
+
- Relevance scoring
|
|
367
|
+
|
|
368
|
+
3. **Update status command** to show both modes:
|
|
369
|
+
```bash
|
|
370
|
+
$ claude-flow memory status
|
|
371
|
+
|
|
372
|
+
📊 Memory Status:
|
|
373
|
+
|
|
374
|
+
Basic Mode:
|
|
375
|
+
- Location: ./memory/memory-store.json
|
|
376
|
+
- Entries: 42
|
|
377
|
+
- Size: 12KB
|
|
378
|
+
- Status: ✅ Initialized
|
|
379
|
+
|
|
380
|
+
ReasoningBank Mode:
|
|
381
|
+
- Location: .swarm/memory.db
|
|
382
|
+
- Patterns: 289
|
|
383
|
+
- Embeddings: 289
|
|
384
|
+
- Size: 1.8MB
|
|
385
|
+
- Status: ✅ Active
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## 🧪 Validation Commands
|
|
391
|
+
|
|
392
|
+
### Test Semantic Search (agentic-flow)
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
node --experimental-wasm-modules <<'EOF'
|
|
396
|
+
import { createReasoningBank } from 'agentic-flow/dist/reasoningbank/wasm-adapter.js';
|
|
397
|
+
|
|
398
|
+
const rb = await createReasoningBank('test');
|
|
399
|
+
|
|
400
|
+
// Store patterns
|
|
401
|
+
await rb.storePattern({
|
|
402
|
+
task_description: 'Implement authentication',
|
|
403
|
+
task_category: 'auth',
|
|
404
|
+
strategy: 'jwt',
|
|
405
|
+
success_score: 0.9
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
// Semantic search
|
|
409
|
+
const results = await rb.findSimilar('user login', 'auth', 5);
|
|
410
|
+
console.log(`Found ${results.length} similar patterns`);
|
|
411
|
+
console.log(`Score: ${results[0]?.similarity_score}`);
|
|
412
|
+
// Expected: 1 result with score > 0.5
|
|
413
|
+
EOF
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Test Hybrid Query (claude-flow, after implementation)
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
# Store in Basic mode
|
|
420
|
+
claude-flow memory store auth_key "sk-test-12345"
|
|
421
|
+
|
|
422
|
+
# Store in ReasoningBank
|
|
423
|
+
npx agentic-flow --agent coder --task "Implement OAuth2"
|
|
424
|
+
|
|
425
|
+
# Hybrid query
|
|
426
|
+
claude-flow memory query "auth" --hybrid
|
|
427
|
+
# Expected: Results from both Basic and ReasoningBank
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## ✅ Conclusion
|
|
433
|
+
|
|
434
|
+
Both issues are **resolved**:
|
|
435
|
+
|
|
436
|
+
1. **Semantic Query**: ✅ Working perfectly with auto-generated embeddings
|
|
437
|
+
- Not a bug, WASM in-memory storage was confusing
|
|
438
|
+
- Use Node.js ReasoningBank for persistence
|
|
439
|
+
|
|
440
|
+
2. **Namespace Separation**: ✅ By design, can be bridged
|
|
441
|
+
- Intentional architecture for performance/simplicity
|
|
442
|
+
- Hybrid mode implementation provided (optional)
|
|
443
|
+
|
|
444
|
+
No bugs found - all functionality working as designed!
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
**Status**: Complete ✅
|
|
449
|
+
**Action Items**:
|
|
450
|
+
- [ ] Document WASM vs Node.js backends
|
|
451
|
+
- [ ] Consider hybrid query for claude-flow v2.7.1
|
|
452
|
+
- [ ] Add environment detection helper
|
|
453
|
+
- [ ] Update integration guides
|
|
454
|
+
|
|
455
|
+
**Next Steps**: Update agentic-flow README and claude-flow integration docs
|