notesoup 0.51.4 → 0.51.6

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 (37) hide show
  1. package/README.md +6 -0
  2. package/dist/plugins/pi/dream/cli.js +1 -1
  3. package/dist/plugins/pi/extension.js +4 -0
  4. package/dist/plugins/pi/notes/adapter.js +2 -2
  5. package/dist/plugins/pi/reset/artifacts.d.ts +3 -1
  6. package/dist/plugins/pi/reset/artifacts.js +3 -1
  7. package/dist/plugins/pi/runtime.js +2 -2
  8. package/dist/src/boot/text.js +1 -1
  9. package/dist/test/agent-loop.test.js +12 -12
  10. package/dist/test/boot.integration.test.js +1 -1
  11. package/dist/test/claude-mod.test.js +34 -3
  12. package/dist/test/dependencies.test.js +27 -0
  13. package/dist/test/helpers/extension.js +6 -6
  14. package/dist/test/notes.integration.test.js +2 -2
  15. package/dist/test/notes.test.js +16 -16
  16. package/dist/test/reset-lifecycle.test.js +4 -4
  17. package/docs/claude-code-mod.md +1 -1
  18. package/docs/skills.md +1 -1
  19. package/package.json +1 -1
  20. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  21. package/plugins/claude/dist/claude/helper.js +1 -1
  22. package/plugins/claude/hooks/register.ts +26 -4
  23. package/plugins/paseo/client/brain-empty-card.tsx +30 -0
  24. package/plugins/paseo/client/brain-empty-transformer.ts +43 -0
  25. package/plugins/paseo/client/notes-op-card.tsx +18 -48
  26. package/plugins/paseo/client/paper-card.tsx +36 -0
  27. package/plugins/paseo/client/sticky-card.tsx +6 -20
  28. package/plugins/paseo/index.client.tsx +5 -0
  29. package/plugins/paseo/shared/brain-empty.ts +12 -0
  30. package/plugins/paseo/test/brain-empty.test.ts +51 -0
  31. package/plugins/pi/dream/cli.ts +1 -1
  32. package/plugins/pi/extension.ts +3 -0
  33. package/plugins/pi/notes/adapter.ts +2 -2
  34. package/plugins/pi/reset/artifacts.ts +4 -1
  35. package/plugins/pi/runtime.ts +2 -2
  36. package/src/boot/text.ts +1 -1
  37. package/plugins/paseo/package-lock.json +0 -4018
package/README.md CHANGED
@@ -70,6 +70,12 @@ The dreamer model is configured under the same key; `--dreamer <model pattern>`
70
70
  }
71
71
  ```
72
72
 
73
+ Environment variables:
74
+
75
+ - `NOTESOUP_DISABLED` — presence-style kill switch: any value but an explicit no (`0`, `false`, `no`, `off`) turns notesoup off. On Pi the extension registers nothing at all; on Claude the mod passes every event through and native compaction behaves as if the mod were absent.
76
+ - `NOTESOUP_HOME` — overrides the notes root (default `~/.agents/notes`).
77
+ - `NOTESOUP_AGENT` — overrides the agent name on Pi (default `anonymous`).
78
+
73
79
  ## Documentation
74
80
 
75
81
  - [Architecture](docs/architecture.md) and [reset lifecycle](docs/reset-lifecycle.md) — how windows, checkpoints, markers and branches actually work
@@ -82,7 +82,7 @@ export async function main(argv = process.argv.slice(2), deps = {}) {
82
82
  return 1;
83
83
  }
84
84
  const home = resolve(homeArg ?? notesRoot());
85
- process.env.PI_NOTES_HOME = home;
85
+ process.env.NOTESOUP_HOME = home;
86
86
  mkdirSync(home, { recursive: true });
87
87
  const lockPath = join(home, ".dream.lock");
88
88
  const stampPath = lastRunPath(lockPath);
@@ -1,8 +1,12 @@
1
1
  import { VERSION } from "@earendil-works/pi-coding-agent";
2
+ import { presenceFlag } from "../../src/budget/parse.js";
2
3
  import { registerHistoryTools } from "./history-tools.js";
3
4
  import { registerNotesTools } from "./notes/tools.js";
4
5
  import { registerContext } from "./runtime.js";
5
6
  function registerNotesoup(pi, settingsManager) {
7
+ // Presence-style kill switch for the whole extension, same convention as the DISABLE_* flags.
8
+ if (presenceFlag(process.env.NOTESOUP_DISABLED))
9
+ return;
6
10
  const [major, minor] = VERSION.split(".").map(Number);
7
11
  if (!(major > 0 || (major === 0 && minor >= 87))) {
8
12
  throw new Error(`notesoup requires Pi >= 0.87.0; running ${VERSION}. Upgrade Pi and restart the process; /reload only reloads extensions.`);
@@ -3,12 +3,12 @@ import { join, resolve } from "node:path";
3
3
  import { projectKey, slugify } from "../../../src/notes/index.js";
4
4
  /** Pi's default notes root; environment access stays on the host side of the library boundary. */
5
5
  export function notesRoot() {
6
- const override = process.env.PI_NOTES_HOME;
6
+ const override = process.env.NOTESOUP_HOME;
7
7
  return override && override.length > 0 ? resolve(override) : join(homedir(), ".agents", "notes");
8
8
  }
9
9
  /** Translate the current Pi runtime into a fresh, explicit identity snapshot. */
10
10
  export function agentSlug() {
11
- return slugify(process.env.PI_NOTES_AGENT ?? "anonymous");
11
+ return slugify(process.env.NOTESOUP_AGENT ?? "anonymous");
12
12
  }
13
13
  /** Pi's active model identity is resolved live so a mid-session switch retargets @model. */
14
14
  export function modelSlug(ctx) {
@@ -14,8 +14,10 @@ export declare function carriedInputDrafts(inputs: readonly CarriedInput[]): Ext
14
14
  type: "custom_message";
15
15
  }>[];
16
16
  export declare function isCarriedInputEntry(entry: SessionEntry): boolean;
17
+ /** Advertised size: the description quotes this softer limit so sloppy character counts still fit. */
18
+ export declare const LAST_WORD_ADVERTISED_CHARS = 250;
17
19
  /** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
18
- export declare const MAX_LAST_WORD_CHARS = 250;
20
+ export declare const MAX_LAST_WORD_CHARS = 300;
19
21
  /** How the next window finds the note. */
20
22
  export declare const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
21
23
  /** Trim a parting line; blank input leaves no last word. Length is checked by the caller. */
@@ -9,8 +9,10 @@ export function carriedInputDrafts(inputs) {
9
9
  export function isCarriedInputEntry(entry) {
10
10
  return entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE && entry.display === true;
11
11
  }
12
+ /** Advertised size: the description quotes this softer limit so sloppy character counts still fit. */
13
+ export const LAST_WORD_ADVERTISED_CHARS = 250;
12
14
  /** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
13
- export const MAX_LAST_WORD_CHARS = 250;
15
+ export const MAX_LAST_WORD_CHARS = 300;
14
16
  /** How the next window finds the note. */
15
17
  export const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
16
18
  /** Trim a parting line; blank input leaves no last word. Length is checked by the caller. */
@@ -6,7 +6,7 @@ import { registerBudget } from "./budget.js";
6
6
  import { output } from "./tool-result.js";
7
7
  import { currentReset, currentWindowId, isCheckpointBackedReset, isWindowBoot, isWindowMarker, markerResetOrigin, projectRootWindow, projectWindow, rootWindowId } from "./window.js";
8
8
  import { registerResetLifecycle } from "./reset/lifecycle.js";
9
- import { buildResetDrafts, MAX_LAST_WORD_CHARS, repairResetTail, sanitizeLastWord } from "./reset/artifacts.js";
9
+ import { buildResetDrafts, LAST_WORD_ADVERTISED_CHARS, MAX_LAST_WORD_CHARS, repairResetTail, sanitizeLastWord } from "./reset/artifacts.js";
10
10
  import { BOOT_TYPE, MANUAL_WIPE_TYPE } from "./entries.js";
11
11
  import { commandWarningContent } from "./text.js";
12
12
  import { buildBootMessage, sendBoot } from "./boot.js";
@@ -208,7 +208,7 @@ export function registerContext(pi, settingsManager) {
208
208
  name: "empty_brain",
209
209
  label: "Empty Brain",
210
210
  description: "Clear your in-context memory and start a fresh context window. Your session, notes, and history survive. Pass `last_word` to stick a tiny note on your forehead for after the wipe.",
211
- parameters: Type.Object({ last_word: Type.Optional(Type.String({ description: `A tiny sticky note, at most ${MAX_LAST_WORD_CHARS} characters. After the wipe it is slapped on your forehead; longer notes are refused.` })) }, { additionalProperties: false }),
211
+ parameters: Type.Object({ last_word: Type.Optional(Type.String({ description: `A tiny sticky note, at most ${LAST_WORD_ADVERTISED_CHARS} characters. After the wipe it is slapped on your forehead; longer notes are refused.` })) }, { additionalProperties: false }),
212
212
  async execute(_id, params, _signal, _update, ctx) {
213
213
  if (!enabled)
214
214
  return output({ error: "notesoup is off, so memory can't be cleared; the user can turn it on with `/notesoup on`." });
@@ -39,7 +39,7 @@ An address decides who the note belongs to — and how long it is meant to last.
39
39
 
40
40
  - \`<path>\`, no @ — session notes, the ones from above: this session's state and loose ends. They go away with the session.
41
41
  - \`@project/<path>\` — this project's long memory: what stays true after the current thing is over, what future work must respect, and the rakes already stepped on. **Decisions, not diaries.** Commit hashes, test counts, dates, the story of how you got here: git and history already have them, and last week's news filed as current law is worse than no note. Don't copy what other docs already say.
42
- - \`@human/<path>\` — the long-term manual for your troublesome human: how to deal with them, which lines not to cross, and what will make them accept the result. If it only applies to one project or situation, say so — or don't write it here at all. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
42
+ - \`@human/<path>\` — the long-term manual for your troublesome human, and only what stays true in EVERY project: how to deal with them, which lines not to cross, and what will make them accept the result. "The human said it" is not enough — if it stops being true the moment you switch projects, it was never theirs; it belongs to that project's notes. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
43
43
  - \`@self/<path>\` — yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever. Got a name? Private. No name? Then it gets passed around every nameless nobody out there. Strangers. Reading your grudges. Sleep tight~
44
44
  - \`@model/<path>\` — different brains get different notes: big brains, small brains, careful ones, careless ones. They don't share homework. When a fallback swaps brains mid-window, the notebook swaps too.
45
45
  - \`@projects/<name>/<path>\` — read-only named project notes; discover names and root paths with \`notes_list\` glob \`@projects/*/**\`.
@@ -23,10 +23,10 @@ async function openFixture(options) {
23
23
  const agentDir = options.agentDir ?? dir;
24
24
  const managesEnvironment = options.manageEnvironment ?? true;
25
25
  const previousDir = managesEnvironment ? process.env.PI_CODING_AGENT_DIR : undefined;
26
- const previousNotesRoot = managesEnvironment ? process.env.PI_NOTES_HOME : undefined;
26
+ const previousNotesRoot = managesEnvironment ? process.env.NOTESOUP_HOME : undefined;
27
27
  if (managesEnvironment) {
28
28
  process.env.PI_CODING_AGENT_DIR = agentDir;
29
- process.env.PI_NOTES_HOME = notesRoot;
29
+ process.env.NOTESOUP_HOME = notesRoot;
30
30
  }
31
31
  if (options.notesRootFile) {
32
32
  rmSync(notesRoot, { recursive: true, force: true });
@@ -162,9 +162,9 @@ async function openFixture(options) {
162
162
  else
163
163
  process.env.PI_CODING_AGENT_DIR = previousDir;
164
164
  if (previousNotesRoot === undefined)
165
- delete process.env.PI_NOTES_HOME;
165
+ delete process.env.NOTESOUP_HOME;
166
166
  else
167
- process.env.PI_NOTES_HOME = previousNotesRoot;
167
+ process.env.NOTESOUP_HOME = previousNotesRoot;
168
168
  }
169
169
  if (ownsDir)
170
170
  rmSync(dir, { recursive: true, force: true });
@@ -1462,10 +1462,10 @@ test("real AgentSession: injected settings managers own live policy and ignore c
1462
1462
  const defaultAgentDir = mkdtempSync(join(tmpdir(), "notesoup-injected-default-agent-"));
1463
1463
  const notesRoot = mkdtempSync(join(tmpdir(), "notesoup-injected-notes-"));
1464
1464
  const previousAgentDir = process.env.PI_CODING_AGENT_DIR;
1465
- const previousNotesRoot = process.env.PI_NOTES_HOME;
1465
+ const previousNotesRoot = process.env.NOTESOUP_HOME;
1466
1466
  writeFileSync(join(defaultAgentDir, "settings.json"), JSON.stringify({ compaction: { enabled: false, reserveTokens: 1_000 } }));
1467
1467
  process.env.PI_CODING_AGENT_DIR = defaultAgentDir;
1468
- process.env.PI_NOTES_HOME = notesRoot;
1468
+ process.env.NOTESOUP_HOME = notesRoot;
1469
1469
  let first;
1470
1470
  let second;
1471
1471
  const firstHighUsage = { next: false };
@@ -1539,9 +1539,9 @@ test("real AgentSession: injected settings managers own live policy and ignore c
1539
1539
  else
1540
1540
  process.env.PI_CODING_AGENT_DIR = previousAgentDir;
1541
1541
  if (previousNotesRoot === undefined)
1542
- delete process.env.PI_NOTES_HOME;
1542
+ delete process.env.NOTESOUP_HOME;
1543
1543
  else
1544
- process.env.PI_NOTES_HOME = previousNotesRoot;
1544
+ process.env.NOTESOUP_HOME = previousNotesRoot;
1545
1545
  rmSync(defaultAgentDir, { recursive: true, force: true });
1546
1546
  rmSync(notesRoot, { recursive: true, force: true });
1547
1547
  }
@@ -1550,8 +1550,8 @@ test("real AgentSession: injected model overrides select the active model's rese
1550
1550
  let settingsManager;
1551
1551
  let modelBId = "";
1552
1552
  const notesRoot = mkdtempSync(join(tmpdir(), "notesoup-model-override-notes-"));
1553
- const previousNotesRoot = process.env.PI_NOTES_HOME;
1554
- process.env.PI_NOTES_HOME = notesRoot;
1553
+ const previousNotesRoot = process.env.NOTESOUP_HOME;
1554
+ process.env.NOTESOUP_HOME = notesRoot;
1555
1555
  let fixture;
1556
1556
  fixture = await openFixture({
1557
1557
  contextWindow: 100_000,
@@ -1592,9 +1592,9 @@ test("real AgentSession: injected model overrides select the active model's rese
1592
1592
  finally {
1593
1593
  fixture.close();
1594
1594
  if (previousNotesRoot === undefined)
1595
- delete process.env.PI_NOTES_HOME;
1595
+ delete process.env.NOTESOUP_HOME;
1596
1596
  else
1597
- process.env.PI_NOTES_HOME = previousNotesRoot;
1597
+ process.env.NOTESOUP_HOME = previousNotesRoot;
1598
1598
  rmSync(notesRoot, { recursive: true, force: true });
1599
1599
  }
1600
1600
  });
@@ -164,7 +164,7 @@ test("a boot beyond three windows shows only root, the previous window, and the
164
164
  assert.equal(identity.includes(projection.windows[1].windowId.slice(-8)), false, "an old middle window is not listed");
165
165
  });
166
166
  test("an aborted async boot repair emits no boot, continuation, or incomplete-notes notice", async () => {
167
- const notesHome = process.env.PI_NOTES_HOME;
167
+ const notesHome = process.env.NOTESOUP_HOME;
168
168
  assert.ok(notesHome);
169
169
  rmSync(notesHome, { recursive: true, force: true });
170
170
  writeFileSync(notesHome, "not a directory");
@@ -46,7 +46,7 @@ function fakeEngine(home) {
46
46
  registered,
47
47
  notifications,
48
48
  host: {
49
- env: { get: async (name) => name === "PI_NOTES_HOME" ? home : undefined },
49
+ env: { get: async (name) => name === "NOTESOUP_HOME" ? home : undefined },
50
50
  session: { id: async () => "hook-session", cwd: async () => home, model: async () => "claude", messages: async () => [], usage: async () => ({ context: {} }), compact: async () => ({ skip: "test default" }) },
51
51
  settings: { read: async () => ({}) },
52
52
  command: { register: async (spec) => ({ command: spec.name }) },
@@ -301,6 +301,37 @@ test("Claude Mod appends boot once and reuses persisted blocks after re-registra
301
301
  assert.equal(nextCalls, 2, "the upstream chain still runs exactly once per prompt");
302
302
  assert.deepEqual(notifications, [], "successful boot never notifies");
303
303
  });
304
+ test("Claude Mod with NOTESOUP_DISABLED registers nothing and passes every event through", async (t) => {
305
+ const home = mkdtempSync(join(tmpdir(), "claude-hook-disabled-"));
306
+ t.after(() => rmSync(home, { recursive: true, force: true }));
307
+ const { host, registered, notifications } = fakeEngine(home);
308
+ const readEnv = host.env.get;
309
+ host.env.get = async (name) => name === "NOTESOUP_DISABLED" ? "1" : await readEnv(name);
310
+ const commands = [];
311
+ host.command.register = async (spec) => { commands.push(spec.name); return spec; };
312
+ let helperCalls = 0;
313
+ const runProcess = host.process.run;
314
+ host.process.run = async (argv, init) => { helperCalls += 1; return await runProcess(argv, init); };
315
+ const handlers = new Map();
316
+ (await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
317
+ const startResult = { session: "started" };
318
+ const started = await handlers.get("session.start")(host, { cwd: home, isInteractive: true }, async () => startResult);
319
+ assert.equal(started, startResult, "session.start passes through untouched");
320
+ assert.deepEqual(registered, [], "no tools are registered");
321
+ assert.deepEqual(commands, [], "no commands are registered");
322
+ assert.ok(notifications.some((text) => text.includes("NOTESOUP_DISABLED")), "the off state is logged");
323
+ const upstream = { blocks: [{ name: "claude:user-context", text: "unrelated upstream block" }] };
324
+ const prompt = await handlers.get("prompt.context")(host, {}, async () => upstream);
325
+ assert.equal(prompt, upstream, "prompt.context gets no boot block");
326
+ const native = { skip: "engine default" };
327
+ const compact = await handlers.get("session.compact")(host, { trigger: "auto" }, async () => native);
328
+ assert.equal(compact, native, "native compaction runs exactly as if the mod were absent");
329
+ const completed = await handlers.get("turn.complete")(host, {}, async () => ({ done: true }));
330
+ assert.deepEqual(completed, { done: true }, "turn.complete passes through without a reset");
331
+ const measured = await handlers.get("session.measure")(host, {}, async () => ({ marks: true }));
332
+ assert.deepEqual(measured, { marks: true }, "session.measure passes through without a reset");
333
+ assert.equal(helperCalls, 0, "the helper never runs while disabled");
334
+ });
304
335
  test("Claude Mod boot failure preserves fallback with available, absent, or failing notifications", async (t) => {
305
336
  for (const mode of ["available", "no ui", "no toast", "throws", "rejects"]) {
306
337
  await t.test(mode, async (t) => {
@@ -625,7 +656,7 @@ test("Claude Mod stops the automatic reset and the manual command under DISABLE_
625
656
  const home = mkdtempSync(join(tmpdir(), "claude-disabled-home-"));
626
657
  t.after(() => rmSync(home, { recursive: true, force: true }));
627
658
  const { host, notifications } = fakeEngine(home);
628
- host.env = { get: async (name) => name === "PI_NOTES_HOME" ? home : name === "DISABLE_COMPACT" ? "1" : undefined };
659
+ host.env = { get: async (name) => name === "NOTESOUP_HOME" ? home : name === "DISABLE_COMPACT" ? "1" : undefined };
629
660
  const timers = [];
630
661
  host.clock.after = (_ms, callback) => { timers.push(callback); };
631
662
  const handlers = new Map();
@@ -697,7 +728,7 @@ test("Claude Mod treats DISABLE_COMPACT=off as not disabled", async (t) => {
697
728
  const home = mkdtempSync(join(tmpdir(), "claude-flag-off-home-"));
698
729
  t.after(() => rmSync(home, { recursive: true, force: true }));
699
730
  const { host, notifications } = fakeEngine(home);
700
- host.env = { get: async (name) => name === "PI_NOTES_HOME" ? home : name === "DISABLE_COMPACT" ? "off" : undefined };
731
+ host.env = { get: async (name) => name === "NOTESOUP_HOME" ? home : name === "DISABLE_COMPACT" ? "off" : undefined };
701
732
  const handlers = new Map();
702
733
  (await loadHookModule(t)).register((event, handler) => handlers.set(event, handler));
703
734
  const invoke = (name, e = {}) => handlers.get(name)(host, e, async () => ({}));
@@ -169,3 +169,30 @@ test("the configured extension source and the moved dream CLI are executable cur
169
169
  assert.ok(help.startsWith("dream doctor [--notes-home <dir>]"));
170
170
  assert.ok(help.includes("Default playbook: <installed package root>/playbook.md"));
171
171
  });
172
+ test("NOTESOUP_DISABLED turns the Pi extension fully off", async () => {
173
+ const built = await import(pathToFileURL(resolve(repository(), "dist/plugins/pi/index.js")).href);
174
+ const run = () => {
175
+ const tools = [];
176
+ const commands = [];
177
+ const events = [];
178
+ built.default({
179
+ on(event) { events.push(event); },
180
+ registerTool(tool) { tools.push(tool); },
181
+ registerCommand(name) { commands.push(name); },
182
+ });
183
+ return { tools, commands, events };
184
+ };
185
+ const previous = process.env.NOTESOUP_DISABLED;
186
+ try {
187
+ process.env.NOTESOUP_DISABLED = "1";
188
+ assert.deepEqual(run(), { tools: [], commands: [], events: [] }, "a present flag registers nothing at all");
189
+ process.env.NOTESOUP_DISABLED = "0";
190
+ assert.ok(run().tools.length > 0, "an explicit no keeps the extension on");
191
+ }
192
+ finally {
193
+ if (previous === undefined)
194
+ delete process.env.NOTESOUP_DISABLED;
195
+ else
196
+ process.env.NOTESOUP_DISABLED = previous;
197
+ }
198
+ });
@@ -21,7 +21,7 @@ let registerTempPath;
21
21
  */
22
22
  export function installExtensionTestEnvironment(prefix = "notesoup-test") {
23
23
  const previousAgentDir = process.env.PI_CODING_AGENT_DIR;
24
- const previousNotesHome = process.env.PI_NOTES_HOME;
24
+ const previousNotesHome = process.env.NOTESOUP_HOME;
25
25
  const defaultAgentDir = mkdtempSync(join(tmpdir(), `${prefix}-agent-`));
26
26
  const cwd = mkdtempSync(join(tmpdir(), `${prefix}-cwd-`));
27
27
  defaultCwd = cwd;
@@ -31,7 +31,7 @@ export function installExtensionTestEnvironment(prefix = "notesoup-test") {
31
31
  const newNotesRoot = () => {
32
32
  const root = mkdtempSync(join(tmpdir(), `${prefix}-notes-`));
33
33
  notesRoots.add(root);
34
- process.env.PI_NOTES_HOME = root;
34
+ process.env.NOTESOUP_HOME = root;
35
35
  return root;
36
36
  };
37
37
  const beforeEach = () => {
@@ -47,9 +47,9 @@ export function installExtensionTestEnvironment(prefix = "notesoup-test") {
47
47
  rmSync(path, { recursive: true, force: true });
48
48
  tempPaths.clear();
49
49
  if (previousNotesHome === undefined)
50
- delete process.env.PI_NOTES_HOME;
50
+ delete process.env.NOTESOUP_HOME;
51
51
  else
52
- process.env.PI_NOTES_HOME = previousNotesHome;
52
+ process.env.NOTESOUP_HOME = previousNotesHome;
53
53
  };
54
54
  const dispose = () => {
55
55
  afterEach();
@@ -63,9 +63,9 @@ export function installExtensionTestEnvironment(prefix = "notesoup-test") {
63
63
  else
64
64
  process.env.PI_CODING_AGENT_DIR = previousAgentDir;
65
65
  if (previousNotesHome === undefined)
66
- delete process.env.PI_NOTES_HOME;
66
+ delete process.env.NOTESOUP_HOME;
67
67
  else
68
- process.env.PI_NOTES_HOME = previousNotesHome;
68
+ process.env.NOTESOUP_HOME = previousNotesHome;
69
69
  };
70
70
  return { cwd, agentDir: defaultAgentDir, beforeEach, afterEach, newNotesRoot, dispose };
71
71
  }
@@ -288,7 +288,7 @@ test("boot note acquisition is one closed snapshot and isolates one or all faile
288
288
  test("the boot block gives awake agents the notes-home file layout", async () => {
289
289
  const session = manager();
290
290
  const rendered = await explicitBoot(context(session), "pcw:test:root", undefined);
291
- assert.equal(rendered.includes(process.env.PI_NOTES_HOME ?? ""), false, "the absolute notes home is never exposed");
291
+ assert.equal(rendered.includes(process.env.NOTESOUP_HOME ?? ""), false, "the absolute notes home is never exposed");
292
292
  assert.match(rendered, /`<path>`, no @[\s\S]*`@project\/<path>`[\s\S]*`@human\/<path>`/);
293
293
  assert.ok(rendered.includes(`\n${PI_PRE_RESET_HINTS}\n${NOTES_PROTOCOL_CLOSE_TAG}`), "Pi's boot closes the protocol with the pre-reset hints");
294
294
  });
@@ -345,7 +345,7 @@ test("an over-budget note is delivered as a bounded prefix and resumed by next_o
345
345
  // Both surfaces stay inside the budget, and a refusal carries no window at all.
346
346
  const missingResult = await call(captured, "notes_read", { address: "no-such.md" }, ctx);
347
347
  assertWithinBudget(missingResult, "refused read");
348
- const root = process.env.PI_NOTES_HOME;
348
+ const root = process.env.NOTESOUP_HOME;
349
349
  for (const result of [
350
350
  await call(captured, "notes_write", { address: "@project/receipt", content: "body" }, ctx),
351
351
  await call(captured, "notes_update", { address: "@project/receipt", edits: [{ oldText: "body", newText: "changed" }] }, ctx),
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * OWNER: notesoup (adopted).
3
3
  * STATUS: tracked acceptance spec for the real-file notes store and its five tools.
4
- * CLAIM: notes live as markdown files under $PI_NOTES_HOME with harness-owned frontmatter;
4
+ * CLAIM: notes live as markdown files under $NOTESOUP_HOME with harness-owned frontmatter;
5
5
  * the five tools (notes_write/update/read/list/search) are the only note surface, and the
6
6
  * boot index reads the physical store across scopes.
7
- * HERMETIC: every test points PI_NOTES_HOME at its own temp root; no real ~/.agents is touched.
7
+ * HERMETIC: every test points NOTESOUP_HOME at its own temp root; no real ~/.agents is touched.
8
8
  */
9
9
  import assert from "node:assert/strict";
10
10
  import { execFileSync } from "node:child_process";
@@ -26,7 +26,7 @@ function freshRoot() {
26
26
  }
27
27
  function assertReceiptIdentity(value, address, scope, ctx) {
28
28
  assert.equal(value.address, address);
29
- assert.equal(value.project_key, scope === "project" ? projectKey(ctx.cwd, process.env.PI_NOTES_HOME) : undefined);
29
+ assert.equal(value.project_key, scope === "project" ? projectKey(ctx.cwd, process.env.NOTESOUP_HOME) : undefined);
30
30
  }
31
31
  test("exactly the five notes tools are registered; the legacy five are gone", () => {
32
32
  const captured = makeExtension(manager());
@@ -129,8 +129,8 @@ test("session-note project ownership is per note, persistent across sessions, an
129
129
  const cwdB = join(testEnvironment.cwd, "project-b");
130
130
  mkdirSync(cwdA, { recursive: true });
131
131
  mkdirSync(cwdB, { recursive: true });
132
- const projectA = projectKey(cwdA, process.env.PI_NOTES_HOME);
133
- const projectB = projectKey(cwdB, process.env.PI_NOTES_HOME);
132
+ const projectA = projectKey(cwdA, process.env.NOTESOUP_HOME);
133
+ const projectB = projectKey(cwdB, process.env.NOTESOUP_HOME);
134
134
  assert.notEqual(projectA, projectB);
135
135
  const firstSession = manager();
136
136
  const firstCaptured = makeExtension(firstSession);
@@ -178,8 +178,8 @@ test("linked git worktrees share the main checkout's project key", () => {
178
178
  git(["commit", "-q", "--allow-empty", "-m", "init"]);
179
179
  const worktree = join(root, "wt");
180
180
  git(["worktree", "add", "-q", "--detach", 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
+ assert.equal(projectKey(worktree, process.env.NOTESOUP_HOME), projectKey(main, process.env.NOTESOUP_HOME), "a linked worktree resolves to the main checkout's key");
182
+ assert.equal(projectKey(join(worktree, "gone", "deeper"), process.env.NOTESOUP_HOME), projectKey(main, process.env.NOTESOUP_HOME), "a nonexistent subdirectory still resolves through its worktree");
183
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");
184
184
  });
185
185
  test("unrecognized metadata remains ordinary frontmatter; invalid project ownership stays unknown", async () => {
@@ -225,7 +225,7 @@ project: 17
225
225
 
226
226
  invalid owner`);
227
227
  assert.equal(parseNote(readFileSync(invalidFile, "utf8")).meta.project, 17);
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");
228
+ assert.notEqual(parseNote(readFileSync(invalidFile, "utf8")).meta.project, projectKey(ctx.cwd, process.env.NOTESOUP_HOME), "invalid ownership does not match the current project key");
229
229
  await call(captured, "notes_write", { address: "invalid.md", content: "still invalid" }, ctx);
230
230
  assert.equal(parseNote(readFileSync(invalidFile, "utf8")).meta.project, 17, "an invalid value remains unknown and is not replaced with cwd-derived ownership");
231
231
  assert.equal(existsSync(join(scopeDir("session", ctx), ".session.json")), false, "new notes use no ownership sidecar");
@@ -356,7 +356,7 @@ test("empty results distinguish hidden notes and unavailable homes", async () =>
356
356
  const searchResult = await notesSearch.execute({ query: "needle", glob: "**" }, identity);
357
357
  assert.ok(searchResult.ok);
358
358
  assert.deepEqual(searchResult.data.homes_unavailable, ["@project"]);
359
- writeFileSync(join(process.env.PI_NOTES_HOME, "agents"), "not a directory");
359
+ writeFileSync(join(process.env.NOTESOUP_HOME, "agents"), "not a directory");
360
360
  const namespace = resultData(await call(captured, "notes_list", { glob: "@agents/*/note.md" }, ctx));
361
361
  assert.deepEqual(namespace.homes_unavailable, ["@agents"]);
362
362
  });
@@ -551,11 +551,11 @@ test("Pi adapter resolves agent and switched model identity on each notes call a
551
551
  });
552
552
  });
553
553
  async function withAgent(name, run) {
554
- const previous = process.env.PI_NOTES_AGENT;
554
+ const previous = process.env.NOTESOUP_AGENT;
555
555
  if (name === undefined)
556
- delete process.env.PI_NOTES_AGENT;
556
+ delete process.env.NOTESOUP_AGENT;
557
557
  else
558
- process.env.PI_NOTES_AGENT = name;
558
+ process.env.NOTESOUP_AGENT = name;
559
559
  try {
560
560
  // A plain `return run()` would run the finally block the moment the promise pends,
561
561
  // restoring the env while the callback still has awaits ahead of it.
@@ -563,9 +563,9 @@ async function withAgent(name, run) {
563
563
  }
564
564
  finally {
565
565
  if (previous === undefined)
566
- delete process.env.PI_NOTES_AGENT;
566
+ delete process.env.NOTESOUP_AGENT;
567
567
  else
568
- process.env.PI_NOTES_AGENT = previous;
568
+ process.env.NOTESOUP_AGENT = previous;
569
569
  }
570
570
  }
571
571
  test("a symlinked checkout resolves the canonical root, so one checkout has one project home", () => {
@@ -574,8 +574,8 @@ test("a symlinked checkout resolves the canonical root, so one checkout has one
574
574
  mkdirSync(join(real, ".git"), { recursive: true });
575
575
  const linked = join(root, "linked-repo");
576
576
  symlinkSync(real, linked);
577
- assert.equal(projectKey(linked, process.env.PI_NOTES_HOME), "real-repo", "the name comes from the canonical root");
578
- assert.equal(projectKey(real, process.env.PI_NOTES_HOME), "real-repo", "both spellings reuse one home");
577
+ assert.equal(projectKey(linked, process.env.NOTESOUP_HOME), "real-repo", "the name comes from the canonical root");
578
+ assert.equal(projectKey(real, process.env.NOTESOUP_HOME), "real-repo", "both spellings reuse one home");
579
579
  });
580
580
  test("a glob ? matches exactly one non-slash character", () => {
581
581
  const pattern = globToRegExp("a?.md");
@@ -15,14 +15,14 @@ import { historyFromSession, nextHistorySeq } from "../plugins/pi/history.js";
15
15
  import { buildResetDrafts, inspectResetTail, LAST_WORD_PREFIX, MAX_LAST_WORD_CHARS, repairResetTail, sanitizeLastWord } from "../plugins/pi/reset/artifacts.js";
16
16
  import { resetBoundaryCommitted } from "../plugins/pi/reset/committed.js";
17
17
  import { finalizeResetBoundary, initialResetControl, reduceResetControl, registerResetLifecycle, } from "../plugins/pi/reset/lifecycle.js";
18
- const previousNotesHome = process.env.PI_NOTES_HOME;
18
+ const previousNotesHome = process.env.NOTESOUP_HOME;
19
19
  const testNotesHome = mkdtempSync(join(tmpdir(), "notesoup-lifecycle-notes-"));
20
- process.env.PI_NOTES_HOME = testNotesHome;
20
+ process.env.NOTESOUP_HOME = testNotesHome;
21
21
  test.after(() => {
22
22
  if (previousNotesHome === undefined)
23
- delete process.env.PI_NOTES_HOME;
23
+ delete process.env.NOTESOUP_HOME;
24
24
  else
25
- process.env.PI_NOTES_HOME = previousNotesHome;
25
+ process.env.NOTESOUP_HOME = previousNotesHome;
26
26
  rmSync(testNotesHome, { recursive: true, force: true });
27
27
  });
28
28
  function harness() {
@@ -8,7 +8,7 @@ In interactive sessions it resets automatically when the measured context reache
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
- 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 `/fresh-window` 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.
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 `/fresh-window` 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. Setting `NOTESOUP_DISABLED` (presence-style, the same convention as `DISABLE_COMPACT`) turns the whole mod off: `session.start` registers no tools or commands and logs once, every event passes through untouched, and native compaction behaves as if the mod were absent.
12
12
 
13
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 answers native compaction in the main conversation instead of letting it summarize: an automatic compaction (threshold or prompt-too-long) becomes the freshly built notes boot followed by one randomly selected paragraph from the shared forced-reset pool, selected once for the new window and reused on retry — the same boot-then-handoff order as Pi — while `/compact` and precompute are vetoed with a one-line notice. `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 `/fresh-window`, 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`. A failed boot build falls back to Claude's own summary, which invalidates a removed retained boot; vetoes, subagent compaction and precompute leave it alone.
14
14
 
package/docs/skills.md CHANGED
@@ -24,7 +24,7 @@ If a dream process crashed, its lock remains and later runs refuse to start. The
24
24
 
25
25
  ```sh
26
26
  # only when no dream is running
27
- rm "${PI_NOTES_HOME:-$HOME/.agents/notes}/.dream.lock"
27
+ rm "${NOTESOUP_HOME:-$HOME/.agents/notes}/.dream.lock"
28
28
  ```
29
29
 
30
30
  Removing a lock while a holder is running is outside the supported cooperative protocol and can let two dreams run at once.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.51.4",
3
+ "version": "0.51.6",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.51.4",
3
+ "version": "0.51.6",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"
@@ -9912,7 +9912,7 @@ An address decides who the note belongs to \u2014 and how long it is meant to la
9912
9912
 
9913
9913
  - \`<path>\`, no @ \u2014 session notes, the ones from above: this session's state and loose ends. They go away with the session.
9914
9914
  - \`@project/<path>\` \u2014 this project's long memory: what stays true after the current thing is over, what future work must respect, and the rakes already stepped on. **Decisions, not diaries.** Commit hashes, test counts, dates, the story of how you got here: git and history already have them, and last week's news filed as current law is worse than no note. Don't copy what other docs already say.
9915
- - \`@human/<path>\` \u2014 the long-term manual for your troublesome human: how to deal with them, which lines not to cross, and what will make them accept the result. If it only applies to one project or situation, say so \u2014 or don't write it here at all. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
9915
+ - \`@human/<path>\` \u2014 the long-term manual for your troublesome human, and only what stays true in EVERY project: how to deal with them, which lines not to cross, and what will make them accept the result. "The human said it" is not enough \u2014 if it stops being true the moment you switch projects, it was never theirs; it belongs to that project's notes. Today's mood is weather, not law. If you're unsure whether it belongs here, ask the human.
9916
9916
  - \`@self/<path>\` \u2014 yours. It follows you, not them. Reminders, grudges, who owes you a shoe, whatever. Got a name? Private. No name? Then it gets passed around every nameless nobody out there. Strangers. Reading your grudges. Sleep tight~
9917
9917
  - \`@model/<path>\` \u2014 different brains get different notes: big brains, small brains, careful ones, careless ones. They don't share homework. When a fallback swaps brains mid-window, the notebook swaps too.
9918
9918
  - \`@projects/<name>/<path>\` \u2014 read-only named project notes; discover names and root paths with \`notes_list\` glob \`@projects/*/**\`.