toon-memory 4.1.0 → 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/bin/toon-memory.js +1 -0
- package/dist/cli/setup.js +54 -13
- package/mcp/server.js +27 -7
- package/package.json +1 -1
- package/src/bin/toon-memory.ts +1 -0
- package/src/cli/setup.ts +26 -1
- package/src/lib/context.ts +30 -6
- package/src/lib/graph.ts +1 -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
|
@@ -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
|
-
|
|
33806
|
-
|
|
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
|
-
|
|
34094
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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": {
|
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/lib/context.ts
CHANGED
|
@@ -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
|
-
|
|
180
|
-
|
|
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
|
-
|
|
615
|
-
|
|
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
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 {
|