notesoup 0.59.1 → 0.60.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 (79) hide show
  1. package/README.md +3 -17
  2. package/dist/plugins/claude/src/helper.js +3 -4
  3. package/dist/plugins/codex/src/mcp.js +1 -2
  4. package/dist/plugins/dsh/tools.js +1 -2
  5. package/dist/plugins/pi/notes/tools.d.ts +1 -1
  6. package/dist/plugins/pi/notes/tools.js +2 -3
  7. package/dist/src/history/claude.d.ts +3 -1
  8. package/dist/src/history/claude.js +40 -4
  9. package/dist/src/history/history.d.ts +10 -11
  10. package/dist/src/history/history.js +8 -19
  11. package/dist/src/history/prefilter.d.ts +1 -1
  12. package/dist/src/history/prefilter.js +14 -9
  13. package/dist/src/history/query.d.ts +3 -14
  14. package/dist/src/history/query.js +73 -85
  15. package/dist/src/index.d.ts +1 -1
  16. package/dist/src/index.js +1 -1
  17. package/dist/src/notes/address.js +3 -3
  18. package/dist/src/notes/store.d.ts +2 -4
  19. package/dist/src/notes/store.js +1 -2
  20. package/dist/src/tools/history.d.ts +4 -6
  21. package/dist/src/tools/history.js +69 -29
  22. package/dist/src/tools/notes.d.ts +18 -78
  23. package/dist/src/tools/notes.js +39 -50
  24. package/dist/src/tools/schema.d.ts +0 -1
  25. package/dist/src/tools/schema.js +0 -1
  26. package/dist/test/claude-history.test.js +27 -6
  27. package/dist/test/claude-mod.test.js +19 -8
  28. package/dist/test/codex-history.test.js +1 -1
  29. package/dist/test/codex-plugin.test.js +1 -2
  30. package/dist/test/dependencies.test.js +2 -2
  31. package/dist/test/dsh.test.js +2 -2
  32. package/dist/test/history-corpus.test.js +21 -36
  33. package/dist/test/history-prefilter.test.js +5 -0
  34. package/dist/test/history-summary-cache.test.js +3 -3
  35. package/dist/test/history.integration.test.js +53 -106
  36. package/dist/test/host-neutral.test.js +1 -1
  37. package/dist/test/note-policy.test.js +5 -5
  38. package/dist/test/notes-cwd.test.js +5 -5
  39. package/dist/test/notes-query-namespaces.test.js +2 -6
  40. package/dist/test/notes.integration.test.js +30 -35
  41. package/dist/test/notes.test.js +12 -14
  42. package/dist/test/project-namespace.test.js +3 -3
  43. package/docs/architecture.md +3 -3
  44. package/docs/claude-code-mod.md +5 -3
  45. package/docs/codex.md +1 -1
  46. package/docs/dsh.md +2 -2
  47. package/docs/history-sessions.md +9 -10
  48. package/docs/notes-library.md +3 -3
  49. package/docs/tool-results.md +12 -6
  50. package/package.json +1 -1
  51. package/plugins/claude/dist/claude/helper.js +214 -173
  52. package/plugins/claude/hooks/register.ts +8 -6
  53. package/plugins/claude/skills/memory/SKILL.md +6 -6
  54. package/plugins/claude/src/helper.ts +3 -4
  55. package/plugins/codex/README.md +1 -1
  56. package/plugins/codex/dist/codex/notesoup.js +176 -160
  57. package/plugins/codex/src/mcp.ts +1 -2
  58. package/plugins/dsh/tools.ts +1 -2
  59. package/plugins/paseo/README.md +16 -0
  60. package/plugins/paseo/client/brain-empty-card.tsx +5 -3
  61. package/plugins/paseo/client/markdown-core.tsx +189 -0
  62. package/plugins/paseo/client/markdown.tsx +38 -135
  63. package/plugins/paseo/client/notes-op-card.tsx +15 -12
  64. package/plugins/paseo/client/paper-card.tsx +1 -3
  65. package/plugins/paseo/client/sticky-card.tsx +2 -1
  66. package/plugins/paseo/client/typography.ts +24 -0
  67. package/plugins/paseo/test/markdown-core.test.ts +75 -0
  68. package/plugins/pi/notes/tools.ts +2 -3
  69. package/skills/memory/SKILL.md +6 -6
  70. package/src/history/claude.ts +31 -4
  71. package/src/history/history.ts +11 -16
  72. package/src/history/prefilter.ts +13 -9
  73. package/src/history/query.ts +67 -99
  74. package/src/index.ts +1 -1
  75. package/src/notes/address.ts +2 -2
  76. package/src/notes/store.ts +3 -6
  77. package/src/tools/history.ts +60 -29
  78. package/src/tools/notes.ts +39 -54
  79. package/src/tools/schema.ts +0 -1
@@ -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, notesSearch } from "../src/tools/notes.js";
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", "notes_search"]) {
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
- ["notes_search", await call(captured, "notes_search", { query: "needle" }, ctx)],
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
- ["notes_search", { query: "x", crumpled: true }],
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, "notes_search", { query: "needle", glob: "@human/**" }, ctx));
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 notesSearch.execute({ query: "needle", glob: "**" }, notesToolContext(identity, ctx.cwd));
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, "notes_search", { query: "match", glob: "**" }, ctx));
395
- assert.deepEqual(searched.files.map((file) => file.address), notes.map((note) => note.address).sort(), "notes_search returns each full address");
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, "notes_search", { query: "needle" }, ctx));
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.length === 1), true);
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, "notes_search", { query: "needle", glob: "emoji.md" }, ctx));
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, "notes_search", { query: "needle" }, ctx));
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, notesSearch, notesUpdate, notesWrite } from "../src/tools/notes.js";
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");
@@ -300,9 +300,9 @@ test("named projects read/list/search with root and sibling receipts, without to
300
300
  const listed = data(await notesList.execute({ glob: "@projects/*/**" }, toolContext(own)));
301
301
  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
302
  assert.equal(Check(notesList.outputSchema, listed), true);
303
- const searched = data(await notesSearch.execute({ glob: "@projects/api-1/**", query: "needle" }, toolContext(own)));
303
+ const searched = data(await notesList.execute({ glob: "@projects/api-1/**", query: "needle" }, toolContext(own)));
304
304
  assert.equal(searched.files[0]?.project_root, second);
305
- assert.equal(Check(notesSearch.outputSchema, searched), true);
305
+ assert.equal(Check(notesList.outputSchema, searched), true);
306
306
  assert.equal(readFileSync(file, "utf8"), before, "named-notebook reads never rewrite access metadata");
307
307
  });
308
308
  test("named project writes, edits, crumples and both move endpoints refuse, including the current notebook", async (t) => {
@@ -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, `from` selection, literal matching, folding and chronological cross-session hit merging | Caller-supplied budget check and page-too-large facts; no tool dependencies or native SDK/session traversal |
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 with seq anchors and an explicit `from`. 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.
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
 
@@ -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 five 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.
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,11 +30,13 @@ The notes tools also serve subagent calls, using the same session identity and s
30
30
 
31
31
  ## Persisted history
32
32
 
33
- `history_list` and `history_read` use the same schemas, literal search (`history_list.query`), paging, folding, pairing and text rendering as Pi. 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.
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
 
37
- The active head comes from the main loop's successful `session.append` result UUID, including attachments and notices. On startup/resume, before such an append, the public API supplies no authoritative selected leaf: history explicitly refuses instead of assuming the last file row or `last-prompt.leafUuid` is current. The append result means the engine kept a row, but its disk write may lag; a head missing on disk is a retryable refusal, not permission to switch branches. Session end clears the binding; a new classic start rebinds it.
37
+ The active head comes from the main loop's successful `session.append` result UUID, including attachments and notices. On startup/resume, before such an append, the public API supplies no authoritative selected leaf: history explicitly refuses instead of assuming the last file row or `last-prompt.leafUuid` is current. The append result means the engine kept a row, but its disk write may lag. History tools wait briefly (up to one second of polling) for the exact confirmed UUID, retrying the read only when the file changes. If it still isn't on disk they refuse rather than switch branches. The internal `history_state` check for reset bookkeeping does not wait. Session end clears the binding; a new classic start rebinds it.
38
+
39
+ History tools have a two-minute helper deadline so a cold search can scan large archives. Notes, boot and reset helper calls keep the ten-second deadline.
38
40
 
39
41
  Seqs are allocated over first-occurrence persisted append order, before active-branch filtering: one address per logical message/attachment/notice and additional addresses for each tool use/result. Repeated UUID records do not allocate again. List pages skip empty user/assistant envelopes even with explicit roles, so tool-only and thinking-only rows do not crowd out dialogue; direct reads preserve those addresses and explicitly say when no visible text was recorded. Results pair by `tool_use_id`; pending calls remain unfinished, and a paired result's seq redirects to its call. Only text blocks and recorded attachment renderings become visible text; thinking and raw, unrendered attachment payloads are never exposed. Record types other than user, assistant, system and attachment are ignored, including future metadata, without allocating addresses or exposing payloads. If the selected branch requires a skipped record as an ancestor, that UUID is an ancestry gap, not a visible metadata event. Invalid supported message/block schemas, conflicting duplicates, session/sidechain mismatches, cycles and malformed committed JSONL lines still refuse explicitly. An incomplete final unterminated write is tolerated. Valid forward parent references are resolved after reading the snapshot, without reallocating addresses.
40
42
 
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`, `notes_list` and `notes_search`. `NOTESOUP_HOME` overrides the root (default `~/.agents/notes`); a root thread's agent name is `NOTESOUP_AGENT` or `anonymous`.
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, seven 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. Dream is not registered on dsh.
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-search operations. 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).
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
 
@@ -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 happens to be the current session. Headers become `session <harness>:<id> | seq <seq> | <role>`. Paging footers, folded-row `expand`, and read `neighborhood` recipes carry that same canonical selector. Structured pages expose `has_older` and `has_newer`; use the first or last item’s seq as the next `before_seq` or `after_seq`, respectively, together with its session. The newer footer is `→ newer: {"session":"<harness>:<full-id>","after_seq":...}`. When `after_seq` is set, omitted `from` defaults to `oldest`; otherwise, it defaults to `newest`. Explicit `from` takes precedence. Copy it into subsequent `history_read` calls, including reads continued with `next_offset_chars`.
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"], since: "2026-10-01" })
27
+ history_list({ session: "codex:*", query: "migration", roles: ["tool"], after: "2026-10-01", context: 1 })
28
28
  ```
29
29
 
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.
31
- - Without `query` (including empty strings/lists or lists containing only empty entries), return a recent-sessions overview. Sessions are considered newest-modified first, or oldest-modified first with `from: "oldest"`; loading stops once `limit` sessions (default 20) produce a representative. Apply `roles`, `since` and `until` before choosing each representative: without roles, prefer the first visible user event, falling back to the latest visible dialogue event or latest event of any role; with roles, choose the latest matching visible event. Sort the chosen representatives by event time, oldest first. There are no folded rows.
32
- - `before_seq` and `after_seq` refuse with `invalid_bounds`: seqs from different sessions cannot define a common range.
33
- - `history_read` refuses wildcard selectors with `invalid_session`; take a specific `session` and `seq` from a search hit instead.
34
- - With a query, every role is searched, including tool arguments/output and context; `roles` can narrow this. There are no folded rows.
35
- - `since` is inclusive and `until` exclusive. Time-bounded searches exclude events with no usable timestamp.
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.
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 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`, `since`, or `until`. 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.
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
 
@@ -41,9 +41,9 @@ 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 or use the bare collection alias `@default` 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. `@default` is query-only, not a directory or a read/write address; `@default/**` is not its spelling. The former `scope`/`who` query parameters are removed, without compatibility aliases. Row metadata still includes scope.
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`/`notes_search` 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.
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
 
@@ -58,7 +58,7 @@ Addresses are a relative path (a current-session note), `@project/`, `@human/`,
58
58
  - 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
59
  - `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
60
 
61
- The five model tools accept the same policy options (write/update) and return effective policy visibly in receipts, read metadata, list and search 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.
61
+ 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
62
 
63
63
  ## Library and plugin boundary
64
64
 
@@ -1,6 +1,6 @@
1
1
  # Notes and history tool results
2
2
 
3
- The seven notes/history tools have one business result model. Pi exposes compact results as `structuredContent` to codemode and renders them as `content` for ordinary model calls. Claude uses the same business handlers and text rendering. Neither host re-runs a query, truncates a different page, or parses formatted text to recover data.
3
+ The six notes/history tools share one result model on Pi, Claude Code, Codex and Cordis. Pi exposes compact results as `structuredContent` to codemode and renders them as `content` for ordinary model calls. Host adapters use the same shared handlers and text rendering; they do not re-run a query or truncate a different page.
4
4
 
5
5
  This is a breaking tool protocol change: successes no longer have `ok/data` wrappers, errors are flat, and read fields no longer sit under `window`. History execution details live once in the pageable document. Stored notes and raw Pi session entries are not deleted or rewritten by this change. In Pi, `get_context_remaining` independently declares `{ remaining_tokens }` as its output schema; `empty_brain` remains outside this protocol.
6
6
 
@@ -10,7 +10,7 @@ This is a breaking tool protocol change: successes no longer have `ok/data` wrap
10
10
  type Result<T> = T | { error: string; code: string };
11
11
  ```
12
12
 
13
- Each operation declares its concrete success schema; `error` is reserved for a refusal message. Success and expected failure both have a structured result; Pi's `isError` follows the outcome. Host-level argument validation, blocked execution and transport errors remain host failures. Shared handlers and the private Claude helper transport retain an internal `Outcome<T>` (`{ ok: true, data }` or `{ ok: false, error: { code, message } }`); this envelope is not the Pi wire result. The Claude hook returns rendered text as a string result and sets `isError: true` only on a refusal.
13
+ Each operation declares its concrete success schema; `error` is reserved for a refusal message. Success and expected failure both have a structured result; Pi's `isError` follows the outcome. Host-level argument validation, blocked execution and transport errors remain host failures. Shared handlers return an internal `Outcome<T>` (`{ ok: true, data }` or `{ ok: false, error: { code, message } }`); this envelope is not the Pi wire result. The Claude hook returns rendered text as a string result and sets `isError: true` only on a refusal.
14
14
 
15
15
  ```js
16
16
  const result = await tools.notes_list({ glob: "@project/**" });
@@ -22,7 +22,7 @@ The text representation uses short mutation receipts, lists, search hits or raw
22
22
 
23
23
  ## Per-call project selection
24
24
 
25
- All five notes operations accept optional `cwd`. Omitted means the host session's current project. A relative value resolves against the host session/binding cwd, and an existing directory is required; invalid explicit paths produce `invalid_cwd`. The override lasts one call and consistently drives `@project`, default/current-project globs, mutation endpoints, receipts, and new session-note ownership. It does not change the notes root or the physical session notebook.
25
+ All four notes tools accept optional `cwd`. Omitted means the host session's current project. A relative value resolves against the host session/binding cwd, and an existing directory is required; invalid explicit paths produce `invalid_cwd`. The override lasts one call and consistently drives `@project`, default/current-project globs, mutation endpoints, receipts, and new session-note ownership. It does not change the notes root or the physical session notebook.
26
26
 
27
27
  ## Read windows
28
28
 
@@ -55,7 +55,7 @@ The suffix and presentation header are never part of `text`, search offsets or t
55
55
 
56
56
  The native adapter allocates seqs from session append order, selects the active branch and decodes facts. Shared history pairs calls and results without allocating a second transcript. A paired execution is addressed by its call seq. Its result's raw slot is not a public event address; list/search provide the canonical seq. Unpaired results remain independently addressable. Inactive-branch addresses are not readable.
57
57
 
58
- Seqs address events across the whole session, including earlier windows. With `session` omitted, list and read headers use `seq <seq> | <role>`; the boot window tree supplies per-window seq ranges for narrowing a list with `before_seq` and `after_seq`. With an explicit selector, returned events/read data carry canonical `session`, headers use `session <harness>:<id> | seq <seq> | <role>`, and all paging/expand/neighborhood recipes carry that same identity. Wildcard `history_list` forbids seq bounds and reports whether more results may exist beyond the page. With `query`, it returns only hits across all roles; without a non-empty query, it returns one representative event per recent session, stopping once `limit` sessions have produced an item. Individual unreadable sessions are skipped only in wildcard calls. See [cross-session history](history-sessions.md) for resolution, discovery and refusal rules.
58
+ Seqs address events across the whole session, including earlier windows. With `session` omitted, list and read headers use `seq <seq> | <role>`; the boot window tree supplies seq ranges for narrowing a list with `after` and `before`. With an explicit selector, returned events/read data carry canonical `session`, headers use `session <harness>:<id> | seq <seq> | <role>`, and all paging/expand/neighborhood recipes carry that same identity. Wildcards accept time bounds only, and report whether more results may exist beyond the page. See [cross-session history](history-sessions.md) for discovery, representative selection and refusal rules.
59
59
 
60
60
  Tool events expose `tool`, `tool_status`, and, when recorded, `output_truncated` and `full_output_path`; a truncated run is named even when the host recorded no path, and the full text path is named only when it exists. `history_read` also reports `nested_calls`; a page row does not. Full arguments and nested-call records live only in the searchable/readable document, avoiding a second structured copy on every read.
61
61
 
@@ -67,13 +67,19 @@ Pi's nested records contain child ID, name, optional arguments, status, timing a
67
67
 
68
68
  One selection determines the structured result and its text. Both complete representations must fit the 32 KiB output budget, including metadata, cursor and rendered notice. A programmatic caller does not receive an unbounded hidden payload beside a truncated textual one. History operations accept an optional pure text wrapper from the host: selection and read-window checks measure that wrapper around the shared rendering, and the caller must apply the same wrapper at delivery. Host prose stays in its plugin; no final clipping or separate query is involved.
69
69
 
70
- `after_seq` is a strict lower bound; `after_seq: 0` starts from the beginning. History pages carry boolean `has_older` and `has_newer` flags. For single-session pages, use the first item’s `seq` as `before_seq` to page older, and the last item’s `seq` as `after_seq` to page newer; include its `session` when present. Wildcard pages instead report more results and suggest narrowing by time, query, roles or session pattern; an overview with unvisited sessions may have more. The single-session rendered newer footer gives `→ newer: {"after_seq":...}` with an optional session. `from` picks which end of a bounded range `limit` counts from: it defaults to `oldest` when `after_seq` is set, and `newest` otherwise. Explicit `from` wins. `since`/`until` narrow that range by event `created_at`, and only a single-session call without roles or a non-empty query folds tool/context runs. Omitted queries, empty strings and empty lists all disable search filtering; empty entries in a query list are ignored. Without a query, notes search returns scoped notes with empty `matches`, not every body line. Notes listings/search are snapshots with a `more` count and can be narrowed by `glob`; they are not falsely advertised as paginated. A read can stop anywhere in the event document, including inside serialized arguments; concatenate its verbatim text slices before parsing any arguments. There is no separately truncated arguments object.
70
+ `history_list` takes exclusive `after` and `before` bounds. Each accepts a seq (an integer or a digit-only string) or an ISO 8601 time (UTC when no offset is given). With `after`, `limit` counts forward (`after: 0` starts at the oldest event); without it, `limit` counts back from the newest eligible end. Both bounds define a range. Rows always come back oldest first.
71
+
72
+ With a non-empty `query`, `context: N` includes up to N events on each side of each hit, from the same session’s visible events. `after`, `before`, and `roles` limit hits, not their neighbors. Neighbor rows carry `context: true` and do not count toward `limit`; overlapping windows merge and the same output budget applies. History pages carry boolean `has_older` and `has_newer` flags. To page a single session, use the first non-context item's `seq` as `before` or the last non-context item's `seq` as `after`, with its `session` when present. Keep the search filters on the next call. Wildcard pages suggest narrowing by time, query, roles or session pattern instead. Only single-session browsing without roles folds tool/context runs.
73
+
74
+ `notes_list` with a non-empty `query` returns only matching notes and adds `matches` containing `line`, `text` and `offset_chars`, plus `more_matches` when lines are omitted. `max_matches_per_file` requires a query, as does history's `context`. Queries are literal and case-insensitive; a list matches any entry, ignoring empty entries. An empty or omitted query browses. Notes results are unpaged snapshots with a `more` count. Omit `glob` for current notebooks or supply a non-empty glob to narrow or widen the selection.
75
+
76
+ A history read can stop anywhere in the event document, including inside serialized arguments; concatenate its verbatim text slices before parsing any arguments.
71
77
 
72
78
  `notes_write` and `notes_update` accept optional `pinned`, `budget`, and `readonly` policy fields. Their receipts, list/search rows, and read `metadata` expose the effective `pinned`, `budget`, and `readonly` values as structured fields **and visible text**. Successes also carry a `warnings` array (per file for list/search), rendered visibly when a body exceeds its budget: the default is 4096 Unicode code points for ordinary pages and 2048 for root `CHEATSHEET.md` and `MAP.md`, adjustable per note. Overflow saves successfully; boot injects full pinned bodies instead of cutting them. Pi's custom write/update/read renderers show policy and warnings even when collapsed, outside the expandable body/diff and clipped summary. A readonly note refuses mutations with `readonly` until explicitly unlocked with `readonly:false`; this is a soft lock, not security. Pin admission refuses a sixth live pin per notebook with `pin_limit`, including restore/move/rename. Invalid policy fields refuse with `invalid_policy`.
73
79
 
74
80
  A note read reports unrecognized frontmatter under `metadata.extra`; a value too large to carry, or past the verbatim budget, is named in place as `[omitted: too large]` under its key rather than delivered in part, and the value itself stays in the note file. A rename receipt uses `address` for the destination and `rename_from` for the source; it has no duplicate `rename_to` field.
75
81
 
76
- `output_too_large` is not one failure. Each operation's own message says what it means: a read that cannot deliver a single advancing character is refused rather than answered with an empty window, and a search result whose first match line cannot fit is cut to the longest prefix that does and ends with ` [truncated]`. `notes_update` returns a compact policy-bearing receipt plus any budget warning; Pi attaches the rendered diff under `details.diff` for the UI rather than repeating it in model-facing text or `structuredContent`. Narrowing helps only where a parameter genuinely reduces the selection — `glob` or `query`, `roles`, `limit`, `max_chars_per_item`, a `before_seq`/`after_seq` range, or a `since`/`until` time window — and cannot help a read whose own metadata is what overflows. History pages refuse with `page_too_large` for the same reason. Nothing is ever quietly delivered short: every other omission is reported on the successful result that carries it.
82
+ `output_too_large` is not one failure. Each operation's own message says what it means: a read that cannot deliver a single advancing character is refused rather than answered with an empty window, and a search result whose first match line cannot fit is cut to the longest prefix that does and ends with ` [truncated]`. `notes_update` returns a compact policy-bearing receipt plus any budget warning; Pi attaches the rendered diff under `details.diff` for the UI rather than repeating it in model-facing text or `structuredContent`. Narrowing helps only where a parameter genuinely reduces the selection — `glob` or `query`, `roles`, `limit`, `max_chars_per_item`, or an `after`/`before` seq or time range — and cannot help a read whose own metadata is what overflows. History pages refuse with `page_too_large` for the same reason. Nothing is ever quietly delivered short: every other omission is reported on the successful result that carries it.
77
83
 
78
84
  ## Ownership
79
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.59.1",
3
+ "version": "0.60.0",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",