@davidbyoung/software-factory 0.1.2 → 0.1.4
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 +20 -20
- package/actions/factory-agent/action.yml +1 -1
- package/agents/factory-e2e-reviewer.md +102 -0
- package/agents/factory-test-reviewer.md +26 -64
- package/agents/factory-ticket-readiness.md +14 -6
- package/dist/agent/claude-code.d.mts +3 -0
- package/dist/agent/claude-code.mjs +89 -0
- package/dist/agent/index.d.mts +2 -0
- package/dist/agent/index.mjs +5 -0
- package/dist/board.mjs +1 -1
- package/dist/cli.mjs +46 -4
- package/dist/code-host/github-setup.d.mts +5 -0
- package/dist/code-host/github-setup.mjs +133 -0
- package/dist/code-host/github.mjs +4 -0
- package/dist/code-host/index.d.mts +1 -1
- package/dist/code-host/index.mjs +2 -1
- package/dist/code-host/types.d.mts +2 -0
- package/dist/commands.d.mts +16 -0
- package/dist/commands.mjs +129 -0
- package/dist/config.d.mts +87 -20
- package/dist/config.mjs +344 -89
- package/dist/deps.d.mts +7 -4
- package/dist/deps.mjs +20 -9
- package/dist/doctor.d.mts +9 -16
- package/dist/doctor.mjs +71 -68
- package/dist/explain.d.mts +4 -0
- package/dist/explain.mjs +174 -0
- package/dist/guard-commit.d.mts +7 -2
- package/dist/guard-commit.mjs +58 -21
- package/dist/init.d.mts +12 -14
- package/dist/init.mjs +194 -136
- package/dist/lib/default-branch.d.mts +35 -0
- package/dist/lib/default-branch.mjs +117 -0
- package/dist/lib/has-command.d.mts +5 -0
- package/dist/lib/has-command.mjs +8 -0
- package/dist/lib/listed.d.mts +2 -0
- package/dist/lib/listed.mjs +4 -0
- package/dist/lib/refined-check.d.mts +7 -0
- package/dist/lib/refined-check.mjs +76 -0
- package/dist/lib/work-status.d.mts +12 -2
- package/dist/lib/work-status.mjs +14 -3
- package/dist/parts.d.mts +18 -15
- package/dist/parts.mjs +15 -43
- package/dist/patch-coverage.d.mts +13 -0
- package/dist/patch-coverage.mjs +73 -0
- package/dist/poller.d.mts +20 -3
- package/dist/poller.mjs +62 -15
- package/dist/pr-watch.d.mts +3 -2
- package/dist/pr-watch.mjs +22 -5
- package/dist/pr.mjs +34 -2
- package/dist/remove.d.mts +11 -0
- package/dist/remove.mjs +156 -0
- package/dist/runner/github-actions.d.mts +1 -1
- package/dist/runner/github-actions.mjs +12 -0
- package/dist/runner/index.d.mts +1 -1
- package/dist/runner/index.mjs +2 -1
- package/dist/runner/setup.d.mts +2 -0
- package/dist/runner/setup.mjs +22 -0
- package/dist/runner/types.d.mts +3 -0
- package/dist/runner/types.mjs +0 -2
- package/dist/session-start.d.mts +23 -13
- package/dist/session-start.mjs +56 -44
- package/dist/setup.d.mts +98 -0
- package/dist/setup.mjs +3 -0
- package/dist/site/servers.d.mts +6 -2
- package/dist/site/servers.mjs +14 -9
- package/dist/site.mjs +2 -2
- package/dist/status.d.mts +4 -4
- package/dist/status.mjs +8 -7
- package/dist/sync.d.mts +26 -2
- package/dist/sync.mjs +177 -13
- package/dist/ticket.mjs +19 -1
- package/dist/tickets/github-setup.d.mts +2 -0
- package/dist/tickets/github-setup.mjs +50 -0
- package/dist/tickets/github.mjs +0 -2
- package/dist/tickets/index.mjs +2 -1
- package/dist/tickets/transport.mjs +1 -3
- package/dist/tickets/types.mjs +0 -2
- package/dist/tool-names.d.mts +11 -0
- package/dist/tool-names.mjs +20 -0
- package/dist/tools.d.mts +56 -0
- package/dist/tools.mjs +76 -0
- package/docs/builds.md +111 -59
- package/docs/cli.md +106 -69
- package/docs/configuration.md +489 -171
- package/docs/design.md +18 -5
- package/docs/developing.md +179 -73
- package/docs/existing-repo.md +25 -12
- package/docs/github/by-hand.md +334 -0
- package/docs/github/reference.md +76 -67
- package/docs/github/setup.md +105 -286
- package/docs/glossary.md +18 -7
- package/docs/limitations.md +39 -12
- package/docs/plugins.md +305 -56
- package/docs/quick-start.md +85 -100
- package/docs/removing.md +37 -17
- package/docs/skills.md +121 -62
- package/docs/updating.md +150 -9
- package/docs/workflow.md +23 -19
- package/package.json +1 -1
- package/poller.Dockerfile +10 -18
- package/review.md +20 -11
- package/rules.md +36 -30
- package/settings.schema.json +313 -69
- package/skills/factory-address-review/SKILL.md +50 -30
- package/skills/factory-build/SKILL.md +76 -23
- package/skills/factory-deps/SKILL.md +46 -21
- package/skills/factory-design/SKILL.md +17 -8
- package/skills/factory-diagnose/SKILL.md +22 -20
- package/skills/factory-mutate/SKILL.md +38 -24
- package/skills/factory-refine/SKILL.md +55 -31
- package/skills/factory-resolve-conflicts/SKILL.md +76 -34
- package/skills/factory-trace/SKILL.md +80 -0
- package/workflows/factory-build.yml +6 -5
- package/workflows/factory-conflicts.yml +8 -8
- package/workflows/factory-deps-auto-merge.yml +3 -2
- package/workflows/factory-deps.yml +1 -1
- package/workflows/factory-poller.yml +46 -0
- package/workflows/factory-review.yml +1 -1
- package/skills/factory-address-review/patch-coverage.py +0 -68
package/dist/session-start.mjs
CHANGED
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
// The SessionStart hook, run as `factory session-start`. Its output opens
|
|
2
2
|
// the session's context, so work left on another branch is visible before
|
|
3
3
|
// anything new starts: the checkout's state, the local branches with work
|
|
4
|
-
// not on
|
|
5
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
+
// not on the default branch, then each ticket's state.
|
|
6
5
|
import { readFileSync } from "node:fs";
|
|
7
6
|
import { join } from "node:path";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* a merged branch still has commits main lacks: it counts as merged when
|
|
19
|
-
* merging it into main would change nothing. */
|
|
20
|
-
export function unmergedBranches(git) {
|
|
21
|
-
const mainTree = git(["rev-parse", "origin/main^{tree}"]).out.trim();
|
|
7
|
+
import { branchDeps, CANNOT_TELL, defaultBranch, gitIn, } from "./lib/default-branch.mjs";
|
|
8
|
+
export { gitIn };
|
|
9
|
+
/** Each local branch but the default one, `branch`, with work
|
|
10
|
+
* origin/BRANCH lacks, as "NAME (N commits not on origin/BRANCH)". Pull
|
|
11
|
+
* requests are squash-merged, so a merged branch still has commits the
|
|
12
|
+
* default branch lacks: it counts as merged when merging it into the
|
|
13
|
+
* default branch would change nothing. */
|
|
14
|
+
export function unmergedBranches(git, branch) {
|
|
15
|
+
const base = `origin/${branch}`;
|
|
16
|
+
const baseTree = git(["rev-parse", `${base}^{tree}`]).out.trim();
|
|
22
17
|
const branches = git([
|
|
23
18
|
"for-each-ref",
|
|
24
19
|
"--format=%(refname:short)",
|
|
25
20
|
"refs/heads",
|
|
26
21
|
])
|
|
27
22
|
.out.split("\n")
|
|
28
|
-
.filter((b) => b && b !==
|
|
23
|
+
.filter((b) => b && b !== branch);
|
|
29
24
|
const found = [];
|
|
30
25
|
for (const b of branches) {
|
|
31
|
-
const merged = git(["merge-tree", "--write-tree",
|
|
32
|
-
if (merged.ok && merged.out.split("\n")[0] ===
|
|
26
|
+
const merged = git(["merge-tree", "--write-tree", base, b]);
|
|
27
|
+
if (merged.ok && merged.out.split("\n")[0] === baseTree)
|
|
33
28
|
continue;
|
|
34
|
-
const count = Number(git(["rev-list", "--count",
|
|
29
|
+
const count = Number(git(["rev-list", "--count", `${base}..${b}`]).out.trim() || 0);
|
|
35
30
|
if (count > 0)
|
|
36
|
-
found.push(`${b} (${count} commits not on
|
|
31
|
+
found.push(`${b} (${count} commits not on ${base})`);
|
|
37
32
|
}
|
|
38
33
|
return found;
|
|
39
34
|
}
|
|
40
|
-
/** What the hook prints before the tickets' state.
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
/** What the hook prints before the tickets' state. `branch` is the default
|
|
36
|
+
* branch, or null when it could not be told: then no branch is compared
|
|
37
|
+
* with anything, and the line that names the fix stands in for the list. */
|
|
38
|
+
export function repositoryState(git, branch) {
|
|
39
|
+
if (branch !== null)
|
|
40
|
+
git(["fetch", "-q", "origin", branch]);
|
|
43
41
|
const lines = [
|
|
44
42
|
"## Repository state at session start",
|
|
45
43
|
"",
|
|
@@ -48,9 +46,11 @@ export function repositoryState(git) {
|
|
|
48
46
|
"```",
|
|
49
47
|
"",
|
|
50
48
|
];
|
|
51
|
-
|
|
49
|
+
if (branch === null)
|
|
50
|
+
return [...lines, CANNOT_TELL];
|
|
51
|
+
const unmerged = unmergedBranches(git, branch);
|
|
52
52
|
if (unmerged.length) {
|
|
53
|
-
lines.push(
|
|
53
|
+
lines.push(`Local branches with work not on origin/${branch}:`, "", ...unmerged.map((b) => `- ${b}`), "", "Mention any of these to the user before starting work on another branch.");
|
|
54
54
|
}
|
|
55
55
|
return lines;
|
|
56
56
|
}
|
|
@@ -86,6 +86,15 @@ export function installBehind(dir) {
|
|
|
86
86
|
}
|
|
87
87
|
return null;
|
|
88
88
|
}
|
|
89
|
+
export async function main(d) {
|
|
90
|
+
const branch = await defaultBranch(d.branch).catch(() => null);
|
|
91
|
+
d.out(repositoryState(gitIn(d.dir), branch).join("\n"));
|
|
92
|
+
const behind = installBehind(d.dir);
|
|
93
|
+
if (behind)
|
|
94
|
+
d.out(`\n${behind}\n`);
|
|
95
|
+
return d.tickets();
|
|
96
|
+
}
|
|
97
|
+
/** `factory session-start`. */
|
|
89
98
|
export async function run() {
|
|
90
99
|
const dir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
91
100
|
try {
|
|
@@ -94,22 +103,25 @@ export async function run() {
|
|
|
94
103
|
catch {
|
|
95
104
|
return 0;
|
|
96
105
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
console.log(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
return main({
|
|
107
|
+
dir,
|
|
108
|
+
branch: branchDeps(dir),
|
|
109
|
+
out: (text) => console.log(text),
|
|
110
|
+
// What each ticket's board card says, and who is working on it. The
|
|
111
|
+
// status command enforces its own time limit, since a hook the harness
|
|
112
|
+
// kills prints nothing.
|
|
113
|
+
tickets: async () => {
|
|
114
|
+
const error = console.error;
|
|
115
|
+
console.error = () => { };
|
|
116
|
+
try {
|
|
117
|
+
return await (await import("./status.mjs")).run(["--hook"]);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
console.error = error;
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
});
|
|
115
127
|
}
|
package/dist/setup.d.mts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { CodeHost } from "./code-host/types.mts";
|
|
2
|
+
import type { Settings } from "./config.mts";
|
|
3
|
+
import type { Part } from "./parts.mts";
|
|
4
|
+
import type { Runner } from "./runner/types.mts";
|
|
5
|
+
import type { Tickets } from "./tickets/types.mts";
|
|
6
|
+
/** The repository rule that requires the review's verdict, by name, so
|
|
7
|
+
* removing it is deleting that one rule. */
|
|
8
|
+
export declare const RULE = "Software factory";
|
|
9
|
+
export type Check = {
|
|
10
|
+
state: "pass" | "fail" | "off";
|
|
11
|
+
text: string;
|
|
12
|
+
/** What to do about a failure. */
|
|
13
|
+
fix?: string;
|
|
14
|
+
};
|
|
15
|
+
/** A secret is needed for a part that is on, or always when `part` is
|
|
16
|
+
* null, and any one of `anyOf` being set meets it. */
|
|
17
|
+
export type Need = {
|
|
18
|
+
part: Part | null;
|
|
19
|
+
anyOf: string[];
|
|
20
|
+
};
|
|
21
|
+
/** A value written under the tool's kind's block of the settings. */
|
|
22
|
+
export type ValueStep = {
|
|
23
|
+
kind: "value";
|
|
24
|
+
/** Its key, such as `site` under `tickets`. */
|
|
25
|
+
key: string;
|
|
26
|
+
part: Part | null;
|
|
27
|
+
ask: string;
|
|
28
|
+
fallback?: string;
|
|
29
|
+
};
|
|
30
|
+
export type SecretStep = {
|
|
31
|
+
kind: "secret";
|
|
32
|
+
needs: Need[];
|
|
33
|
+
/** The names a pasted value is stored under. */
|
|
34
|
+
storeAs: string[];
|
|
35
|
+
/** Printed before the value is read. */
|
|
36
|
+
intro: string[];
|
|
37
|
+
get?: {
|
|
38
|
+
page: string;
|
|
39
|
+
} | {
|
|
40
|
+
command: string[];
|
|
41
|
+
};
|
|
42
|
+
/** The masked prompt. */
|
|
43
|
+
prompt: string;
|
|
44
|
+
/** Printed when nothing is pasted, before "Run ... init again". */
|
|
45
|
+
skipped: string;
|
|
46
|
+
/** Resolves to lines to print, and the account the value belongs to
|
|
47
|
+
* when the tool knows it; rejects with the line to print before asking
|
|
48
|
+
* again. */
|
|
49
|
+
verify?: (value: string) => Promise<{
|
|
50
|
+
lines: string[];
|
|
51
|
+
account?: string;
|
|
52
|
+
}>;
|
|
53
|
+
/** Printed once it is stored. */
|
|
54
|
+
stored: (names: string[], account?: string) => string;
|
|
55
|
+
};
|
|
56
|
+
export type SetupStep = ValueStep | SecretStep;
|
|
57
|
+
/** The name of each kind's tool in use. */
|
|
58
|
+
export type Chosen = {
|
|
59
|
+
codeHost: string;
|
|
60
|
+
tickets: string;
|
|
61
|
+
runner: string;
|
|
62
|
+
agent: string;
|
|
63
|
+
};
|
|
64
|
+
export type Opened = {
|
|
65
|
+
codeHost: CodeHost;
|
|
66
|
+
runner: Runner;
|
|
67
|
+
tickets: Tickets;
|
|
68
|
+
};
|
|
69
|
+
export type SetupContext = {
|
|
70
|
+
repository: string;
|
|
71
|
+
root: string;
|
|
72
|
+
parts: ReadonlySet<Part>;
|
|
73
|
+
chosen: Chosen;
|
|
74
|
+
settings: Settings | null;
|
|
75
|
+
hasCommand: (name: string) => boolean;
|
|
76
|
+
opened: Opened;
|
|
77
|
+
};
|
|
78
|
+
/** The secrets set, or null when the runner could not list them. */
|
|
79
|
+
export type WithSecrets = SetupContext & {
|
|
80
|
+
secrets: string[] | null;
|
|
81
|
+
};
|
|
82
|
+
/** A file of the tool's own, as it reads with the factory's part taken
|
|
83
|
+
* out: null to delete it. */
|
|
84
|
+
export type Unconfigured = {
|
|
85
|
+
path: string;
|
|
86
|
+
text: string | null;
|
|
87
|
+
};
|
|
88
|
+
export type ToolSetup = {
|
|
89
|
+
/** Its row under Found, when it says more than its label. */
|
|
90
|
+
found?(c: Pick<SetupContext, "hasCommand">): string;
|
|
91
|
+
steps?(c: SetupContext): SetupStep[];
|
|
92
|
+
checks?(c: WithSecrets): Promise<Check[]>;
|
|
93
|
+
/** What `remove` prints as left to remove by hand. */
|
|
94
|
+
leftovers?(c: WithSecrets): string[];
|
|
95
|
+
/** Its own files with the factory's part taken out, for `remove`: only
|
|
96
|
+
* those the factory's part is in. */
|
|
97
|
+
unconfigure?(c: SetupContext): Unconfigured[];
|
|
98
|
+
};
|
package/dist/setup.mjs
ADDED
package/dist/site/servers.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Deps as BranchDeps } from "../lib/default-branch.mts";
|
|
1
2
|
export declare class SiteError extends Error {
|
|
2
3
|
}
|
|
3
4
|
export type Running = {
|
|
@@ -25,8 +26,11 @@ export declare function startSite(opts: {
|
|
|
25
26
|
* that stops the others. */
|
|
26
27
|
export declare function startSites(sites: Parameters<typeof startSite>[0][], pids: number[]): Promise<Running[]>;
|
|
27
28
|
export declare function stopProcess(pid: number): void;
|
|
28
|
-
/**
|
|
29
|
-
|
|
29
|
+
/** The ref a comparison's base is started from when none is given: the
|
|
30
|
+
* default branch, as `origin` has it, or the checkout's own branch of that
|
|
31
|
+
* name where there is no such ref, as in a checkout with no remote. It
|
|
32
|
+
* fails, naming the fix, when the default branch cannot be told. */
|
|
33
|
+
export declare function defaultBase(root: string, d?: BranchDeps): Promise<string>;
|
|
30
34
|
/** A detached worktree of `ref` in a temporary folder, with its dependencies
|
|
31
35
|
* installed when it has a lockfile. Returns its path. */
|
|
32
36
|
export declare function addWorktree(root: string, ref: string): string;
|
package/dist/site/servers.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { createServer } from "node:net";
|
|
|
6
6
|
import { closeSync, existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
import { join } from "node:path";
|
|
9
|
+
import { branchDeps, CANNOT_TELL, defaultBranch, } from "../lib/default-branch.mjs";
|
|
9
10
|
export class SiteError extends Error {
|
|
10
11
|
}
|
|
11
12
|
/** A port nothing is listening on. */
|
|
@@ -80,15 +81,19 @@ export function stopProcess(pid) {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
84
|
+
/** The ref a comparison's base is started from when none is given: the
|
|
85
|
+
* default branch, as `origin` has it, or the checkout's own branch of that
|
|
86
|
+
* name where there is no such ref, as in a checkout with no remote. It
|
|
87
|
+
* fails, naming the fix, when the default branch cannot be told. */
|
|
88
|
+
export async function defaultBase(root, d = branchDeps(root)) {
|
|
89
|
+
const name = await defaultBranch(d);
|
|
90
|
+
if (name === null)
|
|
91
|
+
throw new SiteError(CANNOT_TELL);
|
|
92
|
+
const remote = `refs/remotes/origin/${name}`;
|
|
93
|
+
return d.git(["rev-parse", "--verify", "--quiet", remote]).ok
|
|
94
|
+
? `origin/${name}`
|
|
95
|
+
: name;
|
|
96
|
+
}
|
|
92
97
|
/** A detached worktree of `ref` in a temporary folder, with its dependencies
|
|
93
98
|
* installed when it has a lockfile. Returns its path. */
|
|
94
99
|
export function addWorktree(root, ref) {
|
package/dist/site.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import { crawl, normalize, sitemapPaths } from "./site/pages.mjs";
|
|
|
17
17
|
import { changedWithoutNoise, classify, diff, } from "./site/pixels.mjs";
|
|
18
18
|
import { encode, launch, measureView, shoot, } from "./site/capture.mjs";
|
|
19
19
|
import { addToCensus, AXE_TAGS, emptyCensus, formatFinding, newValues, newViolations, sidewaysScroll, } from "./site/measure.mjs";
|
|
20
|
-
import { addWorktree,
|
|
20
|
+
import { addWorktree, defaultBase, freePort, keep, removeWorktree, SiteError, startSites, stopKept, stopProcess, } from "./site/servers.mjs";
|
|
21
21
|
const slug = (p) => p.replace(/^\/|\/$/g, "").replace(/\W+/g, "-") || "home";
|
|
22
22
|
async function text(url) {
|
|
23
23
|
try {
|
|
@@ -261,7 +261,7 @@ async function compare(argv) {
|
|
|
261
261
|
after = given.after;
|
|
262
262
|
}
|
|
263
263
|
else {
|
|
264
|
-
const base = flag(argv, "--base") ??
|
|
264
|
+
const base = flag(argv, "--base") ?? (await defaultBase(root));
|
|
265
265
|
const [pa, pb] = [await freePort(), await freePort()];
|
|
266
266
|
worktree = addWorktree(root, base);
|
|
267
267
|
const common = { start: site.start, minutes: site.startMinutes };
|
package/dist/status.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { type Settings, type Target } from "./config.mts";
|
|
3
|
-
import { type Columns, type Board, type Derived, type PullRequest, type Issue, type RepoSnapshot, type ReviewerRun } from "./lib/work-status.mts";
|
|
3
|
+
import { type Columns, type Watch, type Board, type Derived, type PullRequest, type Issue, type RepoSnapshot, type ReviewerRun } from "./lib/work-status.mts";
|
|
4
4
|
import { type Tickets } from "./tickets/types.mts";
|
|
5
5
|
import { type CodeHost } from "./code-host/index.mts";
|
|
6
6
|
import { type Runner } from "./runner/index.mts";
|
|
@@ -27,9 +27,9 @@ export declare function isWatching(body: string, now: Date): boolean;
|
|
|
27
27
|
/** One row per open issue, and one per open pull request that closes no
|
|
28
28
|
* issue and builds no part of the follow-ups, such as Dependabot's. */
|
|
29
29
|
export declare function toRows(snapshot: RepoSnapshot, board: Board, blockers: Map<number, number[]>, now: Date,
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
|
|
30
|
+
/** What starts builds from the board, so that a card left in Ready is
|
|
31
|
+
* worth flagging; null when builds.trigger is manual. */
|
|
32
|
+
watch?: Watch | null, columns?: Columns): {
|
|
33
33
|
rows: Row[];
|
|
34
34
|
closed: Row[];
|
|
35
35
|
};
|
package/dist/status.mjs
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
15
15
|
import { NO_DEPENDENCIES, SettingsError, loadSettings, targetOf, } from "./config.mjs";
|
|
16
16
|
import { appSessionLink } from "./lib/gh.mjs";
|
|
17
|
-
import { DEFAULT_COLUMNS, cardOf, derive, isNotStarted, isStale, isStuck, actionsRunLink, buildsPartOf, markedComments, parseRuns, toSnapshot, } from "./lib/work-status.mjs";
|
|
17
|
+
import { DEFAULT_COLUMNS, cardOf, derive, isNotStarted, watchOf, isStale, isStuck, actionsRunLink, buildsPartOf, markedComments, parseRuns, toSnapshot, } from "./lib/work-status.mjs";
|
|
18
18
|
import { boardOf, readAll } from "./tickets/types.mjs";
|
|
19
19
|
import { openTickets } from "./tickets/index.mjs";
|
|
20
20
|
import { openCodeHost } from "./code-host/index.mjs";
|
|
@@ -66,9 +66,9 @@ export function isWatching(body, now) {
|
|
|
66
66
|
/** One row per open issue, and one per open pull request that closes no
|
|
67
67
|
* issue and builds no part of the follow-ups, such as Dependabot's. */
|
|
68
68
|
export function toRows(snapshot, board, blockers, now,
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
|
|
69
|
+
/** What starts builds from the board, so that a card left in Ready is
|
|
70
|
+
* worth flagging; null when builds.trigger is manual. */
|
|
71
|
+
watch = watchOf("own-server", 5), columns = DEFAULT_COLUMNS) {
|
|
72
72
|
const rows = [];
|
|
73
73
|
const closed = [];
|
|
74
74
|
const claimed = new Set();
|
|
@@ -79,8 +79,9 @@ watched = true, columns = DEFAULT_COLUMNS) {
|
|
|
79
79
|
const flags = [];
|
|
80
80
|
if (isStale(derived, now))
|
|
81
81
|
flags.push("stale");
|
|
82
|
-
if (
|
|
83
|
-
|
|
82
|
+
if (watch &&
|
|
83
|
+
isNotStarted(derived, blockers.get(issue.number) ?? [], now, watch.minutes))
|
|
84
|
+
flags.push(watch.flag);
|
|
84
85
|
const row = {
|
|
85
86
|
number: issue.number,
|
|
86
87
|
kind: "issue",
|
|
@@ -404,7 +405,7 @@ async function snapshotLines(source, target, now, hook, style = PLAIN) {
|
|
|
404
405
|
const list = await source.tickets.blockers.list(issue.number);
|
|
405
406
|
blockers.set(issue.number, list.filter((b) => b.state === "open").map((b) => b.number));
|
|
406
407
|
}
|
|
407
|
-
return formatRows(toRows(snapshot, board, blockers, now, target.
|
|
408
|
+
return formatRows(toRows(snapshot, board, blockers, now, target.watch, target.columns), now, !hook, { ...style, links, columns: target.columns });
|
|
408
409
|
}
|
|
409
410
|
const WATCH_MS = 15_000;
|
|
410
411
|
// The alternate screen with the cursor hidden, and back.
|
package/dist/sync.d.mts
CHANGED
|
@@ -8,10 +8,20 @@ export declare const CLAUDE_MD = "CLAUDE.md";
|
|
|
8
8
|
export declare const IMPORT_LINE = "@.claude/factory/rules.md";
|
|
9
9
|
/** Whether the repository has a file, by its path from the root. */
|
|
10
10
|
type Has = (path: string) => boolean;
|
|
11
|
+
/** The scheduled poller's workflow, its one `cron` line set to run every
|
|
12
|
+
* `minutes`: on the hour for 60, every N minutes past it otherwise. */
|
|
13
|
+
export declare function withSchedule(text: string, minutes: number, file: string): string;
|
|
14
|
+
/** A workflow with the one `branches:` line of its push trigger naming the
|
|
15
|
+
* default branch and nothing else. */
|
|
16
|
+
export declare function withDefaultBranch(text: string, name: string, file: string): string;
|
|
11
17
|
/** A session workflow with the minutes its session may run, and its job 10
|
|
12
18
|
* more, so the steps after the session still run before the job is
|
|
13
19
|
* stopped. */
|
|
14
20
|
export declare function withMinutes(text: string, minutes: number, file: string): string;
|
|
21
|
+
/** A copy with the rules' numbers the settings give in place of the
|
|
22
|
+
* defaults. A phrase is replaced only when its number is not the default,
|
|
23
|
+
* and must then match exactly once. */
|
|
24
|
+
export declare function withRules(text: string, r: Settings["rules"], file: string): string;
|
|
15
25
|
/** Each copy, as [path in the package, path in the repository]. */
|
|
16
26
|
export declare function copies(pkg: string, s: Settings, has: Has): [string, string][];
|
|
17
27
|
/** The launcher's path from the repository's root: the root's own, where
|
|
@@ -35,8 +45,19 @@ export declare function factoryHooks(launcher: string): [string, HookGroup][];
|
|
|
35
45
|
* replaced by the five above, and attribution turned off unless the file
|
|
36
46
|
* sets its own. Every other entry stays, in its order. */
|
|
37
47
|
export declare function withHooks(text: string | null, launcher: string): string;
|
|
48
|
+
/** Whether every event of the five has the factory's entry. */
|
|
49
|
+
export declare function hasFactoryHooks(text: string | null): boolean;
|
|
50
|
+
/** Whether any hook entry is the factory's. */
|
|
51
|
+
export declare function hasAnyFactoryHook(text: string | null): boolean;
|
|
52
|
+
/** `.claude/settings.json` with the factory's entries taken out and an
|
|
53
|
+
* emptied `hooks` dropped, or null when nothing is left. */
|
|
54
|
+
export declare function withoutHooks(text: string): string | null;
|
|
55
|
+
export declare const hasImport: (text: string | null) => boolean;
|
|
38
56
|
/** `CLAUDE.md` with the rules' import added when no line is that import. */
|
|
39
57
|
export declare function withImport(text: string | null): string;
|
|
58
|
+
/** `CLAUDE.md` without the rules' import, nor the blank line `withImport`
|
|
59
|
+
* put before it, or null when nothing else is left. */
|
|
60
|
+
export declare function withoutImport(text: string): string | null;
|
|
40
61
|
export declare function lockText(version: string, files: string[]): string;
|
|
41
62
|
export declare function lockedFiles(text: string | null): string[];
|
|
42
63
|
export type Plan = {
|
|
@@ -45,14 +66,17 @@ export type Plan = {
|
|
|
45
66
|
/** Paths the lock lists that this version no longer writes. */
|
|
46
67
|
remove: string[];
|
|
47
68
|
};
|
|
48
|
-
/** What a sync of `root` from `pkg` writes and deletes
|
|
49
|
-
|
|
69
|
+
/** What a sync of `root` from `pkg` writes and deletes, in a repository
|
|
70
|
+
* whose default branch is `branch`. */
|
|
71
|
+
export declare function plan(pkg: string, root: string, s: Settings, branch: string): Plan;
|
|
50
72
|
/** The paths whose content a sync would change, in the plan's order. */
|
|
51
73
|
export declare function differences(root: string, p: Plan): string[];
|
|
52
74
|
export declare function main(argv: string[], d: {
|
|
53
75
|
root: string;
|
|
54
76
|
pkg: string;
|
|
55
77
|
settings: () => Promise<Settings>;
|
|
78
|
+
/** The repository's default branch, or null when it cannot be told. */
|
|
79
|
+
defaultBranch: () => Promise<string | null>;
|
|
56
80
|
out: (line: string) => void;
|
|
57
81
|
err: (line: string) => void;
|
|
58
82
|
}): Promise<number>;
|