@ccpocket/bridge 1.30.0 → 1.31.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.
@@ -0,0 +1,7 @@
1
+ import type { Provider } from "./parser.js";
2
+ export interface GitAssistOptions {
3
+ provider: Provider;
4
+ projectPath: string;
5
+ model?: string;
6
+ }
7
+ export declare function generateCommitMessage(options: GitAssistOptions): string;
@@ -0,0 +1,51 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { mkdtempSync, readFileSync, rmSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join, resolve } from "node:path";
5
+ import { getStagedDiff } from "./git-operations.js";
6
+ const COMMIT_MESSAGE_PROMPT = "Write a single Conventional Commits message in English for the staged changes below. Output only the commit message, with no quotes or explanation.";
7
+ const CODEX_COMMIT_MODEL = "gpt-5.4-mini";
8
+ export function generateCommitMessage(options) {
9
+ const diff = getStagedDiff(options.projectPath).trim();
10
+ if (!diff) {
11
+ throw new Error("Nothing to commit: no files are staged");
12
+ }
13
+ const cwd = resolve(options.projectPath);
14
+ const output = options.provider === "codex"
15
+ ? runCodexCommitAssist(cwd, diff, options.model)
16
+ : execFileSync("claude", [
17
+ "-p",
18
+ ...(options.model ? ["--model", options.model] : []),
19
+ COMMIT_MESSAGE_PROMPT,
20
+ ], {
21
+ cwd,
22
+ encoding: "utf-8",
23
+ input: diff,
24
+ maxBuffer: 1024 * 1024,
25
+ });
26
+ const message = output
27
+ .split("\n")
28
+ .map((line) => line.trim())
29
+ .find(Boolean);
30
+ if (!message) {
31
+ throw new Error("Commit message generation returned empty output");
32
+ }
33
+ return message;
34
+ }
35
+ function runCodexCommitAssist(cwd, diff, _model) {
36
+ const outputDir = mkdtempSync(join(tmpdir(), "ccpocket-git-assist-"));
37
+ const outputPath = join(outputDir, "last-message.txt");
38
+ try {
39
+ execFileSync("codex", ["exec", "-m", CODEX_COMMIT_MODEL, "-o", outputPath, "-"], {
40
+ cwd,
41
+ encoding: "utf-8",
42
+ input: `${COMMIT_MESSAGE_PROMPT}\n\n${diff}`,
43
+ maxBuffer: 1024 * 1024,
44
+ });
45
+ return readFileSync(outputPath, "utf-8");
46
+ }
47
+ finally {
48
+ rmSync(outputDir, { recursive: true, force: true });
49
+ }
50
+ }
51
+ //# sourceMappingURL=git-assist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-assist.js","sourceRoot":"","sources":["../src/git-assist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,qBAAqB,GACzB,qJAAqJ,CAAC;AACxJ,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAQ1C,MAAM,UAAU,qBAAqB,CAAC,OAAyB;IAC7D,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,MAAM,GACV,OAAO,CAAC,QAAQ,KAAK,OAAO;QAC1B,CAAC,CAAC,oBAAoB,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC;QAChD,CAAC,CAAC,YAAY,CACV,QAAQ,EACR;YACE,IAAI;YACJ,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,C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}
5
+ export interface CommitResult {
6
+ hash: string;
7
+ message: string;
8
+ }
9
+ export interface BranchRemoteStatus {
10
+ ahead: number;
11
+ behind: number;
12
+ hasUpstream: boolean;
13
+ }
14
+ export interface BranchListResult {
15
+ current: string;
16
+ branches: string[];
17
+ /** Branches currently checked out by main repo or worktrees (cannot switch to). */
18
+ checkedOutBranches: string[];
19
+ remoteStatusByBranch: Record<string, BranchRemoteStatus>;
20
+ }
21
+ /** Stage entire files. */
22
+ export declare function stageFiles(projectPath: string, files: string[]): void;
23
+ /**
24
+ * Stage specific hunks by extracting them from `git diff` and applying via `git apply --cached`.
25
+ *
26
+ * Groups hunks by file, extracts the diff header + requested hunks, then pipes through `git apply`.
27
+ */
28
+ export declare function stageHunks(projectPath: string, hunks: HunkRef[]): void;
29
+ /** Unstage files (remove from index, keep working tree changes). */
30
+ export declare function unstageFiles(projectPath: string, files: string[]): void;
31
+ /** Unstage specific hunks from the index, leaving the working tree intact. */
32
+ export declare function unstageHunks(projectPath: string, hunks: HunkRef[]): void;
33
+ /** Create a commit with the given message. Throws if nothing is staged. */
34
+ export declare function gitCommit(projectPath: string, message: string): CommitResult;
35
+ /** Return staged diff content for commit-message generation. */
36
+ export declare function getStagedDiff(projectPath: string): string;
37
+ /** Push to remote. */
38
+ export declare function gitPush(projectPath: string): void;
39
+ /** List branches and branches checked out by worktrees. */
40
+ export declare function listBranches(projectPath: string): BranchListResult;
41
+ /** Create a new branch, optionally checking it out. */
42
+ export declare function createBranch(projectPath: string, name: string, checkout?: boolean): void;
43
+ /** Checkout an existing branch. */
44
+ export declare function checkoutBranch(projectPath: string, branch: string): void;
45
+ /** Revert (discard) unstaged changes for specific files. */
46
+ export declare function revertFiles(projectPath: string, files: string[]): void;
47
+ /** Revert specific working-tree hunks, leaving the index intact. */
48
+ export declare function revertHunks(projectPath: string, hunks: HunkRef[]): void;
49
+ export interface RemoteStatusResult {
50
+ ahead: number;
51
+ behind: number;
52
+ branch: string;
53
+ hasUpstream: boolean;
54
+ }
55
+ /** Fetch from remote (non-blocking, returns when done). */
56
+ export declare function gitFetch(projectPath: string): void;
57
+ /** Get ahead/behind counts relative to upstream. */
58
+ export declare function gitRemoteStatus(projectPath: string): RemoteStatusResult;
59
+ /** Pull from remote (fetch + merge). */
60
+ export declare function gitPull(projectPath: string): {
61
+ success: boolean;
62
+ message: string;
63
+ };
@@ -0,0 +1,251 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { realpathSync } from "node:fs";
3
+ import { resolve } from "node:path";
4
+ // ---- Helpers ----
5
+ function resolveProject(projectPath) {
6
+ return realpathSync(resolve(projectPath));
7
+ }
8
+ function git(args, cwd) {
9
+ return execFileSync("git", args, { cwd, encoding: "utf-8" }).trim();
10
+ }
11
+ function buildHunkPatch(diffText, file, indices) {
12
+ if (!diffText)
13
+ return null;
14
+ const lines = diffText.split("\n");
15
+ const hunkStarts = [];
16
+ for (let i = 0; i < lines.length; i++) {
17
+ if (lines[i].startsWith("@@")) {
18
+ hunkStarts.push(i);
19
+ }
20
+ }
21
+ if (hunkStarts.length === 0)
22
+ return null;
23
+ const header = lines.slice(0, hunkStarts[0]).join("\n") + "\n";
24
+ const sortedIndices = [...new Set(indices)].sort((a, b) => a - b);
25
+ let patch = header;
26
+ for (const idx of sortedIndices) {
27
+ if (idx < 0 || idx >= hunkStarts.length) {
28
+ throw new Error(`Hunk index ${idx} out of range for file ${file} (${hunkStarts.length} hunks)`);
29
+ }
30
+ const start = hunkStarts[idx];
31
+ const end = idx + 1 < hunkStarts.length ? hunkStarts[idx + 1] : lines.length;
32
+ patch += lines.slice(start, end).join("\n") + "\n";
33
+ }
34
+ return patch;
35
+ }
36
+ function applyHunks(projectPath, hunks, options) {
37
+ const cwd = resolveProject(projectPath);
38
+ const byFile = new Map();
39
+ for (const h of hunks) {
40
+ const list = byFile.get(h.file) ?? [];
41
+ list.push(h.hunkIndex);
42
+ byFile.set(h.file, list);
43
+ }
44
+ for (const [file, indices] of byFile) {
45
+ const diffText = git([...options.diffArgs, "--", file], cwd);
46
+ const patch = buildHunkPatch(diffText, file, indices);
47
+ if (!patch)
48
+ continue;
49
+ execFileSync("git", [...options.applyArgs, "-"], {
50
+ cwd,
51
+ encoding: "utf-8",
52
+ input: patch,
53
+ });
54
+ }
55
+ }
56
+ // ---- Phase 1: Staging ----
57
+ /** Stage entire files. */
58
+ export function stageFiles(projectPath, files) {
59
+ const cwd = resolveProject(projectPath);
60
+ execFileSync("git", ["add", "--", ...files], { cwd, encoding: "utf-8" });
61
+ }
62
+ /**
63
+ * Stage specific hunks by extracting them from `git diff` and applying via `git apply --cached`.
64
+ *
65
+ * Groups hunks by file, extracts the diff header + requested hunks, then pipes through `git apply`.
66
+ */
67
+ export function stageHunks(projectPath, hunks) {
68
+ applyHunks(projectPath, hunks, {
69
+ diffArgs: ["diff", "--unified=0"],
70
+ applyArgs: ["apply", "--cached", "--unidiff-zero"],
71
+ });
72
+ }
73
+ /** Unstage files (remove from index, keep working tree changes). */
74
+ export function unstageFiles(projectPath, files) {
75
+ const cwd = resolveProject(projectPath);
76
+ execFileSync("git", ["reset", "HEAD", "--", ...files], {
77
+ cwd,
78
+ encoding: "utf-8",
79
+ });
80
+ }
81
+ /** Unstage specific hunks from the index, leaving the working tree intact. */
82
+ export function unstageHunks(projectPath, hunks) {
83
+ applyHunks(projectPath, hunks, {
84
+ diffArgs: ["diff", "--cached", "--unified=0"],
85
+ applyArgs: ["apply", "-R", "--cached", "--unidiff-zero"],
86
+ });
87
+ }
88
+ // ---- Phase 2: Commit / Push ----
89
+ /** Create a commit with the given message. Throws if nothing is staged. */
90
+ export function gitCommit(projectPath, message) {
91
+ const cwd = resolveProject(projectPath);
92
+ // Check if there's anything staged
93
+ const staged = git(["diff", "--cached", "--name-only"], cwd);
94
+ if (!staged) {
95
+ throw new Error("Nothing to commit: no files are staged");
96
+ }
97
+ execFileSync("git", ["commit", "-m", message], { cwd, encoding: "utf-8" });
98
+ const hash = git(["rev-parse", "--short", "HEAD"], cwd);
99
+ return { hash, message };
100
+ }
101
+ /** Return staged diff content for commit-message generation. */
102
+ export function getStagedDiff(projectPath) {
103
+ const cwd = resolveProject(projectPath);
104
+ return execFileSync("git", ["diff", "--cached", "--no-color"], {
105
+ cwd,
106
+ encoding: "utf-8",
107
+ });
108
+ }
109
+ /** Push to remote. */
110
+ export function gitPush(projectPath) {
111
+ const cwd = resolveProject(projectPath);
112
+ const branch = git(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
113
+ execFileSync("git", ["push", "--set-upstream", "origin", branch], {
114
+ cwd,
115
+ encoding: "utf-8",
116
+ });
117
+ }
118
+ // ---- Phase 3: Branch Operations ----
119
+ /** List branches and branches checked out by worktrees. */
120
+ export function listBranches(projectPath) {
121
+ const cwd = resolveProject(projectPath);
122
+ const current = git(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
123
+ const output = git(["branch", "--list", "--format=%(refname:short)"], cwd);
124
+ const branches = output ? output.split("\n").filter(Boolean) : [];
125
+ // Collect branches checked out by worktrees (+ main repo)
126
+ const checkedOutBranches = [];
127
+ try {
128
+ const wtOutput = execFileSync("git", ["worktree", "list", "--porcelain"], {
129
+ cwd,
130
+ encoding: "utf-8",
131
+ });
132
+ for (const line of wtOutput.split("\n")) {
133
+ if (line.startsWith("branch ")) {
134
+ const branch = line
135
+ .slice("branch ".length)
136
+ .replace(/^refs\/heads\//, "");
137
+ checkedOutBranches.push(branch);
138
+ }
139
+ }
140
+ }
141
+ catch {
142
+ /* ignore if worktree command fails */
143
+ }
144
+ const remoteStatusByBranch = Object.fromEntries(branches.map((branch) => [branch, getBranchRemoteStatus(cwd, branch)]));
145
+ return { current, branches, checkedOutBranches, remoteStatusByBranch };
146
+ }
147
+ function getBranchRemoteStatus(cwd, branch) {
148
+ const upstream = execFileSync("git", ["for-each-ref", "--format=%(upstream:short)", `refs/heads/${branch}`], { cwd, encoding: "utf-8" }).trim();
149
+ if (!upstream) {
150
+ return { ahead: 0, behind: 0, hasUpstream: false };
151
+ }
152
+ let ahead = 0;
153
+ let behind = 0;
154
+ try {
155
+ ahead =
156
+ parseInt(git(["rev-list", "--count", `${upstream}..${branch}`], cwd), 10) || 0;
157
+ }
158
+ catch {
159
+ ahead = 0;
160
+ }
161
+ try {
162
+ behind =
163
+ parseInt(git(["rev-list", "--count", `${branch}..${upstream}`], cwd), 10) || 0;
164
+ }
165
+ catch {
166
+ behind = 0;
167
+ }
168
+ return { ahead, behind, hasUpstream: true };
169
+ }
170
+ /** Create a new branch, optionally checking it out. */
171
+ export function createBranch(projectPath, name, checkout) {
172
+ const cwd = resolveProject(projectPath);
173
+ if (checkout) {
174
+ execFileSync("git", ["checkout", "-b", name], { cwd, encoding: "utf-8" });
175
+ }
176
+ else {
177
+ execFileSync("git", ["branch", name], { cwd, encoding: "utf-8" });
178
+ }
179
+ }
180
+ /** Checkout an existing branch. */
181
+ export function checkoutBranch(projectPath, branch) {
182
+ const cwd = resolveProject(projectPath);
183
+ execFileSync("git", ["checkout", branch], { cwd, encoding: "utf-8" });
184
+ }
185
+ /** Revert (discard) unstaged changes for specific files. */
186
+ export function revertFiles(projectPath, files) {
187
+ const cwd = resolveProject(projectPath);
188
+ execFileSync("git", ["checkout", "--", ...files], { cwd, encoding: "utf-8" });
189
+ }
190
+ /** Revert specific working-tree hunks, leaving the index intact. */
191
+ export function revertHunks(projectPath, hunks) {
192
+ applyHunks(projectPath, hunks, {
193
+ diffArgs: ["diff", "--unified=0"],
194
+ applyArgs: ["apply", "-R", "--unidiff-zero"],
195
+ });
196
+ }
197
+ /** Fetch from remote (non-blocking, returns when done). */
198
+ export function gitFetch(projectPath) {
199
+ const cwd = resolveProject(projectPath);
200
+ execFileSync("git", ["fetch", "--quiet"], {
201
+ cwd,
202
+ encoding: "utf-8",
203
+ timeout: 30000,
204
+ });
205
+ }
206
+ /** Get ahead/behind counts relative to upstream. */
207
+ export function gitRemoteStatus(projectPath) {
208
+ const cwd = resolveProject(projectPath);
209
+ const branch = git(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
210
+ // Check if upstream is configured
211
+ let hasUpstream = false;
212
+ try {
213
+ git(["rev-parse", "--abbrev-ref", `${branch}@{upstream}`], cwd);
214
+ hasUpstream = true;
215
+ }
216
+ catch {
217
+ return { ahead: 0, behind: 0, branch, hasUpstream: false };
218
+ }
219
+ let ahead = 0;
220
+ let behind = 0;
221
+ try {
222
+ const aheadStr = git(["rev-list", "--count", `@{upstream}..HEAD`], cwd);
223
+ ahead = parseInt(aheadStr, 10) || 0;
224
+ }
225
+ catch {
226
+ /* ignore */
227
+ }
228
+ try {
229
+ const behindStr = git(["rev-list", "--count", `HEAD..@{upstream}`], cwd);
230
+ behind = parseInt(behindStr, 10) || 0;
231
+ }
232
+ catch {
233
+ /* ignore */
234
+ }
235
+ return { ahead, behind, branch, hasUpstream };
236
+ }
237
+ /** Pull from remote (fetch + merge). */
238
+ export function gitPull(projectPath) {
239
+ const cwd = resolveProject(projectPath);
240
+ try {
241
+ const output = execFileSync("git", ["pull"], {
242
+ cwd,
243
+ encoding: "utf-8",
244
+ }).trim();
245
+ return { success: true, message: output };
246
+ }
247
+ catch (err) {
248
+ return { success: false, message: String(err) };
249
+ }
250
+ }
251
+ //# sourceMappingURL=git-operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-operations.js","sourceRoot":"","sources":["../src/git-operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4BpC,oBAAoB;AAEpB,SAAS,cAAc,CAAC,WAAmB;IACzC,OAAO,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,GAAG,CAAC,IAAc,EAAE,GAAW;IACtC,OAAO,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,OA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OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AAChD,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,OAAO,CAAC,WAAmB;IAIzC,MAAM,GAAG,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE;YAC3C,GAAG;YACH,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAC5C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IAClD,CAAC;AACH,CAAC"}
package/dist/parser.d.ts CHANGED
@@ -162,6 +162,7 @@ export type ClientMessage = {
162
162
  } | {
163
163
  type: "get_diff";
164
164
  projectPath: string;
165
+ staged?: boolean;
165
166
  } | {
166
167
  type: "get_diff_image";
167
168
  projectPath: string;
@@ -232,6 +233,66 @@ export type ClientMessage = {
232
233
  } | {
233
234
  type: "refresh_branch";
234
235
  sessionId: string;
236
+ } | {
237
+ type: "git_stage";
238
+ projectPath: string;
239
+ files?: string[];
240
+ hunks?: {
241
+ file: string;
242
+ hunkIndex: number;
243
+ }[];
244
+ } | {
245
+ type: "git_unstage";
246
+ projectPath: string;
247
+ files?: string[];
248
+ } | {
249
+ type: "git_unstage_hunks";
250
+ projectPath: string;
251
+ hunks: {
252
+ file: string;
253
+ hunkIndex: number;
254
+ }[];
255
+ } | {
256
+ type: "git_commit";
257
+ projectPath: string;
258
+ sessionId?: string;
259
+ message?: string;
260
+ autoGenerate?: boolean;
261
+ } | {
262
+ type: "git_push";
263
+ projectPath: string;
264
+ } | {
265
+ type: "git_branches";
266
+ projectPath: string;
267
+ } | {
268
+ type: "git_create_branch";
269
+ projectPath: string;
270
+ name: string;
271
+ checkout?: boolean;
272
+ } | {
273
+ type: "git_checkout_branch";
274
+ projectPath: string;
275
+ branch: string;
276
+ } | {
277
+ type: "git_revert_file";
278
+ projectPath: string;
279
+ files: string[];
280
+ } | {
281
+ type: "git_revert_hunks";
282
+ projectPath: string;
283
+ hunks: {
284
+ file: string;
285
+ hunkIndex: number;
286
+ }[];
287
+ } | {
288
+ type: "git_fetch";
289
+ projectPath: string;
290
+ } | {
291
+ type: "git_pull";
292
+ projectPath: string;
293
+ } | {
294
+ type: "git_remote_status";
295
+ projectPath: string;
235
296
  };
236
297
  /** Image change detected in a git diff (binary image file). */
237
298
  export interface ImageChange {
@@ -474,6 +535,70 @@ export type ServerMessage = {
474
535
  name: string | null;
475
536
  success: boolean;
476
537
  error?: string;
538
+ } | {
539
+ type: "git_stage_result";
540
+ success: boolean;
541
+ error?: string;
542
+ } | {
543
+ type: "git_unstage_result";
544
+ success: boolean;
545
+ error?: string;
546
+ } | {
547
+ type: "git_unstage_hunks_result";
548
+ success: boolean;
549
+ error?: string;
550
+ } | {
551
+ type: "git_commit_result";
552
+ success: boolean;
553
+ commitHash?: string;
554
+ message?: string;
555
+ error?: string;
556
+ } | {
557
+ type: "git_push_result";
558
+ success: boolean;
559
+ error?: string;
560
+ } | {
561
+ type: "git_branches_result";
562
+ current: string;
563
+ branches: string[];
564
+ checkedOutBranches?: string[];
565
+ remoteStatusByBranch?: Record<string, {
566
+ ahead: number;
567
+ behind: number;
568
+ hasUpstream: boolean;
569
+ }>;
570
+ error?: string;
571
+ } | {
572
+ type: "git_create_branch_result";
573
+ success: boolean;
574
+ error?: string;
575
+ } | {
576
+ type: "git_checkout_branch_result";
577
+ success: boolean;
578
+ error?: string;
579
+ } | {
580
+ type: "git_revert_file_result";
581
+ success: boolean;
582
+ error?: string;
583
+ } | {
584
+ type: "git_revert_hunks_result";
585
+ success: boolean;
586
+ error?: string;
587
+ } | {
588
+ type: "git_fetch_result";
589
+ success: boolean;
590
+ error?: string;
591
+ } | {
592
+ type: "git_pull_result";
593
+ success: boolean;
594
+ message?: string;
595
+ error?: string;
596
+ } | {
597
+ type: "git_remote_status_result";
598
+ ahead: number;
599
+ behind: number;
600
+ branch: string;
601
+ hasUpstream: boolean;
477
602
  };
478
603
  export interface UsageWindowPayload {
479
604
  utilization: number;