claude-flow 3.5.72 → 3.5.73
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/package.json +1 -1
- package/v3/@claude-flow/cli/dist/src/init/claudemd-generator.js +15 -17
- package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +3 -0
- package/v3/@claude-flow/cli/dist/src/mcp-tools/neural-tools.js +8 -0
- package/v3/@claude-flow/cli/dist/src/memory/sona-optimizer.d.ts +21 -3
- package/v3/@claude-flow/cli/dist/src/memory/sona-optimizer.js +74 -7
- package/v3/@claude-flow/cli/dist/src/ruvector/vector-db.d.ts +4 -0
- package/v3/@claude-flow/cli/dist/src/ruvector/vector-db.js +22 -1
- package/v3/@claude-flow/cli/package.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.73",
|
|
4
4
|
"description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -52,9 +52,8 @@ function concurrencyRules() {
|
|
|
52
52
|
return `## Concurrency: 1 MESSAGE = ALL RELATED OPERATIONS
|
|
53
53
|
|
|
54
54
|
- All operations MUST be concurrent/parallel in a single message
|
|
55
|
-
- Use Claude Code's
|
|
56
|
-
- ALWAYS
|
|
57
|
-
- ALWAYS spawn ALL agents in ONE message with full instructions via Task tool
|
|
55
|
+
- Use Claude Code's Agent tool for spawning agents, not just MCP
|
|
56
|
+
- ALWAYS spawn ALL agents in ONE message with full instructions via Agent tool
|
|
58
57
|
- ALWAYS batch ALL file reads/writes/edits in ONE message
|
|
59
58
|
- ALWAYS batch ALL Bash commands in ONE message`;
|
|
60
59
|
}
|
|
@@ -62,9 +61,9 @@ function swarmOrchestration() {
|
|
|
62
61
|
return `## Swarm Orchestration
|
|
63
62
|
|
|
64
63
|
- MUST initialize the swarm using CLI tools when starting complex tasks
|
|
65
|
-
- MUST spawn concurrent agents using Claude Code's
|
|
66
|
-
- Never use CLI tools alone for execution —
|
|
67
|
-
- MUST call CLI tools AND
|
|
64
|
+
- MUST spawn concurrent agents using Claude Code's Agent tool
|
|
65
|
+
- Never use CLI tools alone for execution — Agent tool agents do the actual work
|
|
66
|
+
- MUST call CLI tools AND Agent tool in ONE message for complex work
|
|
68
67
|
|
|
69
68
|
### 3-Tier Model Routing (ADR-026)
|
|
70
69
|
|
|
@@ -74,8 +73,7 @@ function swarmOrchestration() {
|
|
|
74
73
|
| **2** | Haiku | ~500ms | $0.0002 | Simple tasks, low complexity (<30%) |
|
|
75
74
|
| **3** | Sonnet/Opus | 2-5s | $0.003-0.015 | Complex reasoning, architecture, security (>30%) |
|
|
76
75
|
|
|
77
|
-
-
|
|
78
|
-
- Use Edit tool directly when \`[AGENT_BOOSTER_AVAILABLE]\``;
|
|
76
|
+
- For Tier 1 simple transforms, use Edit tool directly — no LLM agent needed`;
|
|
79
77
|
}
|
|
80
78
|
function antiDriftConfig() {
|
|
81
79
|
return `## Swarm Configuration & Anti-Drift
|
|
@@ -103,11 +101,11 @@ When the user requests a complex task, spawn agents in background and WAIT:
|
|
|
103
101
|
Bash("npx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized")
|
|
104
102
|
|
|
105
103
|
// STEP 2: Spawn ALL agents IN BACKGROUND in a SINGLE message
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
Agent("Research requirements", "Analyze codebase patterns and store findings in memory", {subagent_type: "researcher", run_in_background: true})
|
|
105
|
+
Agent("Design architecture", "Design architecture based on research", {subagent_type: "system-architect", run_in_background: true})
|
|
106
|
+
Agent("Implement solution", "Implement the solution following the design", {subagent_type: "coder", run_in_background: true})
|
|
107
|
+
Agent("Write tests", "Write comprehensive tests for the implementation", {subagent_type: "tester", run_in_background: true})
|
|
108
|
+
Agent("Review code quality", "Review code quality, security, and best practices", {subagent_type: "reviewer", run_in_background: true})
|
|
111
109
|
\`\`\`
|
|
112
110
|
|
|
113
111
|
### Agent Routing
|
|
@@ -128,10 +126,10 @@ Task({prompt: "Review code quality...", subagent_type: "reviewer", run_in_backgr
|
|
|
128
126
|
function executionRules() {
|
|
129
127
|
return `## Swarm Execution Rules
|
|
130
128
|
|
|
131
|
-
- ALWAYS use \`run_in_background: true\` for all
|
|
132
|
-
- ALWAYS put ALL
|
|
129
|
+
- ALWAYS use \`run_in_background: true\` for all Agent tool calls
|
|
130
|
+
- ALWAYS put ALL Agent calls in ONE message for parallel execution
|
|
133
131
|
- After spawning, STOP — do NOT add more tool calls or check status
|
|
134
|
-
- Never poll
|
|
132
|
+
- Never poll agent status repeatedly — trust agents to return
|
|
135
133
|
- When agent results arrive, review ALL results before proceeding`;
|
|
136
134
|
}
|
|
137
135
|
function cliCommandsTable() {
|
|
@@ -407,7 +405,7 @@ npx @claude-flow/cli@latest doctor --fix
|
|
|
407
405
|
|
|
408
406
|
## Claude Code vs MCP Tools
|
|
409
407
|
|
|
410
|
-
- **Claude Code
|
|
408
|
+
- **Claude Code Agent tool** handles execution: agents, file ops, code generation, git
|
|
411
409
|
- **MCP tools** (via ToolSearch) handle coordination: swarm, memory, hooks, routing, hive-mind
|
|
412
410
|
- **CLI commands** (via Bash) are the same tools with terminal output
|
|
413
411
|
- Use \`ToolSearch("keyword")\` to discover available MCP tools
|
|
@@ -291,6 +291,7 @@ async function getSemanticRouter() {
|
|
|
291
291
|
}
|
|
292
292
|
nativeVectorDb = db;
|
|
293
293
|
routerBackend = 'native';
|
|
294
|
+
console.log('[hooks] Semantic router initialized: native VectorDb (HNSW, 16k+ routes/s)');
|
|
294
295
|
return { router: null, backend: routerBackend, native: nativeVectorDb };
|
|
295
296
|
}
|
|
296
297
|
}
|
|
@@ -312,10 +313,12 @@ async function getSemanticRouter() {
|
|
|
312
313
|
});
|
|
313
314
|
}
|
|
314
315
|
routerBackend = 'pure-js';
|
|
316
|
+
console.log('[hooks] Semantic router initialized: pure JS (cosine, 47k routes/s)');
|
|
315
317
|
}
|
|
316
318
|
catch {
|
|
317
319
|
semanticRouter = null;
|
|
318
320
|
routerBackend = 'none';
|
|
321
|
+
console.log('[hooks] Semantic router initialized: none (no backend available)');
|
|
319
322
|
}
|
|
320
323
|
return { router: semanticRouter, backend: routerBackend, native: nativeVectorDb };
|
|
321
324
|
}
|
|
@@ -131,7 +131,11 @@ async function generateEmbedding(text, dims = 384) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
// Hash-based deterministic embedding (better than pure random for consistency)
|
|
134
|
+
// NOTE: No semantic meaning — only useful for consistent deduplication, not similarity search
|
|
134
135
|
if (text) {
|
|
136
|
+
if (embeddingServiceName === 'none') {
|
|
137
|
+
embeddingServiceName = 'hash-fallback';
|
|
138
|
+
}
|
|
135
139
|
const hash = text.split('').reduce((acc, char, i) => {
|
|
136
140
|
return acc + char.charCodeAt(0) * (i + 1);
|
|
137
141
|
}, 0);
|
|
@@ -238,6 +242,7 @@ export const neuralTools = [
|
|
|
238
242
|
return {
|
|
239
243
|
success: true,
|
|
240
244
|
_realEmbedding: !!realEmbeddings,
|
|
245
|
+
_embeddingSource: embeddingServiceName,
|
|
241
246
|
embeddingProvider: embeddingServiceName,
|
|
242
247
|
modelId,
|
|
243
248
|
type: modelType,
|
|
@@ -307,6 +312,7 @@ export const neuralTools = [
|
|
|
307
312
|
return {
|
|
308
313
|
success: true,
|
|
309
314
|
_realEmbedding: !!realEmbeddings,
|
|
315
|
+
_embeddingSource: embeddingServiceName,
|
|
310
316
|
embeddingProvider: embeddingServiceName,
|
|
311
317
|
_hasStoredPatterns: storedPatterns.length > 0,
|
|
312
318
|
modelId: model?.id || 'default',
|
|
@@ -397,6 +403,7 @@ export const neuralTools = [
|
|
|
397
403
|
return {
|
|
398
404
|
success: true,
|
|
399
405
|
_realEmbedding: !!realEmbeddings,
|
|
406
|
+
_embeddingSource: embeddingServiceName,
|
|
400
407
|
embeddingProvider: embeddingServiceName,
|
|
401
408
|
patternId,
|
|
402
409
|
name: pattern.name,
|
|
@@ -420,6 +427,7 @@ export const neuralTools = [
|
|
|
420
427
|
return {
|
|
421
428
|
_realSimilarity: true,
|
|
422
429
|
_realEmbedding: !!realEmbeddings,
|
|
430
|
+
_embeddingSource: embeddingServiceName,
|
|
423
431
|
embeddingProvider: embeddingServiceName,
|
|
424
432
|
query,
|
|
425
433
|
results: results.map(r => ({
|
|
@@ -60,7 +60,7 @@ export interface RoutingSuggestion {
|
|
|
60
60
|
/** Whether Q-learning was used */
|
|
61
61
|
usedQLearning: boolean;
|
|
62
62
|
/** Source of recommendation */
|
|
63
|
-
source: 'sona-pattern' | 'q-learning' | 'keyword
|
|
63
|
+
source: 'sona-native' | 'sona-pattern' | 'q-learning' | 'sona-keyword' | 'default';
|
|
64
64
|
/** Alternative agents with scores */
|
|
65
65
|
alternatives: Array<{
|
|
66
66
|
agent: string;
|
|
@@ -103,9 +103,20 @@ export declare class SONAOptimizer {
|
|
|
103
103
|
private persistencePath;
|
|
104
104
|
private qLearningRouter;
|
|
105
105
|
private qLearningEnabled;
|
|
106
|
+
/** Real @ruvector/sona engine — null if native not available, undefined if not yet tried */
|
|
107
|
+
private sonaEngine;
|
|
106
108
|
constructor(options?: {
|
|
107
109
|
persistencePath?: string;
|
|
108
110
|
});
|
|
111
|
+
/**
|
|
112
|
+
* Attempt to load the native @ruvector/sona engine (once).
|
|
113
|
+
* Sets `sonaEngine` to the engine instance or null if unavailable.
|
|
114
|
+
*/
|
|
115
|
+
private loadSonaEngine;
|
|
116
|
+
/**
|
|
117
|
+
* Infer an agent type string from a SONA pattern result object.
|
|
118
|
+
*/
|
|
119
|
+
private inferAgentFromPattern;
|
|
109
120
|
/**
|
|
110
121
|
* Initialize the optimizer and load persisted state
|
|
111
122
|
*/
|
|
@@ -124,9 +135,16 @@ export declare class SONAOptimizer {
|
|
|
124
135
|
keywordsExtracted: string[];
|
|
125
136
|
};
|
|
126
137
|
/**
|
|
127
|
-
* Get routing suggestion based on learned patterns
|
|
138
|
+
* Get routing suggestion based on learned patterns.
|
|
139
|
+
*
|
|
140
|
+
* Priority order:
|
|
141
|
+
* 1. Real @ruvector/sona native engine (if available and has matches)
|
|
142
|
+
* 2. SONA learned pattern matching (keyword overlap + confidence)
|
|
143
|
+
* 3. Q-learning router (if enabled)
|
|
144
|
+
* 4. Keyword heuristic
|
|
145
|
+
* 5. Default fallback
|
|
128
146
|
*/
|
|
129
|
-
getRoutingSuggestion(task: string): RoutingSuggestion
|
|
147
|
+
getRoutingSuggestion(task: string): Promise<RoutingSuggestion>;
|
|
130
148
|
/**
|
|
131
149
|
* Get optimizer statistics
|
|
132
150
|
*/
|
|
@@ -104,9 +104,44 @@ export class SONAOptimizer {
|
|
|
104
104
|
persistencePath;
|
|
105
105
|
qLearningRouter = null;
|
|
106
106
|
qLearningEnabled = false;
|
|
107
|
+
/** Real @ruvector/sona engine — null if native not available, undefined if not yet tried */
|
|
108
|
+
sonaEngine = undefined;
|
|
107
109
|
constructor(options) {
|
|
108
110
|
this.persistencePath = options?.persistencePath || DEFAULT_PERSISTENCE_PATH;
|
|
109
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Attempt to load the native @ruvector/sona engine (once).
|
|
114
|
+
* Sets `sonaEngine` to the engine instance or null if unavailable.
|
|
115
|
+
*/
|
|
116
|
+
async loadSonaEngine() {
|
|
117
|
+
if (this.sonaEngine !== undefined)
|
|
118
|
+
return; // already attempted
|
|
119
|
+
try {
|
|
120
|
+
const sona = await import('@ruvector/sona');
|
|
121
|
+
const EngineCtor = sona.SonaEngine || sona.default?.SonaEngine;
|
|
122
|
+
if (EngineCtor) {
|
|
123
|
+
this.sonaEngine = new EngineCtor({ mode: 'real-time' });
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.sonaEngine = null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
this.sonaEngine = null; // native not available
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Infer an agent type string from a SONA pattern result object.
|
|
135
|
+
*/
|
|
136
|
+
inferAgentFromPattern(pattern) {
|
|
137
|
+
if (typeof pattern.agent === 'string')
|
|
138
|
+
return pattern.agent;
|
|
139
|
+
if (typeof pattern.route === 'string')
|
|
140
|
+
return pattern.route;
|
|
141
|
+
if (typeof pattern.label === 'string')
|
|
142
|
+
return pattern.label;
|
|
143
|
+
return 'coder';
|
|
144
|
+
}
|
|
110
145
|
/**
|
|
111
146
|
* Initialize the optimizer and load persisted state
|
|
112
147
|
*/
|
|
@@ -193,11 +228,43 @@ export class SONAOptimizer {
|
|
|
193
228
|
};
|
|
194
229
|
}
|
|
195
230
|
/**
|
|
196
|
-
* Get routing suggestion based on learned patterns
|
|
231
|
+
* Get routing suggestion based on learned patterns.
|
|
232
|
+
*
|
|
233
|
+
* Priority order:
|
|
234
|
+
* 1. Real @ruvector/sona native engine (if available and has matches)
|
|
235
|
+
* 2. SONA learned pattern matching (keyword overlap + confidence)
|
|
236
|
+
* 3. Q-learning router (if enabled)
|
|
237
|
+
* 4. Keyword heuristic
|
|
238
|
+
* 5. Default fallback
|
|
197
239
|
*/
|
|
198
|
-
getRoutingSuggestion(task) {
|
|
240
|
+
async getRoutingSuggestion(task) {
|
|
241
|
+
// Priority 1: Try real @ruvector/sona native engine
|
|
242
|
+
await this.loadSonaEngine();
|
|
243
|
+
if (this.sonaEngine) {
|
|
244
|
+
try {
|
|
245
|
+
const patterns = this.sonaEngine.findPatterns(task, 3);
|
|
246
|
+
if (patterns && patterns.length > 0) {
|
|
247
|
+
const best = patterns[0];
|
|
248
|
+
const agent = best.route || best.agent || this.inferAgentFromPattern(best);
|
|
249
|
+
return {
|
|
250
|
+
agent,
|
|
251
|
+
confidence: best.quality || 0.8,
|
|
252
|
+
usedQLearning: false,
|
|
253
|
+
source: 'sona-native',
|
|
254
|
+
alternatives: patterns.slice(1).map((p) => ({
|
|
255
|
+
agent: p.route || p.agent || this.inferAgentFromPattern(p),
|
|
256
|
+
score: p.quality || 0.5,
|
|
257
|
+
})),
|
|
258
|
+
matchedKeywords: best.keywords || [],
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
// Native SONA failed on this query — fall through to keyword matching
|
|
264
|
+
}
|
|
265
|
+
}
|
|
199
266
|
const keywords = this.extractKeywords(task);
|
|
200
|
-
// Try SONA pattern matching
|
|
267
|
+
// Priority 2: Try SONA learned pattern matching
|
|
201
268
|
const sonaResult = this.findBestPatternMatch(keywords);
|
|
202
269
|
if (sonaResult && sonaResult.confidence >= 0.6) {
|
|
203
270
|
return {
|
|
@@ -209,7 +276,7 @@ export class SONAOptimizer {
|
|
|
209
276
|
matchedKeywords: sonaResult.matchedKeywords,
|
|
210
277
|
};
|
|
211
278
|
}
|
|
212
|
-
// Try Q-learning router if available
|
|
279
|
+
// Priority 3: Try Q-learning router if available
|
|
213
280
|
if (this.qLearningRouter && this.qLearningEnabled) {
|
|
214
281
|
try {
|
|
215
282
|
const decision = this.qLearningRouter.route(task, false);
|
|
@@ -227,19 +294,19 @@ export class SONAOptimizer {
|
|
|
227
294
|
// Q-learning failed, continue to fallback
|
|
228
295
|
}
|
|
229
296
|
}
|
|
230
|
-
//
|
|
297
|
+
// Priority 4: Keyword-based heuristic
|
|
231
298
|
const keywordMatch = this.matchKeywordsToAgent(keywords);
|
|
232
299
|
if (keywordMatch) {
|
|
233
300
|
return {
|
|
234
301
|
agent: keywordMatch.agent,
|
|
235
302
|
confidence: keywordMatch.confidence,
|
|
236
303
|
usedQLearning: false,
|
|
237
|
-
source: 'keyword
|
|
304
|
+
source: 'sona-keyword',
|
|
238
305
|
alternatives: this.getAlternatives(keywords, keywordMatch.agent),
|
|
239
306
|
matchedKeywords: keywordMatch.matchedKeywords,
|
|
240
307
|
};
|
|
241
308
|
}
|
|
242
|
-
// Default fallback
|
|
309
|
+
// Priority 5: Default fallback
|
|
243
310
|
return {
|
|
244
311
|
agent: 'coder',
|
|
245
312
|
confidence: 0.3,
|
|
@@ -52,6 +52,10 @@ export declare function createVectorDB(dimensions?: number): Promise<VectorDB>;
|
|
|
52
52
|
/**
|
|
53
53
|
* Generate an embedding for text
|
|
54
54
|
* Uses ruvector if available, falls back to hash-based embedding
|
|
55
|
+
*
|
|
56
|
+
* @returns The embedding vector. When using hash fallback, the returned
|
|
57
|
+
* Float32Array will have a `_warning` property (non-enumerable)
|
|
58
|
+
* indicating it lacks semantic meaning.
|
|
55
59
|
*/
|
|
56
60
|
export declare function generateEmbedding(text: string, dimensions?: number): Float32Array;
|
|
57
61
|
/**
|
|
@@ -60,10 +60,20 @@ function cosineSimilarity(a, b) {
|
|
|
60
60
|
const denom = Math.sqrt(normA) * Math.sqrt(normB);
|
|
61
61
|
return denom === 0 ? 0 : dotProduct / denom;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Whether the hash-embedding one-time warning has been emitted
|
|
65
|
+
*/
|
|
66
|
+
let hashEmbeddingWarned = false;
|
|
63
67
|
/**
|
|
64
68
|
* Generate a simple hash-based embedding (fallback when ruvector not available)
|
|
69
|
+
* WARNING: Produces deterministic vectors with NO semantic meaning.
|
|
65
70
|
*/
|
|
66
71
|
function generateHashEmbedding(text, dimensions = 768) {
|
|
72
|
+
if (!hashEmbeddingWarned) {
|
|
73
|
+
hashEmbeddingWarned = true;
|
|
74
|
+
console.warn('[vector-db] Using hash-based pseudo-embeddings (no semantic similarity). ' +
|
|
75
|
+
'Install ruvector or @claude-flow/embeddings for real ML embeddings.');
|
|
76
|
+
}
|
|
67
77
|
const embedding = new Float32Array(dimensions);
|
|
68
78
|
const normalized = text.toLowerCase().trim();
|
|
69
79
|
// Simple hash function
|
|
@@ -196,6 +206,10 @@ export async function createVectorDB(dimensions = 768) {
|
|
|
196
206
|
/**
|
|
197
207
|
* Generate an embedding for text
|
|
198
208
|
* Uses ruvector if available, falls back to hash-based embedding
|
|
209
|
+
*
|
|
210
|
+
* @returns The embedding vector. When using hash fallback, the returned
|
|
211
|
+
* Float32Array will have a `_warning` property (non-enumerable)
|
|
212
|
+
* indicating it lacks semantic meaning.
|
|
199
213
|
*/
|
|
200
214
|
export function generateEmbedding(text, dimensions = 768) {
|
|
201
215
|
if (ruvectorModule && typeof ruvectorModule.generateEmbedding === 'function') {
|
|
@@ -206,7 +220,14 @@ export function generateEmbedding(text, dimensions = 768) {
|
|
|
206
220
|
// Fall back to hash-based embedding
|
|
207
221
|
}
|
|
208
222
|
}
|
|
209
|
-
|
|
223
|
+
const embedding = generateHashEmbedding(text, dimensions);
|
|
224
|
+
// Tag the result so consumers can detect it came from hash fallback
|
|
225
|
+
Object.defineProperty(embedding, '_warning', {
|
|
226
|
+
value: 'hash-based pseudo-embedding — no semantic similarity',
|
|
227
|
+
enumerable: false,
|
|
228
|
+
configurable: true,
|
|
229
|
+
});
|
|
230
|
+
return embedding;
|
|
210
231
|
}
|
|
211
232
|
/**
|
|
212
233
|
* Compute cosine similarity between two vectors
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
|
|
6
6
|
"main": "dist/src/index.js",
|