toon-memory 4.1.1 → 4.1.2

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/mcp/server.js CHANGED
@@ -33252,9 +33252,9 @@ init_graph();
33252
33252
  init_utils();
33253
33253
  init_synonyms();
33254
33254
  init_fuzzy();
33255
- init_sessions();
33256
33255
  import { existsSync as existsSync9 } from "fs";
33257
33256
  import { join as join6 } from "path";
33257
+ init_sessions();
33258
33258
 
33259
33259
  // src/lib/git.ts
33260
33260
  init_sessions();
@@ -33802,8 +33802,9 @@ function formatHealth(data) {
33802
33802
  if (expired.length > 0) {
33803
33803
  warnings.push(`${expired.length} entries with expired TTL (run memory_archive)`);
33804
33804
  }
33805
- if (entries.length > 80) {
33806
- warnings.push(`${entries.length} entries (near limit of 100, auto-archive will trigger)`);
33805
+ const maxEntries = getMaxEntries();
33806
+ if (entries.length > Math.floor(maxEntries * 0.8)) {
33807
+ warnings.push(`${entries.length} entries (near limit of ${maxEntries}, auto-archive triggers on the next memory_remember that exceeds it)`);
33807
33808
  }
33808
33809
  const orphanLinks = findOrphanLinks(entries);
33809
33810
  if (orphanLinks.length > 0) {
@@ -33994,6 +33995,24 @@ function generateContextHealth(data, root) {
33994
33995
  const warnings = [];
33995
33996
  const info = [];
33996
33997
  let score = 100;
33998
+ const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
33999
+ const TTL_RE = /^\d{4}(?:-\d{2}-\d{2})?$/;
34000
+ const malformed = [];
34001
+ for (const line of entryLines(data)) {
34002
+ const parts2 = parseToonLine(line);
34003
+ if (parts2.length < 7) {
34004
+ malformed.push(`too few fields (${parts2.length})`);
34005
+ continue;
34006
+ }
34007
+ const date5 = parts2[6] || "";
34008
+ if (date5 && !DATE_RE.test(date5)) malformed.push(`${parts2[2]} (date=${JSON.stringify(date5)})`);
34009
+ const ttl = parts2[7] || "";
34010
+ if (ttl && !DATE_RE.test(ttl) && !TTL_RE.test(ttl)) malformed.push(`${parts2[2]} (ttl=${JSON.stringify(ttl)})`);
34011
+ }
34012
+ if (malformed.length > 0) {
34013
+ critical.push(`${malformed.length} malformed entries: ${malformed.slice(0, 3).join("; ")}`);
34014
+ score -= 20;
34015
+ }
33997
34016
  const keys = new Set(entries.map((e) => e.key));
33998
34017
  const orphanLinks = [];
33999
34018
  for (const e of entries) {
@@ -34090,8 +34109,9 @@ function generateContextHealth(data, root) {
34090
34109
  warnings.push(`${staleClaims.length} potentially overlapping claims: ${staleClaims.slice(0, 3).join("; ")}`);
34091
34110
  score -= 3;
34092
34111
  }
34093
- if (entries.length > 80) {
34094
- warnings.push(`${entries.length} entries (near limit of 100)`);
34112
+ const maxEntries = getMaxEntries();
34113
+ if (entries.length > Math.floor(maxEntries * 0.8)) {
34114
+ warnings.push(`${entries.length} entries (near limit of ${maxEntries})`);
34095
34115
  score -= 3;
34096
34116
  } else if (entries.length === 0) {
34097
34117
  info.push("Empty memory");
@@ -47939,7 +47959,7 @@ function registerResources(server2) {
47939
47959
 
47940
47960
  // src/mcp/server.ts
47941
47961
  var server = new McpServer(
47942
- { name: "toon-memory", version: "4.1.1" },
47962
+ { name: "toon-memory", version: "4.1.2" },
47943
47963
  { capabilities: { tools: { listChanged: true }, resources: { listChanged: true }, experimental: { "io.modelcontextprotocol/ui": {} } } }
47944
47964
  );
47945
47965
  var s = server.server;
@@ -47951,7 +47971,7 @@ s.setRequestHandler(InitializeRequestSchema, async (request) => {
47951
47971
  return {
47952
47972
  protocolVersion,
47953
47973
  capabilities: s.getCapabilities(),
47954
- serverInfo: { name: "toon-memory", version: "4.1.1" },
47974
+ serverInfo: { name: "toon-memory", version: "4.1.2" },
47955
47975
  ...s._instructions && { instructions: s._instructions }
47956
47976
  };
47957
47977
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "toon-memory",
3
3
  "mcpName": "io.github.LuiggiVal08/toon-memory",
4
- "version": "4.1.1",
4
+ "version": "4.1.2",
5
5
  "description": "MCP server giving AI coding agents offline, token-efficient persistent memory — 35 tools, 80% fewer tool calls, recall decisions, patterns, and bugs across sessions. No LLM, no server; works with 15+ agents.",
6
6
  "type": "module",
7
7
  "bin": {
@@ -15,11 +15,12 @@
15
15
 
16
16
  import { existsSync, readFileSync } from "fs"
17
17
  import { join } from "path"
18
- import { parseEntries, buildGraph, bm25Scores, centrality, renderCompact, type GraphEntry } from "./graph"
18
+ import { parseEntries, buildGraph, bm25Scores, centrality, renderCompact, entryLines, type GraphEntry } from "./graph"
19
19
  import { qualityScore } from "./quality"
20
- import { normalize, isExpiredLocal, tokenize, importance, isPrivate } from "./utils"
20
+ import { normalize, isExpiredLocal, tokenize, importance, isPrivate, parseToonLine } from "./utils"
21
21
  import { expandSynonyms } from "./synonyms"
22
22
  import { fuzzyMatch } from "./fuzzy"
23
+ import { getMaxEntries } from "../mcp/config"
23
24
  import { coordinationView, currentBranch, pruneSessions, listSessions } from "./sessions"
24
25
  import { readRecentCommits, gitStatusSummary, readGitIndex, fileMtimes } from "./git"
25
26
  import { scanProjectStructure, readManifest, readEnvExample } from "./project-scan"
@@ -176,8 +177,9 @@ function formatHealth(data: string): string {
176
177
  warnings.push(`${expired.length} entries with expired TTL (run memory_archive)`)
177
178
  }
178
179
 
179
- if (entries.length > 80) {
180
- warnings.push(`${entries.length} entries (near limit of 100, auto-archive will trigger)`)
180
+ const maxEntries = getMaxEntries()
181
+ if (entries.length > Math.floor(maxEntries * 0.8)) {
182
+ warnings.push(`${entries.length} entries (near limit of ${maxEntries}, auto-archive triggers on the next memory_remember that exceeds it)`)
181
183
  }
182
184
 
183
185
  const orphanLinks = findOrphanLinks(entries)
@@ -495,6 +497,27 @@ export function generateContextHealth(data: string, root: string): { report: Hea
495
497
  const info: string[] = []
496
498
  let score = 100
497
499
 
500
+ // 0. Malformed lines (unescaped-pipe corruption shifts fields; a non-date
501
+ // date field is the reliable signature — seen as "3"/"2"/a file path).
502
+ const DATE_RE = /^\d{4}-\d{2}-\d{2}$/
503
+ const TTL_RE = /^\d{4}(?:-\d{2}-\d{2})?$/
504
+ const malformed: string[] = []
505
+ for (const line of entryLines(data)) {
506
+ const parts = parseToonLine(line)
507
+ if (parts.length < 7) {
508
+ malformed.push(`too few fields (${parts.length})`)
509
+ continue
510
+ }
511
+ const date = parts[6] || ""
512
+ if (date && !DATE_RE.test(date)) malformed.push(`${parts[2]} (date=${JSON.stringify(date)})`)
513
+ const ttl = parts[7] || ""
514
+ if (ttl && !DATE_RE.test(ttl) && !TTL_RE.test(ttl)) malformed.push(`${parts[2]} (ttl=${JSON.stringify(ttl)})`)
515
+ }
516
+ if (malformed.length > 0) {
517
+ critical.push(`${malformed.length} malformed entries: ${malformed.slice(0, 3).join("; ")}`)
518
+ score -= 20
519
+ }
520
+
498
521
  // 1. Orphan links
499
522
  const keys = new Set(entries.map((e) => e.key))
500
523
  const orphanLinks: string[] = []
@@ -611,8 +634,9 @@ export function generateContextHealth(data: string, root: string): { report: Hea
611
634
  }
612
635
 
613
636
  // 10. Entry count
614
- if (entries.length > 80) {
615
- warnings.push(`${entries.length} entries (near limit of 100)`)
637
+ const maxEntries = getMaxEntries()
638
+ if (entries.length > Math.floor(maxEntries * 0.8)) {
639
+ warnings.push(`${entries.length} entries (near limit of ${maxEntries})`)
616
640
  score -= 3
617
641
  } else if (entries.length === 0) {
618
642
  info.push("Empty memory")
package/src/lib/graph.ts CHANGED
@@ -86,7 +86,7 @@ export interface MemoryGraph {
86
86
  byKey: Map<string, GraphEntry>
87
87
  }
88
88
 
89
- const entryLines = (data: string): string[] =>
89
+ export const entryLines = (data: string): string[] =>
90
90
  data
91
91
  .split("\n")
92
92
  .filter(