@edihasaj/recall 2.0.8 → 2.0.10
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/dist/{chunk-RSBIISGE.js → chunk-2HTE5YCD.js} +5 -5
- package/dist/{chunk-PW42PFVO.js → chunk-452CBEMK.js} +7 -7
- package/dist/{chunk-4LTGMFHN.js → chunk-5BINFOTB.js} +3 -3
- package/dist/{chunk-HYDNV5T2.js → chunk-6CNPKVFS.js} +10 -10
- package/dist/{chunk-VV2QPDAM.js → chunk-7OUMLNMS.js} +2 -2
- package/dist/{chunk-VV2QPDAM.js.map → chunk-7OUMLNMS.js.map} +1 -1
- package/dist/{chunk-LOWPEB72.js → chunk-7XERG2KZ.js} +3 -3
- package/dist/{chunk-N2ONUBXR.js → chunk-CLQYFL23.js} +9 -9
- package/dist/{chunk-OHWHU653.js → chunk-MR27BZJI.js} +13 -13
- package/dist/{chunk-URQEUH7T.js → chunk-NHVAJ65F.js} +3 -3
- package/dist/{chunk-MD2LUEVD.js → chunk-OHYZAY32.js} +9 -9
- package/dist/{chunk-QOMNHKYE.js → chunk-Q73UNU65.js} +2 -2
- package/dist/{chunk-3ZA4YOFN.js → chunk-QBGL65RB.js} +5 -5
- package/dist/{chunk-6U7YMPBE.js → chunk-SQLOLEB4.js} +2 -2
- package/dist/{chunk-3LL5S473.js → chunk-UINNMPRU.js} +2 -2
- package/dist/{chunk-BOUMOPKD.js → chunk-X72XQAXI.js} +2 -2
- package/dist/{chunk-QKGE74LD.js → chunk-XW7UG26X.js} +16 -5
- package/dist/chunk-XW7UG26X.js.map +1 -0
- package/dist/{chunk-J3F3CLWL.js → chunk-Y777IVJL.js} +22 -16
- package/dist/chunk-Y777IVJL.js.map +1 -0
- package/dist/{chunk-JSKYG7TC.js → chunk-ZFRBDRLV.js} +2 -2
- package/dist/{cleanup-QC7EHMUB.js → cleanup-MGE4SH7X.js} +11 -11
- package/dist/cli.js +667 -124
- package/dist/cli.js.map +1 -1
- package/dist/{codex-trust-4RI6LCAI.js → codex-trust-55ECVIEG.js} +4 -4
- package/dist/daemon.js +18 -18
- package/dist/dispatcher-5GGXB7QB.js +22 -0
- package/dist/{embeddings-RS3GK3TS.js → embeddings-RNT3VZ3N.js} +5 -5
- package/dist/ingest-IYVKCX2V.js +20 -0
- package/dist/{keychain-BRWB5CL5.js → keychain-AISDPFDE.js} +3 -3
- package/dist/mcp.js +15 -15
- package/dist/{memory-value-6KDRPDXE.js → memory-value-REBCJWHS.js} +11 -11
- package/dist/{provenance-NLVTH5ZK.js → provenance-HWX3SR5M.js} +9 -9
- package/dist/quality-5BFTWSRU.js +25 -0
- package/dist/retrieval-IBGAA6Y2.js +15 -0
- package/dist/{store-DXJJ7VOQ.js → store-CVQY5QVT.js} +4 -4
- package/dist/sync-server.js +2 -2
- package/dist/{tasks-32RY4KNA.js → tasks-UWUCCJL6.js} +11 -11
- package/dist/{usage-3EMXD6MZ.js → usage-QLQPIDA5.js} +4 -4
- package/package.json +2 -2
- package/dist/chunk-J3F3CLWL.js.map +0 -1
- package/dist/chunk-QKGE74LD.js.map +0 -1
- package/dist/dispatcher-XGATH6Q5.js +0 -22
- package/dist/ingest-RGPV5QYT.js +0 -20
- package/dist/quality-QPRUXM4B.js +0 -25
- package/dist/retrieval-N5FQRL2V.js +0 -15
- /package/dist/{chunk-RSBIISGE.js.map → chunk-2HTE5YCD.js.map} +0 -0
- /package/dist/{chunk-PW42PFVO.js.map → chunk-452CBEMK.js.map} +0 -0
- /package/dist/{chunk-4LTGMFHN.js.map → chunk-5BINFOTB.js.map} +0 -0
- /package/dist/{chunk-HYDNV5T2.js.map → chunk-6CNPKVFS.js.map} +0 -0
- /package/dist/{chunk-LOWPEB72.js.map → chunk-7XERG2KZ.js.map} +0 -0
- /package/dist/{chunk-N2ONUBXR.js.map → chunk-CLQYFL23.js.map} +0 -0
- /package/dist/{chunk-OHWHU653.js.map → chunk-MR27BZJI.js.map} +0 -0
- /package/dist/{chunk-URQEUH7T.js.map → chunk-NHVAJ65F.js.map} +0 -0
- /package/dist/{chunk-MD2LUEVD.js.map → chunk-OHYZAY32.js.map} +0 -0
- /package/dist/{chunk-QOMNHKYE.js.map → chunk-Q73UNU65.js.map} +0 -0
- /package/dist/{chunk-3ZA4YOFN.js.map → chunk-QBGL65RB.js.map} +0 -0
- /package/dist/{chunk-6U7YMPBE.js.map → chunk-SQLOLEB4.js.map} +0 -0
- /package/dist/{chunk-3LL5S473.js.map → chunk-UINNMPRU.js.map} +0 -0
- /package/dist/{chunk-BOUMOPKD.js.map → chunk-X72XQAXI.js.map} +0 -0
- /package/dist/{chunk-JSKYG7TC.js.map → chunk-ZFRBDRLV.js.map} +0 -0
- /package/dist/{cleanup-QC7EHMUB.js.map → cleanup-MGE4SH7X.js.map} +0 -0
- /package/dist/{codex-trust-4RI6LCAI.js.map → codex-trust-55ECVIEG.js.map} +0 -0
- /package/dist/{dispatcher-XGATH6Q5.js.map → dispatcher-5GGXB7QB.js.map} +0 -0
- /package/dist/{embeddings-RS3GK3TS.js.map → embeddings-RNT3VZ3N.js.map} +0 -0
- /package/dist/{ingest-RGPV5QYT.js.map → ingest-IYVKCX2V.js.map} +0 -0
- /package/dist/{keychain-BRWB5CL5.js.map → keychain-AISDPFDE.js.map} +0 -0
- /package/dist/{memory-value-6KDRPDXE.js.map → memory-value-REBCJWHS.js.map} +0 -0
- /package/dist/{provenance-NLVTH5ZK.js.map → provenance-HWX3SR5M.js.map} +0 -0
- /package/dist/{quality-QPRUXM4B.js.map → quality-5BFTWSRU.js.map} +0 -0
- /package/dist/{retrieval-N5FQRL2V.js.map → retrieval-IBGAA6Y2.js.map} +0 -0
- /package/dist/{store-DXJJ7VOQ.js.map → store-CVQY5QVT.js.map} +0 -0
- /package/dist/{tasks-32RY4KNA.js.map → tasks-UWUCCJL6.js.map} +0 -0
- /package/dist/{usage-3EMXD6MZ.js.map → usage-QLQPIDA5.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -55,14 +55,14 @@ import {
|
|
|
55
55
|
unregisterStrayApps,
|
|
56
56
|
verifyBackupIntegrity,
|
|
57
57
|
writeRepoContextArtifact
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-MR27BZJI.js";
|
|
59
59
|
import {
|
|
60
60
|
hasCommand,
|
|
61
61
|
installCodexHooks,
|
|
62
62
|
resolveCodexHookTargets,
|
|
63
63
|
resolveUserHomeDir,
|
|
64
64
|
uninstallCodexHooks
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-5BINFOTB.js";
|
|
66
66
|
import {
|
|
67
67
|
closeDb,
|
|
68
68
|
compileContext,
|
|
@@ -105,7 +105,7 @@ import {
|
|
|
105
105
|
startEvalSession,
|
|
106
106
|
summarizeValueRetrievalEval,
|
|
107
107
|
togglePolicy
|
|
108
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-6CNPKVFS.js";
|
|
109
109
|
import {
|
|
110
110
|
autoResolveContradictions,
|
|
111
111
|
computeAllHealthScores,
|
|
@@ -120,10 +120,10 @@ import {
|
|
|
120
120
|
processCorrection,
|
|
121
121
|
processReviewFeedback,
|
|
122
122
|
resolveContradiction
|
|
123
|
-
} from "./chunk-
|
|
124
|
-
import "./chunk-
|
|
125
|
-
import "./chunk-
|
|
126
|
-
import "./chunk-
|
|
123
|
+
} from "./chunk-OHYZAY32.js";
|
|
124
|
+
import "./chunk-452CBEMK.js";
|
|
125
|
+
import "./chunk-UINNMPRU.js";
|
|
126
|
+
import "./chunk-ZFRBDRLV.js";
|
|
127
127
|
import {
|
|
128
128
|
confirmMemory,
|
|
129
129
|
createMemory,
|
|
@@ -139,11 +139,11 @@ import {
|
|
|
139
139
|
recordAuditWithSnapshot,
|
|
140
140
|
rejectMemory,
|
|
141
141
|
rollbackMemory
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-Y777IVJL.js";
|
|
143
143
|
import {
|
|
144
144
|
desc
|
|
145
|
-
} from "./chunk-
|
|
146
|
-
import "./chunk-
|
|
145
|
+
} from "./chunk-NHVAJ65F.js";
|
|
146
|
+
import "./chunk-SQLOLEB4.js";
|
|
147
147
|
import {
|
|
148
148
|
CONFIDENCE,
|
|
149
149
|
bootstrapEmbeddings,
|
|
@@ -156,48 +156,351 @@ import {
|
|
|
156
156
|
rebuildEmbeddingIndex,
|
|
157
157
|
searchMemoryFtsIndex,
|
|
158
158
|
semanticSearch,
|
|
159
|
+
upsertMemoryFtsRow,
|
|
159
160
|
verifyEmbeddings
|
|
160
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-XW7UG26X.js";
|
|
161
162
|
import {
|
|
162
163
|
deleteApiKey,
|
|
163
164
|
hasKeychainApiKey,
|
|
164
165
|
init_keychain,
|
|
165
166
|
init_outbound_url,
|
|
166
167
|
normalizeSyncRemoteUrl
|
|
167
|
-
} from "./chunk-
|
|
168
|
-
import "./chunk-
|
|
168
|
+
} from "./chunk-Q73UNU65.js";
|
|
169
|
+
import "./chunk-7XERG2KZ.js";
|
|
169
170
|
import {
|
|
171
|
+
and,
|
|
170
172
|
auditTrail,
|
|
171
173
|
eq,
|
|
172
174
|
gt,
|
|
173
175
|
memories,
|
|
174
176
|
sql,
|
|
175
177
|
syncState
|
|
176
|
-
} from "./chunk-
|
|
178
|
+
} from "./chunk-X72XQAXI.js";
|
|
177
179
|
import {
|
|
178
180
|
init_define_RECALL_BUILD_INFO
|
|
179
|
-
} from "./chunk-
|
|
181
|
+
} from "./chunk-7OUMLNMS.js";
|
|
180
182
|
|
|
181
183
|
// src/cli.ts
|
|
182
184
|
init_define_RECALL_BUILD_INFO();
|
|
183
185
|
import { Command } from "commander";
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
|
|
187
|
+
// src/cli/harness2.ts
|
|
188
|
+
init_define_RECALL_BUILD_INFO();
|
|
189
|
+
|
|
190
|
+
// src/importers/harness2.ts
|
|
191
|
+
init_define_RECALL_BUILD_INFO();
|
|
192
|
+
import { createHash } from "crypto";
|
|
193
|
+
import {
|
|
194
|
+
closeSync,
|
|
195
|
+
constants,
|
|
196
|
+
fstatSync,
|
|
197
|
+
openSync,
|
|
198
|
+
readSync
|
|
199
|
+
} from "fs";
|
|
200
|
+
import { resolve } from "path";
|
|
201
|
+
var MAX_DOCUMENT_BYTES = 128 * 1024;
|
|
202
|
+
var MAX_DOCUMENT_CODEPOINTS = 2e4;
|
|
203
|
+
var MAX_REPO_LENGTH = 255;
|
|
204
|
+
var MAX_SOURCE_REF_LENGTH = 2e3;
|
|
205
|
+
var HARNESS2_DEDUPE_PREFIX = "harness2sha256:";
|
|
206
|
+
function normalizeHarness2Experience(text) {
|
|
207
|
+
return text.replace(/^\uFEFF/u, "").replace(/\r\n?|\n/g, "\n").trim();
|
|
208
|
+
}
|
|
209
|
+
function previewHarness2Experience(text, options) {
|
|
210
|
+
const repo = validateRepo(options.repo);
|
|
211
|
+
const sourceRef = validateSourceRef(options.sourceRef);
|
|
212
|
+
validateRawDocument(text);
|
|
213
|
+
const content = normalizeHarness2Experience(text);
|
|
214
|
+
validateDocument(content);
|
|
215
|
+
const digest = sha256(`${repo}
|
|
216
|
+
${content}`);
|
|
217
|
+
const id = uuidFromDigest(digest);
|
|
218
|
+
const cloudImport = {
|
|
219
|
+
provider: "harness2",
|
|
220
|
+
project: repo,
|
|
221
|
+
content,
|
|
222
|
+
sourceRef
|
|
223
|
+
};
|
|
224
|
+
return {
|
|
225
|
+
...cloudImport,
|
|
226
|
+
digest,
|
|
227
|
+
id,
|
|
228
|
+
candidate: {
|
|
229
|
+
type: "gotcha",
|
|
230
|
+
scope: "repo",
|
|
231
|
+
status: "candidate",
|
|
232
|
+
confidence: 0.4,
|
|
233
|
+
source: "tool_outcome",
|
|
234
|
+
autoInject: false
|
|
235
|
+
},
|
|
236
|
+
cloudImport
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function readHarness2Experience(file, options) {
|
|
240
|
+
const sourceRef = options.sourceRef ?? resolve(file);
|
|
241
|
+
validateSourceRef(sourceRef);
|
|
242
|
+
const flags = constants.O_RDONLY | constants.O_NONBLOCK | constants.O_NOFOLLOW;
|
|
243
|
+
let fd;
|
|
244
|
+
try {
|
|
245
|
+
fd = openSync(file, flags);
|
|
246
|
+
const stat = fstatSync(fd);
|
|
247
|
+
if (!stat.isFile()) throw new Error("Harness2 import requires a regular file.");
|
|
248
|
+
if (stat.size > MAX_DOCUMENT_BYTES) {
|
|
249
|
+
throw new Error(`Harness2 EXPERIENCE.md exceeds ${MAX_DOCUMENT_BYTES} bytes.`);
|
|
250
|
+
}
|
|
251
|
+
const buffer = Buffer.alloc(stat.size);
|
|
252
|
+
let offset = 0;
|
|
253
|
+
while (offset < buffer.length) {
|
|
254
|
+
const count = readSync(fd, buffer, offset, buffer.length - offset, offset);
|
|
255
|
+
if (count === 0) break;
|
|
256
|
+
offset += count;
|
|
257
|
+
}
|
|
258
|
+
if (offset !== stat.size) throw new Error("Harness2 EXPERIENCE.md changed while it was read.");
|
|
259
|
+
let text;
|
|
260
|
+
try {
|
|
261
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(buffer);
|
|
262
|
+
} catch {
|
|
263
|
+
throw new Error("Harness2 EXPERIENCE.md must be valid UTF-8.");
|
|
264
|
+
}
|
|
265
|
+
return previewHarness2Experience(text, { ...options, sourceRef });
|
|
266
|
+
} finally {
|
|
267
|
+
if (fd !== void 0) closeSync(fd);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function importHarness2Experience(db, preview) {
|
|
271
|
+
assertPreviewIntegrity(preview);
|
|
272
|
+
const { created, memory } = db.$client.transaction(() => {
|
|
273
|
+
const existing = db.select().from(memories).where(eq(memories.id, preview.id)).get();
|
|
274
|
+
if (existing) return { created: false, memory: existing };
|
|
275
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
276
|
+
const sourceFile = preview.sourceRef ?? "EXPERIENCE.md";
|
|
277
|
+
const generatedContext = `<agent-response> experimental Harness2 EXPERIENCE.md import; sourceRef=${sourceFile}; sha256=${preview.digest}`;
|
|
278
|
+
db.insert(memories).values({
|
|
279
|
+
id: preview.id,
|
|
280
|
+
type: "gotcha",
|
|
281
|
+
text: preview.content,
|
|
282
|
+
scope: "repo",
|
|
283
|
+
path_scope: null,
|
|
284
|
+
repo: preview.project,
|
|
285
|
+
status: "candidate",
|
|
286
|
+
confidence: 0.4,
|
|
287
|
+
source: "tool_outcome",
|
|
288
|
+
evidence: [
|
|
289
|
+
{
|
|
290
|
+
type: "review_feedback",
|
|
291
|
+
reported_by_user: false,
|
|
292
|
+
reviewer: "harness2",
|
|
293
|
+
timestamp: now,
|
|
294
|
+
context: generatedContext
|
|
295
|
+
},
|
|
296
|
+
{ type: "repo_scan", file: sourceFile, timestamp: now }
|
|
297
|
+
],
|
|
298
|
+
capture_context: null,
|
|
299
|
+
note: null,
|
|
300
|
+
supersedes: null,
|
|
301
|
+
dedupe_key: `${HARNESS2_DEDUPE_PREFIX}${preview.digest}`,
|
|
302
|
+
created_at: now,
|
|
303
|
+
updated_at: now,
|
|
304
|
+
last_validated_at: null,
|
|
305
|
+
last_injected_at: null,
|
|
306
|
+
injection_count: 0,
|
|
307
|
+
override_count: 0,
|
|
308
|
+
repetition_count: 0,
|
|
309
|
+
auto_inject: false
|
|
310
|
+
}).run();
|
|
311
|
+
const inserted = db.select().from(memories).where(and(
|
|
312
|
+
eq(memories.id, preview.id),
|
|
313
|
+
eq(memories.repo, preview.project)
|
|
314
|
+
)).get();
|
|
315
|
+
if (!inserted) throw new Error("Harness2 import did not retain its inserted candidate.");
|
|
316
|
+
upsertMemoryFtsRow(db, inserted);
|
|
317
|
+
recordAudit(db, preview.id, "created", "harness2", "imported EXPERIENCE.md");
|
|
318
|
+
return { created: true, memory: inserted };
|
|
319
|
+
}).immediate();
|
|
320
|
+
return { id: memory.id, created, memory, preview };
|
|
321
|
+
}
|
|
322
|
+
function validateRepo(value) {
|
|
323
|
+
const repo = value?.trim();
|
|
324
|
+
if (!repo) throw new Error("Harness2 import requires --repo.");
|
|
325
|
+
if (codePointLength(repo) > MAX_REPO_LENGTH) {
|
|
326
|
+
throw new Error(`Harness2 repo must be at most ${MAX_REPO_LENGTH} characters.`);
|
|
327
|
+
}
|
|
328
|
+
if (repo.includes("\0")) throw new Error("Harness2 repo must not contain NUL.");
|
|
329
|
+
if (/[\r\n]/u.test(repo)) throw new Error("Harness2 repo must be a single line.");
|
|
330
|
+
return repo;
|
|
331
|
+
}
|
|
332
|
+
function validateSourceRef(value) {
|
|
333
|
+
if (value == null) return null;
|
|
334
|
+
const sourceRef = value.trim();
|
|
335
|
+
if (!sourceRef) return null;
|
|
336
|
+
if (codePointLength(sourceRef) > MAX_SOURCE_REF_LENGTH) {
|
|
337
|
+
throw new Error(`Harness2 sourceRef must be at most ${MAX_SOURCE_REF_LENGTH} characters.`);
|
|
338
|
+
}
|
|
339
|
+
if (sourceRef.includes("\0")) throw new Error("Harness2 sourceRef must not contain NUL.");
|
|
340
|
+
return sourceRef;
|
|
341
|
+
}
|
|
342
|
+
function validateDocument(content) {
|
|
343
|
+
if (!content) throw new Error("Harness2 EXPERIENCE.md must not be empty.");
|
|
344
|
+
if (content.includes("\0")) throw new Error("Harness2 EXPERIENCE.md must not contain NUL.");
|
|
345
|
+
if (codePointLength(content) > MAX_DOCUMENT_CODEPOINTS) {
|
|
346
|
+
throw new Error(`Harness2 EXPERIENCE.md must be at most ${MAX_DOCUMENT_CODEPOINTS} Unicode code points.`);
|
|
347
|
+
}
|
|
348
|
+
if (Buffer.byteLength(content, "utf8") > MAX_DOCUMENT_BYTES) {
|
|
349
|
+
throw new Error(`Harness2 EXPERIENCE.md exceeds ${MAX_DOCUMENT_BYTES} bytes.`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function validateRawDocument(text) {
|
|
353
|
+
if (text.includes("\0")) throw new Error("Harness2 EXPERIENCE.md must not contain NUL.");
|
|
354
|
+
if (Buffer.byteLength(text, "utf8") > MAX_DOCUMENT_BYTES) {
|
|
355
|
+
throw new Error(`Harness2 EXPERIENCE.md exceeds ${MAX_DOCUMENT_BYTES} bytes.`);
|
|
356
|
+
}
|
|
357
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
358
|
+
const unit = text.charCodeAt(index);
|
|
359
|
+
if (unit >= 55296 && unit <= 56319) {
|
|
360
|
+
const next = text.charCodeAt(index + 1);
|
|
361
|
+
if (next >= 56320 && next <= 57343) {
|
|
362
|
+
index += 1;
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
throw new Error("Harness2 EXPERIENCE.md must not contain an unpaired UTF-16 surrogate.");
|
|
366
|
+
}
|
|
367
|
+
if (unit >= 56320 && unit <= 57343) {
|
|
368
|
+
throw new Error("Harness2 EXPERIENCE.md must not contain an unpaired UTF-16 surrogate.");
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
function assertPreviewIntegrity(preview) {
|
|
373
|
+
const expected = previewHarness2Experience(preview.content, {
|
|
374
|
+
repo: preview.project,
|
|
375
|
+
sourceRef: preview.sourceRef ?? void 0
|
|
376
|
+
});
|
|
377
|
+
if (preview.digest !== expected.digest || preview.id !== expected.id) {
|
|
378
|
+
throw new Error("Harness2 preview digest does not match its content.");
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function sha256(value) {
|
|
382
|
+
return createHash("sha256").update(value, "utf8").digest("hex");
|
|
383
|
+
}
|
|
384
|
+
function uuidFromDigest(digest) {
|
|
385
|
+
const bytes = Buffer.from(digest.slice(0, 32), "hex");
|
|
386
|
+
bytes[6] = bytes[6] & 15 | 80;
|
|
387
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
388
|
+
const hex = bytes.toString("hex");
|
|
389
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
390
|
+
}
|
|
391
|
+
function codePointLength(value) {
|
|
392
|
+
return Array.from(value).length;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// src/cli/harness2.ts
|
|
396
|
+
function registerHarness2Commands(program2) {
|
|
397
|
+
const harness2 = program2.command("harness2").description("Import experimental Harness2 experience documents");
|
|
398
|
+
harness2.command("import <file>").description("Preview or import one Harness2 EXPERIENCE.md document").requiredOption("--repo <slug>", "Repository slug for the candidate").option("--source-ref <ref>", "Optional original Harness2 source reference").option("--apply", "Write the candidate after previewing it").option("--json", "Emit a cloud-import compatible JSON payload").action((file, options) => {
|
|
399
|
+
const preview = readHarness2Experience(file, {
|
|
400
|
+
repo: options.repo,
|
|
401
|
+
sourceRef: options.sourceRef
|
|
402
|
+
});
|
|
403
|
+
const result = options.apply ? importHarness2Experience(initDb(), preview) : void 0;
|
|
404
|
+
if (options.json) {
|
|
405
|
+
console.log(JSON.stringify({
|
|
406
|
+
applied: Boolean(options.apply),
|
|
407
|
+
created: result?.created ?? false,
|
|
408
|
+
preview,
|
|
409
|
+
memory: result?.memory ?? null,
|
|
410
|
+
cloudImport: preview.cloudImport
|
|
411
|
+
}, null, 2));
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const memory = result?.memory;
|
|
415
|
+
const verb = options.apply ? result.created ? "Imported" : "Already imported" : "Preview";
|
|
416
|
+
console.log(`${verb} Harness2 candidate: ${memory?.id ?? preview.id}`);
|
|
417
|
+
console.log(` repo: ${memory?.repo ?? preview.project}`);
|
|
418
|
+
console.log(` digest: ${preview.digest}`);
|
|
419
|
+
if (memory) {
|
|
420
|
+
console.log(` status: ${memory.status} (confidence ${memory.confidence.toFixed(2)}, auto-inject ${memory.auto_inject ? "on" : "off"})`);
|
|
421
|
+
} else {
|
|
422
|
+
console.log(` status: preview candidate (confidence 0.40, auto-inject off)`);
|
|
423
|
+
}
|
|
424
|
+
console.log(` content: ${preview.content.slice(0, 160)}${preview.content.length > 160 ? "\u2026" : ""}`);
|
|
425
|
+
if (!options.apply) {
|
|
426
|
+
console.log(`
|
|
427
|
+
To import: recall harness2 import ${JSON.stringify(file)} --repo ${JSON.stringify(preview.project)} --apply`);
|
|
428
|
+
}
|
|
429
|
+
if (memory?.status === "candidate") {
|
|
430
|
+
console.log(`To confirm after review: recall confirm ${memory.id}`);
|
|
431
|
+
} else if (memory?.status === "rejected") {
|
|
432
|
+
console.log(`This retained import is rejected. To review it again: recall reactivate ${memory.id}`);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// src/cli.ts
|
|
438
|
+
import { resolve as resolve4 } from "path";
|
|
439
|
+
import { writeFileSync, readFileSync as readFileSync3, realpathSync } from "fs";
|
|
440
|
+
import { join as join5 } from "path";
|
|
187
441
|
|
|
188
442
|
// src/ump/serve.ts
|
|
189
443
|
init_define_RECALL_BUILD_INFO();
|
|
190
444
|
import {
|
|
191
445
|
UmpServer,
|
|
192
|
-
generateKeyPair,
|
|
193
446
|
createHttpServer,
|
|
194
447
|
createMcpServer
|
|
195
448
|
} from "@universalmemoryprotocol/core";
|
|
196
|
-
import { RecallStore, fromAmpId } from "@universalmemoryprotocol/core/adapters/recall";
|
|
449
|
+
import { RecallStore, fromAmpId as fromAmpId2 } from "@universalmemoryprotocol/core/adapters/recall";
|
|
197
450
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
198
451
|
|
|
199
452
|
// src/ump/backend.ts
|
|
200
453
|
init_define_RECALL_BUILD_INFO();
|
|
454
|
+
import {
|
|
455
|
+
fromAmpId,
|
|
456
|
+
kindToRecallType,
|
|
457
|
+
recallMemoryToRecord,
|
|
458
|
+
toUmpId
|
|
459
|
+
} from "@universalmemoryprotocol/core/adapters/recall";
|
|
460
|
+
|
|
461
|
+
// src/ump/records.ts
|
|
462
|
+
init_define_RECALL_BUILD_INFO();
|
|
463
|
+
function storedUmpRecord(value) {
|
|
464
|
+
if (!value || typeof value !== "object") return void 0;
|
|
465
|
+
const record = value;
|
|
466
|
+
if (record.ump !== "1.0" || typeof record.id !== "string" || typeof record.kind !== "string" || !record.body || typeof record.body.text !== "string" || !record.scope || typeof record.scope.owner !== "string" || !record.time || typeof record.time.created !== "string") {
|
|
467
|
+
return void 0;
|
|
468
|
+
}
|
|
469
|
+
return record;
|
|
470
|
+
}
|
|
471
|
+
function canonicalizeStoredRecord(record, canonicalId, previous) {
|
|
472
|
+
const validTo = earliestValidTo(previous?.time.valid_to, record.time.valid_to);
|
|
473
|
+
return {
|
|
474
|
+
...record,
|
|
475
|
+
id: canonicalId,
|
|
476
|
+
time: {
|
|
477
|
+
...record.time,
|
|
478
|
+
...validTo !== void 0 ? { valid_to: validTo } : {}
|
|
479
|
+
},
|
|
480
|
+
// A replacement closes a predecessor and adds its successor. Never lose
|
|
481
|
+
// that history if an adapter sends a partial lifecycle rewrite.
|
|
482
|
+
supersedes: unionStrings(previous?.supersedes, record.supersedes),
|
|
483
|
+
superseded_by: unionStrings(previous?.superseded_by, record.superseded_by),
|
|
484
|
+
// Relations are a full-record field. A revise may intentionally remove
|
|
485
|
+
// one, so only lifecycle lineage is merged defensively above.
|
|
486
|
+
relations: record.relations,
|
|
487
|
+
integrity: void 0
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
function earliestValidTo(previous, incoming) {
|
|
491
|
+
if (previous == null) return incoming;
|
|
492
|
+
if (incoming == null) return previous;
|
|
493
|
+
const previousAt = Date.parse(previous);
|
|
494
|
+
const incomingAt = Date.parse(incoming);
|
|
495
|
+
if (Number.isNaN(previousAt) || Number.isNaN(incomingAt)) return previous;
|
|
496
|
+
return previousAt <= incomingAt ? previous : incoming;
|
|
497
|
+
}
|
|
498
|
+
function unionStrings(left, right) {
|
|
499
|
+
const values = [...left ?? [], ...right ?? []];
|
|
500
|
+
return values.length ? [...new Set(values)] : void 0;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/ump/backend.ts
|
|
201
504
|
var SEARCH_MIN_SIM = parseFloat(process.env.UMP_RECALL_MIN_SIM ?? "0.3");
|
|
202
505
|
var RRF_K = 60;
|
|
203
506
|
function toRecallMemory(m) {
|
|
@@ -223,56 +526,195 @@ function toRecallMemory(m) {
|
|
|
223
526
|
};
|
|
224
527
|
}
|
|
225
528
|
function tokenOverlap(query, text) {
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
228
|
-
const
|
|
529
|
+
const queryTokens = new Set(query.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 1));
|
|
530
|
+
if (queryTokens.size === 0) return 0;
|
|
531
|
+
const candidate = text.toLowerCase();
|
|
229
532
|
let hits = 0;
|
|
230
|
-
for (const
|
|
231
|
-
return hits /
|
|
533
|
+
for (const word of queryTokens) if (candidate.includes(word)) hits++;
|
|
534
|
+
return hits / queryTokens.size;
|
|
535
|
+
}
|
|
536
|
+
function statusForNative(memory) {
|
|
537
|
+
if (memory.status === "rejected") return "tombstoned";
|
|
538
|
+
const saved = storedUmpRecord(memory.capture_context?.ump_record);
|
|
539
|
+
if (saved?.lifecycle?.status === "tombstoned") return "tombstoned";
|
|
540
|
+
return memory.status === "active" ? "active" : "candidate";
|
|
541
|
+
}
|
|
542
|
+
function recordForMemory(memory, owner) {
|
|
543
|
+
const saved = storedUmpRecord(memory.capture_context?.ump_record);
|
|
544
|
+
if (saved) {
|
|
545
|
+
return {
|
|
546
|
+
...saved,
|
|
547
|
+
id: toUmpId(memory.id),
|
|
548
|
+
integrity: void 0,
|
|
549
|
+
lifecycle: {
|
|
550
|
+
...saved.lifecycle,
|
|
551
|
+
status: statusForNative(memory)
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
return recallMemoryToRecord(toRecallMemory(memory), owner);
|
|
232
556
|
}
|
|
233
|
-
function
|
|
557
|
+
function matchesScope(record, requested) {
|
|
558
|
+
if (!requested) return true;
|
|
559
|
+
return Object.keys(requested).every((key) => requested[key] === void 0 || record.scope[key] === requested[key]);
|
|
560
|
+
}
|
|
561
|
+
function matchesFilter(record, filter) {
|
|
562
|
+
if (!filter) return true;
|
|
563
|
+
const status = record.lifecycle?.status ?? "active";
|
|
564
|
+
if (filter.status && !filter.status.includes(status)) return false;
|
|
565
|
+
if (filter.kind && !filter.kind.includes(record.kind)) return false;
|
|
566
|
+
if (filter.valid_at) {
|
|
567
|
+
const at = Date.parse(filter.valid_at);
|
|
568
|
+
const from = Date.parse(record.time.valid_from ?? record.time.created);
|
|
569
|
+
const to = record.time.valid_to == null ? Number.POSITIVE_INFINITY : Date.parse(record.time.valid_to);
|
|
570
|
+
if (!Number.isFinite(at) || !Number.isFinite(from) || Number.isNaN(to)) return false;
|
|
571
|
+
if (at < from || at > to) return false;
|
|
572
|
+
}
|
|
573
|
+
return true;
|
|
574
|
+
}
|
|
575
|
+
function candidateMatches(memory, owner, request) {
|
|
576
|
+
const record = recordForMemory(memory, owner);
|
|
577
|
+
if (statusForNative(memory) === "tombstoned") return false;
|
|
578
|
+
if (record.scope.owner !== owner) return false;
|
|
579
|
+
return matchesScope(record, request.scope) && matchesFilter(record, request.filter);
|
|
580
|
+
}
|
|
581
|
+
function asTemporalScope(record) {
|
|
582
|
+
if (record.scope.project) {
|
|
583
|
+
return { scope: "repo", repo: record.scope.project, path: null };
|
|
584
|
+
}
|
|
585
|
+
return { scope: "global", repo: null, path: null };
|
|
586
|
+
}
|
|
587
|
+
function confidenceFor(record) {
|
|
588
|
+
const confidence = record.lifecycle?.confidence ?? 0.8;
|
|
589
|
+
return record.lifecycle?.status === "candidate" ? Math.min(confidence, 0.59) : Math.max(confidence, 0.6);
|
|
590
|
+
}
|
|
591
|
+
function captureContextFor(record, canonicalId, previous) {
|
|
592
|
+
const prior = storedUmpRecord(previous?.capture_context?.ump_record);
|
|
593
|
+
return {
|
|
594
|
+
...previous?.capture_context ?? {},
|
|
595
|
+
ump_kind: record.kind,
|
|
596
|
+
ump_record: canonicalizeStoredRecord(record, canonicalId, prior)
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
function putUmpRecord(db, record, existingId) {
|
|
600
|
+
const targetId = existingId ?? (record.id.startsWith("urn:ump:") ? safeRecallId(record.id) : void 0);
|
|
601
|
+
const existing = targetId ? getMemory(db, targetId) : void 0;
|
|
602
|
+
if (existing) {
|
|
603
|
+
const captureContext = captureContextFor(record, toUmpId(existing.id), existing);
|
|
604
|
+
const scope2 = asTemporalScope(record);
|
|
605
|
+
const tombstoned = record.lifecycle?.status === "tombstoned";
|
|
606
|
+
const nativeStatus = existing.status === "rejected" ? "rejected" : record.lifecycle?.status === "candidate" ? "candidate" : "active";
|
|
607
|
+
db.update(memories).set({
|
|
608
|
+
text: record.body.text,
|
|
609
|
+
type: kindToRecallType(record.kind),
|
|
610
|
+
scope: scope2.scope,
|
|
611
|
+
repo: scope2.repo,
|
|
612
|
+
path_scope: scope2.path,
|
|
613
|
+
confidence: confidenceFor(record),
|
|
614
|
+
status: nativeStatus,
|
|
615
|
+
capture_context: captureContext,
|
|
616
|
+
// A UMP record can carry validity, source, and structured semantics
|
|
617
|
+
// that the instruction compiler does not understand. Keep all direct
|
|
618
|
+
// UMP writes out of automatic instructions until that path is proven.
|
|
619
|
+
auto_inject: false,
|
|
620
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
621
|
+
}).where(eq(memories.id, existing.id)).run();
|
|
622
|
+
if (tombstoned && existing.status !== "rejected") {
|
|
623
|
+
rejectMemory(db, existing.id, "ump");
|
|
624
|
+
}
|
|
625
|
+
return existing.id;
|
|
626
|
+
}
|
|
627
|
+
const scope = asTemporalScope(record);
|
|
628
|
+
const id = db.$client.transaction(() => {
|
|
629
|
+
const initialContext = {
|
|
630
|
+
ump_kind: record.kind,
|
|
631
|
+
ump_record: canonicalizeStoredRecord(record, record.id, void 0)
|
|
632
|
+
};
|
|
633
|
+
const createdId = createMemory(db, {
|
|
634
|
+
type: kindToRecallType(record.kind),
|
|
635
|
+
text: record.body.text,
|
|
636
|
+
scope: scope.scope,
|
|
637
|
+
repo: scope.repo,
|
|
638
|
+
path_scope: scope.path,
|
|
639
|
+
source: "user_correction",
|
|
640
|
+
confidence: confidenceFor(record),
|
|
641
|
+
// Equal text with distinct validity windows is intentional.
|
|
642
|
+
dedupe: false,
|
|
643
|
+
auto_inject: false,
|
|
644
|
+
capture_context: initialContext
|
|
645
|
+
});
|
|
646
|
+
db.update(memories).set({
|
|
647
|
+
capture_context: captureContextFor(record, toUmpId(createdId), void 0),
|
|
648
|
+
auto_inject: false,
|
|
649
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
650
|
+
}).where(eq(memories.id, createdId)).run();
|
|
651
|
+
return createdId;
|
|
652
|
+
})();
|
|
653
|
+
if (record.lifecycle?.status === "tombstoned") rejectMemory(db, id, "ump");
|
|
654
|
+
return id;
|
|
655
|
+
}
|
|
656
|
+
function safeRecallId(umpId) {
|
|
657
|
+
try {
|
|
658
|
+
return fromAmpId(umpId);
|
|
659
|
+
} catch {
|
|
660
|
+
return void 0;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
function makeRecallBackend(db, owner) {
|
|
234
664
|
const umpSessionId = `ump:${process.pid}:${Date.now().toString(36)}`;
|
|
235
665
|
return {
|
|
236
|
-
queryMemories: (
|
|
666
|
+
queryMemories: (filter) => queryMemories(db, { repo: filter.repo }).map(toRecallMemory),
|
|
237
667
|
getMemory: (id) => {
|
|
238
|
-
const
|
|
239
|
-
return
|
|
668
|
+
const memory = getMemory(db, id);
|
|
669
|
+
return memory ? toRecallMemory(memory) : void 0;
|
|
240
670
|
},
|
|
241
|
-
compileHybrid: async (
|
|
242
|
-
const cap = limit ?? 8;
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
|
|
671
|
+
compileHybrid: async (request) => {
|
|
672
|
+
const cap = request.limit ?? 8;
|
|
673
|
+
const totalCandidates = queryMemories(db, {}).length;
|
|
674
|
+
const window = Math.max(totalCandidates, cap);
|
|
675
|
+
const scores = /* @__PURE__ */ new Map();
|
|
676
|
+
const add = (id, rank) => scores.set(id, (scores.get(id) ?? 0) + 1 / (RRF_K + rank));
|
|
677
|
+
const config = loadEmbeddingConfigFromEnv();
|
|
678
|
+
if (config && window > 0) {
|
|
248
679
|
try {
|
|
249
|
-
const
|
|
680
|
+
const semantic = await semanticSearch(
|
|
250
681
|
db,
|
|
251
|
-
query,
|
|
252
|
-
{ ...
|
|
253
|
-
{ repo, limit: window }
|
|
682
|
+
request.query,
|
|
683
|
+
{ ...config, similarity_threshold: SEARCH_MIN_SIM },
|
|
684
|
+
{ repo: request.repo, limit: window }
|
|
254
685
|
);
|
|
255
|
-
|
|
686
|
+
semantic.forEach((result, index) => add(result.memory.id, index));
|
|
256
687
|
} catch {
|
|
257
688
|
}
|
|
258
689
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (rrf.size > 0) {
|
|
264
|
-
const out = [];
|
|
265
|
-
for (const [id, score] of [...rrf.entries()].sort((a, b) => b[1] - a[1])) {
|
|
266
|
-
const m = getMemory(db, id);
|
|
267
|
-
if (m && (m.status === "active" || m.status === "candidate")) {
|
|
268
|
-
out.push({ memory: toRecallMemory(m), score });
|
|
269
|
-
if (out.length >= cap) break;
|
|
270
|
-
}
|
|
690
|
+
if (window > 0) {
|
|
691
|
+
try {
|
|
692
|
+
searchMemoryFtsIndex(db, request.query, { repo: request.repo, limit: window }).forEach((result, index) => add(result.memory_id, index));
|
|
693
|
+
} catch {
|
|
271
694
|
}
|
|
272
|
-
if (out.length > 0) return out;
|
|
273
695
|
}
|
|
274
|
-
|
|
696
|
+
const ranked = [];
|
|
697
|
+
for (const [id, score] of [...scores.entries()].sort((a, b) => b[1] - a[1])) {
|
|
698
|
+
const memory = getMemory(db, id);
|
|
699
|
+
if (!memory || !candidateMatches(memory, owner, request)) continue;
|
|
700
|
+
ranked.push({ memory: toRecallMemory(memory), score });
|
|
701
|
+
if (ranked.length >= cap) return ranked;
|
|
702
|
+
}
|
|
703
|
+
const rankedIds = new Set(scores.keys());
|
|
704
|
+
const fallback = queryMemories(db, {}).filter((memory) => !rankedIds.has(memory.id)).filter((memory) => candidateMatches(memory, owner, request)).map((memory) => ({ memory, score: tokenOverlap(request.query, memory.text) })).sort((a, b) => b.score - a.score);
|
|
705
|
+
for (const result of fallback) {
|
|
706
|
+
ranked.push({ memory: toRecallMemory(result.memory), score: result.score });
|
|
707
|
+
if (ranked.length >= cap) break;
|
|
708
|
+
}
|
|
709
|
+
return ranked;
|
|
710
|
+
},
|
|
711
|
+
putRecord: async (record, existingId) => {
|
|
712
|
+
const id = putUmpRecord(db, record, existingId);
|
|
713
|
+
await flushEmbeddingJobs();
|
|
714
|
+
return id;
|
|
275
715
|
},
|
|
716
|
+
// SDK 1.0.2 compatibility only. SDK 1.0.3 uses putRecord for all direct
|
|
717
|
+
// writes, including lifecycle revisions and tombstones.
|
|
276
718
|
storeDirect: async ({ text, type, scope, repo, confidence, kind }) => {
|
|
277
719
|
const id = createMemory(db, {
|
|
278
720
|
type,
|
|
@@ -281,6 +723,7 @@ function makeRecallBackend(db) {
|
|
|
281
723
|
repo: repo ?? null,
|
|
282
724
|
source: "user_correction",
|
|
283
725
|
confidence,
|
|
726
|
+
dedupe: false,
|
|
284
727
|
capture_context: { ump_kind: kind }
|
|
285
728
|
});
|
|
286
729
|
await flushEmbeddingJobs();
|
|
@@ -288,34 +731,103 @@ function makeRecallBackend(db) {
|
|
|
288
731
|
},
|
|
289
732
|
tombstone: (id) => rejectMemory(db, id, "ump"),
|
|
290
733
|
capture: async ({ text, repo, path }) => {
|
|
291
|
-
const
|
|
292
|
-
// Unique per server process: a constant "ump" session id made
|
|
293
|
-
// stablePromptId() dedupe identical rule text forever, so a rule
|
|
294
|
-
// re-sent in a later UMP session was silently never re-extracted.
|
|
734
|
+
const result = await processCorrection(db, text, {
|
|
295
735
|
sessionId: umpSessionId,
|
|
296
736
|
repo,
|
|
297
737
|
path,
|
|
298
738
|
agent: "ump",
|
|
299
739
|
force_semantic_capture: true
|
|
300
740
|
});
|
|
301
|
-
return { ids:
|
|
741
|
+
return { ids: result.ids ?? [] };
|
|
302
742
|
}
|
|
303
743
|
};
|
|
304
744
|
}
|
|
305
745
|
|
|
746
|
+
// src/ump/identity.ts
|
|
747
|
+
init_define_RECALL_BUILD_INFO();
|
|
748
|
+
import {
|
|
749
|
+
closeSync as closeSync2,
|
|
750
|
+
fchmodSync,
|
|
751
|
+
fsyncSync,
|
|
752
|
+
linkSync,
|
|
753
|
+
openSync as openSync2,
|
|
754
|
+
readFileSync,
|
|
755
|
+
unlinkSync,
|
|
756
|
+
writeSync
|
|
757
|
+
} from "fs";
|
|
758
|
+
import { dirname, join } from "path";
|
|
759
|
+
import { randomBytes } from "crypto";
|
|
760
|
+
import { generateKeyPair } from "@universalmemoryprotocol/core";
|
|
761
|
+
var SEED_FILE = "ump-operator-ed25519.seed";
|
|
762
|
+
var ED25519_SEED_LENGTH = 32;
|
|
763
|
+
function loadPersistedUmpOperatorKey(dbPath = getDbPath()) {
|
|
764
|
+
const path = join(dirname(dbPath), SEED_FILE);
|
|
765
|
+
let seed;
|
|
766
|
+
try {
|
|
767
|
+
seed = new Uint8Array(readFileSync(path));
|
|
768
|
+
} catch (error) {
|
|
769
|
+
if (!isMissingFile(error)) throw new Error("Unable to read Recall UMP operator identity");
|
|
770
|
+
seed = createSeed(path);
|
|
771
|
+
}
|
|
772
|
+
if (seed.byteLength !== ED25519_SEED_LENGTH) {
|
|
773
|
+
throw new Error("Invalid persisted Recall UMP operator identity");
|
|
774
|
+
}
|
|
775
|
+
return generateKeyPair(seed);
|
|
776
|
+
}
|
|
777
|
+
function createSeed(path) {
|
|
778
|
+
const seed = randomBytes(ED25519_SEED_LENGTH);
|
|
779
|
+
const temporaryPath = `${path}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`;
|
|
780
|
+
let fd;
|
|
781
|
+
try {
|
|
782
|
+
fd = openSync2(temporaryPath, "wx", 384);
|
|
783
|
+
fchmodSync(fd, 384);
|
|
784
|
+
writeSync(fd, seed);
|
|
785
|
+
fsyncSync(fd);
|
|
786
|
+
closeSync2(fd);
|
|
787
|
+
fd = void 0;
|
|
788
|
+
linkSync(temporaryPath, path);
|
|
789
|
+
return seed;
|
|
790
|
+
} catch (error) {
|
|
791
|
+
if (isAlreadyExists(error)) {
|
|
792
|
+
const existing = new Uint8Array(readFileSync(path));
|
|
793
|
+
if (existing.byteLength !== ED25519_SEED_LENGTH) {
|
|
794
|
+
throw new Error("Invalid persisted Recall UMP operator identity");
|
|
795
|
+
}
|
|
796
|
+
return existing;
|
|
797
|
+
}
|
|
798
|
+
throw new Error("Unable to create Recall UMP operator identity");
|
|
799
|
+
} finally {
|
|
800
|
+
if (fd !== void 0) closeSync2(fd);
|
|
801
|
+
try {
|
|
802
|
+
unlinkSync(temporaryPath);
|
|
803
|
+
} catch {
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
function isMissingFile(error) {
|
|
808
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
809
|
+
}
|
|
810
|
+
function isAlreadyExists(error) {
|
|
811
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST";
|
|
812
|
+
}
|
|
813
|
+
|
|
306
814
|
// src/ump/serve.ts
|
|
307
815
|
function createRecallUmpServer(db, opts = {}) {
|
|
308
|
-
const
|
|
816
|
+
const dbPath = db.$client.name;
|
|
817
|
+
if (!opts.key && (!dbPath || dbPath === ":memory:" || dbPath.startsWith("file::memory:"))) {
|
|
818
|
+
throw new Error("In-memory Recall UMP servers require an injected operator key");
|
|
819
|
+
}
|
|
820
|
+
const key = opts.key ?? loadPersistedUmpOperatorKey(dbPath);
|
|
309
821
|
const owner = key.did;
|
|
310
822
|
const server = new UmpServer({
|
|
311
823
|
name: "recall",
|
|
312
|
-
version: "ump-0.
|
|
824
|
+
version: "ump-1.0.4",
|
|
313
825
|
conformance: "L1",
|
|
314
|
-
store: new RecallStore(makeRecallBackend(db), { owner, smart: opts.smart }),
|
|
826
|
+
store: new RecallStore(makeRecallBackend(db, owner), { owner, smart: opts.smart }),
|
|
315
827
|
key,
|
|
316
828
|
onFeedback: async (req) => {
|
|
317
829
|
signalOutcomeFallback(db, {
|
|
318
|
-
memory_id:
|
|
830
|
+
memory_id: fromAmpId2(req.id),
|
|
319
831
|
session_id: req.session ?? `ump:${process.pid}`,
|
|
320
832
|
injected: true,
|
|
321
833
|
outcome: req.outcome,
|
|
@@ -353,7 +865,7 @@ async function runUmpServer(opts = {}) {
|
|
|
353
865
|
});
|
|
354
866
|
}
|
|
355
867
|
if (opts.stdio ?? !opts.http) {
|
|
356
|
-
await createMcpServer(server).connect(new StdioServerTransport());
|
|
868
|
+
await createMcpServer(server, { owner }).connect(new StdioServerTransport());
|
|
357
869
|
process.stderr.write(`[recall ump] MCP binding on stdio (owner ${owner})
|
|
358
870
|
`);
|
|
359
871
|
}
|
|
@@ -395,7 +907,22 @@ async function pushMemories(db, config) {
|
|
|
395
907
|
if (localMemories.length === 0) {
|
|
396
908
|
return { pushed: 0, version: state.last_push_version };
|
|
397
909
|
}
|
|
398
|
-
const
|
|
910
|
+
const syncableMemories = localMemories.filter(
|
|
911
|
+
(memory) => !hasUmpRecordMarker(memory.capture_context)
|
|
912
|
+
);
|
|
913
|
+
const pushedThroughVersion = Math.max(
|
|
914
|
+
...localMemories.map((memory) => memory.sync_version)
|
|
915
|
+
);
|
|
916
|
+
if (syncableMemories.length === 0) {
|
|
917
|
+
updateSyncState(db, {
|
|
918
|
+
remote_url: remoteUrl,
|
|
919
|
+
team_id: config.team_id,
|
|
920
|
+
last_push_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
921
|
+
last_push_version: pushedThroughVersion
|
|
922
|
+
});
|
|
923
|
+
return { pushed: 0, version: pushedThroughVersion };
|
|
924
|
+
}
|
|
925
|
+
const payload = syncableMemories.map((m) => ({
|
|
399
926
|
...m,
|
|
400
927
|
origin_id: m.id,
|
|
401
928
|
evidence: typeof m.evidence === "string" ? JSON.parse(m.evidence) : m.evidence
|
|
@@ -420,9 +947,7 @@ async function pushMemories(db, config) {
|
|
|
420
947
|
remote_url: remoteUrl,
|
|
421
948
|
team_id: config.team_id,
|
|
422
949
|
last_push_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
423
|
-
last_push_version:
|
|
424
|
-
...localMemories.map((m) => m.sync_version)
|
|
425
|
-
)
|
|
950
|
+
last_push_version: pushedThroughVersion
|
|
426
951
|
});
|
|
427
952
|
return result;
|
|
428
953
|
}
|
|
@@ -448,8 +973,10 @@ async function pullMemories(db, config) {
|
|
|
448
973
|
let pulled = 0;
|
|
449
974
|
let conflicts = 0;
|
|
450
975
|
for (const remote of data.memories) {
|
|
976
|
+
if (hasUmpRecordMarker(remote.capture_context)) continue;
|
|
451
977
|
const localMem = db.select().from(memories).where(eq(memories.id, remote.origin_id)).get();
|
|
452
978
|
if (localMem) {
|
|
979
|
+
if (hasUmpRecordMarker(localMem.capture_context)) continue;
|
|
453
980
|
if (remote.updated_at > localMem.updated_at) {
|
|
454
981
|
db.update(memories).set({
|
|
455
982
|
text: remote.text,
|
|
@@ -492,6 +1019,21 @@ async function pullMemories(db, config) {
|
|
|
492
1019
|
});
|
|
493
1020
|
return { pulled, conflicts };
|
|
494
1021
|
}
|
|
1022
|
+
function hasUmpRecordMarker(captureContext) {
|
|
1023
|
+
const context = parseCaptureContext(captureContext);
|
|
1024
|
+
return context !== null && Object.prototype.hasOwnProperty.call(context, "ump_record");
|
|
1025
|
+
}
|
|
1026
|
+
function parseCaptureContext(value) {
|
|
1027
|
+
let context = value;
|
|
1028
|
+
if (typeof context === "string") {
|
|
1029
|
+
try {
|
|
1030
|
+
context = JSON.parse(context);
|
|
1031
|
+
} catch {
|
|
1032
|
+
return null;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
return context !== null && typeof context === "object" && !Array.isArray(context) ? context : null;
|
|
1036
|
+
}
|
|
495
1037
|
async function sync(db, config) {
|
|
496
1038
|
const errors = [];
|
|
497
1039
|
let pushed = 0;
|
|
@@ -687,12 +1229,12 @@ function formatRestoreReport(result) {
|
|
|
687
1229
|
init_define_RECALL_BUILD_INFO();
|
|
688
1230
|
import { mkdtempSync, rmSync } from "fs";
|
|
689
1231
|
import { tmpdir } from "os";
|
|
690
|
-
import { join } from "path";
|
|
1232
|
+
import { join as join2 } from "path";
|
|
691
1233
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
692
1234
|
async function runReliabilityCanary(options = {}) {
|
|
693
1235
|
const started = performance.now();
|
|
694
|
-
const root = mkdtempSync(
|
|
695
|
-
const db = initStandaloneDb(
|
|
1236
|
+
const root = mkdtempSync(join2(tmpdir(), "recall-reliability-canary-"));
|
|
1237
|
+
const db = initStandaloneDb(join2(root, "recall.db"));
|
|
696
1238
|
const priorDisabled = process.env.RECALL_EMBEDDINGS_DISABLED;
|
|
697
1239
|
const realEmbeddings = options.real_embeddings === true;
|
|
698
1240
|
const checks = {};
|
|
@@ -817,34 +1359,34 @@ async function runReliabilityProbe(db, options = {}) {
|
|
|
817
1359
|
init_define_RECALL_BUILD_INFO();
|
|
818
1360
|
import { existsSync } from "fs";
|
|
819
1361
|
import { execFileSync } from "child_process";
|
|
820
|
-
import { basename, dirname, join as
|
|
1362
|
+
import { basename, dirname as dirname2, join as join3, resolve as resolve2 } from "path";
|
|
821
1363
|
import { fileURLToPath } from "url";
|
|
822
1364
|
function resolveRuntimePaths(appPath) {
|
|
823
1365
|
const override = process.env.RECALL_RUNTIME_DIR;
|
|
824
1366
|
if (override) {
|
|
825
1367
|
return {
|
|
826
1368
|
appPath: override,
|
|
827
|
-
runtimeNodePath:
|
|
828
|
-
runtimeCliPath:
|
|
829
|
-
runtimeMcpPath:
|
|
1369
|
+
runtimeNodePath: join3(override, "bin", "node"),
|
|
1370
|
+
runtimeCliPath: join3(override, "dist", "cli.js"),
|
|
1371
|
+
runtimeMcpPath: join3(override, "dist", "mcp.js")
|
|
830
1372
|
};
|
|
831
1373
|
}
|
|
832
1374
|
if (appPath || process.platform === "darwin" && existsSync("/Applications/Recall.app")) {
|
|
833
1375
|
const resolvedAppPath = appPath ?? "/Applications/Recall.app";
|
|
834
|
-
const runtimeRoot =
|
|
1376
|
+
const runtimeRoot = join3(resolvedAppPath, "Contents", "Resources", "Runtime");
|
|
835
1377
|
return {
|
|
836
1378
|
appPath: resolvedAppPath,
|
|
837
|
-
runtimeNodePath:
|
|
838
|
-
runtimeCliPath:
|
|
839
|
-
runtimeMcpPath:
|
|
1379
|
+
runtimeNodePath: join3(runtimeRoot, "bin", "node"),
|
|
1380
|
+
runtimeCliPath: join3(runtimeRoot, "dist", "cli.js"),
|
|
1381
|
+
runtimeMcpPath: join3(runtimeRoot, "dist", "mcp.js")
|
|
840
1382
|
};
|
|
841
1383
|
}
|
|
842
|
-
const distDir =
|
|
1384
|
+
const distDir = dirname2(fileURLToPath(import.meta.url));
|
|
843
1385
|
return {
|
|
844
1386
|
appPath: distDir,
|
|
845
1387
|
runtimeNodePath: process.execPath,
|
|
846
|
-
runtimeCliPath:
|
|
847
|
-
runtimeMcpPath:
|
|
1388
|
+
runtimeCliPath: join3(distDir, "cli.js"),
|
|
1389
|
+
runtimeMcpPath: join3(distDir, "mcp.js")
|
|
848
1390
|
};
|
|
849
1391
|
}
|
|
850
1392
|
function runLocalSetup(opts = {}) {
|
|
@@ -894,7 +1436,7 @@ function runRecallSetup(opts = {}) {
|
|
|
894
1436
|
throw new Error(`Recall MCP entry not found at ${paths.runtimeMcpPath}`);
|
|
895
1437
|
}
|
|
896
1438
|
const targetAgents = resolveTargetAgents(opts.agent);
|
|
897
|
-
const cwd =
|
|
1439
|
+
const cwd = resolve2(opts.cwd ?? process.cwd());
|
|
898
1440
|
const claudeMdEnabled = opts.claudeMd ?? true;
|
|
899
1441
|
const agents = targetAgents.map(
|
|
900
1442
|
(agent) => setupAgent(agent, {
|
|
@@ -1025,9 +1567,9 @@ function configureMcp(agent, options) {
|
|
|
1025
1567
|
}
|
|
1026
1568
|
function configureHooks(agent, options) {
|
|
1027
1569
|
const codexTargets = agent === "codex" ? options.scope === "project" ? [{
|
|
1028
|
-
home:
|
|
1570
|
+
home: dirname2(options.configPath),
|
|
1029
1571
|
configPath: options.configPath,
|
|
1030
|
-
hooksPath:
|
|
1572
|
+
hooksPath: join3(dirname2(options.configPath), "hooks.json")
|
|
1031
1573
|
}] : resolveCodexHookTargets() : [];
|
|
1032
1574
|
if (options.dryRun) {
|
|
1033
1575
|
const base = options.uninstallHooks ? `would remove hooks from ${options.configPath}` : `would install hooks into ${options.configPath}${options.promptInjection === false ? " (prompt injection opt-out)" : ""}`;
|
|
@@ -1076,18 +1618,18 @@ function resolveTargetAgents(target) {
|
|
|
1076
1618
|
}
|
|
1077
1619
|
function detectAgent(agent) {
|
|
1078
1620
|
if (agent === "codex") {
|
|
1079
|
-
return hasCommand("codex") || existsSync(
|
|
1621
|
+
return hasCommand("codex") || existsSync(join3(resolveUserHomeDir(), ".codex", "config.toml"));
|
|
1080
1622
|
}
|
|
1081
1623
|
if (agent === "claude-code") {
|
|
1082
|
-
return hasCommand("claude") || existsSync(
|
|
1624
|
+
return hasCommand("claude") || existsSync(join3(resolveUserHomeDir(), ".claude", "settings.json"));
|
|
1083
1625
|
}
|
|
1084
1626
|
return resolveAdapter(agent).detect() === "installed";
|
|
1085
1627
|
}
|
|
1086
1628
|
function resolveHookConfigPath(agent, scope, cwd) {
|
|
1087
1629
|
if (scope === "project") {
|
|
1088
|
-
return agent === "codex" ?
|
|
1630
|
+
return agent === "codex" ? join3(cwd, ".codex", "config.toml") : join3(cwd, ".claude", "settings.json");
|
|
1089
1631
|
}
|
|
1090
|
-
return agent === "codex" ?
|
|
1632
|
+
return agent === "codex" ? join3(resolveUserHomeDir(), ".codex", "config.toml") : join3(resolveUserHomeDir(), ".claude", "settings.json");
|
|
1091
1633
|
}
|
|
1092
1634
|
function defaultRunner(command, args, options) {
|
|
1093
1635
|
execFileSync(command, args, { ...stdioOpts(), ...options?.env ? { env: options.env } : {} });
|
|
@@ -1120,13 +1662,13 @@ init_define_RECALL_BUILD_INFO();
|
|
|
1120
1662
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
1121
1663
|
import {
|
|
1122
1664
|
existsSync as existsSync2,
|
|
1123
|
-
readFileSync,
|
|
1665
|
+
readFileSync as readFileSync2,
|
|
1124
1666
|
readdirSync,
|
|
1125
1667
|
rmSync as rmSync2,
|
|
1126
1668
|
rmdirSync
|
|
1127
1669
|
} from "fs";
|
|
1128
1670
|
import { homedir } from "os";
|
|
1129
|
-
import { dirname as
|
|
1671
|
+
import { dirname as dirname3, join as join4, parse, resolve as resolve3 } from "path";
|
|
1130
1672
|
init_keychain();
|
|
1131
1673
|
|
|
1132
1674
|
// src/daemon/service.ts
|
|
@@ -1175,12 +1717,12 @@ var PROVIDERS = [
|
|
|
1175
1717
|
"azure-openai"
|
|
1176
1718
|
];
|
|
1177
1719
|
function resolveRecallDataDir(options = {}) {
|
|
1178
|
-
const home =
|
|
1179
|
-
return
|
|
1720
|
+
const home = resolve3(options.homeDir ?? homedir());
|
|
1721
|
+
return resolve3(options.dataDir ?? process.env.RECALL_DATA_DIR ?? join4(home, ".recall"));
|
|
1180
1722
|
}
|
|
1181
1723
|
function purgeLocalData(options = {}) {
|
|
1182
1724
|
const dryRun = options.dryRun ?? false;
|
|
1183
|
-
const home =
|
|
1725
|
+
const home = resolve3(options.homeDir ?? homedir());
|
|
1184
1726
|
const dataDir = resolveRecallDataDir({ dataDir: options.dataDir, homeDir: home });
|
|
1185
1727
|
assertSafeDataDir(dataDir, home);
|
|
1186
1728
|
const repoRoots = options.repoRoots ?? configuredRepoRoots(home);
|
|
@@ -1234,7 +1776,7 @@ function purgeLocalData(options = {}) {
|
|
|
1234
1776
|
}
|
|
1235
1777
|
try {
|
|
1236
1778
|
rmSync2(contextPath, { force: true });
|
|
1237
|
-
removeDirectoryIfEmpty(
|
|
1779
|
+
removeDirectoryIfEmpty(dirname3(contextPath));
|
|
1238
1780
|
actions.push({
|
|
1239
1781
|
category: "artifact",
|
|
1240
1782
|
target: contextPath,
|
|
@@ -1282,7 +1824,7 @@ function assertSafeDataDir(dataDir, home) {
|
|
|
1282
1824
|
}
|
|
1283
1825
|
function configuredRepoRoots(home) {
|
|
1284
1826
|
const configured = process.env.RECALL_REPO_ROOTS?.split(",").map((value) => value.trim()).filter(Boolean);
|
|
1285
|
-
return configured?.length ? configured.map((value) =>
|
|
1827
|
+
return configured?.length ? configured.map((value) => resolve3(value)) : [join4(home, "Projects")];
|
|
1286
1828
|
}
|
|
1287
1829
|
function findGeneratedContextArtifacts(repoRoots) {
|
|
1288
1830
|
const paths = /* @__PURE__ */ new Set();
|
|
@@ -1297,7 +1839,7 @@ function findGeneratedContextArtifacts(repoRoots) {
|
|
|
1297
1839
|
function isGeneratedContext(path) {
|
|
1298
1840
|
if (!existsSync2(path)) return false;
|
|
1299
1841
|
try {
|
|
1300
|
-
return
|
|
1842
|
+
return readFileSync2(path, "utf8").startsWith(GENERATED_CONTEXT_MARKER);
|
|
1301
1843
|
} catch {
|
|
1302
1844
|
return false;
|
|
1303
1845
|
}
|
|
@@ -1450,6 +1992,7 @@ function defaultRecallAppPath(platform = process.platform) {
|
|
|
1450
1992
|
return platform === "darwin" ? "/Applications/Recall.app" : void 0;
|
|
1451
1993
|
}
|
|
1452
1994
|
program.name("recall").description("Cross-tool coding memory and instruction compiler").version(pkg.version);
|
|
1995
|
+
registerHarness2Commands(program);
|
|
1453
1996
|
program.command("init").description("Initialize Recall database").action(() => {
|
|
1454
1997
|
initDb();
|
|
1455
1998
|
console.log("Recall initialized. Database ready.");
|
|
@@ -1496,7 +2039,7 @@ program.command("doctor").description("Show local Recall runtime, DB, embedding,
|
|
|
1496
2039
|
const finalReport = opts.fix ? getDoctorReport() : report;
|
|
1497
2040
|
const codexEntry = finalReport.agents.find((agent) => agent.agent === "codex" && agent.detected);
|
|
1498
2041
|
if (codexEntry) {
|
|
1499
|
-
const { inspectCodexTrust } = await import("./codex-trust-
|
|
2042
|
+
const { inspectCodexTrust } = await import("./codex-trust-55ECVIEG.js");
|
|
1500
2043
|
codexEntry.hook_trust = await inspectCodexTrust();
|
|
1501
2044
|
}
|
|
1502
2045
|
if (opts.json) {
|
|
@@ -1669,9 +2212,9 @@ function safeHookAction(event, action) {
|
|
|
1669
2212
|
try {
|
|
1670
2213
|
const { appendFileSync, mkdirSync, statSync, renameSync, rmSync: rmSync3 } = await import("fs");
|
|
1671
2214
|
const { homedir: homedir2 } = await import("os");
|
|
1672
|
-
const dir =
|
|
2215
|
+
const dir = join5(homedir2(), ".recall", "logs");
|
|
1673
2216
|
mkdirSync(dir, { recursive: true });
|
|
1674
|
-
logPath =
|
|
2217
|
+
logPath = join5(dir, "hook-errors.log");
|
|
1675
2218
|
try {
|
|
1676
2219
|
const maxBytes = parseInt(process.env.RECALL_HOOK_LOG_MAX_BYTES ?? String(1024 * 1024), 10);
|
|
1677
2220
|
if (maxBytes > 0 && statSync(logPath).size >= maxBytes) {
|
|
@@ -1828,7 +2371,7 @@ program.command("ump").description("Serve the Universal Memory Protocol (UMP) ov
|
|
|
1828
2371
|
});
|
|
1829
2372
|
program.command("scan").description("Scan a repository and bootstrap memories").argument("[path]", "Repository path", ".").option("-s, --session <id>", "Session ID").action((path, opts) => {
|
|
1830
2373
|
const db = initDb();
|
|
1831
|
-
const repoPath =
|
|
2374
|
+
const repoPath = resolve4(path);
|
|
1832
2375
|
const ids = scanAndStore(db, repoPath);
|
|
1833
2376
|
const artifact = writeRepoContextArtifact(db, {
|
|
1834
2377
|
repo: inferRepoSlugFromPath(repoPath),
|
|
@@ -2075,7 +2618,7 @@ program.command("export").description("Export memories as markdown instruction f
|
|
|
2075
2618
|
console.error(`Could not resolve local repo path for ${opts.repo}`);
|
|
2076
2619
|
process.exit(1);
|
|
2077
2620
|
}
|
|
2078
|
-
content =
|
|
2621
|
+
content = readFileSync3(artifact.output_path, "utf-8");
|
|
2079
2622
|
if (!opts.output) {
|
|
2080
2623
|
console.log(content);
|
|
2081
2624
|
return;
|
|
@@ -2094,7 +2637,7 @@ program.command("export").description("Export memories as markdown instruction f
|
|
|
2094
2637
|
});
|
|
2095
2638
|
program.command("publish").description("Write repo-local .recall/context.md for the current repo").argument("[path]", "Repository path", ".").action((path) => {
|
|
2096
2639
|
const db = initDb();
|
|
2097
|
-
const repoPath =
|
|
2640
|
+
const repoPath = resolve4(path);
|
|
2098
2641
|
const artifact = writeRepoContextArtifact(db, {
|
|
2099
2642
|
repo: inferRepoSlugFromPath(repoPath),
|
|
2100
2643
|
repo_path: repoPath
|
|
@@ -2223,7 +2766,7 @@ evalCmd.command("value-retrieval").description("Run retrieval eval cases synthes
|
|
|
2223
2766
|
});
|
|
2224
2767
|
let snapshot = null;
|
|
2225
2768
|
if (opts.snapshot) {
|
|
2226
|
-
const { computeQualityReport, recordQualitySnapshot } = await import("./quality-
|
|
2769
|
+
const { computeQualityReport, recordQualitySnapshot } = await import("./quality-5BFTWSRU.js");
|
|
2227
2770
|
const qualityReport = computeQualityReport(db, { sinceIso: report.since });
|
|
2228
2771
|
snapshot = recordQualitySnapshot(
|
|
2229
2772
|
db,
|
|
@@ -2752,15 +3295,15 @@ uiCmd.command("status").description("Show WebUI status").option("--daemon-port <
|
|
|
2752
3295
|
var graphCmd = program.command("graph").description("Inspect and rebuild the knowledge graph (entities + relations)");
|
|
2753
3296
|
graphCmd.command("stats").description("Show entity/relation counts").action(async () => {
|
|
2754
3297
|
const db = initDb();
|
|
2755
|
-
const { countEntities, countRelations } = await import("./store-
|
|
3298
|
+
const { countEntities, countRelations } = await import("./store-CVQY5QVT.js");
|
|
2756
3299
|
console.log(`entities: ${countEntities(db)}`);
|
|
2757
3300
|
console.log(`relations: ${countRelations(db)}`);
|
|
2758
3301
|
});
|
|
2759
3302
|
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").option("--rebuild", "Clear all existing entities/relations first, then re-extract").action(async (opts) => {
|
|
2760
3303
|
const db = initDb();
|
|
2761
|
-
const { ingestMemoryHeuristic } = await import("./ingest-
|
|
3304
|
+
const { ingestMemoryHeuristic } = await import("./ingest-IYVKCX2V.js");
|
|
2762
3305
|
if (opts.rebuild) {
|
|
2763
|
-
const { clearGraph } = await import("./store-
|
|
3306
|
+
const { clearGraph } = await import("./store-CVQY5QVT.js");
|
|
2764
3307
|
clearGraph(db);
|
|
2765
3308
|
console.log("Cleared existing graph entities and relations.");
|
|
2766
3309
|
}
|
|
@@ -2782,7 +3325,7 @@ graphCmd.command("backfill").description("Run the heuristic extractor over every
|
|
|
2782
3325
|
});
|
|
2783
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) => {
|
|
2784
3327
|
const db = initDb();
|
|
2785
|
-
const { listEntities } = await import("./store-
|
|
3328
|
+
const { listEntities } = await import("./store-CVQY5QVT.js");
|
|
2786
3329
|
const rows = listEntities(db, {
|
|
2787
3330
|
repo: opts.repo,
|
|
2788
3331
|
kind: opts.kind,
|
|
@@ -2801,8 +3344,8 @@ graphCmd.command("entities").description("List entities").option("--repo <repo>"
|
|
|
2801
3344
|
});
|
|
2802
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) => {
|
|
2803
3346
|
const db = initDb();
|
|
2804
|
-
const { graphQuery } = await import("./retrieval-
|
|
2805
|
-
const { loadEmbeddingConfigFromEnv: loadEmbeddingConfigFromEnv2 } = await import("./embeddings-
|
|
3347
|
+
const { graphQuery } = await import("./retrieval-IBGAA6Y2.js");
|
|
3348
|
+
const { loadEmbeddingConfigFromEnv: loadEmbeddingConfigFromEnv2 } = await import("./embeddings-RNT3VZ3N.js");
|
|
2806
3349
|
const embeddingConfig = loadEmbeddingConfigFromEnv2();
|
|
2807
3350
|
const result = await graphQuery(db, queryTokens.join(" "), embeddingConfig, {
|
|
2808
3351
|
repo: opts.repo,
|
|
@@ -2818,7 +3361,7 @@ graphCmd.command("query <query...>").description("Run graph-aware retrieval for
|
|
|
2818
3361
|
});
|
|
2819
3362
|
var maintenanceCmd = program.command("maintenance").description("Inspect and manage the delegated maintenance task queue");
|
|
2820
3363
|
maintenanceCmd.command("stats").description("Show backlog counts, completion stats, and mean latency").action(async () => {
|
|
2821
|
-
const { getTaskStats } = await import("./tasks-
|
|
3364
|
+
const { getTaskStats } = await import("./tasks-UWUCCJL6.js");
|
|
2822
3365
|
const db = initDb();
|
|
2823
3366
|
const stats = getTaskStats(db);
|
|
2824
3367
|
console.log(`Total tasks: ${stats.total}`);
|
|
@@ -2844,7 +3387,7 @@ maintenanceCmd.command("stats").description("Show backlog counts, completion sta
|
|
|
2844
3387
|
}
|
|
2845
3388
|
});
|
|
2846
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) => {
|
|
2847
|
-
const { listTasks } = await import("./tasks-
|
|
3390
|
+
const { listTasks } = await import("./tasks-UWUCCJL6.js");
|
|
2848
3391
|
const db = initDb();
|
|
2849
3392
|
const tasks = listTasks(db, {
|
|
2850
3393
|
status: opts.status,
|
|
@@ -2866,7 +3409,7 @@ maintenanceCmd.command("list").description("List tasks (default: pending)").opti
|
|
|
2866
3409
|
}
|
|
2867
3410
|
});
|
|
2868
3411
|
maintenanceCmd.command("drop").description("Delete a task by id (or id prefix)").argument("<task-id>", "Task id or prefix").action(async (taskIdArg) => {
|
|
2869
|
-
const { deleteTask, listTasks } = await import("./tasks-
|
|
3412
|
+
const { deleteTask, listTasks } = await import("./tasks-UWUCCJL6.js");
|
|
2870
3413
|
const db = initDb();
|
|
2871
3414
|
const all = listTasks(db, { limit: 1e4 });
|
|
2872
3415
|
const matches = all.filter((t) => t.id === taskIdArg || t.id.startsWith(taskIdArg));
|
|
@@ -2885,7 +3428,7 @@ maintenanceCmd.command("drop").description("Delete a task by id (or id prefix)")
|
|
|
2885
3428
|
});
|
|
2886
3429
|
var credentialsCmd = maintenanceCmd.command("credentials").description("Manage LLM provider API keys in macOS Keychain (env fallback on other platforms)");
|
|
2887
3430
|
credentialsCmd.command("list", { isDefault: true }).description("Show which providers have credentials available").action(async () => {
|
|
2888
|
-
const { listCredentials } = await import("./keychain-
|
|
3431
|
+
const { listCredentials } = await import("./keychain-AISDPFDE.js");
|
|
2889
3432
|
const creds = listCredentials();
|
|
2890
3433
|
if (creds.length === 0) {
|
|
2891
3434
|
console.log("No API keys configured. Set one with:");
|
|
@@ -2899,7 +3442,7 @@ credentialsCmd.command("list", { isDefault: true }).description("Show which prov
|
|
|
2899
3442
|
}
|
|
2900
3443
|
});
|
|
2901
3444
|
credentialsCmd.command("set").description("Store credentials for an LLM provider in the macOS Keychain").argument("<provider>", "openai|anthropic|azure").argument("[key]", "API key (prompts via stdin if omitted; required for openai/anthropic and for azure unless --stdin-json is used)").option("--endpoint <url>", "Azure OpenAI resource endpoint (e.g. https://myresource.openai.azure.com)").option("--deployment <name>", "Azure OpenAI deployment name").option("--api-version <version>", "Azure OpenAI api-version (e.g. 2024-10-21)").option("--stdin-json", "Read the azure config (endpoint/deployment/api_version/key) as a JSON object from stdin").action(async (providerArg, keyArg, opts) => {
|
|
2902
|
-
const { setApiKey, setAzureConfig } = await import("./keychain-
|
|
3445
|
+
const { setApiKey, setAzureConfig } = await import("./keychain-AISDPFDE.js");
|
|
2903
3446
|
const provider = providerArg === "azure" ? "azure-openai" : providerArg;
|
|
2904
3447
|
if (provider === "openai" || provider === "anthropic") {
|
|
2905
3448
|
const key = keyArg ?? await readStdinKey();
|
|
@@ -2961,7 +3504,7 @@ credentialsCmd.command("set").description("Store credentials for an LLM provider
|
|
|
2961
3504
|
process.exit(1);
|
|
2962
3505
|
});
|
|
2963
3506
|
credentialsCmd.command("clear").description("Remove provider credentials from the macOS Keychain").argument("<provider>", "openai|anthropic|azure").action(async (providerArg) => {
|
|
2964
|
-
const { deleteApiKey: deleteApiKey2 } = await import("./keychain-
|
|
3507
|
+
const { deleteApiKey: deleteApiKey2 } = await import("./keychain-AISDPFDE.js");
|
|
2965
3508
|
const provider = providerArg === "azure" ? "azure-openai" : providerArg;
|
|
2966
3509
|
if (provider !== "openai" && provider !== "anthropic" && provider !== "azure-openai") {
|
|
2967
3510
|
console.error(`Provider must be "openai", "anthropic", or "azure", got "${providerArg}".`);
|
|
@@ -2972,8 +3515,8 @@ credentialsCmd.command("clear").description("Remove provider credentials from th
|
|
|
2972
3515
|
else console.log(`No ${provider} credentials found in Keychain.`);
|
|
2973
3516
|
});
|
|
2974
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) => {
|
|
2975
|
-
const { dispatchPendingTasks, formatDispatchReport, buildPrompt } = await import("./dispatcher-
|
|
2976
|
-
const { listTasks } = await import("./tasks-
|
|
3518
|
+
const { dispatchPendingTasks, formatDispatchReport, buildPrompt } = await import("./dispatcher-5GGXB7QB.js");
|
|
3519
|
+
const { listTasks } = await import("./tasks-UWUCCJL6.js");
|
|
2977
3520
|
const db = initDb();
|
|
2978
3521
|
if (opts.preview) {
|
|
2979
3522
|
const pending = listTasks(db, {
|
|
@@ -3030,12 +3573,12 @@ ${p.prompt.max_output_tokens}
|
|
|
3030
3573
|
console.log(formatDispatchReport(report));
|
|
3031
3574
|
});
|
|
3032
3575
|
maintenanceCmd.command("quarantine-generated").description("Preview memories supported only by generated messages; preserve them outside injection").option("--apply", "Quarantine matching memories with reversible audit snapshots").action(async (opts) => {
|
|
3033
|
-
const { quarantineGeneratedMemories } = await import("./provenance-
|
|
3576
|
+
const { quarantineGeneratedMemories } = await import("./provenance-HWX3SR5M.js");
|
|
3034
3577
|
const ids = quarantineGeneratedMemories(initDb(), Boolean(opts.apply));
|
|
3035
3578
|
console.log(JSON.stringify({ applied: Boolean(opts.apply), count: ids.length, memory_ids: ids }, null, 2));
|
|
3036
3579
|
});
|
|
3037
3580
|
maintenanceCmd.command("cleanup").description("Run deterministic, LLM-free cleanup for duplicate, low-quality, stale, and mis-scoped memories").option("--apply", "Persist changes (default is dry-run)").option("--only <action>", "Restrict to one action: dedupe_exact_merge|reject_fragment_candidate|promote_repeat_correction|suppress_unproductive_command|globalize_cross_repo|reject_test_fixture_repo|reject_invalid_scope|reject_generic_scanned_tooling").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) => {
|
|
3038
|
-
const { runDeterministicCleanup, formatCleanupReport, revertCleanupRun, listCleanupRuns } = await import("./cleanup-
|
|
3581
|
+
const { runDeterministicCleanup, formatCleanupReport, revertCleanupRun, listCleanupRuns } = await import("./cleanup-MGE4SH7X.js");
|
|
3039
3582
|
const db = initDb();
|
|
3040
3583
|
if (opts.list) {
|
|
3041
3584
|
const runs = listCleanupRuns(db);
|
|
@@ -3089,7 +3632,7 @@ maintenanceCmd.command("quality").description("Show injection outcome distributi
|
|
|
3089
3632
|
recordQualitySnapshot,
|
|
3090
3633
|
listQualitySnapshots,
|
|
3091
3634
|
diffQualitySnapshots
|
|
3092
|
-
} = await import("./quality-
|
|
3635
|
+
} = await import("./quality-5BFTWSRU.js");
|
|
3093
3636
|
const db = initDb();
|
|
3094
3637
|
if (opts.history) {
|
|
3095
3638
|
const snaps = listQualitySnapshots(db);
|
|
@@ -3150,7 +3693,7 @@ maintenanceCmd.command("value-backfill").description("Backfill memory value even
|
|
|
3150
3693
|
const {
|
|
3151
3694
|
backfillMemoryValueEvents,
|
|
3152
3695
|
formatMemoryValueBackfillReport
|
|
3153
|
-
} = await import("./memory-value-
|
|
3696
|
+
} = await import("./memory-value-REBCJWHS.js");
|
|
3154
3697
|
const db = initDb();
|
|
3155
3698
|
const report = backfillMemoryValueEvents(db, {
|
|
3156
3699
|
sinceIso: opts.since,
|
|
@@ -3163,7 +3706,7 @@ maintenanceCmd.command("value-backfill").description("Backfill memory value even
|
|
|
3163
3706
|
console.log(formatMemoryValueBackfillReport(report));
|
|
3164
3707
|
});
|
|
3165
3708
|
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) => {
|
|
3166
|
-
const { summarizeUsage, formatUsageReport } = await import("./usage-
|
|
3709
|
+
const { summarizeUsage, formatUsageReport } = await import("./usage-QLQPIDA5.js");
|
|
3167
3710
|
const db = initDb();
|
|
3168
3711
|
const summary = summarizeUsage(db, {
|
|
3169
3712
|
sinceIso: opts.since,
|