@voidwire/lore 0.9.0 → 0.9.1
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/lib/realtime.ts +39 -7
- package/package.json +7 -7
package/lib/realtime.ts
CHANGED
|
@@ -87,13 +87,15 @@ function insertSearchEntry(db: Database, event: CaptureEvent): number {
|
|
|
87
87
|
const title = buildTitle(event);
|
|
88
88
|
const content = getContentForEmbedding(event);
|
|
89
89
|
const metadata = buildMetadata(event);
|
|
90
|
+
const data = event.data as Record<string, unknown>;
|
|
91
|
+
const topic = String(data.topic || "");
|
|
90
92
|
|
|
91
93
|
const stmt = db.prepare(`
|
|
92
|
-
INSERT INTO search (source, title, content, metadata)
|
|
93
|
-
VALUES (?, ?, ?, ?)
|
|
94
|
+
INSERT INTO search (source, title, content, metadata, topic)
|
|
95
|
+
VALUES (?, ?, ?, ?, ?)
|
|
94
96
|
`);
|
|
95
97
|
|
|
96
|
-
const result = stmt.run(source, title, content, metadata);
|
|
98
|
+
const result = stmt.run(source, title, content, metadata, topic);
|
|
97
99
|
return Number(result.lastInsertRowid);
|
|
98
100
|
}
|
|
99
101
|
|
|
@@ -147,10 +149,13 @@ function buildTitle(event: CaptureEvent): string {
|
|
|
147
149
|
|
|
148
150
|
/**
|
|
149
151
|
* Extract content for embedding from event
|
|
152
|
+
* Concatenates topic+content for richer embeddings (matches lore-embed-all)
|
|
150
153
|
*/
|
|
151
154
|
function getContentForEmbedding(event: CaptureEvent): string {
|
|
152
155
|
const data = event.data as Record<string, unknown>;
|
|
153
|
-
|
|
156
|
+
const content = String(data.content || data.text || "");
|
|
157
|
+
const topic = String(data.topic || "").trim();
|
|
158
|
+
return topic ? `${topic} ${content}`.trim() : content;
|
|
154
159
|
}
|
|
155
160
|
|
|
156
161
|
/**
|
|
@@ -255,13 +260,40 @@ function insertEmbedding(
|
|
|
255
260
|
const source = getSourceForEvent(event);
|
|
256
261
|
const data = event.data as Record<string, unknown>;
|
|
257
262
|
const topic = String(data.topic || "");
|
|
263
|
+
const type = extractType(event);
|
|
258
264
|
|
|
259
265
|
const embeddingBlob = serializeEmbedding(embedding);
|
|
260
266
|
|
|
261
267
|
const stmt = db.prepare(`
|
|
262
|
-
INSERT INTO embeddings (doc_id, chunk_idx, source, topic, embedding)
|
|
263
|
-
VALUES (?, 0, ?, ?, ?)
|
|
268
|
+
INSERT INTO embeddings (doc_id, chunk_idx, source, topic, type, embedding)
|
|
269
|
+
VALUES (?, 0, ?, ?, ?, ?)
|
|
264
270
|
`);
|
|
265
271
|
|
|
266
|
-
stmt.run(docId, source, topic, embeddingBlob);
|
|
272
|
+
stmt.run(docId, source, topic, type, embeddingBlob);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Extract type value for embeddings partition column
|
|
277
|
+
*/
|
|
278
|
+
function extractType(event: CaptureEvent): string {
|
|
279
|
+
const data = event.data as Record<string, unknown>;
|
|
280
|
+
|
|
281
|
+
switch (event.type) {
|
|
282
|
+
case "knowledge":
|
|
283
|
+
return String(data.subtype || "general");
|
|
284
|
+
case "teaching":
|
|
285
|
+
return "teaching";
|
|
286
|
+
case "observation":
|
|
287
|
+
return String(data.subtype || "pattern");
|
|
288
|
+
case "insight":
|
|
289
|
+
return String(data.subtype || "insight");
|
|
290
|
+
case "learning":
|
|
291
|
+
return "learning";
|
|
292
|
+
case "task":
|
|
293
|
+
return "task";
|
|
294
|
+
case "note":
|
|
295
|
+
return "note";
|
|
296
|
+
default:
|
|
297
|
+
return "general";
|
|
298
|
+
}
|
|
267
299
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voidwire/lore",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Unified knowledge CLI - Search, list, and capture your indexed knowledge",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
@@ -19,11 +19,6 @@
|
|
|
19
19
|
"README.md",
|
|
20
20
|
"LICENSE"
|
|
21
21
|
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc --noEmit false --outDir dist --declaration",
|
|
24
|
-
"typecheck": "tsc --noEmit",
|
|
25
|
-
"test": "bun test"
|
|
26
|
-
},
|
|
27
22
|
"keywords": [
|
|
28
23
|
"knowledge",
|
|
29
24
|
"search",
|
|
@@ -52,5 +47,10 @@
|
|
|
52
47
|
},
|
|
53
48
|
"devDependencies": {
|
|
54
49
|
"bun-types": "1.3.5"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc --noEmit false --outDir dist --declaration",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"test": "bun test"
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|