notesoup 0.58.1 → 0.58.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/boot/text.d.ts +1 -1
- package/dist/src/boot/text.js +5 -4
- package/dist/src/notes/policy.d.ts +1 -1
- package/dist/src/notes/policy.js +4 -3
- package/dist/src/tools/notes.js +1 -1
- package/dist/test/agent-loop.test.js +13 -39
- package/dist/test/boot.integration.test.js +20 -18
- package/dist/test/budget-settings.integration.test.js +18 -13
- package/dist/test/claude-history.test.js +1 -2
- package/dist/test/claude-mod.test.js +417 -87
- package/dist/test/codex-history.test.js +9 -6
- package/dist/test/codex-plugin.test.js +4 -8
- package/dist/test/dream-skill.test.js +6 -10
- package/dist/test/dsh-cli.test.js +2 -3
- package/dist/test/dsh.test.js +1 -7
- package/dist/test/helpers/extension.js +3 -1
- package/dist/test/history-corpus.test.js +2 -3
- package/dist/test/history-prefilter.test.js +33 -40
- package/dist/test/history-summary-cache.test.js +1 -1
- package/dist/test/history.integration.test.js +11 -37
- package/dist/test/host-neutral.test.js +2 -2
- package/dist/test/marker.test.js +1 -2
- package/dist/test/model-facing-text.test.js +20 -187
- package/dist/test/note-policy.test.js +40 -22
- package/dist/test/notes-library.test.js +2 -2
- package/dist/test/notes.integration.test.js +36 -149
- package/dist/test/notes.test.js +13 -61
- package/dist/test/pi-render.test.js +23 -62
- package/dist/test/reset-lifecycle.test.js +4 -9
- package/docs/architecture.md +1 -1
- package/docs/claude-code-mod.md +15 -3
- package/docs/dsh.md +1 -1
- package/docs/notes-library.md +1 -1
- package/docs/tool-results.md +1 -1
- package/package.json +1 -1
- package/playbook.md +1 -1
- package/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/plugins/claude/dist/claude/helper.js +10 -8
- package/plugins/claude/hooks/register.ts +198 -130
- package/plugins/claude/playbook.md +1 -1
- package/plugins/claude/skills/dream/SKILL.md +1 -1
- package/plugins/claude/skills/memory/SKILL.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +10 -8
- package/skills/dream/SKILL.md +1 -1
- package/skills/memory/SKILL.md +1 -1
- package/src/boot/text.ts +5 -4
- package/src/notes/policy.ts +4 -3
- package/src/tools/notes.ts +1 -1
package/docs/claude-code-mod.md
CHANGED
|
@@ -12,9 +12,17 @@ The warning remains `resetMarginTokens` (default 8192) plus `warningRunwayTokens
|
|
|
12
12
|
|
|
13
13
|
Once per window, when the measured context crosses the warning point, main-agent tool results or prompt submission carry exactly the same budget warning as Pi, ending with `empty_brain` and the countdown. Delivery is consumed only when the downstream chain accepts the warning. 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 handoff paragraph (normal only when the model called `empty_brain`, otherwise forced), selected once for the new window and reused on retry — the same boot-then-handoff order as Pi — while user `/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 binds the shared reset sentence to `mcp__notesoup__empty_brain`; 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
|
|
|
15
|
-
The
|
|
15
|
+
The reset flow has three separate lifetimes. `ResetFlow.request` lasts until successful reset or cancellation; it owns the first valid tool call's sticky note and continuation policy. `ResetState.commit` lasts for one native command attempt and tracks proof that Claude kept the boot. The per-turn cutoff can outlive the request when native auto compaction consumes it before the next step. Successful explicit reset and automatic reset share the same window/boot bookkeeping. A failed compaction retains the request for retry; an aborted, failed, or refused main turn cancels it. Session changes discard the flow and invalidate asynchronous work by generation.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
`empty_brain` accepts optional `last_word` and boolean `terminate` (default `false`). Non-boolean `terminate` is refused before recording a request. The first valid tool call owns both arguments for that pending reset; duplicates can re-arm the cutoff but cannot replace them. Every tool in the response's batch finishes, including parallel siblings. At the requesting main turn's next `turn.step`, the cutoff yields a synthetic `end_turn` without another model request or aborting tools. Subagent steps pass through, and subagents cannot reset the main brain. After successful main `turn.complete`, the non-held reset worker compacts; a confirmed commit permits one plugin-origin continuation unless `terminate: true`, manual STOP, or natural input has taken over. The handoff and sticky are already retained alongside the boot and are not repeated by that prompt.
|
|
18
|
+
|
|
19
|
+
Accepted natural input owns its continuation. Input received within the running turn, including input accepted before the first tool latch, releases the cutoff at the next step for the whole subsequent tool workflow. Input not yet delivered to a model request prevents reset work from starting. A separately queued natural turn also runs normally. No input is replayed. Native auto compaction consumes a pending request without resetting twice, while preserving its armed cutoff until turn completion or natural-input delivery; further auto compaction does not disarm it. Once that reset has completed and natural input releases its cutoff, a new `empty_brain` owns its own sticky and `terminate` policy. A consumed request's STOP does not carry into the new request.
|
|
20
|
+
|
|
21
|
+
`/empty` and `/fresh-window` request STOP for the same pending or in-flight reset, including one first requested by a tool. While idle they start one hidden normal-model close-out using the shared budget warning, so the model can save notes; while busy they use the current turn. A close-out tool call may select the normal handoff pool and sticky but cannot undo manual STOP. If the warning cannot load, submission fails, or another hook drops it, the request is cancelled so the command can retry. STOP controls automatic continuation; handoff selection still follows actual tool origin (normal) or no tool origin (forced). `DISABLE_COMPACT` refuses explicit requests and suppresses warnings.
|
|
22
|
+
|
|
23
|
+
Both interactive and headless (`-p` / SDK) resets use `$.command.run({command:"compact",args:...})`. A waiter armed in `session.start` runs this work outside held hooks and re-arms before submitting a close-out, avoiding prompt deadlock and lost completion signals. The command carries a unique instruction marker stored in its commit attempt; only matching manual compaction is admitted, while user `/compact` stays vetoed. Direct `$.session.compact` skips the calling mod's hook interactively and is unavailable headlessly. The command is enqueued before `turn.complete` returns, supporting single-prompt `-p` runs and open SDK streams.
|
|
24
|
+
|
|
25
|
+
A command receipt and prepared boot are not commit evidence. On Claude Code 2.1.319, interactive completion exposes the installed boot through `$.session.messages()`. Headless completion still exposes the old request snapshot and precedes appends, so the worker waits for successful main `session.append` results: a kept compact boundary followed by the unchanged boot with its UUID. A missing or rewritten boot, veto, or rejected command cannot start continuation. Boot acquisition failure vetoes an explicit reset without advancing the window. After commit, a dropped or failed continuation is reported without compacting again. Native command/output rows remain alongside the fresh boot; no compaction model request is made. A Claude dream backend is not implemented, and budget reporting (`get_context_remaining`) remains Pi-only.
|
|
18
26
|
|
|
19
27
|
The notes tools also serve subagent calls, using the same session identity and shared operations. The plugin exposes the shared memory and dream skills and the dream playbook; the build keeps these copies byte-identical to the canonical files.
|
|
20
28
|
|
|
@@ -36,4 +44,8 @@ Without a path back to a root or retained boot, window ordinals are unknown. Tho
|
|
|
36
44
|
|
|
37
45
|
## Validation
|
|
38
46
|
|
|
39
|
-
`npm run typecheck` includes the mod against the vendored Claude Code 2.1.295 contract. `npm test` also typechecks it and runs `claude plugin validate plugins/claude --strict`, skipping validation with a clear message only if `claude` is not installed. Scanner regression tests deliberately reintroduce each of the three forbidden call shapes and require the gate to fail.
|
|
47
|
+
`npm run typecheck` includes the mod against the vendored Claude Code 2.1.295 contract. `npm test` also typechecks it and runs `claude plugin validate plugins/claude --strict`, skipping validation with a clear message only if `claude` is not installed. Scanner regression tests deliberately reintroduce each of the three forbidden call shapes and require the gate to fail. Unit regressions drain the `turn.step` generator (including its final return value), distinguish a command receipt from deferred kept rows, and cover optional/default/explicit `terminate`, first-request-wins arguments, invalid booleans, manual STOP, STOP consumed by native automatic compaction, accepted natural input, failed commits, submission failures, and session changes.
|
|
48
|
+
|
|
49
|
+
The reset sequence was also verified with the installed Claude Code 2.1.319 main loop, using a scripted Anthropic service bound to loopback, isolated homes/settings/working directories, fake credentials, and a sandbox blocking external network access and reads of the real home. Single-prompt `-p`, open `stream-json`, and an interactive PTY all produced one clean request after a committed tool reset. The probe also checked parallel fast/slow `Read` siblings, `terminate:true` (one original API request, one commit, no kickoff) and explicit `terminate:false` (one commit followed by one fresh-window API request), manual close-out STOP even when it calls the tool, compaction vetoes, continuation drops, interruption, and natural input delivered within the running turn. These are host integration observations, separate from the unit harness. A skip returned after `next()` has already compacted is rejected by 2.1.319; that compaction stands. Valid vetoes return before calling `next`.
|
|
50
|
+
|
|
51
|
+
From a built checkout, check the real load with `claude --plugin-dir plugins/claude -p "ok"`; a model/API failure after load is separate from a hooks-module refusal. The package build and `npm pack --dry-run` include the manifests, hooks module, helper, skills, and playbook.
|
package/docs/dsh.md
CHANGED
|
@@ -47,7 +47,7 @@ The reminder and close-out warning go through `agent.steer`. Close-out remains a
|
|
|
47
47
|
| dsh versions | Tested against **0.2.1-alpha.2**. Capability checks do not establish wire or persistence compatibility with every newer preview. Run the scripted tests before upgrading. |
|
|
48
48
|
| Model calls per reset | **0** auxiliary model calls. The agent's note-writing turns and fresh-window continuation still make ordinary calls. |
|
|
49
49
|
| Retention | Surface node **0**, one boot/continuation checkpoint, and subsequent messages. An unfinished tool batch postpones reset; no partial tool pairs are discarded. |
|
|
50
|
-
| Boot bounds | Up to **5 live pins** and **3 recent notes per notebook**, from the shared policy/renderer. Root CHEATSHEET/MAP default pinned; explicit `pinned:false` overrides.
|
|
50
|
+
| Boot bounds | Up to **5 live pins** and **3 recent notes per notebook**, from the shared policy/renderer. Root CHEATSHEET/MAP default pinned; explicit `pinned:false` overrides. Ordinary pages default to a **4096-code-point advisory budget**; root CHEATSHEET/MAP default to **2048**, adjustable per note. Pinned bodies arrive **whole**, with over-budget warnings instead of truncation; manually over-cap pins are omitted with a visible address list. |
|
|
51
51
|
| Tool output | Shared **32 KiB** bounds; use `next_offset_chars`, history cursors, or narrower filters. There is no unbounded hidden result. |
|
|
52
52
|
| Warning timing | Steering enters the next step; a large current response/tool batch can spend the runway. The hard reserve protects the next balanced boundary, not an in-flight provider call. |
|
|
53
53
|
| Unknown capacity | Countdown is **null** and automatic reserve checks skip. Add `models[].contextWindow` to `llm-deepseek`; explicit resets still work. |
|
package/docs/notes-library.md
CHANGED
|
@@ -53,7 +53,7 @@ Addresses are a relative path (a current-session note), `@project/`, `@human/`,
|
|
|
53
53
|
|
|
54
54
|
`effectiveNotePolicy(meta, path)` returns `{ pinned, budget, readonly }` for a notebook-relative Markdown path (`MAP.md`, not an `@` address). This is the shared default resolver used by storage, tools and boot:
|
|
55
55
|
|
|
56
|
-
-
|
|
56
|
+
- Ordinary pages have a default budget of **4096 Unicode code points**; root `CHEATSHEET.md` and `MAP.md` default to **2048**, adjustable to any positive safe integer. `warnings` on write/update/rename results report body overflow but do not reject it. Astral characters count once. The separate serialized-file byte limit still applies.
|
|
57
57
|
- Only root `CHEATSHEET.md` and `MAP.md` default to pinned; all other paths, including nested files with those names, default false. Explicit false overrides the default. Raw `meta` keeps absent policy fields absent, so implicit defaults are re-evaluated at a move's destination; explicitly set values travel with the note.
|
|
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.
|
package/docs/tool-results.md
CHANGED
|
@@ -69,7 +69,7 @@ One selection determines the structured result and its text. Both complete repre
|
|
|
69
69
|
|
|
70
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.
|
|
71
71
|
|
|
72
|
-
`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
|
|
72
|
+
`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
73
|
|
|
74
74
|
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
75
|
|
package/package.json
CHANGED
package/playbook.md
CHANGED
|
@@ -27,7 +27,7 @@ Durable notes hold decisions, constraints, and lessons that stay true after the
|
|
|
27
27
|
5. **Relocate misfiled notes.** When a standing ruling or the note's own MAP already names its proper notebook, move it there, preserving its metadata, and update both notebooks' maps. Do it, don't propose it. Propose only when the destination notebook itself is unclear.
|
|
28
28
|
6. **Preserve meaning and provenance.** Keep facts, conditions, exceptions, uncertainty, authorship, and sources. When promoting a finding, cite its source. Do not relabel agent-authored material as human-authored. If its destination or authority is unclear, propose the promotion instead.
|
|
29
29
|
7. **Keep notes manageable.** Aim below about 200 lines / 8KB per note. Split oversized notes by topic with one-line cross-links.
|
|
30
|
-
8. **Keep wake-up pages useful.** Each writable notebook's `CHEATSHEET.md` holds standing reminders, kept to five lines. Its `MAP.md` holds only the note index: durable notes' addresses and short gists. Both default to pinned and load every window when live unless explicitly unpinned; do not create empty pages. Each notebook allows five live pins.
|
|
30
|
+
8. **Keep wake-up pages useful.** Each writable notebook's `CHEATSHEET.md` holds standing reminders, kept to five lines. Its `MAP.md` holds only the note index: durable notes' addresses and short gists. Both default to pinned and load every window when live unless explicitly unpinned; do not create empty pages. Each notebook allows five live pins. Ordinary pages default to a 4096-code-point advisory budget (2048 for root `CHEATSHEET.md` and `MAP.md`), adjustable per note; overflow warns without truncating a pinned body. Preserve standing rules, add promoted notes to the map, and drop entries that no longer hold.
|
|
31
31
|
|
|
32
32
|
## Deleting
|
|
33
33
|
|
|
@@ -8165,7 +8165,7 @@ function addressFor(identity2, scope, path, who) {
|
|
|
8165
8165
|
}
|
|
8166
8166
|
|
|
8167
8167
|
// src/notes/policy.ts
|
|
8168
|
-
var DEFAULT_NOTE_BUDGET =
|
|
8168
|
+
var DEFAULT_NOTE_BUDGET = 4096;
|
|
8169
8169
|
var MAX_PINNED_NOTES = 5;
|
|
8170
8170
|
var DEFAULT_PINNED_PAGES = ["CHEATSHEET.md", "MAP.md"];
|
|
8171
8171
|
function validateNotePolicy(fields) {
|
|
@@ -8178,9 +8178,10 @@ function validateNotePolicy(fields) {
|
|
|
8178
8178
|
}
|
|
8179
8179
|
function effectiveNotePolicy(fields, path) {
|
|
8180
8180
|
validateNotePolicy(fields);
|
|
8181
|
+
const defaultPage = DEFAULT_PINNED_PAGES.some((page) => page === path);
|
|
8181
8182
|
return {
|
|
8182
|
-
pinned: fields.pinned ??
|
|
8183
|
-
budget: fields.budget ?? DEFAULT_NOTE_BUDGET,
|
|
8183
|
+
pinned: fields.pinned ?? defaultPage,
|
|
8184
|
+
budget: fields.budget ?? (defaultPage ? 2048 : DEFAULT_NOTE_BUDGET),
|
|
8184
8185
|
readonly: fields.readonly ?? false
|
|
8185
8186
|
};
|
|
8186
8187
|
}
|
|
@@ -9166,7 +9167,7 @@ var ORIGIN = typebox_exports.Optional(typebox_exports.Union([...ORIGIN_VALUES],
|
|
|
9166
9167
|
}));
|
|
9167
9168
|
var POLICY_PARAMETERS = {
|
|
9168
9169
|
pinned: typebox_exports.Optional(typebox_exports.Boolean({ description: "Inject the full body at boot. At most 5 live pins per notebook; root CHEATSHEET.md/MAP.md default true, all others false. Explicit false overrides the default." })),
|
|
9169
|
-
budget: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER, description: "Body budget in Unicode code points (default
|
|
9170
|
+
budget: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER, description: "Body budget in Unicode code points (default 4096; root CHEATSHEET.md and MAP.md default 2048). Over budget warns but saves; boot does not truncate." })),
|
|
9170
9171
|
readonly: typebox_exports.Optional(typebox_exports.Boolean({ description: "Soft lock, not a security boundary. true locks changes; explicitly pass false to unlock, including in the same call as edits or overwrite." }))
|
|
9171
9172
|
};
|
|
9172
9173
|
var PolicySchema = {
|
|
@@ -11229,10 +11230,11 @@ Pinned pages get jammed straight into your brain the moment you wake up. Whoever
|
|
|
11229
11230
|
reads them, and next is you. So keep them short, and keep them true.
|
|
11230
11231
|
|
|
11231
11232
|
Set \`pinned\`, \`budget\`, and \`readonly\` with the note tools or frontmatter. Each notebook allows five
|
|
11232
|
-
live pins, including the defaults; \`pinned:false\` unpins even a default page.
|
|
11233
|
-
|
|
11234
|
-
and pinned bodies arrive whole, not cut short.
|
|
11235
|
-
explicitly set \`readonly:false\` to unlock,
|
|
11233
|
+
live pins, including the defaults; \`pinned:false\` unpins even a default page. Budgets start at 4096
|
|
11234
|
+
Unicode code points, or 2048 for root \`CHEATSHEET.md\` and \`MAP.md\`; set a positive integer to
|
|
11235
|
+
change one. Going over warns but saves, and pinned bodies arrive whole, not cut short.
|
|
11236
|
+
\`readonly:true\` is a soft lock, not security; explicitly set \`readonly:false\` to unlock,
|
|
11237
|
+
on its own or with your changes.
|
|
11236
11238
|
|
|
11237
11239
|
- **\`CHEATSHEET.md\`** holds what you'll want next time \u2014 a rule, a warning, a grudge, a name,
|
|
11238
11240
|
a phone number you'll regret losing. Nobody grades it. Keep it to five lines, or it grows fat
|