wayfind 2.0.50 → 2.0.51

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.
@@ -440,7 +440,26 @@ async function indexJournals(options = {}) {
440
440
  const backend = getBackend(storePath);
441
441
  const existingIndex = backend.loadIndex();
442
442
  const existingEntries = existingIndex ? existingIndex.entries : {};
443
- const existingEmbeddings = doEmbeddings ? backend.loadEmbeddings() : {};
443
+
444
+ // Detect embedding model mismatch — if the stored model differs from the current
445
+ // provider, treat all entries as needing re-embedding so the index stays consistent.
446
+ // A silent auto-migration is better than silently returning garbage similarity scores.
447
+ const currentProviderInfo = llm.getEmbeddingProviderInfo();
448
+ const storedEmbeddingModel = existingIndex ? existingIndex.embedding_model : null;
449
+ const modelChanged = doEmbeddings && storedEmbeddingModel && currentProviderInfo.model &&
450
+ storedEmbeddingModel !== currentProviderInfo.model;
451
+ if (modelChanged) {
452
+ process.stderr.write(
453
+ `[wayfind] Embedding model changed: ${storedEmbeddingModel} → ${currentProviderInfo.model}\n` +
454
+ `[wayfind] Re-embedding all entries for consistent search results...\n`
455
+ );
456
+ // Mark all existing entries as needing re-embedding
457
+ for (const entry of Object.values(existingEntries)) {
458
+ entry.hasEmbedding = false;
459
+ }
460
+ }
461
+
462
+ const existingEmbeddings = doEmbeddings ? (modelChanged ? {} : backend.loadEmbeddings()) : {};
444
463
 
445
464
  // Parse all journal files
446
465
  const files = fs.readdirSync(journalDir).filter(f => DATE_FILE_RE.test(f)).sort();
@@ -1400,9 +1419,24 @@ async function indexConversations(options = {}) {
1400
1419
  // Load existing indexes
1401
1420
  const backend = getBackend(storePath);
1402
1421
  const existingIndex = backend.loadIndex() || { version: INDEX_VERSION, entries: {}, lastUpdated: Date.now(), entryCount: 0 };
1403
- const existingEmbeddings = doEmbeddings ? backend.loadEmbeddings() : {};
1404
1422
  const convIndex = backend.loadConversationIndex();
1405
1423
 
1424
+ // Auto-migrate embeddings if model changed
1425
+ const _convProviderInfo = llm.getEmbeddingProviderInfo();
1426
+ const _convStoredModel = existingIndex.embedding_model || null;
1427
+ const _convModelChanged = doEmbeddings && _convStoredModel && _convProviderInfo.model &&
1428
+ _convStoredModel !== _convProviderInfo.model;
1429
+ if (_convModelChanged) {
1430
+ process.stderr.write(
1431
+ `[wayfind] Embedding model changed: ${_convStoredModel} → ${_convProviderInfo.model}\n` +
1432
+ `[wayfind] Re-embedding conversation entries...\n`
1433
+ );
1434
+ for (const entry of Object.values(existingIndex.entries)) {
1435
+ entry.hasEmbedding = false;
1436
+ }
1437
+ }
1438
+ const existingEmbeddings = doEmbeddings ? (_convModelChanged ? {} : backend.loadEmbeddings()) : {};
1439
+
1406
1440
  // Compute since cutoff
1407
1441
  let sinceCutoff = 0;
1408
1442
  if (options.since) {
@@ -1821,7 +1855,18 @@ async function indexSignals(options = {}) {
1821
1855
  // Load existing index (contains journal + conversation entries too)
1822
1856
  const backend = getBackend(storePath);
1823
1857
  const existingIndex = backend.loadIndex() || { version: INDEX_VERSION, entries: {}, lastUpdated: Date.now(), entryCount: 0 };
1824
- const existingEmbeddings = doEmbeddings ? backend.loadEmbeddings() : {};
1858
+
1859
+ // Auto-migrate embeddings if model changed
1860
+ const _sigProviderInfo = llm.getEmbeddingProviderInfo();
1861
+ const _sigStoredModel = existingIndex.embedding_model || null;
1862
+ const _sigModelChanged = doEmbeddings && _sigStoredModel && _sigProviderInfo.model &&
1863
+ _sigStoredModel !== _sigProviderInfo.model;
1864
+ if (_sigModelChanged) {
1865
+ for (const entry of Object.values(existingIndex.entries)) {
1866
+ entry.hasEmbedding = false;
1867
+ }
1868
+ }
1869
+ const existingEmbeddings = doEmbeddings ? (_sigModelChanged ? {} : backend.loadEmbeddings()) : {};
1825
1870
 
1826
1871
  const stats = { fileCount: 0, newEntries: 0, updatedEntries: 0, skippedEntries: 0 };
1827
1872
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wayfind",
3
- "version": "2.0.50",
3
+ "version": "2.0.51",
4
4
  "description": "Team decision trail for AI-assisted development. The connective tissue between product, engineering, and strategy.",
5
5
  "bin": {
6
6
  "wayfind": "./bin/team-context.js",