opencode-see-image 0.4.1 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +21 -20
  2. package/index.ts +5 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -6,6 +6,14 @@ When a user attaches a screenshot to a text-only model, opencode rejects it with
6
6
 
7
7
  ## Install
8
8
 
9
+ **Option A, one command (recommended):**
10
+ ```bash
11
+ opencode plugin opencode-see-image --global
12
+ ```
13
+ This installs the package and adds it to your config. Then restart opencode.
14
+
15
+ **Option B, edit config manually:**
16
+
9
17
  Add the plugin to your opencode config:
10
18
 
11
19
  ```jsonc
@@ -17,20 +25,13 @@ Add the plugin to your opencode config:
17
25
  ```
18
26
  Then restart opencode.
19
27
 
28
+ ## Install via your agent
20
29
 
21
- ## Install via your agent (copy-paste this)
22
-
23
- Paste this prompt to your opencode agent, and it'll install the plugin for you.
24
-
30
+ Ask your agent:
25
31
  ```
26
- Install the opencode-see-image plugin so I can send you screenshots. Do this:
27
-
28
- 1. Edit ~/.config/opencode/opencode.jsonc (create it if missing). Preserve any existing fields and the $schema. Add "opencode-see-image" to the "plugin" array. If "plugin" doesn't exist, add it as ["opencode-see-image"].
29
- 2. Check that a vision-capable provider is connected by looking for ~/.local/share/opencode/auth.json with either an "opencode-go" entry (paid, fast) OR an "opencode" entry (free). If neither is present, tell me to run /connect and select either opencode-go or opencode (key from opencode.ai/auth).
30
- 3. Tell me to quit and restart opencode for the plugin to load.
31
-
32
- After I restart and attach a screenshot, you should call the see_image tool to view it.
32
+ install the opencode-see-image plugin
33
33
  ```
34
+ It'll run `opencode plugin opencode-see-image --global` and tell you to restart.
34
35
 
35
36
  ## Prerequisites
36
37
 
@@ -71,7 +72,7 @@ plugin's system-prompt instructions tell the model to call see_image
71
72
  see_image tool:
72
73
  1. locates the file (macOS screenshot temp dirs, ~/Desktop, ~/Downloads, cwd)
73
74
  2. base64-encodes it
74
- 3. sends it to the vision model via the Anthropic Messages API
75
+ 3. routes it to the vision model via opencode's SDK (or direct HTTP if SEE_IMAGE_API_KEY is set)
75
76
  4. returns the textual description
76
77
 
77
78
 
@@ -91,16 +92,16 @@ Your model calls this tool automatically when you attach a screenshot, you don't
91
92
 
92
93
  ## Configuration
93
94
 
94
- All settings are env-var overrides. Defaults work out-of-the-box for opencode-go + MiniMax M3.
95
+ All settings are env-var overrides. The plugin uses opencode's SDK client by default (handles auth automatically). Set `SEE_IMAGE_API_KEY` to bypass the SDK and call an HTTP endpoint directly.
95
96
 
96
97
  | Env var | Default | Description |
97
98
  |---|---|---|
98
- | `SEE_IMAGE_MODEL` | `minimax-m3` | Vision model ID to call |
99
- | `SEE_IMAGE_PROVIDER` | `opencode-go` | Provider key in opencode's `auth.json` |
100
- | `SEE_IMAGE_ENDPOINT` | `https://opencode.ai/zen/go/v1/messages` | Anthropic-Messages-compatible endpoint |
101
- | `SEE_IMAGE_API_KEY` | _(reads auth.json)_ | Bypass auth.json with an explicit key |
102
- | `SEE_IMAGE_API_VERSION` | `2023-06-01` | `anthropic-version` header value |
103
- | `SEE_IMAGE_USER_AGENT` | _(Chrome UA)_ | Override the User-Agent header |
99
+ | `SEE_IMAGE_MODEL` | `minimax-m3` | Vision model ID |
100
+ | `SEE_IMAGE_PROVIDER` | `opencode-go` | Provider ID for SDK routing |
101
+ | `SEE_IMAGE_API_KEY` | _(uses SDK)_ | Bypass SDK, call HTTP endpoint directly |
102
+ | `SEE_IMAGE_ENDPOINT` | `https://opencode.ai/zen/go/v1/messages` | HTTP endpoint (only used if `SEE_IMAGE_API_KEY` is set) |
103
+ | `SEE_IMAGE_API_VERSION` | `2023-06-01` | `anthropic-version` header (HTTP mode only) |
104
+ | `SEE_IMAGE_USER_AGENT` | _(Chrome UA)_ | User-Agent header (HTTP mode only) |
104
105
 
105
106
  ### Using a different vision model
106
107
 
@@ -147,7 +148,7 @@ Then restart opencode. (No bun required, this uses opencode's own bun.)
147
148
 
148
149
  **Pin a version** in your config to opt out of auto-updates:
149
150
  ```jsonc
150
- "plugin": ["opencode-see-image@0.4.1"]
151
+ "plugin": ["opencode-see-image@0.4.2"]
151
152
  ```
152
153
 
153
154
  ## File search locations
package/index.ts CHANGED
@@ -76,6 +76,7 @@ async function seeImageViaSDK(
76
76
  dataUrl: string,
77
77
  mediaType: string,
78
78
  prompt: string,
79
+ abort?: AbortSignal,
79
80
  ): Promise<{ text: string; model: string; provider: string }> {
80
81
  const envProvider = process.env.SEE_IMAGE_PROVIDER
81
82
  const envModel = process.env.SEE_IMAGE_MODEL
@@ -144,6 +145,7 @@ async function seeImageViaHTTP(
144
145
  b64: string,
145
146
  mediaType: string,
146
147
  prompt: string,
148
+ abort?: AbortSignal,
147
149
  ): Promise<{ text: string; model: string; provider: string }> {
148
150
  const key = process.env.SEE_IMAGE_API_KEY!
149
151
  const body = {
@@ -172,6 +174,7 @@ async function seeImageViaHTTP(
172
174
  "user-agent": USER_AGENT,
173
175
  },
174
176
  body: JSON.stringify(body),
177
+ signal: abort,
175
178
  })
176
179
 
177
180
  if (!res.ok) {
@@ -347,9 +350,9 @@ const SeeImagePlugin: Plugin = async (ctx) => {
347
350
  let result: { text: string; model: string; provider: string }
348
351
 
349
352
  if (process.env.SEE_IMAGE_API_KEY) {
350
- result = await seeImageViaHTTP(b64, mediaType, prompt)
353
+ result = await seeImageViaHTTP(b64, mediaType, prompt, context.abort)
351
354
  } else {
352
- result = await seeImageViaSDK(client, dataUrl, mediaType, prompt)
355
+ result = await seeImageViaSDK(client, dataUrl, mediaType, prompt, context.abort)
353
356
  }
354
357
 
355
358
  context.metadata({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-see-image",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Give non-vision opencode models the ability to see images/screenshots by routing them to a vision-capable model (MiniMax M3 via opencode-go by default).",
5
5
  "type": "module",
6
6
  "main": "index.ts",