toon-memory 2.4.1 → 2.4.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/dist/cli/capture.js +18 -8
- package/dist/cli/session-start.js +18 -8
- package/mcp/server.js +19 -9
- package/package.json +1 -1
- package/src/lib/sessions.ts +20 -8
- package/src/mcp/server.ts +1 -1
package/dist/cli/capture.js
CHANGED
|
@@ -91,9 +91,8 @@ function atomicWrite(file, content) {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
// src/lib/sessions.ts
|
|
94
|
-
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2, readdirSync, unlinkSync as unlinkSync2 } from "fs";
|
|
94
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2, readdirSync, unlinkSync as unlinkSync2, statSync as statSync2 } from "fs";
|
|
95
95
|
import { join } from "path";
|
|
96
|
-
import { execSync } from "child_process";
|
|
97
96
|
var SESSION_TTL_MS = 10 * 60 * 1e3;
|
|
98
97
|
var PRUNE_STALE_MS = 10 * 60 * 1e3;
|
|
99
98
|
function sessionDir() {
|
|
@@ -119,12 +118,23 @@ function currentBranch() {
|
|
|
119
118
|
return process.env.TOON_MEMORY_BRANCH.trim();
|
|
120
119
|
}
|
|
121
120
|
try {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
let gitDir = join(process.cwd(), ".git");
|
|
122
|
+
if (existsSync2(gitDir) && !statSync2(gitDir).isDirectory()) {
|
|
123
|
+
const pointer = readFileSync2(gitDir, "utf-8").trim();
|
|
124
|
+
if (pointer.startsWith("gitdir:")) {
|
|
125
|
+
const target = pointer.slice(7).trim();
|
|
126
|
+
gitDir = target.startsWith("/") ? target : join(process.cwd(), target);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const headPath = join(gitDir, "HEAD");
|
|
130
|
+
if (!existsSync2(headPath)) return "unknown";
|
|
131
|
+
const head = readFileSync2(headPath, "utf-8").trim();
|
|
132
|
+
if (head.startsWith("ref:")) {
|
|
133
|
+
const ref = head.slice(4).trim();
|
|
134
|
+
const parts = ref.split("/");
|
|
135
|
+
return parts[parts.length - 1] || "unknown";
|
|
136
|
+
}
|
|
137
|
+
return head ? head.slice(0, 7) : "unknown";
|
|
128
138
|
} catch {
|
|
129
139
|
return "unknown";
|
|
130
140
|
}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
import { readFileSync as readFileSync2 } from "fs";
|
|
3
3
|
|
|
4
4
|
// src/lib/sessions.ts
|
|
5
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, unlinkSync } from "fs";
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, unlinkSync, statSync } from "fs";
|
|
6
6
|
import { join } from "path";
|
|
7
|
-
import { execSync } from "child_process";
|
|
8
7
|
var SESSION_TTL_MS = 10 * 60 * 1e3;
|
|
9
8
|
var PRUNE_STALE_MS = 10 * 60 * 1e3;
|
|
10
9
|
function isAlive(pid) {
|
|
@@ -39,12 +38,23 @@ function currentBranch() {
|
|
|
39
38
|
return process.env.TOON_MEMORY_BRANCH.trim();
|
|
40
39
|
}
|
|
41
40
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
let gitDir = join(process.cwd(), ".git");
|
|
42
|
+
if (existsSync(gitDir) && !statSync(gitDir).isDirectory()) {
|
|
43
|
+
const pointer = readFileSync(gitDir, "utf-8").trim();
|
|
44
|
+
if (pointer.startsWith("gitdir:")) {
|
|
45
|
+
const target = pointer.slice(7).trim();
|
|
46
|
+
gitDir = target.startsWith("/") ? target : join(process.cwd(), target);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const headPath = join(gitDir, "HEAD");
|
|
50
|
+
if (!existsSync(headPath)) return "unknown";
|
|
51
|
+
const head = readFileSync(headPath, "utf-8").trim();
|
|
52
|
+
if (head.startsWith("ref:")) {
|
|
53
|
+
const ref = head.slice(4).trim();
|
|
54
|
+
const parts = ref.split("/");
|
|
55
|
+
return parts[parts.length - 1] || "unknown";
|
|
56
|
+
}
|
|
57
|
+
return head ? head.slice(0, 7) : "unknown";
|
|
48
58
|
} catch {
|
|
49
59
|
return "unknown";
|
|
50
60
|
}
|
package/mcp/server.js
CHANGED
|
@@ -27739,9 +27739,8 @@ function readUnderLock(file2, encoding = "utf-8") {
|
|
|
27739
27739
|
}
|
|
27740
27740
|
|
|
27741
27741
|
// src/lib/sessions.ts
|
|
27742
|
-
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2, readdirSync, unlinkSync as unlinkSync2 } from "fs";
|
|
27742
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2, readdirSync, unlinkSync as unlinkSync2, statSync as statSync2 } from "fs";
|
|
27743
27743
|
import { join } from "path";
|
|
27744
|
-
import { execSync } from "child_process";
|
|
27745
27744
|
var SESSION_TTL_MS = 10 * 60 * 1e3;
|
|
27746
27745
|
var PRUNE_STALE_MS = 10 * 60 * 1e3;
|
|
27747
27746
|
function isAlive2(pid) {
|
|
@@ -27769,12 +27768,23 @@ function currentBranch() {
|
|
|
27769
27768
|
return process.env.TOON_MEMORY_BRANCH.trim();
|
|
27770
27769
|
}
|
|
27771
27770
|
try {
|
|
27772
|
-
|
|
27773
|
-
|
|
27774
|
-
|
|
27775
|
-
|
|
27776
|
-
|
|
27777
|
-
|
|
27771
|
+
let gitDir = join(process.cwd(), ".git");
|
|
27772
|
+
if (existsSync2(gitDir) && !statSync2(gitDir).isDirectory()) {
|
|
27773
|
+
const pointer = readFileSync2(gitDir, "utf-8").trim();
|
|
27774
|
+
if (pointer.startsWith("gitdir:")) {
|
|
27775
|
+
const target = pointer.slice(7).trim();
|
|
27776
|
+
gitDir = target.startsWith("/") ? target : join(process.cwd(), target);
|
|
27777
|
+
}
|
|
27778
|
+
}
|
|
27779
|
+
const headPath = join(gitDir, "HEAD");
|
|
27780
|
+
if (!existsSync2(headPath)) return "unknown";
|
|
27781
|
+
const head = readFileSync2(headPath, "utf-8").trim();
|
|
27782
|
+
if (head.startsWith("ref:")) {
|
|
27783
|
+
const ref = head.slice(4).trim();
|
|
27784
|
+
const parts = ref.split("/");
|
|
27785
|
+
return parts[parts.length - 1] || "unknown";
|
|
27786
|
+
}
|
|
27787
|
+
return head ? head.slice(0, 7) : "unknown";
|
|
27778
27788
|
} catch {
|
|
27779
27789
|
return "unknown";
|
|
27780
27790
|
}
|
|
@@ -28398,7 +28408,7 @@ function consolidateEntries() {
|
|
|
28398
28408
|
return { removed: duplicates.length, kept: order.length, duplicates };
|
|
28399
28409
|
}
|
|
28400
28410
|
var server = new McpServer(
|
|
28401
|
-
{ name: "toon-memory", version: "2.4.
|
|
28411
|
+
{ name: "toon-memory", version: "2.4.2" },
|
|
28402
28412
|
{ capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
|
|
28403
28413
|
);
|
|
28404
28414
|
server.registerResource(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toon-memory",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "MCP server giving AI coding agents offline, token-efficient persistent memory — recall decisions, patterns, and bugs across sessions with 68.5% fewer tokens than re-reading context. No LLM, no server; works with 15+ agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/lib/sessions.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, readdirSync, unlinkSync, statSync } from "fs"
|
|
2
2
|
import { join } from "path"
|
|
3
|
-
import { execSync } from "child_process"
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* File-based multi-session coordination — no server, no network, no LLM.
|
|
@@ -74,18 +73,31 @@ export function resolveSessionId(payload: Record<string, unknown> = {}): string
|
|
|
74
73
|
return `proc-${process.pid}-${Math.random().toString(36).slice(2, 10)}`
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
/** Detect the current git branch
|
|
76
|
+
/** Detect the current git branch by reading .git/HEAD directly (no shell). */
|
|
78
77
|
export function currentBranch(): string {
|
|
79
78
|
if (process.env.TOON_MEMORY_BRANCH && process.env.TOON_MEMORY_BRANCH.trim()) {
|
|
80
79
|
return process.env.TOON_MEMORY_BRANCH.trim()
|
|
81
80
|
}
|
|
82
81
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
let gitDir = join(process.cwd(), ".git")
|
|
83
|
+
// .git may be a file pointing at the real git dir (worktrees).
|
|
84
|
+
if (existsSync(gitDir) && !statSync(gitDir).isDirectory()) {
|
|
85
|
+
const pointer = readFileSync(gitDir, "utf-8").trim()
|
|
86
|
+
if (pointer.startsWith("gitdir:")) {
|
|
87
|
+
const target = pointer.slice(7).trim()
|
|
88
|
+
gitDir = target.startsWith("/") ? target : join(process.cwd(), target)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const headPath = join(gitDir, "HEAD")
|
|
92
|
+
if (!existsSync(headPath)) return "unknown"
|
|
93
|
+
const head = readFileSync(headPath, "utf-8").trim()
|
|
94
|
+
if (head.startsWith("ref:")) {
|
|
95
|
+
const ref = head.slice(4).trim()
|
|
96
|
+
const parts = ref.split("/")
|
|
97
|
+
return parts[parts.length - 1] || "unknown"
|
|
98
|
+
}
|
|
99
|
+
// Detached HEAD: HEAD holds a commit hash.
|
|
100
|
+
return head ? head.slice(0, 7) : "unknown"
|
|
89
101
|
} catch {
|
|
90
102
|
return "unknown"
|
|
91
103
|
}
|
package/src/mcp/server.ts
CHANGED
|
@@ -599,7 +599,7 @@ function consolidateEntries(): { removed: number; kept: number; duplicates: stri
|
|
|
599
599
|
}
|
|
600
600
|
|
|
601
601
|
const server = new McpServer(
|
|
602
|
-
{ name: "toon-memory", version: "2.4.
|
|
602
|
+
{ name: "toon-memory", version: "2.4.2" },
|
|
603
603
|
{ capabilities: { tools: { listChanged: true }, resources: { listChanged: true } } }
|
|
604
604
|
)
|
|
605
605
|
|