@edihasaj/recall 0.6.7 → 0.7.3
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/README.md +57 -1
- package/dist/chunk-2G5DMOVA.js +6527 -0
- package/dist/chunk-2G5DMOVA.js.map +1 -0
- package/dist/chunk-37K4DPRI.js +17 -0
- package/dist/chunk-37K4DPRI.js.map +1 -0
- package/dist/chunk-AKODTKWM.js +123 -0
- package/dist/chunk-AKODTKWM.js.map +1 -0
- package/dist/{chunk-LFWG3CBM.js → chunk-BMWLHPLS.js} +234 -2384
- package/dist/chunk-BMWLHPLS.js.map +1 -0
- package/dist/{chunk-AJAAK4FK.js → chunk-I5TTXHOM.js} +179 -9
- package/dist/chunk-I5TTXHOM.js.map +1 -0
- package/dist/chunk-JRIM7VBY.js +2346 -0
- package/dist/chunk-JRIM7VBY.js.map +1 -0
- package/dist/{chunk-4P3NKEIJ.js → chunk-OLZS3M24.js} +18 -9
- package/dist/{chunk-4P3NKEIJ.js.map → chunk-OLZS3M24.js.map} +1 -1
- package/dist/chunk-QDA5M3AJ.js +2617 -0
- package/dist/chunk-QDA5M3AJ.js.map +1 -0
- package/dist/chunk-QSJKGEID.js +235 -0
- package/dist/chunk-QSJKGEID.js.map +1 -0
- package/dist/chunk-UBPGOOAN.js +462 -0
- package/dist/chunk-UBPGOOAN.js.map +1 -0
- package/dist/{chunk-XUM7JEJU.js → chunk-YL23MKB3.js} +10 -4
- package/dist/{chunk-XUM7JEJU.js.map → chunk-YL23MKB3.js.map} +1 -1
- package/dist/chunk-Z6RT5BUO.js +282 -0
- package/dist/chunk-Z6RT5BUO.js.map +1 -0
- package/dist/{cleanup-JM3CGHUV.js → cleanup-2HK2TX7Q.js} +6 -3
- package/dist/cli.js +167 -28
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +665 -45
- package/dist/daemon.js.map +1 -1
- package/dist/{dispatcher-C5S7SYY6.js → dispatcher-Z4GEFOQG.js} +6 -3
- package/dist/embeddings-GKNH2E3N.js +48 -0
- package/dist/ingest-JWXX22QX.js +19 -0
- package/dist/mcp.js +9 -4
- package/dist/mcp.js.map +1 -1
- package/dist/{quality-YTQKAEY6.js → quality-2JOLSIC3.js} +4 -3
- package/dist/quality-2JOLSIC3.js.map +1 -0
- package/dist/retrieval-GLAEYWGA.js +13 -0
- package/dist/retrieval-GLAEYWGA.js.map +1 -0
- package/dist/store-2BPQPOOZ.js +31 -0
- package/dist/store-2BPQPOOZ.js.map +1 -0
- package/dist/{tasks-KHLJT7MP.js → tasks-GJBURDAB.js} +6 -3
- package/dist/tasks-GJBURDAB.js.map +1 -0
- package/dist/{usage-DU4TKVJH.js → usage-YBS74UEU.js} +8 -4
- package/dist/{usage-DU4TKVJH.js.map → usage-YBS74UEU.js.map} +1 -1
- package/dist/webui/assets/index-BJt1Lf-q.css +1 -0
- package/dist/webui/assets/index-Bfhwll2B.js +5224 -0
- package/dist/webui/assets/index-Bfhwll2B.js.map +1 -0
- package/dist/webui/index.html +15 -0
- package/dist/webui/recall-icon.png +0 -0
- package/drizzle/0008_premium_red_hulk.sql +44 -0
- package/drizzle/meta/0008_snapshot.json +2491 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +8 -3
- package/dist/chunk-A6XEULA4.js +0 -470
- package/dist/chunk-A6XEULA4.js.map +0 -1
- package/dist/chunk-AJAAK4FK.js.map +0 -1
- package/dist/chunk-DSNYEUZW.js +0 -2993
- package/dist/chunk-DSNYEUZW.js.map +0 -1
- package/dist/chunk-LFWG3CBM.js.map +0 -1
- /package/dist/{cleanup-JM3CGHUV.js.map → cleanup-2HK2TX7Q.js.map} +0 -0
- /package/dist/{dispatcher-C5S7SYY6.js.map → dispatcher-Z4GEFOQG.js.map} +0 -0
- /package/dist/{quality-YTQKAEY6.js.map → embeddings-GKNH2E3N.js.map} +0 -0
- /package/dist/{tasks-KHLJT7MP.js.map → ingest-JWXX22QX.js.map} +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import {
|
|
2
|
+
and,
|
|
3
|
+
entities,
|
|
4
|
+
entityRelations,
|
|
5
|
+
eq,
|
|
6
|
+
inArray,
|
|
7
|
+
like,
|
|
8
|
+
memoryEntities,
|
|
9
|
+
or,
|
|
10
|
+
sql
|
|
11
|
+
} from "./chunk-QDA5M3AJ.js";
|
|
12
|
+
|
|
13
|
+
// src/graph/store.ts
|
|
14
|
+
import { randomUUID } from "crypto";
|
|
15
|
+
|
|
16
|
+
// src/graph/normalize.ts
|
|
17
|
+
function normalizeName(kind, raw) {
|
|
18
|
+
const trimmed = raw.trim();
|
|
19
|
+
switch (kind) {
|
|
20
|
+
case "file":
|
|
21
|
+
case "repo_path":
|
|
22
|
+
return trimmed.replace(/\\/g, "/").replace(/^[./]+/, "").replace(/\/+$/, "").toLowerCase();
|
|
23
|
+
case "function":
|
|
24
|
+
return trimmed.replace(/\(.*\)/, "").replace(/\s+/g, "").toLowerCase();
|
|
25
|
+
case "library":
|
|
26
|
+
case "tool":
|
|
27
|
+
case "command":
|
|
28
|
+
return trimmed.toLowerCase();
|
|
29
|
+
case "url":
|
|
30
|
+
try {
|
|
31
|
+
const u = new URL(trimmed);
|
|
32
|
+
return `${u.hostname.toLowerCase()}${u.pathname.replace(/\/+$/, "")}`;
|
|
33
|
+
} catch {
|
|
34
|
+
return trimmed.toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
case "concept":
|
|
37
|
+
default:
|
|
38
|
+
return trimmed.toLowerCase().replace(/\s+/g, " ");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function isPlausibleEntityName(kind, name) {
|
|
42
|
+
const n = name.trim();
|
|
43
|
+
if (n.length === 0 || n.length > 200) return false;
|
|
44
|
+
if (/^[0-9]+$/.test(n)) return false;
|
|
45
|
+
if (kind === "concept" && n.split(/\s+/).length > 8) return false;
|
|
46
|
+
if ((kind === "library" || kind === "tool") && n.length < 2) return false;
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/graph/store.ts
|
|
51
|
+
function upsertEntity(db, input) {
|
|
52
|
+
const normalized = normalizeName(input.kind, input.name);
|
|
53
|
+
const repo = input.repo ?? null;
|
|
54
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
55
|
+
const existing = findEntityByNormalized(db, input.kind, normalized, repo);
|
|
56
|
+
if (existing) {
|
|
57
|
+
db.update(entities).set({
|
|
58
|
+
mention_count: existing.mention_count + 1,
|
|
59
|
+
updated_at: now,
|
|
60
|
+
// Backfill description / first_seen if not previously set.
|
|
61
|
+
description: existing.description ?? input.description ?? null,
|
|
62
|
+
first_seen_memory_id: existing.first_seen_memory_id ?? input.first_seen_memory_id ?? null
|
|
63
|
+
}).where(eq(entities.id, existing.id)).run();
|
|
64
|
+
return {
|
|
65
|
+
...existing,
|
|
66
|
+
mention_count: existing.mention_count + 1,
|
|
67
|
+
updated_at: now,
|
|
68
|
+
description: existing.description ?? input.description ?? null,
|
|
69
|
+
first_seen_memory_id: existing.first_seen_memory_id ?? input.first_seen_memory_id ?? null
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const id = randomUUID();
|
|
73
|
+
db.insert(entities).values({
|
|
74
|
+
id,
|
|
75
|
+
kind: input.kind,
|
|
76
|
+
name: input.name.trim(),
|
|
77
|
+
normalized_name: normalized,
|
|
78
|
+
repo,
|
|
79
|
+
description: input.description ?? null,
|
|
80
|
+
first_seen_memory_id: input.first_seen_memory_id ?? null,
|
|
81
|
+
mention_count: 1,
|
|
82
|
+
created_at: now,
|
|
83
|
+
updated_at: now
|
|
84
|
+
}).run();
|
|
85
|
+
return {
|
|
86
|
+
id,
|
|
87
|
+
kind: input.kind,
|
|
88
|
+
name: input.name.trim(),
|
|
89
|
+
normalized_name: normalized,
|
|
90
|
+
repo,
|
|
91
|
+
description: input.description ?? null,
|
|
92
|
+
mention_count: 1,
|
|
93
|
+
first_seen_memory_id: input.first_seen_memory_id ?? null,
|
|
94
|
+
created_at: now,
|
|
95
|
+
updated_at: now
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function findEntityByNormalized(db, kind, normalized, repo) {
|
|
99
|
+
const row = db.select().from(entities).where(
|
|
100
|
+
and(
|
|
101
|
+
eq(entities.kind, kind),
|
|
102
|
+
eq(entities.normalized_name, normalized),
|
|
103
|
+
repo === null ? sql`${entities.repo} IS NULL` : eq(entities.repo, repo)
|
|
104
|
+
)
|
|
105
|
+
).get();
|
|
106
|
+
return row ?? null;
|
|
107
|
+
}
|
|
108
|
+
function getEntity(db, id) {
|
|
109
|
+
const row = db.select().from(entities).where(eq(entities.id, id)).get();
|
|
110
|
+
return row ?? null;
|
|
111
|
+
}
|
|
112
|
+
function listEntities(db, opts = {}) {
|
|
113
|
+
const conditions = [];
|
|
114
|
+
if (opts.repo) conditions.push(eq(entities.repo, opts.repo));
|
|
115
|
+
if (opts.kind) conditions.push(eq(entities.kind, opts.kind));
|
|
116
|
+
if (opts.search) {
|
|
117
|
+
const needle = `%${opts.search.toLowerCase()}%`;
|
|
118
|
+
conditions.push(
|
|
119
|
+
or(
|
|
120
|
+
like(entities.normalized_name, needle),
|
|
121
|
+
like(sql`lower(${entities.name})`, needle)
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
const where = conditions.length === 1 ? conditions[0] : conditions.length > 1 ? and(...conditions) : void 0;
|
|
126
|
+
const builder = where ? db.select().from(entities).where(where) : db.select().from(entities);
|
|
127
|
+
return builder.orderBy(sql`${entities.mention_count} DESC`).limit(opts.limit ?? 200).offset(opts.offset ?? 0).all();
|
|
128
|
+
}
|
|
129
|
+
function linkMemoryToEntity(db, input) {
|
|
130
|
+
const existing = db.select({ id: memoryEntities.id }).from(memoryEntities).where(
|
|
131
|
+
and(
|
|
132
|
+
eq(memoryEntities.memory_id, input.memory_id),
|
|
133
|
+
eq(memoryEntities.entity_id, input.entity_id)
|
|
134
|
+
)
|
|
135
|
+
).get();
|
|
136
|
+
if (existing) return;
|
|
137
|
+
db.insert(memoryEntities).values({
|
|
138
|
+
id: randomUUID(),
|
|
139
|
+
memory_id: input.memory_id,
|
|
140
|
+
entity_id: input.entity_id,
|
|
141
|
+
source: input.source,
|
|
142
|
+
weight: input.weight ?? 1,
|
|
143
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
144
|
+
}).run();
|
|
145
|
+
}
|
|
146
|
+
function listEntitiesForMemory(db, memoryId) {
|
|
147
|
+
return db.select({
|
|
148
|
+
id: entities.id,
|
|
149
|
+
kind: entities.kind,
|
|
150
|
+
name: entities.name,
|
|
151
|
+
normalized_name: entities.normalized_name,
|
|
152
|
+
repo: entities.repo,
|
|
153
|
+
description: entities.description,
|
|
154
|
+
mention_count: entities.mention_count,
|
|
155
|
+
first_seen_memory_id: entities.first_seen_memory_id,
|
|
156
|
+
created_at: entities.created_at,
|
|
157
|
+
updated_at: entities.updated_at
|
|
158
|
+
}).from(memoryEntities).innerJoin(entities, eq(entities.id, memoryEntities.entity_id)).where(eq(memoryEntities.memory_id, memoryId)).all();
|
|
159
|
+
}
|
|
160
|
+
function listMemoryIdsForEntity(db, entityId) {
|
|
161
|
+
const rows = db.select({ memory_id: memoryEntities.memory_id }).from(memoryEntities).where(eq(memoryEntities.entity_id, entityId)).all();
|
|
162
|
+
return rows.map((r) => r.memory_id);
|
|
163
|
+
}
|
|
164
|
+
function upsertRelation(db, input) {
|
|
165
|
+
const sourceMem = input.source_memory_id ?? null;
|
|
166
|
+
const existing = db.select().from(entityRelations).where(
|
|
167
|
+
and(
|
|
168
|
+
eq(entityRelations.source_entity_id, input.source_entity_id),
|
|
169
|
+
eq(entityRelations.target_entity_id, input.target_entity_id),
|
|
170
|
+
eq(entityRelations.relation_type, input.relation_type),
|
|
171
|
+
sourceMem === null ? sql`${entityRelations.source_memory_id} IS NULL` : eq(entityRelations.source_memory_id, sourceMem)
|
|
172
|
+
)
|
|
173
|
+
).get();
|
|
174
|
+
if (existing) {
|
|
175
|
+
if (input.confidence !== void 0 && input.confidence > existing.confidence) {
|
|
176
|
+
db.update(entityRelations).set({ confidence: input.confidence }).where(eq(entityRelations.id, existing.id)).run();
|
|
177
|
+
return { ...existing, confidence: input.confidence };
|
|
178
|
+
}
|
|
179
|
+
return existing;
|
|
180
|
+
}
|
|
181
|
+
const id = randomUUID();
|
|
182
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
183
|
+
db.insert(entityRelations).values({
|
|
184
|
+
id,
|
|
185
|
+
source_entity_id: input.source_entity_id,
|
|
186
|
+
target_entity_id: input.target_entity_id,
|
|
187
|
+
relation_type: input.relation_type,
|
|
188
|
+
source_memory_id: sourceMem,
|
|
189
|
+
confidence: input.confidence ?? 0.6,
|
|
190
|
+
created_at: now
|
|
191
|
+
}).run();
|
|
192
|
+
return {
|
|
193
|
+
id,
|
|
194
|
+
source_entity_id: input.source_entity_id,
|
|
195
|
+
target_entity_id: input.target_entity_id,
|
|
196
|
+
relation_type: input.relation_type,
|
|
197
|
+
source_memory_id: sourceMem,
|
|
198
|
+
confidence: input.confidence ?? 0.6,
|
|
199
|
+
created_at: now
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function neighborsOf(db, entityId, options = {}) {
|
|
203
|
+
const maxHops = Math.max(1, Math.min(5, options.hops ?? 1));
|
|
204
|
+
const visited = /* @__PURE__ */ new Set([entityId]);
|
|
205
|
+
let frontier = [entityId];
|
|
206
|
+
const collectedRelations = /* @__PURE__ */ new Map();
|
|
207
|
+
for (let hop = 0; hop < maxHops; hop++) {
|
|
208
|
+
if (frontier.length === 0) break;
|
|
209
|
+
const next = [];
|
|
210
|
+
const relationFilter = options.relationTypes;
|
|
211
|
+
const outgoing = db.select().from(entityRelations).where(
|
|
212
|
+
relationFilter && relationFilter.length > 0 ? and(
|
|
213
|
+
inArray(entityRelations.source_entity_id, frontier),
|
|
214
|
+
inArray(entityRelations.relation_type, relationFilter)
|
|
215
|
+
) : inArray(entityRelations.source_entity_id, frontier)
|
|
216
|
+
).all();
|
|
217
|
+
const incoming = db.select().from(entityRelations).where(
|
|
218
|
+
relationFilter && relationFilter.length > 0 ? and(
|
|
219
|
+
inArray(entityRelations.target_entity_id, frontier),
|
|
220
|
+
inArray(entityRelations.relation_type, relationFilter)
|
|
221
|
+
) : inArray(entityRelations.target_entity_id, frontier)
|
|
222
|
+
).all();
|
|
223
|
+
for (const rel of [...outgoing, ...incoming]) {
|
|
224
|
+
collectedRelations.set(rel.id, rel);
|
|
225
|
+
for (const candidate of [rel.source_entity_id, rel.target_entity_id]) {
|
|
226
|
+
if (!visited.has(candidate)) {
|
|
227
|
+
visited.add(candidate);
|
|
228
|
+
next.push(candidate);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
frontier = next;
|
|
233
|
+
}
|
|
234
|
+
const entityRows = visited.size === 0 ? [] : db.select().from(entities).where(inArray(entities.id, Array.from(visited))).all();
|
|
235
|
+
return {
|
|
236
|
+
entities: entityRows,
|
|
237
|
+
relations: Array.from(collectedRelations.values())
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function listAllRelations(db, opts = {}) {
|
|
241
|
+
const limit = Math.min(Math.max(opts.limit ?? 2e3, 1), 1e4);
|
|
242
|
+
if (!opts.repo) {
|
|
243
|
+
return db.select().from(entityRelations).limit(limit).all();
|
|
244
|
+
}
|
|
245
|
+
const repoEntityIds = db.select({ id: entities.id }).from(entities).where(eq(entities.repo, opts.repo)).all().map((r) => r.id);
|
|
246
|
+
if (repoEntityIds.length === 0) return [];
|
|
247
|
+
const idSet = new Set(repoEntityIds);
|
|
248
|
+
const all = db.select().from(entityRelations).where(
|
|
249
|
+
and(
|
|
250
|
+
inArray(entityRelations.source_entity_id, repoEntityIds),
|
|
251
|
+
inArray(entityRelations.target_entity_id, repoEntityIds)
|
|
252
|
+
)
|
|
253
|
+
).limit(limit).all();
|
|
254
|
+
return all.filter(
|
|
255
|
+
(r) => idSet.has(r.source_entity_id) && idSet.has(r.target_entity_id)
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
function countEntities(db) {
|
|
259
|
+
const row = db.select({ c: sql`count(*)` }).from(entities).get();
|
|
260
|
+
return Number(row?.c ?? 0);
|
|
261
|
+
}
|
|
262
|
+
function countRelations(db) {
|
|
263
|
+
const row = db.select({ c: sql`count(*)` }).from(entityRelations).get();
|
|
264
|
+
return Number(row?.c ?? 0);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export {
|
|
268
|
+
isPlausibleEntityName,
|
|
269
|
+
upsertEntity,
|
|
270
|
+
findEntityByNormalized,
|
|
271
|
+
getEntity,
|
|
272
|
+
listEntities,
|
|
273
|
+
linkMemoryToEntity,
|
|
274
|
+
listEntitiesForMemory,
|
|
275
|
+
listMemoryIdsForEntity,
|
|
276
|
+
upsertRelation,
|
|
277
|
+
neighborsOf,
|
|
278
|
+
listAllRelations,
|
|
279
|
+
countEntities,
|
|
280
|
+
countRelations
|
|
281
|
+
};
|
|
282
|
+
//# sourceMappingURL=chunk-Z6RT5BUO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph/store.ts","../src/graph/normalize.ts"],"sourcesContent":["/**\n * Read/write layer for the knowledge graph tables. Pure DB operations —\n * no LLM calls, no business logic — so they're safe to call from any\n * code path (capture hook, dispatcher, scan, MCP tool).\n */\nimport { randomUUID } from \"node:crypto\";\nimport { and, eq, inArray, like, or, sql } from \"drizzle-orm\";\nimport type { RecallDb } from \"../db/client.js\";\nimport { entities, entityRelations, memoryEntities } from \"../db/schema.js\";\nimport { normalizeName, type EntityKind } from \"./normalize.js\";\n\nexport type RelationType =\n | \"uses\"\n | \"replaces\"\n | \"conflicts_with\"\n | \"tested_by\"\n | \"depends_on\"\n | \"references\"\n | \"part_of\";\n\nexport interface EntityRow {\n id: string;\n kind: EntityKind;\n name: string;\n normalized_name: string;\n repo: string | null;\n description: string | null;\n mention_count: number;\n first_seen_memory_id: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface EntityRelationRow {\n id: string;\n source_entity_id: string;\n target_entity_id: string;\n relation_type: RelationType;\n source_memory_id: string | null;\n confidence: number;\n created_at: string;\n}\n\nexport interface UpsertEntityInput {\n kind: EntityKind;\n name: string;\n repo?: string | null;\n description?: string | null;\n first_seen_memory_id?: string | null;\n}\n\n/**\n * Insert or look up an entity by (kind, normalized_name, repo). Returns the\n * canonical row. Increments mention_count on every call so we can rank\n * entities by how often the codebase mentions them.\n */\nexport function upsertEntity(db: RecallDb, input: UpsertEntityInput): EntityRow {\n const normalized = normalizeName(input.kind, input.name);\n const repo = input.repo ?? null;\n const now = new Date().toISOString();\n\n const existing = findEntityByNormalized(db, input.kind, normalized, repo);\n if (existing) {\n db.update(entities)\n .set({\n mention_count: existing.mention_count + 1,\n updated_at: now,\n // Backfill description / first_seen if not previously set.\n description: existing.description ?? input.description ?? null,\n first_seen_memory_id: existing.first_seen_memory_id ?? input.first_seen_memory_id ?? null,\n })\n .where(eq(entities.id, existing.id))\n .run();\n return {\n ...existing,\n mention_count: existing.mention_count + 1,\n updated_at: now,\n description: existing.description ?? input.description ?? null,\n first_seen_memory_id: existing.first_seen_memory_id ?? input.first_seen_memory_id ?? null,\n };\n }\n\n const id = randomUUID();\n db.insert(entities)\n .values({\n id,\n kind: input.kind,\n name: input.name.trim(),\n normalized_name: normalized,\n repo,\n description: input.description ?? null,\n first_seen_memory_id: input.first_seen_memory_id ?? null,\n mention_count: 1,\n created_at: now,\n updated_at: now,\n })\n .run();\n return {\n id,\n kind: input.kind,\n name: input.name.trim(),\n normalized_name: normalized,\n repo,\n description: input.description ?? null,\n mention_count: 1,\n first_seen_memory_id: input.first_seen_memory_id ?? null,\n created_at: now,\n updated_at: now,\n };\n}\n\nexport function findEntityByNormalized(\n db: RecallDb,\n kind: EntityKind,\n normalized: string,\n repo: string | null,\n): EntityRow | null {\n const row = db\n .select()\n .from(entities)\n .where(\n and(\n eq(entities.kind, kind),\n eq(entities.normalized_name, normalized),\n repo === null\n ? sql`${entities.repo} IS NULL`\n : eq(entities.repo, repo),\n ),\n )\n .get();\n return (row as EntityRow | undefined) ?? null;\n}\n\nexport function getEntity(db: RecallDb, id: string): EntityRow | null {\n const row = db.select().from(entities).where(eq(entities.id, id)).get();\n return (row as EntityRow | undefined) ?? null;\n}\n\nexport interface ListEntitiesOptions {\n repo?: string;\n kind?: EntityKind;\n search?: string;\n limit?: number;\n offset?: number;\n}\n\nexport function listEntities(db: RecallDb, opts: ListEntitiesOptions = {}): EntityRow[] {\n const conditions = [] as Array<ReturnType<typeof eq> | ReturnType<typeof or>>;\n if (opts.repo) conditions.push(eq(entities.repo, opts.repo));\n if (opts.kind) conditions.push(eq(entities.kind, opts.kind));\n if (opts.search) {\n // Push the contains-match into SQL so LIMIT applies post-filter; the\n // previous in-memory filter only saw the top-N by mention_count and\n // missed long-tail matches entirely.\n const needle = `%${opts.search.toLowerCase()}%`;\n conditions.push(\n or(\n like(entities.normalized_name, needle),\n like(sql`lower(${entities.name})`, needle),\n )!,\n );\n }\n const where = conditions.length === 1 ? conditions[0] : conditions.length > 1 ? and(...conditions) : undefined;\n const builder = where\n ? db.select().from(entities).where(where)\n : db.select().from(entities);\n return builder\n .orderBy(sql`${entities.mention_count} DESC`)\n .limit(opts.limit ?? 200)\n .offset(opts.offset ?? 0)\n .all() as EntityRow[];\n}\n\nexport interface LinkMemoryEntityInput {\n memory_id: string;\n entity_id: string;\n source: \"heuristic\" | \"llm\" | \"manual\";\n weight?: number;\n}\n\n/** Idempotent: links a memory to an entity, no-op if the edge already exists. */\nexport function linkMemoryToEntity(db: RecallDb, input: LinkMemoryEntityInput): void {\n const existing = db\n .select({ id: memoryEntities.id })\n .from(memoryEntities)\n .where(\n and(\n eq(memoryEntities.memory_id, input.memory_id),\n eq(memoryEntities.entity_id, input.entity_id),\n ),\n )\n .get();\n if (existing) return;\n db.insert(memoryEntities)\n .values({\n id: randomUUID(),\n memory_id: input.memory_id,\n entity_id: input.entity_id,\n source: input.source,\n weight: input.weight ?? 1,\n created_at: new Date().toISOString(),\n })\n .run();\n}\n\nexport function listEntitiesForMemory(db: RecallDb, memoryId: string): EntityRow[] {\n return db\n .select({\n id: entities.id,\n kind: entities.kind,\n name: entities.name,\n normalized_name: entities.normalized_name,\n repo: entities.repo,\n description: entities.description,\n mention_count: entities.mention_count,\n first_seen_memory_id: entities.first_seen_memory_id,\n created_at: entities.created_at,\n updated_at: entities.updated_at,\n })\n .from(memoryEntities)\n .innerJoin(entities, eq(entities.id, memoryEntities.entity_id))\n .where(eq(memoryEntities.memory_id, memoryId))\n .all() as EntityRow[];\n}\n\nexport function listMemoryIdsForEntity(db: RecallDb, entityId: string): string[] {\n const rows = db\n .select({ memory_id: memoryEntities.memory_id })\n .from(memoryEntities)\n .where(eq(memoryEntities.entity_id, entityId))\n .all();\n return rows.map((r) => r.memory_id);\n}\n\nexport interface UpsertRelationInput {\n source_entity_id: string;\n target_entity_id: string;\n relation_type: RelationType;\n source_memory_id?: string | null;\n confidence?: number;\n}\n\n/** Idempotent on (source, target, relation_type, source_memory_id). */\nexport function upsertRelation(db: RecallDb, input: UpsertRelationInput): EntityRelationRow {\n const sourceMem = input.source_memory_id ?? null;\n const existing = db\n .select()\n .from(entityRelations)\n .where(\n and(\n eq(entityRelations.source_entity_id, input.source_entity_id),\n eq(entityRelations.target_entity_id, input.target_entity_id),\n eq(entityRelations.relation_type, input.relation_type),\n sourceMem === null\n ? sql`${entityRelations.source_memory_id} IS NULL`\n : eq(entityRelations.source_memory_id, sourceMem),\n ),\n )\n .get() as EntityRelationRow | undefined;\n if (existing) {\n if (input.confidence !== undefined && input.confidence > existing.confidence) {\n db.update(entityRelations)\n .set({ confidence: input.confidence })\n .where(eq(entityRelations.id, existing.id))\n .run();\n return { ...existing, confidence: input.confidence };\n }\n return existing;\n }\n const id = randomUUID();\n const now = new Date().toISOString();\n db.insert(entityRelations)\n .values({\n id,\n source_entity_id: input.source_entity_id,\n target_entity_id: input.target_entity_id,\n relation_type: input.relation_type,\n source_memory_id: sourceMem,\n confidence: input.confidence ?? 0.6,\n created_at: now,\n })\n .run();\n return {\n id,\n source_entity_id: input.source_entity_id,\n target_entity_id: input.target_entity_id,\n relation_type: input.relation_type,\n source_memory_id: sourceMem,\n confidence: input.confidence ?? 0.6,\n created_at: now,\n };\n}\n\nexport function neighborsOf(\n db: RecallDb,\n entityId: string,\n options: { hops?: number; relationTypes?: RelationType[] } = {},\n): { entities: EntityRow[]; relations: EntityRelationRow[] } {\n const maxHops = Math.max(1, Math.min(5, options.hops ?? 1));\n const visited = new Set<string>([entityId]);\n let frontier = [entityId];\n const collectedRelations = new Map<string, EntityRelationRow>();\n\n for (let hop = 0; hop < maxHops; hop++) {\n if (frontier.length === 0) break;\n const next: string[] = [];\n const relationFilter = options.relationTypes;\n const outgoing = db\n .select()\n .from(entityRelations)\n .where(\n relationFilter && relationFilter.length > 0\n ? and(\n inArray(entityRelations.source_entity_id, frontier),\n inArray(entityRelations.relation_type, relationFilter),\n )\n : inArray(entityRelations.source_entity_id, frontier),\n )\n .all() as EntityRelationRow[];\n const incoming = db\n .select()\n .from(entityRelations)\n .where(\n relationFilter && relationFilter.length > 0\n ? and(\n inArray(entityRelations.target_entity_id, frontier),\n inArray(entityRelations.relation_type, relationFilter),\n )\n : inArray(entityRelations.target_entity_id, frontier),\n )\n .all() as EntityRelationRow[];\n\n for (const rel of [...outgoing, ...incoming]) {\n collectedRelations.set(rel.id, rel);\n for (const candidate of [rel.source_entity_id, rel.target_entity_id]) {\n if (!visited.has(candidate)) {\n visited.add(candidate);\n next.push(candidate);\n }\n }\n }\n frontier = next;\n }\n\n const entityRows = visited.size === 0\n ? []\n : (db\n .select()\n .from(entities)\n .where(inArray(entities.id, Array.from(visited)))\n .all() as EntityRow[]);\n\n return {\n entities: entityRows,\n relations: Array.from(collectedRelations.values()),\n };\n}\n\n/**\n * List every relation in the graph, optionally restricted to relations\n * whose source AND target entities both belong to the given repo. Used by\n * the WebUI to render the whole graph at once (no seed required).\n */\nexport function listAllRelations(\n db: RecallDb,\n opts: { repo?: string; limit?: number } = {},\n): EntityRelationRow[] {\n const limit = Math.min(Math.max(opts.limit ?? 2000, 1), 10_000);\n if (!opts.repo) {\n return db\n .select()\n .from(entityRelations)\n .limit(limit)\n .all() as EntityRelationRow[];\n }\n // Filter both endpoints to entities in the repo. Two-step: collect ids,\n // then pick relations whose endpoints are both inside that set.\n const repoEntityIds = db\n .select({ id: entities.id })\n .from(entities)\n .where(eq(entities.repo, opts.repo))\n .all()\n .map((r) => r.id);\n if (repoEntityIds.length === 0) return [];\n const idSet = new Set(repoEntityIds);\n const all = db\n .select()\n .from(entityRelations)\n .where(\n and(\n inArray(entityRelations.source_entity_id, repoEntityIds),\n inArray(entityRelations.target_entity_id, repoEntityIds),\n ),\n )\n .limit(limit)\n .all() as EntityRelationRow[];\n return all.filter(\n (r) => idSet.has(r.source_entity_id) && idSet.has(r.target_entity_id),\n );\n}\n\nexport function countEntities(db: RecallDb): number {\n const row = db\n .select({ c: sql<number>`count(*)` })\n .from(entities)\n .get();\n return Number(row?.c ?? 0);\n}\n\nexport function countRelations(db: RecallDb): number {\n const row = db\n .select({ c: sql<number>`count(*)` })\n .from(entityRelations)\n .get();\n return Number(row?.c ?? 0);\n}\n","/**\n * Canonical-form helpers for entity dedup. Two entities with the same\n * (kind, normalizedName, repo) collapse into one node.\n *\n * Normalization rules are conservative on purpose — we'd rather have a\n * duplicate than merge two semantically distinct things. Aggressive\n * merging belongs in a maintenance pass that can be reviewed.\n */\n\nexport type EntityKind =\n | \"file\"\n | \"function\"\n | \"library\"\n | \"tool\"\n | \"concept\"\n | \"repo_path\"\n | \"command\"\n | \"url\";\n\nexport function normalizeName(kind: EntityKind, raw: string): string {\n const trimmed = raw.trim();\n switch (kind) {\n case \"file\":\n case \"repo_path\":\n // Posix-style paths, no leading slash, no trailing slash.\n return trimmed\n .replace(/\\\\/g, \"/\")\n .replace(/^[./]+/, \"\")\n .replace(/\\/+$/, \"\")\n .toLowerCase();\n case \"function\":\n // foo() / Class.method / obj.method — keep the dotted form, drop parens/args.\n return trimmed\n .replace(/\\(.*\\)/, \"\")\n .replace(/\\s+/g, \"\")\n .toLowerCase();\n case \"library\":\n case \"tool\":\n case \"command\":\n // package names / CLI names: lowercase, strip @scope leading-only if present\n // but keep `@scope/name` distinct from `name`.\n return trimmed.toLowerCase();\n case \"url\":\n try {\n const u = new URL(trimmed);\n return `${u.hostname.toLowerCase()}${u.pathname.replace(/\\/+$/, \"\")}`;\n } catch {\n return trimmed.toLowerCase();\n }\n case \"concept\":\n default:\n return trimmed.toLowerCase().replace(/\\s+/g, \" \");\n }\n}\n\nexport function isPlausibleEntityName(kind: EntityKind, name: string): boolean {\n const n = name.trim();\n if (n.length === 0 || n.length > 200) return false;\n // Filter common false positives that look like identifiers but aren't.\n if (/^[0-9]+$/.test(n)) return false;\n if (kind === \"concept\" && n.split(/\\s+/).length > 8) return false;\n // Single-letter \"library\" tokens are almost always noise.\n if ((kind === \"library\" || kind === \"tool\") && n.length < 2) return false;\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;AAKA,SAAS,kBAAkB;;;ACcpB,SAAS,cAAc,MAAkB,KAAqB;AACnE,QAAM,UAAU,IAAI,KAAK;AACzB,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AAEH,aAAO,QACJ,QAAQ,OAAO,GAAG,EAClB,QAAQ,UAAU,EAAE,EACpB,QAAQ,QAAQ,EAAE,EAClB,YAAY;AAAA,IACjB,KAAK;AAEH,aAAO,QACJ,QAAQ,UAAU,EAAE,EACpB,QAAQ,QAAQ,EAAE,EAClB,YAAY;AAAA,IACjB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAGH,aAAO,QAAQ,YAAY;AAAA,IAC7B,KAAK;AACH,UAAI;AACF,cAAM,IAAI,IAAI,IAAI,OAAO;AACzB,eAAO,GAAG,EAAE,SAAS,YAAY,CAAC,GAAG,EAAE,SAAS,QAAQ,QAAQ,EAAE,CA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,IAAI,EAAE,gBAAgB,KAAK,MAAM,IAAI,EAAE,gBAAgB;AAAA,EACtE;AACF;AAEO,SAAS,cAAc,IAAsB;AAClD,QAAM,MAAM,GACT,OAAO,EAAE,GAAG,cAAsB,CAAC,EACnC,KAAK,QAAQ,EACb,IAAI;AACP,SAAO,OAAO,KAAK,KAAK,CAAC;AAC3B;AAEO,SAAS,eAAe,IAAsB;AACnD,QAAM,MAAM,GACT,OAAO,EAAE,GAAG,cAAsB,CAAC,EACnC,KAAK,eAAe,EACpB,IAAI;AACP,SAAO,OAAO,KAAK,KAAK,CAAC;AAC3B;","names":[]}
|
|
@@ -9,8 +9,11 @@ import {
|
|
|
9
9
|
qualityReasons,
|
|
10
10
|
revertCleanupRun,
|
|
11
11
|
runDeterministicCleanup
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-BMWLHPLS.js";
|
|
13
|
+
import "./chunk-UBPGOOAN.js";
|
|
14
|
+
import "./chunk-37K4DPRI.js";
|
|
15
|
+
import "./chunk-JRIM7VBY.js";
|
|
16
|
+
import "./chunk-QDA5M3AJ.js";
|
|
14
17
|
import "./chunk-DNFKAHS6.js";
|
|
15
18
|
import "./chunk-4CV4JOE5.js";
|
|
16
19
|
export {
|
|
@@ -25,4 +28,4 @@ export {
|
|
|
25
28
|
revertCleanupRun,
|
|
26
29
|
runDeterministicCleanup
|
|
27
30
|
};
|
|
28
|
-
//# sourceMappingURL=cleanup-
|
|
31
|
+
//# sourceMappingURL=cleanup-2HK2TX7Q.js.map
|
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
readCodexSessionStartInputFromStdin,
|
|
23
23
|
readCodexToolInputFromStdin,
|
|
24
24
|
restoreBackup
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-OLZS3M24.js";
|
|
26
26
|
import {
|
|
27
27
|
RECALL_DB_USER_VERSION,
|
|
28
28
|
compileContext,
|
|
@@ -61,43 +61,50 @@ import {
|
|
|
61
61
|
startEvalSession,
|
|
62
62
|
togglePolicy,
|
|
63
63
|
writeRepoContextArtifact
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-2G5DMOVA.js";
|
|
65
65
|
import {
|
|
66
66
|
autoResolveContradictions,
|
|
67
|
-
bootstrapEmbeddings,
|
|
68
67
|
computeAllHealthScores,
|
|
69
68
|
computeHealthScore,
|
|
70
|
-
confirmMemory,
|
|
71
69
|
detectContradictions,
|
|
72
|
-
ensureEmbeddingProviderReady,
|
|
73
70
|
formatAuditTrail,
|
|
74
71
|
formatHealthReport,
|
|
75
72
|
getAuditTrail,
|
|
76
|
-
getEmbeddingModelInfo,
|
|
77
|
-
getMemory,
|
|
78
73
|
getRecentAudit,
|
|
79
74
|
getRepoQualityProfile,
|
|
80
|
-
hybridSearch,
|
|
81
75
|
inferScope,
|
|
82
76
|
listContradictions,
|
|
83
|
-
listMemories,
|
|
84
|
-
listRepos,
|
|
85
|
-
loadEmbeddingConfigFromEnv,
|
|
86
77
|
processCorrection,
|
|
87
78
|
processReviewFeedback,
|
|
79
|
+
recordAudit,
|
|
80
|
+
resolveContradiction,
|
|
81
|
+
rollbackMemory
|
|
82
|
+
} from "./chunk-BMWLHPLS.js";
|
|
83
|
+
import {
|
|
84
|
+
confirmMemory,
|
|
85
|
+
getMemory,
|
|
86
|
+
listMemories,
|
|
87
|
+
listRepos,
|
|
88
88
|
queryMemories,
|
|
89
|
+
rejectMemory
|
|
90
|
+
} from "./chunk-UBPGOOAN.js";
|
|
91
|
+
import "./chunk-37K4DPRI.js";
|
|
92
|
+
import {
|
|
93
|
+
bootstrapEmbeddings,
|
|
94
|
+
ensureEmbeddingProviderReady,
|
|
95
|
+
getEmbeddingModelInfo,
|
|
96
|
+
hybridSearch,
|
|
97
|
+
loadEmbeddingConfigFromEnv,
|
|
89
98
|
queueMemoryEmbeddingSync,
|
|
90
99
|
rebuildEmbeddingIndex,
|
|
91
|
-
recordAudit,
|
|
92
|
-
rejectMemory,
|
|
93
|
-
resolveContradiction,
|
|
94
|
-
rollbackMemory,
|
|
95
100
|
verifyEmbeddings
|
|
96
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-JRIM7VBY.js";
|
|
97
102
|
import {
|
|
103
|
+
eq,
|
|
104
|
+
gt,
|
|
98
105
|
memories,
|
|
99
106
|
syncState
|
|
100
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-QDA5M3AJ.js";
|
|
101
108
|
import {
|
|
102
109
|
init_keychain,
|
|
103
110
|
keychain_exports
|
|
@@ -113,7 +120,6 @@ import { writeFileSync as writeFileSync5, readFileSync as readFileSync5 } from "
|
|
|
113
120
|
import { join as join7 } from "path";
|
|
114
121
|
|
|
115
122
|
// src/sync/client.ts
|
|
116
|
-
import { eq, gt } from "drizzle-orm";
|
|
117
123
|
import { randomUUID } from "crypto";
|
|
118
124
|
function getSyncState(db) {
|
|
119
125
|
const row = db.select().from(syncState).where(eq(syncState.id, "local")).get();
|
|
@@ -2612,7 +2618,7 @@ program.command("compile").description("Compile active memories into injection p
|
|
|
2612
2618
|
});
|
|
2613
2619
|
program.command("correct").description("Report a correction to learn from").argument("<text>", "Correction text").option("-r, --repo <repo>", "Repository name").option("-p, --path <path>", "File path context").option("-s, --session <id>", "Session ID", "cli").action(async (text, opts) => {
|
|
2614
2620
|
const db = initDb();
|
|
2615
|
-
const ids = await processCorrection(db, text, {
|
|
2621
|
+
const { ids, pendingTaskId } = await processCorrection(db, text, {
|
|
2616
2622
|
sessionId: opts.session,
|
|
2617
2623
|
repo: opts.repo,
|
|
2618
2624
|
path: opts.path
|
|
@@ -2625,9 +2631,14 @@ program.command("correct").description("Report a correction to learn from").argu
|
|
|
2625
2631
|
event_type: "correction",
|
|
2626
2632
|
memory_ids: ids,
|
|
2627
2633
|
request: { text },
|
|
2628
|
-
result: { created: ids }
|
|
2634
|
+
result: { created: ids, pending_task_id: pendingTaskId ?? null }
|
|
2629
2635
|
});
|
|
2630
2636
|
if (ids.length === 0) {
|
|
2637
|
+
if (pendingTaskId) {
|
|
2638
|
+
console.log(`Enqueued for LLM extraction (task ${pendingTaskId.slice(0, 16)}).`);
|
|
2639
|
+
console.log("The candidate memory will appear once the dispatcher processes the prompt.");
|
|
2640
|
+
return;
|
|
2641
|
+
}
|
|
2631
2642
|
console.log("No correction pattern detected.");
|
|
2632
2643
|
console.log(
|
|
2633
2644
|
`Try: "don't use X, use Y", "always do Z", "let's use editorconfig defaults", or "review said to use W"`
|
|
@@ -3220,9 +3231,137 @@ daemonCmd.command("uninstall").description("Remove the service").option("--label
|
|
|
3220
3231
|
const status = uninstallService(opts.label);
|
|
3221
3232
|
console.log(getServiceInfo(status.label));
|
|
3222
3233
|
});
|
|
3234
|
+
var uiCmd = program.command("ui").description("Control the Recall WebUI dashboard (browser-based view of memories, graph, sessions)");
|
|
3235
|
+
uiCmd.command("start", { isDefault: true }).description("Start the WebUI and open it in your default browser").option("--port <port>", "WebUI port", "7891").option("--daemon-port <port>", "Daemon port", "7890").option("--no-open", "Do not open the browser automatically").action(async (opts) => {
|
|
3236
|
+
const daemonPort = parseInt(opts.daemonPort, 10);
|
|
3237
|
+
const webuiPort = parseInt(opts.port, 10);
|
|
3238
|
+
try {
|
|
3239
|
+
const res = await fetch(`http://localhost:${daemonPort}/webui/start`, {
|
|
3240
|
+
method: "POST",
|
|
3241
|
+
headers: { "Content-Type": "application/json" },
|
|
3242
|
+
body: JSON.stringify({ port: webuiPort, open: opts.open !== false })
|
|
3243
|
+
});
|
|
3244
|
+
const status = await res.json();
|
|
3245
|
+
if (!res.ok || !status.running) {
|
|
3246
|
+
console.error(`Failed to start WebUI: ${JSON.stringify(status)}`);
|
|
3247
|
+
process.exit(1);
|
|
3248
|
+
}
|
|
3249
|
+
console.log(`Recall WebUI: ${status.url}`);
|
|
3250
|
+
if (opts.open === false) {
|
|
3251
|
+
console.log("Open the URL in your browser to view the dashboard.");
|
|
3252
|
+
}
|
|
3253
|
+
} catch (err) {
|
|
3254
|
+
console.error(
|
|
3255
|
+
`Could not reach daemon at http://localhost:${daemonPort}. Is it running? Try \`recall daemon start\`.`
|
|
3256
|
+
);
|
|
3257
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
3258
|
+
process.exit(1);
|
|
3259
|
+
}
|
|
3260
|
+
});
|
|
3261
|
+
uiCmd.command("stop").description("Stop the WebUI listener (the browser tab stays open)").option("--daemon-port <port>", "Daemon port", "7890").action(async (opts) => {
|
|
3262
|
+
const daemonPort = parseInt(opts.daemonPort, 10);
|
|
3263
|
+
try {
|
|
3264
|
+
const res = await fetch(`http://localhost:${daemonPort}/webui/stop`, { method: "POST" });
|
|
3265
|
+
const status = await res.json();
|
|
3266
|
+
console.log(status.running ? "WebUI still running" : "WebUI stopped");
|
|
3267
|
+
} catch (err) {
|
|
3268
|
+
console.error(
|
|
3269
|
+
`Could not reach daemon at http://localhost:${daemonPort}. Is it running?`
|
|
3270
|
+
);
|
|
3271
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
3272
|
+
process.exit(1);
|
|
3273
|
+
}
|
|
3274
|
+
});
|
|
3275
|
+
uiCmd.command("status").description("Show WebUI status").option("--daemon-port <port>", "Daemon port", "7890").action(async (opts) => {
|
|
3276
|
+
const daemonPort = parseInt(opts.daemonPort, 10);
|
|
3277
|
+
try {
|
|
3278
|
+
const res = await fetch(`http://localhost:${daemonPort}/webui/status`);
|
|
3279
|
+
const status = await res.json();
|
|
3280
|
+
if (!status.running) {
|
|
3281
|
+
console.log("WebUI: stopped");
|
|
3282
|
+
if (!status.dist_exists) {
|
|
3283
|
+
console.log(`Bundle missing at ${status.dist_dir}. Run \`npm run webui:build\` once.`);
|
|
3284
|
+
}
|
|
3285
|
+
return;
|
|
3286
|
+
}
|
|
3287
|
+
console.log(`WebUI: running at ${status.url}`);
|
|
3288
|
+
console.log(`Live clients: ${status.client_count}`);
|
|
3289
|
+
if (!status.dist_exists) {
|
|
3290
|
+
console.log(`Bundle missing at ${status.dist_dir}. UI will render a fallback page.`);
|
|
3291
|
+
}
|
|
3292
|
+
} catch (err) {
|
|
3293
|
+
console.error(
|
|
3294
|
+
`Could not reach daemon at http://localhost:${daemonPort}. Is it running?`
|
|
3295
|
+
);
|
|
3296
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
3297
|
+
process.exit(1);
|
|
3298
|
+
}
|
|
3299
|
+
});
|
|
3300
|
+
var graphCmd = program.command("graph").description("Inspect and rebuild the knowledge graph (entities + relations)");
|
|
3301
|
+
graphCmd.command("stats").description("Show entity/relation counts").action(async () => {
|
|
3302
|
+
const db = initDb();
|
|
3303
|
+
const { countEntities, countRelations } = await import("./store-2BPQPOOZ.js");
|
|
3304
|
+
console.log(`entities: ${countEntities(db)}`);
|
|
3305
|
+
console.log(`relations: ${countRelations(db)}`);
|
|
3306
|
+
});
|
|
3307
|
+
graphCmd.command("backfill").description("Run the heuristic extractor over every active memory (idempotent)").option("--repo <repo>", "Limit to a single repo").option("--limit <n>", "Cap rows processed", "10000").action(async (opts) => {
|
|
3308
|
+
const db = initDb();
|
|
3309
|
+
const { ingestMemoryHeuristic } = await import("./ingest-JWXX22QX.js");
|
|
3310
|
+
const rows = queryMemories(db, {
|
|
3311
|
+
repo: opts.repo,
|
|
3312
|
+
status: "active",
|
|
3313
|
+
limit: parseInt(opts.limit, 10)
|
|
3314
|
+
});
|
|
3315
|
+
let totalEntities = 0;
|
|
3316
|
+
let totalRelations = 0;
|
|
3317
|
+
for (const row of rows) {
|
|
3318
|
+
const s = ingestMemoryHeuristic(db, { id: row.id, text: row.text, repo: row.repo });
|
|
3319
|
+
totalEntities += s.entities_created_or_updated;
|
|
3320
|
+
totalRelations += s.relations_created_or_updated;
|
|
3321
|
+
}
|
|
3322
|
+
console.log(
|
|
3323
|
+
`Processed ${rows.length} memories \u2014 entity touches: ${totalEntities}, relation touches: ${totalRelations}`
|
|
3324
|
+
);
|
|
3325
|
+
});
|
|
3326
|
+
graphCmd.command("entities").description("List entities").option("--repo <repo>", "Filter by repo").option("--kind <kind>", "Filter by entity kind").option("--search <q>", "Substring filter on name").option("--limit <n>", "Max rows", "50").action(async (opts) => {
|
|
3327
|
+
const db = initDb();
|
|
3328
|
+
const { listEntities } = await import("./store-2BPQPOOZ.js");
|
|
3329
|
+
const rows = listEntities(db, {
|
|
3330
|
+
repo: opts.repo,
|
|
3331
|
+
kind: opts.kind,
|
|
3332
|
+
search: opts.search,
|
|
3333
|
+
limit: parseInt(opts.limit, 10)
|
|
3334
|
+
});
|
|
3335
|
+
if (rows.length === 0) {
|
|
3336
|
+
console.log("(no entities)");
|
|
3337
|
+
return;
|
|
3338
|
+
}
|
|
3339
|
+
for (const r of rows) {
|
|
3340
|
+
console.log(
|
|
3341
|
+
`${r.mention_count.toString().padStart(4)} ${r.kind.padEnd(10)} ${r.name} ${r.repo ?? ""}`
|
|
3342
|
+
);
|
|
3343
|
+
}
|
|
3344
|
+
});
|
|
3345
|
+
graphCmd.command("query <query...>").description("Run graph-aware retrieval for a query").option("--repo <repo>", "Restrict to repo").option("--hops <n>", "Graph hops", "2").option("--limit <n>", "Max hits", "10").action(async (queryTokens, opts) => {
|
|
3346
|
+
const db = initDb();
|
|
3347
|
+
const { graphQuery } = await import("./retrieval-GLAEYWGA.js");
|
|
3348
|
+
const { loadEmbeddingConfigFromEnv: loadEmbeddingConfigFromEnv2 } = await import("./embeddings-GKNH2E3N.js");
|
|
3349
|
+
const embeddingConfig = loadEmbeddingConfigFromEnv2();
|
|
3350
|
+
const result = await graphQuery(db, queryTokens.join(" "), embeddingConfig, {
|
|
3351
|
+
repo: opts.repo,
|
|
3352
|
+
hops: parseInt(opts.hops, 10),
|
|
3353
|
+
limit: parseInt(opts.limit, 10)
|
|
3354
|
+
});
|
|
3355
|
+
console.log(`seeds=${result.seed_count} expanded_entities=${result.expanded_entities}`);
|
|
3356
|
+
for (const h of result.hits) {
|
|
3357
|
+
console.log(
|
|
3358
|
+
`[${h.via}${h.hops}] score=${h.score.toFixed(3)} ${h.memory.id.slice(0, 8)} ${h.memory.text.slice(0, 100)}`
|
|
3359
|
+
);
|
|
3360
|
+
}
|
|
3361
|
+
});
|
|
3223
3362
|
var maintenanceCmd = program.command("maintenance").description("Inspect and manage the delegated maintenance task queue");
|
|
3224
3363
|
maintenanceCmd.command("stats").description("Show backlog counts, completion stats, and mean latency").action(async () => {
|
|
3225
|
-
const { getTaskStats } = await import("./tasks-
|
|
3364
|
+
const { getTaskStats } = await import("./tasks-GJBURDAB.js");
|
|
3226
3365
|
const db = initDb();
|
|
3227
3366
|
const stats = getTaskStats(db);
|
|
3228
3367
|
console.log(`Total tasks: ${stats.total}`);
|
|
@@ -3248,7 +3387,7 @@ maintenanceCmd.command("stats").description("Show backlog counts, completion sta
|
|
|
3248
3387
|
}
|
|
3249
3388
|
});
|
|
3250
3389
|
maintenanceCmd.command("list").description("List tasks (default: pending)").option("-s, --status <status>", "pending|claimed|completed|abandoned", "pending").option("-k, --kind <kind>", "Filter by kind").option("-r, --repo <repo>", "Filter by repo").option("-n, --limit <n>", "Max entries", "20").action(async (opts) => {
|
|
3251
|
-
const { listTasks } = await import("./tasks-
|
|
3390
|
+
const { listTasks } = await import("./tasks-GJBURDAB.js");
|
|
3252
3391
|
const db = initDb();
|
|
3253
3392
|
const tasks = listTasks(db, {
|
|
3254
3393
|
status: opts.status,
|
|
@@ -3270,7 +3409,7 @@ maintenanceCmd.command("list").description("List tasks (default: pending)").opti
|
|
|
3270
3409
|
}
|
|
3271
3410
|
});
|
|
3272
3411
|
maintenanceCmd.command("drop").description("Delete a task by id (or id prefix)").argument("<task-id>", "Task id or prefix").action(async (taskIdArg) => {
|
|
3273
|
-
const { deleteTask, listTasks } = await import("./tasks-
|
|
3412
|
+
const { deleteTask, listTasks } = await import("./tasks-GJBURDAB.js");
|
|
3274
3413
|
const db = initDb();
|
|
3275
3414
|
const all = listTasks(db, { limit: 1e4 });
|
|
3276
3415
|
const matches = all.filter((t) => t.id === taskIdArg || t.id.startsWith(taskIdArg));
|
|
@@ -3376,8 +3515,8 @@ credentialsCmd.command("clear").description("Remove provider credentials from th
|
|
|
3376
3515
|
else console.log(`No ${provider} credentials found in Keychain.`);
|
|
3377
3516
|
});
|
|
3378
3517
|
maintenanceCmd.command("dispatch").description("Run the daemon-owned dispatcher once against pending maintenance tasks (requires a configured LLM provider)").option("--provider <provider>", "openai|anthropic|azure-openai (defaults to whichever is configured)").option("--model <model>", "Model override").option("--kind <kind>", "Restrict to a single task kind (repeatable)", (value, acc = []) => [...acc, value], []).option("--repo <repo>", "Restrict to a single repo").option("--max <n>", "Max tasks to run this round", "5").option("--dry-run", "Show which tasks would be dispatched; do not call the LLM").option("--preview", "Show the actual prompts that would be sent (no provider needed; no LLM call)").option("--json", "Emit the raw JSON report").action(async (opts) => {
|
|
3379
|
-
const { dispatchPendingTasks, formatDispatchReport, buildPrompt } = await import("./dispatcher-
|
|
3380
|
-
const { listTasks } = await import("./tasks-
|
|
3518
|
+
const { dispatchPendingTasks, formatDispatchReport, buildPrompt } = await import("./dispatcher-Z4GEFOQG.js");
|
|
3519
|
+
const { listTasks } = await import("./tasks-GJBURDAB.js");
|
|
3381
3520
|
const db = initDb();
|
|
3382
3521
|
if (opts.preview) {
|
|
3383
3522
|
const pending = listTasks(db, {
|
|
@@ -3434,7 +3573,7 @@ ${p.prompt.max_output_tokens}
|
|
|
3434
3573
|
console.log(formatDispatchReport(report));
|
|
3435
3574
|
});
|
|
3436
3575
|
maintenanceCmd.command("cleanup").description("Run deterministic, LLM-free cleanup: exact-text dedupe, fragment rejection, repeat-correction promotion").option("--apply", "Persist changes (default is dry-run)").option("--only <action>", "Restrict to one action: dedupe_exact_merge|reject_fragment_candidate|promote_repeat_correction").option("--revert <run-id>", "Revert a previous cleanup run (id or 8-char prefix)").option("--list", "List recent cleanup runs").option("--json", "Emit the raw JSON report").action(async (opts) => {
|
|
3437
|
-
const { runDeterministicCleanup, formatCleanupReport, revertCleanupRun, listCleanupRuns } = await import("./cleanup-
|
|
3576
|
+
const { runDeterministicCleanup, formatCleanupReport, revertCleanupRun, listCleanupRuns } = await import("./cleanup-2HK2TX7Q.js");
|
|
3438
3577
|
const db = initDb();
|
|
3439
3578
|
if (opts.list) {
|
|
3440
3579
|
const runs = listCleanupRuns(db);
|
|
@@ -3488,7 +3627,7 @@ maintenanceCmd.command("quality").description("Show injection outcome distributi
|
|
|
3488
3627
|
recordQualitySnapshot,
|
|
3489
3628
|
listQualitySnapshots,
|
|
3490
3629
|
diffQualitySnapshots
|
|
3491
|
-
} = await import("./quality-
|
|
3630
|
+
} = await import("./quality-2JOLSIC3.js");
|
|
3492
3631
|
const db = initDb();
|
|
3493
3632
|
if (opts.history) {
|
|
3494
3633
|
const snaps = listQualitySnapshots(db);
|
|
@@ -3538,7 +3677,7 @@ maintenanceCmd.command("quality").description("Show injection outcome distributi
|
|
|
3538
3677
|
console.log(formatQualityReport(report));
|
|
3539
3678
|
});
|
|
3540
3679
|
maintenanceCmd.command("usage").description("Summarize LLM API usage (tokens, cost) across recent maintenance runs").option("--since <iso>", "Window start (default: last 30 days)").option("--limit <n>", "Recent-call rows to show", "10").option("--json", "Emit raw JSON summary").action(async (opts) => {
|
|
3541
|
-
const { summarizeUsage, formatUsageReport } = await import("./usage-
|
|
3680
|
+
const { summarizeUsage, formatUsageReport } = await import("./usage-YBS74UEU.js");
|
|
3542
3681
|
const db = initDb();
|
|
3543
3682
|
const summary = summarizeUsage(db, {
|
|
3544
3683
|
sinceIso: opts.since,
|