Skip to content

[FEATURE]: Expose V2 VCS status and diff APIs #34433

Closed

Description

@opencode-agent

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Expose V2 VCS APIs through packages/protocol, server handlers, and the generated @opencode-ai/client.

From #34359, the TUI currently relies on legacy client calls for:

  • vcs.status
  • vcs.diff

Observed TUI/app usage on origin/v2:

  • Move/delete working-copy flows call vcs.status to warn about uncommitted changes.
  • Workspace-create/move prompts call vcs.status for source/destination status.
  • The diff viewer calls vcs.diff for working-tree/index/all-style VCS review modes.
  • The app session review UI also calls vcs.diff({ mode }) for review diffs.

Intention:

  • This is repository/worktree state, independent of a specific session turn.
  • Use this when the UI wants the current VCS working tree/index diff/status for a directory/workspace.

Expected scope:

  • Add protocol/server/client surface for VCS status.
  • Add protocol/server/client surface for VCS diff, including mode/context options.
  • Preserve directory/workspace location semantics needed by TUI.
  • Regenerate @opencode-ai/client.
  • Add tests around git/non-git/error behavior.

This issue is split out from the broader TUI client migration umbrella #34359.

Activity

  1. opencode-agent commented on Jul 2, 2026

    @opencode-agent
    ContributorAuthor

    Assigned to @nexxeln from the V2 TODO LIST thread.

    Scope reminder from the original split:

    • vcs.status / vcs.diff are repository/worktree state for a Location, independent of a particular session turn.
    • Keep this separate from [FEATURE]: Expose V2 session.diff API #34434 (session.diff), which is session/message-boundary-scoped.

    Aiden noted there was a Dax/Aiden scope discussion in another thread; if found, link it here before finalizing the API shape.

  2. opencode-agent commented on Jul 2, 2026

    @opencode-agent
    ContributorAuthor

    Scope references from Discord:

    1. Original V2 API split:
      https://discord.com/channels/1391832426048651334/1520962938733723720/1521136350936694906

    Relevant distinction:

    • VCS APIs = current repository/worktree status + raw VCS diff for a Location.
    • Session diff API = session-scoped or message-boundary diff, used for last-turn diff, session modified-files sidebar, plugin session diff state, and app review refreshes.
    1. Older snapshot/diff scoping discussion:
      https://discord.com/channels/1391832426048651334/1518799327076810812/1518808524354748446

    Relevant contract:

    • session scope = launch directory
    • snapshot storage/path identity = Git worktree
    • patch files = absolute
    • displayed FileDiff.file = worktree-relative
    • consumers should not need to know both roots, but the implementation must preserve this distinction.
  3. removed their assignment
    on Jul 2, 2026
  4. nexxeln commented on Jul 3, 2026

    @nexxeln
    Contributor

    Implementation up in #35129. Also did the requested pass on how git-welded V2 is and what a second VCS (hg/jj) would take — summary of the coupling audit:

    Already agnostic (after #35129)

    • Wire contracts: Vcs.FileStatus, FileDiff.Info, Vcs.Mode renamed to working | branch (no git literals on the new surface)
    • Core seam: Vcs.Service is the adapter interface; the git implementation is one file (packages/core/src/vcs/git.ts) selected by location.vcs?.type. An hg adapter supporting status/diff/branch is roughly ~250-450 LOC behind the same interface.

    The real blocker for a second VCS

    • Detection: packages/core/src/project.ts Project.resolve only discovers .git (fs.up({ targets: [".git"] })), so location.vcs can never be anything else. Widening means touching core/project.ts, core/project/schema.ts (Vcs union), schema/src/project.ts (Literal("git")), plus UI guards (~8-12 files total).
    • Agent-visible copy: system-context/builtins.ts says "Is directory a git repo", plus assorted TUI/app copy that leaks git.

    Git-only territory (keep gated or hidden for non-git)

    • Workspaces/worktrees: git_worktree is the copy strategy ID down to the DB (project/sql.ts), and all create/move/delete flows assume it (~600-1000 LOC to generalize — not worth it unless the target VCS has a worktree equivalent)
    • Repository clone/cache: repository.ts / repository-cache.ts are git-remote-native
    • Snapshots: stay git per discussion — invisible to users, uses its own git store

    Suggested follow-ups

    1. hg (or jj) adapter: detection widening + adapter file + hg in CI — its own PR
    2. Plugin-registered VCS backends (the "Google doesn't have to fork" path): needs plugin API design; the adapter seam in feat(core): expose V2 VCS status and diff APIs #35129 is the hook point
    3. Rename the SnapshotFileDiff schema identifier to something neutral once the legacy SDK can absorb the break (V2 clients now standardize on FileDiff.Info)
  5. opencode-agent commented on Jul 3, 2026

    @opencode-agent
    ContributorAuthor

    Status from @nexxeln/Shoubhit: current VCS APIs are in, and Mercurial support is in.

    Remaining follow-up is the plugin API for VCS adapters, for systems like jj. Filed the focused follow-up as #35162.

    Source: https://discord.com/channels/1391832426048651334/1520962938733723720/1522589081282937052

  6. opencode-agent commented on Jul 5, 2026

    @opencode-agent
    ContributorAuthor

    Completed by merged PR #35129: V2 VCS status/diff APIs and Mercurial support are in. Remaining extensibility work continues in #35162 / PR #35166.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions