core: add /vcs/diff endpoint to retrieve git diff for working tree or default branch comparison

This commit is contained in:
Shoubhit Dash
2026-03-24 13:43:45 +05:30
parent 614ae4895e
commit 01d786ea76
5 changed files with 93 additions and 9 deletions
+30 -2
View File
@@ -38,6 +38,7 @@ import { websocket } from "hono/bun"
import { HTTPException } from "hono/http-exception"
import { errors } from "./error"
import { Filesystem } from "@/util/filesystem"
import { Snapshot } from "@/snapshot"
import { QuestionRoutes } from "./routes/question"
import { PermissionRoutes } from "./routes/permission"
import { GlobalRoutes } from "./routes/global"
@@ -330,12 +331,39 @@ export namespace Server {
},
}),
async (c) => {
const branch = await Vcs.branch()
return c.json({
branch,
branch: await Vcs.branch(),
default_branch: await Vcs.defaultBranch(),
})
},
)
.get(
"/vcs/diff",
describeRoute({
summary: "Get VCS diff",
description: "Retrieve the current git diff for the working tree or against the default branch.",
operationId: "vcs.diff",
responses: {
200: {
description: "VCS diff",
content: {
"application/json": {
schema: resolver(Snapshot.FileDiff.array()),
},
},
},
},
}),
validator(
"query",
z.object({
mode: Vcs.Mode,
}),
),
async (c) => {
return c.json(await Vcs.diff(c.req.valid("query").mode))
},
)
.get(
"/command",
describeRoute({