feat: support OpenCode v2 with safe sync tool commands - #84
Merged
Merged
Conversation
Single-read override loading and shared merge helpers. Keep replay callbacks pure with warnings outside transforms. Set-based command lookup, hardened arg parsing, v2 logging.
…esume # Conflicts: # src/sync/service.ts
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
Adds one package entrypoint for OpenCode v1 and v2. V1 keeps its existing server hooks and
/sync-*commands. V2 registersopencode_syncas a tool, uses domain transforms for MCP, agent, model, and provider overrides, and shares the sync service with v1. README anddocs/v2.mddocument the version requirements and remaining parity gaps.This contains the complete work from PR #81 plus the focused safety fix in the contributor-branch fix PR. PR #81 should be superseded by this PR after review; this PR does not close it automatically.
Safety fix found during live verification
The original v2
/sync-statuscallback posted its result throughsession.synthetic. OpenCode treated that text as a new prompt, and the model attemptedopencode_sync init. V2 now exposes sync operations through theopencode_synctool only. The/sync-*commands remain on v1. V2 tool results rewrite v1-only slash-command hints to the equivalent tool arguments.Verification
bun run checkandbun run buildpassed.bun testpassed, 202 tests.plugin listshowedopencode-synced;command.listshowed nosync-*commands.opencode_syncwith{ "command": "status" }returned visible tool content:opencode-synced is not configured. Run opencode_sync with {"command":"init"} to set it up.No configuration changed.sync-init: OpenCode's default free model rejected API use, and an OpenAI OAuth retry failed token refresh with 401. The package's v1 entrypoint and hooks passed local tests; full v1 sync behavior remains unverified in this run.Review notes
mcp,agent,model, andproviderwarn and are not applied.