claude-flow 3.5.52 → 3.5.53

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.
@@ -96,7 +96,11 @@ async function main() {
96
96
  // Merge stdin data into prompt resolution: prefer stdin fields, then env vars.
97
97
  // NEVER fall back to argv args — shell glob expansion of braces in bash output
98
98
  // creates junk files (#1342). Use env vars or stdin only.
99
- const prompt = hookInput.prompt || hookInput.command || hookInput.toolInput
99
+ // Normalize snake_case/camelCase: Claude Code sends tool_input/tool_name (snake_case)
100
+ var toolInput = hookInput.toolInput || hookInput.tool_input || {};
101
+ var toolName = hookInput.toolName || hookInput.tool_name || '';
102
+
103
+ var prompt = hookInput.prompt || hookInput.command || toolInput
100
104
  || process.env.PROMPT || process.env.TOOL_INPUT_command || '';
101
105
 
102
106
  const handlers = {
@@ -141,7 +145,7 @@ const handlers = {
141
145
  }
142
146
  if (intelligence && intelligence.recordEdit) {
143
147
  try {
144
- var file = hookInput.file_path || (hookInput.toolInput && hookInput.toolInput.file_path)
148
+ var file = hookInput.file_path || toolInput.file_path
145
149
  || process.env.TOOL_INPUT_file_path || args[0] || '';
146
150
  intelligence.recordEdit(file);
147
151
  } catch (e) { /* non-fatal */ }
@@ -58,8 +58,10 @@ function tokenize(text) {
58
58
 
59
59
  function bootstrapFromMemoryFiles() {
60
60
  var entries = [];
61
+ // Scope to current project only (not all 51+ project dirs)
62
+ var projectSlug = process.cwd().replace(/^\//, '').replace(/\//g, '-');
61
63
  var candidates = [
62
- path.join(os.homedir(), ".claude", "projects"),
64
+ path.join(os.homedir(), ".claude", "projects", projectSlug, "memory"),
63
65
  path.join(process.cwd(), ".claude-flow", "memory"),
64
66
  path.join(process.cwd(), ".claude", "memory"),
65
67
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.5.52",
3
+ "version": "3.5.53",
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",
@@ -573,7 +573,7 @@ const initCommand = {
573
573
  name: 'init',
574
574
  description: 'Initialize embedding subsystem with ONNX model and hyperbolic config',
575
575
  options: [
576
- { name: 'model', short: 'm', type: 'string', description: 'ONNX model ID', default: 'all-MiniLM-L6-v2' },
576
+ { name: 'model', short: 'm', type: 'string', description: 'ONNX model ID', default: 'Xenova/all-MiniLM-L6-v2' },
577
577
  { name: 'hyperbolic', type: 'boolean', description: 'Enable hyperbolic (Poincaré ball) embeddings', default: 'true' },
578
578
  { name: 'curvature', short: 'c', type: 'string', description: 'Poincaré ball curvature (use --curvature=-1 for negative)', default: '-1' },
579
579
  { name: 'download', short: 'd', type: 'boolean', description: 'Download model during init', default: 'true' },
@@ -582,13 +582,13 @@ const initCommand = {
582
582
  ],
583
583
  examples: [
584
584
  { command: 'claude-flow embeddings init', description: 'Initialize with defaults' },
585
- { command: 'claude-flow embeddings init --model all-mpnet-base-v2', description: 'Use higher quality model' },
585
+ { command: 'claude-flow embeddings init --model Xenova/all-mpnet-base-v2', description: 'Use higher quality model' },
586
586
  { command: 'claude-flow embeddings init --no-hyperbolic', description: 'Euclidean only' },
587
587
  { command: 'claude-flow embeddings init --curvature=-0.5', description: 'Custom curvature (use = for negative)' },
588
588
  { command: 'claude-flow embeddings init --force', description: 'Overwrite existing config' },
589
589
  ],
590
590
  action: async (ctx) => {
591
- const model = ctx.flags.model || 'all-MiniLM-L6-v2';
591
+ const model = ctx.flags.model || 'Xenova/all-MiniLM-L6-v2';
592
592
  const hyperbolic = ctx.flags.hyperbolic !== false;
593
593
  const download = ctx.flags.download !== false;
594
594
  const force = ctx.flags.force === true;
@@ -727,7 +727,7 @@ const providersCommand = {
727
727
  data: [
728
728
  { provider: 'OpenAI', model: 'text-embedding-3-small', dims: '1536', type: 'Cloud', status: output.success('Ready') },
729
729
  { provider: 'OpenAI', model: 'text-embedding-3-large', dims: '3072', type: 'Cloud', status: output.success('Ready') },
730
- { provider: 'Transformers.js', model: 'all-MiniLM-L6-v2', dims: '384', type: 'Local', status: output.success('Ready') },
730
+ { provider: 'Transformers.js', model: 'Xenova/all-MiniLM-L6-v2', dims: '384', type: 'Local', status: output.success('Ready') },
731
731
  { provider: 'Agentic Flow', model: 'ONNX optimized', dims: '384', type: 'Local', status: output.success('Ready') },
732
732
  { provider: 'Mock', model: 'mock-embedding', dims: '384', type: 'Dev', status: output.dim('Dev only') },
733
733
  ],
@@ -1129,9 +1129,9 @@ const modelsCommand = {
1129
1129
  }
1130
1130
  // List models
1131
1131
  let models = [
1132
- { id: 'all-MiniLM-L6-v2', dimension: 384, size: '23MB', quantized: false, downloaded: true },
1133
- { id: 'all-mpnet-base-v2', dimension: 768, size: '110MB', quantized: false, downloaded: false },
1134
- { id: 'paraphrase-MiniLM-L3-v2', dimension: 384, size: '17MB', quantized: false, downloaded: false },
1132
+ { id: 'Xenova/all-MiniLM-L6-v2', dimension: 384, size: '23MB', quantized: false, downloaded: true },
1133
+ { id: 'Xenova/all-mpnet-base-v2', dimension: 768, size: '110MB', quantized: false, downloaded: false },
1134
+ { id: 'Xenova/paraphrase-MiniLM-L3-v2', dimension: 384, size: '17MB', quantized: false, downloaded: false },
1135
1135
  ];
1136
1136
  if (embeddings) {
1137
1137
  try {
@@ -845,8 +845,8 @@ const pretrainCommand = {
845
845
  name: 'embedding-model',
846
846
  description: 'ONNX embedding model',
847
847
  type: 'string',
848
- default: 'all-MiniLM-L6-v2',
849
- choices: ['all-MiniLM-L6-v2', 'all-mpnet-base-v2']
848
+ default: 'Xenova/all-MiniLM-L6-v2',
849
+ choices: ['Xenova/all-MiniLM-L6-v2', 'Xenova/all-mpnet-base-v2']
850
850
  },
851
851
  {
852
852
  name: 'file-types',
@@ -865,7 +865,7 @@ const pretrainCommand = {
865
865
  const repoPath = ctx.flags.path || '.';
866
866
  const depth = ctx.flags.depth || 'medium';
867
867
  const withEmbeddings = ctx.flags['with-embeddings'] !== false && ctx.flags.withEmbeddings !== false;
868
- const embeddingModel = (ctx.flags['embedding-model'] || ctx.flags.embeddingModel || 'all-MiniLM-L6-v2');
868
+ const embeddingModel = (ctx.flags['embedding-model'] || ctx.flags.embeddingModel || 'Xenova/all-MiniLM-L6-v2');
869
869
  const fileTypes = (ctx.flags['file-types'] || ctx.flags.fileTypes || 'ts,js,py,md,json');
870
870
  output.writeln();
871
871
  output.writeln(output.bold('Pretraining Intelligence (4-Step Pipeline + Embeddings)'));
@@ -3830,9 +3830,10 @@ const tokenOptimizeCommand = {
3830
3830
  output.printInfo(`Retrieving compact context for: "${query}"`);
3831
3831
  const memories = await reasoningBank.retrieveMemories(query, { k: 5 });
3832
3832
  const compactPrompt = reasoningBank.formatMemoriesForPrompt ? reasoningBank.formatMemoriesForPrompt(memories) : '';
3833
- const baseline = 1000;
3833
+ // Estimate based on actual query vs compact prompt size difference
3834
+ const queryTokenEstimate = Math.ceil((query?.length || 0) / 4);
3834
3835
  const used = Math.ceil((compactPrompt?.length || 0) / 4);
3835
- const tokensSaved = Math.max(0, baseline - used);
3836
+ const tokensSaved = Math.max(0, queryTokenEstimate - used);
3836
3837
  stats.totalTokensSaved += tokensSaved;
3837
3838
  stats.memoriesRetrieved += Array.isArray(memories) ? memories.length : 0;
3838
3839
  output.writeln(` Memories found: ${Array.isArray(memories) ? memories.length : 0}`);
@@ -316,7 +316,7 @@ const initAction = async (ctx) => {
316
316
  }
317
317
  // Handle --with-embeddings
318
318
  const withEmbeddings = ctx.flags['with-embeddings'] || ctx.flags.withEmbeddings;
319
- const embeddingModel = (ctx.flags['embedding-model'] || ctx.flags.embeddingModel || 'all-MiniLM-L6-v2');
319
+ const embeddingModel = (ctx.flags['embedding-model'] || ctx.flags.embeddingModel || 'Xenova/all-MiniLM-L6-v2');
320
320
  if (withEmbeddings) {
321
321
  output.writeln();
322
322
  output.printInfo('Initializing ONNX embedding subsystem...');
@@ -519,13 +519,13 @@ const wizardCommand = {
519
519
  message: 'Enable ONNX embedding system with hyperbolic support?',
520
520
  default: true,
521
521
  });
522
- let embeddingModel = 'all-MiniLM-L6-v2';
522
+ let embeddingModel = 'Xenova/all-MiniLM-L6-v2';
523
523
  if (enableEmbeddings) {
524
524
  embeddingModel = await select({
525
525
  message: 'Select embedding model:',
526
526
  options: [
527
- { value: 'all-MiniLM-L6-v2', label: 'MiniLM L6 (384d)', hint: 'Fast, good quality (recommended)' },
528
- { value: 'all-mpnet-base-v2', label: 'MPNet Base (768d)', hint: 'Higher quality, more memory' },
527
+ { value: 'Xenova/all-MiniLM-L6-v2', label: 'MiniLM L6 (384d)', hint: 'Fast, good quality (recommended)' },
528
+ { value: 'Xenova/all-mpnet-base-v2', label: 'MPNet Base (768d)', hint: 'Higher quality, more memory' },
529
529
  ],
530
530
  });
531
531
  }
@@ -926,8 +926,8 @@ export const initCommand = {
926
926
  name: 'embedding-model',
927
927
  description: 'ONNX embedding model to use',
928
928
  type: 'string',
929
- default: 'all-MiniLM-L6-v2',
930
- choices: ['all-MiniLM-L6-v2', 'all-mpnet-base-v2'],
929
+ default: 'Xenova/all-MiniLM-L6-v2',
930
+ choices: ['Xenova/all-MiniLM-L6-v2', 'Xenova/all-mpnet-base-v2'],
931
931
  },
932
932
  {
933
933
  name: 'codex',
@@ -953,7 +953,7 @@ export const initCommand = {
953
953
  { command: 'claude-flow init --skip-claude', description: 'Only create V3 runtime' },
954
954
  { command: 'claude-flow init wizard', description: 'Interactive setup wizard' },
955
955
  { command: 'claude-flow init --with-embeddings', description: 'Initialize with ONNX embeddings' },
956
- { command: 'claude-flow init --with-embeddings --embedding-model all-mpnet-base-v2', description: 'Use larger embedding model' },
956
+ { command: 'claude-flow init --with-embeddings --embedding-model Xenova/all-mpnet-base-v2', description: 'Use larger embedding model' },
957
957
  { command: 'claude-flow init skills --all', description: 'Install all available skills' },
958
958
  { command: 'claude-flow init hooks --minimal', description: 'Create minimal hooks configuration' },
959
959
  { command: 'claude-flow init upgrade', description: 'Update helpers while preserving data' },
@@ -34,7 +34,7 @@ const listCommand = {
34
34
  { provider: 'Anthropic', type: 'LLM', models: 'claude-3.5-sonnet, opus', status: output.success('Active') },
35
35
  { provider: 'OpenAI', type: 'LLM', models: 'gpt-4o, gpt-4-turbo', status: output.success('Active') },
36
36
  { provider: 'OpenAI', type: 'Embedding', models: 'text-embedding-3-small/large', status: output.success('Active') },
37
- { provider: 'Transformers.js', type: 'Embedding', models: 'all-MiniLM-L6-v2', status: output.success('Active') },
37
+ { provider: 'Transformers.js', type: 'Embedding', models: 'Xenova/all-MiniLM-L6-v2', status: output.success('Active') },
38
38
  { provider: 'Agentic Flow', type: 'Embedding', models: 'ONNX optimized', status: output.success('Active') },
39
39
  { provider: 'Mock', type: 'All', models: 'mock-*', status: output.dim('Dev only') },
40
40
  ],
@@ -269,7 +269,7 @@ const modelsCommand = {
269
269
  { model: 'gpt-4-turbo', provider: 'OpenAI', capability: 'Chat', context: '128K', cost: '$0.01/$0.03' },
270
270
  { model: 'text-embedding-3-small', provider: 'OpenAI', capability: 'Embedding', context: '8K', cost: '$0.00002' },
271
271
  { model: 'text-embedding-3-large', provider: 'OpenAI', capability: 'Embedding', context: '8K', cost: '$0.00013' },
272
- { model: 'all-MiniLM-L6-v2', provider: 'Transformers', capability: 'Embedding', context: '512', cost: output.success('Free') },
272
+ { model: 'Xenova/all-MiniLM-L6-v2', provider: 'Transformers', capability: 'Embedding', context: '512', cost: output.success('Free') },
273
273
  ],
274
274
  });
275
275
  return { success: true };
@@ -197,7 +197,7 @@ export interface EmbeddingsConfig {
197
197
  /** Enable embedding subsystem */
198
198
  enabled: boolean;
199
199
  /** ONNX model ID */
200
- model: 'all-MiniLM-L6-v2' | 'all-mpnet-base-v2' | 'bge-small-en-v1.5' | string;
200
+ model: 'Xenova/all-MiniLM-L6-v2' | 'Xenova/all-mpnet-base-v2' | 'Xenova/bge-small-en-v1.5' | string;
201
201
  /** Enable hyperbolic (Poincaré ball) embeddings */
202
202
  hyperbolic: boolean;
203
203
  /** Poincaré ball curvature (negative value, typically -1) */
@@ -133,7 +133,7 @@ export const DEFAULT_INIT_OPTIONS = {
133
133
  },
134
134
  embeddings: {
135
135
  enabled: true,
136
- model: 'all-MiniLM-L6-v2',
136
+ model: 'Xenova/all-MiniLM-L6-v2',
137
137
  hyperbolic: true,
138
138
  curvature: -1.0,
139
139
  predownload: false, // Don't auto-download to speed up init
@@ -201,7 +201,7 @@ export const MINIMAL_INIT_OPTIONS = {
201
201
  },
202
202
  embeddings: {
203
203
  enabled: false,
204
- model: 'all-MiniLM-L6-v2',
204
+ model: 'Xenova/all-MiniLM-L6-v2',
205
205
  hyperbolic: false,
206
206
  curvature: -1.0,
207
207
  predownload: false,
@@ -252,7 +252,7 @@ export const FULL_INIT_OPTIONS = {
252
252
  },
253
253
  embeddings: {
254
254
  enabled: true,
255
- model: 'all-MiniLM-L6-v2',
255
+ model: 'Xenova/all-MiniLM-L6-v2',
256
256
  hyperbolic: true,
257
257
  curvature: -1.0,
258
258
  predownload: true, // Pre-download for full init
@@ -113,8 +113,8 @@ export const embeddingsTools = [
113
113
  model: {
114
114
  type: 'string',
115
115
  description: 'ONNX model ID',
116
- enum: ['all-MiniLM-L6-v2', 'all-mpnet-base-v2'],
117
- default: 'all-MiniLM-L6-v2',
116
+ enum: ['Xenova/all-MiniLM-L6-v2', 'Xenova/all-mpnet-base-v2'],
117
+ default: 'Xenova/all-MiniLM-L6-v2',
118
118
  },
119
119
  hyperbolic: {
120
120
  type: 'boolean',
@@ -139,7 +139,7 @@ export const embeddingsTools = [
139
139
  },
140
140
  },
141
141
  handler: async (input) => {
142
- const model = input.model || 'all-MiniLM-L6-v2';
142
+ const model = input.model || 'Xenova/all-MiniLM-L6-v2';
143
143
  const hyperbolic = input.hyperbolic !== false;
144
144
  const curvature = input.curvature || -1;
145
145
  const cacheSize = input.cacheSize || 256;
@@ -770,7 +770,7 @@ export const embeddingsTools = [
770
770
  },
771
771
  initializedAt: config.initialized,
772
772
  capabilities: {
773
- onnxModels: ['all-MiniLM-L6-v2', 'all-mpnet-base-v2'],
773
+ onnxModels: ['Xenova/all-MiniLM-L6-v2', 'Xenova/all-mpnet-base-v2'],
774
774
  geometries: ['euclidean', 'poincare'],
775
775
  normalizations: ['L2', 'L1', 'minmax', 'zscore'],
776
776
  features: ['semantic search', 'hyperbolic projection', 'neural substrate'],
@@ -1692,10 +1692,10 @@ export const hooksIntelligence = {
1692
1692
  },
1693
1693
  embeddings: {
1694
1694
  provider: 'transformers',
1695
- model: 'all-MiniLM-L6-v2',
1695
+ model: 'Xenova/all-MiniLM-L6-v2',
1696
1696
  dimension: 384,
1697
1697
  implemented: true,
1698
- note: 'Real ONNX embeddings via all-MiniLM-L6-v2',
1698
+ note: 'Real ONNX embeddings via Xenova/all-MiniLM-L6-v2',
1699
1699
  },
1700
1700
  },
1701
1701
  realMetrics: {
@@ -165,18 +165,47 @@ export const neuralTools = [
165
165
  };
166
166
  store.models[modelId] = model;
167
167
  saveNeuralStore(store);
168
- // Simulate training
169
- await new Promise(resolve => setTimeout(resolve, 100));
168
+ // Real training: embed training data and store as searchable patterns
169
+ const trainingData = input.data;
170
+ let patternsStored = 0;
171
+ if (trainingData) {
172
+ const entries = Array.isArray(trainingData) ? trainingData : [trainingData];
173
+ for (let i = 0; i < entries.length; i++) {
174
+ const entry = entries[i];
175
+ const text = typeof entry === 'string' ? entry
176
+ : entry?.text
177
+ || entry?.content
178
+ || entry?.label
179
+ || JSON.stringify(entry);
180
+ if (!text)
181
+ continue;
182
+ const embedding = await generateEmbedding(text, 384);
183
+ const patternId = `${modelId}-train-${i}`;
184
+ store.patterns[patternId] = {
185
+ id: patternId,
186
+ name: typeof entry === 'object' && entry !== null && 'label' in entry
187
+ ? String(entry.label) : text.slice(0, 100),
188
+ type: modelType,
189
+ embedding,
190
+ metadata: { modelId, epoch: epochs, index: i, raw: entry },
191
+ createdAt: new Date().toISOString(),
192
+ usageCount: 0,
193
+ };
194
+ patternsStored++;
195
+ }
196
+ }
170
197
  model.status = 'ready';
171
- model.accuracy = 0.85 + Math.random() * 0.1;
198
+ model.accuracy = patternsStored > 0 ? 1.0 : 0; // accuracy = data stored, not simulated
172
199
  model.trainedAt = new Date().toISOString();
173
200
  saveNeuralStore(store);
174
201
  return {
175
202
  success: true,
203
+ _realEmbedding: !!realEmbeddings,
176
204
  modelId,
177
205
  type: modelType,
178
206
  status: model.status,
179
- accuracy: model.accuracy,
207
+ patternsStored,
208
+ totalPatterns: Object.keys(store.patterns).length,
180
209
  epochs,
181
210
  trainedAt: model.trainedAt,
182
211
  };
@@ -205,22 +234,32 @@ export const neuralTools = [
205
234
  if (model && model.status !== 'ready') {
206
235
  return { success: false, error: 'Model not ready' };
207
236
  }
208
- // Simulate predictions
209
- const predictions = [
210
- { label: 'coder', confidence: 0.75 + Math.random() * 0.2 },
211
- { label: 'researcher', confidence: 0.5 + Math.random() * 0.3 },
212
- { label: 'reviewer', confidence: 0.3 + Math.random() * 0.4 },
213
- { label: 'tester', confidence: 0.2 + Math.random() * 0.3 },
214
- ]
215
- .sort((a, b) => b.confidence - a.confidence)
216
- .slice(0, topK);
217
237
  // Generate real embedding for the input
218
238
  const startTime = performance.now();
219
- const embedding = await generateEmbedding(inputText, 128);
239
+ const embedding = await generateEmbedding(inputText, 384);
220
240
  const latency = Math.round(performance.now() - startTime);
241
+ // Search stored patterns via real cosine similarity
242
+ const storedPatterns = Object.values(store.patterns);
243
+ let predictions;
244
+ if (storedPatterns.length > 0) {
245
+ // Real nearest-neighbor prediction using stored pattern embeddings
246
+ predictions = storedPatterns
247
+ .map(p => ({
248
+ label: p.name || p.type || p.id,
249
+ confidence: Math.max(0, cosineSimilarity(embedding, p.embedding)),
250
+ patternId: p.id,
251
+ }))
252
+ .sort((a, b) => b.confidence - a.confidence)
253
+ .slice(0, topK);
254
+ }
255
+ else {
256
+ // No patterns stored — no predictions possible
257
+ predictions = [];
258
+ }
221
259
  return {
222
260
  success: true,
223
261
  _realEmbedding: !!realEmbeddings,
262
+ _hasStoredPatterns: storedPatterns.length > 0,
224
263
  modelId: model?.id || 'default',
225
264
  input: inputText,
226
265
  predictions,
@@ -76,6 +76,7 @@ async function getRegistry(dbPath) {
76
76
  try {
77
77
  await registry.initialize({
78
78
  dbPath: dbPath || getDbPath(),
79
+ embeddingModel: 'Xenova/all-MiniLM-L6-v2',
79
80
  dimension: 384,
80
81
  controllers: {
81
82
  reasoningBank: true,
@@ -1292,7 +1292,7 @@ export async function loadEmbeddingModel(options) {
1292
1292
  return {
1293
1293
  success: true,
1294
1294
  dimensions: 384,
1295
- modelName: 'all-MiniLM-L6-v2',
1295
+ modelName: 'Xenova/all-MiniLM-L6-v2',
1296
1296
  loadTime: Date.now() - startTime
1297
1297
  };
1298
1298
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.5.52",
3
+ "version": "3.5.53",
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",