Repository navigation
feat: port the plugin to the OpenCode v2 plugin API - #5
Merged
Merged
Conversation
- `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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
plugin=easy-vision.codemodeitself. NewdisableCodeModeoption.opencode-easy-vision.jsonc, and the defaultimageAnalysisToolis nowMiniMax_understand_image.nexttag, solateststays on 1.x for OpenCode v1 users.just e2e) that run the packed plugin in the realopencodebinary.Related
Closes #3