@kenkaiiii/ggcoder 7.3.1 → 7.4.1
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.
- package/dist/app-sidecar/app-settings.d.ts +0 -3
- package/dist/app-sidecar/app-settings.js +3 -3
- package/dist/app-sidecar/app-settings.js.map +1 -1
- package/dist/app-sidecar/autopilot-runner.d.ts +2 -1
- package/dist/app-sidecar/autopilot-runner.js +1 -1
- package/dist/app-sidecar/autopilot-runner.js.map +1 -1
- package/dist/app-sidecar/feature-map-watch.d.ts +2 -0
- package/dist/app-sidecar/feature-map-watch.js +11 -0
- package/dist/app-sidecar/feature-map-watch.js.map +1 -1
- package/dist/app-sidecar/fix-all-checkout.d.ts +45 -0
- package/dist/app-sidecar/fix-all-checkout.js +100 -0
- package/dist/app-sidecar/fix-all-checkout.js.map +1 -0
- package/dist/app-sidecar/fix-all-checks.d.ts +58 -0
- package/dist/app-sidecar/fix-all-checks.js +426 -0
- package/dist/app-sidecar/fix-all-checks.js.map +1 -0
- package/dist/app-sidecar/fix-all-git.d.ts +81 -0
- package/dist/app-sidecar/fix-all-git.js +271 -0
- package/dist/app-sidecar/fix-all-git.js.map +1 -0
- package/dist/app-sidecar/fix-all-journal.d.ts +56 -0
- package/dist/app-sidecar/fix-all-journal.js +68 -0
- package/dist/app-sidecar/fix-all-journal.js.map +1 -0
- package/dist/app-sidecar/fix-all-launch.d.ts +23 -0
- package/dist/app-sidecar/fix-all-launch.js +77 -0
- package/dist/app-sidecar/fix-all-launch.js.map +1 -0
- package/dist/app-sidecar/fix-all-routes.d.ts +10 -0
- package/dist/app-sidecar/fix-all-routes.js +100 -0
- package/dist/app-sidecar/fix-all-routes.js.map +1 -0
- package/dist/app-sidecar/fix-all-runner.d.ts +163 -0
- package/dist/app-sidecar/fix-all-runner.js +1012 -0
- package/dist/app-sidecar/fix-all-runner.js.map +1 -0
- package/dist/app-sidecar/prompt-routes.js +6 -0
- package/dist/app-sidecar/prompt-routes.js.map +1 -1
- package/dist/app-sidecar/route-context.d.ts +7 -0
- package/dist/app-sidecar/run-control-routes.js +1 -0
- package/dist/app-sidecar/run-control-routes.js.map +1 -1
- package/dist/app-sidecar/run-progress.d.ts +7 -0
- package/dist/app-sidecar/run-progress.js +56 -0
- package/dist/app-sidecar/run-progress.js.map +1 -0
- package/dist/app-sidecar/session-broadcast.d.ts +11 -0
- package/dist/app-sidecar/session-broadcast.js +11 -0
- package/dist/app-sidecar/session-broadcast.js.map +1 -0
- package/dist/app-sidecar/session-routes.d.ts +1 -0
- package/dist/app-sidecar/session-routes.js +1 -0
- package/dist/app-sidecar/session-routes.js.map +1 -1
- package/dist/app-sidecar/session-types.d.ts +3 -0
- package/dist/app-sidecar/session-types.js.map +1 -1
- package/dist/app-sidecar/shell-routes.js +6 -0
- package/dist/app-sidecar/shell-routes.js.map +1 -1
- package/dist/app-sidecar/worktrees.d.ts +2 -0
- package/dist/app-sidecar/worktrees.js +5 -1
- package/dist/app-sidecar/worktrees.js.map +1 -1
- package/dist/app-sidecar.js +226 -17
- package/dist/app-sidecar.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { FEATURE_MAP_FILE } from "@kenkaiiii/gg-engine/internal/core/feature-map-manifest.js";
|
|
5
|
+
import { checkoutRoot } from "@kenkaiiii/gg-engine/internal/core/shared-checkout-guard.js";
|
|
6
|
+
import { realpathNative, runBackgroundGit } from "@kenkaiiii/gg-engine/internal/utils/git.js";
|
|
7
|
+
import { copyLocalFiles, runUserGit, worktreePathFor } from "./git-branches.js";
|
|
8
|
+
import { mainCheckoutOf } from "./worktrees.js";
|
|
9
|
+
// Fix all's git: a run works on a branch of its own in a GG worktree of its own (the project's
|
|
10
|
+
// folder is never touched), commits each fix with the user's git (hooks run, never --no-verify),
|
|
11
|
+
// and undoes a failed fix by resetting to the run's own last commit. Every reset re-checks that
|
|
12
|
+
// it's still the run's branch and checkout.
|
|
13
|
+
const READ_TIMEOUT_MS = 10_000;
|
|
14
|
+
/** Hooks run on commit and can be slow. */
|
|
15
|
+
const COMMIT_TIMEOUT_MS = 10 * 60_000;
|
|
16
|
+
/** Never `--no-verify`: the repo's hooks are part of the checks. */
|
|
17
|
+
export const COMMIT_ARGS = ["commit", "-F", "-"];
|
|
18
|
+
/** A guard refused: nothing was changed. `message` is safe to show the user. */
|
|
19
|
+
export class FixAllGuardError extends Error {
|
|
20
|
+
name = "FixAllGuardError";
|
|
21
|
+
}
|
|
22
|
+
const read = async (dir, args) => (await runBackgroundGit(args, { cwd: dir, timeoutMs: READ_TIMEOUT_MS })).stdout;
|
|
23
|
+
export async function currentBranch(dir) {
|
|
24
|
+
try {
|
|
25
|
+
return (await read(dir, ["symbolic-ref", "--quiet", "--short", "HEAD"])).trim() || null;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function headCommit(dir) {
|
|
32
|
+
try {
|
|
33
|
+
return (await read(dir, ["rev-parse", "--verify", "--quiet", "HEAD^{commit}"])).trim() || null;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Whether `commit` is behind (or at) HEAD. */
|
|
40
|
+
export async function isAncestorOfHead(dir, commit) {
|
|
41
|
+
try {
|
|
42
|
+
await read(dir, ["merge-base", "--is-ancestor", commit, "HEAD"]);
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Repo-relative paths `git status` lists (tracked changes and untracked files; not ignored ones). */
|
|
50
|
+
export async function changedPaths(dir) {
|
|
51
|
+
const out = await read(dir, ["status", "--porcelain=v1", "-z", "--untracked-files=all"]);
|
|
52
|
+
const parts = out.split("\0");
|
|
53
|
+
const paths = [];
|
|
54
|
+
for (let i = 0; i < parts.length; i++) {
|
|
55
|
+
const entry = parts[i] ?? "";
|
|
56
|
+
if (entry.length < 4)
|
|
57
|
+
continue;
|
|
58
|
+
paths.push(entry.slice(3));
|
|
59
|
+
// A rename or copy carries its old path as the next entry.
|
|
60
|
+
if (entry[0] === "R" || entry[0] === "C")
|
|
61
|
+
i++;
|
|
62
|
+
}
|
|
63
|
+
return paths;
|
|
64
|
+
}
|
|
65
|
+
const IN_PROGRESS = [
|
|
66
|
+
["MERGE_HEAD", "a merge"],
|
|
67
|
+
["rebase-merge", "a rebase"],
|
|
68
|
+
["rebase-apply", "a rebase"],
|
|
69
|
+
["CHERRY_PICK_HEAD", "a cherry-pick"],
|
|
70
|
+
["REVERT_HEAD", "a revert"],
|
|
71
|
+
["BISECT_LOG", "a bisect"],
|
|
72
|
+
];
|
|
73
|
+
/**
|
|
74
|
+
* The checkout is safe to run in (clean, on a branch, no merge or rebase under way, and on
|
|
75
|
+
* `opts.branch` when given), or a FixAllGuardError saying why not.
|
|
76
|
+
*/
|
|
77
|
+
export async function preflightTree(dir, opts = {}) {
|
|
78
|
+
const root = await checkoutRoot(dir);
|
|
79
|
+
if (!root)
|
|
80
|
+
throw new FixAllGuardError("This folder isn't a Git repository.");
|
|
81
|
+
const head = await headCommit(dir);
|
|
82
|
+
if (!head)
|
|
83
|
+
throw new FixAllGuardError("This repository has no commits yet.");
|
|
84
|
+
const branch = await currentBranch(dir);
|
|
85
|
+
if (!branch) {
|
|
86
|
+
throw new FixAllGuardError("This checkout isn't on a branch (detached HEAD). Switch to one first.");
|
|
87
|
+
}
|
|
88
|
+
if (opts.branch && branch !== opts.branch) {
|
|
89
|
+
throw new FixAllGuardError(`The run's folder is on ${branch}, not the run's branch ${opts.branch}. Nothing was changed.`);
|
|
90
|
+
}
|
|
91
|
+
const gitDir = (await read(dir, ["rev-parse", "--absolute-git-dir"])).trim();
|
|
92
|
+
for (const [name, what] of IN_PROGRESS) {
|
|
93
|
+
if (existsSync(path.join(gitDir, name))) {
|
|
94
|
+
throw new FixAllGuardError(`Git is in the middle of ${what}. Finish or abort it first.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const changed = await changedPaths(dir);
|
|
98
|
+
if (changed.length > 0) {
|
|
99
|
+
throw new FixAllGuardError(`There ${changed.length === 1 ? "is 1 uncommitted file" : `are ${changed.length} uncommitted files`}. Commit or stash them first, so a fix that's undone can't take your work with it.`);
|
|
100
|
+
}
|
|
101
|
+
return { root, branch, head };
|
|
102
|
+
}
|
|
103
|
+
/** What a run is keyed by: the repository's main folder, the same from any worktree of it. */
|
|
104
|
+
export async function repoKey(dir) {
|
|
105
|
+
return (await mainCheckoutOf(dir)) ?? (await checkoutRoot(dir));
|
|
106
|
+
}
|
|
107
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
108
|
+
/** `gg/fix-all-20261202-1615`, with `-2`, `-3`… when taken. */
|
|
109
|
+
export function fixAllBranchName(now, taken) {
|
|
110
|
+
const base = `gg/fix-all-${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}`;
|
|
111
|
+
let name = base;
|
|
112
|
+
for (let n = 2; taken.has(name); n++)
|
|
113
|
+
name = `${base}-${n}`;
|
|
114
|
+
return name;
|
|
115
|
+
}
|
|
116
|
+
async function localBranches(dir) {
|
|
117
|
+
const out = await read(dir, ["for-each-ref", "--format=%(refname:short)", "refs/heads"]);
|
|
118
|
+
return new Set(out.split("\n").filter(Boolean));
|
|
119
|
+
}
|
|
120
|
+
/** A free branch name for a run started now. */
|
|
121
|
+
export async function proposeRunBranch(dir, now) {
|
|
122
|
+
return fixAllBranchName(now, await localBranches(dir).catch(() => new Set()));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The run's branch, at the folder's HEAD, checked out in a new worktree under `worktreesRoot`
|
|
126
|
+
* with the user's git (hooks run). The folder itself is only read. A map file that's new or
|
|
127
|
+
* changed there is carried over as a commit on the run's branch. Any failure removes what it made.
|
|
128
|
+
*/
|
|
129
|
+
export async function createRunWorktree(from, worktreesRoot, now) {
|
|
130
|
+
const root = await checkoutRoot(from);
|
|
131
|
+
if (!root)
|
|
132
|
+
throw new FixAllGuardError("This folder isn't a Git repository.");
|
|
133
|
+
const base = await headCommit(root);
|
|
134
|
+
if (!base)
|
|
135
|
+
throw new FixAllGuardError("This repository has no commits yet.");
|
|
136
|
+
const branch = await proposeRunBranch(root, now);
|
|
137
|
+
const target = await worktreePathFor(worktreesRoot, (await repoKey(root)) ?? root, branch);
|
|
138
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
139
|
+
try {
|
|
140
|
+
await runUserGit(["worktree", "add", "-b", branch, target, base], root, {
|
|
141
|
+
timeoutMs: COMMIT_TIMEOUT_MS,
|
|
142
|
+
});
|
|
143
|
+
const real = await realpathNative(target);
|
|
144
|
+
const copied = await copyLocalFiles(root, real).catch(() => []);
|
|
145
|
+
const mapCommitted = await carryMap(root, real);
|
|
146
|
+
return { branch, base, path: real, copied, mapCommitted };
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
await discardRunWorktree(root, target, branch);
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** Copy the folder's map in when it differs; commit it unless the project ignores it. */
|
|
154
|
+
async function carryMap(from, to) {
|
|
155
|
+
const text = await fs.readFile(path.join(from, FEATURE_MAP_FILE)).catch(() => null);
|
|
156
|
+
if (!text)
|
|
157
|
+
return false;
|
|
158
|
+
const dest = path.join(to, FEATURE_MAP_FILE);
|
|
159
|
+
const have = await fs.readFile(dest).catch(() => null);
|
|
160
|
+
if (have?.equals(text))
|
|
161
|
+
return false;
|
|
162
|
+
await fs.writeFile(dest, text);
|
|
163
|
+
const ignored = await read(to, ["check-ignore", "-q", "--", FEATURE_MAP_FILE]).then(() => true, () => false);
|
|
164
|
+
if (ignored)
|
|
165
|
+
return false;
|
|
166
|
+
await runUserGit(["add", "--", FEATURE_MAP_FILE], to);
|
|
167
|
+
await runUserGit(COMMIT_ARGS, to, {
|
|
168
|
+
input: "Add the feature map\n",
|
|
169
|
+
timeoutMs: COMMIT_TIMEOUT_MS,
|
|
170
|
+
});
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Remove an ended run's worktree and branch when they hold nothing to review: a GG worktree (under
|
|
175
|
+
* `worktreesRoot`, never the main folder), still on the run's branch at the commit it started from,
|
|
176
|
+
* with no uncommitted changes (ignored files such as `node_modules` and `.env` don't count). False,
|
|
177
|
+
* changing nothing, when any of that doesn't hold.
|
|
178
|
+
*/
|
|
179
|
+
export async function removeEmptyRunWorktree(run, worktreesRoot) {
|
|
180
|
+
const managed = await realpathNative(worktreesRoot).catch(() => path.resolve(worktreesRoot));
|
|
181
|
+
const rel = path.relative(managed, run.root);
|
|
182
|
+
if (!rel || rel.startsWith("..") || path.isAbsolute(rel))
|
|
183
|
+
return false;
|
|
184
|
+
const main = await mainCheckoutOf(run.root);
|
|
185
|
+
if (!main || main === run.root)
|
|
186
|
+
return false;
|
|
187
|
+
if ((await currentBranch(run.root)) !== run.branch)
|
|
188
|
+
return false;
|
|
189
|
+
if ((await headCommit(run.root)) !== run.head)
|
|
190
|
+
return false;
|
|
191
|
+
if ((await changedPaths(run.root).catch(() => ["?"])).length > 0)
|
|
192
|
+
return false;
|
|
193
|
+
// No --force: git refuses itself if anything changed since.
|
|
194
|
+
await runBackgroundGit(["worktree", "remove", run.root], {
|
|
195
|
+
cwd: main,
|
|
196
|
+
timeoutMs: COMMIT_TIMEOUT_MS,
|
|
197
|
+
});
|
|
198
|
+
const tip = await read(main, ["rev-parse", "--verify", "--quiet", `refs/heads/${run.branch}`])
|
|
199
|
+
.then((out) => out.trim())
|
|
200
|
+
.catch(() => "");
|
|
201
|
+
if (tip === run.head) {
|
|
202
|
+
await runBackgroundGit(["branch", "-D", run.branch], {
|
|
203
|
+
cwd: main,
|
|
204
|
+
timeoutMs: READ_TIMEOUT_MS,
|
|
205
|
+
}).catch(() => { });
|
|
206
|
+
}
|
|
207
|
+
// The repo's group folder under worktreesRoot, once its last worktree is gone.
|
|
208
|
+
await fs.rmdir(path.dirname(run.root)).catch(() => { });
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
/** Remove a run's worktree and its branch (best effort): a launch that failed after making them. */
|
|
212
|
+
export async function discardRunWorktree(root, target, branch) {
|
|
213
|
+
await runBackgroundGit(["worktree", "remove", "--force", target], {
|
|
214
|
+
cwd: root,
|
|
215
|
+
timeoutMs: COMMIT_TIMEOUT_MS,
|
|
216
|
+
}).catch(() => { });
|
|
217
|
+
await fs.rm(target, { recursive: true, force: true, maxRetries: 5 }).catch(() => { });
|
|
218
|
+
await runBackgroundGit(["worktree", "prune"], { cwd: root, timeoutMs: READ_TIMEOUT_MS }).catch(() => { });
|
|
219
|
+
await runBackgroundGit(["branch", "-D", branch], {
|
|
220
|
+
cwd: root,
|
|
221
|
+
timeoutMs: READ_TIMEOUT_MS,
|
|
222
|
+
}).catch(() => { });
|
|
223
|
+
}
|
|
224
|
+
async function requireBranch(dir, branch) {
|
|
225
|
+
const now = await currentBranch(dir);
|
|
226
|
+
if (now !== branch) {
|
|
227
|
+
throw new FixAllGuardError(now
|
|
228
|
+
? `The checkout moved to ${now}, off the run's branch ${branch}. Nothing was reset.`
|
|
229
|
+
: `The checkout left the run's branch ${branch} (detached HEAD). Nothing was reset.`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Commit everything the fix changed on the run's branch; null when it changed nothing. */
|
|
233
|
+
export async function commitStep(dir, branch, message) {
|
|
234
|
+
await requireBranch(dir, branch);
|
|
235
|
+
if ((await changedPaths(dir)).length === 0)
|
|
236
|
+
return null;
|
|
237
|
+
await runUserGit(["add", "-A"], dir);
|
|
238
|
+
await runUserGit(COMMIT_ARGS, dir, { input: message, timeoutMs: COMMIT_TIMEOUT_MS });
|
|
239
|
+
return headCommit(dir);
|
|
240
|
+
}
|
|
241
|
+
/** What a rollback to `checkpoint` would discard: uncommitted changes plus commits since it. */
|
|
242
|
+
export async function filesToDiscard(dir, checkpoint) {
|
|
243
|
+
const changed = await changedPaths(dir);
|
|
244
|
+
const committed = (await read(dir, ["diff", "--name-only", "-z", checkpoint, "HEAD"]))
|
|
245
|
+
.split("\0")
|
|
246
|
+
.filter(Boolean);
|
|
247
|
+
return [...new Set([...changed, ...committed])].sort();
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Undo an unfinished fix: `reset --hard` to the run's checkpoint, then `clean -fd` (never `-x`,
|
|
251
|
+
* so ignored files such as `.env` and `node_modules` stay). Returns the files it discarded.
|
|
252
|
+
*/
|
|
253
|
+
export async function rollbackTo(req) {
|
|
254
|
+
const { dir, branch, checkpoint } = req;
|
|
255
|
+
await requireBranch(dir, branch);
|
|
256
|
+
if (!req.allowed.has(checkpoint)) {
|
|
257
|
+
throw new FixAllGuardError("That commit isn't one this run made. Nothing was reset.");
|
|
258
|
+
}
|
|
259
|
+
if (!(await isAncestorOfHead(dir, checkpoint))) {
|
|
260
|
+
throw new FixAllGuardError("The run's last commit is no longer behind this branch's tip. Nothing was reset.");
|
|
261
|
+
}
|
|
262
|
+
if ((await req.othersOnCheckout()) > 0) {
|
|
263
|
+
throw new FixAllGuardError("Another GG Coder window opened this checkout, so the run won't reset it. Nothing was reset.");
|
|
264
|
+
}
|
|
265
|
+
const files = await filesToDiscard(dir, checkpoint);
|
|
266
|
+
await req.onDiscard?.(files);
|
|
267
|
+
await runUserGit(["reset", "--hard", "--quiet", checkpoint], dir);
|
|
268
|
+
await runUserGit(["clean", "-fd", "--quiet"], dir);
|
|
269
|
+
return files;
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=fix-all-git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-all-git.js","sourceRoot":"","sources":["../../src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AC,KAAK,UAAU,UAAU,CAAC,GAAoB;IACnD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;IACxC,MAAM,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,gBAAgB,CAAC,yDAAyD,CAAC,CAAC;IACxF,CAAC;IACD,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,gBAAgB,CACxB,iFAAiF,CAClF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,MAAM,GAAG,CAAC,gBAAgB,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,gBAAgB,CACxB,6FAA6F,CAC9F,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACpD,MAAM,GAAG,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,UAAU,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,CAAC;IAClE,MAAM,UAAU,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { FixAllDone, FixAllFinding, FixAllGroup, FixAllSetAside, FixAllStep } from "@kenkaiiii/gg-protocol";
|
|
2
|
+
import type { FixCheck } from "./fix-all-checks.js";
|
|
3
|
+
export type FixAllJournalStatus = "running" | "paused" | "gate" | "done" | "stopped";
|
|
4
|
+
export interface FixAllJournal {
|
|
5
|
+
readonly version: 1;
|
|
6
|
+
readonly status: FixAllJournalStatus;
|
|
7
|
+
readonly step: FixAllStep | null;
|
|
8
|
+
readonly reason: string | null;
|
|
9
|
+
/** The checkout root the run works in. */
|
|
10
|
+
readonly root: string;
|
|
11
|
+
readonly branch: string;
|
|
12
|
+
/** The commit the branch started from. */
|
|
13
|
+
readonly base: string;
|
|
14
|
+
/** The last commit a rollback goes back to. */
|
|
15
|
+
readonly checkpoint: string;
|
|
16
|
+
/** Commits this run made. */
|
|
17
|
+
readonly commits: readonly string[];
|
|
18
|
+
readonly startCount: number;
|
|
19
|
+
readonly steps: number;
|
|
20
|
+
readonly failStreak: number;
|
|
21
|
+
readonly restructureConfirmed: boolean;
|
|
22
|
+
/** Action ids set aside: never queued again. */
|
|
23
|
+
readonly settled: readonly string[];
|
|
24
|
+
/** Action id → times a passing fix left it still flagged. */
|
|
25
|
+
readonly retried: Readonly<Record<string, number>>;
|
|
26
|
+
/** The group in progress; non-null while a step is unfinished. */
|
|
27
|
+
readonly current: FixAllGroup | null;
|
|
28
|
+
readonly done: readonly FixAllDone[];
|
|
29
|
+
readonly setAside: readonly FixAllSetAside[];
|
|
30
|
+
readonly needsYou: readonly FixAllFinding[];
|
|
31
|
+
readonly next: readonly FixAllGroup[];
|
|
32
|
+
/** Groups still queued after the current one (`next` is capped). */
|
|
33
|
+
readonly queued: number;
|
|
34
|
+
/** Files the last rollback discarded, or a resume would. */
|
|
35
|
+
readonly discard: readonly string[];
|
|
36
|
+
/** How many fixes were done when the full checks last passed (fixes are checked scoped). */
|
|
37
|
+
readonly fullAt?: number;
|
|
38
|
+
/** The checks that passed at the start: every fix runs (some of) these, resumed or not. */
|
|
39
|
+
readonly checks?: readonly FixCheck[];
|
|
40
|
+
/** Checks left out and code left for the user, in a sentence. */
|
|
41
|
+
readonly unchecked?: string | null;
|
|
42
|
+
readonly startedAt: string;
|
|
43
|
+
readonly updatedAt: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const markJournalLive: (file: string, on: boolean) => void;
|
|
46
|
+
export declare function fixAllJournalPath(stateDir: string, root: string): string;
|
|
47
|
+
export interface LoadedJournal {
|
|
48
|
+
readonly journal: FixAllJournal;
|
|
49
|
+
/** It says running, but nothing in this process is running it: the app quit mid-run. */
|
|
50
|
+
readonly interrupted: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** The run's journal, or null when there's none (or it can't be read). */
|
|
53
|
+
export declare function loadFixAllJournal(file: string): Promise<LoadedJournal | null>;
|
|
54
|
+
/** Write it whole or not at all: a temp file renamed over the old one. */
|
|
55
|
+
export declare function saveFixAllJournal(file: string, journal: FixAllJournal): Promise<void>;
|
|
56
|
+
export declare function removeFixAllJournal(file: string): Promise<void>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { retryWindowsReplace } from "@kenkaiiii/gg-engine/internal/core/session-storage.js";
|
|
5
|
+
/** Journals of runs in progress in this process. One left `running` without it was cut short. */
|
|
6
|
+
const live = new Set();
|
|
7
|
+
export const markJournalLive = (file, on) => {
|
|
8
|
+
if (on)
|
|
9
|
+
live.add(file);
|
|
10
|
+
else
|
|
11
|
+
live.delete(file);
|
|
12
|
+
};
|
|
13
|
+
export function fixAllJournalPath(stateDir, root) {
|
|
14
|
+
const hash = createHash("sha256").update(root).digest("hex").slice(0, 16);
|
|
15
|
+
return path.join(stateDir, `${hash}.fix-all.json`);
|
|
16
|
+
}
|
|
17
|
+
const STATUSES = new Set(["running", "paused", "gate", "done", "stopped"]);
|
|
18
|
+
function valid(o) {
|
|
19
|
+
if (typeof o !== "object" || o === null)
|
|
20
|
+
return false;
|
|
21
|
+
const j = o;
|
|
22
|
+
const str = (k) => typeof j[k] === "string" && j[k].length > 0;
|
|
23
|
+
const arr = (k) => Array.isArray(j[k]);
|
|
24
|
+
return (j.version === 1 &&
|
|
25
|
+
typeof j.status === "string" &&
|
|
26
|
+
STATUSES.has(j.status) &&
|
|
27
|
+
["root", "branch", "base", "checkpoint", "startedAt", "updatedAt"].every(str) &&
|
|
28
|
+
["commits", "settled", "done", "setAside", "needsYou", "next", "discard"].every(arr) &&
|
|
29
|
+
typeof j.retried === "object" &&
|
|
30
|
+
j.retried !== null &&
|
|
31
|
+
["startCount", "steps", "failStreak", "queued"].every((k) => typeof j[k] === "number") &&
|
|
32
|
+
(j.checks === undefined ||
|
|
33
|
+
(Array.isArray(j.checks) &&
|
|
34
|
+
j.checks.every((c) => typeof c === "object" &&
|
|
35
|
+
c !== null &&
|
|
36
|
+
typeof c.command === "string" &&
|
|
37
|
+
typeof c.language === "string"))));
|
|
38
|
+
}
|
|
39
|
+
/** The run's journal, or null when there's none (or it can't be read). */
|
|
40
|
+
export async function loadFixAllJournal(file) {
|
|
41
|
+
let parsed;
|
|
42
|
+
try {
|
|
43
|
+
parsed = JSON.parse(await fs.readFile(file, "utf8"));
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (!valid(parsed))
|
|
49
|
+
return null;
|
|
50
|
+
return { journal: parsed, interrupted: parsed.status === "running" && !live.has(file) };
|
|
51
|
+
}
|
|
52
|
+
/** Write it whole or not at all: a temp file renamed over the old one. */
|
|
53
|
+
export async function saveFixAllJournal(file, journal) {
|
|
54
|
+
const tmp = `${file}.${randomUUID()}.tmp`;
|
|
55
|
+
try {
|
|
56
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
57
|
+
await fs.writeFile(tmp, JSON.stringify(journal));
|
|
58
|
+
await retryWindowsReplace(() => fs.rename(tmp, file));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
await fs.rm(tmp, { force: true }).catch(() => { });
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export async function removeFixAllJournal(file) {
|
|
66
|
+
await fs.rm(file, { force: true });
|
|
67
|
+
}
|
|
68
|
+
//# sourceMapp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C,IAAY;IACpD,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type RunWorktree } from "./fix-all-git.js";
|
|
2
|
+
import type { FixAllLaunchRequest, FixAllRunner } from "./fix-all-runner.js";
|
|
3
|
+
export interface FixAllLaunchDeps {
|
|
4
|
+
/** `~/.gg/worktrees`. */
|
|
5
|
+
readonly worktreesRoot: string;
|
|
6
|
+
readonly createWorktree: (from: string, worktreesRoot: string, now: Date) => Promise<RunWorktree>;
|
|
7
|
+
/** Undo a worktree made for a launch that then failed. */
|
|
8
|
+
readonly discardWorktree: (from: string, made: RunWorktree) => Promise<void>;
|
|
9
|
+
/** A code session in `cwd`, and its Fix all runner (null when it has none). */
|
|
10
|
+
readonly openSession: (cwd: string) => Promise<{
|
|
11
|
+
id: string;
|
|
12
|
+
runner: FixAllRunner | null;
|
|
13
|
+
}>;
|
|
14
|
+
/** Keep it working with no window; false when it wasn't kept. */
|
|
15
|
+
readonly detach: (id: string) => boolean;
|
|
16
|
+
readonly close: (id: string) => Promise<void>;
|
|
17
|
+
/** The runner that owns the repository's run now, if any. */
|
|
18
|
+
readonly live: (key: string) => FixAllRunner | null;
|
|
19
|
+
readonly exists: (dir: string) => boolean;
|
|
20
|
+
readonly log: (level: "INFO" | "WARN", message: string, data?: Record<string, string>) => void;
|
|
21
|
+
readonly now?: () => Date;
|
|
22
|
+
}
|
|
23
|
+
export declare function createFixAllLauncher(deps: FixAllLaunchDeps): (request: FixAllLaunchRequest) => Promise<FixAllRunner>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { FixAllGuardError } from "./fix-all-git.js";
|
|
2
|
+
const IN_PROGRESS = "A Fix all run is already in progress.";
|
|
3
|
+
const errText = (e) => (e instanceof Error ? e.message : String(e));
|
|
4
|
+
const FINISHED = new Set(["done", "stopped"]);
|
|
5
|
+
export function createFixAllLauncher(deps) {
|
|
6
|
+
const now = deps.now ?? (() => new Date());
|
|
7
|
+
/** Repositories a launch is under way for: two Starts at once get one run. */
|
|
8
|
+
const launching = new Set();
|
|
9
|
+
/** Open the run's session, hand it the run, then let it work with no window. */
|
|
10
|
+
async function handOff(cwd, take) {
|
|
11
|
+
const { id, runner } = await deps.openSession(cwd);
|
|
12
|
+
try {
|
|
13
|
+
if (!runner)
|
|
14
|
+
throw new FixAllGuardError("The run's folder couldn't open a code session.");
|
|
15
|
+
await take(runner);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
await deps.close(id).catch(() => { });
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
if (!deps.detach(id))
|
|
22
|
+
deps.log("WARN", "fix-all: the run's session wasn't kept", { id });
|
|
23
|
+
deps.log("INFO", "fix-all: launched", { id, cwd });
|
|
24
|
+
return runner;
|
|
25
|
+
}
|
|
26
|
+
return async function launch(request) {
|
|
27
|
+
if (launching.has(request.key))
|
|
28
|
+
throw new FixAllGuardError(IN_PROGRESS);
|
|
29
|
+
launching.add(request.key);
|
|
30
|
+
try {
|
|
31
|
+
const owner = deps.live(request.key);
|
|
32
|
+
if (request.kind === "resume") {
|
|
33
|
+
if (owner) {
|
|
34
|
+
await owner.resume(request.confirmRestructure ? { confirmRestructure: true } : {});
|
|
35
|
+
return owner;
|
|
36
|
+
}
|
|
37
|
+
if (!deps.exists(request.root)) {
|
|
38
|
+
throw new FixAllGuardError("The run's folder is gone, so it can't be resumed. Stop the run instead.");
|
|
39
|
+
}
|
|
40
|
+
return await handOff(request.root, (runner) => runner.resume(request.confirmRestructure ? { confirmRestructure: true } : {}));
|
|
41
|
+
}
|
|
42
|
+
// A finished run's summary makes way for the new one; anything else is still a run.
|
|
43
|
+
if (owner) {
|
|
44
|
+
if (owner.working() || !FINISHED.has((await owner.state()).status)) {
|
|
45
|
+
throw new FixAllGuardError(IN_PROGRESS);
|
|
46
|
+
}
|
|
47
|
+
await owner.stop();
|
|
48
|
+
}
|
|
49
|
+
let made;
|
|
50
|
+
try {
|
|
51
|
+
made = await deps.createWorktree(request.from, deps.worktreesRoot, now());
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error instanceof FixAllGuardError)
|
|
55
|
+
throw error;
|
|
56
|
+
throw new FixAllGuardError(`Couldn't make the run's folder: ${errText(error)}`);
|
|
57
|
+
}
|
|
58
|
+
deps.log("INFO", "fix-all: made the run's worktree", {
|
|
59
|
+
branch: made.branch,
|
|
60
|
+
path: made.path,
|
|
61
|
+
copied: made.copied.join(", "),
|
|
62
|
+
map: made.mapCommitted ? "committed" : "unchanged",
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
return await handOff(made.path, (runner) => runner.beginInWorktree({ branch: made.branch, startCount: request.startCount }));
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
await deps.discardWorktree(request.from, made).catch(() => { });
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
launching.delete(request.key);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=fix-all-launch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-all-launch.js","sourceRoot":"","sources":["../../src/app-sidecar/fix-all-launch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AAyBtE,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAC5D,MAAM,OAAO,GAAG,CAAC,CAAU,EAAU,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACrF,MAAM,QAAQ,GAAuC,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAA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AAgB;oBAAE,MAAM,KAAK,CAAC;gBACnD,MAAM,IAAI,gBAAgB,CAAC,mCAAmC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClF,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,kCAAkC,EAAE;gBACnD,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC9B,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;aACnD,CAAC,CAAC;YACH,IAAI,CAAC;gBACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CACzC,MAAM,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAChF,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;gBAC/D,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type http from "node:http";
|
|
2
|
+
import type { FixAllRunner } from "./fix-all-runner.js";
|
|
3
|
+
/**
|
|
4
|
+
* Fix all on the Feature map: `GET /feature-map/fix-all` is the run's state (or, idle, what a run
|
|
5
|
+
* would do); `POST …/start|pause|resume|stop` control it. A refused start or control answers 409
|
|
6
|
+
* with the reason in plain words. Code windows only (`runner` null elsewhere).
|
|
7
|
+
*/
|
|
8
|
+
export declare function handleFixAllRoutes(
|
|
9
|
+
/** The run `action` goes to: the repository's, whichever session drives it (start: this one's). */
|
|
10
|
+
runnerFor: ((action: string) => Promise<FixAllRunner | null>) | null, req: http.IncomingMessage, res: http.ServerResponse, url: string, method: string): boolean;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { log } from "@kenkaiiii/gg-core";
|
|
2
|
+
import { FixAllGuardError } from "./fix-all-git.js";
|
|
3
|
+
import { json, readBody } from "./http.js";
|
|
4
|
+
const BODY_BYTES = 1024;
|
|
5
|
+
const BASE = "/feature-map/fix-all";
|
|
6
|
+
const POSTS = new Set(["start", "pause", "resume", "stop"]);
|
|
7
|
+
/** An empty body or a JSON object; resume's `confirmRestructure` must be a boolean. */
|
|
8
|
+
function parseBody(raw, action) {
|
|
9
|
+
if (!raw.trim())
|
|
10
|
+
return {};
|
|
11
|
+
let o;
|
|
12
|
+
try {
|
|
13
|
+
o = JSON.parse(raw);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (typeof o !== "object" || o === null || Array.isArray(o))
|
|
19
|
+
return null;
|
|
20
|
+
const confirm = o.confirmRestructure;
|
|
21
|
+
if (confirm === undefined)
|
|
22
|
+
return {};
|
|
23
|
+
if (action !== "resume" || typeof confirm !== "boolean")
|
|
24
|
+
return null;
|
|
25
|
+
return { confirmRestructure: confirm };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fix all on the Feature map: `GET /feature-map/fix-all` is the run's state (or, idle, what a run
|
|
29
|
+
* would do); `POST …/start|pause|resume|stop` control it. A refused start or control answers 409
|
|
30
|
+
* with the reason in plain words. Code windows only (`runner` null elsewhere).
|
|
31
|
+
*/
|
|
32
|
+
export function handleFixAllRoutes(
|
|
33
|
+
/** The run `action` goes to: the repository's, whichever session drives it (start: this one's). */
|
|
34
|
+
runnerFor, req, res, url, method) {
|
|
35
|
+
if (url !== BASE && !url.startsWith(`${BASE}/`))
|
|
36
|
+
return false;
|
|
37
|
+
const action = url === BASE ? "" : url.slice(BASE.length + 1);
|
|
38
|
+
if (action !== "" && !POSTS.has(action))
|
|
39
|
+
return false;
|
|
40
|
+
if (!runnerFor) {
|
|
41
|
+
json(res, 404, { error: "Fix all is only in code windows" });
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
const reply = (work) => {
|
|
45
|
+
runnerFor(action)
|
|
46
|
+
.then((runner) => {
|
|
47
|
+
if (!runner)
|
|
48
|
+
throw new FixAllGuardError("Fix all is only in code windows.");
|
|
49
|
+
return work(runner);
|
|
50
|
+
})
|
|
51
|
+
.then((state) => {
|
|
52
|
+
if (!res.destroyed)
|
|
53
|
+
json(res, 200, { state });
|
|
54
|
+
})
|
|
55
|
+
.catch((error) => {
|
|
56
|
+
if (res.destroyed)
|
|
57
|
+
return;
|
|
58
|
+
if (error instanceof FixAllGuardError) {
|
|
59
|
+
json(res, 409, { error: error.message });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
log("WARN", "fix-all", "route failed", { action, error: String(error) });
|
|
63
|
+
json(res, 500, { error: "Fix all couldn't do that. See the app log." });
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
if (action === "") {
|
|
67
|
+
if (method !== "GET")
|
|
68
|
+
json(res, 405, { error: "method not allowed" });
|
|
69
|
+
else
|
|
70
|
+
reply((runner) => runner.state());
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
if (method !== "POST") {
|
|
74
|
+
json(res, 405, { error: "method not allowed" });
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
void (async () => {
|
|
78
|
+
const raw = await readBody(req, res, BODY_BYTES);
|
|
79
|
+
if (raw === null)
|
|
80
|
+
return;
|
|
81
|
+
const body = parseBody(raw, action);
|
|
82
|
+
if (!body) {
|
|
83
|
+
json(res, 400, { error: "invalid body" });
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
reply((runner) => action === "start"
|
|
87
|
+
? runner.start()
|
|
88
|
+
: action === "pause"
|
|
89
|
+
? runner.pause()
|
|
90
|
+
: action === "resume"
|
|
91
|
+
? runner.resume(body)
|
|
92
|
+
: runner.stop());
|
|
93
|
+
})().catch((error) => {
|
|
94
|
+
log("WARN", "fix-all", "route failed", { action, error: String(error) });
|
|
95
|
+
if (!res.destroyed)
|
|
96
|
+
json(res, 500, { error: "Fix all couldn't do that. See the app log." });
|
|
97
|
+
});
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=fix-all-routes.js.map
|