@juicesharp/rpiv-warp 1.20.0 → 2.1.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/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to `@juicesharp/rpiv-warp` are documented here.
5
5
  Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
  Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.1.0] - 2026-07-23
9
+
10
+ ### Changed
11
+ - README rewritten to follow the documentation standard shared across all packages.
12
+ - npm tarball now includes the versioned `docs/` reference and no longer ships cover or screenshot art.
13
+
14
+ ## [2.0.0] - 2026-07-21
15
+
16
+ ### Added
17
+ - Show a Blocked badge when a workflow run parks on a question, with each concurrent run badged independently until its question is answered.
18
+ - Read configuration from `XDG_CONFIG_HOME` when set, falling back to the legacy `~/.config` location only when no config file exists at the new path.
19
+
20
+ ### Changed
21
+ - Detached workflow child sessions no longer load Warp; it observes only from the launching session.
22
+
23
+ ### Fixed
24
+ - Render skill invocations in toast summaries as `/skill:<name> <args>` without leaking internal argument labeling.
25
+
8
26
  ## [1.20.0] - 2026-06-15
9
27
 
10
28
  ## [1.19.1] - 2026-06-10
package/README.md CHANGED
@@ -1,87 +1,123 @@
1
- # rpiv-warp
1
+ # @juicesharp/rpiv-warp
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@juicesharp/rpiv-warp.svg)](https://www.npmjs.com/package/@juicesharp/rpiv-warp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
2
5
 
3
6
  <div align="center">
4
7
  <a href="https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-warp">
5
- <picture>
6
- <img src="https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-warp/docs/cover.png" alt="rpiv-warp cover" width="50%">
7
- </picture>
8
+ <img src="https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-warp/docs/cover.png" alt="rpiv-warp cover: a Pi lifecycle event traced from the agent_end hook, through the OSC 777 escape sequence, into a delivered macOS toast reading 'Pi needs attention — Waiting for your answer'" width="60%">
8
9
  </a>
9
10
  </div>
10
11
 
11
- Native [Warp terminal](https://www.warp.dev/) toasts for [Pi Agent](https://github.com/badlogic/pi-mono) lifecycle events. When Pi finishes a long task, asks for your input, or completes a turn, `rpiv-warp` emits Warp's `OSC 777` escape sequence and Warp surfaces a native OS notification. Outside Warp it does nothing - install it everywhere, it only fires where it's useful.
12
-
13
- ## Features
14
-
15
- - **Native OS toasts on Pi lifecycle events** - agent start, agent end, blocking-tool calls, and turn boundaries surface as native Warp / macOS / Windows notifications.
16
- - **Live Warp tab badge** - the tab indicator transitions through **In progress → Success / Blocked** as Pi works.
17
- - **Tab-title spinner** - animates the tab title while the agent loop is active and restores Pi's `π - <repo>` title on stop.
18
- - **Configurable blocking-tool allowlist** - choose which tool calls flip the badge to **Blocked** via `~/.config/rpiv-warp/config.json`. Defaults to `ask_user_question`.
19
- - **Startup-only session notifications** - `/new`, `/resume`, `/fork`, and `/reload` stay quiet; only fresh startups notify.
20
- - **Silent outside Warp** - no-op when not running in Warp, on known-broken Warp builds, or when `/dev/tty` is unreachable.
21
- - **Windows support** - best-effort delivery via `process.stdout` / ConPTY, gated on `isTTY`.
22
- - **Zero-tool, zero-UI footprint** - no tools registered with the model, no commands, no widgets, no token cost.
12
+ The [Warp terminal](https://www.warp.dev/) tells you when
13
+ [Pi Agent](https://github.com/badlogic/pi-mono) needs you — a native OS toast, a
14
+ tab badge, and an animated tab title while a turn is running. `rpiv-warp` listens
15
+ to Pi's lifecycle events and writes Warp's `OSC 777` cli-agent sequence to the
16
+ terminal; Warp does the rest. Outside Warp it registers nothing and writes
17
+ nothing, so installing it costs you exactly zero everywhere else — it is opt-in,
18
+ and nothing else installs it for you.
23
19
 
24
20
  ## Install
25
21
 
26
- ```bash
22
+ ```sh
27
23
  pi install npm:@juicesharp/rpiv-warp
28
24
  ```
29
25
 
30
- `rpiv-warp` is **opt-in** - it is NOT auto-installed by `/rpiv-setup`. Install it explicitly only if you use Warp.
26
+ Restart your Pi session.
31
27
 
32
- ## What you get
28
+ ## Quick start
29
+
30
+ Start Pi inside Warp, send it a prompt that takes a while, then switch to another
31
+ tab or another app. You get:
33
32
 
34
- | Pi event | Warp wire event | Effect on the tab badge |
35
- |---|---|---|
36
- | `session_start` (startup only) | `session_start` | records plugin version |
37
- | `agent_start` | `prompt_submit` | → **In progress** |
38
- | `agent_end` | `stop` | → **Success** (checkmark) |
39
- | `tool_call` (configured blocking tool) | `question_asked` | → **Blocked** ("Waiting for your answer") |
40
- | `tool_execution_end` (configured blocking tool) | `tool_complete` | Blocked → **In progress** |
33
+ - the tab title animating a braille spinner for as long as the turn runs
34
+ - an OS notification when Pi finishes, naming the project and quoting the reply
35
+ - an OS notification the moment Pi asks a question and blocks on your answer
41
36
 
42
- `session_start` is filtered to `reason === "startup"` only - `/new`, `/resume`, `/fork`, `/reload` do NOT emit (you're already looking at the terminal in those cases).
37
+ Nothing to configure, no key to supply.
43
38
 
44
- ## Config
39
+ ## What you get
45
40
 
46
- Optional file at `~/.config/rpiv-warp/config.json`:
41
+ - **A toast the moment Pi needs you** — six lifecycle moments (session start,
42
+ prompt submitted, question asked, tool finished, turn stopped, gone idle) reach
43
+ Warp as structured notifications carrying the project name, your query and the
44
+ assistant's reply.
45
+ - **A tab that shows Pi is still working** — a braille spinner animates the tab
46
+ title for the whole turn, then Pi's original `π - <repo>` label comes back.
47
+ - **A Blocked badge that never sticks** — an ESC-aborted question is drained at
48
+ turn end instead of leaving the badge lit.
49
+ - **No false idle mid-task** — the running prompt is re-announced every 15
50
+ seconds while the turn is live.
51
+ - **Per-run badges for parked workflow questions** — each `/wf` run gets its own
52
+ badge keyed on the run id, so concurrent runs light up and clear independently.
53
+ - **Nothing to pay for where it can't help** — outside Warp or on a known-broken
54
+ Warp build it registers zero handlers; when `/dev/tty` is unreachable every
55
+ terminal write is silently swallowed, so a failed notification can never reach
56
+ the agent loop.
57
+ - **No tokens, no clutter** — no tools registered with the model, no slash
58
+ commands, no widgets. Only lifecycle listeners and escape bytes the terminal
59
+ eats before they reach stdout.
60
+
61
+ ## Configuration
62
+
63
+ Optional. Create `~/.config/rpiv-warp/config.json`:
47
64
 
48
65
  ```json
49
- {
50
- "blockingTools": ["ask_user_question", "my_custom_blocking_tool"]
51
- }
66
+ { "blockingTools": ["ask_user_question", "my_custom_tool"], "heartbeatMs": 5000 }
52
67
  ```
53
68
 
54
- | Key | Default | Meaning |
55
- |---|---|---|
56
- | `blockingTools` | `["ask_user_question"]` | Tool names that put the Warp tab badge into the **Blocked** state when called and clear it when the tool finishes. Use for tools that genuinely block the agent loop on user input. |
69
+ | Key | What it does | Default |
70
+ | --- | --- | --- |
71
+ | `blockingTools` | Tool names that raise the Blocked badge when called and clear it when they finish. Set to `[]` to turn the badge off entirely. | `["ask_user_question"]` |
72
+ | `heartbeatMs` | How often the running prompt is re-announced so Warp doesn't mark the tab idle. Set to `0` to disable. | `15000` |
57
73
 
58
- Missing or malformed file falls back to defaults - no config required.
74
+ Both keys are optional, and a missing or malformed file falls back to the
75
+ defaults. If `XDG_CONFIG_HOME` is set to an absolute path the file is read from
76
+ `$XDG_CONFIG_HOME/rpiv-warp/config.json` instead, falling back to the
77
+ `~/.config` location when that file does not exist. Config is read once when the
78
+ extension registers, so restart Pi after editing it.
59
79
 
60
- ## Detection
80
+ `rpiv-warp` reads this file and never writes one.
61
81
 
62
- `rpiv-warp` reads three environment variables Warp sets automatically:
82
+ ## Reference
63
83
 
64
- - `TERM_PROGRAM === "WarpTerminal"` - required. Outside Warp the extension is a no-op.
65
- - `WARP_CLI_AGENT_PROTOCOL_VERSION` - required for structured emission. If unset, `rpiv-warp` does nothing rather than falling back to a less-rich legacy format.
66
- - `WARP_CLIENT_VERSION` - used for broken-version gating. A short list of known-broken Warp builds (per release channel) suppresses emission until Warp ships a fix.
84
+ - [Event reference](https://github.com/juicesharp/rpiv-mono/blob/main/packages/rpiv-warp/docs/events.md)
85
+ — every lifecycle handler and what it emits, the timer-driven events, the exact
86
+ escape sequences, the full payload field list, and the workflow-question API.
87
+ - [Detection and edge cases](https://github.com/juicesharp/rpiv-mono/blob/main/packages/rpiv-warp/docs/detection.md)
88
+ — the environment variables Warp sets, protocol negotiation, broken-build
89
+ gating, Windows behavior, and what happens in every environment where nothing
90
+ can be emitted.
67
91
 
68
- ## Edge cases
92
+ ## Requirements
69
93
 
70
- | Case | Behavior |
71
- |---|---|
72
- | Not in Warp (`TERM_PROGRAM !== "WarpTerminal"`) | Silent no-op - extension loads, every handler short-circuits |
73
- | Pi in print mode (`pi -p "..."`) | **Toasts still fire** - print mode emits all four events at the agent layer |
74
- | `/dev/tty` unreachable (cron, no-tty SSH) | Silent no-op - `try/catch` around `openSync` |
75
- | Windows | Best-effort - writes OSC 777 to `process.stdout` so ConPTY forwards it to Warp ([Warp eng blog: "ConPTY will send even unrecognized OSCs to the shell"](https://www.warp.dev/blog/building-warp-on-windows)). Skipped when stdout is not a TTY (piped/redirected output). Untested in the wild - no Warp plugin currently ships a Windows transport |
76
- | Known-broken Warp build | Silent no-op - broken-version table gates emission per channel |
94
+ - **Warp.** Warp sets `TERM_PROGRAM`, `WARP_CLI_AGENT_PROTOCOL_VERSION` and
95
+ `WARP_CLIENT_VERSION` itself; you never set them. Any other terminal is a
96
+ silent no-op.
97
+ - **A current Warp build.** Builds at or below `v0.2026.3.25.8.24.stable_5` on the
98
+ stable and preview channels are gated off — they advertise the protocol but do
99
+ not render the notifications.
100
+ - **macOS or Linux** for the `/dev/tty` transport. Windows delivery via ConPTY is
101
+ best-effort and untested in the wild.
77
102
 
78
- ## Why standalone (not a sibling)
103
+ No API key, no model selection, no native modules — nothing to set up beyond Warp
104
+ itself.
79
105
 
80
- `rpiv-warp` is intentionally NOT registered in `rpiv-pi`'s sibling list. Not every Pi user uses Warp - auto-installing it everywhere would impose Warp-specific code on every install. If you don't use Warp, don't install it. If you do, install it explicitly. The package still joins the rpiv-mono lockstep version + shared release pipeline.
106
+ ## Troubleshooting
81
107
 
82
- ## License
108
+ - **No notifications at all, and the tab title never animates.** Your Warp build
109
+ is at or below the gated threshold above, or you are not in Warp. Upgrade Warp
110
+ and restart your Pi session.
111
+ - **The tab title animates but no OS toast arrives.** Warp does not have OS
112
+ notification permission, or the system is in Do Not Disturb. Enable
113
+ notifications for Warp in your OS settings.
83
114
 
84
- [![npm version](https://img.shields.io/npm/v/@juicesharp/rpiv-warp.svg)](https://www.npmjs.com/package/@juicesharp/rpiv-warp)
85
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
115
+ ## Related
116
+
117
+ - [`@juicesharp/rpiv-pi`](https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-pi)
118
+ — drives the per-run workflow-question badges when both are installed, and
119
+ keeps `rpiv-warp` out of detached workflow child sessions.
120
+
121
+ ## License
86
122
 
87
- MIT - see [LICENSE](./LICENSE).
123
+ MIT — see [LICENSE](./LICENSE).
package/config.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { configPath, loadJsonConfig } from "@juicesharp/rpiv-config";
1
+ import { configPath, loadJsonConfigWithLegacyFallback } from "@juicesharp/rpiv-config";
2
2
 
3
3
  export const CONFIG_PATH = configPath("rpiv-warp");
4
4
 
@@ -11,7 +11,7 @@ export const DEFAULT_BLOCKING_TOOLS: readonly string[] = ["ask_user_question"];
11
11
  export const DEFAULT_HEARTBEAT_MS = 15000;
12
12
 
13
13
  export function loadConfig(): RpivWarpConfig {
14
- return loadJsonConfig<RpivWarpConfig>(CONFIG_PATH);
14
+ return loadJsonConfigWithLegacyFallback<RpivWarpConfig>("rpiv-warp");
15
15
  }
16
16
 
17
17
  export function getHeartbeatMs(): number {
@@ -0,0 +1,94 @@
1
+ # Detection and edge cases
2
+
3
+ How `rpiv-warp` decides whether to emit anything at all, and exactly what it does
4
+ in every environment where it cannot.
5
+
6
+ ## The gate
7
+
8
+ `rpiv-warp` checks the environment once, at registration. If the check fails it
9
+ returns immediately — **zero** handlers are subscribed, no timers are armed, and
10
+ nothing is ever written. There is no partial mode.
11
+
12
+ Both of these must hold:
13
+
14
+ 1. `TERM_PROGRAM === "WarpTerminal"`
15
+ 2. `WARP_CLI_AGENT_PROTOCOL_VERSION` is set to a non-empty string, **and**
16
+ `WARP_CLIENT_VERSION` is not a known-broken build
17
+
18
+ Warp sets all three variables itself. You never set them by hand.
19
+
20
+ ## Environment variables
21
+
22
+ | Variable | Read for | Behavior |
23
+ | --- | --- | --- |
24
+ | `TERM_PROGRAM` | terminal identification | Must equal exactly `"WarpTerminal"`. Anything else — iTerm2, Ghostty, VS Code, a bare SSH session — is a total no-op. |
25
+ | `WARP_CLI_AGENT_PROTOCOL_VERSION` | structured protocol support | Any non-empty value enables emission. Unset means the extension does nothing rather than falling back to a less-rich legacy format. |
26
+ | `WARP_CLIENT_VERSION` | broken-build gating | Parsed and compared against a per-channel threshold. An unparseable value is treated as fine and emission proceeds. |
27
+ | `XDG_CONFIG_HOME` | config file location | Relocates the config directory. See the [Configuration](../README.md#configuration) section. |
28
+
29
+ All three Warp variables are read fresh on every call — nothing is cached at
30
+ module level.
31
+
32
+ ## Protocol negotiation
33
+
34
+ The version written into every payload's `v` field is
35
+ `min(WARP_CLI_AGENT_PROTOCOL_VERSION, 1)`, where `1` is the highest protocol this
36
+ extension speaks. Clamping client-side means an older Warp that only understands
37
+ `v: 1` keeps seeing `v: 1` even after the plugin's ceiling is raised. A missing,
38
+ empty or unparseable environment value falls back to `1`.
39
+
40
+ ## Broken-build gating
41
+
42
+ Some Warp builds advertise structured-protocol support but render the
43
+ notifications behind a feature flag. Emission is suppressed for builds at or
44
+ below the last known-broken build on their channel:
45
+
46
+ | Channel | Last broken build |
47
+ | --- | --- |
48
+ | `stable` | `v0.2026.3.25.8.24.stable_5` |
49
+ | `preview` | `v0.2026.3.25.8.24.preview_5` |
50
+ | `dev` | never gated |
51
+
52
+ Version literals follow the grammar `v0.YYYY.M.D.H.M.(stable|preview|dev)_N`.
53
+ Comparison is element-wise and inclusive — a build equal to the threshold is
54
+ gated. Upgrading Warp clears the gate; there is nothing to configure.
55
+
56
+ ## Edge cases
57
+
58
+ | Situation | Behavior |
59
+ | --- | --- |
60
+ | Not running in Warp | Silent no-op. No handlers registered, nothing written, no measurable cost. Install it everywhere. |
61
+ | Known-broken Warp build | Silent no-op, per the table above. |
62
+ | `WARP_CLI_AGENT_PROTOCOL_VERSION` unset | Silent no-op. No legacy fallback format. |
63
+ | `/dev/tty` unopenable (cron, no-TTY SSH) | Every write is silently swallowed. The `open`/`write`/`close` cycle is wrapped in a try/catch that never rethrows, so a failed notification cannot reach the agent loop. |
64
+ | Windows | Best-effort. There is no `/dev/tty`, so the same OSC bytes go to `process.stdout` and ConPTY forwards them to Warp. Skipped entirely when `process.stdout.isTTY` is false, so piped or redirected output is never polluted. This path is untested in the wild. |
65
+ | Detached workflow child sessions | The extension is not loaded at all. See below. |
66
+ | `blockingTools` configured empty | The `tool_call` and `tool_execution_end` handlers short-circuit; no Blocked badge, everything else unaffected. |
67
+ | `heartbeatMs` set to `0` | The heartbeat interval never starts. |
68
+ | Terminal without an xterm title stack | The CSI push/pop sequences are ignored silently; the spinner still animates. |
69
+
70
+ ## Detached workflow child sessions
71
+
72
+ `rpiv-warp` declares `"pi": { "ambientObserver": true }` in its `package.json`.
73
+ That flag marks it as a launcher-only extension: it registers lifecycle handlers
74
+ and side effects — timers, terminal writes, a spinner — but exposes no tool or
75
+ command that a workflow stage could invoke.
76
+
77
+ `rpiv-pi`'s workflow host reads the flag before it constructs a child session's
78
+ extensions and filters `rpiv-warp` out. A detached child has no terminal of its
79
+ own, so loading it there would be pure cost, and the 300 ms idle timer armed at
80
+ `agent_end` would fire against an already-disposed context.
81
+
82
+ Workflow questions still reach Warp — they go through the run-keyed transport
83
+ described in [events.md](./events.md#workflow-question-transport), driven from the
84
+ launcher session where the terminal actually is.
85
+
86
+ ## Terminal writes
87
+
88
+ Every emission opens `/dev/tty`, writes, and closes. There is no cached file
89
+ descriptor. On Unix the escape bytes are intercepted by the terminal emulator and
90
+ never enter stdout or stderr, so they cannot corrupt piped output or Pi's own
91
+ capture.
92
+
93
+ `rpiv-warp` writes no other files. It reads its config file and never creates,
94
+ modifies or chmods one.
package/docs/events.md ADDED
@@ -0,0 +1,129 @@
1
+ # Event reference
2
+
3
+ Every Pi lifecycle event `rpiv-warp` subscribes to, the Warp wire event it emits,
4
+ and the exact bytes and JSON that go out to the terminal.
5
+
6
+ ## Lifecycle handlers
7
+
8
+ `rpiv-warp` registers exactly seven `pi.on(...)` handlers. It registers no tools,
9
+ no slash commands, no widgets, and no keyboard shortcuts.
10
+
11
+ | Pi event | Emits | Side effects |
12
+ | --- | --- | --- |
13
+ | `session_start` | `session_start` — only when `reason === "startup"` | none |
14
+ | `before_agent_start` | nothing | captures the prompt for `prompt_submit` and the heartbeat |
15
+ | `agent_start` | `session_start` (defensive re-announce), then `prompt_submit` | starts the tab-title spinner, cancels the pending idle timer, starts the heartbeat |
16
+ | `agent_end` | one `tool_complete` per outstanding blocking call, then `stop` | stops the spinner, stops the heartbeat, arms the 300 ms idle timer |
17
+ | `tool_call` | `question_asked` — only for a tool in `blockingTools` | records the call's input, stops the spinner, pauses the heartbeat |
18
+ | `tool_execution_end` | `tool_complete` — only for a tool in `blockingTools` | restarts the spinner, resumes the heartbeat |
19
+ | `session_shutdown` | nothing | cancels the idle timer, stops the heartbeat, stops the spinner, clears pending state |
20
+
21
+ `/new`, `/resume`, `/fork` and `/reload` all fire `session_start` with a reason
22
+ other than `"startup"`, so none of them notify — you are already looking at the
23
+ terminal in those cases.
24
+
25
+ ### Why `agent_end` drains blocking calls
26
+
27
+ Pressing ESC during a blocking tool aborts it, and an aborted tool never fires
28
+ `tool_execution_end`. Without a drain, Warp's Blocked badge would stay lit for the
29
+ rest of the session. `agent_end` therefore emits a `tool_complete` for every call
30
+ still outstanding — carrying the tool name and the input captured at `tool_call`
31
+ time — before it emits `stop`.
32
+
33
+ ## Timer-driven emissions
34
+
35
+ | Emission | Trigger |
36
+ | --- | --- |
37
+ | `idle_prompt` | 300 ms after `agent_end`, unless `agent_start` or `session_shutdown` cancels first. Carries the last assistant message as `summary`. |
38
+ | `prompt_submit` | Re-emitted every `heartbeatMs` (default 15000) while a turn is active, so Warp does not decide the session went idle mid-task. Paused for blocking tools, stopped at turn end. |
39
+
40
+ Both timers, and the spinner's interval, are `unref()`d — a stray timer can never
41
+ hold the process open.
42
+
43
+ ## Wire format
44
+
45
+ Every notification is one OSC 777 write to the controlling terminal, with the
46
+ literal title `warp://cli-agent` and a JSON body:
47
+
48
+ ```
49
+ ESC ] 777 ; notify ; warp://cli-agent ; <json> BEL
50
+ ```
51
+
52
+ The tab-title spinner uses three more sequences:
53
+
54
+ | Sequence | Bytes | Used for |
55
+ | --- | --- | --- |
56
+ | OSC 0 | `ESC ] 0 ; <title> BEL` | writing the animated tab title |
57
+ | CSI 22;0t | `ESC [ 22;0t` | pushing the current title onto the xterm title stack on spinner start |
58
+ | CSI 23;0t | `ESC [ 23;0t` | popping it on spinner stop, restoring Pi's `π - <repo>` title verbatim |
59
+
60
+ The spinner is four braille frames rewritten every 160 ms, so a full cycle takes
61
+ ~640 ms. Terminals that do not implement the title stack ignore both CSI
62
+ sequences silently.
63
+
64
+ ## Payload fields
65
+
66
+ Every payload carries the same envelope:
67
+
68
+ | Field | Value |
69
+ | --- | --- |
70
+ | `v` | negotiated protocol version (see [detection.md](./detection.md)) |
71
+ | `agent` | `"pi"` |
72
+ | `event` | one of `session_start`, `prompt_submit`, `stop`, `question_asked`, `tool_complete`, `idle_prompt` |
73
+ | `session_id` | Pi's session id — or the workflow run id, for workflow-question badges |
74
+ | `cwd` | absolute working directory |
75
+ | `project` | `basename(cwd)` |
76
+
77
+ Per-event additions:
78
+
79
+ | Event | Extra fields |
80
+ | --- | --- |
81
+ | `prompt_submit` | `query` — the prompt you submitted |
82
+ | `stop` | `query` — last user message; `response` — last assistant message |
83
+ | `idle_prompt` | `summary` — last assistant message |
84
+ | `tool_complete` | `tool_name`, plus `tool_input` when the input was captured at `tool_call` |
85
+ | `session_start`, `question_asked` | none |
86
+
87
+ Example `stop` body:
88
+
89
+ ```json
90
+ {
91
+ "v": 1,
92
+ "agent": "pi",
93
+ "event": "stop",
94
+ "session_id": "0199c0d5-...",
95
+ "cwd": "/Users/you/src/rpiv-mono",
96
+ "project": "rpiv-mono",
97
+ "query": "/skill:commit the config change",
98
+ "response": "Committed as 4f2a1c9."
99
+ }
100
+ ```
101
+
102
+ ### Text normalization
103
+
104
+ - Fields read back from the session branch — `stop.query`, `stop.response` and
105
+ `idle_prompt.summary` — are truncated to 200 characters with a trailing `...`.
106
+ The `query` on `prompt_submit` is the prompt as submitted, untruncated.
107
+ - A `<skill name="…" location="…">…</skill>` wrapper is collapsed back to
108
+ `/skill:<name> <args>`, and the internal `Skill input: ` label is stripped, so a
109
+ toast shows what you typed rather than the expanded LLM input.
110
+
111
+ ## Workflow-question transport
112
+
113
+ `rpiv-warp` also exports a direct-call API used by
114
+ [`@juicesharp/rpiv-pi`](https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-pi)
115
+ to badge parked workflow questions independently of the launcher session:
116
+
117
+ ```ts
118
+ import { createWorkflowQuestionTransport } from "@juicesharp/rpiv-warp";
119
+
120
+ const transport = createWorkflowQuestionTransport(process.cwd());
121
+ transport.asked("run-1"); // session_start + question_asked, session_id = "run-1"
122
+ transport.resolved("run-1"); // tool_complete, tool_name = "ask_user_question"
123
+ ```
124
+
125
+ Keying `session_id` on the workflow run id is what lets concurrent `/wf` runs
126
+ badge and clear independently. Both methods check the Warp environment on every
127
+ call and no-op outside it, so a caller can invoke them unconditionally.
128
+ `resolved` carries no `tool_input` — the bridge aggregates questions and has no
129
+ per-question input to report.
package/index.ts CHANGED
@@ -8,6 +8,9 @@ import {
8
8
  buildSessionStartPayload,
9
9
  buildStopPayload,
10
10
  buildToolCompletePayload,
11
+ buildWorkflowQuestionAskedPayload,
12
+ buildWorkflowQuestionCompletePayload,
13
+ buildWorkflowSessionStartPayload,
11
14
  lastAssistantText,
12
15
  serializePayload,
13
16
  type WarpPayload,
@@ -55,6 +58,37 @@ function emit(payload: WarpPayload): void {
55
58
  writeOSC777(TITLE, serializePayload(payload));
56
59
  }
57
60
 
61
+ // ---------------------------------------------------------------------------
62
+ // Workflow-question transport — a run-keyed OSC emitter for the rpiv-core
63
+ // workflow-question-warp-bridge. session_id is the workflow runId (Warp's
64
+ // logical session for a parked-question badge), NOT the launcher session.
65
+ // Each method is gated per-call on supportsStructured so the bridge can call
66
+ // unconditionally outside Warp; the factory is cheap and holds no state.
67
+ // ---------------------------------------------------------------------------
68
+
69
+ export interface WorkflowQuestionTransport {
70
+ /** A workflow run parked its FIRST outstanding question (0→≥1): emit
71
+ * `session_start` (defensive) then `question_asked`. No-op outside Warp. */
72
+ asked(runId: string): void;
73
+ /** A workflow run's LAST outstanding question cleared (≥1→0): emit
74
+ * `tool_complete`. No-op outside Warp. */
75
+ resolved(runId: string): void;
76
+ }
77
+
78
+ export function createWorkflowQuestionTransport(cwd: string): WorkflowQuestionTransport {
79
+ return {
80
+ asked(runId: string): void {
81
+ if (!detectWarpEnvironment().supportsStructured) return;
82
+ emit(buildWorkflowSessionStartPayload(runId, cwd));
83
+ emit(buildWorkflowQuestionAskedPayload(runId, cwd));
84
+ },
85
+ resolved(runId: string): void {
86
+ if (!detectWarpEnvironment().supportsStructured) return;
87
+ emit(buildWorkflowQuestionCompletePayload(runId, cwd));
88
+ },
89
+ };
90
+ }
91
+
58
92
  function cancelIdleTimer(): void {
59
93
  if (idleTimer !== undefined) {
60
94
  clearTimeout(idleTimer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-warp",
3
- "version": "1.20.0",
3
+ "version": "2.1.0",
4
4
  "private": false,
5
5
  "description": "Pi extension. Native Warp terminal notifications, dispatched via OSC 777 on Pi lifecycle events.",
6
6
  "keywords": [
@@ -27,6 +27,9 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
+ "exports": {
31
+ ".": "./index.ts"
32
+ },
30
33
  "scripts": {
31
34
  "test": "vitest run"
32
35
  },
@@ -37,6 +40,10 @@
37
40
  "title-spinner.ts",
38
41
  "payload.ts",
39
42
  "config.ts",
43
+ "docs/",
44
+ "!docs/*.png",
45
+ "!docs/*.jpg",
46
+ "!docs/*.svg",
40
47
  "README.md",
41
48
  "CHANGELOG.md",
42
49
  "LICENSE"
@@ -44,12 +51,13 @@
44
51
  "pi": {
45
52
  "extensions": [
46
53
  "./index.ts"
47
- ]
54
+ ],
55
+ "ambientObserver": true
48
56
  },
49
57
  "peerDependencies": {
50
58
  "@earendil-works/pi-coding-agent": "*"
51
59
  },
52
60
  "dependencies": {
53
- "@juicesharp/rpiv-config": "^1.20.0"
61
+ "@juicesharp/rpiv-config": "^2.1.0"
54
62
  }
55
63
  }
package/payload.ts CHANGED
@@ -91,7 +91,17 @@ export function extractMessageText(content: UserMessage["content"] | AssistantMe
91
91
  export function summarizeSkillBlock(text: string): string {
92
92
  const parsed = parseSkillBlock(text);
93
93
  if (!parsed) return text;
94
- return parsed.userMessage ? `/skill:${parsed.name} ${parsed.userMessage}` : `/skill:${parsed.name}`;
94
+ const args = unwrapSkillInput(parsed.userMessage);
95
+ return args ? `/skill:${parsed.name} ${args}` : `/skill:${parsed.name}`;
96
+ }
97
+
98
+ /** rpiv-args' token emit path carries the raw argument string in a
99
+ * `Skill input:`-labeled trailer after `</skill>` (args.ts
100
+ * appendSkillInput) — Pi's parseSkillBlock surfaces it verbatim as
101
+ * userMessage. Strip the label so the toast shows what the human typed. */
102
+ function unwrapSkillInput(userMessage: string | undefined): string | undefined {
103
+ const m = userMessage?.match(/^Skill input: ([\s\S]*)$/);
104
+ return m ? m[1] : userMessage;
95
105
  }
96
106
 
97
107
  // ---------------------------------------------------------------------------
@@ -126,18 +136,28 @@ export function lastAssistantText(branch: SessionEntry[]): string {
126
136
  // Envelope — common fields for every Warp event
127
137
  // ---------------------------------------------------------------------------
128
138
 
129
- export function baseEnvelope(event: WarpEvent, ctx: ExtensionContext): WarpPayloadBase {
130
- const cwd = ctx.cwd;
139
+ /**
140
+ * Identity-independent envelope core: builds the shared fields from an
141
+ * explicit `session_id` + `cwd` rather than an `ExtensionContext`. The root
142
+ * flow delegates here with the live session; the workflow-question bridge
143
+ * delegates here with `session_id = runId` (a workflow run is Warp's
144
+ * logical session for its parked-question badge).
145
+ */
146
+ export function runEnvelope(event: WarpEvent, session_id: string, cwd: string): WarpPayloadBase {
131
147
  return {
132
148
  v: negotiateProtocolVersion(),
133
149
  agent: AGENT_ID,
134
150
  event,
135
- session_id: ctx.sessionManager.getSessionId(),
151
+ session_id,
136
152
  cwd,
137
153
  project: projectName(cwd),
138
154
  };
139
155
  }
140
156
 
157
+ export function baseEnvelope(event: WarpEvent, ctx: ExtensionContext): WarpPayloadBase {
158
+ return runEnvelope(event, ctx.sessionManager.getSessionId(), ctx.cwd);
159
+ }
160
+
141
161
  // ---------------------------------------------------------------------------
142
162
  // Builders — one per Warp event; composition is linear and named
143
163
  // ---------------------------------------------------------------------------
@@ -184,6 +204,35 @@ export function buildToolCompletePayload(
184
204
  };
185
205
  }
186
206
 
207
+ // ---------------------------------------------------------------------------
208
+ // Workflow-question builders — session_id is the workflow runId, NOT the
209
+ // launcher session. Composed from runEnvelope so they share the root flow's
210
+ // field shape. Used by createWorkflowQuestionTransport in index.ts.
211
+ // ---------------------------------------------------------------------------
212
+
213
+ /** Defensive first emission for a run that just parked its first question —
214
+ * mirrors the root flow's agent_start defensive `session_start`. */
215
+ export function buildWorkflowSessionStartPayload(runId: string, cwd: string): WarpPayload {
216
+ return runEnvelope("session_start", runId, cwd);
217
+ }
218
+
219
+ /** A workflow run parked its first outstanding question — Warp shows the
220
+ * "question" / Blocked badge for this runId. */
221
+ export function buildWorkflowQuestionAskedPayload(runId: string, cwd: string): WarpPayload {
222
+ return runEnvelope("question_asked", runId, cwd);
223
+ }
224
+
225
+ /** A workflow run's last outstanding question was answered/cleared — Warp
226
+ * clears the badge. Carries `tool_name` so Warp attributes it to the
227
+ * blocking tool, but no `tool_input` (the bridge aggregates, it has no
228
+ * per-question input). */
229
+ export function buildWorkflowQuestionCompletePayload(runId: string, cwd: string): WarpPayload {
230
+ return {
231
+ ...runEnvelope("tool_complete", runId, cwd),
232
+ tool_name: "ask_user_question",
233
+ };
234
+ }
235
+
187
236
  // ---------------------------------------------------------------------------
188
237
  // Serializer — single source of truth so tests can assert on JSON shape
189
238
  // ---------------------------------------------------------------------------