notesoup 0.47.1 → 0.48.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.
- package/README.md +1 -1
- package/dist/src/boot/render.d.ts +14 -7
- package/dist/src/boot/render.js +29 -16
- package/dist/src/boot/text.d.ts +25 -4
- package/dist/src/boot/text.js +59 -11
- package/dist/src/budget/text.d.ts +29 -9
- package/dist/src/budget/text.js +51 -10
- package/dist/src/claude/helper.d.ts +2 -3
- package/dist/src/claude/helper.js +45 -11
- package/dist/src/claude/history.d.ts +9 -0
- package/dist/src/claude/history.js +271 -0
- package/dist/src/dsh/engine.d.ts +2 -1
- package/dist/src/dsh/engine.js +18 -9
- package/dist/src/dsh/index.js +9 -4
- package/dist/src/dsh/window.d.ts +2 -1
- package/dist/src/dsh/window.js +14 -8
- package/dist/src/history/query.js +59 -81
- package/dist/src/notes/address.d.ts +5 -0
- package/dist/src/notes/address.js +20 -21
- package/dist/src/notes/store.js +12 -19
- package/dist/src/pi/boot.d.ts +1 -1
- package/dist/src/pi/boot.js +28 -5
- package/dist/src/pi/budget.d.ts +0 -2
- package/dist/src/pi/budget.js +13 -53
- package/dist/src/pi/entries.d.ts +0 -1
- package/dist/src/pi/entries.js +0 -1
- package/dist/src/pi/history.d.ts +3 -0
- package/dist/src/pi/history.js +4 -0
- package/dist/src/pi/reset/artifacts.d.ts +7 -2
- package/dist/src/pi/reset/artifacts.js +16 -14
- package/dist/src/pi/reset/lifecycle.d.ts +21 -25
- package/dist/src/pi/reset/lifecycle.js +48 -72
- package/dist/src/pi/runtime.js +6 -6
- package/dist/src/pi/window.d.ts +12 -6
- package/dist/src/pi/window.js +7 -0
- package/dist/test/agent-loop.test.js +52 -29
- package/dist/test/boot.integration.test.js +114 -11
- package/dist/test/budget-settings.integration.test.js +4 -2
- package/dist/test/claude-history.test.d.ts +1 -0
- package/dist/test/claude-history.test.js +184 -0
- package/dist/test/claude-mod.test.js +236 -42
- package/dist/test/dsh.test.js +79 -2
- package/dist/test/helpers/extension.d.ts +3 -0
- package/dist/test/helpers/extension.js +33 -5
- package/dist/test/history.integration.test.js +66 -0
- package/dist/test/host-neutral.test.js +1 -1
- package/dist/test/model-facing-text.test.d.ts +1 -0
- package/dist/test/model-facing-text.test.js +181 -0
- package/dist/test/notes.integration.test.js +16 -18
- package/dist/test/reset-lifecycle.test.js +201 -46
- package/docs/architecture.md +3 -3
- package/docs/claude-code-mod.md +15 -3
- package/docs/dsh.md +1 -1
- package/docs/reset-lifecycle.md +32 -20
- package/docs/skills.md +1 -1
- package/mods/notesoup/.claude-plugin/plugin.json +1 -1
- package/mods/notesoup/dist/claude/helper.js +836 -92
- package/mods/notesoup/hooks/register.ts +140 -38
- package/package.json +1 -1
- package/src/boot/render.ts +41 -23
- package/src/boot/text.ts +68 -11
- package/src/budget/text.ts +61 -10
- package/src/claude/helper.ts +53 -22
- package/src/claude/history.ts +228 -0
- package/src/dsh/engine.ts +16 -9
- package/src/dsh/index.ts +8 -3
- package/src/dsh/window.ts +15 -9
- package/src/history/query.ts +57 -82
- package/src/notes/address.ts +19 -16
- package/src/notes/store.ts +9 -14
- package/src/pi/boot.ts +27 -5
- package/src/pi/budget.ts +13 -50
- package/src/pi/entries.ts +0 -1
- package/src/pi/history.ts +7 -2
- package/src/pi/reset/artifacts.ts +17 -14
- package/src/pi/reset/lifecycle.ts +56 -79
- package/src/pi/runtime.ts +6 -6
- package/src/pi/window.ts +11 -1
package/docs/reset-lifecycle.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Reset lifecycle
|
|
2
2
|
|
|
3
|
-
All lifecycle control flow is native Pi integration. `src/pi/reset/lifecycle.ts` owns
|
|
3
|
+
All lifecycle control flow is native Pi integration. `src/pi/reset/lifecycle.ts` owns actual tool requests, command settlement policy, bounded overflow recovery and scheduling. `src/pi/budget.ts` reads usage/settings and stages reminders; `src/budget/policy.ts` derives thresholds. `src/pi/reset/artifacts.ts` constructs ordered drafts and repairs incomplete suffixes; `src/pi/reset/committed.ts` confirms durable boundaries. `src/pi/window.ts` owns markers and provider projection. `src/pi/runtime.ts` wires commands, tools and public Pi hooks.
|
|
4
4
|
|
|
5
5
|
Boot acquisition/rendering is shared: `src/boot/snapshot.ts` receives explicit identity, a captured time and an optional scope loader; `src/boot/render.ts` receives the snapshot and logical tool bindings. Pi supplies its existing names. Shared history is an addressed query projection, never an inference transcript or reset scheduler. There is no generic HostEvent or Harness reducer, and no second commit database.
|
|
6
6
|
|
|
@@ -8,9 +8,9 @@ Boot acquisition/rendering is shared: `src/boot/snapshot.ts` receives explicit i
|
|
|
8
8
|
|
|
9
9
|
| Trigger | Behavior |
|
|
10
10
|
| --- | --- |
|
|
11
|
-
| `empty_brain` tool |
|
|
12
|
-
| `/fresh-window` or `/empty-brain` |
|
|
13
|
-
| Budget warning |
|
|
11
|
+
| `empty_brain` tool | Record an actual tool request for the current window, including any last word. Without command policy it commits at `turn_end` after the complete tool batch and continues. Under command policy the request remains recorded but waits for settlement. |
|
|
12
|
+
| `/fresh-window` or `/empty-brain` | Store command policy and send a hidden warning (start a turn when idle, steer when running). Wait for successful settlement after queued messages drain, then reset and stop for a bare command or continue for a command with text. Model tool calls remain actual requests; they do not change settlement policy. The text reaches the closing model only, never the new window directly. |
|
|
13
|
+
| Budget warning | Inject a warning at reserve plus runway when automatic reset is enabled. This creates no lifecycle state. A warning alone never authorizes a reset; a tool call or the independent hard-reserve check does. |
|
|
14
14
|
| Hard reserve | Independent safety path: if automatic resets are enabled and completed-turn usage reaches Pi's reserve, commit a boundary at `turn_end`. A pending manual stop survives in a run-scoped `stop-pending` phase; empty automatic follow-up is cancelled before provider work, while real queued user input is answered before stopping. |
|
|
15
15
|
| Abort or error | Never count as successful close-out. Abort clears lifecycle state. An ordinary close-out error is dropped without reset. Manual overflow clears and stops without retry, even with automatic reset disabled; automatic provider-overflow recovery remains separately bounded. |
|
|
16
16
|
| `/compact` while active | Cancel native compaction, which could otherwise summarize pre-reset history back into the active window. A manual attempt receives an actionable `/fresh-window` notice. |
|
|
@@ -18,14 +18,24 @@ Boot acquisition/rendering is shared: `src/boot/snapshot.ts` receives explicit i
|
|
|
18
18
|
A new boundary is ordered as:
|
|
19
19
|
|
|
20
20
|
1. A native `compaction` entry with `summary: ""` and `firstKeptEntryId` set to its own ID. This is Pi's retain-none canonical checkpoint; it is not a generated summary request.
|
|
21
|
-
2. A `notesoup/reset-marker` custom entry with `{ windowId }`.
|
|
21
|
+
2. A `notesoup/reset-marker` custom entry with `{ windowId, origin }`.
|
|
22
22
|
3. A hidden `notesoup/boot` custom message with matching `details.windowId`.
|
|
23
|
-
4. A hidden continuation message.
|
|
24
|
-
5. If the
|
|
23
|
+
4. A hidden continuation message carrying the paragraph drawn for that boundary.
|
|
24
|
+
5. If the closing window passed a `last_word`, a visible `notesoup/reset-last-word` message carrying it. Pi boundary drafts do not support ordinary user entries, so the parting line is committed with the reset instead of queued separately.
|
|
25
|
+
|
|
26
|
+
## Handoff origin and the continuation pools
|
|
27
|
+
|
|
28
|
+
The continuation is one randomly selected, complete paragraph from an approved pool, drawn when a new boundary artifact is created and persisted verbatim in the continuation entry; the marker's `origin` field records which pool was used. Rendering, history reads, and reloads never draw again, so a window keeps the handoff it was opened with.
|
|
29
|
+
|
|
30
|
+
The origin comes directly from the recorded tool request: with a call it is `normal`, without one it is `forced`. Command policy affects timing and continuation, never origin. A hard-reserve stop latch retains the tool request for construction retry. No separate acknowledgement flag or warning-source inference is needed. Legacy markers without a valid origin default to normal.
|
|
31
|
+
|
|
32
|
+
Each host draws once per artifact and shares that value across every representation of it: Pi persists one entry, dsh writes the same paragraph into its checkpoint text and its steered continuation, and Claude — which has no model-facing reset tool, so every Claude reset is forced — caches one line per window so a retried compaction cannot redraw it. A generic read-only text endpoint never draws.
|
|
33
|
+
|
|
34
|
+
A manual `/empty-brain <prompt>` command line is not persisted after the reset: it reaches the closing window inside the warning, and the closing model records what the next window needs in notes.
|
|
25
35
|
|
|
26
36
|
The raw session branch is preserved for history. New checkpoint-backed branches use Pi's canonical retain-none projection, which preserves the empty summary wrapper and system/tool state while excluding earlier conversational context. Older marker-only sessions use marker slicing as a narrow compatibility fallback. A marker is trusted as checkpoint-backed only when it directly follows an empty native compaction whose `firstKeptEntryId` is the compaction's own ID; a generic preceding compaction is not enough.
|
|
27
37
|
|
|
28
|
-
`turn_end`
|
|
38
|
+
`turn_end` preserves incoming entries, consumes budget drafts and appends a reset only for a tool-only request or hard reserve. `agent_before_settle` executes command policy after queued work drains, or performs bounded overflow recovery. Pi owns ensuing continuation and scheduling. Async reset construction captures session/window generations and rechecks them, enabled state and abort status before returning drafts. Stale results are discarded without losing incoming/budget entries; construction failures notify only while current and do not claim a continuation.
|
|
29
39
|
|
|
30
40
|
## Reducer state
|
|
31
41
|
|
|
@@ -33,10 +43,10 @@ The raw session branch is preserved for history. New checkpoint-backed branches
|
|
|
33
43
|
|
|
34
44
|
| State | Meaning |
|
|
35
45
|
| --- | --- |
|
|
36
|
-
| `{ phase: "none" }` | No
|
|
37
|
-
| `{ phase: "
|
|
38
|
-
| `{ phase: "stop-pending", windowId }` | A manual hard-reserve reset was proposed for the given old window. The stop survives a committed window change; settlement stops without a second wipe (or retries construction if the old window is still active). New wipe requests only acknowledge it. |
|
|
39
|
-
|
|
46
|
+
| `{ phase: "none" }` | No request or command policy is pending. |
|
|
47
|
+
| `{ phase: "pending", windowId, command?, tool? }` | `command: { continueAfterReset }` is settlement policy. `tool: { lastWord? }` records an actual model call, even without a last word. Either or both may exist; neither overwrites the other. No warning source or raw prompt is stored. |
|
|
48
|
+
| `{ phase: "stop-pending", windowId, tool? }` | A manual hard-reserve reset was proposed for the given old window. The stop survives a committed window change; settlement stops without a second wipe (or retries construction if the old window is still active). New wipe requests only acknowledge it. |
|
|
49
|
+
|
|
40
50
|
| `overflow: "idle"` | No overflow recovery is pending. |
|
|
41
51
|
| `overflow: "pending"` | An overflow failure may recover once at pre-settlement. |
|
|
42
52
|
| `overflow: "pending-spent"` | Recovery was already spent in this failure chain. |
|
|
@@ -44,21 +54,23 @@ The raw session branch is preserved for history. New checkpoint-backed branches
|
|
|
44
54
|
|
|
45
55
|
### Transition rules
|
|
46
56
|
|
|
47
|
-
- `
|
|
48
|
-
- `tool_request(windowId)`
|
|
49
|
-
- `turn_end`
|
|
50
|
-
- `agent_before_settle`
|
|
57
|
+
- `command(windowId, continueAfterReset)` stores settlement policy. Duplicate same-window commands retain the first policy; a pending tool request is retained.
|
|
58
|
+
- `tool_request(windowId, lastWord?)` records an actual call without changing command policy. Tool-only duplicates keep the first request; under command policy, repeated calls may supply the first nonempty last word.
|
|
59
|
+
- `turn_end` clears on abort. Overflow preserves command policy and its tool request; otherwise automatic recovery is armed only when enabled and unqueued. Other errors drop pending requests. Success commits a tool-only request or hard-reserve reset. Hard reserve under a bare command retains the cross-window `stop-pending` latch; a continuing command needs no stop latch.
|
|
60
|
+
- `agent_before_settle` waits for queued work. Command overflow resets even with automatic recovery disabled, honoring command continuation policy. Other overflow recovery gets one attempt. A committed stop latch stops without a second wipe; an uncommitted one can retry construction. Otherwise a successful command settles and resets. No command means no ordinary settle reset.
|
|
51
61
|
- `agent_settled`, session start/tree navigation/shutdown, `/notesoup off`, and abort clear transient request state. Durable checkpoint/marker history remains authoritative after transient state is gone.
|
|
52
62
|
|
|
53
63
|
After a manual safety reset, `context_with_system` verifies the committed checkpoint/marker/boot/continuation before using public `ctx.abort()` to cancel Pi's otherwise unavoidable tool-batch follow-up, returning a system-only safe context. Pending messages or a real user message after the reset marker bypass cancellation so queued work is not swallowed. A follow-up queue may require Pi's ordinary tool follow-up to finish before delivery; the stop intent remains armed until that work settles. Abort/settlement clears the run-scoped latch, so later user prompts work normally.
|
|
54
64
|
|
|
55
|
-
|
|
65
|
+
Budget warnings need no rearming or consumption in the lifecycle. Direct tool calls remain valid without a warning. Actual abort, synthetic assistant abort and generic provider failure keep their existing cleanup semantics.
|
|
56
66
|
|
|
57
67
|
## Budget staging and notifications
|
|
58
68
|
|
|
59
|
-
The early reminder is staged once per window
|
|
69
|
+
The early reminder is staged once per window at `reserve + reminderMarginTokens`; the final warning at `reserve + WARNING_RUNWAY_TOKENS`, only when automatic compaction is enabled. Hard reserve remains independent. Budget and command warnings have distinct message types, so an aborted command cannot suppress a later budget warning. Durable warning deduplication concerns only injection; no transient automatic close-out is armed or rearmed.
|
|
70
|
+
|
|
71
|
+
Pi's boot protocol and second-tier warning include pre-reset hints: the reset clears the human's chat view, so long explanations belong after it; the model manages reset timing unless directed otherwise. Those hints are Pi-only. Dsh's second-tier notice ends with the same countdown as Pi and Claude.
|
|
60
72
|
|
|
61
|
-
Budget drafts are instance-local and are consumed at turn end. They are discarded on abort, failed turn, transition, or window mismatch. UI
|
|
73
|
+
Budget drafts are instance-local and are consumed at turn end. They are discarded on abort, failed turn, transition, or window mismatch. The final warning notifies the UI when first injected into a model request, before the response or tool execution, rather than waiting for durability. Aborting the request does not retract the notice or repeat it on retry in the same window; early guidance remains UI-silent. Active-window usage and the exact `SettingsManager` authority drive threshold checks; default file-backed policy is cached per extension instance, while injected managers are read through their public API.
|
|
62
74
|
|
|
63
75
|
## Projection, repair, and history
|
|
64
76
|
|
|
@@ -66,7 +78,7 @@ Budget drafts are instance-local and are consumed at turn end. They are discarde
|
|
|
66
78
|
|
|
67
79
|
Commit confirmation and repair are different native facts. `resetBoundaryCommitted` validates a checkpoint-backed marker followed by its matching hidden boot and hidden continuation; later conversation does not undo that commit. `inspectResetTail` instead asks whether the entire suffix remains safe to repair, refusing later conversation, foreign messages, later markers or misordered/duplicate artifacts. UI success notices use confirmation, not the repair predicate, and remain committed-only.
|
|
68
80
|
|
|
69
|
-
Startup/tree repair is narrow: it may complete a repairable marker tail when later conversation does not make the missing metadata ambiguous. It awaits the notes snapshot and rechecks lifecycle/window identity before sending a repaired boot or continuation. Legacy marker-only tails remain supported; repair never moves a boundary or promotes an arbitrary compaction to a retain-none checkpoint. `/tree` summary generation is suppressed with an empty summary when either branch crosses a reset, because the raw summary generator bypasses the provider projection.
|
|
81
|
+
Startup/tree repair is narrow: it may complete a repairable marker tail when later conversation does not make the missing metadata ambiguous. It awaits the notes snapshot and rechecks lifecycle/window identity before sending a repaired boot or continuation. A missing continuation is drawn from the pool its marker's `origin` names; an existing continuation is never replaced, never redrawn, and its marker is never rewritten. Legacy marker-only tails remain supported; repair never moves a boundary or promotes an arbitrary compaction to a retain-none checkpoint. `/tree` summary generation is suppressed with an empty summary when either branch crosses a reset, because the raw summary generator bypasses the provider projection.
|
|
70
82
|
|
|
71
83
|
## Validation and known limits
|
|
72
84
|
|
package/docs/skills.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Memory skill
|
|
4
4
|
|
|
5
|
-
The package provides `/skill:memory`, a short self-contained guide to the notes and history tools: note addresses and homes, finding and paging notes, searching and paging history, saving recovery state, and what to do when a memory tool is unavailable. It is a fallback for sessions where the boot protocol is missing or unclear and a reference on demand; normal tool calls do not require reading it. It is written independently of the boot text rather than generated from it. The Claude Code Mod
|
|
5
|
+
The package provides `/skill:memory`, a short self-contained guide to the notes and history tools: note addresses and homes, finding and paging notes, searching and paging history, saving recovery state, and what to do when a memory tool is unavailable. It is a fallback for sessions where the boot protocol is missing or unclear and a reference on demand; normal tool calls do not require reading it. It is written independently of the boot text rather than generated from it. The Claude Code Mod ships the same guide; its history tools require the documented main-session transcript path and a confirmed append head.
|
|
6
6
|
|
|
7
7
|
## Dream skill
|
|
8
8
|
|