@clemrig/factory 0.6.0 → 0.7.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/README.md +61 -23
- package/dist/app/define.js +1 -1
- package/dist/app/define.js.map +1 -1
- package/dist/app/init.d.ts +1 -0
- package/dist/app/init.js +1 -0
- package/dist/app/init.js.map +1 -1
- package/dist/app/run.d.ts +2 -1
- package/dist/app/run.js +16 -4
- package/dist/app/run.js.map +1 -1
- package/dist/app/workflows/implement.d.ts +1 -1
- package/dist/app/workflows/implement.js +332 -132
- package/dist/app/workflows/implement.js.map +1 -1
- package/dist/app/workflows/issue-save.js +16 -14
- package/dist/app/workflows/issue-save.js.map +1 -1
- package/dist/cli/help.d.ts +1 -1
- package/dist/cli/help.js +4 -2
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/init.d.ts +3 -2
- package/dist/cli/init.js +10 -3
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/run.js +1 -1
- package/dist/cli/run.js.map +1 -1
- package/dist/domain/definition.d.ts +2 -0
- package/dist/domain/definition.js +1 -0
- package/dist/domain/definition.js.map +1 -1
- package/dist/domain/description.d.ts +51 -0
- package/dist/domain/description.js +78 -0
- package/dist/domain/description.js.map +1 -0
- package/dist/domain/plan.d.ts +2 -0
- package/dist/domain/plan.js +15 -0
- package/dist/domain/plan.js.map +1 -1
- package/dist/domain/pull-request.d.ts +42 -8
- package/dist/domain/pull-request.js +287 -24
- package/dist/domain/pull-request.js.map +1 -1
- package/dist/domain/review.d.ts +19 -11
- package/dist/domain/review.js +42 -21
- package/dist/domain/review.js.map +1 -1
- package/dist/domain/spec.js +12 -4
- package/dist/domain/spec.js.map +1 -1
- package/dist/domain/verification.d.ts +0 -2
- package/dist/domain/verification.js.map +1 -1
- package/dist/system/browser.d.ts +29 -0
- package/dist/system/browser.js +84 -0
- package/dist/system/browser.js.map +1 -0
- package/dist/system/checks.d.ts +5 -6
- package/dist/system/checks.js +3 -3
- package/dist/system/checks.js.map +1 -1
- package/dist/system/git.d.ts +9 -15
- package/dist/system/git.js +92 -100
- package/dist/system/git.js.map +1 -1
- package/dist/system/github.d.ts +15 -0
- package/dist/system/github.js +36 -2
- package/dist/system/github.js.map +1 -1
- package/dist/system/issues.d.ts +5 -2
- package/dist/system/issues.js +5 -3
- package/dist/system/issues.js.map +1 -1
- package/dist/system/run-files.d.ts +22 -2
- package/dist/system/run-files.js +78 -4
- package/dist/system/run-files.js.map +1 -1
- package/dist/system/templates.d.ts +3 -2
- package/dist/system/templates.js +8 -3
- package/dist/system/templates.js.map +1 -1
- package/package.json +3 -3
- package/prompts/implement/describe.md +74 -0
- package/prompts/implement/implement.md +25 -8
- package/prompts/implement/plan.md +35 -7
- package/prompts/implement/review.md +43 -16
- package/templates/init/factory.ts +23 -5
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** The browser command line `factory init` installs in `.factory/`, and its version. */
|
|
2
|
+
export declare const browserPackage: {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
};
|
|
6
|
+
/** Where a `.factory/` installs the browser command line. */
|
|
7
|
+
export declare function installedBrowser(factoryDir: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* The browser of the run's agents, when `.factory/` installs one: a command in
|
|
10
|
+
* the run's directory that runs Playwright CLI from there. Playwright CLI keeps
|
|
11
|
+
* its sessions in the workspace of the folder it runs from, the nearest one
|
|
12
|
+
* holding `.playwright`: the run's folder holds one, so that every session the
|
|
13
|
+
* agents open, whatever its name, stays in the run's own workspace, out of the
|
|
14
|
+
* repository and away from the operator's. Its files go to the run's folder,
|
|
15
|
+
* reported by their absolute path, and it uses the browser `factory init`
|
|
16
|
+
* downloaded. It refuses `kill-all`,
|
|
17
|
+
* which ends the browsers of every workspace.
|
|
18
|
+
*/
|
|
19
|
+
export declare function runBrowser(dir: string, runDir: string): Promise<string | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Closes every session of the run's browser, which outlives the agent that
|
|
22
|
+
* opened it; returns why it could not, if it could not.
|
|
23
|
+
*/
|
|
24
|
+
export declare function closeBrowser(command: string): Promise<string | undefined>;
|
|
25
|
+
/** Downloads the browser of the installed command line; `output` explains a failure. */
|
|
26
|
+
export declare function installBrowser(factoryDir: string): Promise<{
|
|
27
|
+
ok: boolean;
|
|
28
|
+
output: string;
|
|
29
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { access, chmod, mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { runProcess } from "@clemrig/flow";
|
|
4
|
+
/** The browser command line `factory init` installs in `.factory/`, and its version. */
|
|
5
|
+
export const browserPackage = { name: "@playwright/cli", version: "0.1.22" };
|
|
6
|
+
/** The browser it downloads: the agents never use the machine's own. */
|
|
7
|
+
const browser = "chromium";
|
|
8
|
+
/** Where a `.factory/` installs the browser command line. */
|
|
9
|
+
export function installedBrowser(factoryDir) {
|
|
10
|
+
return join(factoryDir, "node_modules", ".bin", "playwright-cli");
|
|
11
|
+
}
|
|
12
|
+
/** A command's failure, `undefined` once it succeeded. */
|
|
13
|
+
async function attempt(command, cwd) {
|
|
14
|
+
const result = await runProcess(command, cwd, 60_000).catch((error) => ({
|
|
15
|
+
exitCode: 1,
|
|
16
|
+
stdout: "",
|
|
17
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
18
|
+
}));
|
|
19
|
+
if (result.exitCode === 0)
|
|
20
|
+
return undefined;
|
|
21
|
+
return ((result.stderr || result.stdout).trim() || `exit code ${result.exitCode}`);
|
|
22
|
+
}
|
|
23
|
+
/** A path as one word of a POSIX shell. */
|
|
24
|
+
function quoted(text) {
|
|
25
|
+
return `'${text.replaceAll("'", "'\\''")}'`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The browser of the run's agents, when `.factory/` installs one: a command in
|
|
29
|
+
* the run's directory that runs Playwright CLI from there. Playwright CLI keeps
|
|
30
|
+
* its sessions in the workspace of the folder it runs from, the nearest one
|
|
31
|
+
* holding `.playwright`: the run's folder holds one, so that every session the
|
|
32
|
+
* agents open, whatever its name, stays in the run's own workspace, out of the
|
|
33
|
+
* repository and away from the operator's. Its files go to the run's folder,
|
|
34
|
+
* reported by their absolute path, and it uses the browser `factory init`
|
|
35
|
+
* downloaded. It refuses `kill-all`,
|
|
36
|
+
* which ends the browsers of every workspace.
|
|
37
|
+
*/
|
|
38
|
+
export async function runBrowser(dir, runDir) {
|
|
39
|
+
const cli = installedBrowser(join(dir, ".factory"));
|
|
40
|
+
if (!(await access(cli).then(() => true, () => false)))
|
|
41
|
+
return undefined;
|
|
42
|
+
const folder = join(runDir, "browser");
|
|
43
|
+
await mkdir(join(folder, ".playwright"), { recursive: true });
|
|
44
|
+
await mkdir(join(folder, "output"), { recursive: true });
|
|
45
|
+
const command = join(folder, "playwright-cli");
|
|
46
|
+
await writeFile(command, [
|
|
47
|
+
"#!/bin/sh",
|
|
48
|
+
'for arg in "$@"; do',
|
|
49
|
+
' if [ "$arg" = kill-all ]; then',
|
|
50
|
+
' echo "playwright-cli: kill-all would end the operator\'s browsers too: use close-all" >&2',
|
|
51
|
+
" exit 2",
|
|
52
|
+
" fi",
|
|
53
|
+
"done",
|
|
54
|
+
`cd ${quoted(folder)} || exit 1`,
|
|
55
|
+
`export PLAYWRIGHT_MCP_OUTPUT_DIR=${quoted(join(folder, "output"))}`,
|
|
56
|
+
// The files it reports, the agent opens from wherever it is.
|
|
57
|
+
"export PLAYWRIGHT_MCP_FILE_PATHS=absolute",
|
|
58
|
+
`export PLAYWRIGHT_MCP_BROWSER=${browser}`,
|
|
59
|
+
`exec ${quoted(cli)} "$@"`,
|
|
60
|
+
"",
|
|
61
|
+
].join("\n"));
|
|
62
|
+
await chmod(command, 0o755);
|
|
63
|
+
return command;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Closes every session of the run's browser, which outlives the agent that
|
|
67
|
+
* opened it; returns why it could not, if it could not.
|
|
68
|
+
*/
|
|
69
|
+
export function closeBrowser(command) {
|
|
70
|
+
return attempt([command, "close-all"], dirname(command));
|
|
71
|
+
}
|
|
72
|
+
/** Downloads the browser of the installed command line; `output` explains a failure. */
|
|
73
|
+
export async function installBrowser(factoryDir) {
|
|
74
|
+
const install = await runProcess([installedBrowser(factoryDir), "install-browser", browser], factoryDir, 600_000).catch((error) => ({
|
|
75
|
+
exitCode: 1,
|
|
76
|
+
stdout: "",
|
|
77
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
78
|
+
}));
|
|
79
|
+
return {
|
|
80
|
+
ok: install.exitCode === 0,
|
|
81
|
+
output: install.stderr || install.stdout,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/system/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,wFAAwF;AACxF,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAE7E,wEAAwE;AACxE,MAAM,OAAO,GAAG,UAAU,CAAC;AAE3B,6DAA6D;AAC7D,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,OAAO,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;AACpE,CAAC;AAED,0DAA0D;AAC1D,KAAK,UAAU,OAAO,CACpB,OAAiB,EACjB,GAAW;IAEX,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,KAAK,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O,CAAC,MAAM;KACzC,CAAC;AACJ,CAAC"}
|
package/dist/system/checks.d.ts
CHANGED
|
@@ -15,17 +15,16 @@ export type PassedCheck = CheckResult & {
|
|
|
15
15
|
output: string;
|
|
16
16
|
};
|
|
17
17
|
export type ChecksOutcome = {
|
|
18
|
-
ok: true;
|
|
19
18
|
passed: PassedCheck[];
|
|
20
19
|
skipped: VerifyCommand[];
|
|
20
|
+
} & ({
|
|
21
|
+
ok: true;
|
|
21
22
|
} | {
|
|
22
23
|
ok: false;
|
|
23
|
-
passed: PassedCheck[];
|
|
24
|
-
skipped: VerifyCommand[];
|
|
25
24
|
check: VerifyCommand;
|
|
26
25
|
cause: string;
|
|
27
26
|
output: string;
|
|
28
|
-
};
|
|
27
|
+
});
|
|
29
28
|
/** A check that starts, passes with its duration, or is skipped: no changed file matches its `when`. */
|
|
30
29
|
export type CheckProgress = {
|
|
31
30
|
check: VerifyCommand;
|
|
@@ -42,6 +41,6 @@ export type CheckProgress = {
|
|
|
42
41
|
export declare function matchesAny(files: string[], globs: string[]): boolean;
|
|
43
42
|
/**
|
|
44
43
|
* Runs the checks in order, stopping at the first failure. A check with `when`
|
|
45
|
-
* runs only if one of the `changed` files matches it
|
|
44
|
+
* runs only if one of the `changed` files matches it: never when none changed.
|
|
46
45
|
*/
|
|
47
|
-
export declare function runChecks(dir: string, checks: VerifyCommand[], progress?: (event: CheckProgress) => void
|
|
46
|
+
export declare function runChecks(dir: string, checks: VerifyCommand[], changed: string[], progress?: (event: CheckProgress) => void): Promise<ChecksOutcome>;
|
package/dist/system/checks.js
CHANGED
|
@@ -35,13 +35,13 @@ export function matchesAny(files, globs) {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Runs the checks in order, stopping at the first failure. A check with `when`
|
|
38
|
-
* runs only if one of the `changed` files matches it
|
|
38
|
+
* runs only if one of the `changed` files matches it: never when none changed.
|
|
39
39
|
*/
|
|
40
|
-
export async function runChecks(dir, checks,
|
|
40
|
+
export async function runChecks(dir, checks, changed, progress) {
|
|
41
41
|
const passed = [];
|
|
42
42
|
const skipped = [];
|
|
43
43
|
for (const check of checks) {
|
|
44
|
-
if (check.when && !
|
|
44
|
+
if (check.when && !matchesAny(changed, check.when)) {
|
|
45
45
|
progress?.({ check, status: "skipped" });
|
|
46
46
|
skipped.push(check);
|
|
47
47
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src/system/checks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,GACX,MAAM,eAAe,CAAC;AAOvB,oHAAoH;AACpH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,GAAW,EACX,KAAoB;IAEpB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;QACrE,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC;YACvB,OAAO;gBACL,EAAE,EAAE,IAAI;gBACR,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO;gBAChC,wEAAwE;gBACxE,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;aACtC,CAAC;QACJ,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,aAAa,MAAM,CAAC,QAAQ,EAAE;YACrC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;SACtC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,uBAAuB;YAAE,MAAM,KAAK,CAAC;QAC1D,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,KAA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,EAAE,KAAK;gBACT,MAAM;gBACN,OAAO;gBACP,KAAK;gBACL,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC;QACJ,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;QACxE,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC"}
|
package/dist/system/git.d.ts
CHANGED
|
@@ -20,19 +20,16 @@ export declare function commitOf(dir: string, ref: string): Promise<string>;
|
|
|
20
20
|
export declare function switchTo(dir: string, branch: string, from?: string): Promise<void>;
|
|
21
21
|
/** Commits the given paths, or every change; returns the new commit. */
|
|
22
22
|
export declare function commit(dir: string, message: string, paths?: string[]): Promise<string>;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
export declare function forcePush(dir: string, branch: string): Promise<void>;
|
|
24
|
+
/** The diff from one commit or tree to another. */
|
|
25
|
+
export declare function diff(dir: string, before: string, after: string): Promise<{
|
|
25
26
|
text: string;
|
|
26
27
|
truncated: boolean;
|
|
27
28
|
}>;
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
* removed lines, renames seen as the diff sees them; call it after `stagedDiff`.
|
|
31
|
-
*/
|
|
32
|
-
export declare function stagedStat(dir: string, since: string): Promise<ChangedFile[]>;
|
|
29
|
+
/** Each file that differs from one commit or tree to another, with its added and removed lines, renames seen as `diff` sees them. */
|
|
30
|
+
export declare function diffStat(dir: string, before: string, after: string): Promise<ChangedFile[]>;
|
|
33
31
|
/** The files changed since a commit, untracked ones included, without staging anything. */
|
|
34
32
|
export declare function changedFiles(dir: string, since: string): Promise<string[]>;
|
|
35
|
-
export declare function forcePush(dir: string, branch: string): Promise<void>;
|
|
36
33
|
/**
|
|
37
34
|
* The working tree as a tree object: tracked and untracked files, ignored ones
|
|
38
35
|
* aside. It stages every change, as a delivery does.
|
|
@@ -55,12 +52,9 @@ export declare function changesBetween(dir: string, before: string, after: strin
|
|
|
55
52
|
export declare function restore(dir: string, before: string, changes: TreeChange[]): Promise<void>;
|
|
56
53
|
/**
|
|
57
54
|
* Puts back everything that changed in the working tree since the snapshot
|
|
58
|
-
* `before
|
|
59
|
-
*
|
|
60
|
-
* followed by a new snapshot: the
|
|
61
|
-
*
|
|
62
|
-
* a deeper `.gitignore` that seems new may be an ignored file it exposed: it
|
|
63
|
-
* waits for the next snapshot. The other changes are then what they really
|
|
64
|
-
* are, and an ignored file is never taken for one.
|
|
55
|
+
* `before`; returns the paths it put back, none when nothing changed. A
|
|
56
|
+
* snapshot depends on the ignore rules, so they come back first, each time
|
|
57
|
+
* followed by a new snapshot (`nextToPutBack`): the other changes are then
|
|
58
|
+
* what they really are, and an ignored file is never taken for one.
|
|
65
59
|
*/
|
|
66
60
|
export declare function putBack(dir: string, before: string): Promise<string[]>;
|
package/dist/system/git.js
CHANGED
|
@@ -11,6 +11,20 @@ async function git(dir, args, timeoutMs = 60_000) {
|
|
|
11
11
|
async function output(dir, args) {
|
|
12
12
|
return (await git(dir, args)).stdout.trim();
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Git's output when the run read all of it: a list cut by the capture limit
|
|
16
|
+
* would name wrong paths, so the run stops instead.
|
|
17
|
+
*/
|
|
18
|
+
async function whole(dir, args) {
|
|
19
|
+
const result = await git(dir, args);
|
|
20
|
+
if (result.stdoutTruncated)
|
|
21
|
+
throw new Error(`git ${args[0]} wrote more than the run reads (2 MiB): the run stops`);
|
|
22
|
+
return result.stdout;
|
|
23
|
+
}
|
|
24
|
+
/** NUL-separated fields of Git's `-z` output. */
|
|
25
|
+
async function fields(dir, args) {
|
|
26
|
+
return (await whole(dir, args)).split("\0").filter(Boolean);
|
|
27
|
+
}
|
|
14
28
|
/** A branch's full reference: a tag of the same name never answers for it. */
|
|
15
29
|
export function branchRef(branch) {
|
|
16
30
|
return `refs/heads/${branch}`;
|
|
@@ -67,52 +81,31 @@ export async function commit(dir, message, paths) {
|
|
|
67
81
|
await git(dir, ["commit", "-m", message, ...(paths ? ["--", ...paths] : [])]);
|
|
68
82
|
return commitOf(dir, "HEAD");
|
|
69
83
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
await git(dir, ["
|
|
73
|
-
const result = await git(dir, ["diff", "--cached", since]);
|
|
74
|
-
return { text: result.stdout, truncated: result.stdoutTruncated };
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Git's output when the run read all of it: a list cut by the capture limit
|
|
78
|
-
* would name wrong paths, so the run stops instead.
|
|
79
|
-
*/
|
|
80
|
-
async function whole(dir, args) {
|
|
81
|
-
const result = await git(dir, args);
|
|
82
|
-
if (result.stdoutTruncated)
|
|
83
|
-
throw new Error(`git ${args[0]} wrote more than the run reads (2 MiB): the run stops`);
|
|
84
|
-
return result.stdout;
|
|
84
|
+
export async function forcePush(dir, branch) {
|
|
85
|
+
const ref = branchRef(branch);
|
|
86
|
+
await git(dir, ["push", "--force", "-u", "origin", `${ref}:${ref}`], 120_000);
|
|
85
87
|
}
|
|
86
|
-
/**
|
|
87
|
-
async function
|
|
88
|
-
|
|
88
|
+
/** The diff from one commit or tree to another. */
|
|
89
|
+
export async function diff(dir, before, after) {
|
|
90
|
+
const result = await git(dir, ["diff", before, after]);
|
|
91
|
+
return { text: result.stdout, truncated: result.stdoutTruncated };
|
|
89
92
|
}
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*/
|
|
94
|
-
export async function stagedStat(dir, since) {
|
|
95
|
-
const records = await fields(dir, [
|
|
96
|
-
"diff",
|
|
97
|
-
"--cached",
|
|
98
|
-
"--numstat",
|
|
99
|
-
"-z",
|
|
100
|
-
since,
|
|
101
|
-
]);
|
|
93
|
+
/** Each file that differs from one commit or tree to another, with its added and removed lines, renames seen as `diff` sees them. */
|
|
94
|
+
export async function diffStat(dir, before, after) {
|
|
95
|
+
const records = (await fields(dir, ["diff", "--numstat", "-z", before, after])).values();
|
|
102
96
|
const files = [];
|
|
103
|
-
for (
|
|
104
|
-
const [added = "-", removed = "-", ...rest] =
|
|
97
|
+
for (const record of records) {
|
|
98
|
+
const [added = "-", removed = "-", ...rest] = record.split("\t");
|
|
105
99
|
let path = rest.join("\t");
|
|
106
|
-
let
|
|
100
|
+
let from;
|
|
107
101
|
// A rename leaves the path empty, then gives its source and destination.
|
|
108
102
|
if (path === "") {
|
|
109
|
-
|
|
110
|
-
path = records
|
|
111
|
-
index += 2;
|
|
103
|
+
from = records.next().value ?? "";
|
|
104
|
+
path = records.next().value ?? "";
|
|
112
105
|
}
|
|
113
106
|
files.push({
|
|
114
107
|
path,
|
|
115
|
-
...(
|
|
108
|
+
...(from === undefined ? {} : { from }),
|
|
116
109
|
...(added === "-" ? {} : { added: Number(added) }),
|
|
117
110
|
...(removed === "-" ? {} : { removed: Number(removed) }),
|
|
118
111
|
});
|
|
@@ -121,27 +114,20 @@ export async function stagedStat(dir, since) {
|
|
|
121
114
|
}
|
|
122
115
|
/** The files changed since a commit, untracked ones included, without staging anything. */
|
|
123
116
|
export async function changedFiles(dir, since) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
])),
|
|
139
|
-
]),
|
|
140
|
-
];
|
|
141
|
-
}
|
|
142
|
-
export async function forcePush(dir, branch) {
|
|
143
|
-
const ref = branchRef(branch);
|
|
144
|
-
await git(dir, ["push", "--force", "-u", "origin", `${ref}:${ref}`], 120_000);
|
|
117
|
+
const tracked = await fields(dir, [
|
|
118
|
+
"diff",
|
|
119
|
+
"--name-only",
|
|
120
|
+
"-z",
|
|
121
|
+
"--no-renames",
|
|
122
|
+
since,
|
|
123
|
+
]);
|
|
124
|
+
const untracked = await fields(dir, [
|
|
125
|
+
"ls-files",
|
|
126
|
+
"--others",
|
|
127
|
+
"--exclude-standard",
|
|
128
|
+
"-z",
|
|
129
|
+
]);
|
|
130
|
+
return [...new Set([...tracked, ...untracked])];
|
|
145
131
|
}
|
|
146
132
|
/**
|
|
147
133
|
* The working tree as a tree object: tracked and untracked files, ignored ones
|
|
@@ -153,7 +139,7 @@ export async function snapshot(dir) {
|
|
|
153
139
|
}
|
|
154
140
|
/** The files that differ from `before` to `after`, renames seen as a deletion and an addition. */
|
|
155
141
|
export async function changesBetween(dir, before, after) {
|
|
156
|
-
const records = await fields(dir, [
|
|
142
|
+
const records = (await fields(dir, [
|
|
157
143
|
"diff-tree",
|
|
158
144
|
"-r",
|
|
159
145
|
"-z",
|
|
@@ -161,16 +147,14 @@ export async function changesBetween(dir, before, after) {
|
|
|
161
147
|
"--name-status",
|
|
162
148
|
before,
|
|
163
149
|
after,
|
|
164
|
-
]);
|
|
150
|
+
])).values();
|
|
165
151
|
const changes = [];
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const path = records[index + 1] ?? "";
|
|
152
|
+
// Each status is followed by its path.
|
|
153
|
+
for (const code of records)
|
|
169
154
|
changes.push({
|
|
170
155
|
status: code === "A" ? "added" : code === "D" ? "deleted" : "modified",
|
|
171
|
-
path,
|
|
156
|
+
path: records.next().value ?? "",
|
|
172
157
|
});
|
|
173
|
-
}
|
|
174
158
|
return changes;
|
|
175
159
|
}
|
|
176
160
|
/**
|
|
@@ -181,22 +165,24 @@ export async function changesBetween(dir, before, after) {
|
|
|
181
165
|
* Then the modified and deleted ones are rewritten. Ignored files stay.
|
|
182
166
|
*/
|
|
183
167
|
export async function restore(dir, before, changes) {
|
|
168
|
+
const added = changes.filter(({ status }) => status === "added");
|
|
169
|
+
const rewritten = changes.filter(({ status }) => status !== "added");
|
|
184
170
|
await git(dir, ["read-tree", before]);
|
|
185
|
-
for (const {
|
|
186
|
-
if (status !== "added")
|
|
187
|
-
continue;
|
|
171
|
+
for (const { path } of added) {
|
|
188
172
|
await rm(join(dir, path), { force: true });
|
|
189
173
|
await removeEmptyParents(dir, path);
|
|
190
174
|
}
|
|
191
|
-
const rewritten = changes
|
|
192
|
-
.filter(({ status }) => status !== "added")
|
|
193
|
-
.map(({ path }) => path);
|
|
194
175
|
if (rewritten.length > 0)
|
|
195
|
-
await git(dir, [
|
|
176
|
+
await git(dir, [
|
|
177
|
+
"checkout-index",
|
|
178
|
+
"-f",
|
|
179
|
+
"--",
|
|
180
|
+
...rewritten.map(({ path }) => path),
|
|
181
|
+
]);
|
|
196
182
|
}
|
|
197
183
|
/** Removes the folders of `path` that are now empty, from the deepest up to the repository. */
|
|
198
184
|
async function removeEmptyParents(dir, path) {
|
|
199
|
-
for (let parent = dirname(path); parent !== "."; parent = dirname(parent))
|
|
185
|
+
for (let parent = dirname(path); parent !== "."; parent = dirname(parent)) {
|
|
200
186
|
try {
|
|
201
187
|
await rmdir(join(dir, parent));
|
|
202
188
|
}
|
|
@@ -204,41 +190,47 @@ async function removeEmptyParents(dir, path) {
|
|
|
204
190
|
// Not empty, or already gone: the folders above it stay too.
|
|
205
191
|
return;
|
|
206
192
|
}
|
|
193
|
+
}
|
|
207
194
|
}
|
|
208
195
|
/**
|
|
209
196
|
* Puts back everything that changed in the working tree since the snapshot
|
|
210
|
-
* `before
|
|
211
|
-
*
|
|
212
|
-
* followed by a new snapshot: the
|
|
213
|
-
*
|
|
214
|
-
* a deeper `.gitignore` that seems new may be an ignored file it exposed: it
|
|
215
|
-
* waits for the next snapshot. The other changes are then what they really
|
|
216
|
-
* are, and an ignored file is never taken for one.
|
|
197
|
+
* `before`; returns the paths it put back, none when nothing changed. A
|
|
198
|
+
* snapshot depends on the ignore rules, so they come back first, each time
|
|
199
|
+
* followed by a new snapshot (`nextToPutBack`): the other changes are then
|
|
200
|
+
* what they really are, and an ignored file is never taken for one.
|
|
217
201
|
*/
|
|
218
202
|
export async function putBack(dir, before) {
|
|
219
|
-
const put =
|
|
220
|
-
|
|
221
|
-
for (let round = 0;
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
const ignores = changes.filter(({ path }) => basename(path) === ".gitignore");
|
|
227
|
-
const existing = ignores.filter(({ status }) => status !== "added");
|
|
228
|
-
const shallowest = Math.min(...ignores.map(({ path }) => depth(path)));
|
|
229
|
-
const next = existing.length > 0
|
|
230
|
-
? existing
|
|
231
|
-
: ignores.length > 0
|
|
232
|
-
? ignores.filter(({ path }) => depth(path) === shallowest)
|
|
233
|
-
: changes;
|
|
203
|
+
const put = new Set();
|
|
204
|
+
let after = await snapshot(dir);
|
|
205
|
+
for (let round = 0; after !== before; round += 1) {
|
|
206
|
+
// Past this many rounds, something else keeps rewriting the ignore rules.
|
|
207
|
+
if (round === 20)
|
|
208
|
+
throw new Error("The working tree's .gitignore files keep changing: the run stops");
|
|
209
|
+
const next = nextToPutBack(await changesBetween(dir, before, after));
|
|
234
210
|
await restore(dir, before, next);
|
|
235
|
-
|
|
211
|
+
for (const { path } of next)
|
|
212
|
+
put.add(path);
|
|
213
|
+
after = await snapshot(dir);
|
|
236
214
|
}
|
|
237
|
-
|
|
238
|
-
return [...new Set(put)].sort();
|
|
239
|
-
throw new Error("The working tree's .gitignore files keep changing: the run stops");
|
|
215
|
+
return [...put].sort();
|
|
240
216
|
}
|
|
241
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* What `putBack` puts back next: the `.gitignore` files that were there, else
|
|
219
|
+
* the shallowest new ones, else every change. A rule only exposes files in its
|
|
220
|
+
* folder and below, so a deeper `.gitignore` that seems new may be an ignored
|
|
221
|
+
* file it exposed: it waits for the next snapshot.
|
|
222
|
+
*/
|
|
223
|
+
function nextToPutBack(changes) {
|
|
224
|
+
const ignores = changes.filter(({ path }) => basename(path) === ".gitignore");
|
|
225
|
+
if (ignores.length === 0)
|
|
226
|
+
return changes;
|
|
227
|
+
const existing = ignores.filter(({ status }) => status !== "added");
|
|
228
|
+
if (existing.length > 0)
|
|
229
|
+
return existing;
|
|
230
|
+
const shallowest = Math.min(...ignores.map(({ path }) => depth(path)));
|
|
231
|
+
return ignores.filter(({ path }) => depth(path) === shallowest);
|
|
232
|
+
}
|
|
233
|
+
/** How deep a path is: 1 for a file at the root of the repository. */
|
|
242
234
|
function depth(path) {
|
|
243
235
|
return path.split("/").length;
|
|
244
236
|
}
|
package/dist/system/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/system/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,uEAAuE;AACvE,KAAK,UAAU,GAAG,CAAC,GAAW,EAAE,IAAc,EAAE,SAAS,GAAG,MAAM;IAChE,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;IAClE,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAChF,CAAC;IACJ,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,KAAK,UAAU,MAAM,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,CAAC;QAC3C,KAAK,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,OAAqB;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,YAAY,CAAC,CAAC;IAC9E,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC;IACpE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IACzC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC,CAAC;AAClE,CAAC;AAED,sEAAsE;AACtE,SAAS,KAAK,CAAC,IAAY;IACzB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AAChC,CAAC"}
|
package/dist/system/github.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export declare function isAuthenticated(dir: string): Promise<boolean>;
|
|
2
|
+
/** The version of gh, such as `2.102.0`. */
|
|
3
|
+
export declare function version(dir: string): Promise<string>;
|
|
4
|
+
/** The repository's GitHub page, and whether anyone can see it. */
|
|
5
|
+
export declare function repository(dir: string): Promise<{
|
|
6
|
+
url: string;
|
|
7
|
+
public: boolean;
|
|
8
|
+
}>;
|
|
2
9
|
/** Updates the branch's open pull request, or opens one; returns its URL. */
|
|
3
10
|
export declare function openPullRequest(dir: string, pullRequest: {
|
|
4
11
|
base: string;
|
|
@@ -6,3 +13,11 @@ export declare function openPullRequest(dir: string, pullRequest: {
|
|
|
6
13
|
title: string;
|
|
7
14
|
body: string;
|
|
8
15
|
}): Promise<string>;
|
|
16
|
+
/** Replaces the pull request's body. */
|
|
17
|
+
export declare function editBody(dir: string, pullRequest: string, body: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Replaces the pull request's body, uploading the `images` of `folder` it
|
|
20
|
+
* names: gh, run there, points each reference at its upload. When some fail,
|
|
21
|
+
* gh still writes the body, with the others' references unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export declare function attachImages(folder: string, pullRequest: string, body: string, images: string[]): Promise<void>;
|
package/dist/system/github.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { runProcess } from "@clemrig/flow";
|
|
2
2
|
/** Runs gh in the repository; its output is never journaled, as it may describe the account. */
|
|
3
|
-
async function gh(dir, args, stdin) {
|
|
4
|
-
const result = await runProcess(["gh", ...args], dir,
|
|
3
|
+
async function gh(dir, args, stdin, timeoutMs = 60_000) {
|
|
4
|
+
const result = await runProcess(["gh", ...args], dir, timeoutMs, undefined, stdin);
|
|
5
5
|
if (result.exitCode !== 0)
|
|
6
6
|
throw new Error(`gh ${args.slice(0, 2).join(" ")} failed: ${result.stderr.trim()}`);
|
|
7
7
|
return result.stdout.trim();
|
|
@@ -10,6 +10,19 @@ export async function isAuthenticated(dir) {
|
|
|
10
10
|
const result = await runProcess(["gh", "auth", "status"], dir, 60_000);
|
|
11
11
|
return result.exitCode === 0;
|
|
12
12
|
}
|
|
13
|
+
/** The version of gh, such as `2.102.0`. */
|
|
14
|
+
export async function version(dir) {
|
|
15
|
+
const output = await gh(dir, ["--version"]);
|
|
16
|
+
const found = /^gh version (\d+\.\d+\.\d+)/.exec(output)?.[1];
|
|
17
|
+
if (!found)
|
|
18
|
+
throw new Error(`gh --version printed no version: ${output}`);
|
|
19
|
+
return found;
|
|
20
|
+
}
|
|
21
|
+
/** The repository's GitHub page, and whether anyone can see it. */
|
|
22
|
+
export async function repository(dir) {
|
|
23
|
+
const { url, visibility } = JSON.parse(await gh(dir, ["repo", "view", "--json", "url,visibility"]));
|
|
24
|
+
return { url, public: visibility === "PUBLIC" };
|
|
25
|
+
}
|
|
13
26
|
/** Updates the branch's open pull request, or opens one; returns its URL. */
|
|
14
27
|
export async function openPullRequest(dir, pullRequest) {
|
|
15
28
|
const { base, head, title, body } = pullRequest;
|
|
@@ -49,4 +62,25 @@ export async function openPullRequest(dir, pullRequest) {
|
|
|
49
62
|
"-",
|
|
50
63
|
], body);
|
|
51
64
|
}
|
|
65
|
+
/** Replaces the pull request's body. */
|
|
66
|
+
export async function editBody(dir, pullRequest, body) {
|
|
67
|
+
await gh(dir, ["pr", "edit", pullRequest, "--body-file", "-"], body);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Replaces the pull request's body, uploading the `images` of `folder` it
|
|
71
|
+
* names: gh, run there, points each reference at its upload. When some fail,
|
|
72
|
+
* gh still writes the body, with the others' references unchanged.
|
|
73
|
+
*/
|
|
74
|
+
export async function attachImages(folder, pullRequest, body, images) {
|
|
75
|
+
await gh(folder, [
|
|
76
|
+
"pr",
|
|
77
|
+
"edit",
|
|
78
|
+
pullRequest,
|
|
79
|
+
"--body-file",
|
|
80
|
+
"-",
|
|
81
|
+
...images.flatMap((image) => ["--attach", image]),
|
|
82
|
+
], body,
|
|
83
|
+
// Uploads take longer than the other calls.
|
|
84
|
+
600_000);
|
|
85
|
+
}
|
|
52
86
|
//# sourceMappingURL=github.js.map
|