fix(opencode): migrate plugin to V2 API - #2205
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
e72c813 to
043ad15
Compare
043ad15 to
16431e5
Compare
|
Fixed the installer regression identified by review. Updated the assertions to the V2 plugin export and hook registration strings, then verified: cargo test test_opencode_plugin_content_is_valid_typescript --lib; cargo test test_opencode_install_plugin_creates_file_from_scratch --lib. |
| const createGitAiPlugin = (ctx: PluginContext) => { | ||
| const defaultCwd = process.cwd() |
There was a problem hiding this comment.
🟡 Repo resolution drops project worktree fallback
defaultCwd is now set to process.cwd() and the plugin context's directory/worktree are never read, unlike the prior worktree || directory || process.cwd(). When the OpenCode process runs outside the project root, shell-tool checkpoints have no file path to resolve from, so resolveRepoDir fails to locate the repo and the checkpoint is silently skipped.
Prompt for agents
In createGitAiPlugin (agent-support/opencode/git-ai.ts), defaultCwd was changed from `worktree || directory || process.cwd()` to just `process.cwd()`, and the ctx parameter is now unused. If the V2 setup context still exposes the project directory/worktree (verify against the @opencode-ai/plugin beta types for the setup input, e.g. fields like `directory`, `worktree`, or `project`), restore the fallback so repo resolution prefers the project root. This matters for shell/bash tool checkpoints, which have no file path and otherwise fall back to process.cwd(), silently skipping the checkpoint when the OpenCode process cwd differs from the project root.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Confirmed this remains a valid issue in the current head 238561af: defaultCwd still uses only process.cwd(), so shell-tool checkpoints can miss the OpenCode project when the process cwd differs from the project worktree. This needs a follow-up change to restore the V2 context project-directory/worktree fallback and add coverage for that launch layout.
|
Investigated the new repo-resolution finding against the installed |
Fixes #2153
Background
OpenCode does not display a plugin name for the V1-format plugin, showing the local file URL instead.
Changes
Plugin.define.git-aiID and register tool hooks through the V2setupAPI.input,id, andresult.metadatafields.Compatibility
This targets the published OpenCode V2 beta API and preserves checkpoint behavior for edit and shell tools, including post-tool metadata file paths.
Verification
npm run type-check— passed with@opencode-ai/plugin@0.0.0-beta-17963.cargo test --test integration opencode --no-default-features— 14 passed.cargo fmt -- --check— passed on the original commit.git diff --check— passed.cargo clippy --all-targets -- -D warnings— not clean due to 11 pre-existing warnings/errors in unrelated files.The OpenCode UI itself was not run locally; the plugin export and hook contract were verified against the installed beta package types.