@kenkaiiii/ggcoder 5.109.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/assets/skills/gg-guide/references/code-mode.md +3 -0
  3. package/dist/app-sidecar/branch-routes.d.ts +42 -0
  4. package/dist/app-sidecar/branch-routes.js +189 -0
  5. package/dist/app-sidecar/branch-routes.js.map +1 -0
  6. package/dist/app-sidecar/git-branches.d.ts +81 -0
  7. package/dist/app-sidecar/git-branches.js +270 -0
  8. package/dist/app-sidecar/git-branches.js.map +1 -0
  9. package/dist/app-sidecar/history-routes.js +3 -0
  10. package/dist/app-sidecar/history-routes.js.map +1 -1
  11. package/dist/app-sidecar/history.d.ts +2 -0
  12. package/dist/app-sidecar/history.js.map +1 -1
  13. package/dist/app-sidecar/repo-polls.d.ts +3 -1
  14. package/dist/app-sidecar/repo-polls.js +9 -1
  15. package/dist/app-sidecar/repo-polls.js.map +1 -1
  16. package/dist/app-sidecar/route-context.d.ts +1 -0
  17. package/dist/app-sidecar/session-types.d.ts +5 -0
  18. package/dist/app-sidecar/workspace-routes.js +12 -2
  19. package/dist/app-sidecar/workspace-routes.js.map +1 -1
  20. package/dist/app-sidecar/worktrees.d.ts +100 -0
  21. package/dist/app-sidecar/worktrees.js +260 -0
  22. package/dist/app-sidecar/worktrees.js.map +1 -0
  23. package/dist/app-sidecar-sessions.d.ts +3 -1
  24. package/dist/app-sidecar-sessions.js +6 -4
  25. package/dist/app-sidecar-sessions.js.map +1 -1
  26. package/dist/app-sidecar.js +159 -7
  27. package/dist/app-sidecar.js.map +1 -1
  28. package/dist/core/agent-session.d.ts +72 -0
  29. package/dist/core/agent-session.js +203 -46
  30. package/dist/core/agent-session.js.map +1 -1
  31. package/dist/core/checkout-record.d.ts +22 -0
  32. package/dist/core/checkout-record.js +68 -0
  33. package/dist/core/checkout-record.js.map +1 -0
  34. package/dist/core/compaction/tool-result-pruner.d.ts +11 -0
  35. package/dist/core/compaction/tool-result-pruner.js +26 -0
  36. package/dist/core/compaction/tool-result-pruner.js.map +1 -1
  37. package/dist/core/destructive-git-guard.d.ts +23 -0
  38. package/dist/core/destructive-git-guard.js +11 -8
  39. package/dist/core/destructive-git-guard.js.map +1 -1
  40. package/dist/core/event-bus.d.ts +4 -0
  41. package/dist/core/event-bus.js +1 -0
  42. package/dist/core/event-bus.js.map +1 -1
  43. package/dist/core/lsp/servers.js +1 -1
  44. package/dist/core/project-discovery.d.ts +3 -1
  45. package/dist/core/project-discovery.js +5 -3
  46. package/dist/core/project-discovery.js.map +1 -1
  47. package/dist/core/regrounding.d.ts +9 -1
  48. package/dist/core/regrounding.js +46 -6
  49. package/dist/core/regrounding.js.map +1 -1
  50. package/dist/core/session-manager.d.ts +3 -1
  51. package/dist/core/session-manager.js.map +1 -1
  52. package/dist/core/shared-checkout-guard.d.ts +78 -0
  53. package/dist/core/shared-checkout-guard.js +219 -0
  54. package/dist/core/shared-checkout-guard.js.map +1 -0
  55. package/dist/modes/subagent-worker-mode.js +4 -0
  56. package/dist/modes/subagent-worker-mode.js.map +1 -1
  57. package/dist/tools/bash.d.ts +3 -1
  58. package/dist/tools/bash.js +19 -7
  59. package/dist/tools/bash.js.map +1 -1
  60. package/dist/tools/index.d.ts +2 -0
  61. package/dist/tools/index.js +1 -1
  62. package/dist/tools/index.js.map +1 -1
  63. package/dist/ui/App.js +2 -2
  64. package/dist/ui/App.js.map +1 -1
  65. package/dist/ui/hooks/useAgentLoop.d.ts +1 -1
  66. package/dist/ui/hooks/useAgentLoop.js +10 -1
  67. package/dist/ui/hooks/useAgentLoop.js.map +1 -1
  68. package/dist/utils/git.d.ts +7 -0
  69. package/dist/utils/git.js +12 -1
  70. package/dist/utils/git.js.map +1 -1
  71. package/package.json +12 -12
package/README.md CHANGED
@@ -37,7 +37,7 @@ ggcoder login # pick a provider and sign in
37
37
  ggcoder # start coding in the current folder
38
38
  ```
39
39
 
40
- Needs Node.js 22 or newer. Sign-ins are saved in `~/.gg/auth.json`, shared with the desktop app, and refreshed automatically.
40
+ Needs Node.js 24 or newer. Sign-ins are saved in `~/.gg/auth.json`, shared with the desktop app, and refreshed automatically.
41
41
 
42
42
  ## Providers
43
43
 
@@ -171,6 +171,9 @@ Custom commands: each Markdown file in the project's `.gg/commands/` folder beco
171
171
  - When there is nothing to commit it shows **Clean** (tooltip **Nothing to commit**).
172
172
  - These buttons are disabled while GG is running.
173
173
  - The deck's **Git** panel shows the branch, uncommitted files, and pull requests and issues for GitHub projects.
174
+ - Each window can be on its own branch. The Git panel's Branches tab filters, creates and picks branches. If no other window uses the folder, picking a branch switches it there. If other windows share the folder, this window moves to its own git worktree for that branch (under `~/.gg/worktrees`, with ignored `.env` files copied over) and keeps its conversation; the project's setup (for example its install) runs there once as a background task.
175
+ - A reopened conversation comes back where its branch is checked out. If the branch isn't checked out anywhere, the chat says so; pick the branch in the Branches tab to continue on it.
176
+ - Home lists a project's worktrees with their branch and status. You can open one, or remove one GG made (the branch stays). GG asks first when removing would lose uncommitted changes or commits no branch has, and waits for a setup that is still running.
174
177
 
175
178
  ## CI indicator
176
179
 
@@ -0,0 +1,42 @@
1
+ import type http from "node:http";
2
+ import type { CheckoutRecord } from "../core/checkout-record.js";
3
+ import { type BranchRow } from "./git-branches.js";
4
+ /** What the branch routes need from their window session. */
5
+ export interface BranchRouteContext {
6
+ /** The folder this window reads git state from. */
7
+ gitDir: () => string;
8
+ /** A run, worker or autopilot turn is in progress. */
9
+ isBusy: () => boolean;
10
+ /** Goal windows cannot move into a worktree: their folder is the goal's. */
11
+ canMove: () => boolean;
12
+ /** This window's conversation file, so a moved window resumes it. */
13
+ sessionPath: () => string | null;
14
+ /** Who else uses the checkout rooted at `root`, or null. */
15
+ sharedWith: (root: string) => Promise<string | null>;
16
+ worktreesRoot: string;
17
+ /** The branch changed in place: update the footer and tell the agent. */
18
+ onSwitched: (branch: string, previous: string | null) => void;
19
+ /** Tell the agent, once it resumes in `sessionPath`, where it moved. */
20
+ queueMoveNote: (sessionPath: string, note: string) => void;
21
+ /** Remember the conversation's branch so resuming it reopens that branch. */
22
+ recordCheckout: (record: CheckoutRecord) => Promise<void>;
23
+ /** A worktree was just made: run its setup once a window opens in it. */
24
+ queueSetup: (worktreePath: string) => Promise<void>;
25
+ /** How many windows (this one included) work in the checkout rooted at `root`. */
26
+ windowsIn: (root: string) => Promise<number>;
27
+ /** Whether another window on the checkout rooted at `root` is working. */
28
+ othersBusyIn: (root: string) => Promise<boolean>;
29
+ /** Wait briefly for a worktree's setup to exit; true while it still runs. */
30
+ setupRunningIn: (worktreePath: string) => Promise<boolean>;
31
+ }
32
+ export interface BranchesResponse {
33
+ current: string | null;
34
+ branches: BranchRow[];
35
+ /** Other windows using this checkout; picking a branch then opens a worktree. */
36
+ sharedWith: string | null;
37
+ /** Why switching is unavailable right now, or null. */
38
+ locked: string | null;
39
+ /** The command a new worktree runs first, or null. */
40
+ setup: string | null;
41
+ }
42
+ export declare function handleBranchRoutes(ctx: BranchRouteContext, req: http.IncomingMessage, res: http.ServerResponse, url: string, method: string): boolean;
@@ -0,0 +1,189 @@
1
+ import { log } from "../core/logger.js";
2
+ import { checkoutRoot } from "../core/shared-checkout-guard.js";
3
+ import { BranchSwitchError, listBranches, switchBranch, worktreeMoveNote, } from "./git-branches.js";
4
+ import { json, readBody } from "./http.js";
5
+ import { WorktreeRemoveError, listWorktrees, removeWorktree, resolveSetupCommand, } from "./worktrees.js";
6
+ const BUSY = "Switching branches waits until the agent finishes.";
7
+ function lockReason(ctx, shared) {
8
+ if (ctx.isBusy())
9
+ return BUSY;
10
+ if (shared && !ctx.canMove()) {
11
+ return `${shared} also use this folder. Switch branches from a project window instead.`;
12
+ }
13
+ return null;
14
+ }
15
+ export function handleBranchRoutes(ctx, req, res, url, method) {
16
+ if (method === "GET" && url === "/git/branches") {
17
+ void (async () => {
18
+ try {
19
+ const dir = ctx.gitDir();
20
+ const root = await checkoutRoot(dir);
21
+ const shared = root ? await ctx.sharedWith(root) : null;
22
+ const list = await listBranches(dir);
23
+ const setup = root ? await resolveSetupCommand(root) : null;
24
+ const body = {
25
+ ...list,
26
+ sharedWith: shared,
27
+ locked: lockReason(ctx, shared),
28
+ setup: setup?.command ?? null,
29
+ };
30
+ json(res, 200, body);
31
+ }
32
+ catch (error) {
33
+ log("WARN", "app-sidecar", "branch list failed", { error: String(error) });
34
+ json(res, 500, { error: "Couldn't read this project's branches." });
35
+ }
36
+ })();
37
+ return true;
38
+ }
39
+ if (method === "POST" && url === "/git/branch") {
40
+ void (async () => {
41
+ const raw = await readBody(req, res);
42
+ if (raw === null)
43
+ return;
44
+ let body = {};
45
+ try {
46
+ body = raw ? JSON.parse(raw) : {};
47
+ }
48
+ catch {
49
+ /* handled below */
50
+ }
51
+ if (typeof body.branch !== "string" || !body.branch.trim()) {
52
+ json(res, 400, { error: "Pick a branch." });
53
+ return;
54
+ }
55
+ try {
56
+ const dir = ctx.gitDir();
57
+ const root = await checkoutRoot(dir);
58
+ if (!root) {
59
+ json(res, 400, { error: "This folder isn't a git repository." });
60
+ return;
61
+ }
62
+ const shared = await ctx.sharedWith(root);
63
+ const locked = lockReason(ctx, shared);
64
+ if (locked) {
65
+ json(res, 409, { error: locked });
66
+ return;
67
+ }
68
+ // Switching a shared folder moves the other windows too: never under
69
+ // an agent that is working there (its files would change mid-run).
70
+ if (shared && body.placement === "here" && (await ctx.othersBusyIn(root))) {
71
+ json(res, 409, {
72
+ error: "Another window's agent is working in this folder. Wait for it to finish, or open the branch in its own worktree.",
73
+ });
74
+ return;
75
+ }
76
+ const outcome = await switchBranch({
77
+ dir,
78
+ branch: body.branch,
79
+ create: body.create === true,
80
+ // Shared folder: its own worktree unless the user chose to move them all.
81
+ isolate: shared !== null && body.placement !== "here",
82
+ worktreesRoot: ctx.worktreesRoot,
83
+ });
84
+ if (outcome.kind === "moved") {
85
+ if (!ctx.canMove()) {
86
+ json(res, 409, {
87
+ error: `“${outcome.branch}” is open in ${outcome.path}. Open that folder in a project window.`,
88
+ });
89
+ return;
90
+ }
91
+ await ctx.recordCheckout({ branch: outcome.branch, cwd: outcome.path });
92
+ if (outcome.created)
93
+ await ctx.queueSetup(outcome.path);
94
+ const sessionPath = ctx.sessionPath();
95
+ if (sessionPath)
96
+ ctx.queueMoveNote(sessionPath, worktreeMoveNote(root, outcome));
97
+ log("INFO", "app-sidecar", "window moving to a worktree", {
98
+ branch: outcome.branch,
99
+ path: outcome.path,
100
+ created: String(outcome.created),
101
+ });
102
+ json(res, 200, {
103
+ kind: "moved",
104
+ branch: outcome.branch,
105
+ path: outcome.path,
106
+ sessionPath,
107
+ });
108
+ return;
109
+ }
110
+ if (outcome.kind === "switched") {
111
+ await ctx.recordCheckout({ branch: outcome.branch, cwd: root });
112
+ ctx.onSwitched(outcome.branch, outcome.previous);
113
+ }
114
+ json(res, 200, { kind: outcome.kind, branch: outcome.branch });
115
+ }
116
+ catch (error) {
117
+ if (error instanceof BranchSwitchError) {
118
+ json(res, 409, { error: error.message });
119
+ return;
120
+ }
121
+ log("WARN", "app-sidecar", "branch switch failed", { error: String(error) });
122
+ json(res, 500, { error: "Couldn't switch branches." });
123
+ }
124
+ })();
125
+ return true;
126
+ }
127
+ if (method === "GET" && url.startsWith("/git/worktrees")) {
128
+ void (async () => {
129
+ const target = new URL(url, "http://local").searchParams.get("cwd") || ctx.gitDir();
130
+ try {
131
+ const list = await listWorktrees(target, ctx.worktreesRoot);
132
+ json(res, 200, list ?? { mainPath: null, mainBranch: null, worktrees: [] });
133
+ }
134
+ catch (error) {
135
+ log("WARN", "app-sidecar", "worktree list failed", { error: String(error) });
136
+ json(res, 500, { error: "Couldn't list this project's worktrees." });
137
+ }
138
+ })();
139
+ return true;
140
+ }
141
+ if (method === "POST" && url === "/git/worktrees/remove") {
142
+ void (async () => {
143
+ const raw = await readBody(req, res);
144
+ if (raw === null)
145
+ return;
146
+ let body = {};
147
+ try {
148
+ body = raw ? JSON.parse(raw) : {};
149
+ }
150
+ catch {
151
+ /* handled below */
152
+ }
153
+ if (typeof body.path !== "string" || !body.path) {
154
+ json(res, 400, { error: "Pick a worktree." });
155
+ return;
156
+ }
157
+ try {
158
+ const root = await checkoutRoot(body.path);
159
+ const openWindows = root ? await ctx.windowsIn(root) : 0;
160
+ await removeWorktree({
161
+ dir: typeof body.cwd === "string" && body.cwd ? body.cwd : ctx.gitDir(),
162
+ target: body.path,
163
+ managedRoot: ctx.worktreesRoot,
164
+ force: body.force === true,
165
+ openWindows,
166
+ // Its window is closed, but a setup it started may still be stopping.
167
+ setupRunning: openWindows === 0 && (await ctx.setupRunningIn(body.path)),
168
+ });
169
+ log("INFO", "app-sidecar", "worktree removed", { path: body.path });
170
+ json(res, 200, { ok: true });
171
+ }
172
+ catch (error) {
173
+ if (error instanceof WorktreeRemoveError) {
174
+ json(res, 409, {
175
+ error: error.message,
176
+ dirty: error.dirty,
177
+ unreferenced: error.unreferenced,
178
+ });
179
+ return;
180
+ }
181
+ log("WARN", "app-sidecar", "worktree remove failed", { error: String(error) });
182
+ json(res, 500, { error: "Couldn't remove that worktree." });
183
+ }
184
+ })();
185
+ return true;
186
+ }
187
+ return false;
188
+ }
189
+ //# sourceMappingURL=branch-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch-routes.js","sourceRoot":"","sources":["../../src/app-sidecar/branch-routes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,gBAAgB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AA0CxB,MAAM,IAAI,GAAG,oDAA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M,EAAE,aAAa,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBACpE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;oBACzC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE;wBACb,KAAK,EAAE,KAAK,CAAC,OAAO;wBACpB,KAAK,EAAE,KAAK,CAAC,KAAK;wBAClB,YAAY,EAAE,KAAK,CAAC,YAAY;qBACjC,CAAC,CAAC;oBACH,OAAO;gBACT,CAAC;gBACD,GAAG,CAAC,MAAM,EAAE,aAAa,EAAE,wBAAwB,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAC/E,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,gCAAgC,EAAE,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,81 @@
1
+ import type { CheckoutRecord } from "../core/checkout-record.js";
2
+ export interface BranchRow {
3
+ name: string;
4
+ current: boolean;
5
+ /** Another worktree that has this branch checked out, or null. */
6
+ worktree: string | null;
7
+ /** Last commit time, Unix seconds. */
8
+ updatedAt: number;
9
+ }
10
+ export interface BranchList {
11
+ current: string | null;
12
+ branches: BranchRow[];
13
+ }
14
+ export type SwitchOutcome = {
15
+ kind: "unchanged";
16
+ branch: string;
17
+ } | {
18
+ kind: "switched";
19
+ branch: string;
20
+ previous: string | null;
21
+ } | {
22
+ kind: "moved";
23
+ branch: string;
24
+ path: string;
25
+ created: boolean;
26
+ copied: string[];
27
+ };
28
+ /** A switch git refused; `message` is safe to show the user. */
29
+ export declare class BranchSwitchError extends Error {
30
+ name: string;
31
+ }
32
+ /** Local branches, most recently committed first; `limit: null` lists all. */
33
+ export declare function listBranches(dir: string, limit?: number | null): Promise<BranchList>;
34
+ /** `~/.gg/worktrees/<repo>-<hash>/<branch>`, outside the repo, never an existing path. */
35
+ export declare function worktreePathFor(worktreesRoot: string, repoRoot: string, branch: string): Promise<string>;
36
+ /**
37
+ * Copy the ignored local files a fresh checkout lacks (a worktree only gets
38
+ * tracked files): those listed in `.worktreeinclude` (gitignore syntax, the
39
+ * Claude Code / Conductor convention), else `.env` and `.env.*` at the root.
40
+ * Only files git ignores are copied; dependencies are not.
41
+ */
42
+ export declare function copyLocalFiles(fromRoot: string, toRoot: string): Promise<string[]>;
43
+ export interface SwitchRequest {
44
+ /** The checkout this window works in. */
45
+ dir: string;
46
+ branch: string;
47
+ /** Create `branch` from the current commit. */
48
+ create: boolean;
49
+ /** Other windows share this checkout: never switch it, use a worktree. */
50
+ isolate: boolean;
51
+ /** Where new worktrees go (`~/.gg/worktrees`). */
52
+ worktreesRoot: string;
53
+ }
54
+ /**
55
+ * Put this window on `branch`. In place when nobody else uses the checkout;
56
+ * otherwise in the worktree that already has the branch, or a new one.
57
+ */
58
+ export declare function switchBranch(req: SwitchRequest): Promise<SwitchOutcome>;
59
+ export interface ResumeCheckout {
60
+ /** Where the resumed conversation should work. */
61
+ cwd: string;
62
+ /** What to tell its agent, or null when nothing changed for it. */
63
+ note: string | null;
64
+ /** What to show the user in the chat, or null (see `noteCheckout`). */
65
+ notice?: string | null;
66
+ }
67
+ /**
68
+ * Where a resumed conversation should open so it is back on the branch it
69
+ * recorded (`record`), given the folder the window asked for: the folder, or
70
+ * the worktree that has the branch checked out. Reopening a conversation never
71
+ * writes to git: it switches no folder (other windows may use it) and creates
72
+ * no worktree, since that runs the repo's hooks and a new worktree's setup
73
+ * (an install) without the user asking. A branch checked out nowhere opens in
74
+ * the folder, and the user is told to pick it in the Git panel, which makes its
75
+ * worktree. A record from another repository is ignored.
76
+ */
77
+ export declare function resolveResumeCheckout(requestedCwd: string, record: CheckoutRecord): Promise<ResumeCheckout>;
78
+ /** What the agent is told after its window moved into a worktree. */
79
+ export declare function worktreeMoveNote(from: string, outcome: Extract<SwitchOutcome, {
80
+ kind: "moved";
81
+ }>): string;
@@ -0,0 +1,270 @@
1
+ import { execFile } from "node:child_process";
2
+ import crypto from "node:crypto";
3
+ import { existsSync } from "node:fs";
4
+ import fs from "node:fs/promises";
5
+ import path from "node:path";
6
+ import { realpathNative, resolveGitBinary, runBackgroundGit } from "../utils/git.js";
7
+ /**
8
+ * The Git panel's branch picker: list local branches, and switch this window
9
+ * to one. A checkout has one branch, so when other windows share this folder a
10
+ * switch would move them too; instead this window gets its own worktree for
11
+ * the branch (the pattern Claude Code, Codex and Conductor use for parallel
12
+ * sessions). Nothing here assumes a branch name like `main`.
13
+ */
14
+ const READ_TIMEOUT_MS = 5_000;
15
+ /** `git switch` / `git worktree add` check out files and run the repo's hooks. */
16
+ const WRITE_TIMEOUT_MS = 120_000;
17
+ const MAX_BRANCHES = 200;
18
+ /** Ignored local files bigger than this are not copied into a new worktree. */
19
+ const MAX_COPY_BYTES = 5 * 1024 * 1024;
20
+ /** A switch git refused; `message` is safe to show the user. */
21
+ export class BranchSwitchError extends Error {
22
+ name = "BranchSwitchError";
23
+ }
24
+ async function realRoot(dir) {
25
+ const { stdout } = await runBackgroundGit(["rev-parse", "--show-toplevel"], {
26
+ cwd: dir,
27
+ timeoutMs: READ_TIMEOUT_MS,
28
+ });
29
+ return realpathNative(stdout.trim());
30
+ }
31
+ async function currentBranch(dir) {
32
+ try {
33
+ const { stdout } = await runBackgroundGit(["symbolic-ref", "--quiet", "--short", "HEAD"], {
34
+ cwd: dir,
35
+ timeoutMs: READ_TIMEOUT_MS,
36
+ });
37
+ return stdout.trim() || null;
38
+ }
39
+ catch {
40
+ return null; // detached HEAD
41
+ }
42
+ }
43
+ /** Local branches, most recently committed first; `limit: null` lists all. */
44
+ export async function listBranches(dir, limit = MAX_BRANCHES) {
45
+ const root = await realRoot(dir);
46
+ const current = await currentBranch(dir);
47
+ const { stdout } = await runBackgroundGit([
48
+ "for-each-ref",
49
+ "--sort=-committerdate",
50
+ ...(limit === null ? [] : [`--count=${limit}`]),
51
+ "--format=%(refname:short)%00%(committerdate:unix)%00%(worktreepath)",
52
+ "refs/heads",
53
+ ], { cwd: dir, timeoutMs: READ_TIMEOUT_MS });
54
+ const branches = [];
55
+ for (const line of stdout.split("\n")) {
56
+ if (!line)
57
+ continue;
58
+ const [name = "", time = "0", tree = ""] = line.split("\0");
59
+ if (!name)
60
+ continue;
61
+ const elsewhere = tree ? await realpathNative(tree).catch(() => path.resolve(tree)) : "";
62
+ branches.push({
63
+ name,
64
+ current: name === current,
65
+ worktree: elsewhere && elsewhere !== root ? elsewhere : null,
66
+ updatedAt: Number(time) || 0,
67
+ });
68
+ }
69
+ return { current, branches };
70
+ }
71
+ /**
72
+ * Run git as the user would (hooks and LFS filters apply): this is their own
73
+ * action. Still the resolved binary, never a `git.exe` planted in the repo root
74
+ * (Windows searches the cwd first), and no console window.
75
+ */
76
+ function userGit(args, cwd) {
77
+ return new Promise((resolve, reject) => {
78
+ execFile(resolveGitBinary(), [...args], {
79
+ cwd,
80
+ timeout: WRITE_TIMEOUT_MS,
81
+ maxBuffer: 8 * 1024 * 1024,
82
+ env: process.env,
83
+ windowsHide: true,
84
+ }, (error, stdout, stderr) => {
85
+ if (!error)
86
+ return resolve(stdout);
87
+ const detail = (stderr || stdout || error.message).trim().split("\n").slice(-6).join("\n");
88
+ reject(new BranchSwitchError(detail || "git failed"));
89
+ });
90
+ });
91
+ }
92
+ async function validBranchName(dir, name) {
93
+ if (!name || name.startsWith("-"))
94
+ return false;
95
+ try {
96
+ await runBackgroundGit(["check-ref-format", "--branch", name], {
97
+ cwd: dir,
98
+ timeoutMs: READ_TIMEOUT_MS,
99
+ });
100
+ return true;
101
+ }
102
+ catch {
103
+ return false;
104
+ }
105
+ }
106
+ /** `~/.gg/worktrees/<repo>-<hash>/<branch>`, outside the repo, never an existing path. */
107
+ export async function worktreePathFor(worktreesRoot, repoRoot, branch) {
108
+ const hash = crypto.createHash("sha256").update(repoRoot).digest("hex").slice(0, 8);
109
+ const folder = branch.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^[-.]+/, "") || "branch";
110
+ const base = path.join(worktreesRoot, `${path.basename(repoRoot)}-${hash}`, folder);
111
+ let candidate = base;
112
+ for (let n = 2; existsSync(candidate); n++)
113
+ candidate = `${base}-${n}`;
114
+ return candidate;
115
+ }
116
+ /**
117
+ * Copy the ignored local files a fresh checkout lacks (a worktree only gets
118
+ * tracked files): those listed in `.worktreeinclude` (gitignore syntax, the
119
+ * Claude Code / Conductor convention), else `.env` and `.env.*` at the root.
120
+ * Only files git ignores are copied; dependencies are not.
121
+ */
122
+ export async function copyLocalFiles(fromRoot, toRoot) {
123
+ let candidates;
124
+ if (existsSync(path.join(fromRoot, ".worktreeinclude"))) {
125
+ const { stdout } = await runBackgroundGit(["ls-files", "--others", "--ignored", "--exclude-from=.worktreeinclude", "-z"], { cwd: fromRoot, timeoutMs: READ_TIMEOUT_MS });
126
+ candidates = stdout.split("\0").filter(Boolean);
127
+ }
128
+ else {
129
+ candidates = (await fs.readdir(fromRoot)).filter((n) => /^\.env(\..+)?$/.test(n));
130
+ }
131
+ if (candidates.length === 0)
132
+ return [];
133
+ let ignored;
134
+ try {
135
+ const { stdout } = await runBackgroundGit(["check-ignore", "--stdin", "-z"], {
136
+ cwd: fromRoot,
137
+ timeoutMs: READ_TIMEOUT_MS,
138
+ input: `${candidates.join("\0")}\0`,
139
+ });
140
+ ignored = new Set(stdout.split("\0").filter(Boolean));
141
+ }
142
+ catch {
143
+ return []; // exit 1: none of them is ignored
144
+ }
145
+ const copied = [];
146
+ for (const rel of candidates.sort()) {
147
+ if (!ignored.has(rel))
148
+ continue;
149
+ const from = path.join(fromRoot, rel);
150
+ const stat = await fs.lstat(from).catch(() => null);
151
+ if (!stat?.isFile() || stat.size > MAX_COPY_BYTES)
152
+ continue;
153
+ const to = path.join(toRoot, rel);
154
+ if (existsSync(to))
155
+ continue;
156
+ await fs.mkdir(path.dirname(to), { recursive: true });
157
+ await fs.copyFile(from, to);
158
+ copied.push(rel);
159
+ }
160
+ return copied;
161
+ }
162
+ /**
163
+ * Put this window on `branch`. In place when nobody else uses the checkout;
164
+ * otherwise in the worktree that already has the branch, or a new one.
165
+ */
166
+ export async function switchBranch(req) {
167
+ const branch = req.branch.trim();
168
+ if (!(await validBranchName(req.dir, branch))) {
169
+ throw new BranchSwitchError(`“${branch}” isn't a valid branch name.`);
170
+ }
171
+ const root = await realRoot(req.dir);
172
+ const { current, branches } = await listBranches(req.dir, null);
173
+ const existing = branches.find((b) => b.name === branch);
174
+ if (req.create && existing)
175
+ throw new BranchSwitchError(`Branch “${branch}” already exists.`);
176
+ if (!req.create && !existing)
177
+ throw new BranchSwitchError(`Branch “${branch}” doesn't exist.`);
178
+ if (branch === current)
179
+ return { kind: "unchanged", branch };
180
+ // Checked out in another worktree: git won't switch to it here; go there.
181
+ if (existing?.worktree && existsSync(existing.worktree)) {
182
+ return { kind: "moved", branch, path: existing.worktree, created: false, copied: [] };
183
+ }
184
+ if (!req.isolate) {
185
+ await userGit(req.create ? ["switch", "-c", branch] : ["switch", branch], root);
186
+ return { kind: "switched", branch, previous: current };
187
+ }
188
+ const target = await worktreePathFor(req.worktreesRoot, root, branch);
189
+ await fs.mkdir(path.dirname(target), { recursive: true });
190
+ await userGit(req.create
191
+ ? ["worktree", "add", "-b", branch, target, "HEAD"]
192
+ : ["worktree", "add", target, branch], root);
193
+ const real = await realpathNative(target);
194
+ const copied = await copyLocalFiles(root, real).catch(() => []);
195
+ return { kind: "moved", branch, path: real, created: true, copied };
196
+ }
197
+ async function commonGitDir(dir) {
198
+ try {
199
+ const { stdout } = await runBackgroundGit(["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd: dir, timeoutMs: READ_TIMEOUT_MS });
200
+ return await realpathNative(stdout.trim());
201
+ }
202
+ catch {
203
+ return null;
204
+ }
205
+ }
206
+ /**
207
+ * Where a resumed conversation should open so it is back on the branch it
208
+ * recorded (`record`), given the folder the window asked for: the folder, or
209
+ * the worktree that has the branch checked out. Reopening a conversation never
210
+ * writes to git: it switches no folder (other windows may use it) and creates
211
+ * no worktree, since that runs the repo's hooks and a new worktree's setup
212
+ * (an install) without the user asking. A branch checked out nowhere opens in
213
+ * the folder, and the user is told to pick it in the Git panel, which makes its
214
+ * worktree. A record from another repository is ignored.
215
+ */
216
+ export async function resolveResumeCheckout(requestedCwd, record) {
217
+ const unchanged = { cwd: requestedCwd, note: null };
218
+ const common = await commonGitDir(requestedCwd);
219
+ if (!common)
220
+ return unchanged;
221
+ const requestedRoot = await realRoot(requestedCwd);
222
+ const recordedCommon = existsSync(record.cwd) ? await commonGitDir(record.cwd) : null;
223
+ // The conversation was in another repository: nothing here to restore.
224
+ if (recordedCommon && recordedCommon !== common)
225
+ return unchanged;
226
+ // Still where it was, on its branch: go back there.
227
+ if (recordedCommon && (await currentBranch(record.cwd)) === record.branch) {
228
+ const recordedRoot = await realRoot(record.cwd);
229
+ return recordedRoot === requestedRoot ? unchanged : { cwd: recordedRoot, note: null };
230
+ }
231
+ const { current, branches } = await listBranches(requestedCwd, null);
232
+ const row = branches.find((b) => b.name === record.branch);
233
+ if (!row) {
234
+ return {
235
+ cwd: requestedCwd,
236
+ notice: `Branch ${record.branch} no longer exists, so this conversation opened on ${current ?? "the folder's current commit"}.`,
237
+ note: `This conversation was on branch \`${record.branch}\`, which no longer exists. It ` +
238
+ `reopened in ${requestedRoot}${current ? ` on \`${current}\`` : ""}; check git status ` +
239
+ "before relying on earlier file contents.",
240
+ };
241
+ }
242
+ if (row.current)
243
+ return unchanged;
244
+ if (row.worktree && existsSync(row.worktree)) {
245
+ return {
246
+ cwd: row.worktree,
247
+ notice: `Opened on branch ${record.branch}, where it's checked out: ${row.worktree}.`,
248
+ note: `This conversation's branch \`${record.branch}\` is checked out in ${row.worktree}; it reopened there.`,
249
+ };
250
+ }
251
+ const now = current ?? "another commit";
252
+ return {
253
+ cwd: requestedCwd,
254
+ notice: `This conversation was on branch ${record.branch}, but the project folder is on ${now} now. ` +
255
+ `To continue on ${record.branch}, pick it in the Git panel's Branches tab.`,
256
+ note: `This conversation was on branch \`${record.branch}\`, which isn't checked out anywhere now. ` +
257
+ `It reopened in ${requestedRoot}${current ? ` on \`${current}\`` : ""}, so files may differ ` +
258
+ `from what you saw earlier; check git status before relying on them. The user can open ` +
259
+ `\`${record.branch}\` from the Git panel.`,
260
+ };
261
+ }
262
+ /** What the agent is told after its window moved into a worktree. */
263
+ export function worktreeMoveNote(from, outcome) {
264
+ const copied = outcome.copied.length > 0 ? ` Copied ignored local files: ${outcome.copied.join(", ")}.` : "";
265
+ return (`The user switched this window to branch \`${outcome.branch}\` in its own git worktree at ` +
266
+ `${outcome.path}, so it no longer shares ${from} with other windows. Work only in ` +
267
+ `${outcome.path} from now on: files and paths you saw under ${from} earlier now live under ` +
268
+ `${outcome.path}, and other windows may still be changing ${from}.${copied}`);
269
+ }
270
+ //# sourceMappingURL=git-branches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-branches.js","sourceRoot":"","sources":["../../src/app-sidecar/git-branches.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAErF;;;;;;GAMG;AAEH,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,kFAAkF;AAClF,MAAM,gBAAgB,GAAG,OAAO,CAAC;AACjC,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BAAwB;YAC7F,wFAAwF;YACxF,KAAK,MAAM,CAAC,MAAM,wBAAwB;KAC7C,CAAC;AACJ,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,OAAkD;IAC/F,MAAM,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gCAAgC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAChG,OAAO,CACL,6CAA6C,OAAO,CAAC,MAAM,gCAAgC;QAC3F,GAAG,OAAO,CAAC,IAAI,4BAA4B,IAAI,oCAAoC;QACnF,GAAG,OAAO,CAAC,IAAI,+CAA+C,IAAI,0BAA0B;QAC5F,GAAG,OAAO,CAAC,IAAI,6CAA6C,IAAI,IAAI,MAAM,EAAE,CAC7E,CAAC;AACJ,CAAC"}
@@ -226,6 +226,9 @@ export function handleHistoryRoutes(ctx, req, res, url, method) {
226
226
  security: { rule: d.rule, target: typeof d.target === "string" ? d.target : "" },
227
227
  });
228
228
  }
229
+ else if (marker.kind === "checkout" && typeof d.text === "string") {
230
+ history.push({ role: "assistant", text: "", checkoutNotice: d.text });
231
+ }
229
232
  else if (marker.kind === "error" && typeof d.headline === "string") {
230
233
  const error = restoreAppErrorPayload(d);
231
234
  if (error)