toon-memory 4.3.3 → 4.3.5

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.md CHANGED
@@ -116,6 +116,7 @@ Read [How toon-memory Makes Your AI Agent Smarter](https://luiggival08.github.io
116
116
  - **Evidence layer** — every `memory_remember` save is annotated with an evidence level: `verified` when its referenced file exists on disk, `unverified` when it doesn't, `conflict` when it overlaps a warning or critical/high decision. Conflicts get a +0.15 recall boost (verified +0.03, unverified −0.02) and a ⚠️ CONTRADICTION warning on save — but never block the write
117
117
  - **Secrets vault** — `memory_secret` stores credentials in an encrypted sidecar (`secrets.toon`, AES-256-GCM) so `data.toon` stays a readable open format while sensitive values never hit plaintext
118
118
  - **Global memory import/export** — `memory_export_global` writes project memory to `~/.toon-memory/memory/global.toon`; `memory_import_global` pulls cross-project conventions back with a one-shot, deterministic, offline merge (never a live dual source)
119
+ - **~1 MB install** — three tiny prompt packages (`@inquirer/checkbox`/`select`/`confirm`); the MCP SDK, zod, and the TOON parser are bundled into the shipped binary — a single `npm i -g` downloads ~1 MB (was ~14 MB) and lands ~4.4 MB on disk (was ~33 MB)
119
120
 
120
121
  ---
121
122
 
@@ -136,6 +137,8 @@ npm i -g toon-memory
136
137
 
137
138
  > **Tip:** The npm install is the most reliable method. The curl/irm scripts are convenience wrappers.
138
139
 
140
+ > **Size:** A bare `npm i -g toon-memory` downloads ~1 MB and installs ~4.4 MB — three tiny prompt packages; everything else (MCP SDK, zod, TOON parser) ships bundled.
141
+
139
142
  ### 2. Configure your agent(s)
140
143
 
141
144
  ```bash
package/dist/cli/setup.js CHANGED
@@ -62,7 +62,9 @@ function captureToggle(enable) {
62
62
  // src/cli/commands.ts
63
63
  import { existsSync as existsSync9, mkdirSync as mkdirSync7, readFileSync as readFileSync9, writeFileSync as writeFileSync7, unlinkSync, rmSync } from "fs";
64
64
  import { basename, join as join7 } from "path";
65
- import { checkbox, select, confirm } from "@inquirer/prompts";
65
+ import checkbox from "@inquirer/checkbox";
66
+ import select from "@inquirer/select";
67
+ import confirm from "@inquirer/confirm";
66
68
 
67
69
  // src/lib/vocab.ts
68
70
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
@@ -1679,7 +1681,7 @@ function watch(args2) {
1679
1681
  // src/viewer/index.ts
1680
1682
  import { writeFileSync as writeFileSync11, mkdirSync as mkdirSync10 } from "fs";
1681
1683
  import { join as join10 } from "path";
1682
- import { execSync } from "child_process";
1684
+ import { spawn } from "child_process";
1683
1685
 
1684
1686
  // src/lib/lock.ts
1685
1687
  import { openSync, closeSync, writeFileSync as writeFileSync9, readFileSync as readFileSync11, unlinkSync as unlinkSync3, existsSync as existsSync11, statSync as statSync2, renameSync } from "fs";
@@ -2039,19 +2041,6 @@ function buildViewerData() {
2039
2041
  import { readFileSync as readFileSync13 } from "fs";
2040
2042
  import { resolve, dirname as dirname8 } from "path";
2041
2043
  import { fileURLToPath as fileURLToPath2 } from "url";
2042
- var d3Src = (() => {
2043
- try {
2044
- const dir = dirname8(fileURLToPath2(import.meta.url));
2045
- return readFileSync13(resolve(dir, "../src/viewer/d3.v7.min.js"), "utf-8");
2046
- } catch {
2047
- try {
2048
- const dir = dirname8(fileURLToPath2(import.meta.url));
2049
- return readFileSync13(resolve(dir, "d3.v7.min.js"), "utf-8");
2050
- } catch {
2051
- return null;
2052
- }
2053
- }
2054
- })();
2055
2044
  function readViewerAsset(name) {
2056
2045
  const dir = dirname8(fileURLToPath2(import.meta.url));
2057
2046
  const candidates = [
@@ -2067,6 +2056,7 @@ function readViewerAsset(name) {
2067
2056
  }
2068
2057
  return "";
2069
2058
  }
2059
+ var d3Src = readViewerAsset("d3.v7.min.js");
2070
2060
  var logoSrc = readViewerAsset("logo.svg");
2071
2061
  var isologoSrc = readViewerAsset("logo-isologo.svg");
2072
2062
  function generateHtml(viewerData) {
@@ -2341,7 +2331,7 @@ const tooltip = document.getElementById('tooltip');
2341
2331
  function showTooltip(e, d) {
2342
2332
  const score = d.quality || 0;
2343
2333
  tooltip.innerHTML =
2344
- '<div class="tt-cat" style="color:' + (COLORS[d.category] || 'var(--muted)') + '">' + d.category + '</div>' +
2334
+ '<div class="tt-cat" style="color:' + (COLORS[d.category] || 'var(--muted)') + '">' + escHtml(d.category) + '</div>' +
2345
2335
  '<div class="tt-key">' + escHtml(d.id) + '</div>' +
2346
2336
  '<div class="tt-content">' + escHtml(d.content) + '</div>' +
2347
2337
  '<div class="tt-score">Quality: ' + score.toFixed(2) + ' | Access: ' + (d.accessCount || 0) + '</div>';
@@ -2431,7 +2421,7 @@ function renderEntries() {
2431
2421
  div.className = 'entry-item' + (selectedEntry && selectedEntry.id === e.id ? ' selected' : '') + (firstEntriesRender ? ' reveal' : '');
2432
2422
  if (firstEntriesRender) div.style.animationDelay = Math.min(i * 0.03, 0.6) + 's';
2433
2423
  div.innerHTML =
2434
- '<div class="entry-cat ' + e.category + '">' + e.category + '</div>' +
2424
+ '<div class="entry-cat ' + escHtml(e.category) + '">' + escHtml(e.category) + '</div>' +
2435
2425
  '<div class="entry-key">' + escHtml(e.id) + '</div>' +
2436
2426
  '<div class="entry-preview">' + escHtml(e.content) + '</div>' +
2437
2427
  (e.tags.length ? '<div class="entry-tags">' + e.tags.map(t => '<span class="entry-tag">' + escHtml(t) + '</span>').join('') + '</div>' : '');
@@ -2441,7 +2431,7 @@ function renderEntries() {
2441
2431
  firstEntriesRender = false;
2442
2432
  }
2443
2433
 
2444
- function escHtml(s) { return s.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); }
2434
+ function escHtml(s) { return String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;'); }
2445
2435
 
2446
2436
  // --- Entry Selection ---
2447
2437
  function selectEntry(entry) {
@@ -2460,17 +2450,17 @@ function showDetail(e) {
2460
2450
  .map(ed => (typeof ed.source === 'object' ? ed.source.id : ed.source) === e.id ? (typeof ed.target === 'object' ? ed.target.id : ed.target) : (typeof ed.source === 'object' ? ed.source.id : ed.source));
2461
2451
 
2462
2452
  panel.innerHTML =
2463
- '<div class="detail-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + e.category + '</div>' +
2453
+ '<div class="detail-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + escHtml(e.category) + '</div>' +
2464
2454
  '<h2>' + escHtml(e.id) + '</h2>' +
2465
2455
  '<div class="detail-field"><label>Content</label><span class="value mono">' + escHtml(e.content) + '</span></div>' +
2466
2456
  (e.file ? '<div class="detail-field"><label>File</label><span class="value mono"><a href="#" onclick="event.preventDefault()" style="color:var(--brand);text-decoration:none;cursor:pointer">' + escHtml(e.file) + '</a></span></div>' : '') +
2467
- (e.date ? '<div class="detail-field"><label>Date</label><span class="value">' + e.date + '</span></div>' : '') +
2457
+ (e.date ? '<div class="detail-field"><label>Date</label><span class="value">' + escHtml(e.date) + '</span></div>' : '') +
2468
2458
  '<div class="detail-field"><label>Quality Score</label><span class="value" style="color:var(--brand);font-weight:700;font-size:1.1rem">' + (e.quality || 0).toFixed(3) + '</span></div>' +
2469
2459
  '<div class="detail-field"><label>Access Count</label><span class="value">' + (e.accessCount || 0) + '</span></div>' +
2470
- (e.ttl ? '<div class="detail-field"><label>TTL</label><span class="value">' + e.ttl + '</span></div>' : '') +
2471
- (e.lastAccessed ? '<div class="detail-field"><label>Last Accessed</label><span class="value">' + e.lastAccessed + '</span></div>' : '') +
2460
+ (e.ttl ? '<div class="detail-field"><label>TTL</label><span class="value">' + escHtml(e.ttl) + '</span></div>' : '') +
2461
+ (e.lastAccessed ? '<div class="detail-field"><label>Last Accessed</label><span class="value">' + escHtml(e.lastAccessed) + '</span></div>' : '') +
2472
2462
  (e.tags.length ? '<div class="detail-field"><label>Tags</label><div class="entry-tags">' + e.tags.map(t => '<span class="entry-tag">' + escHtml(t) + '</span>').join('') + '</div></div>' : '') +
2473
- (linkedNodes.length ? '<div class="detail-field"><label>Linked Entries (' + linkedNodes.length + ')</label><div class="detail-links">' + linkedNodes.map(k => '<span class="detail-link" onclick="selectEntryById(\\'' + k + '\\')">' + escHtml(k) + '</span>').join('') + '</div></div>' : '');
2463
+ (linkedNodes.length ? '<div class="detail-field"><label>Linked Entries (' + linkedNodes.length + ')</label><div class="detail-links">' + linkedNodes.map(k => '<span class="detail-link" data-id="' + escHtml(k) + '">' + escHtml(k) + '</span>').join('') + '</div></div>' : '');
2474
2464
  }
2475
2465
 
2476
2466
  window.selectEntryById = function(id) {
@@ -2478,6 +2468,16 @@ window.selectEntryById = function(id) {
2478
2468
  if (e) selectEntry(e);
2479
2469
  };
2480
2470
 
2471
+ // Delegated click handling for data-id elements (detail links, timeline) \u2014
2472
+ // avoids inline onclick handlers with interpolated entry data (XSS vector).
2473
+ document.addEventListener('click', function(ev) {
2474
+ const t = ev.target;
2475
+ const el = t && t.closest ? t.closest('[data-id]') : null;
2476
+ if (el && el.dataset.id) {
2477
+ window.selectEntryById(el.dataset.id);
2478
+ }
2479
+ });
2480
+
2481
2481
  // --- Stats ---
2482
2482
  function renderStats() {
2483
2483
  const grid = document.getElementById('statsGrid');
@@ -2496,7 +2496,7 @@ function renderStats() {
2496
2496
  card(3, '<h3>Max Access</h3><div class="stat-big">' + maxAccess + '</div>') +
2497
2497
  card(4, '<h3>Categories</h3><div class="bar-chart">' +
2498
2498
  catEntries.map(([cat, count]) =>
2499
- '<div class="bar-row"><span class="bar-label">' + cat + '</span><div class="bar-track"><div class="bar-fill" data-w="' + (count/maxCat*100) + '" style="background:' + (COLORS[cat] || 'var(--brand)') + '"></div></div><span class="bar-value">' + count + '</span></div>'
2499
+ '<div class="bar-row"><span class="bar-label">' + escHtml(cat) + '</span><div class="bar-track"><div class="bar-fill" data-w="' + (count/maxCat*100) + '" style="background:' + (COLORS[cat] || 'var(--brand)') + '"></div></div><span class="bar-value">' + count + '</span></div>'
2500
2500
  ).join('') +
2501
2501
  '</div>') +
2502
2502
  card(5, '<h3>Top Tags</h3><div class="tag-cloud">' +
@@ -2526,9 +2526,9 @@ function renderTimeline() {
2526
2526
  let idx = 0;
2527
2527
  for (const [date, entries] of Object.entries(grouped)) {
2528
2528
  for (const e of entries) {
2529
- html += '<div class="timeline-entry reveal" style="border-left:3px solid ' + (COLORS[e.category] || 'var(--border)') + ';animation-delay:' + Math.min(idx * 0.02, 0.6) + 's" onclick="selectEntryById(\\'' + e.id + '\\')">' +
2529
+ html += '<div class="timeline-entry reveal" style="border-left:3px solid ' + (COLORS[e.category] || 'var(--border)') + ';animation-delay:' + Math.min(idx * 0.02, 0.6) + 's" data-id="' + escHtml(e.id) + '">' +
2530
2530
  '<div class="tl-date">' + escHtml(date) + '</div>' +
2531
- '<div class="tl-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + e.category + '</div>' +
2531
+ '<div class="tl-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + escHtml(e.category) + '</div>' +
2532
2532
  '<div class="tl-key">' + escHtml(e.id) + '</div>' +
2533
2533
  '<div class="tl-content">' + escHtml(e.content.substring(0, 100)) + '</div>' +
2534
2534
  '</div>';
@@ -3001,13 +3001,10 @@ if (window.parent !== window) {
3001
3001
  import { createServer } from "http";
3002
3002
  function openBrowser(url) {
3003
3003
  const platform = process.platform;
3004
- try {
3005
- if (platform === "darwin") execSync(`open "${url}"`);
3006
- else if (platform === "win32") execSync(`start "" "${url}"`);
3007
- else execSync(`xdg-open "${url}" || sensible-browser "${url}" || x-www-browser "${url}"`, { stdio: "ignore" });
3008
- } catch {
3009
- console.log(`Open in browser: ${url}`);
3010
- }
3004
+ const opts = { stdio: "ignore", detached: true };
3005
+ const child = platform === "darwin" ? spawn("open", [url], opts) : platform === "win32" ? spawn("cmd", ["/c", "start", "", url], opts) : spawn("xdg-open", [url], opts);
3006
+ child.unref();
3007
+ child.on("error", () => console.log(`Open in browser: ${url}`));
3011
3008
  }
3012
3009
  function resolvePort(portArg) {
3013
3010
  const raw = portArg ?? process.env.PORT;
package/mcp/server.js CHANGED
@@ -47705,19 +47705,6 @@ function buildViewerData() {
47705
47705
  import { readFileSync as readFileSync11 } from "fs";
47706
47706
  import { resolve, dirname as dirname2 } from "path";
47707
47707
  import { fileURLToPath } from "url";
47708
- var d3Src = (() => {
47709
- try {
47710
- const dir = dirname2(fileURLToPath(import.meta.url));
47711
- return readFileSync11(resolve(dir, "../src/viewer/d3.v7.min.js"), "utf-8");
47712
- } catch {
47713
- try {
47714
- const dir = dirname2(fileURLToPath(import.meta.url));
47715
- return readFileSync11(resolve(dir, "d3.v7.min.js"), "utf-8");
47716
- } catch {
47717
- return null;
47718
- }
47719
- }
47720
- })();
47721
47708
  function readViewerAsset(name) {
47722
47709
  const dir = dirname2(fileURLToPath(import.meta.url));
47723
47710
  const candidates = [
@@ -47733,6 +47720,7 @@ function readViewerAsset(name) {
47733
47720
  }
47734
47721
  return "";
47735
47722
  }
47723
+ var d3Src = readViewerAsset("d3.v7.min.js");
47736
47724
  var logoSrc = readViewerAsset("logo.svg");
47737
47725
  var isologoSrc = readViewerAsset("logo-isologo.svg");
47738
47726
  function generateHtml(viewerData) {
@@ -48007,7 +47995,7 @@ const tooltip = document.getElementById('tooltip');
48007
47995
  function showTooltip(e, d) {
48008
47996
  const score = d.quality || 0;
48009
47997
  tooltip.innerHTML =
48010
- '<div class="tt-cat" style="color:' + (COLORS[d.category] || 'var(--muted)') + '">' + d.category + '</div>' +
47998
+ '<div class="tt-cat" style="color:' + (COLORS[d.category] || 'var(--muted)') + '">' + escHtml(d.category) + '</div>' +
48011
47999
  '<div class="tt-key">' + escHtml(d.id) + '</div>' +
48012
48000
  '<div class="tt-content">' + escHtml(d.content) + '</div>' +
48013
48001
  '<div class="tt-score">Quality: ' + score.toFixed(2) + ' | Access: ' + (d.accessCount || 0) + '</div>';
@@ -48097,7 +48085,7 @@ function renderEntries() {
48097
48085
  div.className = 'entry-item' + (selectedEntry && selectedEntry.id === e.id ? ' selected' : '') + (firstEntriesRender ? ' reveal' : '');
48098
48086
  if (firstEntriesRender) div.style.animationDelay = Math.min(i * 0.03, 0.6) + 's';
48099
48087
  div.innerHTML =
48100
- '<div class="entry-cat ' + e.category + '">' + e.category + '</div>' +
48088
+ '<div class="entry-cat ' + escHtml(e.category) + '">' + escHtml(e.category) + '</div>' +
48101
48089
  '<div class="entry-key">' + escHtml(e.id) + '</div>' +
48102
48090
  '<div class="entry-preview">' + escHtml(e.content) + '</div>' +
48103
48091
  (e.tags.length ? '<div class="entry-tags">' + e.tags.map(t => '<span class="entry-tag">' + escHtml(t) + '</span>').join('') + '</div>' : '');
@@ -48107,7 +48095,7 @@ function renderEntries() {
48107
48095
  firstEntriesRender = false;
48108
48096
  }
48109
48097
 
48110
- function escHtml(s) { return s.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); }
48098
+ function escHtml(s) { return String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;'); }
48111
48099
 
48112
48100
  // --- Entry Selection ---
48113
48101
  function selectEntry(entry) {
@@ -48126,17 +48114,17 @@ function showDetail(e) {
48126
48114
  .map(ed => (typeof ed.source === 'object' ? ed.source.id : ed.source) === e.id ? (typeof ed.target === 'object' ? ed.target.id : ed.target) : (typeof ed.source === 'object' ? ed.source.id : ed.source));
48127
48115
 
48128
48116
  panel.innerHTML =
48129
- '<div class="detail-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + e.category + '</div>' +
48117
+ '<div class="detail-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + escHtml(e.category) + '</div>' +
48130
48118
  '<h2>' + escHtml(e.id) + '</h2>' +
48131
48119
  '<div class="detail-field"><label>Content</label><span class="value mono">' + escHtml(e.content) + '</span></div>' +
48132
48120
  (e.file ? '<div class="detail-field"><label>File</label><span class="value mono"><a href="#" onclick="event.preventDefault()" style="color:var(--brand);text-decoration:none;cursor:pointer">' + escHtml(e.file) + '</a></span></div>' : '') +
48133
- (e.date ? '<div class="detail-field"><label>Date</label><span class="value">' + e.date + '</span></div>' : '') +
48121
+ (e.date ? '<div class="detail-field"><label>Date</label><span class="value">' + escHtml(e.date) + '</span></div>' : '') +
48134
48122
  '<div class="detail-field"><label>Quality Score</label><span class="value" style="color:var(--brand);font-weight:700;font-size:1.1rem">' + (e.quality || 0).toFixed(3) + '</span></div>' +
48135
48123
  '<div class="detail-field"><label>Access Count</label><span class="value">' + (e.accessCount || 0) + '</span></div>' +
48136
- (e.ttl ? '<div class="detail-field"><label>TTL</label><span class="value">' + e.ttl + '</span></div>' : '') +
48137
- (e.lastAccessed ? '<div class="detail-field"><label>Last Accessed</label><span class="value">' + e.lastAccessed + '</span></div>' : '') +
48124
+ (e.ttl ? '<div class="detail-field"><label>TTL</label><span class="value">' + escHtml(e.ttl) + '</span></div>' : '') +
48125
+ (e.lastAccessed ? '<div class="detail-field"><label>Last Accessed</label><span class="value">' + escHtml(e.lastAccessed) + '</span></div>' : '') +
48138
48126
  (e.tags.length ? '<div class="detail-field"><label>Tags</label><div class="entry-tags">' + e.tags.map(t => '<span class="entry-tag">' + escHtml(t) + '</span>').join('') + '</div></div>' : '') +
48139
- (linkedNodes.length ? '<div class="detail-field"><label>Linked Entries (' + linkedNodes.length + ')</label><div class="detail-links">' + linkedNodes.map(k => '<span class="detail-link" onclick="selectEntryById(\\'' + k + '\\')">' + escHtml(k) + '</span>').join('') + '</div></div>' : '');
48127
+ (linkedNodes.length ? '<div class="detail-field"><label>Linked Entries (' + linkedNodes.length + ')</label><div class="detail-links">' + linkedNodes.map(k => '<span class="detail-link" data-id="' + escHtml(k) + '">' + escHtml(k) + '</span>').join('') + '</div></div>' : '');
48140
48128
  }
48141
48129
 
48142
48130
  window.selectEntryById = function(id) {
@@ -48144,6 +48132,16 @@ window.selectEntryById = function(id) {
48144
48132
  if (e) selectEntry(e);
48145
48133
  };
48146
48134
 
48135
+ // Delegated click handling for data-id elements (detail links, timeline) \u2014
48136
+ // avoids inline onclick handlers with interpolated entry data (XSS vector).
48137
+ document.addEventListener('click', function(ev) {
48138
+ const t = ev.target;
48139
+ const el = t && t.closest ? t.closest('[data-id]') : null;
48140
+ if (el && el.dataset.id) {
48141
+ window.selectEntryById(el.dataset.id);
48142
+ }
48143
+ });
48144
+
48147
48145
  // --- Stats ---
48148
48146
  function renderStats() {
48149
48147
  const grid = document.getElementById('statsGrid');
@@ -48162,7 +48160,7 @@ function renderStats() {
48162
48160
  card(3, '<h3>Max Access</h3><div class="stat-big">' + maxAccess + '</div>') +
48163
48161
  card(4, '<h3>Categories</h3><div class="bar-chart">' +
48164
48162
  catEntries.map(([cat, count]) =>
48165
- '<div class="bar-row"><span class="bar-label">' + cat + '</span><div class="bar-track"><div class="bar-fill" data-w="' + (count/maxCat*100) + '" style="background:' + (COLORS[cat] || 'var(--brand)') + '"></div></div><span class="bar-value">' + count + '</span></div>'
48163
+ '<div class="bar-row"><span class="bar-label">' + escHtml(cat) + '</span><div class="bar-track"><div class="bar-fill" data-w="' + (count/maxCat*100) + '" style="background:' + (COLORS[cat] || 'var(--brand)') + '"></div></div><span class="bar-value">' + count + '</span></div>'
48166
48164
  ).join('') +
48167
48165
  '</div>') +
48168
48166
  card(5, '<h3>Top Tags</h3><div class="tag-cloud">' +
@@ -48192,9 +48190,9 @@ function renderTimeline() {
48192
48190
  let idx = 0;
48193
48191
  for (const [date, entries] of Object.entries(grouped)) {
48194
48192
  for (const e of entries) {
48195
- html += '<div class="timeline-entry reveal" style="border-left:3px solid ' + (COLORS[e.category] || 'var(--border)') + ';animation-delay:' + Math.min(idx * 0.02, 0.6) + 's" onclick="selectEntryById(\\'' + e.id + '\\')">' +
48193
+ html += '<div class="timeline-entry reveal" style="border-left:3px solid ' + (COLORS[e.category] || 'var(--border)') + ';animation-delay:' + Math.min(idx * 0.02, 0.6) + 's" data-id="' + escHtml(e.id) + '">' +
48196
48194
  '<div class="tl-date">' + escHtml(date) + '</div>' +
48197
- '<div class="tl-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + e.category + '</div>' +
48195
+ '<div class="tl-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + escHtml(e.category) + '</div>' +
48198
48196
  '<div class="tl-key">' + escHtml(e.id) + '</div>' +
48199
48197
  '<div class="tl-content">' + escHtml(e.content.substring(0, 100)) + '</div>' +
48200
48198
  '</div>';
@@ -48727,7 +48725,7 @@ function registerResources(server2) {
48727
48725
 
48728
48726
  // src/mcp/server.ts
48729
48727
  var server = new McpServer(
48730
- { name: "toon-memory", version: "4.3.3" },
48728
+ { name: "toon-memory", version: "4.3.5" },
48731
48729
  { capabilities: { tools: { listChanged: true }, resources: { listChanged: true }, experimental: { "io.modelcontextprotocol/ui": {} } } }
48732
48730
  );
48733
48731
  var s = server.server;
@@ -48739,7 +48737,7 @@ s.setRequestHandler(InitializeRequestSchema, async (request) => {
48739
48737
  return {
48740
48738
  protocolVersion,
48741
48739
  capabilities: s.getCapabilities(),
48742
- serverInfo: { name: "toon-memory", version: "4.3.3" },
48740
+ serverInfo: { name: "toon-memory", version: "4.3.5" },
48743
48741
  ...s._instructions && { instructions: s._instructions }
48744
48742
  };
48745
48743
  });
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.3.3",
4
+ "version": "4.3.5",
5
5
  "description": "The Continuity Layer for AI Agents — an MCP memory server that preserves project knowledge, decisions, and conventions across sessions so every session starts where the last one ended. Offline, token-efficient, no LLM, no server; works with 20+ agents.",
6
6
  "type": "module",
7
7
  "bin": {
@@ -37,21 +37,23 @@
37
37
  "bench:retrieval": "node scripts/bench-retrieval.mjs"
38
38
  },
39
39
  "dependencies": {
40
- "@inquirer/prompts": "^8.5.2",
41
- "@modelcontextprotocol/ext-apps": "^1.7.5",
42
- "@modelcontextprotocol/sdk": "^1.30.0",
43
- "@toon-format/toon": "^2.3.0",
44
- "zod": "^4.4.3"
40
+ "@inquirer/checkbox": "^5.2.1",
41
+ "@inquirer/confirm": "^6.1.1",
42
+ "@inquirer/select": "^5.2.1"
45
43
  },
46
44
  "devDependencies": {
47
45
  "@mcp-ui/server": "^6.1.0",
46
+ "@modelcontextprotocol/ext-apps": "^1.7.5",
48
47
  "@modelcontextprotocol/inspector": "^2.0.0",
48
+ "@modelcontextprotocol/sdk": "^1.30.0",
49
+ "@toon-format/toon": "^2.3.0",
49
50
  "@types/node": "^26.1.1",
50
51
  "esbuild": "^0.25.0",
51
52
  "gpt-tokenizer": "^3.4.0",
52
53
  "playwright": "^1.62.0",
53
54
  "typescript": "^7.0.2",
54
- "vitest": "^4.1.10"
55
+ "vitest": "^4.1.10",
56
+ "zod": "^4.4.3"
55
57
  },
56
58
  "keywords": [
57
59
  "opencode",
@@ -1,6 +1,8 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, rmSync } from "fs"
2
2
  import { basename, dirname, join } from "path"
3
- import { checkbox, select, confirm } from "@inquirer/prompts"
3
+ import checkbox from "@inquirer/checkbox"
4
+ import select from "@inquirer/select"
5
+ import confirm from "@inquirer/confirm"
4
6
  import { extractProjectDeps } from "../lib/vocab"
5
7
  import type { Agent } from "./types"
6
8
  import { projectRoot, INSTRUCTION_CONTENT, ANTIGRAVITY_HOOK_NAME } from "./constants"
@@ -3,20 +3,6 @@ import { resolve, dirname } from "path"
3
3
  import { fileURLToPath } from "url"
4
4
  import { ViewerData } from "./types"
5
5
 
6
- const d3Src = (() => {
7
- try {
8
- const dir = dirname(fileURLToPath(import.meta.url))
9
- return readFileSync(resolve(dir, "../src/viewer/d3.v7.min.js"), "utf-8")
10
- } catch {
11
- try {
12
- const dir = dirname(fileURLToPath(import.meta.url))
13
- return readFileSync(resolve(dir, "d3.v7.min.js"), "utf-8")
14
- } catch {
15
- return null
16
- }
17
- }
18
- })()
19
-
20
6
  function readViewerAsset(name: string): string {
21
7
  const dir = dirname(fileURLToPath(import.meta.url))
22
8
  const candidates = [
@@ -33,6 +19,8 @@ function readViewerAsset(name: string): string {
33
19
  }
34
20
  return ""
35
21
  }
22
+
23
+ const d3Src = readViewerAsset("d3.v7.min.js")
36
24
  const logoSrc = readViewerAsset("logo.svg")
37
25
  const isologoSrc = readViewerAsset("logo-isologo.svg")
38
26
 
@@ -311,7 +299,7 @@ const tooltip = document.getElementById('tooltip');
311
299
  function showTooltip(e, d) {
312
300
  const score = d.quality || 0;
313
301
  tooltip.innerHTML =
314
- '<div class="tt-cat" style="color:' + (COLORS[d.category] || 'var(--muted)') + '">' + d.category + '</div>' +
302
+ '<div class="tt-cat" style="color:' + (COLORS[d.category] || 'var(--muted)') + '">' + escHtml(d.category) + '</div>' +
315
303
  '<div class="tt-key">' + escHtml(d.id) + '</div>' +
316
304
  '<div class="tt-content">' + escHtml(d.content) + '</div>' +
317
305
  '<div class="tt-score">Quality: ' + score.toFixed(2) + ' | Access: ' + (d.accessCount || 0) + '</div>';
@@ -401,7 +389,7 @@ function renderEntries() {
401
389
  div.className = 'entry-item' + (selectedEntry && selectedEntry.id === e.id ? ' selected' : '') + (firstEntriesRender ? ' reveal' : '');
402
390
  if (firstEntriesRender) div.style.animationDelay = Math.min(i * 0.03, 0.6) + 's';
403
391
  div.innerHTML =
404
- '<div class="entry-cat ' + e.category + '">' + e.category + '</div>' +
392
+ '<div class="entry-cat ' + escHtml(e.category) + '">' + escHtml(e.category) + '</div>' +
405
393
  '<div class="entry-key">' + escHtml(e.id) + '</div>' +
406
394
  '<div class="entry-preview">' + escHtml(e.content) + '</div>' +
407
395
  (e.tags.length ? '<div class="entry-tags">' + e.tags.map(t => '<span class="entry-tag">' + escHtml(t) + '</span>').join('') + '</div>' : '');
@@ -411,7 +399,7 @@ function renderEntries() {
411
399
  firstEntriesRender = false;
412
400
  }
413
401
 
414
- function escHtml(s) { return s.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); }
402
+ function escHtml(s) { return String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;'); }
415
403
 
416
404
  // --- Entry Selection ---
417
405
  function selectEntry(entry) {
@@ -430,17 +418,17 @@ function showDetail(e) {
430
418
  .map(ed => (typeof ed.source === 'object' ? ed.source.id : ed.source) === e.id ? (typeof ed.target === 'object' ? ed.target.id : ed.target) : (typeof ed.source === 'object' ? ed.source.id : ed.source));
431
419
 
432
420
  panel.innerHTML =
433
- '<div class="detail-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + e.category + '</div>' +
421
+ '<div class="detail-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + escHtml(e.category) + '</div>' +
434
422
  '<h2>' + escHtml(e.id) + '</h2>' +
435
423
  '<div class="detail-field"><label>Content</label><span class="value mono">' + escHtml(e.content) + '</span></div>' +
436
424
  (e.file ? '<div class="detail-field"><label>File</label><span class="value mono"><a href="#" onclick="event.preventDefault()" style="color:var(--brand);text-decoration:none;cursor:pointer">' + escHtml(e.file) + '</a></span></div>' : '') +
437
- (e.date ? '<div class="detail-field"><label>Date</label><span class="value">' + e.date + '</span></div>' : '') +
425
+ (e.date ? '<div class="detail-field"><label>Date</label><span class="value">' + escHtml(e.date) + '</span></div>' : '') +
438
426
  '<div class="detail-field"><label>Quality Score</label><span class="value" style="color:var(--brand);font-weight:700;font-size:1.1rem">' + (e.quality || 0).toFixed(3) + '</span></div>' +
439
427
  '<div class="detail-field"><label>Access Count</label><span class="value">' + (e.accessCount || 0) + '</span></div>' +
440
- (e.ttl ? '<div class="detail-field"><label>TTL</label><span class="value">' + e.ttl + '</span></div>' : '') +
441
- (e.lastAccessed ? '<div class="detail-field"><label>Last Accessed</label><span class="value">' + e.lastAccessed + '</span></div>' : '') +
428
+ (e.ttl ? '<div class="detail-field"><label>TTL</label><span class="value">' + escHtml(e.ttl) + '</span></div>' : '') +
429
+ (e.lastAccessed ? '<div class="detail-field"><label>Last Accessed</label><span class="value">' + escHtml(e.lastAccessed) + '</span></div>' : '') +
442
430
  (e.tags.length ? '<div class="detail-field"><label>Tags</label><div class="entry-tags">' + e.tags.map(t => '<span class="entry-tag">' + escHtml(t) + '</span>').join('') + '</div></div>' : '') +
443
- (linkedNodes.length ? '<div class="detail-field"><label>Linked Entries (' + linkedNodes.length + ')</label><div class="detail-links">' + linkedNodes.map(k => '<span class="detail-link" onclick="selectEntryById(\\'' + k + '\\')">' + escHtml(k) + '</span>').join('') + '</div></div>' : '');
431
+ (linkedNodes.length ? '<div class="detail-field"><label>Linked Entries (' + linkedNodes.length + ')</label><div class="detail-links">' + linkedNodes.map(k => '<span class="detail-link" data-id="' + escHtml(k) + '">' + escHtml(k) + '</span>').join('') + '</div></div>' : '');
444
432
  }
445
433
 
446
434
  window.selectEntryById = function(id) {
@@ -448,6 +436,16 @@ window.selectEntryById = function(id) {
448
436
  if (e) selectEntry(e);
449
437
  };
450
438
 
439
+ // Delegated click handling for data-id elements (detail links, timeline) —
440
+ // avoids inline onclick handlers with interpolated entry data (XSS vector).
441
+ document.addEventListener('click', function(ev) {
442
+ const t = ev.target;
443
+ const el = t && t.closest ? t.closest('[data-id]') : null;
444
+ if (el && el.dataset.id) {
445
+ window.selectEntryById(el.dataset.id);
446
+ }
447
+ });
448
+
451
449
  // --- Stats ---
452
450
  function renderStats() {
453
451
  const grid = document.getElementById('statsGrid');
@@ -466,7 +464,7 @@ function renderStats() {
466
464
  card(3, '<h3>Max Access</h3><div class="stat-big">' + maxAccess + '</div>') +
467
465
  card(4, '<h3>Categories</h3><div class="bar-chart">' +
468
466
  catEntries.map(([cat, count]) =>
469
- '<div class="bar-row"><span class="bar-label">' + cat + '</span><div class="bar-track"><div class="bar-fill" data-w="' + (count/maxCat*100) + '" style="background:' + (COLORS[cat] || 'var(--brand)') + '"></div></div><span class="bar-value">' + count + '</span></div>'
467
+ '<div class="bar-row"><span class="bar-label">' + escHtml(cat) + '</span><div class="bar-track"><div class="bar-fill" data-w="' + (count/maxCat*100) + '" style="background:' + (COLORS[cat] || 'var(--brand)') + '"></div></div><span class="bar-value">' + count + '</span></div>'
470
468
  ).join('') +
471
469
  '</div>') +
472
470
  card(5, '<h3>Top Tags</h3><div class="tag-cloud">' +
@@ -496,9 +494,9 @@ function renderTimeline() {
496
494
  let idx = 0;
497
495
  for (const [date, entries] of Object.entries(grouped)) {
498
496
  for (const e of entries) {
499
- html += '<div class="timeline-entry reveal" style="border-left:3px solid ' + (COLORS[e.category] || 'var(--border)') + ';animation-delay:' + Math.min(idx * 0.02, 0.6) + 's" onclick="selectEntryById(\\'' + e.id + '\\')">' +
497
+ html += '<div class="timeline-entry reveal" style="border-left:3px solid ' + (COLORS[e.category] || 'var(--border)') + ';animation-delay:' + Math.min(idx * 0.02, 0.6) + 's" data-id="' + escHtml(e.id) + '">' +
500
498
  '<div class="tl-date">' + escHtml(date) + '</div>' +
501
- '<div class="tl-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + e.category + '</div>' +
499
+ '<div class="tl-cat" style="color:' + (COLORS[e.category] || 'var(--muted)') + '">' + escHtml(e.category) + '</div>' +
502
500
  '<div class="tl-key">' + escHtml(e.id) + '</div>' +
503
501
  '<div class="tl-content">' + escHtml(e.content.substring(0, 100)) + '</div>' +
504
502
  '</div>';
@@ -1,6 +1,6 @@
1
1
  import { writeFileSync, mkdirSync } from "fs"
2
2
  import { join } from "path"
3
- import { execSync } from "child_process"
3
+ import { spawn } from "child_process"
4
4
  import { buildViewerData } from "./data"
5
5
  import { generateHtml } from "./html"
6
6
  import { createServer, type IncomingMessage, type ServerResponse } from "http"
@@ -9,13 +9,13 @@ export { buildViewerData } from "./data"
9
9
 
10
10
  function openBrowser(url: string): void {
11
11
  const platform = process.platform
12
- try {
13
- if (platform === "darwin") execSync(`open "${url}"`)
14
- else if (platform === "win32") execSync(`start "" "${url}"`)
15
- else execSync(`xdg-open "${url}" || sensible-browser "${url}" || x-www-browser "${url}"`, { stdio: "ignore" })
16
- } catch {
17
- console.log(`Open in browser: ${url}`)
18
- }
12
+ const opts = { stdio: "ignore" as const, detached: true }
13
+ const child =
14
+ platform === "darwin" ? spawn("open", [url], opts)
15
+ : platform === "win32" ? spawn("cmd", ["/c", "start", "", url], opts)
16
+ : spawn("xdg-open", [url], opts)
17
+ child.unref()
18
+ child.on("error", () => console.log(`Open in browser: ${url}`))
19
19
  }
20
20
 
21
21
  function resolvePort(portArg?: string): number {