@nxxxsooo/opencode-annotate 0.13.1 → 0.15.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 CHANGED
@@ -1,12 +1,20 @@
1
- # OpenCode Annotate — review AI replies, documents, and webpages
1
+ # OpenCode Annotate
2
+
3
+ **Review OpenCode AI replies, Markdown documents, and webpages — send annotated feedback to the originating session.**
2
4
 
3
5
  [![npm](https://img.shields.io/npm/v/@nxxxsooo/opencode-annotate)](https://www.npmjs.com/package/@nxxxsooo/opencode-annotate)
4
6
  [![CI](https://github.com/nxxxsooo/opencode-annotate/actions/workflows/ci.yml/badge.svg)](https://github.com/nxxxsooo/opencode-annotate/actions/workflows/ci.yml)
5
7
  [![MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
6
8
 
7
- **Annotate AI replies and Markdown documents in your terminal, or review webpages in your browser.** Select a passage or element, add feedback, and send it to the originating OpenCode conversation.
9
+ [Website](https://mjshao.fun/opencode-annotate/) · [Install](#install) · [Workflows](#workflows) · [Browser review](#browser-review-optional) · [References](#reference-previous-conversations) · [Configuration](#configuration)
10
+
11
+ This **unofficial OpenCode plugin** bundles the native [terminal reviewer](tui/README.md) — no separate reviewer install is required. The optional [browser companion](#browser-review-optional) adds Chrome delivery and Safari copy-only review. Published on npm as `@nxxxsooo/opencode-annotate`.
8
12
 
9
- This **unofficial OpenCode plugin** includes the native [terminal reviewer](tui/README.md): **no separate reviewer install is required**. The optional [browser companion](#browser-review-optional) adds Chrome delivery and Safari's copy-only review. Published on npm as `@nxxxsooo/opencode-annotate`.
13
+ | Surface | Reviews | Entry point |
14
+ |---|---|---|
15
+ | Terminal (bundled TUI) | AI replies, Markdown, plain text | `/annotate` |
16
+ | Chrome (optional) | Webpages, local HTML | `/annotate <url-or-html>` or extension |
17
+ | Safari (optional, copy-only) | Webpages | `/annotate <url-or-html>` or extension |
10
18
 
11
19
  ## Install
12
20
 
@@ -43,7 +51,9 @@ Manual configuration, preserving other entries:
43
51
 
44
52
  Empty and cancelled reviews submit nothing. Opening a review makes no model call.
45
53
 
46
- **`Ctrl+S`** saves the current comment and sends in one step. The header's **Send N back (q)** button does the same as `q`. **`Ctrl+C`** returns without sending, and OpenCode asks whether to send. `E` and `S` send as well, following any `[keys]` rebinding.
54
+ **`Ctrl+S`** saves the current comment and sends in one step. The header's **Send N back (q)** button does the same as `q`. **`Ctrl+C`** returns without sending, and OpenCode asks whether to send. `E` and `S` send as well, following any `[keys]` rebinding. Confirmed text and browser sends continue the captured session with `steer` / `resume: true`, including while a turn is running.
55
+
56
+ <a id="what-it-reviews"></a>
47
57
 
48
58
  ## Workflows
49
59
 
@@ -51,7 +61,7 @@ Empty and cancelled reviews submit nothing. Opening a review makes no model call
51
61
 
52
62
  `/annotate` opens the last completed reply. `/annotate-pick` chooses from recent replies and progress updates. `/annotate-selection` opens the message containing your last transcript selection. Reasoning, tool-call commentary, and in-progress messages are excluded.
53
63
 
54
- `/annotate-last` always reviews the latest completed reply; any supplied argument is ignored. For a selection that spans messages, `/annotate-selection` reviews just the selected text.
64
+ For a selection that spans messages, `/annotate-selection` reviews just the selected text.
55
65
 
56
66
  ### Review Markdown and text documents
57
67
 
@@ -67,31 +77,30 @@ The reviewer reads a fixed snapshot and does not edit the original file. Feedbac
67
77
 
68
78
  ### Browser webpage feedback
69
79
 
70
- Run `/annotate-web` to pair the current session with the Chrome extension, then open the extension panel on any webpage. Select text or pick an element, write notes, and send them back to the paired session.
80
+ Open the extension panel on any webpage and choose an automatically registered OpenCode session. Select text or pick an element, write notes across pages, and send the grouped round to that destination. `/annotate` can also open an explicit browser target:
71
81
 
72
82
  ```text
73
- /annotate-web # Pair this session
74
- /annotate-web page.html # Review a local HTML file
75
- /annotate-web https://example.com # Review a webpage
76
- /annotate-web off # Revoke this session's browser pairing
83
+ /annotate page.html # Review a local HTML file
84
+ /annotate https://example.com # Review a webpage
77
85
  ```
78
86
 
79
87
  <p align="center">
80
88
  <img src="https://raw.githubusercontent.com/nxxxsooo/opencode-annotate/main/docs/assets/browser-review.png" alt="Chrome extension panel with a saved webpage comment and an explicit Send 1 note button" width="440">
81
89
  <br>
82
- <em>Real extension panel with synthetic page feedback; captured in an isolated headless tab.</em>
90
+ <em>Real v0.13.0 extension panel with synthetic feedback; captured in an isolated headless tab. The current panel adds cross-page rounds and a destination picker.</em>
83
91
  </p>
84
92
 
85
93
  Browser setup is separate from the plugin install. Safari supports local notes and copying only; see [Browser review](#browser-review-optional) below.
86
94
 
87
95
  ### Reference previous conversations
88
96
 
89
- Run `/ref` to search and attach a past conversation as context. The source is attached to the session where you invoked `/ref`, queued with `resume: false` so an idle assistant stays idle until your next prompt.
97
+ Run `/ref` to search and attach a past conversation with optional comments and inline annotations as one ordinary user prompt. Confirmation continues an established conversation; before your first message, references wait with `resume: false` for your next prompt.
90
98
 
91
99
  ```text
92
100
  /ref # Choose a conversation from this project
93
101
  /ref authentication # Search titles in this project
94
102
  /ref --all authentication # Search titles across projects
103
+ /ref --tui authentication # Annotate the reference snapshot in the TUI
95
104
  /ref ses_… # Attach a specific conversation
96
105
  ```
97
106
 
@@ -101,23 +110,21 @@ Two Code Mode tools are registered for agent use: `annotate.session_search` and
101
110
 
102
111
  ```text
103
112
  /annotate Review the last completed assistant reply
104
- /annotate-last Review the latest reply, ignoring arguments
105
113
  /annotate docs/plan.md Review a Markdown document
106
114
  /annotate "docs/release plan.md" Review a path containing spaces
107
115
  /annotate ~/Documents/notes.txt Review a plain-text document
108
116
  /annotate-pick Choose a recent reply or mid-turn progress update
109
117
  /annotate-selection Review the message containing your last transcript selection
110
- /annotate-web Pair this session, or create an empty one from home
111
- /annotate-web page.html Review the specified local HTML in Chrome
112
- /annotate-web https://example.com Review the specified webpage
113
- /annotate-web off Revoke this session's browser pairing
118
+ /annotate page.html Review local HTML in the configured browser
119
+ /annotate https://example.com Review the specified webpage
114
120
  /ref Choose a conversation from this project
115
121
  /ref authentication Search conversation titles in this project
116
122
  /ref --all authentication Search titles across projects
123
+ /ref --tui authentication Annotate the reference snapshot in the TUI
117
124
  /ref ses_… Attach a specific conversation
118
125
  ```
119
126
 
120
- Numbered `/annotate N` is retired.
127
+ Numbered `/annotate N`, `/annotate-last` and `/annotate-web` are retired. Use `/annotate-pick` for earlier text, `/annotate` for the latest reply, and `/annotate <url-or-html>` for a page. Browser connection controls live in the extension's destination menu.
121
128
 
122
129
  ## Upgrading from the TUI-only package
123
130
 
@@ -127,20 +134,13 @@ Move its entry from `cli.json` to `opencode.json(c)`, retaining the whole entry
127
134
 
128
135
  ## Reference another conversation
129
136
 
130
- Run `/ref` or `/ref <title words>`, select the source, add an optional comment, then choose
131
- **Attach reference**. The comment field grows as you type or paste, wraps long lines, and
132
- scrolls at a screen-aware height limit. **Shift+Enter** adds a line, **Enter** continues to
133
- confirmation, and **Esc** cancels without attaching anything.
134
- The confirmation names both conversations and shows whether the text is an excerpt.
135
- The source is attached to the session where you invoked `/ref`, even if you switch tabs.
136
- It is queued as historical context with `resume: false`: an idle assistant stays idle
137
- until your next prompt. An already-running session can consume it at a later queue boundary.
138
- Escape cancels without attaching anything.
139
-
140
- Search defaults to the current session's project, including its worktrees. `/ref --all`
141
- searches every project on the connected server. Titles can be ambiguous, so title searches
142
- always show a chooser with directory, time and session ID. An exact `ses_…` ID selects
143
- that source directly, including a source in another project.
137
+ Run `/ref` or `/ref <title words>`, select the source, add an optional whole-reference comment, then choose **Attach and continue**. For inline marks, press **Ctrl+T** in the source chooser (or run `/ref --tui <title words>`) to annotate the snapshot in the existing TUI. The source snapshot, comment and annotations are submitted together as one ordinary user prompt, not a compact reference item. The confirmation names both conversations and shows whether the text is an excerpt. The source is attached to the session where you invoked `/ref`, even if you switch tabs.
138
+
139
+ The comment field grows as you type or paste, wraps long lines, and scrolls at a screen-aware height limit. **Shift+Enter** adds a line, **Enter** continues to confirmation, and **Esc** cancels without attaching anything. Confirming continues the conversation automatically (`delivery: "steer"`, `resume: true`): an idle assistant starts immediately, while a running assistant receives the reference and feedback at its next processing boundary. The quoted conversation remains historical source material.
140
+
141
+ Before your first message, **Attach** adds the reference with `resume: false`, and the assistant reads it with the message you write next. Run `/ref` again to add more. On OpenCode home, `/ref` searches the home directory's project and creates the new session (same directory and model) only after you confirm, then opens it. Cancelling leaves no empty session.
142
+
143
+ Search defaults to the current session's project, including its worktrees. `/ref --all` searches every project on the connected server. In the chooser, **Ctrl+A** switches between this project and all projects and reruns the same title query. The wide chooser gives titles the remaining space beside right-aligned, shortened directory tails; the confirmation retains the full directory. An exact `ses_…` ID selects that source directly, including a source in another project.
144
144
 
145
145
  The server part adds two Code Mode tools:
146
146
 
@@ -151,41 +151,25 @@ The server part adds two Code Mode tools:
151
151
  older history. For a shortened message, pass its `messageID` and `nextOffset` as
152
152
  `offset` to retrieve the rest.
153
153
 
154
- References include user text and completed assistant text, source IDs and timestamps.
155
- Tool payloads, reasoning, binary attachments and unfinished output are excluded. Each
156
- page contains at most 24,000 characters of message text, distributed across the messages;
157
- truncation and continuation are explicit. Historical claims may no longer match the code.
158
- Search matches titles, not words inside messages.
154
+ References include user text and completed assistant text, source IDs and timestamps. Tool payloads, reasoning, binary attachments and unfinished output are excluded. Each page contains at most 24,000 characters of message text, distributed across the messages; truncation and continuation are explicit. Historical claims may no longer match the code. Search matches titles, not words inside messages.
159
155
 
160
- **Server requirement:** the full-history read tool currently uses the official `opencode api`
161
- command because OpenCode 2.2's plugin context exposes only post-compaction context. The
162
- server must run as the managed OpenCode service with `opencode` on PATH. A process-ID
163
- check rejects a different discovered server; standalone and embedded servers are not
164
- supported by this tool. `/ref` uses the TUI's connected client directly. No separate
165
- transcript index or database access is needed.
156
+ **Server requirement:** the full-history read tool uses the official `opencode api` command because OpenCode 2.2's plugin context exposes only post-compaction context. The server must run as the managed OpenCode service with `opencode` on PATH. A process-ID check rejects a different discovered server. `/ref` uses the TUI's connected client directly.
166
157
 
167
- Permission actions are `annotate_session_search` (project ID, or `*` for cross-project
168
- search) and `annotate_session_read` (source session ID).
158
+ Permission actions are `annotate_session_search` (project ID, or `*` for cross-project search) and `annotate_session_read` (source session ID).
169
159
 
170
- ### Reference verification
160
+ <details>
161
+ <summary id="reference-verification">Reference verification</summary>
171
162
 
172
- `npm run test:references` exercises the server tools and `/ref` against source or an
173
- extracted npm package. The checks cover pre-compaction history, API responses larger than 256 KiB,
174
- pagination, long-message continuation, attachment and cancellation without a model
175
- turn. Unit checks also cover tab changes, permission denial and private-file cleanup.
163
+ `npm run test:references` exercises the server tools and `/ref` against source or an extracted npm package. The checks cover pre-compaction history, API responses larger than 256 KiB, pagination, long-message continuation, attachment and cancellation. The fixture records the production `steer`/`resume` request, then forces `resume: false` to avoid a model turn. Unit checks also cover tab changes, permission denial and private-file cleanup.
176
164
 
177
- Recovery starts in `reference-command.mjs` for `/ref`, `session-tools.mjs` for agent
178
- tools, and `session-reference.mjs` for bounded history. `server-history.mjs` captures
179
- CLI output in private temporary files to avoid v2.2.0 pipe truncation, then removes
180
- them. Regression entrypoints are `session-reference.test.mjs`,
181
- `server-history.test.mjs` and `tests/references-smoke.py`; release ownership remains in
182
- [docs/releasing.md](docs/releasing.md).
165
+ Recovery starts in `reference-command.mjs` for `/ref`, `session-tools.mjs` for agent tools, and `session-reference.mjs` for bounded history. `server-history.mjs` captures CLI output in private temporary files to avoid v2.2.0 pipe truncation, then removes them. Regression entrypoints are `session-reference.test.mjs`, `server-history.test.mjs` and `tests/references-smoke.py`; release ownership remains in [docs/releasing.md](docs/releasing.md).
166
+ </details>
183
167
 
184
168
  ## Antigravity (AGY) support
185
169
 
186
170
  `opencode-annotate` provides companion support for Google Antigravity CLI (`agy`) via `agy-annotate`:
187
171
 
188
- - **Slash commands `/annotate` & `/annotate-web`**: Built-in AGY skill at `agy/skills/annotate/` handles review directly within active AGY sessions.
172
+ - **Slash command `/annotate`**: Built-in AGY skill at `agy/skills/annotate/` handles text and explicit URL/HTML review within active AGY sessions.
189
173
  - **Interactive TUI**: Uses the same bundled reviewer as OpenCode, with Dracula theme inheritance and one-key send.
190
174
  - **Native Delivery**: Hooks into AGY lifecycle (`SessionStart`, `PreInvocation`, `Stop`) to deliver feedback directly into the conversation turn without network listeners.
191
175
  - **CLI Commands**:
@@ -198,15 +182,9 @@ them. Regression entrypoints are `session-reference.test.mjs`,
198
182
 
199
183
  ### Match OpenCode's colors
200
184
 
201
- Set `"inheritTheme": true` in the plugin's `options`. The bundled reviewer supports the
202
- full palette and `[ui].doc_width` for a readable text column on wide terminals.
203
- See [TUI theme integration](docs/tui-theme.md).
185
+ Set `"inheritTheme": true` in the plugin's `options`. The bundled reviewer supports the full palette and `[ui].doc_width` for a readable text column on wide terminals. See [TUI theme integration](docs/tui-theme.md).
204
186
 
205
- Each review uses OpenCode's current resolved colors for the canvas, text, Markdown,
206
- borders, highlights, cursor and selection. The plugin asks the chosen binary for its
207
- effective configuration, copies it into that review's private directory, and validates
208
- the themed copy before taking over the terminal. Your original settings stay intact.
209
- Launchers must honor an existing `PLANNOTATOR_TUI_CONFIG`.
187
+ Each review uses OpenCode's current resolved colors for the canvas, text, Markdown, borders, highlights, cursor and selection. The plugin asks the chosen binary for its effective configuration, copies it into that review's private directory, and validates the themed copy before taking over the terminal. Your original settings stay intact. Launchers must honor an existing `PLANNOTATOR_TUI_CONFIG`.
210
188
 
211
189
  ## Browser review (optional)
212
190
 
@@ -222,189 +200,78 @@ ANNOTATE_DEVELOPMENT_TEAM="TEAMID" npm run build:safari
222
200
  npm run install:safari
223
201
  ```
224
202
 
225
- The installer replaces `/Applications/annotate.app` and refreshes its registration.
226
- Open that app once, then enable Annotate in Safari > Settings > Extensions. Without
227
- signing environment variables the build uses an ad-hoc signature, which Safari may
228
- refuse to register. Allow access to the pages you want to review.
203
+ The installer replaces `/Applications/annotate.app` and refreshes its registration. Open that app once, then enable Annotate in Safari > Settings > Extensions. Without signing environment variables the build uses an ad-hoc signature, which Safari may refuse to register. Allow access to the pages you want to review.
229
204
 
230
- Click the Annotate toolbar button, or use Option+Shift+A where Safari supports the
231
- extension command, to open its standalone panel. Select text or pick an element,
232
- write notes, then **Copy notes** to paste the round into any agent. Notes and drafts
233
- stay local; copying closes the round and **Restore last round** recovers it.
205
+ Click the Annotate toolbar button, or use Option+Shift+A where Safari supports the extension command, to open its standalone panel. Select text or pick an element, write notes, then **Copy notes** to paste the round into any agent. Notes and drafts stay local; copying closes the round and **Restore last round** recovers it.
234
206
 
235
- Safari requires an App-Sandboxed app extension, so it cannot start the Node bridge or
236
- read the session registry. It has no direct session delivery or session chooser;
237
- Chrome retains both. Safari also has no docked side panel: its separate window stays
238
- bound to the reviewed browser window and keeps polling while you work on the page.
207
+ Safari requires an App-Sandboxed app extension, so it cannot start the Node bridge or read the session registry. It has no direct session delivery or session chooser; Chrome retains both. Safari also has no docked side panel: its separate window stays bound to the reviewed browser window and keeps polling while you work on the page.
239
208
 
240
- Set the plugin option `"browser": "Safari"` so `/annotate-web <url-or-html-file>` opens
241
- the page in Safari. The only public values are `"Chrome"` (default) and `"Safari"`;
242
- Chrome maps to the macOS app Google Chrome. AGY supports the same choice with
243
- `agy-annotate web <url> --browser Safari`. Restart the client after changing the option.
244
- `/annotate-web` keeps its existing pairing lifecycle; Safari ignores that pairing
245
- and copies notes instead. `/annotate` remains the text/TUI command.
209
+ Set the plugin option `"browser": "Safari"` so `/annotate <url-or-html-file>` opens the page in Safari. The only public values are `"Chrome"` (default) and `"Safari"`; Chrome maps to the macOS app Google Chrome. AGY supports the same choice with `agy-annotate web <url> --browser Safari`. Safari ignores session registration and copies notes instead. Plain `/annotate` still opens the text reviewer.
246
210
 
247
- After updates, run `npm run build:safari` with the signing variables again, then
248
- `npm run install:safari`. Reopen the app and re-enable the extension if needed. An
249
- unpacked Chrome reload does not update the installed Safari app.
211
+ After updates, run `npm run build:safari` with the signing variables again, then `npm run install:safari`. Reopen the app and re-enable the extension if needed. An unpacked Chrome reload does not update the installed Safari app.
250
212
 
251
213
  ### Chrome (direct delivery)
252
214
 
253
- 1. Clone this repository and load its `browser/` directory as an unpacked extension in
254
- `chrome://extensions`. Allow file URL access if reviewing local HTML.
255
- 2. Run `npm run install:bridge` in the clone to register the native host. It allows only this
256
- companion's fixed extension ID and resolves Node absolutely. The host starts on demand and
257
- opens no HTTP port.
258
- 3. Reopen the OpenCode terminal client; the shared service needs no restart.
259
-
260
- Run `/annotate-web`, then open the Chrome extension. From the blank home screen, it
261
- creates an empty session in the current directory using the selected model; no first
262
- prompt is needed. In an existing session, it pairs that session. A sole live
263
- session is shown automatically; with several sessions, choose one once. Click the
264
- destination beside **To** to change or refresh it. Its title stays visible beside Send,
265
- including while disconnected, with its directory available on hover and in the chooser.
266
- A sole target is only preselected: no binding or model turn occurs until
267
- the user clicks **Send & continue**. A disconnected destination never silently switches to another session.
268
-
269
- Choose **Pick element** or select text, then write a comment or question. The composer
270
- appears for that selection. **Send N notes & continue** saves the current feedback and
271
- sends pending notes in one action; **Add note** collects feedback locally for a batch.
272
- Cmd/Ctrl+Enter adds a note or saves an edit. This sends pending notes to that captured
273
- session and starts a normal model turn; pairing and saving notes make no model call.
274
- Switching terminal tabs never changes the paired target. Revoke with `/annotate-web off`.
275
-
276
- The numbered queue matches the page markers. Click a note's quoted target to show it
277
- on the page without activating the element; **Edit** changes the feedback, and **Undo**
278
- restores a deleted note. The delivery bar shows the round's note count and destination.
279
-
280
- Each send closes a review round: delivered notes leave the list and the panel is ready
281
- for the next round. **Restore last round** returns the most recent delivered notes to the
282
- list; the last ten rounds per page are kept.
283
-
284
- Delivery has two modes, shown beside the destination. With a **Live** session the primary
285
- button is **Send N notes**, and the copy icon beside it copies the round instead. When the
286
- session is **Offline**, or none is connected, the button is **Copy N notes**: it copies the
287
- round as Markdown for any agent and closes it the same way. Run `/annotate-web` in a
288
- session to switch back to Send. If a session drops during Send, the notes are kept and the
289
- panel switches to Copy.
290
- **More review options** contains a non-closing Markdown copy, JSON export, and a preview
291
- of the current round.
292
-
293
- After a page reload or same-site navigation, the panel reconnects its page tools
294
- automatically. If Chrome has withdrawn access (for example after moving to another site),
295
- the panel asks you to click the extension icon once; saved notes are kept.
215
+ 1. Clone this repository and load its `browser/` directory as an unpacked extension in `chrome://extensions`. Allow file URL access if reviewing local HTML.
216
+ 2. Reopen the OpenCode terminal client. The plugin registers the native host and active sessions automatically on macOS; the shared service needs no restart. The host allows only this companion's fixed extension ID, resolves Node absolutely, starts on demand and opens no HTTP port.
217
+ 3. Open the extension panel and choose a destination. If automatic setup reports an error, run `npm run install:bridge` in the clone to repair it.
218
+
219
+ Click the destination beside **To** to filter sessions by title or directory and sort by recent activity, creation or title. The picker refreshes automatically and shows current session titles. **New session** creates an empty session with the chosen session's location/model, or the blank OpenCode home's current selection, without starting a model turn. **Disconnect** keeps the destination named and notes local; choosing that session again reconnects. A disconnected destination never silently switches to another session. Restarted receivers reconnect by stable provider/session identity, carrying any retry batch to the replacement.
220
+
221
+ Choose **Pick element** or select text, then write a comment or question. The composer appears for that selection. **Send N notes & continue** saves current feedback and sends all pending notes across pages; **Add note** collects feedback locally. Cmd/Ctrl+Enter adds a note or saves an edit. Confirmed sends use `steer` / `resume: true`: idle sessions start immediately and running turns receive feedback at their next processing boundary. Registering, creating sessions and saving notes make no model call. Switching terminal tabs never changes the captured destination.
222
+
223
+ The queue groups notes by page, with contiguous numbers matching page markers and delivered Markdown. Click a note's quoted target to show it on its page without activating the element; off-page notes can open their page. **Edit** changes the feedback, and **Undo** restores a deleted note. The delivery bar shows the whole round's count and destination; drafts remain page-local.
224
+
225
+ Each send closes the global review round: delivered notes leave the list and the panel is ready for the next round. **Restore last round** returns the most recent round's notes across pages; the last ten rounds are kept globally.
226
+
227
+ **Send** and **Copy instead** remain separate actions. Send requires a live destination; Copy instead copies the grouped round as Markdown for any agent and closes it the same way. If a session drops during Send, notes remain available for retry or copying. **More review options** contains a non-closing Markdown copy, JSON export, and a preview of the current round.
228
+
229
+ After a page reload or same-site navigation, the panel reconnects its page tools automatically. If Chrome has withdrawn access (for example after moving to another site), the panel asks you to click the extension icon once; saved notes are kept.
296
230
 
297
231
  ### Explicit routing
298
232
 
299
- `/annotate`, `/annotate-pick` and `/annotate-selection` always use the TUI; Markdown and
300
- plain-text files do too. Only `/annotate-web` enters the browser workflow; passing a URL or
301
- HTML file to `/annotate` points you there. A reply containing HTML links or code fences does
302
- not change the default.
233
+ Plain `/annotate`, `/annotate-pick` and `/annotate-selection` use the TUI; Markdown and plain-text files do too. Explicit URLs and HTML paths passed to `/annotate` enter the browser workflow. A reply containing HTML links or code fences does not change the default.
303
234
 
304
235
  ### Browser safeguards and limitations
305
236
 
306
- Written drafts autosave locally and restore after panel reload or a return to the same URL,
307
- including SPA routes. Selecting another target with unfinished feedback offers **Add/Save
308
- & switch**, **Keep editing**, or **Discard & switch**. Storage failures keep the input and
309
- offer a retry; competing panels require an explicit choice of draft. Saved-note revision
310
- checks likewise prevent stale tabs overwriting newer feedback. Full JSON/Markdown exports include
311
- redacted URLs, exact selected text/context, verified selector hints, styles and accessibility.
312
- Missing/changed/ambiguous targets are labeled in the sidebar instead of silently rebound.
313
- Comments and drafts live in extension-owned UI/storage; the page receives only selection
314
- metadata and numbered markers, not your written feedback.
315
-
316
- Native delivery requires an open, paired local TUI. If the receiver closes, feedback stays
317
- pending. A failed batch retains its original target and ID for safe retry; if that target
318
- is permanently gone, export the notes before starting a new review. **Retry N notes &
319
- continue** retries that original batch; newly composed feedback stays local for the next
320
- send. Copying a round instead supersedes a failed batch.
321
- Clipboard failures expose a selectable preview and keep the round open. Browser-internal pages, PDF,
322
- cross-origin iframes, Canvas and remote SSH TUI clients are outside this version's scope.
323
- Page Context is retired only after exporting its drafts and verifying this replacement.
324
-
325
- See [implementation plan](docs/annotate-html-integration-plan.md) and
326
- [shipped-artifact evaluation](docs/annotate-html-evaluation.md), plus
327
- [browser provenance](browser/UPSTREAM.md). `npm test`, `npm run test:smoke`, and
328
- `npm run test:browser` verify each layer; the browser test uses an existing Playwright installation
329
- (`PLAYWRIGHT_MODULE`) and browser executable (`CHROMIUM_PATH`) in an isolated profile.
237
+ Written drafts autosave locally and restore after panel reload or a return to the same URL, including SPA routes. Selecting another target with unfinished feedback offers **Add/Save & switch**, **Keep editing**, or **Discard & switch**. Storage failures keep the input and offer a retry; competing panels require an explicit choice of draft. Saved-note revision checks likewise prevent stale tabs overwriting newer feedback. Full JSON/Markdown exports include redacted URLs, exact selected text/context, verified selector hints, styles and accessibility. Missing/changed/ambiguous targets are labeled in the sidebar instead of silently rebound. Comments and drafts live in extension-owned UI/storage; the page receives only selection metadata and numbered markers, not your written feedback.
238
+
239
+ Native delivery requires an open local TUI and a connected destination. If the receiver closes, feedback stays pending. A failed batch retains its original target and ID for safe retry; if that session is permanently gone, export the notes before starting a new review. **Retry N notes & continue** retries that original batch; newly composed feedback stays local for the next send. Copying a round instead supersedes a failed batch. Clipboard failures expose a selectable preview and keep the round open. Browser-internal pages, PDF, cross-origin iframes, Canvas and remote SSH TUI clients are outside this version's scope. Page Context is retired only after exporting its drafts and verifying this replacement.
240
+
241
+ See [implementation plan](docs/annotate-html-integration-plan.md) and [shipped-artifact evaluation](docs/annotate-html-evaluation.md), plus [browser provenance](browser/UPSTREAM.md). `npm test`, `npm run test:smoke`, and `npm run test:browser` verify each layer; the browser test uses an existing Playwright installation (`PLAYWRIGHT_MODULE`) and browser executable (`CHROMIUM_PATH`) in an isolated profile.
330
242
 
331
243
  ### Reload after browser companion updates
332
244
 
333
- After updating the unpacked `browser/` files, open `chrome://extensions` and click
334
- **Reload** for **OpenCode Annotate**. Return to the target webpage and open Annotate
335
- using its extension icon or **Alt+Shift+A**.
245
+ After updating the unpacked `browser/` files, open `chrome://extensions` and click **Reload** for **OpenCode Annotate**. Return to the target webpage and open Annotate using its extension icon or **Alt+Shift+A**.
336
246
 
337
- A newly opened sidebar can load the updated `panel.mjs` while Chrome still runs an
338
- older `worker.mjs`. The panel detects this protocol mismatch and shows **Annotate was
339
- updated** with a **Reload Annotate** button; reopen the panel afterwards.
340
- Saved extension-local data survives an extension reload.
247
+ A newly opened sidebar can load the updated `panel.mjs` while Chrome still runs an older `worker.mjs`. The panel detects this protocol mismatch and shows **Annotate was updated** with a **Reload Annotate** button; reopen the panel afterwards. Saved extension-local data survives an extension reload.
341
248
 
342
- For diagnosis, compare the running worker's source (DevTools/CDP
343
- `Debugger.getScriptSource`) with `browser/worker.mjs` in the loaded checkout.
344
- The manifest version alone cannot identify edits to an unpacked extension.
249
+ For diagnosis, compare the running worker's source (DevTools/CDP `Debugger.getScriptSource`) with `browser/worker.mjs` in the loaded checkout. The manifest version alone cannot identify edits to an unpacked extension.
345
250
 
346
251
  ## Review and send
347
252
 
348
- 1. Run `/annotate` or `/annotate path/to/file.md` in a session.
349
- 2. Select text by dragging, or press `v` and use movement keys.
350
- 3. Press `c` to comment, `w` for **what?**, `a` for “looks good,” or `d` to request deletion.
351
- **what?** marks a passage you don't understand with a short `what?` note
352
- ([what? notes](#what-notes)). Without a selection, `c` comments on the current block.
353
- Enter saves a comment. With a selection waiting, Enter records **Done** (the requested
354
- work is finished), and `g` records **Get** (understood). Esc dismisses without a note.
355
- The compact toolbar shows approve, comment, Done and Get; `w`, `d` and `y` are keyboard-only.
356
- Selecting never touches the clipboard; press `y` to copy the selected source and keep
357
- the selection for annotating.
253
+ 1. Run `/annotate` or `/annotate path/to/file.md`.
254
+ 2. Select text by dragging, or press `v` and move.
255
+ 3. Press `c` to comment, `w` for **what?** ([what? notes](#what-notes)), `a` for "looks good," or `d` to request deletion. Without a selection, `c` comments on the current block. Enter saves a comment; with a selection waiting, Enter records **Done**, `g` records **Get**. Esc dismisses. The compact toolbar shows approve, comment, Done and Get; `w`, `d` and `y` are keyboard-only. Press `y` to copy the selected source.
358
256
  4. Press **`q`** to send your notes and return to OpenCode.
359
257
 
360
- For real PNG toolbar artwork in a verified Kitty-graphics terminal, see the
361
- [local image-toolbar configuration](tui/README.md#local-image-toolbar-trial).
362
- Artwork is user-supplied and not included; unconfigured terminals keep Unicode icons.
258
+ For PNG toolbar artwork in a verified Kitty-graphics terminal, see the [local image-toolbar configuration](tui/README.md#local-image-toolbar-trial). Artwork is user-supplied; unconfigured terminals keep Unicode icons.
363
259
 
364
260
  ### Chinese and other input methods
365
261
 
366
- An input method holds plain letters while it composes, so review keys such as `e`, `q`
367
- and `s`, and OpenCode's permission shortcuts, do nothing. With
368
- [Slash Saver](https://github.com/nxxxsooo/slash-saver) 1.1+ installed in `/Applications`,
369
- the plugin selects its configured ASCII source while you browse a review or answer a
370
- permission prompt, and restores your source afterwards. The comment and edit
371
- boxes switch back to your writing source while open. Set `"inputSource": false` in the
372
- plugin's `options` to turn this off, or a path to another helper with the same
373
- `input-source current|select|ascii` commands. The reviewer also binds **`Ctrl+E`** to edit,
374
- which an input method passes through.
375
-
376
- Opening a review makes no model call. Confirming sends a normal user prompt and
377
- resumes the **original session**, even if the active tab changes. Empty and
378
- cancelled reviews submit nothing.
379
-
380
- ## What it reviews
381
-
382
- **Replies:** the latest completed text reply, with paginated history lookup.
383
- Reasoning, in-progress messages and tool-call commentary are excluded.
384
- Use `/annotate-pick` for an earlier reply or progress update, or `/annotate-selection`
385
- for selected transcript text. Numbered reply arguments are retired.
386
-
387
- **Documents:** local UTF-8 `.md`, `.mdx`, `.markdown` and `.txt` files up to 2 MiB.
388
- Relative paths resolve against the captured session's working directory, not the
389
- directory from which the terminal client happened to start. Absolute and `~/`
390
- paths work too. The file must exist on the machine running the terminal client.
391
-
392
- The TUI reads a fixed snapshot and does not edit the original document. Feedback
393
- includes the original path and snapshot hash, with instructions to re-read the
394
- current file before applying suggestions. Document review works even before the
395
- session has an assistant reply.
262
+ An input method holds plain letters while it composes, so review keys such as `e`, `q` and `s`, and OpenCode's permission shortcuts, do nothing. With [Slash Saver](https://github.com/nxxxsooo/slash-saver) 1.1+ installed in `/Applications`, the plugin selects its configured ASCII source while you browse a review or answer a permission prompt, and restores your source afterwards. The comment and edit boxes switch back to your writing source while open. Set `"inputSource": false` in the plugin's `options` to turn this off, or a path to another helper with the same `input-source current|select|ascii` commands. The reviewer also binds **`Ctrl+E`** to edit, which an input method passes through.
263
+
264
+ Opening a review makes no model call. Confirming sends a normal user prompt and resumes the **original session**, even if the active tab changes. Empty and cancelled reviews submit nothing.
396
265
 
397
266
  ## Updates and uninstall
398
267
 
399
- `@latest` selects the npm release channel. OpenCode caches installed packages;
400
- it does not follow this repository's commits. Update just this plugin with:
268
+ `@latest` selects the npm release channel. OpenCode caches installed packages; it does not follow this repository's commits. Update just this plugin with:
401
269
 
402
270
  ```sh
403
271
  opencode plugin update @nxxxsooo/opencode-annotate@latest
404
272
  ```
405
273
 
406
- Run `/reload` if the command list has not refreshed. Check the installed version with
407
- `opencode plugin list`.
274
+ Run `/reload` if the command list has not refreshed. Check the installed version with `opencode plugin list`.
408
275
 
409
276
  To remove it:
410
277
 
@@ -433,47 +300,30 @@ Enable auto-annotation in the plugin entry in **`opencode.jsonc`** (or `opencode
433
300
  }
434
301
  ```
435
302
 
436
- Add these options to your existing entry, keeping any other options. Auto-annotation
437
- is **off by default**; set `autoAnnotate` to `false` to disable it. The threshold defaults
438
- to **2,000 characters** and accepts a non-negative integer; `0` reviews every non-empty
439
- reply. It counts Unicode characters in the trimmed reply text, including Markdown and
440
- code, excluding reasoning and tool output. A reply exactly at the threshold does not open.
303
+ Add these options to your existing entry, keeping any other options. Auto-annotation is **off by default**; set `autoAnnotate` to `false` to disable it. The threshold defaults to **2,000 characters** and accepts a non-negative integer; `0` reviews every non-empty reply. It counts Unicode characters in the trimmed reply text, including Markdown and code, excluding reasoning and tool output. A reply exactly at the threshold does not open.
441
304
 
442
- After a successful turn, a new qualifying reply in the active session opens the normal
443
- reviewer once. Progress updates, failed or interrupted turns, historical replies and
444
- background sessions do not trigger it. A reply is skipped if another review is open,
445
- you switch sessions before it opens, or a new turn starts. Dismissing the reviewer or
446
- reloading the plugin does not reopen that reply. Sending remains your explicit action.
447
- OpenCode reloads saved configuration automatically; use `/reload` if needed.
305
+ After a successful turn, a new qualifying reply in the active session opens the normal reviewer once. Progress updates, failed or interrupted turns, historical replies and background sessions do not trigger it. A reply is skipped if another review is open, you switch sessions before it opens, or a new turn starts. Dismissing the reviewer or reloading the plugin does not reopen that reply. Sending remains your explicit action. OpenCode reloads saved configuration automatically; use `/reload` if needed.
448
306
 
449
307
  ### What? notes
450
308
 
451
- A `what?` note stays short in the review. When you send, the feedback adds one
452
- instruction after all the notes: explain each marked passage in plain language with more
453
- detail and a concrete example where it helps, relate it to the current task, and hold any
454
- pending action until you confirm. Change or remove that instruction in
455
- `~/.config/opencode-annotate/tui.toml`; an empty string sends the notes alone:
309
+ A `what?` note stays short in the review. When you send, the feedback adds one instruction after all the notes: explain each marked passage in plain language with more detail and a concrete example where it helps, relate it to the current task, and hold any pending action until you confirm. Change or remove that instruction in `~/.config/opencode-annotate/tui.toml`; an empty string sends the notes alone:
456
310
 
457
311
  ```toml
458
312
  [prompts]
459
313
  what = "Explain each passage marked what? in two sentences, then stop."
460
314
  ```
461
315
 
462
- If OpenCode has a skill with ID `what`, the plugin attaches it to the sent feedback, the
463
- same as mentioning `@what`. That skill can then hold pending work and ask whether to
464
- continue. Choose another skill or turn this off with the `whatSkill` plugin option:
316
+ If OpenCode has a skill with ID `what`, the plugin attaches it to the sent feedback, the same as mentioning `@what`. That skill can then hold pending work and ask whether to continue. Choose another skill or turn this off with the `whatSkill` plugin option:
465
317
 
466
318
  ```jsonc
467
319
  "options": { "whatSkill": "explain" } // or false
468
320
  ```
469
321
 
470
- A missing default `what` skill is skipped. A missing skill that you set yourself stops the
471
- send with an error and keeps the draft and `feedback.md`.
322
+ A missing default `what` skill is skipped. A missing skill that you set yourself stops the send with an error and keeps the draft and `feedback.md`.
472
323
 
473
324
  ### Reviewer binary and layout
474
325
 
475
- The bundled reviewer is selected automatically. Use `binary` only to override it with
476
- another locally built Annotate TUI executable:
326
+ The bundled reviewer is selected automatically. Use `binary` only to override it with another locally built Annotate TUI executable:
477
327
 
478
328
  ```json
479
329
  {
@@ -486,31 +336,25 @@ another locally built Annotate TUI executable:
486
336
  }
487
337
  ```
488
338
 
489
- The adapter launches Annotate TUI in the current terminal. Layout and key settings live
490
- in `~/.config/opencode-annotate/tui.toml`; font family and size belong to the terminal.
491
- The adapter supplies `PLANNOTATOR_TUI_THEME` to follow OpenCode's light/dark mode.
492
- The existing environment and annotation-field names are local protocol identifiers;
493
- they do not connect to or install another project.
339
+ The adapter launches Annotate TUI in the current terminal. Layout and key settings live in `~/.config/opencode-annotate/tui.toml`; font family and size belong to the terminal. The adapter supplies `PLANNOTATOR_TUI_THEME` to follow OpenCode's light/dark mode. The existing environment and annotation-field names are local protocol identifiers; they do not connect to or install another project.
494
340
 
495
- ## Draft recovery
341
+ <details>
342
+ <summary id="draft-recovery">Draft recovery</summary>
496
343
 
497
- Each review has its own private temporary source and annotation store. Successful,
498
- empty and cancelled reviews are cleaned up. Failures and archived notes retain the
499
- store, and a status message gives its directory.
344
+ Each review has its own private temporary source and annotation store. Successful, empty and cancelled reviews are cleaned up. Failures and archived notes retain the store, and a status message gives its directory.
500
345
 
501
- `review.json` records the session, original source and relative `snapshot` path.
502
- `feedback.md` holds exported feedback when available. To recover a retained review:
346
+ `review.json` records the session, original source and relative `snapshot` path. `feedback.md` holds exported feedback when available. To recover a retained review:
503
347
 
504
348
  ```sh
505
349
  PLANNOTATOR_DATA_DIR="<retained-directory>/data" \
506
350
  npx --package @nxxxsooo/opencode-annotate annotate-tui "<retained-directory>/<snapshot>"
507
351
  ```
508
352
 
509
- Use the `snapshot` value from `review.json`. Press `H` to restore archived notes,
510
- then `E` to copy them for pasting into OpenCode. An **E → F** archive is
511
- preserved even when `--export` reports “No annotations.”
353
+ Use the `snapshot` value from `review.json`. Press `H` to restore archived notes, then `E` to copy them for pasting into OpenCode. An **E → F** archive is preserved even when `--export` reports "No annotations."
354
+ </details>
512
355
 
513
- ## Development
356
+ <details>
357
+ <summary id="development">Development</summary>
514
358
 
515
359
  ```sh
516
360
  npm ci
@@ -521,24 +365,14 @@ npm run test:smoke
521
365
  npm run test:references
522
366
  ```
523
367
 
524
- Rust 1.96+ is needed to build from source. Unit tests use the bundled annotation/export
525
- binary, including theme inheritance tests. The optional smoke test
526
- also requires Python 3, tmux and OpenCode. It runs a detached terminal, verifies
527
- commands and feedback through the actual API, then removes its test session.
528
- Its submission uses `resume: false`, so it makes no model call or visible window.
368
+ Rust 1.96+ is needed to build from source. Unit tests use the bundled annotation/export binary, including theme inheritance tests. The optional smoke test also requires Python 3, tmux and OpenCode. It runs a detached terminal, verifies commands and feedback through the actual API, then removes its test session. Its submission uses `resume: false`, so it makes no model call or visible window.
529
369
 
530
- Set `ANNOTATE_TUI_BINARY` to test a custom binary or launcher through the plugin's
531
- real configuration path. For a build with a centered 120-column viewport, also
532
- set `ANNOTATE_EXPECT_MARGIN=10` to assert blank margins in the 140-column smoke
533
- terminal. These variables configure the test, not the shipped plugin.
370
+ Set `ANNOTATE_TUI_BINARY` to test a custom binary or launcher through the plugin's real configuration path. For a build with a centered 120-column viewport, also set `ANNOTATE_EXPECT_MARGIN=10` to assert blank margins in the 140-column smoke terminal. These variables configure the test, not the shipped plugin.
534
371
 
535
- For development loading, set the plugin entry in `opencode.json(c)` to this checkout's
536
- absolute directory, preserving its `options`, and run `/reload`. Remove any duplicate
537
- entry in `cli.json`. The older `npm run install:plugin` helper switches **only the TUI**
538
- entry in `cli.json`; use it only for TUI-only development. The reference smoke test loads
539
- both entrypoints in its own temporary location without changing your global configuration.
372
+ For development loading, set the plugin entry in `opencode.json(c)` to this checkout's absolute directory, preserving its `options`, and run `/reload`. Remove any duplicate entry in `cli.json`. The older `npm run install:plugin` helper switches **only the TUI** entry in `cli.json`; use it only for TUI-only development.
540
373
 
541
374
  See [release instructions](docs/releasing.md) and [changelog](CHANGELOG.md).
375
+ </details>
542
376
 
543
377
  ## 中文速用
544
378
 
@@ -548,9 +382,8 @@ See [release instructions](docs/releasing.md) and [changelog](CHANGELOG.md).
548
382
  - `/annotate 文档.md`:批注文档,支持中文、空格和相对路径。
549
383
  - `/annotate-pick`:从最近的回复和运行中的进度说明里选一条批注。
550
384
  - `/annotate-selection`:先在会话里拖选文字,再批注包含这段文字的消息。
551
- - `/annotate-last`:固定批注最新一条完整回复,忽略附带参数。
552
- - `/ref`:选择并引用同项目的历史会话,可附留言;留言框随内容自动增高、换行,超长时滚动。Shift+Enter 换行,Enter 进入确认,Esc 取消。`/ref --all 关键词` 跨项目搜索;`/ref ses_…` 直接指定。确认后附加上下文,不启动空闲助手。
553
- - `/annotate-web`:配对 Chrome;空白首页会先创建空会话,无需先发提示词。`/annotate-web 页面.html`、`/annotate-web https://…` 批注网页;`/annotate-web off` 撤销配对。
385
+ - `/ref`:选择并引用同项目的历史会话,可附整段评论;选择器中按 `Ctrl+A` 切换项目范围,按 `Ctrl+T` 打开 TUI 添加逐段批注;`/ref --all 关键词` 跨项目搜索;`/ref --tui 关键词` 直接进入 TUI 流程;`/ref ses_…` 直接指定。快照、评论和批注合并为一条普通用户提示,确认后继续对话;在首条消息之前(包括 OpenCode 首页,确认后才新建会话),只附加不启动助手,可多次引用后再开口。
386
+ - `/annotate 页面.html`、`/annotate https://…`:打开网页批注。Chrome 自动注册主机和会话,扩展目的地菜单可筛选、新建空会话、断开及重连;Safari 保持仅复制。跨页备注汇成一轮,Send 与 Copy instead 分开,确认发送后自动继续原会话。
554
387
  - 选中文字 → `c` 写批注 → Enter 保存 → `q` 发送并返回。
555
388
  - 写批注中途按 `Ctrl+S`,一步保存、返回并发送(中文输入法开着也有效);`Ctrl+C` 返回后由 OpenCode 询问。
556
389
  - 文档采用独立快照,反馈附原文件路径,确认后发回发起批注的会话。
@@ -10,10 +10,10 @@ import { listTargets } from "../bridge/receiver.mjs"
10
10
  import { request } from "../bridge/wire.mjs"
11
11
 
12
12
  const sampleReview = () => ({
13
- version: 1,
14
- page: { url: "https://example.test/app", title: "App Preview" },
13
+ version: 2,
15
14
  annotations: [
16
15
  {
16
+ page: { url: "https://example.test/app", title: "App Preview" },
17
17
  id: "note-1",
18
18
  revision: 1,
19
19
  kind: "comment",