@kenkaiiii/ggcoder 7.3.0 → 7.4.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.
- 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 +1002 -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/dist/ui/App.js +7 -2
- package/dist/ui/App.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { detectLanguages, LANGUAGE_DISPLAY_NAMES, } from "@kenkaiiii/gg-engine/internal/core/language-detector.js";
|
|
6
|
+
import { stripAnsi } from "@kenkaiiii/gg-engine/internal/core/process-manager.js";
|
|
7
|
+
import { resolveShell, } from "@kenkaiiii/gg-engine/internal/core/shell.js";
|
|
8
|
+
import { detectVerifyCommands, } from "@kenkaiiii/gg-engine/internal/core/verify-commands.js";
|
|
9
|
+
import { killProcessTree } from "@kenkaiiii/gg-engine/internal/utils/process.js";
|
|
10
|
+
import { FixAllGuardError } from "./fix-all-git.js";
|
|
11
|
+
import { lockfileSetup, resolveSetupCommand } from "./worktrees.js";
|
|
12
|
+
// Fix all runs the project's own checks itself after each fix: the agent saying they pass isn't
|
|
13
|
+
// enough to commit on. One command at a time, stopping at the first failure.
|
|
14
|
+
export const CHECK_TIMEOUT_MS = 15 * 60_000;
|
|
15
|
+
export const CHECK_TAIL_BYTES = 8 * 1024;
|
|
16
|
+
/** Raw output kept while a command runs; the tail is cut from this. */
|
|
17
|
+
const KEEP_BYTES = 64 * 1024;
|
|
18
|
+
/** The command as shown and reported: where it runs, when that isn't the root. */
|
|
19
|
+
export const checkLabel = (c) => c.dir ? `${c.command} (in ${c.dir})` : c.command;
|
|
20
|
+
// ── Subprojects: their own checks, for the code under them ──
|
|
21
|
+
const SUBPROJECT_MANIFESTS = new Set([
|
|
22
|
+
"package.json",
|
|
23
|
+
"tsconfig.json",
|
|
24
|
+
"Cargo.toml",
|
|
25
|
+
"go.mod",
|
|
26
|
+
"pyproject.toml",
|
|
27
|
+
"Gemfile",
|
|
28
|
+
"mix.exs",
|
|
29
|
+
"composer.json",
|
|
30
|
+
"pom.xml",
|
|
31
|
+
"build.gradle",
|
|
32
|
+
"build.gradle.kts",
|
|
33
|
+
]);
|
|
34
|
+
/** Folders whose manifests aren't projects of this one. */
|
|
35
|
+
const NOT_SUBPROJECTS = /(^|\/)(node_modules|vendor|third_party|fixtures|__fixtures__|testdata)(\/|$)/;
|
|
36
|
+
const MAX_SUBPROJECTS = 12;
|
|
37
|
+
const EXT_LANGUAGE = new Map([
|
|
38
|
+
["typescript", [".ts", ".tsx", ".mts", ".cts"]],
|
|
39
|
+
["javascript", [".js", ".jsx", ".mjs", ".cjs"]],
|
|
40
|
+
["python", [".py"]],
|
|
41
|
+
["go", [".go"]],
|
|
42
|
+
["rust", [".rs"]],
|
|
43
|
+
["java", [".java"]],
|
|
44
|
+
["kotlin", [".kt", ".kts"]],
|
|
45
|
+
["csharp", [".cs"]],
|
|
46
|
+
["cpp", [".cpp", ".cc", ".cxx", ".hpp", ".hh"]],
|
|
47
|
+
["c", [".c", ".h"]],
|
|
48
|
+
["ruby", [".rb"]],
|
|
49
|
+
["php", [".php"]],
|
|
50
|
+
["swift", [".swift"]],
|
|
51
|
+
["scala", [".scala", ".sc"]],
|
|
52
|
+
["elixir", [".ex", ".exs"]],
|
|
53
|
+
["haskell", [".hs"]],
|
|
54
|
+
["ocaml", [".ml", ".mli"]],
|
|
55
|
+
["fsharp", [".fs", ".fsx"]],
|
|
56
|
+
["clojure", [".clj", ".cljs", ".cljc"]],
|
|
57
|
+
["dart", [".dart"]],
|
|
58
|
+
["lua", [".lua"]],
|
|
59
|
+
["zig", [".zig"]],
|
|
60
|
+
["sql", [".sql"]],
|
|
61
|
+
["bash", [".sh", ".bash"]],
|
|
62
|
+
["terraform", [".tf", ".tfvars"]],
|
|
63
|
+
].flatMap(([lang, exts]) => exts.map((e) => [e, lang])));
|
|
64
|
+
/** TypeScript checks cover the JavaScript beside it, and the other way round. */
|
|
65
|
+
const family = (l) => (l === "javascript" ? "typescript" : l);
|
|
66
|
+
const languageOf = (file) => EXT_LANGUAGE.get(path.extname(file).toLowerCase()) ?? null;
|
|
67
|
+
const within = (file, dir) => !dir || file === dir || file.startsWith(`${dir}/`);
|
|
68
|
+
async function trackedFiles(root) {
|
|
69
|
+
try {
|
|
70
|
+
const { stdout } = await promisify(execFile)("git", ["ls-files", "-z"], {
|
|
71
|
+
cwd: root,
|
|
72
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
73
|
+
windowsHide: true,
|
|
74
|
+
});
|
|
75
|
+
return stdout.split("\0").filter(Boolean);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The project's checks: the root's, then each subproject's (a tracked manifest in a subfolder) for
|
|
83
|
+
* the languages nothing above it checks yet. Throws a FixAllGuardError when there are none at all.
|
|
84
|
+
*/
|
|
85
|
+
export async function resolveFixChecks(cwd) {
|
|
86
|
+
const commands = detectVerifyCommands(cwd, detectLanguages(cwd));
|
|
87
|
+
const dirs = [
|
|
88
|
+
...new Set((await trackedFiles(cwd))
|
|
89
|
+
.filter((f) => f.includes("/") && SUBPROJECT_MANIFESTS.has(path.posix.basename(f)))
|
|
90
|
+
.map((f) => path.posix.dirname(f))
|
|
91
|
+
.filter((d) => !NOT_SUBPROJECTS.test(d))),
|
|
92
|
+
].sort((a, b) => a.split("/").length - b.split("/").length || a.localeCompare(b));
|
|
93
|
+
let subprojects = 0;
|
|
94
|
+
for (const dir of dirs) {
|
|
95
|
+
if (subprojects >= MAX_SUBPROJECTS)
|
|
96
|
+
break;
|
|
97
|
+
const above = commands.filter((c) => within(dir, c.dir)).map((c) => family(c.language));
|
|
98
|
+
const own = detectVerifyCommands(path.join(cwd, dir), detectLanguages(path.join(cwd, dir)))
|
|
99
|
+
.filter((c) => !above.includes(family(c.language)))
|
|
100
|
+
.map((c) => ({ ...c, dir }));
|
|
101
|
+
if (own.length === 0)
|
|
102
|
+
continue;
|
|
103
|
+
commands.push(...own);
|
|
104
|
+
subprojects++;
|
|
105
|
+
}
|
|
106
|
+
if (commands.length === 0) {
|
|
107
|
+
throw new FixAllGuardError("No checks found for this project (no lint, typecheck or test command), so a fix couldn't be checked before it's committed.");
|
|
108
|
+
}
|
|
109
|
+
return commands;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* What a fresh worktree runs before its first checks: the root's setup (`.gg/worktree.json`, else
|
|
113
|
+
* its lockfile's install), then the install of each subproject with checks and a lockfile of its
|
|
114
|
+
* own. Each runs like a check (label `setup`), in its folder.
|
|
115
|
+
*/
|
|
116
|
+
export async function resolveSetupSteps(root, checks) {
|
|
117
|
+
const language = checks[0]?.language ?? "bash";
|
|
118
|
+
const steps = [];
|
|
119
|
+
const top = await resolveSetupCommand(root);
|
|
120
|
+
if (top)
|
|
121
|
+
steps.push({ label: "setup", command: top.command, language });
|
|
122
|
+
const dirs = [...new Set(checks.flatMap((c) => (c.dir ? [c.dir] : [])))];
|
|
123
|
+
for (const dir of dirs) {
|
|
124
|
+
const own = lockfileSetup(path.join(root, dir));
|
|
125
|
+
if (!own)
|
|
126
|
+
continue;
|
|
127
|
+
const of = checks.find((c) => c.dir === dir);
|
|
128
|
+
steps.push({ label: "setup", command: own.command, language: of?.language ?? language, dir });
|
|
129
|
+
}
|
|
130
|
+
return steps;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Whether the checks run on every one of these files: a source file needs a check for its language
|
|
134
|
+
* in its folder or above; any other file, any check there.
|
|
135
|
+
*/
|
|
136
|
+
export function fixChecksCover(checks, files) {
|
|
137
|
+
return files.every((raw) => {
|
|
138
|
+
const file = raw.replace(/\\/g, "/");
|
|
139
|
+
const lang = languageOf(file);
|
|
140
|
+
return checks.some((c) => within(file, c.dir) && (lang === null || family(c.language) === family(lang)));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** What the uncovered files are, for the user: "Swift", "Swift and Kotlin". */
|
|
144
|
+
export function uncheckedKinds(checks, files) {
|
|
145
|
+
const names = new Set();
|
|
146
|
+
for (const f of files) {
|
|
147
|
+
if (fixChecksCover(checks, [f]))
|
|
148
|
+
continue;
|
|
149
|
+
const lang = languageOf(f);
|
|
150
|
+
names.add(lang ? LANGUAGE_DISPLAY_NAMES[lang] : "other");
|
|
151
|
+
}
|
|
152
|
+
const list = [...names].sort();
|
|
153
|
+
return list.length <= 1 ? (list[0] ?? "") : `${list.slice(0, -1).join(", ")} and ${list.at(-1)}`;
|
|
154
|
+
}
|
|
155
|
+
const readJson = (file) => {
|
|
156
|
+
try {
|
|
157
|
+
const v = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
158
|
+
return typeof v === "object" && v !== null && !Array.isArray(v)
|
|
159
|
+
? v
|
|
160
|
+
: null;
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
/** `packages:` from pnpm-workspace.yaml, or `workspaces` from package.json. */
|
|
167
|
+
function workspacePatterns(root) {
|
|
168
|
+
try {
|
|
169
|
+
const yaml = fs.readFileSync(path.join(root, "pnpm-workspace.yaml"), "utf8");
|
|
170
|
+
const out = [];
|
|
171
|
+
let inList = false;
|
|
172
|
+
for (const line of yaml.split(/\r?\n/)) {
|
|
173
|
+
if (/^packages\s*:/.test(line)) {
|
|
174
|
+
inList = true;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (inList) {
|
|
178
|
+
const m = /^\s+-\s*["']?([^"'#]+?)["']?\s*(#.*)?$/.exec(line);
|
|
179
|
+
if (m?.[1])
|
|
180
|
+
out.push(m[1].trim());
|
|
181
|
+
else if (/^\S/.test(line))
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (out.length)
|
|
186
|
+
return out;
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
/* not pnpm */
|
|
190
|
+
}
|
|
191
|
+
const ws = readJson(path.join(root, "package.json"))?.workspaces;
|
|
192
|
+
const list = Array.isArray(ws) ? ws : ws?.packages;
|
|
193
|
+
return Array.isArray(list) ? list.filter((p) => typeof p === "string") : [];
|
|
194
|
+
}
|
|
195
|
+
/** Workspace folders matching `dir`, `dir/*` or `dir/**` (three levels), minus `!` patterns. */
|
|
196
|
+
function workspaceDirs(root, patterns) {
|
|
197
|
+
const found = new Set();
|
|
198
|
+
const hasManifest = (rel) => fs.existsSync(path.join(root, rel, "package.json"));
|
|
199
|
+
const children = (rel) => {
|
|
200
|
+
try {
|
|
201
|
+
return fs
|
|
202
|
+
.readdirSync(path.join(root, rel), { withFileTypes: true })
|
|
203
|
+
.filter((d) => d.isDirectory() && d.name !== "node_modules" && !d.name.startsWith("."))
|
|
204
|
+
.map((d) => (rel ? `${rel}/${d.name}` : d.name));
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const walk = (rel, depth, into) => {
|
|
211
|
+
for (const c of children(rel)) {
|
|
212
|
+
into.push(c);
|
|
213
|
+
if (depth > 1)
|
|
214
|
+
walk(c, depth - 1, into);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const match = (pattern) => {
|
|
218
|
+
const p = pattern.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
219
|
+
if (p.endsWith("/**")) {
|
|
220
|
+
const out = [];
|
|
221
|
+
walk(p.slice(0, -3), 3, out);
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
if (p.endsWith("/*"))
|
|
225
|
+
return children(p.slice(0, -2));
|
|
226
|
+
return p.includes("*") ? [] : [p];
|
|
227
|
+
};
|
|
228
|
+
for (const p of patterns.filter((x) => !x.startsWith("!"))) {
|
|
229
|
+
for (const d of match(p))
|
|
230
|
+
if (hasManifest(d))
|
|
231
|
+
found.add(d);
|
|
232
|
+
}
|
|
233
|
+
for (const p of patterns.filter((x) => x.startsWith("!"))) {
|
|
234
|
+
for (const d of match(p.slice(1)))
|
|
235
|
+
found.delete(d);
|
|
236
|
+
}
|
|
237
|
+
return [...found];
|
|
238
|
+
}
|
|
239
|
+
function readWorkspace(root) {
|
|
240
|
+
return workspaceDirs(root, workspacePatterns(root)).map((dir) => {
|
|
241
|
+
const pkg = readJson(path.join(root, dir, "package.json")) ?? {};
|
|
242
|
+
const deps = new Set();
|
|
243
|
+
for (const field of [
|
|
244
|
+
"dependencies",
|
|
245
|
+
"devDependencies",
|
|
246
|
+
"peerDependencies",
|
|
247
|
+
"optionalDependencies",
|
|
248
|
+
]) {
|
|
249
|
+
const v = pkg[field];
|
|
250
|
+
if (v && typeof v === "object")
|
|
251
|
+
for (const k of Object.keys(v))
|
|
252
|
+
deps.add(k);
|
|
253
|
+
}
|
|
254
|
+
const scripts = (pkg.scripts && typeof pkg.scripts === "object" ? pkg.scripts : {});
|
|
255
|
+
return { dir, name: typeof pkg.name === "string" ? pkg.name : null, deps, scripts };
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/** The root script only fans the same script out to every package (`pnpm -r test`, `npm test -ws`). */
|
|
259
|
+
function fansOut(runner, script, body) {
|
|
260
|
+
if (!body)
|
|
261
|
+
return false;
|
|
262
|
+
const s = script.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
263
|
+
const b = body.trim();
|
|
264
|
+
if (runner === "pnpm")
|
|
265
|
+
return new RegExp(`^pnpm (-r|--recursive)( run)? ${s}$`).test(b);
|
|
266
|
+
if (runner === "npm") {
|
|
267
|
+
return new RegExp(`^npm (run )?${s} (--workspaces|-ws)( --if-present)?$`).test(b);
|
|
268
|
+
}
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
const SCOPED_LABELS = new Set(["typecheck", "test"]);
|
|
272
|
+
const quote = (s) => `'${s.replace(/'/g, "'\\''")}'`;
|
|
273
|
+
/**
|
|
274
|
+
* The checks for one fix: in a pnpm or npm workspace whose root typecheck and test scripts just run
|
|
275
|
+
* every package's own, those two run only in the packages the fix changed plus every package that
|
|
276
|
+
* depends on them (directly or not). Lint and format run as they are. Anything else (a change
|
|
277
|
+
* outside every package, a root script doing more, other tools) keeps the full checks.
|
|
278
|
+
*/
|
|
279
|
+
export function scopeFixChecks(root, commands, changed) {
|
|
280
|
+
if (changed.length === 0)
|
|
281
|
+
return [...commands];
|
|
282
|
+
const rootScripts = (readJson(path.join(root, "package.json"))?.scripts ?? {});
|
|
283
|
+
let pkgs = null;
|
|
284
|
+
const affected = () => {
|
|
285
|
+
pkgs ??= readWorkspace(root);
|
|
286
|
+
if (pkgs.length === 0)
|
|
287
|
+
return null;
|
|
288
|
+
const hit = new Set();
|
|
289
|
+
for (const file of changed) {
|
|
290
|
+
const f = file.replace(/\\/g, "/");
|
|
291
|
+
const owner = pkgs
|
|
292
|
+
.filter((p) => f === p.dir || f.startsWith(`${p.dir}/`))
|
|
293
|
+
.sort((a, b) => b.dir.length - a.dir.length)[0];
|
|
294
|
+
if (!owner)
|
|
295
|
+
return null;
|
|
296
|
+
hit.add(owner);
|
|
297
|
+
}
|
|
298
|
+
// Every package that uses an affected one is affected too.
|
|
299
|
+
for (let grew = true; grew;) {
|
|
300
|
+
grew = false;
|
|
301
|
+
for (const p of pkgs) {
|
|
302
|
+
if (hit.has(p))
|
|
303
|
+
continue;
|
|
304
|
+
if ([...hit].some((h) => h.name !== null && p.deps.has(h.name))) {
|
|
305
|
+
hit.add(p);
|
|
306
|
+
grew = true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return [...hit];
|
|
311
|
+
};
|
|
312
|
+
return commands.flatMap((cmd) => {
|
|
313
|
+
// A subproject's checks run when the fix changed something in it.
|
|
314
|
+
if (cmd.dir) {
|
|
315
|
+
const dir = cmd.dir;
|
|
316
|
+
return changed.some((f) => within(f.replace(/\\/g, "/"), dir)) ? [cmd] : [];
|
|
317
|
+
}
|
|
318
|
+
if (!SCOPED_LABELS.has(cmd.label))
|
|
319
|
+
return [cmd];
|
|
320
|
+
const m = /^(pnpm|npm) (?:run )?([\w:.-]+)$/.exec(cmd.command.trim());
|
|
321
|
+
if (!m?.[1] || !m[2])
|
|
322
|
+
return [cmd];
|
|
323
|
+
const [, runner, script] = m;
|
|
324
|
+
if (!fansOut(runner, script, rootScripts[script]))
|
|
325
|
+
return [cmd];
|
|
326
|
+
const hit = affected();
|
|
327
|
+
if (!hit)
|
|
328
|
+
return [cmd];
|
|
329
|
+
const targets = hit.filter((p) => typeof p.scripts[script] === "string");
|
|
330
|
+
// None of the touched packages has this check: there's nothing of it to run.
|
|
331
|
+
if (targets.length === 0)
|
|
332
|
+
return [];
|
|
333
|
+
const command = runner === "pnpm"
|
|
334
|
+
? `pnpm ${targets.map((p) => `--filter ${quote(p.name ?? `./${p.dir}`)}`).join(" ")} run ${script}`
|
|
335
|
+
: `npm run ${script} ${targets.map((p) => `--workspace=${quote(p.dir)}`).join(" ")}`;
|
|
336
|
+
return [{ ...cmd, command }];
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
/** The executable and args one check runs as (Git Bash, bash, or the `cmd` fallback on Windows). */
|
|
340
|
+
export function checkSpawn(command, opts) {
|
|
341
|
+
return resolveShell(command, opts);
|
|
342
|
+
}
|
|
343
|
+
/** The last `max` bytes of `text`, starting on a whole line where it can. */
|
|
344
|
+
export function outputTail(text, max = CHECK_TAIL_BYTES) {
|
|
345
|
+
const clean = stripAnsi(text).replace(/\r\n?/g, "\n").trimEnd();
|
|
346
|
+
if (Buffer.byteLength(clean) <= max)
|
|
347
|
+
return clean;
|
|
348
|
+
const cut = Buffer.from(clean).subarray(-max).toString("utf8");
|
|
349
|
+
const nl = cut.indexOf("\n");
|
|
350
|
+
return nl >= 0 && nl < cut.length - 1 ? cut.slice(nl + 1) : cut;
|
|
351
|
+
}
|
|
352
|
+
function runOne(cwd, command, opts) {
|
|
353
|
+
return new Promise((resolve) => {
|
|
354
|
+
const shell = checkSpawn(command, opts.shell);
|
|
355
|
+
let output = "";
|
|
356
|
+
let timedOut = false;
|
|
357
|
+
let aborted = false;
|
|
358
|
+
const child = spawn(shell.file, shell.args, {
|
|
359
|
+
cwd,
|
|
360
|
+
// Its own process group, so a timeout or Stop takes the whole tree down.
|
|
361
|
+
detached: process.platform !== "win32",
|
|
362
|
+
windowsHide: true,
|
|
363
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
364
|
+
// Watch-mode runners (vitest, jest) exit under CI; colour only adds noise.
|
|
365
|
+
env: { ...process.env, CI: "1", FORCE_COLOR: "0", NO_COLOR: "1" },
|
|
366
|
+
});
|
|
367
|
+
const take = (chunk) => {
|
|
368
|
+
output += chunk.toString("utf8");
|
|
369
|
+
if (output.length > KEEP_BYTES * 2)
|
|
370
|
+
output = output.slice(-KEEP_BYTES);
|
|
371
|
+
};
|
|
372
|
+
child.stdout?.on("data", take);
|
|
373
|
+
child.stderr?.on("data", take);
|
|
374
|
+
const kill = () => {
|
|
375
|
+
if (child.pid !== undefined && child.exitCode === null)
|
|
376
|
+
killProcessTree(child.pid);
|
|
377
|
+
};
|
|
378
|
+
const timer = setTimeout(() => {
|
|
379
|
+
timedOut = true;
|
|
380
|
+
kill();
|
|
381
|
+
}, opts.timeoutMs ?? CHECK_TIMEOUT_MS);
|
|
382
|
+
const onAbort = () => {
|
|
383
|
+
aborted = true;
|
|
384
|
+
kill();
|
|
385
|
+
};
|
|
386
|
+
if (opts.signal?.aborted)
|
|
387
|
+
onAbort();
|
|
388
|
+
else
|
|
389
|
+
opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
390
|
+
const done = (code) => {
|
|
391
|
+
clearTimeout(timer);
|
|
392
|
+
opts.signal?.removeEventListener("abort", onAbort);
|
|
393
|
+
resolve({ code, output, timedOut, aborted });
|
|
394
|
+
};
|
|
395
|
+
child.on("error", (error) => {
|
|
396
|
+
output += `\n${error.message}`;
|
|
397
|
+
done(null);
|
|
398
|
+
});
|
|
399
|
+
child.on("close", (code) => done(code));
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
/** Run each check in order; the first failure ends it. */
|
|
403
|
+
export async function runFixChecks(cwd, commands, opts = {}) {
|
|
404
|
+
for (const [index, check] of commands.entries()) {
|
|
405
|
+
const command = checkLabel(check);
|
|
406
|
+
if (opts.signal?.aborted) {
|
|
407
|
+
return { ok: false, command, tail: "", timedOut: false, aborted: true };
|
|
408
|
+
}
|
|
409
|
+
opts.onCommand?.(index, check);
|
|
410
|
+
const r = await runOne(check.dir ? path.join(cwd, check.dir) : cwd, check.command, opts);
|
|
411
|
+
if (r.code === 0 && !r.timedOut && !r.aborted)
|
|
412
|
+
continue;
|
|
413
|
+
const note = r.timedOut
|
|
414
|
+
? `\n(stopped after ${Math.round((opts.timeoutMs ?? CHECK_TIMEOUT_MS) / 1000)}s)`
|
|
415
|
+
: "";
|
|
416
|
+
return {
|
|
417
|
+
ok: false,
|
|
418
|
+
command,
|
|
419
|
+
tail: outputTail(r.output + note),
|
|
420
|
+
timedOut: r.timedOut,
|
|
421
|
+
aborted: r.aborted,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
return { ok: true };
|
|
425
|
+
}
|
|
426
|
+
//# sourceMappingURL=fix-all-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-all-checks.js","sourceRoot":"","sources":["../../src/app-sidecar/fix-all-checks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,eAAe,EACf,sBAAsB,GAEvB,MAAM,yDAAyD,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,uDAAuD,CAAC;AAClF,OAAO,EACL,YAAY,GAGb,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,oBAAoB,GAErB,MAAM,uDAAuD,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,gGAAgG;AAChG,6EAA6E;AAE7E,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,MAAM,CAAC;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,CAAC;AACzC,uEAAuE;AACvE,MAAM,UAAU,GAAG,EAAE,GAAG,IAAI,CAAC;AAO7B,kFAAkF;AAClF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAW,EAAU,EAAE,CAChD,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,QAAQ,CAAC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,SAAS,IAAI,gBAAgB,CAAC,GAAG,IAAI,CAAC,IAAI;YACjF,CAAC,CAAC,EAAE,CAAC;QACP,OAAO;YACL,EAAE,EAAE,KAAK;YACT,OAAO;YACP,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;YACjC,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** Never `--no-verify`: the repo's hooks are part of the checks. */
|
|
2
|
+
export declare const COMMIT_ARGS: readonly string[];
|
|
3
|
+
/** A guard refused: nothing was changed. `message` is safe to show the user. */
|
|
4
|
+
export declare class FixAllGuardError extends Error {
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function currentBranch(dir: string): Promise<string | null>;
|
|
8
|
+
export declare function headCommit(dir: string): Promise<string | null>;
|
|
9
|
+
/** Whether `commit` is behind (or at) HEAD. */
|
|
10
|
+
export declare function isAncestorOfHead(dir: string, commit: string): Promise<boolean>;
|
|
11
|
+
/** Repo-relative paths `git status` lists (tracked changes and untracked files; not ignored ones). */
|
|
12
|
+
export declare function changedPaths(dir: string): Promise<string[]>;
|
|
13
|
+
export interface Preflight {
|
|
14
|
+
readonly root: string;
|
|
15
|
+
readonly branch: string;
|
|
16
|
+
readonly head: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The checkout is safe to run in (clean, on a branch, no merge or rebase under way, and on
|
|
20
|
+
* `opts.branch` when given), or a FixAllGuardError saying why not.
|
|
21
|
+
*/
|
|
22
|
+
export declare function preflightTree(dir: string, opts?: {
|
|
23
|
+
branch?: string;
|
|
24
|
+
}): Promise<Preflight>;
|
|
25
|
+
/** What a run is keyed by: the repository's main folder, the same from any worktree of it. */
|
|
26
|
+
export declare function repoKey(dir: string): Promise<string | null>;
|
|
27
|
+
/** `gg/fix-all-20261202-1615`, with `-2`, `-3`… when taken. */
|
|
28
|
+
export declare function fixAllBranchName(now: Date, taken: ReadonlySet<string>): string;
|
|
29
|
+
/** A free branch name for a run started now. */
|
|
30
|
+
export declare function proposeRunBranch(dir: string, now: Date): Promise<string>;
|
|
31
|
+
export interface RunWorktree {
|
|
32
|
+
readonly branch: string;
|
|
33
|
+
/** The commit the branch starts from (the folder's HEAD), before the map commit if any. */
|
|
34
|
+
readonly base: string;
|
|
35
|
+
/** The worktree's folder, symlinks resolved. */
|
|
36
|
+
readonly path: string;
|
|
37
|
+
/** Ignored local files copied in (`.env`, `.worktreeinclude`). */
|
|
38
|
+
readonly copied: readonly string[];
|
|
39
|
+
/** The folder's uncommitted feature map was committed on the run's branch. */
|
|
40
|
+
readonly mapCommitted: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The run's branch, at the folder's HEAD, checked out in a new worktree under `worktreesRoot`
|
|
44
|
+
* with the user's git (hooks run). The folder itself is only read. A map file that's new or
|
|
45
|
+
* changed there is carried over as a commit on the run's branch. Any failure removes what it made.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createRunWorktree(from: string, worktreesRoot: string, now: Date): Promise<RunWorktree>;
|
|
48
|
+
/**
|
|
49
|
+
* Remove an ended run's worktree and branch when they hold nothing to review: a GG worktree (under
|
|
50
|
+
* `worktreesRoot`, never the main folder), still on the run's branch at the commit it started from,
|
|
51
|
+
* with no uncommitted changes (ignored files such as `node_modules` and `.env` don't count). False,
|
|
52
|
+
* changing nothing, when any of that doesn't hold.
|
|
53
|
+
*/
|
|
54
|
+
export declare function removeEmptyRunWorktree(run: {
|
|
55
|
+
readonly root: string;
|
|
56
|
+
readonly branch: string;
|
|
57
|
+
readonly head: string;
|
|
58
|
+
}, worktreesRoot: string): Promise<boolean>;
|
|
59
|
+
/** Remove a run's worktree and its branch (best effort): a launch that failed after making them. */
|
|
60
|
+
export declare function discardRunWorktree(root: string, target: string, branch: string): Promise<void>;
|
|
61
|
+
/** Commit everything the fix changed on the run's branch; null when it changed nothing. */
|
|
62
|
+
export declare function commitStep(dir: string, branch: string, message: string): Promise<string | null>;
|
|
63
|
+
export interface RollbackRequest {
|
|
64
|
+
readonly dir: string;
|
|
65
|
+
readonly branch: string;
|
|
66
|
+
/** The commit to go back to. */
|
|
67
|
+
readonly checkpoint: string;
|
|
68
|
+
/** Commits a rollback may go back to: the branch base and the run's own commits. */
|
|
69
|
+
readonly allowed: ReadonlySet<string>;
|
|
70
|
+
/** How many other windows have this checkout open. */
|
|
71
|
+
readonly othersOnCheckout: () => Promise<number>;
|
|
72
|
+
/** Called with what will be discarded, before anything is. */
|
|
73
|
+
readonly onDiscard?: (files: readonly string[]) => void | Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
/** What a rollback to `checkpoint` would discard: uncommitted changes plus commits since it. */
|
|
76
|
+
export declare function filesToDiscard(dir: string, checkpoint: string): Promise<string[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Undo an unfinished fix: `reset --hard` to the run's checkpoint, then `clean -fd` (never `-x`,
|
|
79
|
+
* so ignored files such as `.env` and `node_modules` stay). Returns the files it discarded.
|
|
80
|
+
*/
|
|
81
|
+
export declare function rollbackTo(req: RollbackRequest): Promise<string[]>;
|