@pi-unipi/memory 2.5.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +56 -34
- package/package.json +3 -3
package/index.ts
CHANGED
|
@@ -35,6 +35,54 @@ import { isEmbeddingReady, hasModelChanged } from "./settings.js";
|
|
|
35
35
|
/** Package version */
|
|
36
36
|
const VERSION = getPackageVersion(dirname(fileURLToPath(import.meta.url)));
|
|
37
37
|
|
|
38
|
+
interface MemoryReminderInput {
|
|
39
|
+
projectName: string;
|
|
40
|
+
memories: Array<{ title: string }>;
|
|
41
|
+
canSearch: boolean;
|
|
42
|
+
canStore: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Build the deterministic, model-visible first-turn memory reminder.
|
|
47
|
+
* Exported so provider-payload regressions can exercise the exact production
|
|
48
|
+
* content without initializing a storage backend.
|
|
49
|
+
*/
|
|
50
|
+
export function buildMemoryRecallReminder(input: MemoryReminderInput): string {
|
|
51
|
+
const lines = [
|
|
52
|
+
"## 🧠 Memory System Active",
|
|
53
|
+
"",
|
|
54
|
+
`You have ${input.memories.length} memories stored for project "${input.projectName}".`,
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
if (input.canSearch && input.memories.length > 0) {
|
|
58
|
+
const titleList = input.memories.slice(0, 20).map((memory) => `- ${memory.title}`).join("\n");
|
|
59
|
+
const extra = input.memories.length > 20
|
|
60
|
+
? `\n... and ${input.memories.length - 20} more`
|
|
61
|
+
: "";
|
|
62
|
+
lines.push(
|
|
63
|
+
"**BEFORE starting work**, call `memory_search` with relevant keywords to check for existing context.",
|
|
64
|
+
"",
|
|
65
|
+
"Available memories:",
|
|
66
|
+
titleList + extra,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (input.canStore) {
|
|
71
|
+
lines.push(
|
|
72
|
+
"",
|
|
73
|
+
"**AFTER completing the task**, if you learned something non-obvious,",
|
|
74
|
+
"call `memory_store` to save it for future sessions.",
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
lines.push(
|
|
79
|
+
"",
|
|
80
|
+
"Guardrails: read max 10 memory results per search. Update existing memories instead of creating duplicates.",
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return lines.join("\n");
|
|
84
|
+
}
|
|
85
|
+
|
|
38
86
|
/** Storage instance for current project */
|
|
39
87
|
let projectStorage: MemoryStorage | null = null;
|
|
40
88
|
|
|
@@ -251,44 +299,18 @@ export default function (pi: ExtensionAPI) {
|
|
|
251
299
|
return;
|
|
252
300
|
}
|
|
253
301
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
"",
|
|
257
|
-
`You have ${projectMemories.length} memories stored for project "${projectName}".`,
|
|
258
|
-
];
|
|
259
|
-
|
|
260
|
-
if (canSearch && projectMemories.length > 0) {
|
|
261
|
-
const titleList = projectMemories.slice(0, 20).map(m => `- ${m.title}`).join("\n");
|
|
262
|
-
const extra = projectMemories.length > 20 ? `\n... and ${projectMemories.length - 20} more` : "";
|
|
263
|
-
lines.push(
|
|
264
|
-
"**BEFORE starting work**, call `memory_search` with relevant keywords to check for existing context.",
|
|
265
|
-
"",
|
|
266
|
-
"Available memories:",
|
|
267
|
-
titleList + extra,
|
|
268
|
-
);
|
|
269
|
-
} else {
|
|
270
|
-
recallDone = true;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (canStore) {
|
|
274
|
-
lines.push(
|
|
275
|
-
"",
|
|
276
|
-
"**AFTER completing the task**, if you learned something non-obvious,",
|
|
277
|
-
"call `memory_store` to save it for future sessions.",
|
|
278
|
-
);
|
|
279
|
-
} else {
|
|
280
|
-
storeDone = true;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
lines.push(
|
|
284
|
-
"",
|
|
285
|
-
"Guardrails: read max 10 memory results per search. Update existing memories instead of creating duplicates.",
|
|
286
|
-
);
|
|
302
|
+
if (!canSearch || projectMemories.length === 0) recallDone = true;
|
|
303
|
+
if (!canStore) storeDone = true;
|
|
287
304
|
|
|
288
305
|
return {
|
|
289
306
|
message: {
|
|
290
307
|
customType: "unipi-memory-recall-reminder",
|
|
291
|
-
content:
|
|
308
|
+
content: buildMemoryRecallReminder({
|
|
309
|
+
projectName,
|
|
310
|
+
memories: projectMemories,
|
|
311
|
+
canSearch,
|
|
312
|
+
canStore,
|
|
313
|
+
}),
|
|
292
314
|
display: false,
|
|
293
315
|
},
|
|
294
316
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/memory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Persistent cross-session memory with MemPalace backend (auto-installed) and SQLite fallback for Pi coding agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"better-sqlite3": "^12.9.0",
|
|
44
44
|
"sqlite-vec": "^0.1.9",
|
|
45
45
|
"js-yaml": "^4.1.0",
|
|
46
|
-
"@pi-unipi/core": "2.
|
|
47
|
-
"@pi-unipi/info-screen": "2.
|
|
46
|
+
"@pi-unipi/core": "2.6.1",
|
|
47
|
+
"@pi-unipi/info-screen": "2.6.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@earendil-works/pi-coding-agent": "^0.80.0",
|