Skip to content

feat: port the plugin to the OpenCode v2 plugin API - #5

Merged
devadathanmb merged 2 commits into
mainfrom
opencode-v2
Oct 31, 2026
Merged

devadathanmb merged 2 commits into
mainfrom
opencode-v2

Conversation

@devadathanmb

Copy link
Copy Markdown
Owner

Summary

  • Ports the plugin to the OpenCode v2 plugin API and drops OpenCode v1 support. Logs go to OpenCode's log, tagged plugin=easy-vision.
  • Images are replaced in the request sent to the model, not in chat history. Each image becomes a saved file path, and only the latest message asks the model to call the vision tool.
  • Turns off MCP Code Mode for the vision tool's server so the model can call the tool directly, unless that server sets codemode itself. New disableCodeMode option.
  • Saved images use content-hash names, are readable only by the user, and are never deleted while in use.
  • Breaking: config is read only from opencode-easy-vision.jsonc, and the default imageAnalysisTool is now MiniMax_understand_image.
  • Releases are published under the npm next tag, so latest stays on 1.x for OpenCode v1 users.
  • Adds unit tests for each module, run in CI, and end-to-end tests (just e2e) that run the packed plugin in the real opencode binary.
  • Updates the docs for v2, including an upgrade guide.

Related

Closes #3

- `src/index.ts` is an Effect plugin (`{ id, effect }`) that logs through the host logger tagged `plugin=easy-vision`, loads config, runs startup cleanup, and registers an MCP transform plus the `context`, `compaction`, `title` and `generate` session hooks.
- Images in user messages are rewritten in the outgoing model context (`src/request.ts`, `src/transform.ts`), not in stored history. Each image becomes a saved path, only the latest user message gets tool instructions, and compaction, title and generate requests get paths only. Failures become text notes for the model.
- Images are saved under content-hash names and written atomically with mode 0600. An existing file is reused only if it is a regular file owned by the user with the expected size, and reuse refreshes its mtime so startup cleanup keeps it (`src/images.ts`, `src/file-lock.ts`, `src/cleanup.ts`). Cleanup only deletes hash-named files.
- `src/codemode.ts` turns MCP Code Mode off for the server that provides `imageAnalysisTool`, unless `codemode` is set on that server. `src/tool-route.ts` decides per request whether to point the model at the tool directly, through `execute`, or report it unavailable. Adds the `disableCodeMode` option.
- Config is loaded per plugin instance from `opencode-easy-vision.jsonc` only; a leftover `.json` file logs a rename hint. The default `imageAnalysisTool` is `MiniMax_understand_image`.
- `@opencode/*` imports are type-only and `effect` is an optional peer, so the package depends only on `strip-json-comments`. A root `index.js` re-exports `dist/` for directory loading. Requires Node >=22.18.0.
- Adds a Vitest unit suite in `test/` with coverage thresholds, run in CI along with type-checking, and `test/e2e/`, which drives the real `opencode` binary with the packed plugin through `just e2e`. Adds a `justfile`.
- The publish workflow tags releases `next`, so `latest` keeps serving 1.x.

BREAKING CHANGE: requires OpenCode v2; OpenCode v1 users must stay on 1.x. The config file must be named `opencode-easy-vision.jsonc`; `opencode-easy-vision.json` and `opencode-minimax-easy-vision.json(c)` are no longer read. The default `imageAnalysisTool` changes from `mcp_minimax_understand_image` to `MiniMax_understand_image`.
- README.md: v2 requirement and `@next` install, Code Mode note, `mcp.servers` examples with `{env:...}` keys, new troubleshooting entries, and an "Upgrading from 1.x" section.
- CONFIGURATION.md: JSONC-only file locations, MCP tool naming and the new default, and the `disableCodeMode` option.
- AGENT_SETUP.md: checks the OpenCode version, writes `mcp.servers` and `opencode-easy-vision@next` entries, and offers environment-variable API keys.
- CONTRIBUTING.md: `just` workflow, end-to-end tests, and local testing against OpenCode v2.
- AGENTS.md: updated module map, transform rules, commands, and the `next`-tag release policy.
@devadathanmb
devadathanmb merged commit b95e5a2 into main Oct 31, 2026
6 checks passed
@devadathanmb
devadathanmb deleted the opencode-v2 branch October 31, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin Not Opencode v2 Compatible

1 participant