@nxxxsooo/opencode-annotate 0.9.1 → 0.10.1
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 +32 -0
- package/README.md +165 -71
- package/agy/cli.mjs +7 -25
- package/agy/cli.test.mjs +8 -16
- package/agy/skills/annotate/SKILL.md +5 -5
- package/agy/skills/annotate/agents/openai.yaml +3 -0
- package/auto-review.mjs +64 -0
- package/configuration.mjs +56 -0
- package/package.json +24 -5
- package/reference-command.mjs +80 -0
- package/review.mjs +45 -15
- package/scripts/verify-tui.mjs +16 -0
- package/server-history.mjs +58 -0
- package/server.ts +11 -0
- package/session-reference.mjs +109 -0
- package/session-tools.mjs +55 -0
- package/theme.mjs +3 -3
- package/tui/LICENSE +21 -0
- package/tui/README.md +75 -0
- 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/binary.mjs +19 -0
- package/tui/run.mjs +15 -0
- package/tui.ts +35 -3
- package/web-review.mjs +21 -3
package/theme.mjs
CHANGED
|
@@ -96,10 +96,10 @@ export async function prepareTheme({ binary, theme, directory, env, signal }) {
|
|
|
96
96
|
cwd: directory, env: environment, signal, timeout: 15000, maxBuffer: 1024 * 1024,
|
|
97
97
|
})
|
|
98
98
|
const { stdout } = await config(env)
|
|
99
|
-
// The
|
|
99
|
+
// The reviewer's `config` command serializes its strict schema with [colors] last.
|
|
100
100
|
// Work on that normalized output, never try to parse or rewrite the user's TOML.
|
|
101
101
|
const marker = stdout.lastIndexOf("\n[colors]\n")
|
|
102
|
-
if (marker < 0) throw new Error("
|
|
102
|
+
if (marker < 0) throw new Error("Annotate TUI did not return its color configuration. Check the plugin's binary option.")
|
|
103
103
|
const filename = path.join(directory, "theme.toml")
|
|
104
104
|
const palette = Object.entries(colors).map(([role, value]) => `${role} = "${value}"`).join("\n")
|
|
105
105
|
await writeFile(filename, `${stdout.slice(0, marker)}\n\n[colors]\n${palette}\n`, { mode: 0o600 })
|
|
@@ -108,7 +108,7 @@ export async function prepareTheme({ binary, theme, directory, env, signal }) {
|
|
|
108
108
|
// Also catches launchers that overwrite PLANNOTATOR_TUI_CONFIG instead of honoring it.
|
|
109
109
|
for (const [role, value] of Object.entries(colors)) {
|
|
110
110
|
if (!new RegExp(`^${role} = "${value}"$`, "mi").test(effective.stdout)) {
|
|
111
|
-
throw new Error(`
|
|
111
|
+
throw new Error(`Annotate TUI did not apply ${role}. Its launcher must honor PLANNOTATOR_TUI_CONFIG.`)
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
return themed
|
package/tui/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Michael Ramos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/tui/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Annotate TUI
|
|
2
|
+
|
|
3
|
+
The terminal reviewer is an owned component of **OpenCode Annotate**. Source, tests,
|
|
4
|
+
builds and releases live in this repository; `tui/` is an ordinary subfolder.
|
|
5
|
+
|
|
6
|
+
## Source and build
|
|
7
|
+
|
|
8
|
+
- `src/`: terminal UI, Markdown layout, source mapping, comments, selection and export.
|
|
9
|
+
- `schema/`: annotation types and anchor resolution.
|
|
10
|
+
- `hosts/`: local transcript readers used by standalone review commands.
|
|
11
|
+
- `tests/`: command-line integration tests; unit tests live alongside the Rust modules.
|
|
12
|
+
- `binary.mjs`: one package-relative executable resolver shared by OpenCode and AGY.
|
|
13
|
+
|
|
14
|
+
From the repository root (Rust 1.96+ and Node 22+):
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm run build:tui
|
|
18
|
+
npm run check:tui
|
|
19
|
+
node tui/run.mjs --version
|
|
20
|
+
node tui/run.mjs document.md
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Builds land in `tui/bin/<platform>-<arch>/annotate-tui` (`.exe` on Windows). The npm release
|
|
24
|
+
contains all supported executables; normal use needs neither Cargo nor another TUI install.
|
|
25
|
+
CI builds and tests macOS arm64/x64, Linux x64/arm64 and Windows x64 from these sources.
|
|
26
|
+
Linux x64 and arm64 target Ubuntu 22.04/glibc 2.35+.
|
|
27
|
+
Windows native tests run in CI; the OpenCode terminal handoff still needs Windows validation.
|
|
28
|
+
|
|
29
|
+
## Configuration and delivery
|
|
30
|
+
|
|
31
|
+
User layout and key settings live in `~/.config/opencode-annotate/tui.toml`
|
|
32
|
+
(`%APPDATA%/opencode-annotate/tui.toml` on Windows). A comfortable layout:
|
|
33
|
+
|
|
34
|
+
```toml
|
|
35
|
+
[ui]
|
|
36
|
+
horizontal_margin = 2
|
|
37
|
+
max_width = 168
|
|
38
|
+
doc_width = 120
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Hosted reviews write their send intent for the adapter: `q` sends notes and returns,
|
|
42
|
+
`Ctrl+S` also saves an open comment, and `Ctrl+C` returns to the adapter's confirmation.
|
|
43
|
+
The adapters own session targeting and delivery. Markdown labels such as `**题库:**把`
|
|
44
|
+
render in bold while selections still map to original source bytes.
|
|
45
|
+
|
|
46
|
+
The `PLANNOTATOR_*` environment names, internal library identifiers and annotation JSON
|
|
47
|
+
keys remain stable so existing retained drafts can be recovered. They do not fetch or
|
|
48
|
+
load anything from another project. `PLANNOTATOR_TUI_CONFIG` selects a private per-review
|
|
49
|
+
theme copy; the user's file stays intact.
|
|
50
|
+
|
|
51
|
+
Standalone annotation data defaults to `~/.local/share/opencode-annotate/tui`
|
|
52
|
+
(`%LOCALAPPDATA%/opencode-annotate/tui` on Windows). Hosted reviews use their own private
|
|
53
|
+
snapshot stores. An explicit `PLANNOTATOR_DATA_DIR` can still open a retained older draft.
|
|
54
|
+
|
|
55
|
+
## Ownership and provenance
|
|
56
|
+
|
|
57
|
+
This code was imported from the customized Plannotator TUI 0.9.4 codebase at source commit
|
|
58
|
+
`7615edea2fd2648ebaeaec50c1c75940408f361b`, including theme, viewport, input-method, send-key
|
|
59
|
+
and Markdown fixes. Subsequent development belongs here. There is no upstream remote,
|
|
60
|
+
submodule, registry dependency on Plannotator, download step or update/sync relationship.
|
|
61
|
+
Normal third-party Rust libraries are pinned in `Cargo.lock`.
|
|
62
|
+
|
|
63
|
+
Original MIT copyright and permission notices are preserved in [LICENSE](LICENSE).
|
|
64
|
+
Import provenance and the ownership decision are recorded in [sources.json](../sources.json).
|
|
65
|
+
|
|
66
|
+
| Date | Decision | Basis |
|
|
67
|
+
|---|---|---|
|
|
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
|
+
|
|
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/binary.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url"
|
|
2
|
+
|
|
3
|
+
export const platforms = {
|
|
4
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
5
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
6
|
+
"linux-arm64": "aarch64-unknown-linux-gnu",
|
|
7
|
+
"linux-x64": "x86_64-unknown-linux-gnu",
|
|
8
|
+
"win32-x64": "x86_64-pc-windows-msvc",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function bundledBinary(platform = `${process.platform}-${process.arch}`) {
|
|
12
|
+
if (!platforms[platform]) throw new Error(`Annotate TUI has no bundled executable for ${platform}. Set the binary option to a local build.`)
|
|
13
|
+
const extension = platform.startsWith("win32-") ? ".exe" : ""
|
|
14
|
+
return fileURLToPath(new URL(`./bin/${platform}/annotate-tui${extension}`, import.meta.url))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function resolveTuiBinary(customBinary) {
|
|
18
|
+
return customBinary ?? bundledBinary()
|
|
19
|
+
}
|
package/tui/run.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process"
|
|
3
|
+
import { bundledBinary } from "./binary.mjs"
|
|
4
|
+
|
|
5
|
+
const child = spawn(bundledBinary(), process.argv.slice(2), { stdio: "inherit" })
|
|
6
|
+
child.on("error", error => {
|
|
7
|
+
console.error(error.code === "ENOENT"
|
|
8
|
+
? "Annotate TUI is missing. In a checkout, run npm run build:tui; otherwise reinstall the package."
|
|
9
|
+
: error.message)
|
|
10
|
+
process.exitCode = 1
|
|
11
|
+
})
|
|
12
|
+
child.on("exit", (code, signal) => {
|
|
13
|
+
if (signal) process.kill(process.pid, signal)
|
|
14
|
+
else process.exitCode = code ?? 1
|
|
15
|
+
})
|
package/tui.ts
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
import { Plugin } from "@opencode/plugin/tui"
|
|
2
2
|
import { createReviewCommand } from "./review.mjs"
|
|
3
3
|
import { createAsciiHold, createInputSource } from "./input-source.mjs"
|
|
4
|
+
import { createReferenceCommand } from "./reference-command.mjs"
|
|
5
|
+
import { createAutoReview } from "./auto-review.mjs"
|
|
6
|
+
import { watchConfiguration } from "./configuration.mjs"
|
|
4
7
|
|
|
5
8
|
export default Plugin.define({
|
|
6
9
|
id: "opencode-annotate",
|
|
7
|
-
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
|
|
8
23
|
const inputSource = createInputSource(context.options.inputSource)
|
|
9
24
|
const review = createReviewCommand(context, { inputSource })
|
|
25
|
+
restartAutoReview = () => {
|
|
26
|
+
stopAutoReview()
|
|
27
|
+
stopAutoReview = createAutoReview(context, review)
|
|
28
|
+
}
|
|
29
|
+
restartAutoReview()
|
|
30
|
+
const reference = createReferenceCommand(context)
|
|
10
31
|
// Permission prompts answer with single letters, which an input method swallows.
|
|
11
32
|
const hold = createAsciiHold(inputSource)
|
|
12
33
|
const stopAsked = context.data.on("permission.asked", event => hold.enter(event.data.id))
|
|
@@ -28,7 +49,7 @@ export default Plugin.define({
|
|
|
28
49
|
}, {
|
|
29
50
|
id: "opencode-annotate.annotate-last",
|
|
30
51
|
title: "Annotate last reply (TUI)",
|
|
31
|
-
description: "Annotate the latest completed reply; q sends
|
|
52
|
+
description: "Annotate the latest completed reply; q sends and returns",
|
|
32
53
|
group: "Annotate",
|
|
33
54
|
palette: true,
|
|
34
55
|
// Keep slash submission with a trailing space local to the command.
|
|
@@ -54,11 +75,19 @@ export default Plugin.define({
|
|
|
54
75
|
}, {
|
|
55
76
|
id: "opencode-annotate.annotate-web",
|
|
56
77
|
title: "Annotate webpage (browser)",
|
|
57
|
-
description: "Pair Chrome
|
|
78
|
+
description: "Pair Chrome (creates a session if needed), open a URL or HTML file, or off",
|
|
58
79
|
group: "Annotate",
|
|
59
80
|
palette: true,
|
|
60
81
|
slash: { name: "annotate-web", arguments: true },
|
|
61
82
|
run: review.web,
|
|
83
|
+
}, {
|
|
84
|
+
id: "opencode-annotate.ref",
|
|
85
|
+
title: "Reference another conversation",
|
|
86
|
+
description: "Attach a past conversation by title or session ID; --all searches across projects",
|
|
87
|
+
group: "Annotate",
|
|
88
|
+
palette: true,
|
|
89
|
+
slash: { name: "ref", arguments: true },
|
|
90
|
+
run: reference.run,
|
|
62
91
|
}],
|
|
63
92
|
}))
|
|
64
93
|
return null
|
|
@@ -67,7 +96,10 @@ export default Plugin.define({
|
|
|
67
96
|
return () => {
|
|
68
97
|
stopAsked()
|
|
69
98
|
stopReplied()
|
|
99
|
+
configuration.dispose()
|
|
100
|
+
stopAutoReview()
|
|
70
101
|
review.dispose()
|
|
102
|
+
reference.dispose()
|
|
71
103
|
unmount()
|
|
72
104
|
}
|
|
73
105
|
},
|
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 }
|