feat(httpapi): bridge instance read endpoints (#24258)

This commit is contained in:
Kit Langton
2026-04-25 10:42:31 -04:00
committed by GitHub
parent bad732c26a
commit d5bfaef53d
6 changed files with 193 additions and 36 deletions

View File

@@ -8,7 +8,8 @@ import { AppFileSystem } from "@opencode-ai/shared/filesystem"
import { FileWatcher } from "@/file/watcher"
import { Git } from "@/git"
import { Log } from "@/util"
import z from "zod"
import { zod } from "@/util/effect-zod"
import { withStatics } from "@/util/schema"
const log = Log.create({ service: "vcs" })
@@ -101,8 +102,8 @@ const compare = Effect.fnUntraced(function* (
)
})
export const Mode = z.enum(["git", "branch"])
export type Mode = z.infer<typeof Mode>
export const Mode = Schema.Literals(["git", "branch"]).pipe(withStatics((s) => ({ zod: zod(s) })))
export type Mode = Schema.Schema.Type<typeof Mode>
export const Event = {
BranchUpdated: BusEvent.define(
@@ -113,28 +114,24 @@ export const Event = {
),
}
export const Info = z
.object({
branch: z.string().optional(),
default_branch: z.string().optional(),
})
.meta({
ref: "VcsInfo",
})
export type Info = z.infer<typeof Info>
export const Info = Schema.Struct({
branch: Schema.optional(Schema.String),
default_branch: Schema.optional(Schema.String),
})
.annotate({ identifier: "VcsInfo" })
.pipe(withStatics((s) => ({ zod: zod(s) })))
export type Info = Schema.Schema.Type<typeof Info>
export const FileDiff = z
.object({
file: z.string(),
patch: z.string(),
additions: z.number(),
deletions: z.number(),
status: z.enum(["added", "deleted", "modified"]).optional(),
})
.meta({
ref: "VcsFileDiff",
})
export type FileDiff = z.infer<typeof FileDiff>
export const FileDiff = Schema.Struct({
file: Schema.String,
patch: Schema.String,
additions: Schema.Number,
deletions: Schema.Number,
status: Schema.optional(Schema.Literals(["added", "deleted", "modified"])),
})
.annotate({ identifier: "VcsFileDiff" })
.pipe(withStatics((s) => ({ zod: zod(s) })))
export type FileDiff = Schema.Schema.Type<typeof FileDiff>
export interface Interface {
readonly init: () => Effect.Effect<void>