feat(plugin): add vcs backend registration api

This commit is contained in:
Shoubhit Dash 2026-07-03 18:45:59 +05:30
commit 66878b4c53
12 changed files with 309 additions and 8 deletions

View file

@ -0,0 +1,33 @@
export * as Vcs from "./vcs.js"
import { FileDiff } from "@opencode-ai/schema/file-diff"
import { FileStatus, Mode } from "@opencode-ai/schema/vcs"
import { Schema, type Effect, type Scope } from "effect"
export class RegistrationError extends Schema.TaggedErrorClass<RegistrationError>()("Vcs.RegistrationError", {
type: Schema.String,
message: Schema.String,
}) {}
export interface AdapterScope {
readonly directory: string
readonly worktree: string
readonly store: string
}
export interface Adapter {
readonly status: () => Effect.Effect<readonly FileStatus[]>
readonly diff: (
mode: Mode,
options?: { readonly context?: number },
) => Effect.Effect<readonly FileDiff.Info[]>
}
export interface Backend {
readonly type: string
readonly make: (scope: AdapterScope) => Adapter
}
export interface VcsDomain {
readonly register: (backend: Backend) => Effect.Effect<void, RegistrationError, Scope.Scope>
}