pi-goosedump 0.12.27 → 0.12.29
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/index.ts +14 -7
- package/package.json +2 -2
package/dist/index.ts
CHANGED
|
@@ -316,29 +316,36 @@ function isStringArray(value) {
|
|
|
316
316
|
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
317
317
|
}
|
|
318
318
|
function isMemorySource(value) {
|
|
319
|
-
return isRecord(value) && typeof value.provider === "string" && typeof value.session_id === "string" && typeof value.entry_id === "string" && typeof value.role === "string" && typeof value.observed_at === "number" && typeof value.project === "string" && typeof value.source_path === "string" && (value.content_hash === undefined || typeof value.content_hash === "string");
|
|
319
|
+
return isRecord(value) && typeof value.citation_id === "string" && typeof value.provider === "string" && typeof value.session_id === "string" && typeof value.entry_id === "string" && typeof value.role === "string" && typeof value.observed_at === "number" && typeof value.project === "string" && typeof value.source_path === "string" && typeof value.snippet === "string" && (value.content_hash === undefined || typeof value.content_hash === "string");
|
|
320
|
+
}
|
|
321
|
+
function isMemoryMatchReason(value) {
|
|
322
|
+
return isRecord(value) && typeof value.detail === "string" && ["lexical", "entity", "vector", "history"].includes(value.kind);
|
|
320
323
|
}
|
|
321
324
|
function parseMemoryHits(output) {
|
|
322
325
|
const value = JSON.parse(output);
|
|
323
326
|
if (!Array.isArray(value))
|
|
324
327
|
throw new Error("goosedump memory recall returned invalid JSON");
|
|
325
|
-
return value.filter((item) => isRecord(item) && typeof item.id === "string" && typeof item.display_id === "string" && typeof item.text === "string" && isStringArray(item.keywords) && typeof item.score === "number" && typeof item.project === "string" && (item.valid_from === null || typeof item.valid_from === "number") && (item.valid_until === null || typeof item.valid_until === "number") && (item.status === undefined || item.status === "active" || item.status === "superseded") && (item.superseded_by === undefined || item.superseded_by === null || typeof item.superseded_by === "string") && (item.related_by === undefined || Array.isArray(item.related_by) && item.related_by.every((entity) => isRecord(entity) && typeof entity.kind === "string" && typeof entity.value === "string")) && ["fact", "decision", "preference", "procedure", "lesson"].includes(item.memory_type) && Array.isArray(item.
|
|
328
|
+
return value.filter((item) => isRecord(item) && typeof item.id === "string" && typeof item.display_id === "string" && typeof item.text === "string" && isStringArray(item.keywords) && typeof item.score === "number" && typeof item.project === "string" && (item.valid_from === null || typeof item.valid_from === "number") && (item.valid_until === null || typeof item.valid_until === "number") && (item.status === undefined || item.status === "active" || item.status === "superseded") && (item.superseded_by === undefined || item.superseded_by === null || typeof item.superseded_by === "string") && (item.related_by === undefined || Array.isArray(item.related_by) && item.related_by.every((entity) => isRecord(entity) && typeof entity.kind === "string" && typeof entity.value === "string")) && Array.isArray(item.match_reasons) && item.match_reasons.every(isMemoryMatchReason) && ["fact", "decision", "preference", "procedure", "lesson"].includes(item.memory_type) && Array.isArray(item.evidence) && item.evidence.every(isMemorySource));
|
|
326
329
|
}
|
|
327
330
|
function formatMemorySource(source) {
|
|
328
331
|
const observed = new Date(source.observed_at).toISOString();
|
|
329
332
|
const revision = source.content_hash ? `; revision ${source.content_hash.slice(0, 12)}` : "";
|
|
330
|
-
|
|
333
|
+
const snippet = source.snippet.trim() ? `
|
|
334
|
+
${source.snippet.trim()}` : "";
|
|
335
|
+
return `[${source.citation_id}] ${source.provider}:${source.session_id}/${source.entry_id} ` + `(${source.role}; observed ${observed}${revision}) · ${source.source_path}${snippet}`;
|
|
331
336
|
}
|
|
332
337
|
function formatMemoryHit(hit, maxBytes) {
|
|
333
338
|
const keywords = hit.keywords.length > 0 ? ` · keywords: ${hit.keywords.join(", ")}` : "";
|
|
334
339
|
const status = hit.status ?? "active";
|
|
335
|
-
const
|
|
340
|
+
const evidenceText = hit.evidence.map(formatMemorySource).join(`
|
|
336
341
|
`);
|
|
342
|
+
const reasonsText = hit.match_reasons.map((reason) => `${reason.kind}: ${reason.detail}`).join("; ");
|
|
337
343
|
const validSpan = hit.valid_from !== null && hit.valid_until !== null ? `${new Date(hit.valid_from).toISOString()} → ${new Date(hit.valid_until).toISOString()}` : hit.valid_from !== null ? `from ${new Date(hit.valid_from).toISOString()}` : hit.valid_until !== null ? `until ${new Date(hit.valid_until).toISOString()}` : "always valid";
|
|
338
344
|
const related = hit.related_by && hit.related_by.length > 0 ? ` · related by: ${hit.related_by.map((entity) => `${entity.kind}:${entity.value}`).join(", ")}` : "";
|
|
339
345
|
const provenance = `[${hit.display_id}] ${hit.memory_type} (${status}; score ${hit.score.toFixed(3)}; ${validSpan}; project ${hit.project})${keywords}${related}
|
|
340
|
-
` + `
|
|
341
|
-
|
|
346
|
+
` + `Match: ${reasonsText}
|
|
347
|
+
` + `Evidence:
|
|
348
|
+
${evidenceText}
|
|
342
349
|
`;
|
|
343
350
|
const full = `${provenance}${hit.text}`;
|
|
344
351
|
if (Buffer.byteLength(full) <= maxBytes)
|
|
@@ -491,7 +498,7 @@ async function goosedumpRecall(query, options = {}, signal, executablePath) {
|
|
|
491
498
|
return { hits: parseMemoryHits(output.stdout), warning: output.stderr.trim() };
|
|
492
499
|
}
|
|
493
500
|
async function goosedumpMemoryRemember(target, signal, executablePath) {
|
|
494
|
-
const output = await runGoosedumpAsync(["memory", "
|
|
501
|
+
const output = await runGoosedumpAsync(["memory", "learn", target, "--json"], signal, executablePath);
|
|
495
502
|
return output.stdout.trim();
|
|
496
503
|
}
|
|
497
504
|
async function goosedumpMemoryForget(target, signal, executablePath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-goosedump",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.29",
|
|
4
4
|
"description": "Pi extension for goosedump session search, durable memory, and compaction",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compaction",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@earendil-works/pi-tui": "^0.82.1",
|
|
41
|
-
"@jarkkojs/goosedump": "^0.12.
|
|
41
|
+
"@jarkkojs/goosedump": "^0.12.29",
|
|
42
42
|
"@sinclair/typebox": "^0.34.49"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|