feat(plugin): add vcs backend registration api
This commit is contained in:
parent
38502f7268
commit
66878b4c53
12 changed files with 309 additions and 8 deletions
|
|
@ -10,6 +10,7 @@ import type { SkillHooks } from "./skill.js"
|
|||
import type { Reload } from "./registration.js"
|
||||
import type { ToolDomain } from "./tool.js"
|
||||
import type { SessionDomain } from "./runtime.js"
|
||||
import type { VcsDomain } from "./vcs.js"
|
||||
|
||||
export interface PluginContext {
|
||||
readonly options: PluginOptions
|
||||
|
|
@ -23,4 +24,5 @@ export interface PluginContext {
|
|||
readonly skill: SkillHooks & Reload
|
||||
readonly tool: ToolDomain
|
||||
readonly session: SessionDomain
|
||||
readonly vcs: VcsDomain
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,3 +4,5 @@ export type { Plugin } from "./plugin.js"
|
|||
export * as Tool from "./tool.js"
|
||||
export type { ToolDomain, ToolExecuteBeforeEvent, ToolExecuteAfterEvent } from "./tool.js"
|
||||
export type { SessionDomain } from "./runtime.js"
|
||||
export { Vcs } from "./vcs.js"
|
||||
export type { VcsDomain } from "./vcs.js"
|
||||
|
|
|
|||
33
packages/plugin/src/v2/effect/vcs.ts
Normal file
33
packages/plugin/src/v2/effect/vcs.ts
Normal 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>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue