toon-memory 2.10.0 → 3.0.0
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.de.md +1209 -0
- package/README.es.md +1214 -0
- package/README.fr.md +1209 -0
- package/README.ja.md +1209 -0
- package/README.ko.md +1209 -0
- package/README.md +16 -3
- package/README.pt-br.md +1211 -0
- package/README.zh.md +1209 -0
- package/dist/cli/session-start.js +32 -1
- package/mcp/server.js +28271 -27641
- package/package.json +1 -1
- package/src/cli/session-start.ts +47 -1
- package/src/lib/context.ts +6 -5
- package/src/lib/graph.ts +4 -0
- package/src/lib/quality.ts +46 -10
- package/src/lib/utils.ts +4 -0
- package/src/mcp/config.ts +2 -0
- package/src/mcp/consolidation.ts +52 -7
- package/src/mcp/scoring.ts +7 -2
- package/src/mcp/tools.ts +573 -7
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/cli/session-start.ts
|
|
2
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
2
|
+
import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";
|
|
3
|
+
import { join as join2 } from "path";
|
|
3
4
|
|
|
4
5
|
// src/lib/sessions.ts
|
|
5
6
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, unlinkSync, statSync } from "fs";
|
|
@@ -155,6 +156,32 @@ function coordinationView(selfId) {
|
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
// src/cli/session-start.ts
|
|
159
|
+
var MEMORY_DIR = join2(process.cwd(), ".toon-memory", "memory");
|
|
160
|
+
var MEMORY_FILE = join2(MEMORY_DIR, "data.toon");
|
|
161
|
+
function systemPrimer() {
|
|
162
|
+
if (!existsSync2(MEMORY_FILE)) return "";
|
|
163
|
+
try {
|
|
164
|
+
const data = readFileSync2(MEMORY_FILE, "utf-8");
|
|
165
|
+
const lines = data.split("\n").filter((l) => l.startsWith(" ") && l.includes("|") && !l.startsWith(" summaries:"));
|
|
166
|
+
if (lines.length === 0) return "";
|
|
167
|
+
const entries = lines.map((l) => {
|
|
168
|
+
const p = l.trim().split("|");
|
|
169
|
+
if (p.length < 7) return null;
|
|
170
|
+
const accessed = p.length > 8 ? parseInt(p[8]) || 0 : 0;
|
|
171
|
+
const daysSince = (Date.now() - (/* @__PURE__ */ new Date(`${p[6]}T00:00:00`)).getTime()) / 864e5;
|
|
172
|
+
const recency = daysSince < 7 ? 3 : daysSince < 30 ? 2 : daysSince < 90 ? 1 : 0;
|
|
173
|
+
return { key: p[2], content: p[3], category: p[1], tags: p[5] || "", importance: accessed + recency };
|
|
174
|
+
}).filter(Boolean).sort((a, b) => b.importance - a.importance).slice(0, 5);
|
|
175
|
+
if (entries.length === 0) return "";
|
|
176
|
+
const lines2 = [" Top memories:"];
|
|
177
|
+
for (const e of entries) {
|
|
178
|
+
lines2.push(` [${e.category}] ${e.key}: ${e.content.slice(0, 100)}`);
|
|
179
|
+
}
|
|
180
|
+
return lines2.join("\n");
|
|
181
|
+
} catch {
|
|
182
|
+
return "";
|
|
183
|
+
}
|
|
184
|
+
}
|
|
158
185
|
function main() {
|
|
159
186
|
const agent = process.argv[2] || "agent";
|
|
160
187
|
let payload = {};
|
|
@@ -195,6 +222,10 @@ function main() {
|
|
|
195
222
|
} else {
|
|
196
223
|
lines.push(" No file conflicts detected.");
|
|
197
224
|
}
|
|
225
|
+
const primer = systemPrimer();
|
|
226
|
+
if (primer) {
|
|
227
|
+
lines.push(primer);
|
|
228
|
+
}
|
|
198
229
|
lines.push(" Use memory_recall before reading files and memory_sessions to coordinate.");
|
|
199
230
|
console.log(lines.join("\n"));
|
|
200
231
|
process.exit(0);
|