feat(core): expose workspace adaptor and VCS branch hooks to plugin system#16706
Open
lytedev wants to merge 2 commits intoanomalyco:devfrom
Open
feat(core): expose workspace adaptor and VCS branch hooks to plugin system#16706lytedev wants to merge 2 commits intoanomalyco:devfrom
lytedev wants to merge 2 commits intoanomalyco:devfrom
Conversation
b3a7cb0 to
bc8fa4d
Compare
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
f44bb7c to
f3a5fcc
Compare
2270eeb to
9d417a5
Compare
Author
|
Mostly superseded by #15895 it looks like! Will see if there are any gaps for my jj workspace plugin... |
9d417a5 to
19cea0a
Compare
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
8afea78 to
54a5ba7
Compare
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.
Issue for this PR
Loosely related to #5008. The
installAdaptor()function andAdaptorinterface already exist internally with a comment saying "we will likely allow this in the future" — this PR implements that by exposing it to the plugin system.Type of change
What does this PR do?
Exposes workspace adaptor registration and VCS branch detection to the plugin system, so plugins can register alternative workspace backends (e.g. jj workspaces) alongside the built-in git worktree adaptor.
I use jj (jujutsu) for version control. jj has its own workspace concept (
jj workspace add/forget) that's incompatible with git worktrees —jj git init --colocaterefuses to run inside a git worktree, and running raw git worktree commands behind jj's back corrupts state.Changes (all additive, no existing behavior modified):
workspace.adaptorhook (record-type, same pattern astool): plugins register adaptor implementations keyed by type name. After plugins load, each is registered via the existinginstallAdaptor().detect()method on adaptors: plugin adaptors can providedetect(directory) => boolean. The/experimental/worktreecreate endpoint now callsdetectAdaptor()first — if a plugin claims the directory, it creates a workspace through that adaptor instead of the default git worktree path.vcs.branchhook (pipeline): lets plugins provide branch info for non-git VCS. Also used as fallback whengit rev-parsefails.WorkspaceAdaptorandWorkspaceAdaptorInfotypes exported from@opencode-ai/plugin.workspaceFetchhelper onPluginInput: proxies requests through the built-in WorkspaceServer so plugin adaptors don't need internal imports.GET /experimental/workspace/typesendpoint: returns available adaptor types and auto-detected adaptor for the current project.TUI workspace creation dialog: dynamically fetches available types from the API instead of hardcoding "worktree".
installAdaptor()cleanup: accepts both internalAdaptorand pluginWorkspaceAdaptortypes cleanly, removed@ts-expect-error.getAdaptor()throws a descriptive error for unknown types instead of crashing.How did you verify your code works?
bun typecheckpasses clean for bothpackages/opencodeandpackages/pluginjj workspace addand branch detection viajj logScreenshots / recordings
No UI changes beyond the workspace creation dialog showing dynamically fetched types instead of a hardcoded list.
Checklist