-
Notifications
You must be signed in to change notification settings - Fork 5.2k
feat(plugin)!: migrate plugin system to SDK v2 #7639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
…v2 plugin subpath exports (@opencode-ai/plugin/v2)\n- Import types from @opencode-ai/sdk/v2 with flattened API params\n- Update permission hook to use PermissionRequest with reply format\n- Add v2/tool.ts importing FilePart from SDK v2
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
…e separate client instances for v1 and v2 SDKs to maintain backward compatibility.\n- Update plugin input handling to accommodate both versions.\n- Implement version detection for plugins to ensure correct initialization based on SDK version.
- Replace separate v1/v2 inputs with unified PluginInput - Create UnifiedClient with .v2 accessor for backward compatibility - Remove plugin version detection logic - Simplify plugin loading to use single unified input
- Remove packages/plugin/src/v2/index.ts and v2/tool.ts - No longer needed after unifying plugin API with single input
- Remove unified client proxy, use v2 SDK client directly - Update CodexAuthPlugin to use v2 auth.set() API format - Update plugin types to use v2 SDK types (OpencodeClient, PermissionRequest) - Add 'reject' status option to permission.ask hook - Remove v1 client imports and creation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Summary
Why This Breaking Change Is Acceptable
Hook Types Were Already Broken
Analysis revealed significant type drift between what the plugin package defined and what the OpenCode core actually passed at runtime:
permission.askPermissionwithtitlePermission.Infowithmessageinput.titlereturnsundefinedchat.paramsProviderPromise<Provider.Info>chat.messageUserMessageMessageV2.InfoThe core was already using
@ts-expect-errorworkarounds to suppress these mismatches. Plugins accessinginput.titleinpermission.askwere already gettingundefinedat runtime.This Change Fixes the Type Mismatch
Instead of maintaining broken v1 types, we:
UnifiedClientcomplexity (no more.v2accessor needed)Changes
Plugin Package (
packages/plugin)@opencode-ai/sdk→@opencode-ai/sdk/v2PermissionRequestinstead ofPermission, etc.)PluginInput.clientto be v2OpencodeClientonlyToolContext.metadata()andToolResulttypesPlugin Loader (
packages/opencode).v2accessor)Breaking Changes
input.client(v1) +input.client.v2(v2)input.client(v2 only)PermissionwithtitlePermissionRequestwithpermissionstatus: ask/deny/allowreply: once/always/reject{ path, body, query }Migration for Plugin Authors
@opencode-ai/plugin(no/v2)Why Not Maintain v1 Compatibility?
Closes #7641