@nxxxsooo/opencode-annotate 0.10.0 → 0.10.2
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 +19 -0
- package/README.md +52 -18
- package/auto-review.mjs +64 -0
- package/configuration.mjs +56 -0
- package/package.json +3 -1
- package/review.mjs +40 -11
- package/server.ts +2 -0
- package/tui/README.md +6 -7
- package/tui/bin/darwin-arm64/annotate-tui +0 -0
- package/tui/bin/darwin-x64/annotate-tui +0 -0
- package/tui/bin/linux-arm64/annotate-tui +0 -0
- package/tui/bin/linux-x64/annotate-tui +0 -0
- package/tui/bin/win32-x64/annotate-tui.exe +0 -0
- package/tui.ts +23 -2
- package/web-review.mjs +21 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.2 — table cell selection
|
|
4
|
+
|
|
5
|
+
- Keep a mouse or `v` selection that starts in a table cell inside that cell. Dragging
|
|
6
|
+
down a wrapped cell no longer pulls in the neighbouring columns, and overshooting the
|
|
7
|
+
cell's last line stops at its edge. Dragging into another column still selects whole rows.
|
|
8
|
+
|
|
9
|
+
## 0.10.1 — automatic review and blank-session web pairing
|
|
10
|
+
|
|
11
|
+
- Let `/annotate-web` start from the blank home screen by creating and pairing an empty
|
|
12
|
+
session in the current directory with the selected model. No prompt or model turn is
|
|
13
|
+
needed before annotating; feedback remains bound to that session after switching tabs.
|
|
14
|
+
|
|
15
|
+
- Add opt-in automatic review of long replies through `autoAnnotate` and
|
|
16
|
+
`autoAnnotateThreshold` in the plugin's JSONC options (default: off, 2,000 characters).
|
|
17
|
+
Open the exact completed reply once after a successful turn in the active session;
|
|
18
|
+
keep feedback sending explicit and skip background, failed and interrupted turns.
|
|
19
|
+
- Read plugin options through a location-scoped RPC so OpenCode 2.2's server-loaded
|
|
20
|
+
TUI receives its JSONC settings, including updates to the auto-annotation switch.
|
|
21
|
+
|
|
3
22
|
## 0.10.0 — integrated TUI and conversation references
|
|
4
23
|
|
|
5
24
|
- Own the terminal reviewer under `tui/`, with its source, tests, native build and
|
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Published on npm as `@nxxxsooo/opencode-annotate`. It replaces `opencode-plannot
|
|
|
24
24
|
/annotate ~/Documents/notes.txt Review a plain-text document
|
|
25
25
|
/annotate-pick Choose a recent reply or mid-turn progress update
|
|
26
26
|
/annotate-selection Review the message containing your last transcript selection
|
|
27
|
-
/annotate-web
|
|
27
|
+
/annotate-web Pair this session, or create an empty one from home
|
|
28
28
|
/annotate-web page.html Review the specified local HTML in Chrome
|
|
29
29
|
/annotate-web https://example.com Review the specified webpage
|
|
30
30
|
/annotate-web off Revoke this session's browser pairing
|
|
@@ -54,6 +54,15 @@ Install the plugin:
|
|
|
54
54
|
opencode plugin add @nxxxsooo/opencode-annotate@latest
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
Update an existing installation explicitly:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
opencode plugin update @nxxxsooo/opencode-annotate@latest
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`@latest` selects the current npm release when installing or updating; publishing a
|
|
64
|
+
release does not itself replace an installed copy. Keep your existing plugin `options`.
|
|
65
|
+
|
|
57
66
|
OpenCode loads the server tools and TUI commands from one entry in your global
|
|
58
67
|
**`opencode.json`** or **`opencode.jsonc`**. Run `/reload` if the command list has not refreshed.
|
|
59
68
|
|
|
@@ -110,19 +119,10 @@ transcript index or database access is needed.
|
|
|
110
119
|
Permission actions are `annotate_session_search` (project ID, or `*` for cross-project
|
|
111
120
|
search) and `annotate_session_read` (source session ID).
|
|
112
121
|
|
|
113
|
-
### Reference
|
|
122
|
+
### Reference verification
|
|
114
123
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
| Decision | Basis |
|
|
119
|
-
| --- | --- |
|
|
120
|
-
| Integrate two agent tools and `/ref` into this package; verify locally | 2026-10-28 approval, `conversation-reference-subfeature` in [sources.json](sources.json) |
|
|
121
|
-
|
|
122
|
-
Verification completed in the implementation session: `npm run check` passed all 58
|
|
123
|
-
tests and the package dry-run; the existing `npm run test:smoke` passed; and
|
|
124
|
-
`npm run test:references` passed against source and an extracted npm package. The
|
|
125
|
-
reference checks cover pre-compaction history, API responses larger than 256 KiB,
|
|
124
|
+
`npm run test:references` exercises the server tools and `/ref` against source or an
|
|
125
|
+
extracted npm package. The checks cover pre-compaction history, API responses larger than 256 KiB,
|
|
126
126
|
pagination, long-message continuation, attachment and cancellation without a model
|
|
127
127
|
turn. Unit checks also cover tab changes, permission denial and private-file cleanup.
|
|
128
128
|
|
|
@@ -131,9 +131,7 @@ tools, and `session-reference.mjs` for bounded history. `server-history.mjs` cap
|
|
|
131
131
|
CLI output in private temporary files to avoid v2.2.0 pipe truncation, then removes
|
|
132
132
|
them. Regression entrypoints are `session-reference.test.mjs`,
|
|
133
133
|
`server-history.test.mjs` and `tests/references-smoke.py`; release ownership remains in
|
|
134
|
-
[docs/releasing.md](docs/releasing.md).
|
|
135
|
-
owned-reviewer changes under `tui/`; this feature's verification is not a release
|
|
136
|
-
receipt for those changes.
|
|
134
|
+
[docs/releasing.md](docs/releasing.md).
|
|
137
135
|
|
|
138
136
|
## Antigravity (AGY) support
|
|
139
137
|
|
|
@@ -173,7 +171,9 @@ Requirements: macOS and Chrome 116+, plus Node 22+ for the native host.
|
|
|
173
171
|
opens no HTTP port.
|
|
174
172
|
3. Reopen the OpenCode terminal client; the shared service needs no restart.
|
|
175
173
|
|
|
176
|
-
Run `/annotate-web
|
|
174
|
+
Run `/annotate-web`, then open the Chrome extension. From the blank home screen, it
|
|
175
|
+
creates an empty session in the current directory using the selected model; no first
|
|
176
|
+
prompt is needed. In an existing session, it pairs that session. A sole live
|
|
177
177
|
session is shown automatically; with several sessions, choose one once. Click the
|
|
178
178
|
destination beside **To** to change or refresh it. Its title stays visible beside Send,
|
|
179
179
|
including while disconnected, with its directory available on hover and in the chooser.
|
|
@@ -324,6 +324,40 @@ opencode plugin remove @nxxxsooo/opencode-annotate@latest
|
|
|
324
324
|
|
|
325
325
|
## Configuration
|
|
326
326
|
|
|
327
|
+
### Automatically review long replies
|
|
328
|
+
|
|
329
|
+
Enable auto-annotation in the plugin entry in **`opencode.jsonc`** (or `opencode.json`):
|
|
330
|
+
|
|
331
|
+
```jsonc
|
|
332
|
+
{
|
|
333
|
+
"$schema": "https://opencode.ai/config.json",
|
|
334
|
+
"plugins": [
|
|
335
|
+
{
|
|
336
|
+
"package": "@nxxxsooo/opencode-annotate@latest",
|
|
337
|
+
"options": {
|
|
338
|
+
"autoAnnotate": true,
|
|
339
|
+
"autoAnnotateThreshold": 2000, // Open when the reply exceeds this many characters.
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
Add these options to your existing entry, keeping any other options. Auto-annotation
|
|
347
|
+
is **off by default**; set `autoAnnotate` to `false` to disable it. The threshold defaults
|
|
348
|
+
to **2,000 characters** and accepts a non-negative integer; `0` reviews every non-empty
|
|
349
|
+
reply. It counts Unicode characters in the trimmed reply text, including Markdown and
|
|
350
|
+
code, excluding reasoning and tool output. A reply exactly at the threshold does not open.
|
|
351
|
+
|
|
352
|
+
After a successful turn, a new qualifying reply in the active session opens the normal
|
|
353
|
+
reviewer once. Progress updates, failed or interrupted turns, historical replies and
|
|
354
|
+
background sessions do not trigger it. A reply is skipped if another review is open,
|
|
355
|
+
you switch sessions before it opens, or a new turn starts. Dismissing the reviewer or
|
|
356
|
+
reloading the plugin does not reopen that reply. Sending remains your explicit action.
|
|
357
|
+
OpenCode reloads saved configuration automatically; use `/reload` if needed.
|
|
358
|
+
|
|
359
|
+
### Reviewer binary and layout
|
|
360
|
+
|
|
327
361
|
The bundled reviewer is selected automatically. Use `binary` only to override it with
|
|
328
362
|
another locally built Annotate TUI executable:
|
|
329
363
|
|
|
@@ -402,7 +436,7 @@ See [release instructions](docs/releasing.md) and [changelog](CHANGELOG.md).
|
|
|
402
436
|
- `/annotate-selection`:先在会话里拖选文字,再批注包含这段文字的消息。
|
|
403
437
|
- `/annotate-last`:固定批注最新一条完整回复,忽略附带参数。
|
|
404
438
|
- `/ref`:选择并引用同项目的历史会话;`/ref --all 关键词` 跨项目搜索;`/ref ses_…` 直接指定。确认后附加上下文,不启动空闲助手。
|
|
405
|
-
- `/annotate-web`:配对 Chrome
|
|
439
|
+
- `/annotate-web`:配对 Chrome;空白首页会先创建空会话,无需先发提示词。`/annotate-web 页面.html`、`/annotate-web https://…` 批注网页;`/annotate-web off` 撤销配对。
|
|
406
440
|
- 选中文字 → `c` 写批注 → Enter 保存 → `q` 发送并返回。
|
|
407
441
|
- 写批注中途按 `Ctrl+S`,一步保存、返回并发送(中文输入法开着也有效);`Ctrl+C` 返回后由 OpenCode 询问。
|
|
408
442
|
- 文档采用独立快照,反馈附原文件路径,确认后发回发起批注的会话。
|
package/auto-review.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const defaultThreshold = 2000
|
|
2
|
+
|
|
3
|
+
export function autoReviewOptions(options) {
|
|
4
|
+
const enabled = options.autoAnnotate === undefined ? false : options.autoAnnotate
|
|
5
|
+
const threshold = options.autoAnnotateThreshold === undefined ? defaultThreshold : options.autoAnnotateThreshold
|
|
6
|
+
if (typeof enabled !== "boolean") throw new Error("autoAnnotate must be true or false.")
|
|
7
|
+
if (!Number.isSafeInteger(threshold) || threshold < 0) {
|
|
8
|
+
throw new Error("autoAnnotateThreshold must be a non-negative integer (characters).")
|
|
9
|
+
}
|
|
10
|
+
return { enabled, threshold }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function createAutoReview(context, review) {
|
|
14
|
+
let config
|
|
15
|
+
try {
|
|
16
|
+
config = autoReviewOptions(context.options)
|
|
17
|
+
} catch (error) {
|
|
18
|
+
context.ui.toast.show({
|
|
19
|
+
title: "Annotate", message: error.message, variant: "error", duration: 15000,
|
|
20
|
+
})
|
|
21
|
+
return () => {}
|
|
22
|
+
}
|
|
23
|
+
if (!config.enabled) return () => {}
|
|
24
|
+
|
|
25
|
+
// Reloading configuration must not offer the same completed reply again.
|
|
26
|
+
const [state, update] = context.storage.memory("auto-review", { initial: { handled: {} } })
|
|
27
|
+
const pending = new Map()
|
|
28
|
+
let disposed = false
|
|
29
|
+
const clear = event => pending.delete(event.data.sessionID)
|
|
30
|
+
const stops = [
|
|
31
|
+
context.data.on("session.step.ended", event => {
|
|
32
|
+
const { sessionID, assistantMessageID, finish } = event.data
|
|
33
|
+
pending.delete(sessionID)
|
|
34
|
+
const route = context.ui.router.current()
|
|
35
|
+
if (route.type !== "session" || route.sessionID !== sessionID) return
|
|
36
|
+
if (["tool-calls", "error", "content-filter"].includes(finish)) return
|
|
37
|
+
pending.set(sessionID, assistantMessageID)
|
|
38
|
+
}),
|
|
39
|
+
context.data.on("session.execution.succeeded", async event => {
|
|
40
|
+
if (disposed) return
|
|
41
|
+
const { sessionID } = event.data
|
|
42
|
+
const messageID = pending.get(sessionID)
|
|
43
|
+
if (!messageID) return
|
|
44
|
+
const key = `${sessionID}:${messageID}`
|
|
45
|
+
if (state.handled[key]) return
|
|
46
|
+
// Claim before awaiting: duplicate events and dismissal must not reopen it.
|
|
47
|
+
update(draft => { draft.handled[key] = true })
|
|
48
|
+
// Let the host apply its idle status before checking whether it is safe to open.
|
|
49
|
+
await Promise.resolve()
|
|
50
|
+
const current = () => !disposed && pending.get(sessionID) === messageID
|
|
51
|
+
if (current()) await review.auto(sessionID, messageID, config.threshold, current)
|
|
52
|
+
if (current()) pending.delete(sessionID)
|
|
53
|
+
}),
|
|
54
|
+
context.data.on("session.execution.started", clear),
|
|
55
|
+
context.data.on("session.execution.failed", clear),
|
|
56
|
+
context.data.on("session.execution.interrupted", clear),
|
|
57
|
+
context.data.on("session.deleted", clear),
|
|
58
|
+
]
|
|
59
|
+
return () => {
|
|
60
|
+
disposed = true
|
|
61
|
+
pending.clear()
|
|
62
|
+
for (const stop of stops) stop()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// OpenCode 2.2's server inventory supplies the TUI package, but drops its options.
|
|
2
|
+
// Carry only this plugin's effective options through the official location-scoped RPC.
|
|
3
|
+
export const configurationRPC = {
|
|
4
|
+
id: "annotate.configuration",
|
|
5
|
+
methods: {
|
|
6
|
+
get: { input: { type: "object", additionalProperties: false }, output: { type: "object", additionalProperties: true } },
|
|
7
|
+
},
|
|
8
|
+
events: { updated: { schema: { type: "object", additionalProperties: false } } },
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function registerConfiguration(context) {
|
|
12
|
+
const registration = await context.rpc.register(configurationRPC, { get: async () => context.options })
|
|
13
|
+
await registration.events.emit("updated", {})
|
|
14
|
+
return registration
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function watchConfiguration(context, apply) {
|
|
18
|
+
const local = context.options
|
|
19
|
+
const rpc = context.client.rpc(configurationRPC)
|
|
20
|
+
let disposed = false
|
|
21
|
+
let generation = 0
|
|
22
|
+
let controller
|
|
23
|
+
const refresh = async () => {
|
|
24
|
+
const request = ++generation
|
|
25
|
+
controller?.abort()
|
|
26
|
+
controller = new AbortController()
|
|
27
|
+
try {
|
|
28
|
+
const options = await rpc.get({}, {
|
|
29
|
+
location: context.location ?? context.data.location.default(), signal: controller.signal,
|
|
30
|
+
})
|
|
31
|
+
if (!disposed && request === generation) apply({ ...options, ...local })
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (disposed || request !== generation) return
|
|
34
|
+
// A CLI-only installation has no server part; its local options are authoritative.
|
|
35
|
+
if (error.type === "rpc.unavailable") return apply(local)
|
|
36
|
+
context.ui.toast.show({
|
|
37
|
+
title: "Annotate", message: `Can't load plugin configuration: ${error.message ?? String(error)}`,
|
|
38
|
+
variant: "error", duration: 15000,
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const stops = [
|
|
43
|
+
context.data.on("plugin.updated", () => { void refresh() }),
|
|
44
|
+
context.data.on("rpc.annotate.configuration.updated", () => { void refresh() }),
|
|
45
|
+
]
|
|
46
|
+
const ready = refresh()
|
|
47
|
+
return {
|
|
48
|
+
ready,
|
|
49
|
+
dispose() {
|
|
50
|
+
disposed = true
|
|
51
|
+
generation++
|
|
52
|
+
controller?.abort()
|
|
53
|
+
for (const stop of stops) stop()
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxxxsooo/opencode-annotate",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Unofficial OpenCode plugin: annotate replies, documents and webpages, and reference previous conversations.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"session-reference.mjs",
|
|
39
39
|
"reference-command.mjs",
|
|
40
40
|
"review.mjs",
|
|
41
|
+
"auto-review.mjs",
|
|
42
|
+
"configuration.mjs",
|
|
41
43
|
"theme.mjs",
|
|
42
44
|
"input-source.mjs",
|
|
43
45
|
"targets.mjs",
|
package/review.mjs
CHANGED
|
@@ -170,14 +170,14 @@ export function createReviewCommand(context, options = {}) {
|
|
|
170
170
|
// run, so keep the last one per session.
|
|
171
171
|
context.renderer.on("selection", remember)
|
|
172
172
|
|
|
173
|
-
async function start(resolve) {
|
|
173
|
+
async function start(resolve, { automatic, home = false } = {}) {
|
|
174
174
|
if (disposed) return
|
|
175
|
+
if (automatic && (active || !automatic())) return
|
|
175
176
|
if (active) return notice("An annotation is already in progress.")
|
|
176
177
|
// Capture before the first await: changing tabs must never redirect a review.
|
|
177
178
|
const route = context.ui.router.current()
|
|
178
|
-
if (route.type !== "session") return notice("Open a session first.")
|
|
179
|
-
const sessionID = route.sessionID
|
|
180
|
-
const title = context.data.session.get(sessionID)?.title ?? sessionID
|
|
179
|
+
if (route.type !== "session" && !(home && route.type === "home")) return notice("Open a session first.")
|
|
180
|
+
const sessionID = route.type === "session" ? route.sessionID : undefined
|
|
181
181
|
const controller = new AbortController()
|
|
182
182
|
active = controller
|
|
183
183
|
let directory
|
|
@@ -185,6 +185,8 @@ export function createReviewCommand(context, options = {}) {
|
|
|
185
185
|
try {
|
|
186
186
|
const source = await resolve({ sessionID, signal: controller.signal })
|
|
187
187
|
if (controller.signal.aborted || !source) return
|
|
188
|
+
if (automatic && !automatic()) return
|
|
189
|
+
const title = context.data.session.get(sessionID)?.title ?? sessionID
|
|
188
190
|
|
|
189
191
|
directory = await mkdtemp(path.join(options.tempRoot ?? os.tmpdir(), "opencode-annotate-"))
|
|
190
192
|
keepDraft = true
|
|
@@ -216,6 +218,10 @@ export function createReviewCommand(context, options = {}) {
|
|
|
216
218
|
// The reviewer writes "send" here when q or Ctrl+S quits with notes.
|
|
217
219
|
const intentPath = path.join(directory, "send-intent")
|
|
218
220
|
env.PLANNOTATOR_TUI_SEND_INTENT = intentPath
|
|
221
|
+
if (automatic && !automatic()) {
|
|
222
|
+
keepDraft = false
|
|
223
|
+
return
|
|
224
|
+
}
|
|
219
225
|
context.ui.dialog.clear()
|
|
220
226
|
// Review keys are single letters an input method would swallow: browse in ASCII, and
|
|
221
227
|
// let a capable binary switch back to the user's source while a comment is written.
|
|
@@ -224,9 +230,18 @@ export function createReviewCommand(context, options = {}) {
|
|
|
224
230
|
env.PLANNOTATOR_TUI_INPUT_SOURCE = inputSource.command
|
|
225
231
|
env.PLANNOTATOR_TUI_TEXT_INPUT_SOURCE = textSource
|
|
226
232
|
}
|
|
233
|
+
if (automatic && !automatic()) {
|
|
234
|
+
await inputSource.select(textSource)
|
|
235
|
+
keepDraft = false
|
|
236
|
+
return
|
|
237
|
+
}
|
|
227
238
|
// OpenCode 2.1.1+ suspends and resumes asynchronously; resume forces a full repaint.
|
|
228
239
|
await context.renderer.suspend()
|
|
229
240
|
try {
|
|
241
|
+
if (automatic && !automatic()) {
|
|
242
|
+
keepDraft = false
|
|
243
|
+
return
|
|
244
|
+
}
|
|
230
245
|
await runInteractive({ binary, file, cwd: directory, env, signal: controller.signal })
|
|
231
246
|
} finally {
|
|
232
247
|
await inputSource.select(textSource)
|
|
@@ -307,6 +322,17 @@ export function createReviewCommand(context, options = {}) {
|
|
|
307
322
|
return reply
|
|
308
323
|
})
|
|
309
324
|
|
|
325
|
+
const auto = (sessionID, messageID, threshold, current = () => true) => start(async ({ signal }) => {
|
|
326
|
+
const message = await context.client.session.message.get({ sessionID, messageID }, { signal, headers: uncompressed })
|
|
327
|
+
const source = selectReply([message])
|
|
328
|
+
// Count Unicode characters, including Markdown, rather than bytes or UTF-16 units.
|
|
329
|
+
if (source && [...source.text.trim()].length > threshold) return source
|
|
330
|
+
}, { automatic: () => {
|
|
331
|
+
const route = context.ui.router.current()
|
|
332
|
+
return current() && route.type === "session" && route.sessionID === sessionID
|
|
333
|
+
&& context.data.session.status(sessionID) === "idle"
|
|
334
|
+
} })
|
|
335
|
+
|
|
310
336
|
const pick = () => start(async ({ sessionID, signal }) => {
|
|
311
337
|
const texts = await recentTexts(context.client, sessionID, signal, 30)
|
|
312
338
|
if (!texts.length) {
|
|
@@ -335,15 +361,18 @@ export function createReviewCommand(context, options = {}) {
|
|
|
335
361
|
return texts.find(text => compact(text.text).includes(needle)) ?? { text: selected, selection: true }
|
|
336
362
|
})
|
|
337
363
|
|
|
338
|
-
const webReview = (input = "") =>
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
364
|
+
const webReview = (input = "") => {
|
|
365
|
+
const value = input.trim()
|
|
366
|
+
const target = value === "" ? "web" : value === "off" ? "web off" : value
|
|
367
|
+
return start(async ({ sessionID, signal }) => {
|
|
368
|
+
if (!(await web.run(target, sessionID, signal))) {
|
|
369
|
+
throw new Error("Use a webpage URL, an HTML file, or off.")
|
|
370
|
+
}
|
|
371
|
+
}, { home: target !== "web off" })
|
|
372
|
+
}
|
|
344
373
|
|
|
345
374
|
return {
|
|
346
|
-
run, pick, selection: annotateSelection, web: webReview,
|
|
375
|
+
run, auto, pick, selection: annotateSelection, web: webReview,
|
|
347
376
|
dispose() {
|
|
348
377
|
context.renderer.off("selection", remember)
|
|
349
378
|
disposed = true
|
package/server.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Plugin } from "@opencode/plugin"
|
|
2
2
|
import { registerSessionTools } from "./session-tools.mjs"
|
|
3
|
+
import { registerConfiguration } from "./configuration.mjs"
|
|
3
4
|
|
|
4
5
|
export default Plugin.define({
|
|
5
6
|
id: "opencode-annotate",
|
|
6
7
|
async setup(context) {
|
|
8
|
+
await registerConfiguration(context)
|
|
7
9
|
await registerSessionTools(context)
|
|
8
10
|
},
|
|
9
11
|
})
|
package/tui/README.md
CHANGED
|
@@ -67,10 +67,9 @@ Import provenance and the ownership decision are recorded in [sources.json](../s
|
|
|
67
67
|
|---|---|---|
|
|
68
68
|
| 2026-10-28 | Own the terminal reviewer inside `opencode-annotate/tui/`; build and distribute it with the plugin. | `tui-ownership-decision` in the source register. |
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
publication follow the repository's [release process](../docs/releasing.md).
|
|
70
|
+
The integrated reviewer first shipped in **0.10.0**, with successful native CI on all
|
|
71
|
+
five supported platforms and verified npm executable bytes. Isolated OpenCode reviews
|
|
72
|
+
passed with theme inheritance, one-key sends, cancellation and captured-session delivery.
|
|
73
|
+
The redundant reviewer repository and local checkout were removed on 2026-10-29 after
|
|
74
|
+
publication verification; recoverable history is retained privately. `tui/` is the sole
|
|
75
|
+
maintained source. Releases follow the repository's [release process](../docs/releasing.md).
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/tui.ts
CHANGED
|
@@ -2,12 +2,31 @@ import { Plugin } from "@opencode/plugin/tui"
|
|
|
2
2
|
import { createReviewCommand } from "./review.mjs"
|
|
3
3
|
import { createAsciiHold, createInputSource } from "./input-source.mjs"
|
|
4
4
|
import { createReferenceCommand } from "./reference-command.mjs"
|
|
5
|
+
import { createAutoReview } from "./auto-review.mjs"
|
|
6
|
+
import { watchConfiguration } from "./configuration.mjs"
|
|
5
7
|
|
|
6
8
|
export default Plugin.define({
|
|
7
9
|
id: "opencode-annotate",
|
|
8
|
-
setup(context) {
|
|
10
|
+
async setup(context) {
|
|
11
|
+
const host = context
|
|
12
|
+
let options = host.options
|
|
13
|
+
context = { ...host, get options() { return options } }
|
|
14
|
+
let restartAutoReview: (() => void) | undefined
|
|
15
|
+
let stopAutoReview = () => {}
|
|
16
|
+
const configuration = watchConfiguration(context, updated => {
|
|
17
|
+
const changed = options.autoAnnotate !== updated.autoAnnotate
|
|
18
|
+
|| options.autoAnnotateThreshold !== updated.autoAnnotateThreshold
|
|
19
|
+
options = updated
|
|
20
|
+
if (changed) restartAutoReview?.()
|
|
21
|
+
})
|
|
22
|
+
await configuration.ready
|
|
9
23
|
const inputSource = createInputSource(context.options.inputSource)
|
|
10
24
|
const review = createReviewCommand(context, { inputSource })
|
|
25
|
+
restartAutoReview = () => {
|
|
26
|
+
stopAutoReview()
|
|
27
|
+
stopAutoReview = createAutoReview(context, review)
|
|
28
|
+
}
|
|
29
|
+
restartAutoReview()
|
|
11
30
|
const reference = createReferenceCommand(context)
|
|
12
31
|
// Permission prompts answer with single letters, which an input method swallows.
|
|
13
32
|
const hold = createAsciiHold(inputSource)
|
|
@@ -56,7 +75,7 @@ export default Plugin.define({
|
|
|
56
75
|
}, {
|
|
57
76
|
id: "opencode-annotate.annotate-web",
|
|
58
77
|
title: "Annotate webpage (browser)",
|
|
59
|
-
description: "Pair Chrome
|
|
78
|
+
description: "Pair Chrome (creates a session if needed), open a URL or HTML file, or off",
|
|
60
79
|
group: "Annotate",
|
|
61
80
|
palette: true,
|
|
62
81
|
slash: { name: "annotate-web", arguments: true },
|
|
@@ -77,6 +96,8 @@ export default Plugin.define({
|
|
|
77
96
|
return () => {
|
|
78
97
|
stopAsked()
|
|
79
98
|
stopReplied()
|
|
99
|
+
configuration.dispose()
|
|
100
|
+
stopAutoReview()
|
|
80
101
|
review.dispose()
|
|
81
102
|
reference.dispose()
|
|
82
103
|
unmount()
|
package/web-review.mjs
CHANGED
|
@@ -8,16 +8,34 @@ export function createWebReview(context, options = {}) {
|
|
|
8
8
|
const receivers = new Map()
|
|
9
9
|
let disposed = false
|
|
10
10
|
return {
|
|
11
|
-
async run(input, sessionID) {
|
|
11
|
+
async run(input, sessionID, signal) {
|
|
12
12
|
if (input.trim() === "web off") {
|
|
13
13
|
await receivers.get(sessionID)?.close(); receivers.delete(sessionID)
|
|
14
14
|
context.ui.toast.show({ title: "Annotate web", message: "Browser pairing revoked for this session." })
|
|
15
15
|
return true
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
// Home has no session until the first prompt. Capture its location/model before
|
|
18
|
+
// awaiting, then create an empty destination without sending a prompt.
|
|
19
|
+
const route = context.ui.router.current()
|
|
20
|
+
const location = sessionID ? undefined : context.location ?? context.data.location.default()
|
|
21
|
+
const selected = sessionID ? undefined : context.ui.model.current()
|
|
22
|
+
const model = selected && { providerID: selected.providerID, id: selected.modelID, variant: selected.variant }
|
|
23
|
+
let session = sessionID ? await context.client.session.get({ sessionID }, { signal }) : undefined
|
|
24
|
+
const target = await browserTarget(input, session ? session.location?.directory : location?.directory)
|
|
19
25
|
if (!target) return false
|
|
20
26
|
if (disposed) throw new Error("Annotation plugin is closed")
|
|
27
|
+
signal?.throwIfAborted()
|
|
28
|
+
if (!session) {
|
|
29
|
+
if (!location?.directory) throw new Error("Can't determine the working directory for a new session.")
|
|
30
|
+
session = await context.client.session.create({ location, ...(model ? { model } : {}) }, { signal })
|
|
31
|
+
if (disposed || signal?.aborted) return true
|
|
32
|
+
sessionID = session.id
|
|
33
|
+
// A tab switch during creation must not steal focus back from the user.
|
|
34
|
+
if (context.ui.router.current() === route) {
|
|
35
|
+
context.ui.dialog.clear()
|
|
36
|
+
context.ui.router.navigate({ type: "session", sessionID })
|
|
37
|
+
}
|
|
38
|
+
}
|
|
21
39
|
if (!receivers.has(sessionID)) {
|
|
22
40
|
const receiver = await createReceiver({ sessionID, title: session.title || sessionID, directory: session.location?.directory || "", client: context.client, ...options.receiver })
|
|
23
41
|
if (disposed) { await receiver.close(); return true }
|