@o-lang/semantic-doc-search 1.1.1 → 1.1.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/resolver.js +12 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o-lang/semantic-doc-search",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "O-Lang semantic document search resolver with vector embeddings",
5
5
  "main": "src/index.js",
6
6
  "exports": {
package/src/resolver.js CHANGED
@@ -46,11 +46,13 @@ async function resolver(action, context = {}) {
46
46
 
47
47
  // Extract ALL quoted args from action string
48
48
  const args = [...action.matchAll(/"([^"]*)"/g)].map(m => m[1]);
49
-
49
+
50
50
  const vectorStore = VectorRouter.create(context);
51
51
  const getEmbedFn = await embedder({ dimension: 384 });
52
- const useCache = !!context.POSTGRES_URL || !!context.REDIS_URL;
53
- const cache = useCache ? loadCache() : {};
52
+
53
+ // ✅ Always use cache for local persistence no Postgres/Redis required
54
+ const useCache = true;
55
+ const cache = loadCache();
54
56
 
55
57
  // =====================================================
56
58
  // ✅ INGEST: 1 arg = doc_root
@@ -71,7 +73,7 @@ async function resolver(action, context = {}) {
71
73
  const text = sanitizeTextForEmbedding(chunks[i]);
72
74
  if (!text) continue;
73
75
  const hash = hashText(text);
74
- if (useCache && cache[hash]) continue;
76
+ if (cache[hash]) continue; // skip already-ingested chunks
75
77
  const rawVector = await getEmbedFn(text);
76
78
  await vectorStore.upsert({
77
79
  id: `${file}:${i}`,
@@ -79,13 +81,15 @@ async function resolver(action, context = {}) {
79
81
  content: text,
80
82
  source: `file:${file}`,
81
83
  });
82
- if (useCache) cache[hash] = true;
84
+ cache[hash] = true;
83
85
  inserted++;
84
86
  }
85
87
  }
86
88
  }
87
- if (useCache) saveCache(cache);
89
+
90
+ saveCache(cache);
88
91
  if (vectorStore.close) await vectorStore.close();
92
+ console.log(`[vector.search] ✅ Ingested ${inserted} chunks from ${ingestRoot}`);
89
93
  return { inserted, doc_root: ingestRoot };
90
94
  }
91
95
 
@@ -110,6 +114,6 @@ async function resolver(action, context = {}) {
110
114
 
111
115
  // ✅ Must match workflow's "Allow resolvers: - vector.search"
112
116
  resolver.resolverName = "vector.search";
113
- resolver.version = "1.0.42";
117
+ resolver.version = "1.0.43";
114
118
 
115
- module.exports = resolver;
119
+ module.exports = resolver;