toon-memory 4.1.0 → 4.1.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/bin/toon-memory.js +1 -0
- package/dist/cli/setup.js +54 -13
- package/mcp/server.js +2 -2
- package/package.json +1 -1
- package/src/bin/toon-memory.ts +1 -0
- package/src/cli/setup.ts +26 -1
- package/src/viewer/index.ts +34 -13
package/bin/toon-memory.js
CHANGED
|
@@ -28,6 +28,7 @@ Commands:
|
|
|
28
28
|
export [file] Export memory to a TOON/JSON file
|
|
29
29
|
import <file> Import memory from a TOON/JSON file
|
|
30
30
|
watch Watch memory file and re-render on change
|
|
31
|
+
viewer [--port <n>] Open the interactive graph viewer in a browser (auto-picks a free port)
|
|
31
32
|
uninstall Remove toon-memory from all agents
|
|
32
33
|
capture <on|off> Enable/disable activity capture hooks
|
|
33
34
|
upgrade Upgrade to the latest version
|
package/dist/cli/setup.js
CHANGED
|
@@ -2759,15 +2759,40 @@ function openBrowser(url) {
|
|
|
2759
2759
|
console.log(`Open in browser: ${url}`);
|
|
2760
2760
|
}
|
|
2761
2761
|
}
|
|
2762
|
+
function resolvePort(portArg) {
|
|
2763
|
+
const raw = portArg ?? process.env.PORT;
|
|
2764
|
+
if (raw === void 0 || raw === "") return 3e3;
|
|
2765
|
+
const port = Number(raw);
|
|
2766
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
2767
|
+
console.error(`Invalid port: '${raw}'. Expected an integer between 1 and 65535.`);
|
|
2768
|
+
process.exit(1);
|
|
2769
|
+
}
|
|
2770
|
+
return port;
|
|
2771
|
+
}
|
|
2772
|
+
var MAX_PORT_ATTEMPTS = 20;
|
|
2762
2773
|
function viewer(portArg) {
|
|
2763
|
-
const
|
|
2774
|
+
const startPort = resolvePort(portArg);
|
|
2775
|
+
let port = startPort;
|
|
2764
2776
|
let currentHtml = generateHtml(buildViewerData());
|
|
2765
2777
|
const server = createServer((_req, res) => {
|
|
2766
2778
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
2767
2779
|
res.end(currentHtml);
|
|
2768
2780
|
});
|
|
2769
|
-
server.
|
|
2770
|
-
|
|
2781
|
+
server.on("error", (err) => {
|
|
2782
|
+
if (err.code === "EADDRINUSE" && port < startPort + MAX_PORT_ATTEMPTS) {
|
|
2783
|
+
port += 1;
|
|
2784
|
+
console.log(`Port ${port - 1} in use, trying ${port}...`);
|
|
2785
|
+
server.listen(port, "127.0.0.1", onListen);
|
|
2786
|
+
} else if (err.code === "EADDRINUSE") {
|
|
2787
|
+
console.error(`Port ${port} already in use. Try: toon-memory viewer --port ${port + 1} (or PORT=${port + 1} toon-memory viewer)`);
|
|
2788
|
+
process.exit(1);
|
|
2789
|
+
} else {
|
|
2790
|
+
console.error(`Server error: ${err.message}`);
|
|
2791
|
+
process.exit(1);
|
|
2792
|
+
}
|
|
2793
|
+
});
|
|
2794
|
+
function onListen() {
|
|
2795
|
+
const url = `http://127.0.0.1:${port}`;
|
|
2771
2796
|
const data = buildViewerData();
|
|
2772
2797
|
console.log(`
|
|
2773
2798
|
toon-memory viewer`);
|
|
@@ -2776,7 +2801,8 @@ toon-memory viewer`);
|
|
|
2776
2801
|
console.log(` Press 'r' in terminal to reload | Ctrl+C to stop
|
|
2777
2802
|
`);
|
|
2778
2803
|
openBrowser(url);
|
|
2779
|
-
}
|
|
2804
|
+
}
|
|
2805
|
+
server.listen(startPort, "127.0.0.1", onListen);
|
|
2780
2806
|
if (process.stdin.isTTY) {
|
|
2781
2807
|
process.stdin.setRawMode?.(true);
|
|
2782
2808
|
process.stdin.resume();
|
|
@@ -2790,14 +2816,6 @@ toon-memory viewer`);
|
|
|
2790
2816
|
if (key === "") process.exit(0);
|
|
2791
2817
|
});
|
|
2792
2818
|
}
|
|
2793
|
-
server.on("error", (err) => {
|
|
2794
|
-
if (err.code === "EADDRINUSE") {
|
|
2795
|
-
console.error(`Port ${PORT} already in use. Try: PORT=3001 toon-memory viewer`);
|
|
2796
|
-
} else {
|
|
2797
|
-
console.error(`Server error: ${err.message}`);
|
|
2798
|
-
}
|
|
2799
|
-
process.exit(1);
|
|
2800
|
-
});
|
|
2801
2819
|
}
|
|
2802
2820
|
function viewerExport() {
|
|
2803
2821
|
const viewerData = buildViewerData();
|
|
@@ -2823,6 +2841,10 @@ if (args[0] === "uninstall") {
|
|
|
2823
2841
|
process.exit(0);
|
|
2824
2842
|
}
|
|
2825
2843
|
if (args[0] === "init") {
|
|
2844
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
2845
|
+
printUsage();
|
|
2846
|
+
process.exit(0);
|
|
2847
|
+
}
|
|
2826
2848
|
const rest = args.slice(1);
|
|
2827
2849
|
const agentNames = [];
|
|
2828
2850
|
let scope;
|
|
@@ -2873,9 +2895,19 @@ if (args[0] === "watch") {
|
|
|
2873
2895
|
process.exit(0);
|
|
2874
2896
|
}
|
|
2875
2897
|
if (args[0] === "viewer") {
|
|
2898
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
2899
|
+
printViewerUsage();
|
|
2900
|
+
process.exit(0);
|
|
2901
|
+
}
|
|
2876
2902
|
const portIdx = args.indexOf("--port");
|
|
2877
|
-
|
|
2903
|
+
if (portIdx !== -1 && !args[portIdx + 1]) {
|
|
2904
|
+
console.error("Missing value for --port\n");
|
|
2905
|
+
printViewerUsage();
|
|
2906
|
+
process.exit(1);
|
|
2907
|
+
}
|
|
2908
|
+
const port = portIdx !== -1 ? args[portIdx + 1] : void 0;
|
|
2878
2909
|
if (args.includes("--export")) {
|
|
2910
|
+
if (port) console.log("Note: --port is ignored with --export");
|
|
2879
2911
|
viewerExport();
|
|
2880
2912
|
} else {
|
|
2881
2913
|
viewer(port);
|
|
@@ -2889,6 +2921,15 @@ if (args[0] === "viewer") {
|
|
|
2889
2921
|
printUsage();
|
|
2890
2922
|
process.exit(1);
|
|
2891
2923
|
}
|
|
2924
|
+
function printViewerUsage() {
|
|
2925
|
+
console.log(`Usage: toon-memory viewer [options]
|
|
2926
|
+
Options:
|
|
2927
|
+
--export Save a static HTML viewer to .toon-memory/viewer/index.html
|
|
2928
|
+
--port <n> Port to serve on (default: 3000, or $PORT)
|
|
2929
|
+
-h, --help Show this help
|
|
2930
|
+
|
|
2931
|
+
Press 'r' in the terminal while serving to reload the graph.`);
|
|
2932
|
+
}
|
|
2892
2933
|
function printUsage() {
|
|
2893
2934
|
console.log(`Usage: toon-memory <command> [options]
|
|
2894
2935
|
Commands: init, status, stats, export, import, watch, viewer, uninstall, capture, upgrade, mcp
|
package/mcp/server.js
CHANGED
|
@@ -47939,7 +47939,7 @@ function registerResources(server2) {
|
|
|
47939
47939
|
|
|
47940
47940
|
// src/mcp/server.ts
|
|
47941
47941
|
var server = new McpServer(
|
|
47942
|
-
{ name: "toon-memory", version: "4.1.
|
|
47942
|
+
{ name: "toon-memory", version: "4.1.1" },
|
|
47943
47943
|
{ capabilities: { tools: { listChanged: true }, resources: { listChanged: true }, experimental: { "io.modelcontextprotocol/ui": {} } } }
|
|
47944
47944
|
);
|
|
47945
47945
|
var s = server.server;
|
|
@@ -47951,7 +47951,7 @@ s.setRequestHandler(InitializeRequestSchema, async (request) => {
|
|
|
47951
47951
|
return {
|
|
47952
47952
|
protocolVersion,
|
|
47953
47953
|
capabilities: s.getCapabilities(),
|
|
47954
|
-
serverInfo: { name: "toon-memory", version: "4.1.
|
|
47954
|
+
serverInfo: { name: "toon-memory", version: "4.1.1" },
|
|
47955
47955
|
...s._instructions && { instructions: s._instructions }
|
|
47956
47956
|
};
|
|
47957
47957
|
});
|
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.
|
|
4
|
+
"version": "4.1.1",
|
|
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": {
|
package/src/bin/toon-memory.ts
CHANGED
|
@@ -31,6 +31,7 @@ Commands:
|
|
|
31
31
|
export [file] Export memory to a TOON/JSON file
|
|
32
32
|
import <file> Import memory from a TOON/JSON file
|
|
33
33
|
watch Watch memory file and re-render on change
|
|
34
|
+
viewer [--port <n>] Open the interactive graph viewer in a browser (auto-picks a free port)
|
|
34
35
|
uninstall Remove toon-memory from all agents
|
|
35
36
|
capture <on|off> Enable/disable activity capture hooks
|
|
36
37
|
upgrade Upgrade to the latest version
|
package/src/cli/setup.ts
CHANGED
|
@@ -16,6 +16,10 @@ if (args[0] === "uninstall") {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
if (args[0] === "init") {
|
|
19
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
20
|
+
printUsage()
|
|
21
|
+
process.exit(0)
|
|
22
|
+
}
|
|
19
23
|
const rest = args.slice(1)
|
|
20
24
|
const agentNames: string[] = []
|
|
21
25
|
let scope: string | undefined
|
|
@@ -74,9 +78,19 @@ if (args[0] === "watch") {
|
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
if (args[0] === "viewer") {
|
|
81
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
82
|
+
printViewerUsage()
|
|
83
|
+
process.exit(0)
|
|
84
|
+
}
|
|
77
85
|
const portIdx = args.indexOf("--port")
|
|
78
|
-
|
|
86
|
+
if (portIdx !== -1 && !args[portIdx + 1]) {
|
|
87
|
+
console.error("Missing value for --port\n")
|
|
88
|
+
printViewerUsage()
|
|
89
|
+
process.exit(1)
|
|
90
|
+
}
|
|
91
|
+
const port = portIdx !== -1 ? args[portIdx + 1] : undefined
|
|
79
92
|
if (args.includes("--export")) {
|
|
93
|
+
if (port) console.log("Note: --port is ignored with --export")
|
|
80
94
|
viewerExport()
|
|
81
95
|
} else {
|
|
82
96
|
viewer(port)
|
|
@@ -90,6 +104,17 @@ if (args[0] === "viewer") {
|
|
|
90
104
|
process.exit(1)
|
|
91
105
|
}
|
|
92
106
|
|
|
107
|
+
/** Viewer-specific usage. */
|
|
108
|
+
function printViewerUsage(): void {
|
|
109
|
+
console.log(`Usage: toon-memory viewer [options]
|
|
110
|
+
Options:
|
|
111
|
+
--export Save a static HTML viewer to .toon-memory/viewer/index.html
|
|
112
|
+
--port <n> Port to serve on (default: 3000, or $PORT)
|
|
113
|
+
-h, --help Show this help
|
|
114
|
+
|
|
115
|
+
Press 'r' in the terminal while serving to reload the graph.`)
|
|
116
|
+
}
|
|
117
|
+
|
|
93
118
|
/** Minimal usage string for unknown commands. */
|
|
94
119
|
function printUsage(): void {
|
|
95
120
|
console.log(`Usage: toon-memory <command> [options]
|
package/src/viewer/index.ts
CHANGED
|
@@ -18,8 +18,22 @@ function openBrowser(url: string): void {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
function resolvePort(portArg?: string): number {
|
|
22
|
+
const raw = portArg ?? process.env.PORT
|
|
23
|
+
if (raw === undefined || raw === "") return 3000
|
|
24
|
+
const port = Number(raw)
|
|
25
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
26
|
+
console.error(`Invalid port: '${raw}'. Expected an integer between 1 and 65535.`)
|
|
27
|
+
process.exit(1)
|
|
28
|
+
}
|
|
29
|
+
return port
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const MAX_PORT_ATTEMPTS = 20
|
|
33
|
+
|
|
21
34
|
export function viewer(portArg?: string): void {
|
|
22
|
-
const
|
|
35
|
+
const startPort = resolvePort(portArg)
|
|
36
|
+
let port = startPort
|
|
23
37
|
let currentHtml = generateHtml(buildViewerData())
|
|
24
38
|
|
|
25
39
|
const server = createServer((_req: IncomingMessage, res: ServerResponse) => {
|
|
@@ -27,15 +41,31 @@ export function viewer(portArg?: string): void {
|
|
|
27
41
|
res.end(currentHtml)
|
|
28
42
|
})
|
|
29
43
|
|
|
30
|
-
server.
|
|
31
|
-
|
|
44
|
+
server.on("error", (err: NodeJS.ErrnoException) => {
|
|
45
|
+
if (err.code === "EADDRINUSE" && port < startPort + MAX_PORT_ATTEMPTS) {
|
|
46
|
+
port += 1
|
|
47
|
+
console.log(`Port ${port - 1} in use, trying ${port}...`)
|
|
48
|
+
server.listen(port, "127.0.0.1", onListen)
|
|
49
|
+
} else if (err.code === "EADDRINUSE") {
|
|
50
|
+
console.error(`Port ${port} already in use. Try: toon-memory viewer --port ${port + 1} (or PORT=${port + 1} toon-memory viewer)`)
|
|
51
|
+
process.exit(1)
|
|
52
|
+
} else {
|
|
53
|
+
console.error(`Server error: ${err.message}`)
|
|
54
|
+
process.exit(1)
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
function onListen(): void {
|
|
59
|
+
const url = `http://127.0.0.1:${port}`
|
|
32
60
|
const data = buildViewerData()
|
|
33
61
|
console.log(`\ntoon-memory viewer`)
|
|
34
62
|
console.log(` Entries: ${data.totalEntries} | Edges: ${data.edges.length}`)
|
|
35
63
|
console.log(` Serving at: ${url}`)
|
|
36
64
|
console.log(` Press 'r' in terminal to reload | Ctrl+C to stop\n`)
|
|
37
65
|
openBrowser(url)
|
|
38
|
-
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
server.listen(startPort, "127.0.0.1", onListen)
|
|
39
69
|
|
|
40
70
|
if (process.stdin.isTTY) {
|
|
41
71
|
process.stdin.setRawMode?.(true)
|
|
@@ -50,15 +80,6 @@ export function viewer(portArg?: string): void {
|
|
|
50
80
|
if (key === "\u0003") process.exit(0)
|
|
51
81
|
})
|
|
52
82
|
}
|
|
53
|
-
|
|
54
|
-
server.on("error", (err: NodeJS.ErrnoException) => {
|
|
55
|
-
if (err.code === "EADDRINUSE") {
|
|
56
|
-
console.error(`Port ${PORT} already in use. Try: PORT=3001 toon-memory viewer`)
|
|
57
|
-
} else {
|
|
58
|
-
console.error(`Server error: ${err.message}`)
|
|
59
|
-
}
|
|
60
|
-
process.exit(1)
|
|
61
|
-
})
|
|
62
83
|
}
|
|
63
84
|
|
|
64
85
|
export function viewerExport(): void {
|