@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.
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: annotate
3
- description: Review assistant replies or local documents in the bundled Annotate TUI, or pair the Chrome companion for webpage annotation. Use for /annotate, /annotate-web, reply/document annotation, or webpage review in an AGY session.
3
+ description: Review assistant replies or local documents in the bundled Annotate TUI, or connect the Chrome companion for webpage annotation. Use for /annotate, reply/document annotation, or webpage review in an AGY session.
4
4
  ---
5
5
 
6
6
  # Annotate (`agy-annotate`)
7
7
 
8
- Use this skill when the user runs `/annotate`, `/annotate-web`, or asks to annotate assistant responses, documents, or webpages.
8
+ Use this skill when the user runs `/annotate` or asks to annotate assistant responses, documents, or webpages.
9
9
 
10
10
  ## Execution Guide for the Agent:
11
11
 
@@ -22,7 +22,7 @@ Run the command:
22
22
  npx --yes --package @nxxxsooo/opencode-annotate@latest agy-annotate tui "<path/to/doc.md>"
23
23
  ```
24
24
 
25
- ### 3. When the user types `/annotate-web` (or provides a URL/HTML file):
25
+ ### 3. When the user provides a URL/HTML file (e.g., `/annotate page.html`) or asks for webpage review:
26
26
  Run the command:
27
27
  ```bash
28
28
  npx --yes --package @nxxxsooo/opencode-annotate@latest agy-annotate web [url-or-html-path]
@@ -16,12 +16,15 @@ decodeStream(process.stdin, async message => {
16
16
  const targets = await listTargets(config.targetsDirectory)
17
17
  if (message.action === "targets") {
18
18
  const live = await Promise.all(targets.map(async target => {
19
- try { return (await request(target.socket, { action: "info", targetID: target.id })).target } catch { return null }
19
+ try {
20
+ const result = await request(target.socket, { action: "info", targetID: target.id })
21
+ return result.ok && result.target ? result.target : null
22
+ } catch { return null }
20
23
  }))
21
24
  response = { ok: true, targets: live.filter(Boolean) }
22
25
  } else {
23
26
  const target = targets.find(target => target.id === message.targetID)
24
- if (!target) throw new Error("Paired session is offline; run /annotate-web in it to reconnect")
27
+ if (!target) throw new Error("Paired session is offline; reopen it in OpenCode or AGY to reconnect")
25
28
  response = await request(target.socket, message)
26
29
  }
27
30
  } catch (error) { response = { ok: false, error: error.message } }
@@ -5,6 +5,7 @@ import os from "node:os"
5
5
  import path from "node:path"
6
6
  import { encode, decodeStream } from "./wire.mjs"
7
7
  import { markdown, validateReview } from "../browser/protocol.mjs"
8
+ import { feedbackInput } from "../delivery.mjs"
8
9
 
9
10
  export const registryRoot = () => path.join(os.homedir(), ".local/share/opencode-annotate/targets")
10
11
  export async function listTargets(root = registryRoot()) {
@@ -24,14 +25,24 @@ export async function listTargets(root = registryRoot()) {
24
25
  }
25
26
  return results
26
27
  }
27
- export async function createReceiver({ sessionID, title, directory, provider = "opencode", deliver, client, root = registryRoot(), resume = true, onError = () => {} }) {
28
+ export async function createReceiver({ sessionID, title, directory, provider = "opencode", deliver, client, getInfo, createSession, root = registryRoot(), resume = true, onError = () => {} }) {
28
29
  await mkdir(root, { recursive: true, mode: 0o700 }); await chmod(root, 0o700)
29
- const id = randomUUID(), socketPath = path.join(root, `${id}.sock`)
30
+ const id = randomUUID(), registered = Date.now(), socketPath = path.join(root, `${id}.sock`)
30
31
  // macOS sockaddr_un is limited to 104 bytes, including the NUL terminator.
31
32
  if (Buffer.byteLength(socketPath) > 103) throw new Error("Annotation socket path is too long")
32
- const target = { id, title, directory, sessionID, provider, socket: socketPath, pid: process.pid }
33
- const received = new Map(), sockets = new Set()
34
- let closed = false
33
+ const kind = sessionID ? "session" : "workspace"
34
+ const target = { id, title, directory, sessionID, provider, kind, socket: socketPath, pid: process.pid }
35
+ const received = new Map(), creations = new Map(), sockets = new Set()
36
+ let closed = false, connected = !!sessionID
37
+ async function info() {
38
+ if (closed) throw new Error("Annotation connection is closed")
39
+ const extra = getInfo ? await getInfo() : {}
40
+ if (extra === null) return null
41
+ const session = client && sessionID ? await client.session.get({ sessionID }) : undefined
42
+ const time = session?.time ? { created: session.time.created, updated: session.time.updated } : {}
43
+ return { id, title: session?.title || title, directory, provider, sessionID, kind, registered,
44
+ ...time, ...extra, connected, canCreate: !!createSession }
45
+ }
35
46
  const server = net.createServer(socket => {
36
47
  let handled = false
37
48
  sockets.add(socket); socket.once("close", () => sockets.delete(socket)); socket.on("error", () => {})
@@ -42,12 +53,27 @@ export async function createReceiver({ sessionID, title, directory, provider = "
42
53
  try {
43
54
  if (closed || message.targetID !== id) throw new Error("Pairing is no longer active")
44
55
  if (message.action === "info") {
45
- if (client) await client.session.get({ sessionID })
46
- socket.end(encode({ ok: true, target: { id, title, directory, provider } })); return
56
+ // Registration happens before OpenCode generates a title; report the live one.
57
+ socket.end(encode({ ok: true, target: await info() })); return
58
+ }
59
+ if (["connect", "disconnect"].includes(message.action)) {
60
+ if (!sessionID) throw new Error("Create a session in this workspace first")
61
+ connected = message.action === "connect"
62
+ socket.end(encode({ ok: true, target: await info() })); return
63
+ }
64
+ if (message.action === "create-session") {
65
+ if (!createSession || !/^[a-f0-9-]{36}$/.test(message.requestID)) throw new Error("Invalid session creation request")
66
+ if (!creations.has(message.requestID)) {
67
+ const promise = Promise.resolve().then(createSession)
68
+ creations.set(message.requestID, promise)
69
+ promise.catch(() => creations.delete(message.requestID))
70
+ }
71
+ socket.end(encode({ ok: true, target: await creations.get(message.requestID) })); return
47
72
  }
73
+ if (!connected) throw new Error("Session disconnected; select it in Annotate to reconnect")
48
74
  if (message.action !== "send" || !/^[a-f0-9-]{36}$/.test(message.batchID)) throw new Error("Invalid delivery request")
49
- validateReview(message.review)
50
- const digest = createHash("sha256").update(JSON.stringify(message.review)).digest("hex")
75
+ const review = structuredClone(validateReview(message.review)), text = markdown(review)
76
+ const digest = createHash("sha256").update(JSON.stringify(review)).digest("hex")
51
77
  const existing = received.get(message.batchID)
52
78
  if (existing && existing.digest !== digest) throw new Error("Batch ID was reused with different content")
53
79
  if (!existing) {
@@ -55,11 +81,11 @@ export async function createReceiver({ sessionID, title, directory, provider = "
55
81
  const promptID = `msg_${createHash("sha256").update(`${id}:${message.batchID}`).digest("hex").slice(0, 32)}`
56
82
  const promise = (async () => {
57
83
  if (deliver) {
58
- const res = await deliver({ review: message.review, promptID, markdown: markdown(message.review), batchID: message.batchID })
84
+ const res = await deliver({ review, promptID, markdown: text, batchID: message.batchID })
59
85
  return { ok: true, messageID: res?.id || promptID, state: "admitted" }
60
86
  }
61
87
  await client.session.get({ sessionID })
62
- const response = await client.session.prompt({ sessionID, id: promptID, text: markdown(message.review), delivery: "queue", resume })
88
+ const response = await client.session.prompt(feedbackInput({ sessionID, id: promptID, text, resume }))
63
89
  return { ok: true, messageID: response?.id || promptID, state: "admitted" }
64
90
  })()
65
91
  received.set(message.batchID, { digest, promise })
@@ -75,7 +101,7 @@ export async function createReceiver({ sessionID, title, directory, provider = "
75
101
  const registration = path.join(root, `${id}.json`)
76
102
  try { await writeFile(registration, JSON.stringify(target), { mode: 0o600, flag: "wx" }) }
77
103
  catch (error) { await new Promise(resolve => server.close(resolve)); await rm(socketPath, { force: true }); throw error }
78
- return { target, async close() {
104
+ return { target, info, async close() {
79
105
  if (closed) return
80
106
  closed = true; for (const socket of sockets) socket.destroy()
81
107
  await new Promise(resolve => server.close(resolve))
@@ -6,4 +6,6 @@ Based on Asim Sayed's MIT-licensed [Annotate HTML](https://github.com/AsimSayed/
6
6
 
7
7
  `inspector.js` adapts the original element identification, computed-style snapshot, and accessibility collectors. This local enhancement replaces the in-page comment popup and volatile state with an extension-origin side panel, durable per-note storage, exact range context and validated selectors. It adds complete export and opt-in paired session delivery. The original upstream implementation is not injected alongside the enhanced runtime.
8
8
 
9
- This is a distinct local extension with its own ID, not an official Annotate HTML update. It has no upstream update URL, analytics or external data service. Only user-requested Native Messaging can send feedback to a paired local OpenCode client. Native Messaging and side-panel installation are macOS/Chrome-only in this version.
9
+ This is a distinct local extension with its own ID, not an official Annotate HTML update. It has no upstream update URL, analytics or external data service. Only user-requested Native Messaging can send feedback to a paired local OpenCode client.
10
+
11
+ This version runs in Chrome and Safari. Chrome uses its native messaging host and a docked side panel. Safari has no docked panel, and it only registers an App-Sandboxed app extension, which cannot reach the local Node bridge. The Safari build therefore keeps notes local and copies rounds out, and the panel opens as its own window. Chrome keeps Native Messaging and session delivery. Both browsers are macOS-only in this version.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "OpenCode Annotate",
4
- "version": "0.13.1",
4
+ "version": "0.15.0",
5
5
  "description": "Annotate HTML-based page feedback, private drafts, and paired OpenCode delivery.",
6
6
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp7TG2yzekNKpQvHBtj4jqkOxtoeDIBhNIjPi37Os/ksuhzPp1pHnrJPV4WV2ToatUaD5x5/SpLP8qZKLBD+wuraEE/TeclEZ8HvEs1yhlnx/S7piTG/s0eV5umuTEx2w66Hi0w3dhTC7ZZfJXCLyqs1feBtWzQx6ClgaHNYly4iJ03pV7RfguqpIaG9LV8Oa8ELA+7Ubr0BAujXrSlvqLF5oAKGoXXcpvTL5rgMRIH4Q/85tnvrk0pRVg+1z9IGNzSfjN82iveC/JAriyWABp8YuswtvKfI2Wb+KspaisBh39Y3BRqlyo8I2Cr+01uE6G5pWiJIWMLhe0glrMr5I2wIDAQAB",
7
7
  "permissions": ["activeTab", "scripting", "storage", "sidePanel", "nativeMessaging", "clipboardWrite"],
package/browser/panel.css CHANGED
@@ -67,7 +67,7 @@ kbd { font: 12px/1.3 system-ui; color: var(--muted); }
67
67
  .notes-section { margin-top: 22px; }
68
68
  ol { list-style: none; margin: 0; padding: 0; }
69
69
  .note { display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 10px; border-top: 1px solid var(--line); padding: 15px 0 14px; }
70
- .note:first-child { border-top: 0; padding-top: 5px; }
70
+ .note:first-child, .page-group + .note { border-top: 0; padding-top: 5px; }
71
71
  .note-number { display: grid; place-items: center; width: 24px; height: 24px; margin-top: 2px; border: 1px solid var(--input); border-radius: 50%; color: var(--muted); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
72
72
  .note.is-current .note-number { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
73
73
  .note-target { display: flex; align-items: flex-start; gap: 6px; width: 100%; min-height: 28px; padding: 2px 0; border: 0; background: transparent; color: var(--muted); font-size: 13px; line-height: 1.5; font-weight: 400; text-align: left; }
@@ -87,16 +87,16 @@ ol { list-style: none; margin: 0; padding: 0; }
87
87
  .empty-state .empty-footnote { margin-top: 24px; font-size: 13px; }
88
88
  .inline-notice { display: flex; align-items: center; gap: 8px; padding: 10px 0; margin-top: 12px; font-size: 13px; color: var(--muted); }
89
89
  .inline-notice span { flex: 1; }
90
- .delivery { min-width: 0; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: var(--bg); }
90
+ .delivery { position: relative; min-width: 0; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: var(--bg); }
91
91
  .destination { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; min-width: 0; }
92
92
  .destination > .icon { width: 16px; height: 16px; color: var(--muted); }
93
93
  .destination-label { color: var(--muted); font-size: 13px; }
94
94
  .destination-button { display: inline-flex; align-items: center; justify-content: flex-start; gap: 5px; min-width: 0; flex: 1; min-height: 28px; padding: 3px 0; border: 0; background: transparent; font-size: 13px; font-weight: 400; text-align: left; }
95
95
  #paired { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
96
96
  .destination-button .icon { width: 14px; height: 14px; color: var(--muted); }
97
- .send-row { display: flex; gap: 6px; }
98
- #send { flex: 1; min-width: 0; min-height: 39px; font-size: 14px; font-weight: 600; }
99
- #copy-round { width: 39px; height: 39px; min-height: 39px; border-color: var(--line); }
97
+ .send-row { display: flex; flex-wrap: wrap; gap: 6px; }
98
+ #send { flex: 1 1 130px; min-width: 0; min-height: 39px; font-size: 14px; font-weight: 600; }
99
+ #copy-round { flex: 1 1 110px; min-height: 39px; border-color: var(--line); white-space: nowrap; }
100
100
  .empty-state #restore-round { margin-top: 10px; }
101
101
  .primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
102
102
  .primary:disabled { opacity: 1; background: var(--soft); border-color: var(--line); color: var(--muted); }
@@ -111,13 +111,30 @@ ol { list-style: none; margin: 0; padding: 0; }
111
111
  #status.error { color: var(--error); }
112
112
  #status.warning { color: var(--warning); }
113
113
  #status.success { color: var(--success); }
114
- .session-chooser, .utilities { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
115
- .session-chooser select { padding: 8px; font-size: 13px; }
114
+ .utilities { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
115
+ .session-chooser { position: absolute; z-index: 2; right: 12px; bottom: calc(100% - 4px); left: 12px; max-height: 45dvh; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 8px 24px light-dark(#27251f20, #0006); }
116
+ .session-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
117
+ .session-tools input { flex: 1 1 8rem; min-width: 0; padding: 6px 9px; border: 1px solid var(--input); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
118
+ .session-tools input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
119
+ .session-tools select { width: auto; flex: none; padding: 6px 8px; font-size: 12px; }
120
+ .session-list { display: grid; gap: 2px; }
121
+ .session-row { display: grid; justify-content: stretch; justify-items: start; gap: 1px; width: 100%; min-height: 0; padding: 6px 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; text-align: left; font-weight: 400; }
122
+ .session-row:hover:not(:disabled) { background: var(--soft); border-color: transparent; }
123
+ .session-row[aria-pressed="true"] { border-color: var(--input); background: var(--soft); }
124
+ .session-row:focus-visible { outline-offset: 0; }
125
+ .session-title, .session-meta { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
126
+ .session-title { font-size: 13px; }
127
+ .session-meta { font-size: 11.5px; color: var(--muted); }
128
+ #show-all-sessions { margin-top: 2px; }
129
+ .session-actions { display: flex; flex-wrap: wrap; gap: 12px; }
130
+ #workspaces { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
116
131
  .hint { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
132
+ #connection-hint:empty { display: none; }
117
133
  #connection-hint { margin-top: 7px; }
118
- #refresh-targets { margin-top: 8px; }
119
134
  .utility-row { display: flex; flex-wrap: wrap; gap: 8px; }
120
135
  details { margin-top: 10px; }
121
136
  summary { min-height: 30px; padding: 4px 0; cursor: pointer; color: var(--muted); font-size: 13px; }
122
137
  pre { max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font: 12px/1.5 ui-monospace, monospace; }
123
138
  @media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
139
+ .page-group { list-style: none; display: grid; gap: 2px; padding: 12px 0 4px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
140
+ .page-group strong { color: var(--text); font-size: 13px; font-weight: 650; }
@@ -25,10 +25,6 @@
25
25
  <div class="utility-row"><button id="copy"><svg class="icon" aria-hidden="true"><use href="#icon-copy"/></svg>Copy Markdown</button><button id="export"><svg class="icon" aria-hidden="true"><use href="#icon-download"/></svg>Export JSON</button></div>
26
26
  <details id="context-details"><summary>Review context · current round</summary><pre id="preview"></pre></details>
27
27
  </section>
28
- <section id="session-options" class="session-chooser" aria-label="Destination selection" hidden>
29
- <label for="targets">Choose session</label><select id="targets"><option value="">Choose a session…</option></select>
30
- <p id="connection-hint" class="hint" aria-live="polite"></p><button id="refresh-targets">Refresh sessions</button>
31
- </section>
32
28
  <div id="update-notice" class="update-notice" role="status" hidden><strong>Annotate was updated</strong><p>Reload once to finish. Notes and drafts are kept; reopen the panel with the icon or Alt+Shift+A afterwards.</p><button id="reload-extension" class="primary">Reload Annotate</button></div>
33
29
  <p id="page-error" class="error" role="alert" hidden></p>
34
30
  <div class="picker-row"><button id="pick" aria-pressed="false"><svg class="icon" aria-hidden="true"><use href="#icon-pick"/></svg><span id="pick-label">Pick element</span></button><span id="pick-hint">or select text</span></div>
@@ -47,8 +43,16 @@
47
43
  <section id="empty-state" class="empty-state"><h2 id="empty-title">Start with what you see.</h2><p>Pick an element or highlight text on the page, then describe what needs attention.</p><p id="empty-footnote" class="empty-footnote">Send one note straight away, or collect a few first. Your feedback stays local until you send.</p><button id="restore-round" class="text-button" hidden>Restore last round</button></section>
48
44
  </main>
49
45
  <footer class="delivery">
46
+ <section id="session-options" class="session-chooser" aria-label="Destination selection" hidden>
47
+ <div class="session-tools"><input id="session-filter" type="search" placeholder="Filter sessions" aria-label="Filter sessions" autocomplete="off" spellcheck="false"><select id="session-sort" aria-label="Sort sessions"><option value="updated">Recently updated</option><option value="created">Recently created</option><option value="title">Title</option></select></div>
48
+ <div id="targets" class="session-list" role="group" aria-label="Destination session"></div>
49
+ <button id="show-all-sessions" class="text-button" type="button" hidden></button>
50
+ <div id="workspaces" class="session-list" aria-label="OpenCode workspaces" hidden></div>
51
+ <div class="session-actions"><button id="new-session" class="text-button" type="button" hidden>New session</button><button id="disconnect" class="text-button" type="button" hidden>Disconnect</button></div>
52
+ <p id="connection-hint" class="hint" aria-live="polite"></p>
53
+ </section>
50
54
  <div class="destination"><svg class="icon" aria-hidden="true"><use href="#icon-session"/></svg><span class="destination-label">To</span><button id="change-target" class="destination-button" aria-label="Change destination session" aria-expanded="false" aria-controls="session-options"><span id="paired">Looking for your session…</span><svg class="icon" aria-hidden="true"><use href="#icon-chevron"/></svg></button><span id="link-state" class="link-state"></span></div>
51
- <div class="send-row"><button id="send" class="primary" aria-describedby="paired status"><svg id="send-copy" class="icon" aria-hidden="true" hidden><use href="#icon-copy"/></svg><span id="send-label">Send &amp; continue</span><svg id="send-arrow" class="icon" aria-hidden="true" hidden><use href="#icon-arrow"/></svg></button><button id="copy-round" class="icon-button" aria-label="Copy notes instead and start the next round" title="Copy instead · paste into any agent" hidden><svg class="icon" aria-hidden="true"><use href="#icon-copy"/></svg></button></div>
55
+ <div class="send-row"><button id="send" class="primary" aria-describedby="paired status"><span id="send-label">Send notes</span><svg id="send-arrow" class="icon" aria-hidden="true" hidden><use href="#icon-arrow"/></svg></button><button id="copy-round" class="soft" aria-label="Copy notes instead and start the next round" title="Copy instead · paste into any agent" hidden><svg class="icon" aria-hidden="true"><use href="#icon-copy"/></svg><span>Copy instead</span></button></div>
52
56
  <p id="status" role="status" aria-live="polite">Looking for your OpenCode session…</p>
53
57
  </footer>
54
58
  <script type="module" src="panel.mjs"></script>