pi-goosedump 0.12.29 → 0.12.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.ts +10 -3
  2. package/package.json +2 -2
package/dist/index.ts CHANGED
@@ -319,13 +319,16 @@ function isMemorySource(value) {
319
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
320
  }
321
321
  function isMemoryMatchReason(value) {
322
- return isRecord(value) && typeof value.detail === "string" && ["lexical", "entity", "vector", "history"].includes(value.kind);
322
+ return isRecord(value) && typeof value.detail === "string" && ["lexical", "entity", "relation", "vector", "history"].includes(value.kind);
323
+ }
324
+ function isMemoryRelationship(value) {
325
+ return isRecord(value) && ["outgoing", "incoming"].includes(value.direction) && ["duplicates", "supports", "revises", "contradicts"].includes(value.kind) && typeof value.claim_id === "string" && typeof value.display_id === "string" && ["fact", "decision", "preference", "procedure", "lesson"].includes(value.memory_type) && typeof value.text === "string" && ["active", "superseded"].includes(value.status) && typeof value.rationale === "string";
323
326
  }
324
327
  function parseMemoryHits(output) {
325
328
  const value = JSON.parse(output);
326
329
  if (!Array.isArray(value))
327
330
  throw new Error("goosedump memory recall returned invalid JSON");
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));
331
+ 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.relationships) && item.relationships.every(isMemoryRelationship) && 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));
329
332
  }
330
333
  function formatMemorySource(source) {
331
334
  const observed = new Date(source.observed_at).toISOString();
@@ -342,9 +345,13 @@ function formatMemoryHit(hit, maxBytes) {
342
345
  const reasonsText = hit.match_reasons.map((reason) => `${reason.kind}: ${reason.detail}`).join("; ");
343
346
  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";
344
347
  const related = hit.related_by && hit.related_by.length > 0 ? ` · related by: ${hit.related_by.map((entity) => `${entity.kind}:${entity.value}`).join(", ")}` : "";
348
+ const relationships = hit.relationships.length > 0 ? `Relationships:
349
+ ${hit.relationships.map((relationship) => `[${relationship.display_id}] ${relationship.direction} ${relationship.kind} ` + `(${relationship.status}): ${relationship.text} — ${relationship.rationale}`).join(`
350
+ `)}
351
+ ` : "";
345
352
  const provenance = `[${hit.display_id}] ${hit.memory_type} (${status}; score ${hit.score.toFixed(3)}; ${validSpan}; project ${hit.project})${keywords}${related}
346
353
  ` + `Match: ${reasonsText}
347
- ` + `Evidence:
354
+ ` + relationships + `Evidence:
348
355
  ${evidenceText}
349
356
  `;
350
357
  const full = `${provenance}${hit.text}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-goosedump",
3
- "version": "0.12.29",
3
+ "version": "0.12.31",
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.29",
41
+ "@jarkkojs/goosedump": "^0.12.31",
42
42
  "@sinclair/typebox": "^0.34.49"
43
43
  },
44
44
  "devDependencies": {