notesoup 0.59.2 → 0.60.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.md +3 -17
- package/dist/plugins/claude/src/helper.js +1 -2
- package/dist/plugins/codex/src/mcp.js +1 -2
- package/dist/plugins/dsh/tools.js +1 -2
- package/dist/plugins/pi/notes/tools.d.ts +1 -1
- package/dist/plugins/pi/notes/tools.js +2 -3
- package/dist/src/dream/git.js +12 -13
- package/dist/src/history/history.d.ts +10 -11
- package/dist/src/history/history.js +8 -19
- package/dist/src/history/query.d.ts +3 -14
- package/dist/src/history/query.js +73 -85
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/notes/address.js +3 -3
- package/dist/src/notes/project-namespace.js +39 -73
- package/dist/src/notes/store.d.ts +2 -4
- package/dist/src/notes/store.js +1 -2
- package/dist/src/sqlite-lock.d.ts +2 -0
- package/dist/src/sqlite-lock.js +17 -0
- package/dist/src/tools/dream.d.ts +2 -4
- package/dist/src/tools/dream.js +15 -16
- package/dist/src/tools/history.d.ts +4 -6
- package/dist/src/tools/history.js +69 -29
- package/dist/src/tools/notes.d.ts +18 -78
- package/dist/src/tools/notes.js +39 -50
- package/dist/src/tools/schema.d.ts +0 -1
- package/dist/src/tools/schema.js +0 -1
- package/dist/test/claude-history.test.js +5 -6
- package/dist/test/claude-mod.test.js +6 -7
- package/dist/test/codex-history.test.js +1 -1
- package/dist/test/codex-plugin.test.js +1 -2
- package/dist/test/dependencies.test.js +2 -2
- package/dist/test/dream-tools.test.js +42 -14
- package/dist/test/dsh.test.js +2 -2
- package/dist/test/history-corpus.test.js +21 -36
- package/dist/test/history-summary-cache.test.js +3 -3
- package/dist/test/history.integration.test.js +53 -106
- package/dist/test/host-neutral.test.js +1 -1
- package/dist/test/note-policy.test.js +5 -5
- package/dist/test/notes-cwd.test.js +5 -5
- package/dist/test/notes-query-namespaces.test.js +2 -6
- package/dist/test/notes.integration.test.js +33 -42
- package/dist/test/notes.test.js +12 -14
- package/dist/test/project-namespace.test.js +36 -91
- package/docs/architecture.md +3 -3
- package/docs/claude-code-mod.md +2 -2
- package/docs/codex.md +1 -1
- package/docs/dsh.md +2 -2
- package/docs/history-sessions.md +8 -9
- package/docs/notes-library.md +9 -3
- package/docs/skills.md +2 -6
- package/docs/tool-results.md +12 -6
- package/package.json +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +212 -211
- package/plugins/claude/skills/memory/SKILL.md +6 -6
- package/plugins/claude/src/helper.ts +1 -2
- package/plugins/codex/README.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +211 -210
- package/plugins/codex/src/mcp.ts +1 -2
- package/plugins/dsh/tools.ts +1 -2
- package/plugins/pi/notes/tools.ts +2 -3
- package/skills/memory/SKILL.md +6 -6
- package/src/dream/git.ts +11 -11
- package/src/history/history.ts +11 -16
- package/src/history/query.ts +67 -99
- package/src/index.ts +1 -1
- package/src/notes/address.ts +2 -2
- package/src/notes/project-namespace.ts +37 -59
- package/src/notes/store.ts +3 -6
- package/src/sqlite-lock.ts +14 -0
- package/src/tools/dream.ts +15 -14
- package/src/tools/history.ts +60 -29
- package/src/tools/notes.ts +39 -54
- package/src/tools/schema.ts +0 -1
- package/dist/src/dream/lock.d.ts +0 -14
- package/dist/src/dream/lock.js +0 -29
- package/src/dream/lock.ts +0 -28
package/dist/test/notes.test.js
CHANGED
|
@@ -16,7 +16,7 @@ import { parseNote } from "../src/notes/frontmatter.js";
|
|
|
16
16
|
import { createNotesStore, projectKey } from "../src/notes/index.js";
|
|
17
17
|
import { globToRegExp } from "../src/notes/address.js";
|
|
18
18
|
import { listNotes, physicalPath, scopeDir } from "./helpers/notes.js";
|
|
19
|
-
import { notesList
|
|
19
|
+
import { notesList } from "../src/tools/notes.js";
|
|
20
20
|
import { notesIdentityFromPi } from "../plugins/pi/notes/adapter.js";
|
|
21
21
|
import { notesToolContext } from "../src/tools/notes-context.js";
|
|
22
22
|
import { call, context, explicitBoot, makeExtension, manager, resultData, resultError, resultRead } from "./helpers/extension.js";
|
|
@@ -34,7 +34,7 @@ test("tools register their namespaces and sequential note mutations", () => {
|
|
|
34
34
|
assert.equal(captured.tools.get("notes_write")?.executionMode, "sequential");
|
|
35
35
|
assert.equal(captured.tools.get("notes_update")?.executionMode, "sequential");
|
|
36
36
|
assert.equal(captured.tools.get("notes_read")?.executionMode, undefined);
|
|
37
|
-
for (const name of ["notes_write", "notes_update", "notes_read", "notes_list"
|
|
37
|
+
for (const name of ["notes_write", "notes_update", "notes_read", "notes_list"]) {
|
|
38
38
|
assert.equal(captured.tools.get(name)?.namespace?.name, "notes", `${name} is in notes`);
|
|
39
39
|
}
|
|
40
40
|
for (const name of ["history_list", "history_read"]) {
|
|
@@ -51,7 +51,7 @@ test("every notes tool declares a result schema that accepts its own structured
|
|
|
51
51
|
["notes_update", await call(captured, "notes_update", { address: "schema.md", edits: [{ oldText: "again", newText: "once" }] }, ctx)],
|
|
52
52
|
["notes_read", await call(captured, "notes_read", { address: "schema.md" }, ctx)],
|
|
53
53
|
["notes_list", await call(captured, "notes_list", {}, ctx)],
|
|
54
|
-
["
|
|
54
|
+
["notes_list", await call(captured, "notes_list", { query: "needle" }, ctx)],
|
|
55
55
|
["notes_read", await call(captured, "notes_read", { address: "absent.md" }, ctx)],
|
|
56
56
|
];
|
|
57
57
|
for (const [name, result] of delivered) {
|
|
@@ -67,7 +67,7 @@ test("note schemas accept their operations, reject unknown fields, and expose cr
|
|
|
67
67
|
["notes_update", { address: "a.md", crumpled: true }],
|
|
68
68
|
["notes_read", { address: "a.md" }],
|
|
69
69
|
["notes_list", { crumpled: true }],
|
|
70
|
-
["
|
|
70
|
+
["notes_list", { query: "x", crumpled: true }],
|
|
71
71
|
]) {
|
|
72
72
|
const schema = captured.tools.get(name).parameters;
|
|
73
73
|
assert.equal(Check(schema, params), true, name);
|
|
@@ -345,7 +345,7 @@ test("empty results distinguish hidden notes and unavailable notebooks", async (
|
|
|
345
345
|
assert.deepEqual(empty, { files: [], more: 0, namespaces_unavailable: [] });
|
|
346
346
|
await call(captured, "notes_write", { address: "@human/hidden.md", content: "needle" }, ctx);
|
|
347
347
|
await call(captured, "notes_update", { address: "@human/hidden.md", crumpled: true }, ctx);
|
|
348
|
-
const hidden = resultData(await call(captured, "
|
|
348
|
+
const hidden = resultData(await call(captured, "notes_list", { query: "needle", glob: "@human/**" }, ctx));
|
|
349
349
|
assert.deepEqual(hidden.files, [], "a crumpled note is hidden from search");
|
|
350
350
|
const identity = notesIdentityFromPi(ctx);
|
|
351
351
|
const broken = scopeDir("project", ctx);
|
|
@@ -357,7 +357,7 @@ test("empty results distinguish hidden notes and unavailable notebooks", async (
|
|
|
357
357
|
const partial = partialResult.data;
|
|
358
358
|
assert.deepEqual(partial.namespaces_unavailable, ["@project"]);
|
|
359
359
|
assert.deepEqual(partial.files, []);
|
|
360
|
-
const searchResult = await
|
|
360
|
+
const searchResult = await notesList.execute({ query: "needle", glob: "**" }, notesToolContext(identity, ctx.cwd));
|
|
361
361
|
assert.ok(searchResult.ok);
|
|
362
362
|
assert.deepEqual(searchResult.data.namespaces_unavailable, ["@project"]);
|
|
363
363
|
writeFileSync(join(process.env.NOTESOUP_HOME, "agents"), "not a directory");
|
|
@@ -391,8 +391,8 @@ test("notes receipts report resolved identity across scopes", async () => {
|
|
|
391
391
|
assert.deepEqual(listed.files.map((file) => file.address).sort(), notes.map((note) => note.address).sort(), "notes_list returns each full address");
|
|
392
392
|
for (const row of listed.files)
|
|
393
393
|
assertReceiptIdentity(row, row.address, notes.find((note) => note.address === row.address).scope, ctx);
|
|
394
|
-
const searched = resultData(await call(captured, "
|
|
395
|
-
assert.deepEqual(searched.files.map((file) => file.address), notes.map((note) => note.address).sort(), "
|
|
394
|
+
const searched = resultData(await call(captured, "notes_list", { query: "match", glob: "**" }, ctx));
|
|
395
|
+
assert.deepEqual(searched.files.map((file) => file.address), notes.map((note) => note.address).sort(), "search returns each full address");
|
|
396
396
|
for (const row of searched.files)
|
|
397
397
|
assertReceiptIdentity(row, row.address, notes.find((note) => note.address === row.address).scope, ctx);
|
|
398
398
|
});
|
|
@@ -410,12 +410,12 @@ test("list and search merge scopes and carry addresses; the path jail rejects es
|
|
|
410
410
|
assert.equal(typeof row.updated_at, "string");
|
|
411
411
|
const scoped = resultData(await call(captured, "notes_list", { glob: "@human/**" }, ctx));
|
|
412
412
|
assert.deepEqual(scoped.files.map((file) => file.address), ["@human/three.md"], "an address glob filter narrows the set");
|
|
413
|
-
const searched = resultData(await call(captured, "
|
|
413
|
+
const searched = resultData(await call(captured, "notes_list", { query: "needle" }, ctx));
|
|
414
414
|
assert.equal(searched.files.length, 3, "literal search finds matches in every scope");
|
|
415
415
|
assert.deepEqual([...searched.files].map((file) => file.address).sort(), ["@human/three.md", "@project/two.md", "one.md"]);
|
|
416
416
|
for (const row of [...listed.files, ...searched.files])
|
|
417
417
|
assert.equal("scope" in row, false, "scope is derivable from the address and never echoed");
|
|
418
|
-
assert.equal(searched.files.every((file) => file.matches
|
|
418
|
+
assert.equal(searched.files.every((file) => file.matches?.length === 1), true);
|
|
419
419
|
const hit = searched.files[0].matches[0];
|
|
420
420
|
assert.equal(hit.line, 1);
|
|
421
421
|
assert.equal(hit.offset_chars, 0, "the offset counts into the note body, so it does not include serialized frontmatter");
|
|
@@ -427,10 +427,8 @@ test("list and search merge scopes and carry addresses; the path jail rejects es
|
|
|
427
427
|
assert.equal(resultError(await call(captured, tool, { address: path, content: "x", edits: [{ oldText: "a", newText: "b" }] }, ctx)).code, "invalid_address");
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
|
-
assert.deepEqual(resultData(await call(captured, "notes_search", { query: "" }, ctx)), resultData(await call(captured, "notes_search", {}, ctx)));
|
|
431
430
|
assert.equal(resultError(await call(captured, "notes_read", { address: "one.md", offset_chars: 99999 }, ctx)).code, "invalid_offset");
|
|
432
431
|
assert.equal(resultError(await call(captured, "notes_list", { glob: "bad\\glob" }, ctx)).code, "invalid_pattern");
|
|
433
|
-
assert.equal(resultError(await call(captured, "notes_search", { query: "needle", glob: "bad\\glob" }, ctx)).code, "invalid_pattern");
|
|
434
432
|
});
|
|
435
433
|
test("a read offsets the body in code points, not bytes or frontmatter", async () => {
|
|
436
434
|
freshRoot();
|
|
@@ -438,7 +436,7 @@ test("a read offsets the body in code points, not bytes or frontmatter", async (
|
|
|
438
436
|
const captured = makeExtension(session);
|
|
439
437
|
const ctx = context(session);
|
|
440
438
|
await call(captured, "notes_write", { address: "emoji.md", content: "🐑字\nneedle tail" }, ctx);
|
|
441
|
-
const search = resultData(await call(captured, "
|
|
439
|
+
const search = resultData(await call(captured, "notes_list", { query: "needle", glob: "emoji.md" }, ctx));
|
|
442
440
|
const match = search.files[0].matches[0];
|
|
443
441
|
assert.equal(match.line, 2);
|
|
444
442
|
assert.equal(match.offset_chars, 3, "the emoji and CJK line above contribute two code points plus the newline, not their bytes");
|
|
@@ -483,7 +481,7 @@ test("interior @ in a note path round-trips through write, list, search, read, u
|
|
|
483
481
|
assert.deepEqual(listed.files.map((row) => row.address).sort(), ["@project/mail/alice@example.com.md", "release@v1.md"], "both addresses list in canonical form");
|
|
484
482
|
const globbed = resultData(await call(captured, "notes_list", { glob: "@project/**" }, ctx));
|
|
485
483
|
assert.deepEqual(globbed.files.map((row) => row.address), ["@project/mail/alice@example.com.md"], "a notebook glob still narrows to that notebook");
|
|
486
|
-
const searched = resultData(await call(captured, "
|
|
484
|
+
const searched = resultData(await call(captured, "notes_list", { query: "needle" }, ctx));
|
|
487
485
|
assert.deepEqual(searched.files.map((row) => row.address).sort(), ["@project/mail/alice@example.com.md", "release@v1.md"], "searched addresses carry the interior @ back out");
|
|
488
486
|
assert.match(resultRead(await call(captured, "notes_read", { address: "@project/mail/alice@example.com.md" }, ctx)).content, /mail needle$/);
|
|
489
487
|
await call(captured, "notes_update", { address: "release@v1.md", edits: [{ oldText: "release", newText: "shipped" }] }, ctx);
|
|
@@ -9,7 +9,7 @@ import { Check } from "typebox/value";
|
|
|
9
9
|
import { createNotesStore } from "../src/notes/index.js";
|
|
10
10
|
import { assertAddress } from "../src/notes/address.js";
|
|
11
11
|
import { normalizeRemote, projectKey } from "../src/notes/project-namespace.js";
|
|
12
|
-
import { notesList, notesRead,
|
|
12
|
+
import { notesList, notesRead, notesUpdate, notesWrite } from "../src/tools/notes.js";
|
|
13
13
|
import { success } from "../src/result.js";
|
|
14
14
|
import { notesToolContext } from "../src/tools/notes-context.js";
|
|
15
15
|
const toolContext = (identity) => notesToolContext(identity, "/work/current");
|
|
@@ -28,7 +28,7 @@ function fixture(t) {
|
|
|
28
28
|
return { root, home, repo, marker, identity };
|
|
29
29
|
}
|
|
30
30
|
// Each participant imports the real built module and operates on the same disk.
|
|
31
|
-
//
|
|
31
|
+
// Pause immediately before publication, with the real writer transaction held.
|
|
32
32
|
const claimWorker = `
|
|
33
33
|
import fs from "node:fs";
|
|
34
34
|
import { syncBuiltinESMExports } from "node:module";
|
|
@@ -42,35 +42,25 @@ function wait(name) {
|
|
|
42
42
|
Atomics.wait(sleep, 0, 0, 5);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function paused() { fs.writeFileSync(join(control, "paused"), ""); wait("continue"); }
|
|
46
45
|
if (pause) {
|
|
47
|
-
const
|
|
48
|
-
fs.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
fs.readdirSync = function(path, ...args) {
|
|
54
|
-
const result = readdir(path, ...args);
|
|
55
|
-
if (pause === "snapshot" && path === join(home, "project") && args.length === 0) paused();
|
|
56
|
-
return result;
|
|
57
|
-
};
|
|
58
|
-
fs.readFileSync = function(path, ...args) {
|
|
59
|
-
try { return read(path, ...args); } catch (error) {
|
|
60
|
-
if (path === join(home, "project", "api", ".project") && error.code === "ENOENT") fs.writeFileSync(join(control, "missing"), "");
|
|
61
|
-
throw error;
|
|
46
|
+
const rename = fs.renameSync;
|
|
47
|
+
fs.renameSync = function(from, to) {
|
|
48
|
+
if (to === join(home, "project", "api")) {
|
|
49
|
+
fs.writeFileSync(join(control, "paused"), "");
|
|
50
|
+
wait("continue");
|
|
62
51
|
}
|
|
52
|
+
return rename(from, to);
|
|
63
53
|
};
|
|
64
54
|
syncBuiltinESMExports();
|
|
65
55
|
}
|
|
66
|
-
const { projectKey } = await import(${JSON.stringify(new URL("../src/notes/
|
|
56
|
+
const { projectKey, createNotesStore } = await import(${JSON.stringify(new URL("../src/notes/index.js", import.meta.url).href)});
|
|
67
57
|
fs.writeFileSync(join(control, "ready"), "");
|
|
68
58
|
wait("start");
|
|
69
59
|
const key = projectKey(cwd, home);
|
|
70
|
-
const
|
|
71
|
-
const probe =
|
|
72
|
-
|
|
73
|
-
console.log(JSON.stringify({ key, marker: JSON.parse(fs.readFileSync(join(
|
|
60
|
+
const notes = createNotesStore({ home, projectKey: key, sessionId: "session", agent: "test", model: "test" });
|
|
61
|
+
const probe = "@project/probe-" + process.pid;
|
|
62
|
+
await notes.write(probe, "usable");
|
|
63
|
+
console.log(JSON.stringify({ key, marker: JSON.parse(fs.readFileSync(join(home, "project", key, ".project"), "utf8")), probe: (await notes.read(probe)).body }));
|
|
74
64
|
`;
|
|
75
65
|
async function waitForFile(path) {
|
|
76
66
|
const deadline = Date.now() + 10_000;
|
|
@@ -93,6 +83,7 @@ function racer(t, root, cwd, home, pause = "") {
|
|
|
93
83
|
});
|
|
94
84
|
return {
|
|
95
85
|
result,
|
|
86
|
+
kill: () => child.kill("SIGKILL"),
|
|
96
87
|
wait: (stage) => waitForFile(join(control, stage)),
|
|
97
88
|
release: (stage) => writeFileSync(join(control, stage), ""),
|
|
98
89
|
};
|
|
@@ -118,7 +109,6 @@ test("sixteen first claimants converge on one usable notebook for root and remot
|
|
|
118
109
|
assert.equal(new Set(keys).size, 1);
|
|
119
110
|
assert.deepEqual(readdirSync(join(home, "project")), [keys[0]]);
|
|
120
111
|
assert.equal(marker(keys[0]).id, remote ? "host/team/api" : cwd);
|
|
121
|
-
assert.equal(existsSync(join(home, ".project-claim")), false);
|
|
122
112
|
});
|
|
123
113
|
});
|
|
124
114
|
test("different concurrent identities retain distinct suffixes", async (t) => {
|
|
@@ -134,72 +124,28 @@ test("different concurrent identities retain distinct suffixes", async (t) => {
|
|
|
134
124
|
assert.deepEqual(results.map(result => JSON.parse(result.stdout).key).sort(), ["api", "api-1"]);
|
|
135
125
|
assert.deepEqual(readdirSync(join(home, "project")).sort(), ["api", "api-1"]);
|
|
136
126
|
});
|
|
137
|
-
test("a claimant
|
|
127
|
+
test("a killed claimant releases its transaction without publishing a partial notebook", async (t) => {
|
|
138
128
|
const { root, home, repo } = fixture(t);
|
|
139
129
|
const cwd = repo("api");
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
await
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
assert.deepEqual(readdirSync(join(home, "project")), ["
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const { root, home, repo, marker } = fixture(t);
|
|
160
|
-
const cwd = repo("api", "https://host/team/api");
|
|
161
|
-
const worker = racer(t, root, cwd, home, "snapshot");
|
|
162
|
-
await worker.wait("ready");
|
|
163
|
-
worker.release("start");
|
|
164
|
-
await worker.wait("paused");
|
|
165
|
-
mkdirSync(join(home, "project/api"));
|
|
166
|
-
worker.release("continue");
|
|
167
|
-
await worker.wait("missing");
|
|
168
|
-
writeFileSync(join(home, "project/api/.project"), JSON.stringify({ id: same ? cwd : "host/other/api", path: "/old/root" }));
|
|
169
|
-
const result = await worker.result;
|
|
170
|
-
assert.equal(result.code, 0, result.stderr);
|
|
171
|
-
const key = same ? "api" : "api-1";
|
|
172
|
-
assert.equal(JSON.parse(result.stdout).key, key);
|
|
173
|
-
assert.deepEqual(marker(key), { id: "host/team/api", path: cwd });
|
|
174
|
-
if (!same)
|
|
175
|
-
assert.deepEqual(marker("api"), { id: "host/other/api", path: "/old/root" });
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
test("an unfinished claim times out without silently allocating another notebook", async (t) => {
|
|
179
|
-
const { root, home, repo } = fixture(t);
|
|
180
|
-
const worker = racer(t, root, repo("api"), home, "snapshot");
|
|
181
|
-
await worker.wait("ready");
|
|
182
|
-
worker.release("start");
|
|
183
|
-
await worker.wait("paused");
|
|
184
|
-
mkdirSync(join(home, "project/api"));
|
|
185
|
-
worker.release("continue");
|
|
186
|
-
const result = await worker.result;
|
|
187
|
-
assert.notEqual(result.code, 0);
|
|
188
|
-
assert.match(result.stderr, /Timed out waiting for project claim.*api/);
|
|
189
|
-
assert.deepEqual(readdirSync(join(home, "project")), ["api"]);
|
|
190
|
-
assert.equal(existsSync(join(home, ".project-claim")), false);
|
|
191
|
-
});
|
|
192
|
-
test("a stuck claim lock has a bounded timeout and is never stolen", async (t) => {
|
|
193
|
-
const { root, home, repo } = fixture(t);
|
|
194
|
-
mkdirSync(join(home, ".project-claim"), { recursive: true });
|
|
195
|
-
const worker = racer(t, root, repo("api"), home);
|
|
196
|
-
await worker.wait("ready");
|
|
197
|
-
worker.release("start");
|
|
198
|
-
const result = await worker.result;
|
|
199
|
-
assert.notEqual(result.code, 0);
|
|
200
|
-
assert.match(result.stderr, /Timed out waiting for project claim.*\.project-claim/);
|
|
201
|
-
assert.deepEqual(readdirSync(join(home, "project")), []);
|
|
202
|
-
assert.equal(existsSync(join(home, ".project-claim")), true);
|
|
130
|
+
const stable = repo("stable");
|
|
131
|
+
assert.equal(projectKey(stable, home), "stable");
|
|
132
|
+
const holder = racer(t, root, cwd, home, "publication");
|
|
133
|
+
await holder.wait("ready");
|
|
134
|
+
holder.release("start");
|
|
135
|
+
await holder.wait("paused");
|
|
136
|
+
// An unchanged identity needs no writer lock. Another claimant cannot steal it.
|
|
137
|
+
assert.equal(projectKey(stable, home), "stable");
|
|
138
|
+
assert.throws(() => projectKey(cwd, home), /Timed out waiting for project claim/);
|
|
139
|
+
assert.deepEqual(readdirSync(join(home, "project")), ["stable"]);
|
|
140
|
+
assert.ok(holder.kill());
|
|
141
|
+
assert.equal((await holder.result).code, null);
|
|
142
|
+
const next = racer(t, root, cwd, home);
|
|
143
|
+
await next.wait("ready");
|
|
144
|
+
next.release("start");
|
|
145
|
+
const result = await next.result;
|
|
146
|
+
assert.equal(result.code, 0, result.stderr);
|
|
147
|
+
assert.deepEqual(JSON.parse(result.stdout), { key: "api", marker: { id: cwd, path: cwd }, probe: "usable" });
|
|
148
|
+
assert.deepEqual(readdirSync(join(home, "project")).sort(), ["api", "stable"]);
|
|
203
149
|
});
|
|
204
150
|
test("malformed marker evidence refuses instead of becoming an unmarked legacy notebook", t => {
|
|
205
151
|
const { home, repo } = fixture(t);
|
|
@@ -210,7 +156,6 @@ test("malformed marker evidence refuses instead of becoming an unmarked legacy n
|
|
|
210
156
|
assert.throws(() => projectKey(cwd, home), /Invalid project marker.*api/);
|
|
211
157
|
assert.equal(readFileSync(join(home, "project/api/.project"), "utf8"), raw);
|
|
212
158
|
assert.deepEqual(readdirSync(join(home, "project")), ["api"]);
|
|
213
|
-
assert.equal(existsSync(join(home, ".project-claim")), false);
|
|
214
159
|
}
|
|
215
160
|
});
|
|
216
161
|
function data(result) {
|
|
@@ -300,9 +245,9 @@ test("named projects read/list/search with root and sibling receipts, without to
|
|
|
300
245
|
const listed = data(await notesList.execute({ glob: "@projects/*/**" }, toolContext(own)));
|
|
301
246
|
assert.deepEqual(listed.files.map(row => [row.address, row.project_root]).sort(), [["@projects/api-1/decision.md", second], ["@projects/api/decision.md", first]].sort());
|
|
302
247
|
assert.equal(Check(notesList.outputSchema, listed), true);
|
|
303
|
-
const searched = data(await
|
|
248
|
+
const searched = data(await notesList.execute({ glob: "@projects/api-1/**", query: "needle" }, toolContext(own)));
|
|
304
249
|
assert.equal(searched.files[0]?.project_root, second);
|
|
305
|
-
assert.equal(Check(
|
|
250
|
+
assert.equal(Check(notesList.outputSchema, searched), true);
|
|
306
251
|
assert.equal(readFileSync(file, "utf8"), before, "named-notebook reads never rewrite access metadata");
|
|
307
252
|
});
|
|
308
253
|
test("named project writes, edits, crumples and both move endpoints refuse, including the current notebook", async (t) => {
|
package/docs/architecture.md
CHANGED
|
@@ -13,7 +13,7 @@ notesoup uses Pi's session branch as the durable source of truth. It does not ma
|
|
|
13
13
|
| `boot/snapshot.ts` | Load each of the five notebooks once; isolate filesystem errno failures | Explicit identity, captured time and optional scope loader |
|
|
14
14
|
| `boot/render.ts`, `boot/text.ts` | Render window data separately from fixed protocol/maps teaching; retain a combined boot for other hosts | Explicit snapshot and logical tool-name bindings; no I/O or clock |
|
|
15
15
|
| `history/history.ts` | Project decoded events and pair tool calls/results, preserving supplied addresses | Decoded items and branch visibility; never inference messages |
|
|
16
|
-
| `history/query.ts` | Bounded paging,
|
|
16
|
+
| `history/query.ts` | Bounded paging, literal matching and neighboring context, folding and chronological cross-session merging | Caller-supplied budget check and page-too-large facts; no tool dependencies or native SDK/session traversal |
|
|
17
17
|
| `history/corpus.ts`, `history/local.ts` | Session selector resolution and read-only local discovery, with explicit roots/env | Lazy projections and canonical identities; DSH contributes service-backed descriptors |
|
|
18
18
|
| `history/pi.ts`, `history/claude.ts`, `history/codex.ts`, `history/codex-transcript.ts` | Persisted wire decoding, stable seq allocation and recorded branch/lineage evidence | Node/structural data only; no SDK or plugin imports; shared by corpus and native adapter entries |
|
|
19
19
|
| `budget/constants.ts`, `budget/policy.ts`, `budget/text.ts` | Pure thresholds, unknown/clamped countdown and reminder text | Values supplied by the caller; no settings reads or scheduling |
|
|
@@ -58,7 +58,7 @@ Pi's `before_agent_start` mutates the public `systemPromptOptions.sections`: `no
|
|
|
58
58
|
|
|
59
59
|
The Pi boot remains a fixed snapshot for its window, stored as a hidden extension custom message and converted to a user-role model message. It contains only the window identity/tree and notes index/pinned bodies: no note, including `@human`, becomes a system instruction, and readonly semantics are unchanged. On resume, provider projection removes only a recognized old boot's consecutive top-level identity -> protocol -> maps -> notes prefix teaching; tags or quotations inside note bodies and ordinary messages remain untouched. Persisted boot/history bytes are never rewritten. Claude, Codex and dsh retain the combined renderer and their existing injection paths. History internally distinguishes native system summaries and extension-authored custom messages; its public `context` event groups both without implying provider instruction priority. Boot injection is silent, including startup, reload, and boot repair. `/empty` and `/fresh-window` acknowledge a new request with `🥣 Dumping Brain`. Normal reset completion is silent; only forced reset completion produces `🥣 Brain forcibly emptied: overflow` through `ctx.ui.notify`, after the verified checkpoint, marker, boot, and continuation are present in the session. Committed resets are checked at the next turn start or final settlement. `plugins/pi/reset/committed.ts` confirms an ordered hidden boot/continuation after a checkpoint-backed marker even when later conversation exists. That is distinct from `inspectResetTail`, which refuses suffix repair after real work or malformed ordering. Uncommitted reset drafts never announce success. Boot and continuation messages retain `display: false`.
|
|
60
60
|
|
|
61
|
-
The Pi history adapter supplies the selected raw session branch on demand without a cache. Its shared wire decoder allocates stable seq values from the session's append-order entry list, then selects current-branch-only visibility, so navigation cannot expose a sibling's history. Shared history pairs and queries those decoded events; it neither traverses SessionReader nor reconstructs inference messages. Optional `session` targeting uses a lazy `HistoryContext`/`HistoryCorpus`; filesystem-only Pi/Claude/Codex wire decoders are shared under `src/history/`, while DSH contributes descriptors through its native query service. Omitted `session` retains the original result/header/recipe shapes; explicit selectors carry canonical session identity throughout, and wildcard search merges hits chronologically without cross-session seq cursors. See [cross-session history](history-sessions.md). The public stream combines each tool call with its result at the call seq; paired result slots are not public event addresses, and unpaired results retain their own seq. Summaries and injected messages project as `context`. List pages chronologically
|
|
61
|
+
The Pi history adapter supplies the selected raw session branch on demand without a cache. Its shared wire decoder allocates stable seq values from the session's append-order entry list, then selects current-branch-only visibility, so navigation cannot expose a sibling's history. Shared history pairs and queries those decoded events; it neither traverses SessionReader nor reconstructs inference messages. Optional `session` targeting uses a lazy `HistoryContext`/`HistoryCorpus`; filesystem-only Pi/Claude/Codex wire decoders are shared under `src/history/`, while DSH contributes descriptors through its native query service. Omitted `session` retains the original result/header/recipe shapes; explicit selectors carry canonical session identity throughout, and wildcard search merges hits chronologically without cross-session seq cursors. See [cross-session history](history-sessions.md). The public stream combines each tool call with its result at the call seq; paired result slots are not public event addresses, and unpaired results retain their own seq. Summaries and injected messages project as `context`. List pages chronologically using exclusive `after` and `before` seq or time bounds. The tool layer normalizes the bounds and query; history selection pages and expands hits with their neighboring events. Tool executions retain structured call/result facts and any native nested-call metadata. A deterministic event document supplies both query-match positions and read windows. Nested calls have no independent seq and never imply that unrecorded child outputs are available.
|
|
62
62
|
|
|
63
63
|
The boot notes index in `boot/snapshot.ts` is a closed snapshot: the current session, project, human, agent, and model notebooks are each loaded at most once while constructing a boot. `boot/snapshot.ts` takes explicit `NotesIdentity`, captured `openedAt` and an optional notebook loader; `boot/render.ts` renders that snapshot and explicit tool bindings without reading the filesystem or consulting the clock. Pi supplies its unchanged tool names. MAP bodies and pocket metadata are derived from the same snapshot, so a boot cannot mix two filesystem reads. Note storage and notebook traversal use `node:fs/promises`; same-file operations queue by absolute physical filename across store instances in this process, without promising symlink/case-alias or cross-process locking. Known persisted metadata is camelCase. Old snake_case keys are unrecognized extras, not interpreted or migrated; startup does not migrate notes. A missing notebook (`ENOENT`) is normal. A real read failure omits only that notebook's index, preserves healthy notebooks, adds a model-facing `notes_list` recovery notice, and notifies the human once for that window. Boot/reset construction captures session, agent, and model identity before awaiting the snapshot, then checks lifecycle generation, active window, enabled state, and abort status before sending or returning artifacts; stale completions cannot commit into a switched or shut-down session. Boot acquisition uses listing and never updates access metadata. Explicit note reads update `lastAccessed` and `accessCount`; no fallback state is created.
|
|
64
64
|
|
|
@@ -66,7 +66,7 @@ Notes remain in their filesystem-backed notebooks, unchanged by session branch n
|
|
|
66
66
|
|
|
67
67
|
Every notes tool accepts an optional per-call `cwd`. The host adapter supplies a `NotesToolContext` containing its base cwd and default `NotesIdentity`; shared tool code resolves a relative override against that base, requires an existing directory, and derives one override `projectKey` through the existing project resolver. Storage, addresses, globs, receipts, and new session-note ownership all consume that same resolved identity. The override neither mutates the context nor changes `NotesIdentity.home`; the standalone store still receives explicit identities and has no cwd-discovery behavior. Dream markers survive resolution, so an override cannot widen dream write permission.
|
|
68
68
|
|
|
69
|
-
Notes/history operations return schema-derived `Outcome<T>` values, not host `content` objects. One bounded candidate is measured against both its complete structured serialization and its text renderer. Pi registers the outcome schema and packages that same value as `structuredContent`, derives `isError` from it and puts rendered text in `content`. Claude uses the same operations and renderers. Neither adapter parses text or independently chooses a page. Read continuation hints follow Pi's native trailing-notice style and are not part of the addressed text. See [tool results](tool-results.md) for the breaking protocol and coordinate contract.
|
|
69
|
+
`notes_list` uses one schema and renderer for browse rows and query hits. Notes/history operations return schema-derived `Outcome<T>` values, not host `content` objects. One bounded candidate is measured against both its complete structured serialization and its text renderer. Pi registers the outcome schema and packages that same value as `structuredContent`, derives `isError` from it and puts rendered text in `content`. Claude uses the same operations and renderers. Neither adapter parses text or independently chooses a page. Read continuation hints follow Pi's native trailing-notice style and are not part of the addressed text. See [tool results](tool-results.md) for the breaking protocol and coordinate contract.
|
|
70
70
|
|
|
71
71
|
The `/fresh-window` command only waits for idle when the session is busy with non-agent work; during model output it arms the close-out and steers the checkpoint prompt into the running turn. While enabled, `/compact` is cancelled with an actionable `/fresh-window` notice. Disabling notesoup stops new automatic resets, but an existing native checkpoint/marker still excludes earlier history and native compaction is still cancelled on that marked branch; a fresh root may use native Pi semantics. Threshold and warning accounting use active-window provider usage rather than pre-reset global usage. Pre-send hard-reserve checks estimate the complete projected transcript, including real system sections and tool declarations; native provider usage remains authoritative once available, and post-checkpoint unknown usage stays unknown. Budget policy and staged prompts are instance-owned, so concurrent sessions cannot share reserve/enablement or uncommitted drafts; default file-backed policy is cached per instance, while injected policy is resolved live on each decision and model/session transitions reset the diagnostic lifecycle.
|
|
72
72
|
|
package/docs/claude-code-mod.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Claude Code Mod
|
|
2
2
|
|
|
3
|
-
The package also ships `plugins/claude/`, an early-access Claude Code Mod that registers
|
|
3
|
+
The package also ships `plugins/claude/`, an early-access Claude Code Mod that registers four notes tools as `mcp__notesoup__notes_*`, two history tools as `mcp__notesoup__history_*`, and `mcp__notesoup__empty_brain` and attaches one host-scoped notes boot block through Claude's conversation-scoped `prompt.context` event; Claude persists it across resume and reload. The sandboxed hooks module delegates filesystem and shared-domain work to the plugin-local `plugins/claude/dist/claude/helper.js` through Claude's bounded `$.process.run` capability.
|
|
4
4
|
|
|
5
5
|
Warning and automatic clear use one budget policy. The existing warning and reset points are derived from Claude's own auto-compact threshold instead of a fixed percent, in `plugins/claude/src/thresholds.ts`, and reach the sandboxed hooks module through the helper's `limits` operation. At the hard point, the next main `turn.step` ends the old turn after its whole tool batch; a successful main `turn.complete` also checks the point when no request is already pending. Both enter the existing non-held reset worker, without a separate cap-specific trigger. Measurement alone never clears context, child events cannot reset the main brain, and aborted/error/refusal turns do not commit a budget reset. The policy resolves its native point as follows:
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ The notes tools also serve subagent calls, using the same session identity and s
|
|
|
30
30
|
|
|
31
31
|
## Persisted history
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
The [shared schemas and results](tool-results.md) apply here too: `notes_list` browses or searches with `query`; `history_list` uses `after` / `before` for paging and accepts `context` alongside a query. With `session` omitted they read the current main session's persisted JSONL, via the documented `classic.SessionStart.transcript_path`; no path is guessed and `$.session.messages()` is not treated as full history. The classic binding survives typed `session.start`, which fires later. Without that path, current-session history calls refuse and the boot says history is unavailable. Subagent history calls refuse rather than silently exposing the main transcript.
|
|
34
34
|
|
|
35
35
|
Explicit `session` selectors use the [local cross-harness corpus](history-sessions.md), including Pi/Claude/Codex files, without needing the current main transcript to have a head yet. Explicitly selecting the current Claude session still uses its strict live binding. Offline Claude targets prefer non-attachment graph leaves when available, then select the last remaining leaf in transcript order; no leaves still refuses. The persisted Claude decoder is shared under `src/history/claude.ts`; its plugin entry remains in `plugins/claude/src/history.ts`.
|
|
36
36
|
|
package/docs/codex.md
CHANGED
|
@@ -37,7 +37,7 @@ Keep the forms separate: `token_budget` is a table here, so do not also write `t
|
|
|
37
37
|
|
|
38
38
|
- **A boot per native window.** The `SessionStart` hook reads the thread's native rollout, binds the thread to this Codex root session, cwd, model, transcript and current window, and returns the shared notes boot with a window marker. The boot is deduped by the host's own persisted `hooks.additional_context` record for that exact thread and window, never by a quoted marker. A compact creates a new native window and therefore a fresh boot.
|
|
39
39
|
- **Codex's `new_context` and `get_context_remaining`.** They remain Codex's tools. notesoup has no MCP reset or budget fallback, and an MCP call cannot trigger a reset.
|
|
40
|
-
- **Five notebooks** through `notes_write`, `notes_update`, `notes_read
|
|
40
|
+
- **Five notebooks** through `notes_write`, `notes_update`, `notes_read` and `notes_list` (add `query` to search). `NOTESOUP_HOME` overrides the root (default `~/.agents/notes`); a root thread's agent name is `NOTESOUP_AGENT` or `anonymous`.
|
|
41
41
|
- **Native history** through `history_list` and `history_read`: the root thread's events and a child's own ancestry, addressed by stable session-wide seqs. The boot's window tree retains native window UUIDs for orientation. Optional `session` targets other local sessions/harnesses, and `history_list` accepts `session: "*"` with a query for cross-session search; see [cross-session history](history-sessions.md).
|
|
42
42
|
- **Per-turn model identity.** `@model` follows the current turn's `x-codex-turn-metadata.model`, not the model recorded at thread start. The start model only labels the boot.
|
|
43
43
|
- **Subagents and forks.** `SubagentStart` binds the child or fork to its own transcript while keeping the parent's root session. Its `@self` notebook is the slugged `agent_type` (for example `worker`), not the parent's.
|
package/docs/dsh.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# DeepSeek Harness adapter
|
|
2
2
|
|
|
3
|
-
notesoup for **dsh 0.2.1-alpha.2** gives the agent a fresh page when context runs low: frozen boot text, the five notebooks,
|
|
3
|
+
notesoup for **dsh 0.2.1-alpha.2** gives the agent a fresh page when context runs low: frozen boot text, the five notebooks, six notes/history tools, `get_context_remaining`, and `empty_brain`. A reset makes **zero model calls**. The old conversation leaves the model surface and remains in the session log for history reads. `notes_list` browses the notebooks or returns match lines and offsets when given `query`. Dream is not registered on dsh.
|
|
4
4
|
|
|
5
5
|
Install the package in your chosen dsh profile with `dsh plugin --profile <profile> add notesoup`, then copy the model declaration from [the profile patch example](dsh.profile.patch.yml) into `$DSH_HOME/profiles/<profile>/cordis.patch.yml`. The package bundle patch disables `compaction-basic` and inserts `notesoup-engine` and `notesoup`. Do not duplicate those rows when adding the model declaration. A source checkout needs `npm ci --ignore-scripts` and `npm run build`; use absolute `file:///.../dist/plugins/dsh/engine.js` and `file:///.../dist/plugins/dsh/index.js` module names. The example shows all rows for a profile assembled without the package bundle.
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ On load and before requests, preflight probes `systemPrompt.section`, `tools.reg
|
|
|
14
14
|
|
|
15
15
|
The boot is a `systemPrompt.section` at order **2450**, with `interpolate: false`. Shared snapshot/render functions read the five notebooks once, using a captured timestamp. Rendering is deterministic for those inputs. A `plugin:notesoup/window` record stores the ordinal, id, timestamp, digest and exact boot text. `agent/created` adopts it before the first assembly. Notes written later appear in the next window's boot. Missing records reconstruct from the notesoup compact checkpoint, or from the marked root system section. Neither path rereads notes or regenerates a summary. Records are informational; checkpoints control the model surface.
|
|
16
16
|
|
|
17
|
-
`history_list` and `history_read` obtain the full raw log through `ctx.sessionQuery.readSession`, then feed the shared pairing, paging and literal
|
|
17
|
+
`history_list` and `history_read` obtain the full raw log through `ctx.sessionQuery.readSession`, then feed the shared pairing, `after` / `before` paging and literal search with optional `context` around hits. Public history seq **1** is native dsh seq **0**; always use the seq a notesoup tool returns. A fork's selected seed prefix is available in its history; no sibling or parent suffix is fetched. Tool results are paired at their call seq. Text blocks are verbatim; other recorded blocks are shown as JSON. Omit `session` to browse the current session. Explicit `session: "dsh:<id-or-prefix>"` resolves through `ctx.sessionQuery.listSessions()` and reads with `readSession`; `session: "*"` with a query also searches the Pi/Claude/Codex local-file corpus. DSH service-backed discovery is available only inside DSH. All hits and continuation recipes retain their canonical session identity; see [cross-session history](history-sessions.md).
|
|
18
18
|
|
|
19
19
|
## Reset and budget
|
|
20
20
|
|
package/docs/history-sessions.md
CHANGED
|
@@ -15,7 +15,7 @@ history_read({ session: "claude:full-session-id", seq: 42 })
|
|
|
15
15
|
|
|
16
16
|
Within the requested harness an exact ID wins over prefixes. Without a harness, resolution checks the current harness first (exact ID, then prefixes); only if it has no matches are the other harnesses checked. No match returns `unknown_session`. Multiple matches return `ambiguous_session` with up to five qualified candidates; specify a harness or a longer ID rather than guessing.
|
|
17
17
|
|
|
18
|
-
Explicit targeting always returns the canonical `session: "<harness>:<full-id>"`, even when the target
|
|
18
|
+
Explicit targeting always returns the canonical `session: "<harness>:<full-id>"`, even when the target is the current session. Headers become `session <harness>:<id> | seq <seq> | <role>`. Copy that session into `history_read` and any continuation reads. Paging, `expand` and `neighborhood` recipes already carry it. Structured pages expose `has_older` and `has_newer`; use the first or last non-context row's seq as `before` or `after`, respectively. For example: `→ newer: {"session":"<harness>:<full-id>","after":42}`. An `after` bound pages forward; otherwise the page starts at the newest eligible end. See [tool results](tool-results.md#bounds-and-continuation) for query context and bounds.
|
|
19
19
|
|
|
20
20
|
## Browse or search across sessions
|
|
21
21
|
|
|
@@ -24,16 +24,15 @@ Any selector containing `*` selects multiple sessions; `*` matches any string an
|
|
|
24
24
|
```js
|
|
25
25
|
history_list({ session: "*" }) // Recent sessions, one opening prompt/topic each
|
|
26
26
|
history_list({ session: "*", query: ["deployment", "rollback"], limit: 20 })
|
|
27
|
-
history_list({ session: "codex:*", query: "migration", roles: ["tool"],
|
|
27
|
+
history_list({ session: "codex:*", query: "migration", roles: ["tool"], after: "2026-10-01", context: 1 })
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
- With a non-empty `query`, matching is literal, case-insensitive, and ORs a list of texts, as in one-session search. Local files are conservatively pre-filtered before full decoding: JSON escapes, Unicode case folding, generated event text and inherited Codex history must not lose hits. Uncertain cases use the full decoder. A possible hit in a Pi or Claude file stops the prefilter early: the strict decoder will read and validate the file next.
|
|
31
|
-
- Without
|
|
32
|
-
-
|
|
33
|
-
- `history_read` refuses wildcard selectors with `invalid_session`; take a specific `session` and `seq` from
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
- Search hits are merged by event time, oldest first, with a deterministic session/seq tie-break; untimed events sort before timed events. For query searches, `limit` counts from the newest event end by default, or the oldest with `from: "oldest"`. The complete text and structured result still share the 32 KiB budget, so large previews can reduce the admitted page.
|
|
31
|
+
- Without a non-empty `query`, return a recent-sessions overview. Consider sessions newest-modified first, or oldest-modified first with `after`; stop loading once `limit` sessions (default 20) produce a representative. Apply `roles`, `after` and `before` before choosing a representative. Without roles, prefer the first visible user event, falling back to the latest visible assistant event or the latest event of any role. With roles, choose the latest matching visible event. Return the representatives oldest first by event time.
|
|
32
|
+
- Wildcard bounds take only ISO 8601 times, both exclusive. Seqs from different sessions cannot define a common range. Time bounds exclude events with no usable timestamp.
|
|
33
|
+
- `history_read` refuses wildcard selectors with `invalid_session`; take a specific `session` and `seq` from the result instead.
|
|
34
|
+
- A query searches all roles, including tool arguments/output and injected context; `roles` can narrow the hits. `context: N` includes up to N neighbors on each side from the hit’s own session, even outside the hit bounds. There are no folded rows.
|
|
35
|
+
- Hits and context are merged oldest first by event time, with a deterministic session/seq tie-break; untimed events sort first. `limit` counts hits from the newest end by default or from the oldest end with `after`. The complete text and structured result still share the 32 KiB budget.
|
|
37
36
|
- Each event carries its canonical `session`. `has_older` and `has_newer` indicate more matching results beyond the page; an overview with unvisited sessions may have more even if those sessions have no representative. Narrow by session pattern, query, roles or time rather than trying to page across per-session seqs.
|
|
38
37
|
|
|
39
38
|
## Local discovery and limits
|
|
@@ -51,7 +50,7 @@ The default roots respect `PI_CODING_AGENT_DIR` (Pi agent directory), `CLAUDE_CO
|
|
|
51
50
|
|
|
52
51
|
## Strict recent-session cache
|
|
53
52
|
|
|
54
|
-
Only an unfiltered wildcard overview uses the persistent offline representative cache: no nonempty query and no `roles`, `
|
|
53
|
+
Only an unfiltered wildcard overview uses the persistent offline representative cache: no nonempty query and no `roles`, `after`, or `before`. Empty queries still mean an overview. Explicit session reads/lists, searches, filtered overviews, DSH service descriptors and the current live binding do not use this cache. Session discovery, modified-time ordering, representative ordering, output budgeting and full event-preview limits are unchanged.
|
|
55
54
|
|
|
56
55
|
A cold miss deliberately reads and strictly decodes the whole transcript, including selected Codex ancestry. It saves only the complete selected event, canonical session identity, notice and source metadata—not a projection, header-only approximation or full-text index. Entries are versioned with the decoder/selection contract; decoder or presentation changes must bump that version. The key includes the canonical root transcript path, harness and session ID. Every source has a `dev`/`ino`/size/nanosecond mtime/ctime fingerprint taken before reading and checked after decoding. Codex records the actual root and ancestor files, and cache hits re-run native lineage discovery so newly ambiguous or missing sources cannot be hidden by unchanged file fingerprints. The fingerprint list must exactly match the root and lineage witness list.
|
|
57
56
|
|
package/docs/notes-library.md
CHANGED
|
@@ -41,12 +41,18 @@ The standalone store does **not** accept `cwd`: its `projectKey` is already the
|
|
|
41
41
|
- `list({ glob?, crumpled? }?)` returns `Promise<NoteRow[]>`, sorted by update time descending with address tie-breaking. Rows contain address, scope, virtual path, metadata, body, and body byte size. Crumpled notes are excluded by default; `crumpled: true` returns only crumpled notes.
|
|
42
42
|
- `search(queries: string[], { glob?, crumpled? }?)` returns `Promise<NoteSearchRow[]>`, sorted by address, with the same selection and crumpled-note rules. Rows also carry body-budget `warnings`. An empty queries array returns matching notes with empty `matches`. Otherwise search is case-insensitive literal OR over body lines; matches contain one-based `line`, `text`, and code-point `offsetChars` into the body. Neither listing nor search increments access metadata.
|
|
43
43
|
|
|
44
|
-
`list` and `search` share `NotesQuery`: **glob is the only notebook/path selector**. Omit it
|
|
44
|
+
`list` and `search` share `NotesQuery`: **glob is the only notebook/path selector**. Omit it for the five current notebooks. Explicit `*` or `**` searches all notebooks, including other sessions, projects, agents and models (any pattern without `@` or `/` matches note filenames at any depth as `**/<pattern>`); `@sessions/*/**` selects all session notebooks. Use `@project/**`, `@self/**`, or `@projects/<name>/**` to select a notebook. The former `scope`/`who` query parameters are removed, without compatibility aliases. Row metadata still includes scope.
|
|
45
45
|
|
|
46
|
-
The library returns full data, not tool envelopes or paginated/truncated output. `NoteError` exposes the existing named store refusals through `code`, with `lineNumbers` for ambiguous edits and `editIndex` for a failed edit. Runtime API fields and known persisted note metadata use camelCase; Pi tool wire fields such as `updated_at`, `offset_chars`, and `replace_all` retain their established names. The notes partition status field is `NoteQueryStatus.namespacesUnavailable` in the library and `namespaces_unavailable` on the `notes_list
|
|
46
|
+
The library returns full data, not tool envelopes or paginated/truncated output. `NoteError` exposes the existing named store refusals through `code`, with `lineNumbers` for ambiguous edits and `editIndex` for a failed edit. Runtime API fields and known persisted note metadata use camelCase; Pi tool wire fields such as `updated_at`, `offset_chars`, and `replace_all` retain their established names. The notes partition status field is `NoteQueryStatus.namespacesUnavailable` in the library and `namespaces_unavailable` on the `notes_list` wire; both replace `NoteQueryStatus.homesUnavailable` and `homes_unavailable` with no compatibility alias, and the on-disk layout is unchanged. Unrecognized frontmatter keys, including old snake_case metadata, are preserved as ordinary extras; they are not interpreted as current camelCase fields or migrated automatically. Invalid addresses/identities and filesystem failures reject; only a missing `read` returns `undefined`. Notes remain markdown files with the existing size limits and same-directory atomic rename. Same-file read/modify/write work is serialized by absolute physical filename across all store instances in this process (including `.md` address aliases). Mutations additionally acquire notebook admission locks in stable order before file locks so concurrent stores cannot admit a sixth pin; reads/scans only acquire file locks. Symlink/case aliases and cross-process locking are not guaranteed. `list` and `search` asynchronously traverse notebooks and serialize each discovered file read against pending mutations, but are not global snapshots and may not discover a file created after traversal. Foreign named notebooks can be read, but their bodies cannot be written or edited through the store. Named project and session reads do not update access metadata. These are cooperative address rules, not an OS security sandbox.
|
|
47
47
|
|
|
48
48
|
Addresses are a relative path (a current-session note), `@project/`, `@human/`, `@self/`, `@model/`, or explicit `@projects/<slug>/`, `@sessions/<id>/`, `@agents/<slug>/` and `@models/<slug>/`. Named project and session addresses are read-only, including for rename sources and destinations. Session IDs use the same safe single-directory-component grammar as `NotesIdentity.sessionId`, not the agent/model slug grammar. Only the first character of an address is sigil-position: an unknown leading `@head` refuses, while `@` inside the path (`release@v1.md`, `@project/mail/alice@example.com.md`) is an ordinary character. Relative self/model addresses resolve to the supplied identity. Results show the current agent's and model's notes as `@self/` and `@model/`; only other agents' or models' notes carry an explicit `@agents/<slug>/` or `@models/<slug>/`. Globs accept either form. The disk layout remains `pi/session/<sessionId>/`, `project/<projectKey>/`, `human/`, `agents/<agent>/`, and `models/<model>/`. No data migration happens on library import or construction. Notes already using camelCase metadata retain their metadata; old snake_case keys are preserved as unrecognized extras, not interpreted or migrated. New session notes record the supplied project key.
|
|
49
49
|
|
|
50
|
+
### Cross-process project claims
|
|
51
|
+
|
|
52
|
+
An unchanged project marker is resolved without a lock. To allocate a notebook, adopt a remote, or update its display path, the resolver takes a SQLite writer transaction on `<home>/.project-claim.sqlite` and checks the markers again. This requires the built-in `node:sqlite` (available without a flag in Node 22.13+) and a local filesystem. The database stores no notes. Leave the file in place: the transaction, not the file's existence, is the lock. A competing writer waits up to five seconds; if the holder exits, the OS releases its lock.
|
|
53
|
+
|
|
54
|
+
A new notebook is staged under the notes home and renamed into `project/` with its marker already present (both locations must be on the same filesystem). Killing a writer before the rename can leave a hidden staging directory, but it neither claims a name nor blocks other sessions. When upgrading, stop old Notesoup processes sharing the home before running the new version; the old directory lock and SQLite do not coordinate. No notes migration is needed.
|
|
55
|
+
|
|
50
56
|
## Per-note policy
|
|
51
57
|
|
|
52
58
|
`NoteMeta` has optional `pinned?: boolean`, `budget?: number`, and `readonly?: boolean` fields. Set these in on-disk frontmatter or in write/update options. Values are validated on parse and mutation: booleans must be actual booleans; budget must be a positive safe integer. Invalid values raise `NoteError("invalid_policy", ...)` without saving. Unknown frontmatter remains intact across rewrites. As before, a leading frontmatter block in `write`'s **content** is stripped, not used to set metadata; use the options or edit the on-disk frontmatter instead.
|
|
@@ -58,7 +64,7 @@ Addresses are a relative path (a current-session note), `@project/`, `@human/`,
|
|
|
58
64
|
- Every physical notebook allows **5 live pins**, including existing default pages. Crumpled pins don't count. New pinning, writes that restore notes, explicit restores, and moves/renames all check admission and refuse with `pin_limit` before mutation if they would add a sixth pin. Same-notebook moves of an already-live pin don't consume another slot. Existing over-cap notes can still be edited, unpinned or crumpled. Boot defensively selects at most five pins, default-page-first then path order, visibly naming omitted pins in a manually over-cap notebook. Pinned bodies are injected whole, with budget warnings rather than truncation.
|
|
59
65
|
- `readonly: true` is a **soft lock**, not an authorization/security boundary. Existing locked notes refuse changes, overwrite, crumple/restore, rename/move, and dream deletion with `readonly`. Explicit `readonly: false` permits a metadata-only unlock or unlock plus the requested mutation in one call. A new/unlocked note may be written and locked together. Replacing a locked crumpled move target also requires explicit false. Reads/access counters still write, and filesystem edits can bypass the lock.
|
|
60
66
|
|
|
61
|
-
The
|
|
67
|
+
The four model tools accept the same policy options (write/update) and return effective policy visibly in receipts, read metadata and `notes_list` rows, alongside budget warnings. Notebook pin admission is serialized across stores **within this process**; manual edits and other processes are not locked by this cooperative API.
|
|
62
68
|
|
|
63
69
|
## Library and plugin boundary
|
|
64
70
|
|
package/docs/skills.md
CHANGED
|
@@ -18,10 +18,6 @@ One session dreams over one project at a time. New session notes record their pr
|
|
|
18
18
|
|
|
19
19
|
## The dream lock and Git audit
|
|
20
20
|
|
|
21
|
-
`dream_begin` takes
|
|
21
|
+
`dream_begin` takes a SQLite writer transaction on `<home>/.dream.lock.sqlite` and commits a Git baseline. Only one dream can run per notes home, even across projects; competing dreams refuse immediately. This lock is separate from project claims and does not block ordinary note reads or writes. The baseline and end commits snapshot the whole home, so they can include ordinary edits made by other sessions as well as edits made by the dream.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
rm "${NOTESOUP_HOME:-$HOME/.agents/notes}/.dream.lock"
|
|
27
|
-
```
|
|
23
|
+
`dream_end` commits and releases the lock. Session shutdown releases it without a final commit. If the process dies, the OS releases the lock; completed note edits stay on disk. Leave the SQLite file in place. Stop older processes sharing this home when upgrading: the old existence lock and the transaction lock do not coordinate.
|