feat: add managed git worktrees (#6674)

This commit is contained in:
Adam
2026-01-02 20:17:02 -06:00
committed by GitHub
parent f6fe709f6e
commit 052de3c556
11 changed files with 692 additions and 116 deletions

View File

@@ -150,6 +150,10 @@ import type {
TuiShowToastResponses,
TuiSubmitPromptResponses,
VcsGetResponses,
WorktreeCreateErrors,
WorktreeCreateInput,
WorktreeCreateResponses,
WorktreeListResponses,
} from "./types.gen.js"
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<
@@ -683,6 +687,62 @@ export class Path extends HeyApiClient {
}
}
export class Worktree extends HeyApiClient {
/**
* List worktrees
*
* List all sandbox worktrees for the current project.
*/
public list<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }])
return (options?.client ?? this.client).get<WorktreeListResponses, unknown, ThrowOnError>({
url: "/experimental/worktree",
...options,
...params,
})
}
/**
* Create worktree
*
* Create a new git worktree for the current project.
*/
public create<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
worktreeCreateInput?: WorktreeCreateInput
},
options?: Options<never, ThrowOnError>,
) {
const params = buildClientParams(
[parameters],
[
{
args: [
{ in: "query", key: "directory" },
{ key: "worktreeCreateInput", map: "body" },
],
},
],
)
return (options?.client ?? this.client).post<WorktreeCreateResponses, WorktreeCreateErrors, ThrowOnError>({
url: "/experimental/worktree",
...options,
...params,
headers: {
"Content-Type": "application/json",
...options?.headers,
...params.headers,
},
})
}
}
export class Vcs extends HeyApiClient {
/**
* Get VCS info
@@ -2789,6 +2849,8 @@ export class OpencodeClient extends HeyApiClient {
path = new Path({ client: this.client })
worktree = new Worktree({ client: this.client })
vcs = new Vcs({ client: this.client })
session = new Session({ client: this.client })