Something went wrong. Try again.
opencode v2 mirror
Something went wrong. Try again.
777 B · 20 lines
TypeScript
123456789101112131415161718192021import type { LocationGetOutput, OpenCodeClient } from "@opencode/client/promise"import type { Data } from "@opencode/client/solid"
export async function createWorktree(input: { api: Pick<OpenCodeClient, "location" | "worktree"> data: Pick<Data, "location"> directory: string project?: LocationGetOutput["project"] branch?: string}) { const project = input.project ?? (await input.api.location.get({ location: { directory: input.directory } })).project const created = await input.api.worktree.create({ projectID: project.id, from: project.canonical, branch: input.branch, }) // Populate the client cache before the destination session mounts. await input.data.location.syncInfo({ directory: created.directory }) return created.directory}