Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Add git integration: branch picker + worktrees
Julius Marminged64f78a9498a
diff --git a/apps/web/src/persistenceSchema.ts b/apps/web/src/persistenceSchema.tsindex e6b4983a2..eb4514b7f 100644--- a/apps/web/src/persistenceSchema.ts+++ b/apps/web/src/persistenceSchema.ts@@ -34,6 +34,8 @@ const persistedThreadSchema = z.object({model: z.string().min(1),messages: z.array(persistedMessageSchema),createdAt: z.string().min(1),+ branch: z.string().min(1).nullable().optional(),+ worktreePath: z.string().min(1).nullable().optional(),});const persistedStateBodySchema = z.object({@@ -112,6 +114,8 @@ function hydrateThread(events: [],error: null,createdAt: thread.createdAt,+ branch: thread.branch ?? null,+ worktreePath: thread.worktreePath ?? null,};}@@ -170,6 +174,8 @@ export function toPersistedState(model: thread.model,messages: thread.messages,createdAt: thread.createdAt,+ branch: thread.branch,+ worktreePath: thread.worktreePath,})),activeThreadId: state.activeThreadId,runtimeMode: state.runtimeMode,diff --git a/apps/web/src/types.ts b/apps/web/src/types.tsindex ebe3731d1..66746532b 100644--- a/apps/web/src/types.ts+++ b/apps/web/src/types.ts@@ -35,4 +35,6 @@ export interface Thread {latestTurnStartedAt?: string | undefined;latestTurnCompletedAt?: string | undefined;latestTurnDurationMs?: number | undefined;+ branch: string | null;+ worktreePath: string | null;}diff --git a/packages/contracts/src/git.ts b/packages/contracts/src/git.tsnew file mode 100644index 000000000..aa2f72e67--- /dev/null+++ b/packages/contracts/src/git.ts@@ -0,0 +1,56 @@+import { z } from "zod";++// ── Input schemas ──++export const gitListBranchesInputSchema = z.object({+ cwd: z.string().min(1),+});++export const gitCreateWorktreeInputSchema = z.object({+ cwd: z.string().min(1),+ branch: z.string().min(1),+ path: z.string().min(1).optional(),+});++export const gitRemoveWorktreeInputSchema = z.object({+ cwd: z.string().min(1),+ path: z.string().min(1),+});++export const gitInitInputSchema = z.object({+ cwd: z.string().min(1),+});++// ── Output schemas ──++export const gitBranchSchema = z.object({+ name: z.string().min(1),+ current: z.boolean(),+});++export const gitWorktreeSchema = z.object({+ path: z.string().min(1),+ branch: z.string().min(1),+});++// ── Types ──++export type GitListBranchesInput = z.infer<typeof gitListBranchesInputSchema>;+export type GitBranch = z.infer<typeof gitBranchSchema>;+export type GitCreateWorktreeInput = z.infer<+ typeof gitCreateWorktreeInputSchema+>;+export type GitWorktree = z.infer<typeof gitWorktreeSchema>;+export type GitRemoveWorktreeInput = z.infer<+ typeof gitRemoveWorktreeInputSchema+>;+export type GitInitInput = z.infer<typeof gitInitInputSchema>;++export interface GitListBranchesResult {+ branches: GitBranch[];+ isRepo: boolean;+}++export interface GitCreateWorktreeResult {+ worktree: GitWorktree;+}diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.tsindex ec007fc29..430f4fd84 100644--- a/packages/contracts/src/index.ts+++ b/packages/contracts/src/index.ts@@ -6,3 +6,4 @@ export * from "./provider";export * from "./model";export * from "./ws";export * from "./project";+export * from "./git";diff --git a/packages/contracts/src/ipc.ts b/packages/contracts/src/ipc.tsindex 413875051..45aa5f1d6 100644--- a/packages/contracts/src/ipc.ts+++ b/packages/contracts/src/ipc.ts@@ -1,4 +1,12 @@import type { AgentConfig, AgentExit, OutputChunk } from "./agent";+import type {+ GitCreateWorktreeInput,+ GitCreateWorktreeResult,+ GitInitInput,+ GitListBranchesInput,+ GitListBranchesResult,+ GitRemoveWorktreeInput,+} from "./git";import type {ProviderEvent,ProviderInterruptTurnInput,@@ -62,4 +70,10 @@ export interface NativeApi {shell: {openInEditor: (cwd: string, editor: EditorId) => Promise<void>;};+ git: {+ listBranches: (input: GitListBranchesInput) => Promise<GitListBranchesResult>;+ createWorktree: (input: GitCreateWorktreeInput) => Promise<GitCreateWorktreeResult>;+ removeWorktree: (input: GitRemoveWorktreeInput) => Promise<void>;+ init: (input: GitInitInput) => Promise<void>;+ };}