opencode-see-image 0.4.1 → 0.4.3
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 +26 -20
- package/index.ts +17 -4
- 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
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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
|
|
99
|
-
| `SEE_IMAGE_PROVIDER` | `opencode-go` | Provider
|
|
100
|
-
| `
|
|
101
|
-
| `
|
|
102
|
-
| `SEE_IMAGE_API_VERSION` | `2023-06-01` | `anthropic-version` header
|
|
103
|
-
| `SEE_IMAGE_USER_AGENT` | _(Chrome UA)_ |
|
|
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,9 +148,14 @@ 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.
|
|
151
|
+
"plugin": ["opencode-see-image@0.4.2"]
|
|
151
152
|
```
|
|
152
153
|
|
|
154
|
+
## Limitations
|
|
155
|
+
|
|
156
|
+
- **Clipboard pastes don't work** — when you paste an image from clipboard (Cmd+V), opencode processes it in-memory but discards it before writing to disk if the model doesn't support image input. The plugin can't access it. **Drag screenshots instead**, or save the clipboard image to a file first.
|
|
157
|
+
- **macOS only** — file search locations target macOS screenshot temp dirs. Linux/Windows users need to pass absolute paths.
|
|
158
|
+
|
|
153
159
|
## File search locations
|
|
154
160
|
|
|
155
161
|
When opencode rejects an image attachment, the model only receives a bare filename. `see_image` searches these locations in order:
|
package/index.ts
CHANGED
|
@@ -64,9 +64,19 @@ function resolveFilePath(name: string, cwd: string): string {
|
|
|
64
64
|
} catch {}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const
|
|
67
|
+
const nsirdCount = searchDirs.filter((d) =>
|
|
68
|
+
String(d).includes("NSIRD_screencaptureui"),
|
|
69
|
+
).length
|
|
70
|
+
const summary = [
|
|
71
|
+
`${nsirdCount} macOS screenshot temp dirs`,
|
|
72
|
+
"~/Desktop",
|
|
73
|
+
"~/Downloads",
|
|
74
|
+
cwd,
|
|
75
|
+
]
|
|
76
|
+
.filter(Boolean)
|
|
77
|
+
.join(", ")
|
|
68
78
|
throw new Error(
|
|
69
|
-
`see_image: could not find "${name}". Searched
|
|
79
|
+
`see_image: could not find "${name}". Searched ${summary}. ` +
|
|
70
80
|
`Pass an absolute filePath instead.`,
|
|
71
81
|
)
|
|
72
82
|
}
|
|
@@ -76,6 +86,7 @@ async function seeImageViaSDK(
|
|
|
76
86
|
dataUrl: string,
|
|
77
87
|
mediaType: string,
|
|
78
88
|
prompt: string,
|
|
89
|
+
abort?: AbortSignal,
|
|
79
90
|
): Promise<{ text: string; model: string; provider: string }> {
|
|
80
91
|
const envProvider = process.env.SEE_IMAGE_PROVIDER
|
|
81
92
|
const envModel = process.env.SEE_IMAGE_MODEL
|
|
@@ -144,6 +155,7 @@ async function seeImageViaHTTP(
|
|
|
144
155
|
b64: string,
|
|
145
156
|
mediaType: string,
|
|
146
157
|
prompt: string,
|
|
158
|
+
abort?: AbortSignal,
|
|
147
159
|
): Promise<{ text: string; model: string; provider: string }> {
|
|
148
160
|
const key = process.env.SEE_IMAGE_API_KEY!
|
|
149
161
|
const body = {
|
|
@@ -172,6 +184,7 @@ async function seeImageViaHTTP(
|
|
|
172
184
|
"user-agent": USER_AGENT,
|
|
173
185
|
},
|
|
174
186
|
body: JSON.stringify(body),
|
|
187
|
+
signal: abort,
|
|
175
188
|
})
|
|
176
189
|
|
|
177
190
|
if (!res.ok) {
|
|
@@ -347,9 +360,9 @@ const SeeImagePlugin: Plugin = async (ctx) => {
|
|
|
347
360
|
let result: { text: string; model: string; provider: string }
|
|
348
361
|
|
|
349
362
|
if (process.env.SEE_IMAGE_API_KEY) {
|
|
350
|
-
result = await seeImageViaHTTP(b64, mediaType, prompt)
|
|
363
|
+
result = await seeImageViaHTTP(b64, mediaType, prompt, context.abort)
|
|
351
364
|
} else {
|
|
352
|
-
result = await seeImageViaSDK(client, dataUrl, mediaType, prompt)
|
|
365
|
+
result = await seeImageViaSDK(client, dataUrl, mediaType, prompt, context.abort)
|
|
353
366
|
}
|
|
354
367
|
|
|
355
368
|
context.metadata({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-see-image",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
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",
|