notesoup 0.51.1 → 0.51.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.
Files changed (35) hide show
  1. package/dist/plugins/pi/entries.d.ts +2 -0
  2. package/dist/plugins/pi/entries.js +2 -0
  3. package/dist/plugins/pi/reset/artifacts.d.ts +10 -2
  4. package/dist/plugins/pi/reset/artifacts.js +24 -5
  5. package/dist/plugins/pi/reset/lifecycle.d.ts +37 -21
  6. package/dist/plugins/pi/reset/lifecycle.js +132 -57
  7. package/dist/plugins/pi/runtime.js +9 -10
  8. package/dist/plugins/pi/text.d.ts +11 -14
  9. package/dist/plugins/pi/text.js +15 -16
  10. package/dist/test/agent-loop.test.js +316 -163
  11. package/dist/test/boot.integration.test.js +3 -3
  12. package/dist/test/claude-validation.test.js +4 -2
  13. package/dist/test/dsh-cli.test.js +7 -6
  14. package/dist/test/helpers/dsh-messages.js +3 -0
  15. package/dist/test/model-facing-text.test.js +10 -4
  16. package/dist/test/reset-lifecycle.test.js +272 -88
  17. package/docs/architecture.md +1 -1
  18. package/docs/reset-lifecycle.md +42 -57
  19. package/package.json +2 -2
  20. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  21. package/plugins/paseo/OVERVIEW.md +7 -0
  22. package/plugins/paseo/README.md +12 -0
  23. package/plugins/paseo/client/source-row.ts +14 -0
  24. package/plugins/paseo/client/sticky-card.tsx +21 -0
  25. package/plugins/paseo/index.client.tsx +10 -0
  26. package/plugins/paseo/package.json +19 -0
  27. package/plugins/paseo/paseo-plugin.json +4 -0
  28. package/plugins/paseo/shared/last-word.ts +6 -0
  29. package/plugins/paseo/test/source-row.test.ts +19 -0
  30. package/plugins/paseo/tsconfig.json +16 -0
  31. package/plugins/pi/entries.ts +2 -0
  32. package/plugins/pi/reset/artifacts.ts +26 -5
  33. package/plugins/pi/reset/lifecycle.ts +135 -70
  34. package/plugins/pi/runtime.ts +9 -10
  35. package/plugins/pi/text.ts +17 -17
@@ -1,87 +1,72 @@
1
1
  # Reset lifecycle
2
2
 
3
- All lifecycle control flow is native Pi integration. `plugins/pi/reset/lifecycle.ts` owns actual tool requests, command settlement policy, bounded overflow recovery and scheduling. `plugins/pi/budget.ts` reads usage/settings and stages reminders; `src/budget/policy.ts` derives thresholds. `plugins/pi/reset/artifacts.ts` constructs ordered drafts and repairs incomplete suffixes; `plugins/pi/reset/committed.ts` confirms durable boundaries. `plugins/pi/window.ts` owns markers and provider projection. `plugins/pi/runtime.ts` wires commands, tools and public Pi hooks.
4
-
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.
3
+ Pi reset control lives in `plugins/pi/reset/lifecycle.ts`: the pure `reduceResetControl` selects state transitions or boundary intents; after asynchronous construction, `finalizeResetBoundary` owns final state, carried inputs and continuation. `registerResetLifecycle` adapts public Pi events, constructs boundaries and applies the finalizer's result unchanged. `budget.ts` stages reminders and checks settings; `reset/artifacts.ts` builds and repairs ordered artifacts; `reset/committed.ts` confirms durable boundaries. `window.ts` owns identities and provider projection; `runtime.ts` wires commands and tools. No Pi source patches, native summarization requests, or second commit database are used.
6
4
 
7
5
  ## Lifecycle at a glance
8
6
 
7
+ **Human input not yet answered must survive a reset and be answered afterward. Only a bare `/empty` with no later human input stops after resetting.**
8
+
9
9
  | Trigger | Behavior |
10
10
  | --- | --- |
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` | 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
- | 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
- | 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
- | `/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. |
17
-
18
- A new boundary is ordered as:
19
-
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, origin }`.
22
- 3. A hidden `notesoup/boot` custom message with matching `details.windowId`.
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.
11
+ | `empty_brain` tool | Record the actual call and optional last word. Without command policy, reset after the whole tool batch at `turn_end` and continue. Under command policy, wait for settlement. |
12
+ | `/empty <text>` or `/fresh-window <text>` | Send a hidden close-out warning (trigger when idle, steer when busy), then reset and continue. Carry the argument text verbatim as the next window's human message; it is not merely a notes hint. |
13
+ | Bare `/empty` or `/fresh-window` | Close out, reset, and stop, unless more human input arrives while close-out is pending. |
14
+ | Human input during command close-out | Intercept public `input` events except source `extension`, return `handled`, and stash text/images in command state. Also hidden-steer the bare `<notesoup:next_window_prompt>` block plus original images to the closing model. The originals are carried even if that steer never arrives; any carried input makes the reset continue. |
15
+ | Passive provider overflow / recoverable length | With automatic reset enabled, force a retain-none reset and continue once. Carry the failed logical run's human messages: starting prompt and delivered steering/follow-ups. A run started by our own continuation has no human input to carry. |
16
+ | Command close-out overflow | Force a reset even if automatic reset is disabled. Apply command policy: continue with text/carried input, otherwise stop. The recovery attempt is spent, so an oversized carried prompt cannot loop. |
17
+ | Budget warning | Stage reminders when automatic reset is enabled. Warnings alone never authorize reset. |
18
+ | Hard reserve | Independently reset at `turn_end` when automatic reset is enabled. A bare-command stop latch cancels empty tool follow-ups, but never real queued or carried human input. |
19
+ | Abort / ordinary error | Restore stashed originals as visible user-content custom messages before clearing command state. Explicit abort stays stopped; ordinary close-out errors do not force reset. |
20
+ | `/compact` while active | Cancel native compaction; manual attempts receive a `/fresh-window` notice. |
25
21
 
26
- ## Handoff origin and the continuation pools
22
+ Switching to a smaller model does not proactively reset or select another model. If its request overflows, the same bounded automatic recovery carries the unanswered prompt into a fresh window on the selected model. Disabling automatic reset disables passive overflow recovery.
27
23
 
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.
24
+ ## Boundary order and handoff
29
25
 
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.
26
+ One public boundary draft contains, in order:
31
27
 
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.
28
+ 1. A native `compaction` with `summary: ""` and `firstKeptEntryId: null` (Pi materializes its own ID: retain none).
29
+ 2. A `notesoup/reset-marker` custom entry with `{ windowId, origin }`.
30
+ 3. A hidden `notesoup/boot` custom message with matching `details.windowId`.
31
+ 4. One hidden continuation paragraph, selected once when the artifact is built.
32
+ 5. An optional visible `notesoup/reset-last-word` sticky note.
33
+ 6. One visible `notesoup/carried-input` custom message per carried human input, preserving original text/image content and order.
33
34
 
34
- A manual `/empty <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.
35
+ Boundary drafts cannot contain ordinary user entries. Pi's public custom-message conversion supplies role `user` to the provider, including text/image arrays. Carried inputs are appended atomically with the reset artifacts, not queued as separate prompts; any carried input returns `continue: true`.
35
36
 
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.
37
+ The origin is `normal` for an actual tool request, otherwise `forced`; overflow recovery is always forced. Each origin has an approved complete-paragraph pool. Construction draws once and persists the paragraph verbatim; rendering, reads, reloads and repair never redraw an existing continuation. Legacy markers without a valid origin default to normal. Other hosts retain their own scheduling: dsh shares one draw across checkpoint and continuation; Claude caches its forced handoff per window.
37
38
 
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.
39
+ Raw session history remains available. The retain-none checkpoint excludes old conversational context while preserving Pi's empty summary wrapper and system/tool state. Marker-only legacy sessions use boot slicing as a compatibility fallback. A marker is checkpoint-backed only if it directly follows a self-retaining, empty native compaction.
39
40
 
40
- ## Reducer state
41
+ ## Reducer and run state
41
42
 
42
- `reduceResetControl` is pure: the adapter supplies all lifecycle facts, and the reducer returns the next state plus a named effect. Its state combines a request phase with a bounded overflow phase:
43
+ `ResetControlState` combines a request, a bounded overflow phase, and an optional run-scoped `stopAfterReset` latch:
43
44
 
44
- | State | Meaning |
45
+ | Request | Meaning |
45
46
  | --- | --- |
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
-
50
- | `overflow: "idle"` | No overflow recovery is pending. |
51
- | `overflow: "pending"` | An overflow failure may recover once at pre-settlement. |
52
- | `overflow: "pending-spent"` | Recovery was already spent in this failure chain. |
53
- | `overflow: "spent"` | The one recovery has been used until the chain settles. |
54
-
55
- ### Transition rules
56
-
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.
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.
62
-
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.
47
+ | `none` | No command or tool request. |
48
+ | `pending` | Current `windowId`, optional `tool: { lastWord? }`, and optional `command: { continueAfterReset, inputs? }`. Command inputs retain originals, not prompt-block wrappers. Duplicate commands retain the first policy/text; tool calls do not overwrite command policy. |
64
49
 
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.
50
+ `stopAfterReset` is separate from the request. It retains the safety boundary's intent after construction, while `request` becomes `none`. Settlement waits for queued work; if the window changed, it stops without a second wipe. If the window did not change, the boundary never committed, so settlement retries the retained intent with its stop policy and tool origin intact. A successful settle retry consumes the latch.
66
51
 
67
- ## Budget staging and notifications
52
+ Overflow phases are `idle`, `pending`, `spent`, and `pending-spent`. `turn_end` arms enabled recovery; `agent_before_settle` waits for queued work and selects recovery intent. Only successful, current construction reaches finalization and spends the attempt. A successful queued turn supersedes the failure. Command overflow spends the same bounded attempt before continuing. Abort, final settlement, session start/tree/shutdown and `/notesoup off` clear transient state.
68
53
 
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.
54
+ The adapter collects actual user `message_end` content until settlement or a successful reset boundary. Low-level `agent_start` events do not clear it: Pi can start additional loops while draining follow-ups/recovering. Custom boot/warning/continuation messages are never mistaken for human input. Successful boundary construction clears this run collection, so an automatic continuation does not replay old input.
70
55
 
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.
56
+ Command state remains live during asynchronous notes acquisition. Boundary intent captures the trigger, explicit `continueAfterReset` policy, tool fact and origin, but contains no final state or continuation decision. After construction passes the currentness guard, the pure finalizer selects live command-owned originals, or the current run's inputs only for passive recovery, and resolves `resumeModel` and the next control state together. `resumeModel` is true when the policy requests continuation or carried input needs an answer; the adapter maps it to Pi's `continue` field. Late originals therefore join the same boundary and prevent a stop latch from being installed; delivery contents never replace explicit command policy. Hidden steers carry window/command identity; provider projection excludes them once that command ends, including steers Pi delivers only after the reset. Originals remain available exactly once as carried input. Construction captures session/window generations and rechecks identity, enabled state and abort status before returning drafts. Clearing the run invalidates any unfinished construction before resetting its input collection. Stale work preserves incoming/budget entries but discards reset drafts; construction failures notify only while current and do not claim continuation. If close-out cannot commit, stashed originals are restored with public `sendMessage(..., { triggerTurn: false })`, including cancellation during construction; clearing command state must not erase input already reported as handled.
72
57
 
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.
58
+ After a manual safety reset, `context_with_system` checks the committed boundary before using public `ctx.abort()` to cancel an unavoidable empty tool follow-up with system-only context. Pending messages, ordinary user entries or carried inputs after the marker bypass cancellation. Later user prompts are not affected by the run-scoped stop latch.
74
59
 
75
- ## Projection, repair, and history
60
+ ## Warnings, projection and repair
76
61
 
77
- `context_with_system` selects the active boot by durable `details.windowId`. For a verified native checkpoint, Pi's canonical projection is used directly; for a legacy marker-only reset, the compatibility projection slices at the matching boot. The projection preserves system/tool state and later prompt patches. If the boot is absent, the runtime aborts safely instead of sending raw history. Usage estimation uses the same checkpoint-aware projection decision.
62
+ Budget reminders are staged once per window at reserve plus reminder margin, then reserve plus warning runway. Hard reserve remains independent. Budget and command warnings use different types. The final budget warning notifies at first provider injection, not durability; early guidance stays UI-silent. Budget drafts are instance-local and discarded on abort, failed turn, transition or window mismatch. Active-window usage and the exact public `SettingsManager` authority determine thresholds.
78
63
 
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.
64
+ Manual warnings begin with the `/empty` notice inside `<notesoup:budget_notice>`, followed by `WARNING_BODY`, the last-word hint and countdown. Optional command text sits after the closing tag in `<notesoup:next_window_prompt>`. They omit budget timing hints. Pi's boot protocol and budget warnings explain that reset erases the human's view and leave timing to the model unless directed otherwise; other hosts do not inherit that Pi-only claim.
80
65
 
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.
66
+ `context_with_system` selects the boot by durable window identity, using Pi's canonical checkpoint projection or legacy slicing. Missing boot aborts safely instead of exposing raw history. Usage estimates use the same projection decision. `/tree` summaries are suppressed when crossing reset branches because native branch summarization bypasses this projection.
82
67
 
83
- ## Validation and known limits
68
+ `resetBoundaryCommitted` validates checkpoint -> marker -> matching hidden boot -> hidden continuation; trailing last words, carried input or later conversation cannot undo that committed prefix. `inspectResetTail` checks the entire repairable suffix: optional last word and carried inputs must follow the continuation, with no duplicate/misordered artifacts or later conversation. A carried input before boot/continuation blocks repair rather than allowing metadata to be appended after human content. Startup/tree repair only fills missing boot/continuation when safe, rechecking lifecycle identity after notes acquisition. UI success notices use committed confirmation, not repairability.
84
69
 
85
- The test suite combines isolated reducer tests with scripted SDK tests executing Pi's real agent loop without model/network calls. The retained scripted AgentSession tests cover idle and streaming manual commands whose close-outs commit at settlement and stop without a fresh-window continuation, direct wipe without warning, budget close-out, same-window concurrent command deduplication, actual and synthetic abort/error cleanup, queued steering/follow-up delivery before the stop, hard-reserve and bounded-overflow recovery, successive resets, and real SessionManager file reopen after two retain-none checkpoints. It also checks raw-history preservation, canonical projection, empty-summary retention, system/tool state, warning/marker order, and fresh-window continuation.
70
+ ## Validation
86
71
 
87
- Focused regression tests distinguish committed-boundary confirmation from safe suffix repair even after later work. Resolved-AST dependency tests reject shared imports of native adapters and SDKs, including indirect type/re-export/dynamic paths. Retained behavioral cases are representative rather than exhaustive. Tree-summary suppression has no dedicated retained test, and external-provider behavior, every malformed persisted shape, and every filesystem failure mode are not established by this suite.
72
+ Scripted SDK tests run Pi's real agent loop without network calls: smaller-model overflow and prompt replay, command text, bare stop, intercepted text/images, hard-reserve handling, overflowing close-out and bounded retry. They also cover passive tool-loop steering/follow-ups and input-free automatic continuations. Focused tests check late input during asynchronous construction, stale queued steer exclusion, abort/error restoration, ordered carry artifacts, commit confirmation, safe repair, canonical projection and persisted history. External-provider behavior and every malformed persisted/filesystem case are not established by this suite.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.51.1",
3
+ "version": "0.51.3",
4
4
  "type": "module",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -62,7 +62,7 @@
62
62
  "scripts": {
63
63
  "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json && node scripts/build-extension.mjs && node -e \"require('node:fs').chmodSync('dist/plugins/pi/dream/cli.js', 0o755)\"",
64
64
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p plugins/claude/tsconfig.json",
65
- "test": "npm run build && node --test --test-concurrency=4 dist/test/*.test.js",
65
+ "test": "npm run build && node --test --test-concurrency=4 $(ls dist/test/*.test.js | grep -v dist/test/claude-validation.test.js) && node --test dist/test/claude-validation.test.js",
66
66
  "prepublishOnly": "npm run typecheck",
67
67
  "prepack": "npm run build"
68
68
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notesoup",
3
- "version": "0.51.0",
3
+ "version": "0.51.3",
4
4
  "description": "Durable notes and a host-scoped notes boot section for Claude Code.",
5
5
  "author": {
6
6
  "name": "AstroSheep"
@@ -0,0 +1,7 @@
1
+ # Notesoup last word
2
+
3
+ Displays notesoup last-word messages already present in Paseo’s timeline as expanded, selectable cards. Cards use the current theme and compact layout. Requires Paseo 0.11.2 on the client and daemon.
4
+
5
+ This client-only plugin transforms the existing custom-message row in place. It does not read session files or append messages. Other timeline items are unchanged.
6
+
7
+ Paseo 0.11.2 drops Pi boundary `entry_appended` events from its live timeline. This plugin cannot display messages that Paseo has not received; that adapter gap needs an upstream fix. Messages available through history can be rendered.
@@ -0,0 +1,12 @@
1
+ # Notesoup Paseo plugin
2
+
3
+ Client-only last-word renderer. See [OVERVIEW.md](OVERVIEW.md) for behavior and the upstream live-event limitation.
4
+
5
+ ```sh
6
+ cd plugins/paseo
7
+ npm install --ignore-scripts --package-lock=false
8
+ npm run typecheck
9
+ npm test
10
+ ```
11
+
12
+ Install this directory with `paseo plugin install /absolute/path/to/plugins/paseo`. Source changes require `paseo plugin reload notesoup-last-word`; no daemon restart is needed.
@@ -0,0 +1,14 @@
1
+ import type { PluginClientContext } from "@getpaseo/plugin/client";
2
+ import { CARD_KIND, LAST_WORD_TYPE } from "../shared/last-word.ts";
3
+
4
+ type Transformer = Extract<Parameters<PluginClientContext["addTimelineTransformer"]>[0], { query: { itemType: "tool_call" } }>;
5
+ type Source = Parameters<Transformer["transform"]>[0];
6
+
7
+ export const sourceRowTransformer = {
8
+ id: "last-word-source",
9
+ query: { itemType: "tool_call" },
10
+ transform: ({ item }: Pick<Source, "item">) => {
11
+ if (item.type !== "tool_call" || item.metadata?.customType !== LAST_WORD_TYPE || item.detail?.type !== "plain_text" || typeof item.detail.text !== "string") return undefined;
12
+ return { items: [{ type: "plugin" as const, kind: CARD_KIND, version: 1, data: { text: item.detail.text } }] };
13
+ },
14
+ } satisfies Transformer;
@@ -0,0 +1,21 @@
1
+ import type { PluginTimelineItemProps } from "@getpaseo/plugin/client";
2
+ import { Text, View } from "react-native";
3
+ import type { LastWord } from "../shared/last-word.ts";
4
+
5
+ export function StickyCard({ item, theme, layout }: PluginTimelineItemProps<LastWord>) {
6
+ const text = item.data.text.replace(/^\*You peel a sticky note off your forehead\.\*\n/, "");
7
+ return (
8
+ <View style={{
9
+ padding: layout.compact ? 12 : 16,
10
+ gap: 8,
11
+ minWidth: 0,
12
+ borderRadius: 12,
13
+ borderWidth: 1,
14
+ borderColor: theme.colors.border,
15
+ backgroundColor: theme.colors.surface1,
16
+ }}>
17
+ <Text style={{ color: theme.colors.foregroundMuted, fontWeight: "600" }}>Last word</Text>
18
+ <Text selectable style={{ color: theme.colors.foreground, flexShrink: 1 }}>{text}</Text>
19
+ </View>
20
+ );
21
+ }
@@ -0,0 +1,10 @@
1
+ import type { PluginClientContext } from "@getpaseo/plugin/client";
2
+ import { sourceRowTransformer } from "./client/source-row.ts";
3
+ import { StickyCard } from "./client/sticky-card.tsx";
4
+ import { CARD_KIND, lastWordSchema } from "./shared/last-word.ts";
5
+
6
+ export default function contribute(client: PluginClientContext) {
7
+ const removeRenderer = client.addTimelineRenderer({ kind: CARD_KIND, version: 1, schema: lastWordSchema, Component: StickyCard });
8
+ const removeTransformer = client.addTimelineTransformer(sourceRowTransformer);
9
+ return () => { removeTransformer(); removeRenderer(); };
10
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "@astrosheep/notesoup-paseo",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "typecheck": "tsc --noEmit",
8
+ "test": "node --experimental-strip-types --test test/*.test.ts"
9
+ },
10
+ "devDependencies": {
11
+ "@getpaseo/plugin": "0.11.2",
12
+ "@types/node": "^22.19.19",
13
+ "@types/react": "~19.2.0",
14
+ "react": "19.1.0",
15
+ "react-native": "0.81.5",
16
+ "typescript": "^5.9.3",
17
+ "zod": "^4.4.3"
18
+ }
19
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": "notesoup-last-word",
3
+ "requirements": { "paseo": ">=0.11.2 <0.12.0" }
4
+ }
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+
3
+ export const LAST_WORD_TYPE = "notesoup/reset-last-word";
4
+ export const CARD_KIND = "last-word";
5
+ export const lastWordSchema = z.object({ text: z.string() });
6
+ export type LastWord = z.infer<typeof lastWordSchema>;
@@ -0,0 +1,19 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { sourceRowTransformer } from "../client/source-row.ts";
4
+ import { LAST_WORD_TYPE, lastWordSchema } from "../shared/last-word.ts";
5
+
6
+ test("renders the Pi adapter's replayed last word in place and leaves other rows intact", () => {
7
+ const item = {
8
+ type: "tool_call" as const, callId: "pi-custom-1", name: LAST_WORD_TYPE,
9
+ status: "completed" as const, error: null,
10
+ detail: { type: "plain_text" as const, text: "*You peel a sticky note off your forehead.*\nKeep the handoff." },
11
+ metadata: { synthetic: true, customType: LAST_WORD_TYPE },
12
+ };
13
+ const result = sourceRowTransformer.transform({ item });
14
+ assert.equal(result?.items.length, 1);
15
+ assert.equal(lastWordSchema.parse(result!.items[0]!.data).text, item.detail.text);
16
+ assert.deepEqual(sourceRowTransformer.transform({ item }), result, "replay deterministically replaces one source row");
17
+ assert.equal(sourceRowTransformer.transform({ item: { ...item, metadata: { synthetic: true, customType: "other" } } }), undefined);
18
+ assert.equal(sourceRowTransformer.transform({ item: { ...item, detail: { type: "plain_text" } } }), undefined);
19
+ });
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "lib": ["ES2023"],
7
+ "types": ["react", "node"],
8
+ "jsx": "react-jsx",
9
+ "strict": true,
10
+ "allowImportingTsExtensions": true,
11
+ "skipLibCheck": true,
12
+ "noEmit": true,
13
+ "esModuleInterop": true
14
+ },
15
+ "include": ["**/*.ts", "**/*.tsx"]
16
+ }
@@ -5,3 +5,5 @@ export const MANUAL_WIPE_TYPE = "notesoup/manual-wipe";
5
5
  export const RESET_MARKER_TYPE = "notesoup/reset-marker";
6
6
  export const CONTINUATION_TYPE = "notesoup/continuation";
7
7
  export const RESET_LAST_WORD_TYPE = "notesoup/reset-last-word";
8
+ export const CARRIED_INPUT_TYPE = "notesoup/carried-input";
9
+ export const NEXT_WINDOW_PROMPT_TYPE = "notesoup/next-window-prompt";
@@ -1,12 +1,23 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import type { ExtensionAPI, ExtensionContext, SessionBoundaryDraft, SessionEntry } from "@earendil-works/pi-coding-agent";
3
- import { BOOT_TYPE, CONTINUATION_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE } from "../entries.js";
3
+ import { BOOT_TYPE, CARRIED_INPUT_TYPE, CONTINUATION_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE } from "../entries.js";
4
4
  import { selectContinuation, type ResetOrigin } from "../../../src/budget/text.js";
5
5
  import { isForeignResetTailEntry, isWindowBootEntry, isWindowMarker, markerResetOrigin, type WindowMarker } from "../window.js";
6
6
  import { buildBootMessage, sendBoot, type IncompleteNotesNotifier } from "../boot.js";
7
7
 
8
8
  export type ResetTailState = { readonly boot: boolean; readonly continuation: boolean };
9
9
 
10
+ /** Original user content, including images; custom boundary messages become LLM user messages. */
11
+ export type CarriedInput = Extract<SessionBoundaryDraft, { type: "custom_message" }>["content"];
12
+
13
+ export function carriedInputDrafts(inputs: readonly CarriedInput[]): Extract<SessionBoundaryDraft, { type: "custom_message" }>[] {
14
+ return inputs.map((content) => ({ type: "custom_message", customType: CARRIED_INPUT_TYPE, content, display: true }));
15
+ }
16
+
17
+ export function isCarriedInputEntry(entry: SessionEntry): boolean {
18
+ return entry.type === "custom_message" && entry.customType === CARRIED_INPUT_TYPE && entry.display === true;
19
+ }
20
+
10
21
  /** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
11
22
  export const MAX_LAST_WORD_CHARS = 250;
12
23
 
@@ -33,8 +44,8 @@ function sendContinuation(pi: ExtensionAPI, content: string): void {
33
44
 
34
45
  /**
35
46
  * The closed, ordered reset shape: retain-none native checkpoint, marker, matching boot,
36
- * continuation, then an optional parting line. The prompt is not persisted here — it reached the
37
- * closing window inside the warning. The boot snapshot is acquired asynchronously after capturing
47
+ * continuation, then an optional parting line. The lifecycle appends carried inputs in the same
48
+ * boundary after these artifacts. The boot snapshot is acquired asynchronously after capturing
38
49
  * this identity. The continuation is drawn from the pool its origin names, here, once: the caller
39
50
  * persists the returned text and no read, render, or repair draws it again. The origin defaults to
40
51
  * `normal`, the same reading a legacy marker with no origin gets.
@@ -77,6 +88,8 @@ export function inspectResetTail(ctx: ExtensionContext, markerId: string, window
77
88
  if (markerIndex < 0) return undefined;
78
89
  let boot = false;
79
90
  let continuation = false;
91
+ let lastWord = false;
92
+ let carried = false;
80
93
  for (const entry of branch.slice(markerIndex + 1)) {
81
94
  if (isWindowBootEntry(entry, windowId)) {
82
95
  // The boot is unique and must precede the continuation; a repeat or a late
@@ -90,9 +103,17 @@ export function inspectResetTail(ctx: ExtensionContext, markerId: string, window
90
103
  continuation = true;
91
104
  continue;
92
105
  }
93
- if (isForeignResetTailEntry(entry)) {
94
- return undefined;
106
+ if (entry.type === "custom_message" && entry.customType === RESET_LAST_WORD_TYPE) {
107
+ if (!continuation || lastWord || carried || entry.display !== true) return undefined;
108
+ lastWord = true;
109
+ continue;
110
+ }
111
+ if (isCarriedInputEntry(entry)) {
112
+ if (!continuation) return undefined;
113
+ carried = true;
114
+ continue;
95
115
  }
116
+ if (isForeignResetTailEntry(entry)) return undefined;
96
117
  }
97
118
  return { boot, continuation };
98
119
  }