Skip to content

feat(core): expose workspace adaptor and VCS branch hooks to plugin system#16706

Open
lytedev wants to merge 2 commits intoanomalyco:devfrom
lytedev:feat/workspace-adaptor-plugin-hook
Open

feat(core): expose workspace adaptor and VCS branch hooks to plugin system#16706
lytedev wants to merge 2 commits intoanomalyco:devfrom
lytedev:feat/workspace-adaptor-plugin-hook

Conversation

@lytedev
Copy link

@lytedev lytedev commented Mar 9, 2026

Issue for this PR

Loosely related to #5008. The installAdaptor() function and Adaptor interface 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

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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 --colocate refuses 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):

  1. workspace.adaptor hook (record-type, same pattern as tool): plugins register adaptor implementations keyed by type name. After plugins load, each is registered via the existing installAdaptor().

  2. detect() method on adaptors: plugin adaptors can provide detect(directory) => boolean. The /experimental/worktree create endpoint now calls detectAdaptor() first — if a plugin claims the directory, it creates a workspace through that adaptor instead of the default git worktree path.

  3. vcs.branch hook (pipeline): lets plugins provide branch info for non-git VCS. Also used as fallback when git rev-parse fails.

  4. WorkspaceAdaptor and WorkspaceAdaptorInfo types exported from @opencode-ai/plugin.

  5. workspaceFetch helper on PluginInput: proxies requests through the built-in WorkspaceServer so plugin adaptors don't need internal imports.

  6. GET /experimental/workspace/types endpoint: returns available adaptor types and auto-detected adaptor for the current project.

  7. TUI workspace creation dialog: dynamically fetches available types from the API instead of hardcoding "worktree".

  8. installAdaptor() cleanup: accepts both internal Adaptor and plugin WorkspaceAdaptor types cleanly, removed @ts-expect-error. getAdaptor() throws a descriptive error for unknown types instead of crashing.

How did you verify your code works?

  • bun typecheck passes clean for both packages/opencode and packages/plugin
  • All changes are additive with no altered code paths for existing behavior
  • Built and deployed a jj workspace plugin that exercises both hooks — workspace creation via jj workspace add and branch detection via jj log

Screenshots / recordings

No UI changes beyond the workspace creation dialog showing dynamically fetched types instead of a hardcoded list.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 9, 2026
@lytedev lytedev force-pushed the feat/workspace-adaptor-plugin-hook branch 2 times, most recently from b3a7cb0 to bc8fa4d Compare March 9, 2026 08:02
@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@lytedev lytedev force-pushed the feat/workspace-adaptor-plugin-hook branch from f44bb7c to f3a5fcc Compare March 10, 2026 15:53
@lytedev lytedev marked this pull request as ready for review March 10, 2026 15:58
@lytedev lytedev force-pushed the feat/workspace-adaptor-plugin-hook branch 3 times, most recently from 2270eeb to 9d417a5 Compare March 12, 2026 14:45
@lytedev
Copy link
Author

lytedev commented Mar 12, 2026

Mostly superseded by #15895 it looks like! Will see if there are any gaps for my jj workspace plugin...

@lytedev lytedev force-pushed the feat/workspace-adaptor-plugin-hook branch from 9d417a5 to 19cea0a Compare March 12, 2026 15:12
@lytedev lytedev changed the title feat: expose workspace adaptor and VCS extension points to plugin system feat(core): expose workspace adaptor and VCS branch hooks to plugin system Mar 12, 2026
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 12, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@lytedev lytedev force-pushed the feat/workspace-adaptor-plugin-hook branch from 8afea78 to 54a5ba7 Compare March 13, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant