toon-memory 3.7.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/README.de.md +3 -5
- package/README.es.md +5 -7
- package/README.fr.md +3 -5
- package/README.ja.md +3 -5
- package/README.ko.md +3 -5
- package/README.md +22 -12
- package/README.pt-br.md +3 -5
- package/README.zh.md +3 -5
- package/bin/toon-memory.js +1 -0
- package/dist/cli/capture.js +49 -1
- package/dist/cli/session-start.js +49 -1
- package/dist/cli/setup.js +187 -19
- package/mcp/server.js +584 -498
- package/package.json +4 -3
- package/skills/toon-memory.md +2 -4
- package/src/bin/toon-memory.ts +1 -0
- package/src/cli/capture.ts +2 -1
- package/src/cli/commands.ts +4 -3
- package/src/cli/memory.ts +3 -2
- package/src/cli/session-start.ts +2 -1
- package/src/cli/setup.ts +26 -1
- package/src/lib/graph.ts +101 -8
- package/src/lib/quality.ts +8 -8
- package/src/lib/utils.ts +81 -5
- package/src/mcp/archive.ts +3 -2
- package/src/mcp/consolidation.ts +5 -4
- package/src/mcp/observations.ts +2 -1
- package/src/mcp/resources.ts +2 -1
- package/src/mcp/scoring.ts +5 -5
- package/src/mcp/session-store.ts +10 -9
- package/src/mcp/tools.ts +468 -544
- package/src/viewer/index.ts +34 -13
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 {
|