toon-memory 3.2.0 → 3.3.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.md +6 -0
- package/dist/cli/setup.js +50 -8
- package/mcp/server.js +44858 -29673
- package/package.json +5 -2
- package/src/cli/constants.ts +4 -0
- package/src/mcp/prompts.ts +1 -1
- package/src/mcp/resources.ts +21 -2
- package/src/mcp/server.ts +22 -3
- package/src/mcp/tools.ts +31 -1
- package/src/viewer/d3.v7.min.js +2 -0
- package/src/viewer/data.ts +1 -2
- package/src/viewer/html.ts +48 -6
package/README.md
CHANGED
|
@@ -706,6 +706,8 @@ On `toon-memory init`, the CLI scans your dependency manifests and writes a `voc
|
|
|
706
706
|
|
|
707
707
|
Visualize your memory as an interactive force-directed graph. See entries, their connections, categories, and access patterns at a glance.
|
|
708
708
|
|
|
709
|
+
### CLI viewer (standalone HTTP server)
|
|
710
|
+
|
|
709
711
|
```bash
|
|
710
712
|
npx toon-memory viewer # Start HTTP server + open browser
|
|
711
713
|
npx toon-memory viewer --port 3001 # Custom port
|
|
@@ -714,6 +716,10 @@ npx toon-memory viewer --export # Save as static HTML
|
|
|
714
716
|
|
|
715
717
|
Once open, press `r` in the terminal to reload from disk, or `r` / ↻ in the browser to refresh the page.
|
|
716
718
|
|
|
719
|
+
### Inline viewer (MCP Apps)
|
|
720
|
+
|
|
721
|
+
Call `memory_visualize` in any MCP Apps–compatible host to render the graph inline — no server needed. The viewer appears as an interactive panel inside the chat interface.
|
|
722
|
+
|
|
717
723
|
### Features
|
|
718
724
|
|
|
719
725
|
| Interaction | Description |
|
package/dist/cli/setup.js
CHANGED
|
@@ -19,6 +19,9 @@ Persistent memory for this project. Use it to avoid re-investigating things.
|
|
|
19
19
|
1. Run memory_stats to see what's in memory.
|
|
20
20
|
2. If the user asks something that might be in memory, run memory_recall BEFORE reading files.
|
|
21
21
|
|
|
22
|
+
## When asked to see the memory graph
|
|
23
|
+
- Call memory_visualize() to open the interactive graph viewer inline.
|
|
24
|
+
|
|
22
25
|
## When making decisions
|
|
23
26
|
- Before implementing a non-trivial change: memory_remember(category='decision')
|
|
24
27
|
- When you resolve a complex bug: memory_remember(category='bug')
|
|
@@ -30,6 +33,7 @@ Persistent memory for this project. Use it to avoid re-investigating things.
|
|
|
30
33
|
var OPENCODE_PASSIVE_INSTRUCTION = `# toon-memory
|
|
31
34
|
|
|
32
35
|
Memory auto-injects via .opencode/instructions/memory-autoload.md; use memory_recall only as fallback.
|
|
36
|
+
When the user asks to see the memory graph, call memory_visualize().
|
|
33
37
|
`;
|
|
34
38
|
|
|
35
39
|
// src/cli/capture-toggle.ts
|
|
@@ -1618,8 +1622,7 @@ function buildViewerData() {
|
|
|
1618
1622
|
const data = readMemory();
|
|
1619
1623
|
const entries = parseEntries(data);
|
|
1620
1624
|
if (entries.length === 0) {
|
|
1621
|
-
|
|
1622
|
-
process.exit(0);
|
|
1625
|
+
return { nodes: [], edges: [], categories: {}, tagCounts: {}, totalEntries: 0 };
|
|
1623
1626
|
}
|
|
1624
1627
|
const graph = buildGraph(entries);
|
|
1625
1628
|
const nodes = entries.map((e) => ({
|
|
@@ -1656,15 +1659,33 @@ function buildViewerData() {
|
|
|
1656
1659
|
}
|
|
1657
1660
|
|
|
1658
1661
|
// src/viewer/html.ts
|
|
1662
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
1663
|
+
import { resolve, dirname as dirname8 } from "path";
|
|
1664
|
+
import { fileURLToPath } from "url";
|
|
1665
|
+
var d3Src = (() => {
|
|
1666
|
+
try {
|
|
1667
|
+
const dir = dirname8(fileURLToPath(import.meta.url));
|
|
1668
|
+
return readFileSync13(resolve(dir, "../src/viewer/d3.v7.min.js"), "utf-8");
|
|
1669
|
+
} catch {
|
|
1670
|
+
try {
|
|
1671
|
+
const dir = dirname8(fileURLToPath(import.meta.url));
|
|
1672
|
+
return readFileSync13(resolve(dir, "d3.v7.min.js"), "utf-8");
|
|
1673
|
+
} catch {
|
|
1674
|
+
return null;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
})();
|
|
1659
1678
|
function generateHtml(viewerData) {
|
|
1660
1679
|
const jsonData = JSON.stringify(viewerData);
|
|
1680
|
+
const d3Tag = d3Src ? `<script>${d3Src}</script>` : `<script src="https://d3js.org/d3.v7.min.js"></script>`;
|
|
1661
1681
|
return `<!DOCTYPE html>
|
|
1662
1682
|
<html lang="en">
|
|
1663
1683
|
<head>
|
|
1664
1684
|
<meta charset="UTF-8">
|
|
1665
1685
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1666
1686
|
<title>toon-memory viewer</title>
|
|
1667
|
-
<script
|
|
1687
|
+
<script>window.__MCP_UI__=window.__MCP_UI__||{invoke:()=>Promise.resolve({})}</script>
|
|
1688
|
+
${d3Tag}
|
|
1668
1689
|
<style>
|
|
1669
1690
|
*{box-sizing:border-box;margin:0;padding:0}
|
|
1670
1691
|
:root{
|
|
@@ -1674,7 +1695,7 @@ function generateHtml(viewerData) {
|
|
|
1674
1695
|
--pink:#ec4899;--cyan:#06b6d4;
|
|
1675
1696
|
}
|
|
1676
1697
|
html,body{height:100%;font-family:system-ui,-apple-system,sans-serif;background:var(--bg);color:var(--text);overflow:hidden}
|
|
1677
|
-
.app{display:grid;grid-template-rows:auto 1fr;height:
|
|
1698
|
+
.app{display:grid;grid-template-rows:auto 1fr;height:100%}
|
|
1678
1699
|
header{display:flex;align-items:center;justify-content:space-between;padding:0.75rem 1.5rem;border-bottom:1px solid var(--border);background:var(--bg2)}
|
|
1679
1700
|
header h1{font-size:1.1rem;font-weight:700;background:linear-gradient(135deg,var(--brand),var(--pink));-webkit-background-clip:text;-webkit-text-fill-color:transparent}
|
|
1680
1701
|
header .meta{display:flex;gap:1rem;font-size:0.8rem;color:var(--muted)}
|
|
@@ -1712,7 +1733,7 @@ header .meta span{display:flex;align-items:center;gap:0.3rem}
|
|
|
1712
1733
|
.tab-content{flex:1;overflow:hidden;position:relative}
|
|
1713
1734
|
.tab-panel{display:none;width:100%;height:100%;overflow:auto}
|
|
1714
1735
|
.tab-panel.active{display:block}
|
|
1715
|
-
.graph-container{width:100%;height:100%;background:var(--bg);position:relative}
|
|
1736
|
+
.graph-container{width:100%;height:100%;min-height:300px;background:var(--bg);position:relative}
|
|
1716
1737
|
.graph-container::before{content:'';position:absolute;inset:0;background-image:radial-gradient(var(--border) 1px,transparent 1px);background-size:24px 24px;opacity:0.3;pointer-events:none;z-index:0}
|
|
1717
1738
|
.graph-container svg{width:100%;height:100%;position:relative;z-index:1}
|
|
1718
1739
|
.node-circle{cursor:pointer;transition:r 0.2s ease,opacity 0.2s ease,filter 0.2s ease,stroke 0.2s ease}
|
|
@@ -2100,8 +2121,11 @@ function renderTimeline() {
|
|
|
2100
2121
|
// --- Graph ---
|
|
2101
2122
|
const graph = (function() {
|
|
2102
2123
|
const container = document.getElementById('graphContainer');
|
|
2103
|
-
|
|
2104
|
-
const
|
|
2124
|
+
let _impl = null;
|
|
2125
|
+
const safe = (name, ...args) => { if (_impl && _impl[name]) return _impl[name](...args); };
|
|
2126
|
+
const initGraph = () => {
|
|
2127
|
+
const width = Math.max(container.clientWidth, 400);
|
|
2128
|
+
const height = Math.max(container.clientHeight, 300);
|
|
2105
2129
|
const svg = d3.select(container).append('svg').attr('width', '100%').attr('height', '100%');
|
|
2106
2130
|
|
|
2107
2131
|
const defs = svg.append('defs');
|
|
@@ -2475,12 +2499,25 @@ const graph = (function() {
|
|
|
2475
2499
|
selectEntry(d); hideTooltip();
|
|
2476
2500
|
});
|
|
2477
2501
|
|
|
2478
|
-
|
|
2502
|
+
_impl = { highlightNode, highlightSearch, centerOn, resize: () => {
|
|
2479
2503
|
const w = container.clientWidth;
|
|
2480
2504
|
const h = container.clientHeight;
|
|
2481
2505
|
simulation.force('center', d3.forceCenter(w / 2, h / 2).strength(centerStrength));
|
|
2482
2506
|
simulation.alpha(0.3).restart();
|
|
2483
2507
|
}};
|
|
2508
|
+
};
|
|
2509
|
+
if (container.clientWidth > 0 && container.clientHeight > 0) {
|
|
2510
|
+
initGraph();
|
|
2511
|
+
} else {
|
|
2512
|
+
const ro = new ResizeObserver(() => {
|
|
2513
|
+
if (container.clientWidth > 0 && container.clientHeight > 0) {
|
|
2514
|
+
ro.disconnect();
|
|
2515
|
+
initGraph();
|
|
2516
|
+
}
|
|
2517
|
+
});
|
|
2518
|
+
ro.observe(container);
|
|
2519
|
+
}
|
|
2520
|
+
return { highlightNode: (...a) => safe('highlightNode', ...a), highlightSearch: (...a) => safe('highlightSearch', ...a), centerOn: (...a) => safe('centerOn', ...a), resize: (...a) => safe('resize', ...a) };
|
|
2484
2521
|
})();
|
|
2485
2522
|
|
|
2486
2523
|
// --- Keyboard Shortcuts ---
|
|
@@ -2529,6 +2566,11 @@ document.getElementById('reloadBtn').addEventListener('click', () => location.re
|
|
|
2529
2566
|
document.addEventListener('keydown', (e) => {
|
|
2530
2567
|
if (e.key === 'r' && !e.metaKey && !e.ctrlKey && !e.target.closest('input,textarea')) location.reload();
|
|
2531
2568
|
});
|
|
2569
|
+
|
|
2570
|
+
// MCP Apps: expose a global so the host can detect the viewer is ready
|
|
2571
|
+
if (window.parent !== window) {
|
|
2572
|
+
console.log('toon-memory viewer running in MCP Apps iframe');
|
|
2573
|
+
}
|
|
2532
2574
|
</script>
|
|
2533
2575
|
</body>
|
|
2534
2576
|
</html>`;
|