notesoup 0.42.0 → 0.44.0

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.
Files changed (126) hide show
  1. package/dist/src/boot/render.js +11 -20
  2. package/dist/src/boot/snapshot.d.ts +2 -0
  3. package/dist/src/boot/snapshot.js +4 -5
  4. package/dist/src/boot/text.js +4 -2
  5. package/dist/src/budget/parse.d.ts +14 -0
  6. package/dist/src/budget/parse.js +36 -0
  7. package/dist/src/budget/policy.js +2 -7
  8. package/dist/src/budget/text.d.ts +2 -0
  9. package/dist/src/budget/text.js +2 -0
  10. package/dist/src/claude/helper.js +3 -4
  11. package/dist/src/claude/thresholds.js +45 -66
  12. package/dist/src/dream/lock.js +6 -13
  13. package/dist/src/dream/report.js +5 -15
  14. package/dist/src/history/history.js +4 -2
  15. package/dist/src/history/query.js +10 -22
  16. package/dist/src/notes/address.d.ts +2 -3
  17. package/dist/src/notes/address.js +10 -22
  18. package/dist/src/notes/errors.d.ts +2 -0
  19. package/dist/src/notes/errors.js +5 -0
  20. package/dist/src/notes/frontmatter.js +16 -2
  21. package/dist/src/notes/identity.js +2 -4
  22. package/dist/src/notes/paths.d.ts +7 -2
  23. package/dist/src/notes/paths.js +18 -60
  24. package/dist/src/notes/project-home.d.ts +25 -0
  25. package/dist/src/notes/project-home.js +231 -0
  26. package/dist/src/notes/store.d.ts +4 -2
  27. package/dist/src/notes/store.js +52 -45
  28. package/dist/src/pi/boot.js +17 -9
  29. package/dist/src/pi/budget.d.ts +3 -3
  30. package/dist/src/pi/budget.js +11 -11
  31. package/dist/src/pi/dream/cli.js +43 -11
  32. package/dist/src/pi/estimate.d.ts +1 -5
  33. package/dist/src/pi/estimate.js +4 -4
  34. package/dist/src/pi/history.js +1 -4
  35. package/dist/src/pi/notes/adapter.d.ts +1 -1
  36. package/dist/src/pi/notes/adapter.js +3 -3
  37. package/dist/src/pi/reset/artifacts.d.ts +0 -2
  38. package/dist/src/pi/reset/artifacts.js +4 -4
  39. package/dist/src/pi/reset/committed.js +2 -2
  40. package/dist/src/pi/runtime.js +8 -5
  41. package/dist/src/pi/thresholds.js +5 -9
  42. package/dist/src/pi/tool-result.d.ts +1 -4
  43. package/dist/src/pi/tool-result.js +1 -1
  44. package/dist/src/pi/window.d.ts +5 -0
  45. package/dist/src/pi/window.js +7 -0
  46. package/dist/src/settings.d.ts +2 -0
  47. package/dist/src/settings.js +4 -3
  48. package/dist/src/tools/history.js +4 -7
  49. package/dist/src/tools/notes.d.ts +47 -21
  50. package/dist/src/tools/notes.js +20 -19
  51. package/dist/src/tools/output.d.ts +0 -3
  52. package/dist/src/tools/output.js +1 -9
  53. package/dist/src/tools/result.d.ts +1 -0
  54. package/dist/src/tools/result.js +14 -20
  55. package/dist/src/tools/schema.d.ts +0 -1
  56. package/dist/src/tools/schema.js +0 -1
  57. package/dist/test/agent-loop.test.js +1 -2
  58. package/dist/test/boot.integration.test.js +1 -1
  59. package/dist/test/claude-mod.test.js +253 -10
  60. package/dist/test/claude-validation.test.d.ts +1 -0
  61. package/dist/test/claude-validation.test.js +73 -0
  62. package/dist/test/dream-skill.test.js +2 -4
  63. package/dist/test/dream.test.js +14 -0
  64. package/dist/test/helpers/extension.js +1 -1
  65. package/dist/test/history.integration.test.js +2 -1
  66. package/dist/test/host-neutral.test.js +15 -0
  67. package/dist/test/notes-library.test.js +30 -1
  68. package/dist/test/notes.integration.test.js +7 -7
  69. package/dist/test/notes.test.js +36 -14
  70. package/dist/test/project-home.test.d.ts +1 -0
  71. package/dist/test/project-home.test.js +134 -0
  72. package/dist/test/reset-lifecycle.test.js +1 -1
  73. package/docs/claude-code-mod.md +5 -3
  74. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  75. package/mods/notesoup/dist/claude/helper.js +359 -218
  76. package/mods/notesoup/hooks/register.ts +158 -67
  77. package/mods/notesoup/playbook.md +1 -1
  78. package/mods/notesoup/skills/dream/SKILL.md +1 -1
  79. package/mods/notesoup/skills/memory/SKILL.md +62 -0
  80. package/package.json +5 -3
  81. package/playbook.md +1 -1
  82. package/skills/dream/SKILL.md +1 -1
  83. package/skills/memory/SKILL.md +2 -1
  84. package/src/boot/render.ts +11 -21
  85. package/src/boot/snapshot.ts +5 -5
  86. package/src/boot/text.ts +4 -2
  87. package/src/budget/parse.ts +39 -0
  88. package/src/budget/policy.ts +2 -6
  89. package/src/budget/text.ts +3 -0
  90. package/src/claude/helper.ts +4 -4
  91. package/src/claude/thresholds.ts +45 -62
  92. package/src/dream/lock.ts +3 -9
  93. package/src/dream/report.ts +5 -10
  94. package/src/history/history.ts +4 -2
  95. package/src/history/query.ts +10 -23
  96. package/src/notes/address.ts +9 -21
  97. package/src/notes/errors.ts +6 -0
  98. package/src/notes/frontmatter.ts +12 -2
  99. package/src/notes/identity.ts +1 -3
  100. package/src/notes/paths.ts +14 -52
  101. package/src/notes/project-home.ts +197 -0
  102. package/src/notes/store.ts +46 -45
  103. package/src/pi/boot.ts +15 -17
  104. package/src/pi/budget.ts +10 -11
  105. package/src/pi/dream/cli.ts +35 -10
  106. package/src/pi/estimate.ts +4 -4
  107. package/src/pi/history.ts +1 -5
  108. package/src/pi/notes/adapter.ts +3 -3
  109. package/src/pi/reset/artifacts.ts +4 -4
  110. package/src/pi/reset/committed.ts +2 -2
  111. package/src/pi/runtime.ts +7 -6
  112. package/src/pi/thresholds.ts +5 -11
  113. package/src/pi/tool-result.ts +1 -1
  114. package/src/pi/window.ts +8 -0
  115. package/src/settings.ts +4 -3
  116. package/src/tools/history.ts +4 -8
  117. package/src/tools/notes.ts +22 -25
  118. package/src/tools/output.ts +1 -12
  119. package/src/tools/result.ts +14 -19
  120. package/src/tools/schema.ts +0 -1
  121. package/dist/src/dream/playbook.d.ts +0 -1
  122. package/dist/src/dream/playbook.js +0 -2
  123. package/dist/src/pi/reset/text.d.ts +0 -4
  124. package/dist/src/pi/reset/text.js +0 -7
  125. package/src/dream/playbook.ts +0 -3
  126. package/src/pi/reset/text.ts +0 -9
@@ -8,13 +8,16 @@
8
8
  */
9
9
  import assert from "node:assert/strict";
10
10
  import { execFileSync } from "node:child_process";
11
- import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
11
+ import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
12
12
  import { join } from "node:path";
13
13
  import test from "node:test";
14
14
  import { Check } from "typebox/value";
15
15
  import { parseNote } from "../src/notes/frontmatter.js";
16
16
  import { projectKey } from "../src/notes/paths.js";
17
+ import { globToRegExp } from "../src/notes/address.js";
17
18
  import { listNotes, physicalPath, scopeDir } from "./helpers/notes.js";
19
+ import { notesList, notesSearch } from "../src/tools/notes.js";
20
+ import { notesIdentityFromPi } from "../src/pi/notes/adapter.js";
18
21
  import { call, context, explicitBoot, makeExtension, manager, resultData, resultError, resultRead } from "./helpers/extension.js";
19
22
  import { installExtensionTestHooks } from "./helpers/extension-test-environment.js";
20
23
  const testEnvironment = installExtensionTestHooks("notesoup-notes");
@@ -23,7 +26,7 @@ function freshRoot() {
23
26
  }
24
27
  function assertReceiptIdentity(value, address, scope, ctx) {
25
28
  assert.equal(value.address, address);
26
- assert.equal(value.project_key, scope === "project" ? projectKey(ctx.cwd) : undefined);
29
+ assert.equal(value.project_key, scope === "project" ? projectKey(ctx.cwd, process.env.PI_NOTES_HOME) : undefined);
27
30
  }
28
31
  test("exactly the five notes tools are registered; the legacy five are gone", () => {
29
32
  const captured = makeExtension(manager());
@@ -110,7 +113,7 @@ test("write lands a real markdown file with harness frontmatter and a pure body"
110
113
  for (const key of ["createdAt", "updatedAt", "lastAccessed"]) {
111
114
  assert.match(raw, new RegExp(`^${key}: \\d{4}-\\d{2}-\\d{2}T`, "m"), `frontmatter renders ${key} via localIso`);
112
115
  }
113
- assert.equal(parseNote(raw).meta.project, projectKey(ctx.cwd), "a newly-created session note records its existing project key");
116
+ assert.equal(parseNote(raw).meta.project, projectKey(ctx.cwd, root), "a newly-created session note records its existing project key");
114
117
  assertReceiptIdentity(result, "a/b.md", "session", ctx);
115
118
  assert.equal(result.outcome, "created");
116
119
  assert.equal(existsSync(join(scopeDir("session", ctx), ".session.json")), false, "ownership is stored in note frontmatter, not a sidecar");
@@ -126,8 +129,8 @@ test("session-note project ownership is per note, persistent across sessions, an
126
129
  const cwdB = join(testEnvironment.cwd, "project-b");
127
130
  mkdirSync(cwdA, { recursive: true });
128
131
  mkdirSync(cwdB, { recursive: true });
129
- const projectA = projectKey(cwdA);
130
- const projectB = projectKey(cwdB);
132
+ const projectA = projectKey(cwdA, process.env.PI_NOTES_HOME);
133
+ const projectB = projectKey(cwdB, process.env.PI_NOTES_HOME);
131
134
  assert.notEqual(projectA, projectB);
132
135
  const firstSession = manager();
133
136
  const firstCaptured = makeExtension(firstSession);
@@ -164,9 +167,8 @@ test("session-note project ownership is per note, persistent across sessions, an
164
167
  });
165
168
  test("linked git worktrees share the main checkout's project key", () => {
166
169
  freshRoot();
167
- // realpath keeps the fixture's gitdir pointer and the asserted paths on one spelling
168
- // (macOS temp roots live under the /var -> /private/var symlink).
169
- const root = realpathSync(testEnvironment.cwd);
170
+ // The fixture root is used as spelled: a symlinked temp root must still hash to one key.
171
+ const root = testEnvironment.cwd;
170
172
  const main = join(root, "repo");
171
173
  mkdirSync(main, { recursive: true });
172
174
  const git = (args) => {
@@ -176,8 +178,8 @@ test("linked git worktrees share the main checkout's project key", () => {
176
178
  git(["commit", "-q", "--allow-empty", "-m", "init"]);
177
179
  const worktree = join(root, "wt");
178
180
  git(["worktree", "add", "-q", "--detach", worktree]);
179
- assert.equal(projectKey(worktree), projectKey(main), "a linked worktree resolves to the main checkout's key");
180
- assert.equal(projectKey(join(worktree, "gone", "deeper")), projectKey(main), "a nonexistent subdirectory still resolves through its worktree");
181
+ assert.equal(projectKey(worktree, process.env.PI_NOTES_HOME), projectKey(main, process.env.PI_NOTES_HOME), "a linked worktree resolves to the main checkout's key");
182
+ assert.equal(projectKey(join(worktree, "gone", "deeper"), process.env.PI_NOTES_HOME), projectKey(main, process.env.PI_NOTES_HOME), "a nonexistent subdirectory still resolves through its worktree");
181
183
  assert.equal(scopeDir("project", context(manager(), undefined, undefined, true, worktree)), scopeDir("project", context(manager(), undefined, undefined, true, main)), "@project uses the same physical home from both checkouts");
182
184
  });
183
185
  test("unrecognized metadata remains ordinary frontmatter; invalid project ownership stays unknown", async () => {
@@ -223,7 +225,7 @@ project: 17
223
225
 
224
226
  invalid owner`);
225
227
  assert.equal(parseNote(readFileSync(invalidFile, "utf8")).meta.project, 17);
226
- assert.notEqual(parseNote(readFileSync(invalidFile, "utf8")).meta.project, projectKey(ctx.cwd), "invalid ownership does not match the current project key");
228
+ assert.notEqual(parseNote(readFileSync(invalidFile, "utf8")).meta.project, projectKey(ctx.cwd, process.env.PI_NOTES_HOME), "invalid ownership does not match the current project key");
227
229
  await call(captured, "notes_write", { address: "invalid.md", content: "still invalid" }, ctx);
228
230
  assert.equal(parseNote(readFileSync(invalidFile, "utf8")).meta.project, 17, "an invalid value remains unknown and is not replaced with cwd-derived ownership");
229
231
  assert.equal(existsSync(join(scopeDir("session", ctx), ".session.json")), false, "new notes use no ownership sidecar");
@@ -338,14 +340,19 @@ test("empty results distinguish hidden notes and unavailable homes", async () =>
338
340
  await call(captured, "notes_update", { address: "@human/hidden.md", crumpled: true }, ctx);
339
341
  const hidden = resultData(await call(captured, "notes_search", { query: "needle", glob: "@human/**" }, ctx));
340
342
  assert.deepEqual(hidden.files, [], "a crumpled note is hidden from search");
343
+ const identity = notesIdentityFromPi(ctx);
341
344
  const broken = scopeDir("project", ctx);
342
345
  mkdirSync(join(broken, ".."), { recursive: true });
346
+ rmSync(broken, { recursive: true });
343
347
  writeFileSync(broken, "not a directory");
344
- const partial = resultData(await call(captured, "notes_list", { glob: "**" }, ctx));
348
+ const partialResult = await notesList.execute({ glob: "**" }, identity);
349
+ assert.ok(partialResult.ok);
350
+ const partial = partialResult.data;
345
351
  assert.deepEqual(partial.homes_unavailable, ["@project"]);
346
352
  assert.deepEqual(partial.files, []);
347
- const searched = resultData(await call(captured, "notes_search", { query: "needle", glob: "**" }, ctx));
348
- assert.deepEqual(searched.homes_unavailable, ["@project"]);
353
+ const searchResult = await notesSearch.execute({ query: "needle", glob: "**" }, identity);
354
+ assert.ok(searchResult.ok);
355
+ assert.deepEqual(searchResult.data.homes_unavailable, ["@project"]);
349
356
  writeFileSync(join(process.env.PI_NOTES_HOME, "agents"), "not a directory");
350
357
  const namespace = resultData(await call(captured, "notes_list", { glob: "@agents/*/note.md" }, ctx));
351
358
  assert.deepEqual(namespace.homes_unavailable, ["@agents"]);
@@ -528,3 +535,18 @@ async function withAgent(name, run) {
528
535
  process.env.PI_NOTES_AGENT = previous;
529
536
  }
530
537
  }
538
+ test("a symlinked checkout resolves the canonical root, so one checkout has one project home", () => {
539
+ const root = realpathSync(testEnvironment.cwd);
540
+ const real = join(root, "real-repo");
541
+ mkdirSync(join(real, ".git"), { recursive: true });
542
+ const linked = join(root, "linked-repo");
543
+ symlinkSync(real, linked);
544
+ assert.equal(projectKey(linked, process.env.PI_NOTES_HOME), "real-repo", "the name comes from the canonical root");
545
+ assert.equal(projectKey(real, process.env.PI_NOTES_HOME), "real-repo", "both spellings reuse one home");
546
+ });
547
+ test("a glob ? matches exactly one non-slash character", () => {
548
+ const pattern = globToRegExp("a?.md");
549
+ assert.equal(pattern.test("ab.md"), true, "? matches one ordinary character");
550
+ assert.equal(pattern.test("a.md"), false, "? is not optional");
551
+ assert.equal(pattern.test("a/b.md"), false, "? never matches a path separator");
552
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,134 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdirSync, mkdtempSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import test from "node:test";
6
+ import { Check } from "typebox/value";
7
+ import { createNotesStore } from "../src/notes/index.js";
8
+ import { assertAddress } from "../src/notes/address.js";
9
+ import { normalizeRemote, projectKey } from "../src/notes/project-home.js";
10
+ import { notesList, notesRead, notesSearch, notesUpdate, notesWrite } from "../src/tools/notes.js";
11
+ import { success } from "../src/tools/result.js";
12
+ function fixture(t) {
13
+ const root = realpathSync(mkdtempSync(join(tmpdir(), "notesoup-project-home-")));
14
+ t.after(() => rmSync(root, { recursive: true, force: true }));
15
+ const home = join(root, "notes");
16
+ const repo = (path, origin) => {
17
+ const cwd = join(root, path);
18
+ mkdirSync(join(cwd, ".git"), { recursive: true });
19
+ writeFileSync(join(cwd, ".git/config"), origin ? `[remote "origin"]\n\turl = ${origin}\n` : "");
20
+ return cwd;
21
+ };
22
+ const marker = (key) => JSON.parse(readFileSync(join(home, "project", key, ".project"), "utf8"));
23
+ const identity = (cwd) => ({ home, projectKey: projectKey(cwd, home), sessionId: "session", agent: "test", model: "test" });
24
+ return { root, home, repo, marker, identity };
25
+ }
26
+ function data(result) {
27
+ if (!result.ok)
28
+ assert.fail(result.error.message);
29
+ return result.data;
30
+ }
31
+ function refused(result) {
32
+ if (result.ok)
33
+ assert.fail("expected refusal");
34
+ return result.error.message;
35
+ }
36
+ test("origin identity normalizes https, scp and port-less ssh without invoking Git", t => {
37
+ const { home, repo, marker } = fixture(t);
38
+ for (const remote of ["https://user:secret@GitHub.COM/team/api.git/", "git@GitHub.COM:team/api.git", "ssh://git@GitHub.COM/team/api.git"]) {
39
+ assert.equal(normalizeRemote(remote), "github.com/team/api");
40
+ }
41
+ assert.equal(normalizeRemote("ssh://git@EXAMPLE.com:2222/team/api.git"), "example.com:2222/team/api");
42
+ const first = repo("one/api", "git@GitHub.COM:team/api.git");
43
+ const second = repo("two/renamed", "https://github.com/team/api.git");
44
+ assert.equal(projectKey(first, home), "api");
45
+ assert.equal(projectKey(second, home), "api");
46
+ assert.deepEqual(marker("api"), { id: "github.com/team/api", path: second });
47
+ });
48
+ test("same-basename repositories get readable suffixes and unmarked legacy names are taken", t => {
49
+ const { home, repo } = fixture(t);
50
+ const first = repo("one/x", "https://host/one/x");
51
+ const second = repo("two/x", "https://host/two/x");
52
+ assert.equal(projectKey(first, home), "x");
53
+ assert.equal(projectKey(second, home), "x-1");
54
+ mkdirSync(join(home, "project", "legacy"));
55
+ writeFileSync(join(home, "project", "legacy", "keep.md"), "old notes");
56
+ assert.equal(projectKey(repo("legacy"), home), "legacy-1");
57
+ assert.equal(readFileSync(join(home, "project", "legacy", "keep.md"), "utf8"), "old notes");
58
+ });
59
+ test("linked worktrees and nested directories share the main checkout home and origin", t => {
60
+ const { root, home, repo, marker } = fixture(t);
61
+ const main = repo("api", "ssh://git@HOST/team/api.git");
62
+ const worktree = join(root, "worktree");
63
+ mkdirSync(worktree);
64
+ mkdirSync(join(main, ".git/worktrees/wt"), { recursive: true });
65
+ writeFileSync(join(worktree, ".git"), `gitdir: ${join(main, ".git/worktrees/wt")}\n`);
66
+ writeFileSync(join(main, ".git/worktrees/wt/commondir"), "../..\n");
67
+ assert.equal(projectKey(main, home), "api");
68
+ assert.equal(projectKey(join(worktree, "missing/subdir"), home), "api");
69
+ assert.deepEqual(marker("api"), { id: "host/team/api", path: main });
70
+ });
71
+ test("a moved checkout reuses its remote home and updates only the display root", async (t) => {
72
+ const { root, home, repo, marker, identity } = fixture(t);
73
+ const old = repo("api", "https://host/team/api.git");
74
+ await createNotesStore(identity(old)).write("@project/decision", "keep me");
75
+ const moved = join(root, "new-name");
76
+ renameSync(old, moved);
77
+ const current = identity(moved);
78
+ assert.equal(current.projectKey, "api");
79
+ assert.deepEqual(marker("api"), { id: "host/team/api", path: moved });
80
+ assert.equal((await createNotesStore(current).read("@project/decision"))?.body, "keep me");
81
+ assert.equal(projectKey(moved, home), "api");
82
+ });
83
+ test("adding origin adopts the canonical path identity without orphaning notes", async (t) => {
84
+ const { home, repo, marker, identity } = fixture(t);
85
+ const cwd = repo("api");
86
+ await createNotesStore(identity(cwd)).write("@project/decision", "still here");
87
+ assert.deepEqual(marker("api"), { id: cwd, path: cwd });
88
+ writeFileSync(join(cwd, ".git/config"), '[remote "backup"]\nurl = https://host/wrong\n[remote "origin"]\nurl = git@HOST:team/api.git\n');
89
+ assert.equal(projectKey(cwd, home), "api");
90
+ assert.deepEqual(marker("api"), { id: "host/team/api", path: cwd });
91
+ assert.equal((await createNotesStore(identity(cwd)).read("@project/decision"))?.body, "still here");
92
+ });
93
+ test("named projects read/list/search with root and sibling receipts, without touching stored bytes", async (t) => {
94
+ const { home, repo, identity } = fixture(t);
95
+ const first = repo("one/api", "https://host/one/backend");
96
+ const second = repo("two/api", "https://host/two/service");
97
+ const own = identity(first);
98
+ const other = identity(second);
99
+ await createNotesStore(own).write("@project/decision", "needle first");
100
+ await createNotesStore(other).write("@project/decision", "needle second");
101
+ const address = "@projects/api-1/decision.md";
102
+ const file = join(home, "project/api-1/decision.md");
103
+ const before = readFileSync(file, "utf8");
104
+ const read = data(await notesRead.execute({ address }, own));
105
+ assert.equal(read.text, "needle second");
106
+ assert.equal(read.project_root, second);
107
+ assert.deepEqual(read.project_siblings, [{ name: "api", path: first }]);
108
+ assert.equal(Check(notesRead.outputSchema, read), true);
109
+ assert.match(notesRead.render(success(read)), /Same-basename projects: api \(/);
110
+ const listed = data(await notesList.execute({ glob: "@projects/*/**" }, own));
111
+ assert.deepEqual(listed.files.map(row => [row.address, row.project_root]).sort(), [["@projects/api-1/decision.md", second], ["@projects/api/decision.md", first]].sort());
112
+ assert.equal(Check(notesList.outputSchema, listed), true);
113
+ const searched = data(await notesSearch.execute({ glob: "@projects/api-1/**", query: "needle" }, own));
114
+ assert.equal(searched.files[0]?.project_root, second);
115
+ assert.equal(Check(notesSearch.outputSchema, searched), true);
116
+ assert.equal(readFileSync(file, "utf8"), before, "named-home reads never rewrite access metadata");
117
+ });
118
+ test("named project writes, edits, crumples and both move endpoints refuse, including the current home", async (t) => {
119
+ const { repo, identity } = fixture(t);
120
+ const own = identity(repo("api"));
121
+ await createNotesStore(own).write("@project/decision", "body");
122
+ const address = "@projects/api/decision";
123
+ for (const result of [
124
+ await notesWrite.execute({ address, content: "replacement" }, own),
125
+ await notesUpdate.execute({ address, edits: [{ oldText: "body", newText: "changed" }] }, own, () => ""),
126
+ await notesUpdate.execute({ address, crumpled: true }, own, () => ""),
127
+ await notesUpdate.execute({ address, rename_to: "@project/moved" }, own, () => ""),
128
+ await notesUpdate.execute({ address: "@project/decision", rename_to: "@projects/api/moved" }, own, () => ""),
129
+ ])
130
+ assert.match(refused(result), /read-only; use @project\//);
131
+ assert.equal(data(await notesRead.execute({ address }, own)).text, "body");
132
+ assert.throws(() => assertAddress("@projects/api/../decision"));
133
+ assert.throws(() => assertAddress("@projects/api"));
134
+ });
@@ -8,7 +8,7 @@ import notesoup from "../src/pi/extension.js";
8
8
  import { BOOT_TYPE, CONTINUATION_TYPE, GUIDANCE_TYPE, RESET_MARKER_TYPE } from "../src/pi/entries.js";
9
9
  import { MANUAL_WIPE_TYPE } from "../src/pi/entries.js";
10
10
  import { toolContext } from "./helpers/extension.js";
11
- import { WARNING_CONTENT } from "../src/pi/reset/text.js";
11
+ import { WARNING_CONTENT } from "../src/budget/text.js";
12
12
  import { initialResetControl, reduceResetControl, registerResetLifecycle, } from "../src/pi/reset/lifecycle.js";
13
13
  const previousNotesHome = process.env.PI_NOTES_HOME;
14
14
  const testNotesHome = mkdtempSync(join(tmpdir(), "notesoup-lifecycle-notes-"));
@@ -4,14 +4,16 @@ The package also ships `mods/notesoup`, an early-access Claude Code Mod that reg
4
4
 
5
5
  In interactive sessions it resets automatically when the measured context reaches notesoup's reset point, checking after `session.measure` and `turn.complete` and waiting for a running turn to complete. That point is derived from Claude's own auto-compact threshold instead of a fixed percent, in `src/claude/thresholds.ts`, and reaches the sandboxed hooks module through the helper's `limits` operation:
6
6
 
7
- 1. `$.session.usage({breakdown:true}).context.autoCompactThreshold` when it is a positive number, with `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` applied the way Claude applies it (it can only lower the point);
7
+ 1. `$.session.usage({breakdown:"summary"}).context.autoCompactThreshold` when it is a positive number, with `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` applied the way Claude applies it (it can only lower the point);
8
8
  2. otherwise computed from `$.session.usage().context.window` plus `CLAUDE_CODE_AUTO_COMPACT_WINDOW`, `modelSettings.<model>.autoCompactWindow` and `autoCompactWindow` (the smallest configured window wins, capped at the model window), with Claude's 20000-token output reserve and 13000-token summary buffer;
9
9
  3. otherwise the percent fallback, which expresses the same reserves on the classic 200K window.
10
10
 
11
11
  Notesoup resets one `resetMarginTokens` (default 8192) below that point, and warns one `warningRunwayTokens` (default `WARNING_RUNWAY_TOKENS`, 16384) below the reset. With automatic compaction off (`autoCompactEnabled: false` in the merged settings, or `DISABLE_AUTO_COMPACT=1`) the point becomes the effective window minus the output reserve, so the same margins still apply. Every undocumented field is type-guarded and degrades to the next source; an unresolvable point, or missing usage, logs once and skips the automatic reset. `DISABLE_COMPACT=1` is detected at `session.start`, logs once, disables the automatic reset, and makes `/clear-memory` report that it cannot run. The margins are read from the `notesoup` object of Claude's merged `$.settings.read()` (`resetMarginTokens`, `warningRunwayTokens`); any other value is ignored.
12
12
 
13
- Once per window, when the measured context crosses the warning point, `prompt.context` adds a `notesoup:warning` block carrying the shared warning text with Claude's closing instruction ("end your turn; the reset runs after it"). The warned flag resets with the window ordinal. Its own `session.compact` hook replaces the conversation with the freshly built notes boot followed by the shared continuation message — the same order and the same words as Pi — not a generated summary. `prompt.context` still recomputes but does not duplicate that retained boot. The boot's protocol block tells the model to end its turn and ask the human to run `/clear-memory`, replacing that one sentence through `BootToolNames.wipeSentence`; Pi's boot text is unchanged. Boot window IDs end in the ordinal `:0`, `:1`, etc.; retained boots restore the ordinal on resume/reload. Original transcript rows remain on disk.
13
+ Once per window, when the measured context crosses the warning point, `prompt.context` adds a `notesoup:warning` block carrying the shared warning text with Claude's closing instruction ("end your turn; the reset runs after it"). The warned flag resets with the window ordinal. Its own `session.compact` hook replaces the conversation with the freshly built notes boot followed by the shared continuation message — the same order and the same words as Pi — not a generated summary. `prompt.context` still recomputes but does not duplicate that retained boot. The boot's protocol block tells the model to end its turn and ask the human to run `/clear-memory`, replacing that one sentence through `BootToolNames.wipeSentence`; Pi's boot text is unchanged. Boot window IDs end in the ordinal `:0`, `:1`, etc.; retained boots restore the ordinal on resume/reload. Original transcript rows remain on disk. `session.end` forgets the old window, and identity is refreshed lazily from `$.session.id()`, `$.session.cwd()` and the documented `$.session.model()` (slugified, with `claude` only as a fallback). `/clear`, `/resume` and `/branch` therefore acquire a boot again without needing another `session.start`. Successful native main-session compaction invalidates a removed retained boot; vetoes, subagent compaction and precompute leave it alone.
14
14
 
15
15
  `/clear-memory` requests the same reset. While idle it submits one hidden normal-model close-out turn to let the model save notes, then resets at `turn.complete`; while busy it waits for the current turn instead. The close-out prompt is the same shared warning text the automatic path shows. This is necessary in Claude Code 2.1.295: `command.run` holds a turn, and calling compact from a detached timer skips the plugin's own compact hook. The timer only schedules the close-out prompt, never compaction. The headless (`-p` / SDK) compact capability is unsupported: automatic attempts are caught and logged once, and the manual command skips without submitting a model turn. Boot acquisition failure vetoes reset, leaving the current window intact. Claude history tools and a Claude dream backend are not implemented; budget reporting (`get_context_remaining`) remains Pi-only, while the reset points and the one warning per window now follow Claude's own configuration.
16
16
 
17
- The plugin also exposes the shared `skills/dream/SKILL.md` and its referenced `playbook.md`; the build synchronizes both projections from the canonical repository files. Validate it from a built checkout with `claude plugin validate mods/notesoup --strict`; the package build and `npm pack --dry-run` include the manifests, hooks module, helper, skill, and playbook.
17
+ The notes tools also serve subagent calls, using the same session identity and shared operations. The plugin exposes the shared memory and dream skills and the dream playbook; the build keeps these copies byte-identical to the canonical files.
18
+
19
+ `npm run typecheck` includes the mod against the vendored Claude Code 2.1.295 contract. `npm test` also typechecks it and runs `claude plugin validate mods/notesoup --strict`, skipping validation with a clear message only if `claude` is not installed. Scanner regression tests deliberately reintroduce each of the three forbidden call shapes and require the gate to fail. From a built checkout, check the real load with `claude --plugin-dir mods/notesoup -p "ok"`; a model/API failure after load is separate from a hooks-module refusal. The package build and `npm pack --dry-run` include the manifests, hooks module, helper, skills, and playbook.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"