claude-flow 3.7.0-alpha.30 → 3.7.0-alpha.32

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.7.0-alpha.30",
3
+ "version": "3.7.0-alpha.32",
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",
@@ -480,14 +480,14 @@ const indexCommand = {
480
480
  description: 'Manage HNSW indexes',
481
481
  options: [
482
482
  { name: 'action', short: 'a', type: 'string', description: 'Action: build, rebuild, status, optimize', default: 'status' },
483
- { name: 'collection', short: 'c', type: 'string', description: 'Collection/namespace name' },
483
+ { name: 'collection', short: 'c', type: 'string', description: 'Collection/namespace label (informational; HNSW is a single global index across all namespaces). Omit to build for all namespaces (#1947 RC2).' },
484
484
  { name: 'ef-construction', type: 'number', description: 'HNSW ef_construction parameter', default: '200' },
485
485
  { name: 'm', type: 'number', description: 'HNSW M parameter', default: '16' },
486
486
  ],
487
487
  examples: [
488
488
  { command: 'claude-flow embeddings index', description: 'Show index status' },
489
- { command: 'claude-flow embeddings index -a build -c documents', description: 'Build index' },
490
- { command: 'claude-flow embeddings index -a optimize -c patterns', description: 'Optimize index' },
489
+ { command: 'claude-flow embeddings index -a build', description: 'Build index from all namespaces' },
490
+ { command: 'claude-flow embeddings index -a rebuild -c project', description: 'Rebuild (label as `project`)' },
491
491
  ],
492
492
  action: async (ctx) => {
493
493
  const action = ctx.flags.action || 'status';
@@ -565,11 +565,15 @@ const indexCommand = {
565
565
  }
566
566
  // Build/Rebuild action
567
567
  if (action === 'build' || action === 'rebuild') {
568
- if (!collection) {
569
- output.printError('Collection is required for build/rebuild');
570
- return { success: false, exitCode: 1 };
571
- }
572
- const spinner = output.createSpinner({ text: `${action}ing index for ${collection}...`, spinner: 'dots' });
568
+ // #1947 RC #2: `-c` is informational — the HNSW index is global
569
+ // and indexes every namespace's embeddings in one structure. The
570
+ // earlier code REQUIRED `-c` for build/rebuild AND its examples
571
+ // suggested `-c default`, which silently produced 0 vectors when a
572
+ // user's entries lived under a different namespace (e.g. `project`,
573
+ // `claude-memories`). Treat omitted `-c` as "all namespaces"
574
+ // (the actual runtime behavior) and tell the user as much.
575
+ const label = collection ?? '(all namespaces)';
576
+ const spinner = output.createSpinner({ text: `${action}ing index for ${label}...`, spinner: 'dots' });
573
577
  spinner.start();
574
578
  // Force rebuild if requested
575
579
  const index = await getHNSWIndex({ forceRebuild: action === 'rebuild' });
@@ -582,13 +586,18 @@ const indexCommand = {
582
586
  const newStatus = getHNSWStatus();
583
587
  output.writeln();
584
588
  output.printBox([
585
- `Collection: ${collection}`,
589
+ `Collection: ${label}`,
586
590
  `Action: ${action}`,
587
591
  `Vectors: ${newStatus.entryCount}`,
588
592
  `Dimensions: ${newStatus.dimensions}`,
589
593
  `M: ${m}`,
590
594
  `ef_construction: ${efConstruction}`,
591
595
  ].join('\n'), 'Index Built');
596
+ if (!collection && newStatus.entryCount === 0) {
597
+ output.writeln();
598
+ output.printInfo('No vectors indexed. Store some entries first:');
599
+ output.printInfo(' claude-flow memory store -k "key" --value "text" --namespace <ns>');
600
+ }
592
601
  return { success: true, data: newStatus };
593
602
  }
594
603
  // Optimize action
@@ -838,14 +838,34 @@ export const memoryTools = [
838
838
  catch { /* ignore */ }
839
839
  }
840
840
  // AgentDB status
841
+ // #1940: previously used `allEntries.entries.length` for the totals,
842
+ // but `listEntries({})` returns the first 20 entries with a separate
843
+ // `total` field for the full row count. So `memory_bridge_status`
844
+ // reported `totalEntries: 0`...20 even when the DB had hundreds of
845
+ // rows. Use `.total` for the count, and surface the namespaces with
846
+ // entries so the report matches what's actually in the store.
841
847
  let agentdbEntries = 0;
842
848
  let claudeMemoryEntries = 0;
849
+ const namespaceCounts = {};
843
850
  try {
844
851
  const { listEntries } = await getMemoryFunctions();
845
852
  const allEntries = await listEntries({});
846
- agentdbEntries = allEntries?.entries?.length ?? 0;
853
+ agentdbEntries = allEntries?.total
854
+ ?? allEntries?.entries?.length ?? 0;
847
855
  const claudeEntries = await listEntries({ namespace: 'claude-memories' });
848
- claudeMemoryEntries = claudeEntries?.entries?.length ?? 0;
856
+ claudeMemoryEntries = claudeEntries?.total
857
+ ?? claudeEntries?.entries?.length ?? 0;
858
+ // Per-namespace counts for the namespaces the reporter referenced
859
+ // (#1940). Best-effort — a namespace with 0 entries is omitted.
860
+ for (const ns of ['default', 'patterns', 'claude-memories', 'auto-memory', 'tasks', 'feedback', 'pretrain']) {
861
+ try {
862
+ const r = await listEntries({ namespace: ns });
863
+ const t = r?.total ?? r?.entries?.length ?? 0;
864
+ if (t > 0)
865
+ namespaceCounts[ns] = t;
866
+ }
867
+ catch { /* skip per-namespace failure */ }
868
+ }
849
869
  }
850
870
  catch { /* ignore */ }
851
871
  // Intelligence status
@@ -859,9 +879,12 @@ export const memoryTools = [
859
879
  catch { /* not initialized */ }
860
880
  return {
861
881
  claudeCode: { memoryFiles: claudeFiles, projects: claudeProjects },
862
- agentdb: { totalEntries: agentdbEntries, claudeMemoryEntries, backend: 'sql.js + ONNX' },
882
+ agentdb: { totalEntries: agentdbEntries, claudeMemoryEntries, namespaces: namespaceCounts, backend: 'sql.js + ONNX' },
863
883
  intelligence,
864
- bridge: { status: claudeMemoryEntries > 0 ? 'connected' : 'not-synced', embedding: 'all-MiniLM-L6-v2 (384-dim)' },
884
+ // #1940: report 'connected' whenever ANY namespace has imported
885
+ // content, not just `claude-memories` — the bridge can be in active
886
+ // use from other import paths (e.g. plugin namespaces, task memory).
887
+ bridge: { status: agentdbEntries > 0 ? 'connected' : 'not-synced', embedding: 'all-MiniLM-L6-v2 (384-dim)' },
865
888
  };
866
889
  },
867
890
  },
@@ -579,6 +579,17 @@ export async function bridgeStoreEntry(options) {
579
579
  embedding, embedding_dimensions, embedding_model,
580
580
  tags, metadata, created_at, updated_at, expires_at, status
581
581
  ) VALUES (?, ?, ?, ?, 'semantic', ?, ?, ?, ?, ?, ?, ?, ?, 'active')`;
582
+ // #1941: provision a `vector_indexes` row for this namespace before the
583
+ // entry insert. AgentDB's HNSW/router keys lookups by namespace via this
584
+ // table — if it has no row for e.g. `claude-memories`, `memory_search`
585
+ // returns 0 results even when memory_entries holds hundreds of rows for
586
+ // that namespace. INSERT OR IGNORE so existing index rows are preserved.
587
+ try {
588
+ ctx.db
589
+ .prepare(`INSERT OR IGNORE INTO vector_indexes (id, name, dimensions) VALUES (?, ?, ?)`)
590
+ .run(namespace, namespace, dimensions || 384);
591
+ }
592
+ catch { /* vector_indexes may not exist on legacy DBs — fall through */ }
582
593
  const stmt = ctx.db.prepare(insertSql);
583
594
  stmt.run(id, key, namespace, value, embeddingJson, dimensions || null, model, tags.length > 0 ? JSON.stringify(tags) : null, '{}', now, now, ttl ? now + (ttl * 1000) : null);
584
595
  // Phase 2: Write-through to TieredCache
@@ -1819,6 +1819,15 @@ export async function storeEntry(options) {
1819
1819
  embeddingDimensions = embResult.dimensions;
1820
1820
  embeddingModel = embResult.model;
1821
1821
  }
1822
+ // #1941: provision a `vector_indexes` row for this namespace before the
1823
+ // entry insert. The HNSW lookup uses this table to find which namespaces
1824
+ // are indexed — without a row, `memory_search({namespace:"X"})` returns
1825
+ // 0 even when memory_entries holds matching rows. INSERT OR IGNORE
1826
+ // preserves the existing `default` / `patterns` rows.
1827
+ try {
1828
+ db.run(`INSERT OR IGNORE INTO vector_indexes (id, name, dimensions) VALUES (?, ?, ?)`, [namespace, namespace, embeddingDimensions ?? 384]);
1829
+ }
1830
+ catch { /* vector_indexes may not exist on legacy DBs — fall through */ }
1822
1831
  // Insert or update entry (upsert mode uses REPLACE)
1823
1832
  const insertSql = upsert
1824
1833
  ? `INSERT OR REPLACE INTO memory_entries (
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.7.0-alpha.30",
3
+ "version": "3.7.0-alpha.32",
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",