@davidbyoung/software-factory 0.1.12 → 0.1.13
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/board.d.mts +3 -1
- package/dist/board.mjs +12 -6
- package/dist/commands.mjs +1 -1
- package/dist/config.d.mts +7 -0
- package/dist/config.mjs +68 -5
- package/dist/explain.mjs +6 -0
- package/dist/guard-commit.d.mts +3 -3
- package/dist/guard-commit.mjs +31 -6
- package/dist/guard-ticket-text.d.mts +3 -2
- package/dist/guard-ticket-text.mjs +7 -4
- package/dist/labels.d.mts +28 -0
- package/dist/labels.mjs +36 -0
- package/dist/lib/refined-check.d.mts +1 -1
- package/dist/lib/refined-check.mjs +3 -5
- package/dist/lib/work-status.d.mts +6 -4
- package/dist/lib/work-status.mjs +17 -7
- package/dist/merge-policy.d.mts +9 -7
- package/dist/merge-policy.mjs +13 -11
- package/dist/poller.d.mts +3 -1
- package/dist/poller.mjs +10 -4
- package/dist/pr.d.mts +4 -0
- package/dist/pr.mjs +6 -3
- package/dist/remove.mjs +16 -9
- package/dist/review-verdict.d.mts +6 -1
- package/dist/review-verdict.mjs +15 -9
- package/dist/status.d.mts +2 -0
- package/dist/status.mjs +6 -3
- package/dist/sync.d.mts +4 -0
- package/dist/sync.mjs +17 -1
- package/dist/ticket-fields.d.mts +4 -2
- package/dist/ticket-fields.mjs +10 -3
- package/dist/ticket.d.mts +2 -1
- package/dist/ticket.mjs +30 -15
- package/dist/tickets/index.d.mts +2 -1
- package/dist/tickets/index.mjs +5 -4
- package/dist/tool-names.d.mts +7 -0
- package/dist/tool-names.mjs +1 -0
- package/dist/tools.d.mts +4 -1
- package/dist/tools.mjs +5 -0
- package/docs/cli.md +1 -1
- package/docs/configuration.md +178 -8
- package/docs/developing.md +1 -1
- package/docs/github/by-hand.md +2 -2
- package/docs/github/reference.md +21 -21
- package/docs/workflow.md +8 -6
- package/package.json +1 -1
- package/rules.md +7 -2
- package/settings.schema.json +45 -0
- package/skills/factory-address-review/SKILL.md +3 -3
- package/skills/factory-build/SKILL.md +3 -3
- package/skills/factory-resolve-conflicts/SKILL.md +1 -1
- package/workflows/factory-conflicts.yml +1 -1
- package/workflows/factory-merge-policy.yml +8 -7
- package/workflows/factory-review-verdict.yml +1 -1
- package/workflows/factory-review.yml +1 -1
package/dist/merge-policy.mjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
// npx --no-install factory merge-policy PR_NUMBER # prints the labels to set
|
|
5
5
|
//
|
|
6
|
-
// "merge
|
|
6
|
+
// "merge-automatic" only when no changed file is one of the factory's own,
|
|
7
7
|
// none matches auto-merge.deny in .claude/factory.yaml, every one matches
|
|
8
8
|
// auto-merge.allow, and every command under auto-merge.commands exits 0;
|
|
9
|
-
// "merge
|
|
9
|
+
// "merge-manual" otherwise. The merge-policy workflow runs this from main's copy,
|
|
10
10
|
// with main's settings, so a pull request cannot change how it is judged.
|
|
11
11
|
import { spawnSync } from "node:child_process";
|
|
12
12
|
import { loadSettings } from "./config.mjs";
|
|
@@ -19,10 +19,10 @@ export const inGithubNames = (files) => files.map(({ path, previousPath, status
|
|
|
19
19
|
previous_filename: previousPath,
|
|
20
20
|
status,
|
|
21
21
|
}));
|
|
22
|
-
/** The two merge labels. The merge-policy workflow applies one
|
|
23
|
-
* other; only
|
|
24
|
-
export const AUTOMATIC = "merge
|
|
25
|
-
export const MANUAL = "merge
|
|
22
|
+
/** The keys of the two merge labels. The merge-policy workflow applies one
|
|
23
|
+
* and removes the other; only the automatic one turns auto-merge on. */
|
|
24
|
+
export const AUTOMATIC = "merge-automatic";
|
|
25
|
+
export const MANUAL = "merge-manual";
|
|
26
26
|
/** The factory's own files, held whatever the settings allow: a pull request
|
|
27
27
|
* must not be able to change how pull requests are judged. Every spec tool's
|
|
28
28
|
* process files are among them, whichever the settings name, since a pull
|
|
@@ -99,13 +99,15 @@ export function statusLine({ risk, reasons }) {
|
|
|
99
99
|
const line = `Waits for the owner: ${first}${more}`;
|
|
100
100
|
return line.length > 140 ? `${line.slice(0, 139)}…` : line;
|
|
101
101
|
}
|
|
102
|
-
/** What the merge-policy workflow needs: the label to set
|
|
103
|
-
* whether auto-merge goes on,
|
|
104
|
-
|
|
102
|
+
/** What the merge-policy workflow needs: the label to set and the one to
|
|
103
|
+
* remove, each by the name `names` gives it, whether auto-merge goes on,
|
|
104
|
+
* and the status line. */
|
|
105
|
+
export function workflowOutput(result, names) {
|
|
105
106
|
const automatic = result.risk === AUTOMATIC;
|
|
106
107
|
return {
|
|
107
108
|
...result,
|
|
108
|
-
|
|
109
|
+
label: names[result.risk],
|
|
110
|
+
other: names[automatic ? MANUAL : AUTOMATIC],
|
|
109
111
|
automatic,
|
|
110
112
|
status: statusLine(result),
|
|
111
113
|
};
|
|
@@ -137,7 +139,7 @@ async function main(argv) {
|
|
|
137
139
|
// The pull request as it is now, not as the event described it: an event
|
|
138
140
|
// sent just after a push can carry the previous commit and draft state.
|
|
139
141
|
console.log(JSON.stringify({
|
|
140
|
-
...workflowOutput(decide(paths, holds)),
|
|
142
|
+
...workflowOutput(decide(paths, holds), settings.codeHost.labels),
|
|
141
143
|
sha: pull.head.sha,
|
|
142
144
|
draft: pull.isDraft,
|
|
143
145
|
}));
|
package/dist/poller.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Runner } from "./runner/types.mts";
|
|
|
6
6
|
import { type Key, type Tickets } from "./tickets/types.mts";
|
|
7
7
|
export declare const FIRE_LIMIT = 20;
|
|
8
8
|
/** The open issues the shared derivation puts in Ready, in key order. */
|
|
9
|
-
export declare function selectToStart(snapshot: RepoSnapshot, board: Board, columns?: Columns): Key[];
|
|
9
|
+
export declare function selectToStart(snapshot: RepoSnapshot, board: Board, columns?: Columns, followUp?: string): Key[];
|
|
10
10
|
export declare function startMarker(): string;
|
|
11
11
|
/** The columns the poller reads a board by. It runs with no settings file,
|
|
12
12
|
* so it is told the one name it needs, the column that approves a build:
|
|
@@ -67,6 +67,8 @@ export declare function tick(d: Deps, state: State): Promise<void>;
|
|
|
67
67
|
export type OnceSettings = {
|
|
68
68
|
board: number | null;
|
|
69
69
|
ready: string | null;
|
|
70
|
+
/** The name of the follow-ups ticket's label. */
|
|
71
|
+
followUp: string;
|
|
70
72
|
};
|
|
71
73
|
export declare function onceSettings(s: Settings): OnceSettings;
|
|
72
74
|
/** One pass, for a scheduled run: the board and the Ready column come from
|
package/dist/poller.mjs
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
// It names its implementations itself, having no settings to name them:
|
|
21
21
|
// the GitHub ticket adapter, GitHub as the code host, and GitHub Actions as
|
|
22
22
|
// the runner, each over the `fetch` transport, since it runs with no `gh`.
|
|
23
|
+
import { TICKET_LABELS } from "./labels.mjs";
|
|
23
24
|
import { randomBytes } from "node:crypto";
|
|
24
25
|
import { columnsOf, loadSettings } from "./config.mjs";
|
|
25
26
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
@@ -36,10 +37,10 @@ const HOUR = 60 * MINUTE;
|
|
|
36
37
|
export const FIRE_LIMIT = 20;
|
|
37
38
|
const FIRE_TIMEOUT_MS = 30_000;
|
|
38
39
|
/** The open issues the shared derivation puts in Ready, in key order. */
|
|
39
|
-
export function selectToStart(snapshot, board, columns = DEFAULT_COLUMNS) {
|
|
40
|
+
export function selectToStart(snapshot, board, columns = DEFAULT_COLUMNS, followUp = TICKET_LABELS["follow-up"]) {
|
|
40
41
|
return snapshot.issues
|
|
41
42
|
.filter((issue) => issue.state === "open" &&
|
|
42
|
-
derive(issue, cardOf(board, issue.key, columns), snapshot.pulls, columns).status === "Ready")
|
|
43
|
+
derive(issue, cardOf(board, issue.key, columns), snapshot.pulls, columns, followUp).status === "Ready")
|
|
43
44
|
.map((issue) => issue.key)
|
|
44
45
|
.sort(compareKeys);
|
|
45
46
|
}
|
|
@@ -177,7 +178,7 @@ export async function tick(d, state) {
|
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
const columns = columnsFrom(d.env);
|
|
180
|
-
const ready = selectToStart(read.snapshot, read.board, columns);
|
|
181
|
+
const ready = selectToStart(read.snapshot, read.board, columns, d.env.FACTORY_FOLLOW_UP_LABEL?.trim() || TICKET_LABELS["follow-up"]);
|
|
181
182
|
// This pass's own start comments are not in what it read, so it adds them.
|
|
182
183
|
const fired = recentStarts(read.snapshot.issues, d.now());
|
|
183
184
|
if (d.now() - state.lastHeartbeat >= HOUR) {
|
|
@@ -231,7 +232,11 @@ export async function tick(d, state) {
|
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
export function onceSettings(s) {
|
|
234
|
-
return {
|
|
235
|
+
return {
|
|
236
|
+
board: s.tickets.board,
|
|
237
|
+
ready: columnsOf(s).Ready?.[0] ?? null,
|
|
238
|
+
followUp: s.tickets.labels["follow-up"],
|
|
239
|
+
};
|
|
235
240
|
}
|
|
236
241
|
/** One pass, for a scheduled run: the board and the Ready column come from
|
|
237
242
|
* the settings, the board's owner is the repository's, and only the token
|
|
@@ -250,6 +255,7 @@ export async function once(s, d) {
|
|
|
250
255
|
FACTORY_BOARD_OWNER: d.repository.split("/")[0],
|
|
251
256
|
FACTORY_BOARD_NUMBER: String(s.board),
|
|
252
257
|
FACTORY_READY_COLUMN: s.ready,
|
|
258
|
+
FACTORY_FOLLOW_UP_LABEL: s.followUp,
|
|
253
259
|
};
|
|
254
260
|
const state = { failuresInARow: 0, lastHeartbeat: d.now() };
|
|
255
261
|
await tick({ ...d, env }, state);
|
package/dist/pr.d.mts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { type Check } from "./pr-watch.mts";
|
|
3
3
|
import { type CodeHost, type Pull, type PullComment, type Review, type Thread } from "./code-host/index.mts";
|
|
4
4
|
import { type Run, type Runner } from "./runner/index.mts";
|
|
5
|
+
import { type Labels } from "./labels.mts";
|
|
5
6
|
import type { Tickets } from "./tickets/types.mts";
|
|
6
7
|
import { type CostDeps } from "./ticket.mts";
|
|
7
8
|
export type Deps = {
|
|
@@ -25,6 +26,9 @@ export type Deps = {
|
|
|
25
26
|
}>;
|
|
26
27
|
/** The session's cost clock, for `cost`. */
|
|
27
28
|
cost?: CostDeps;
|
|
29
|
+
/** The name of each label the factory puts on pull requests, for
|
|
30
|
+
* `label`; the defaults without it. */
|
|
31
|
+
labels?: () => Promise<Labels["codeHost"]>;
|
|
28
32
|
};
|
|
29
33
|
/** The tickets a pull request builds, as the factory counts them. */
|
|
30
34
|
export declare function pullTickets(d: Deps, pr: number): Promise<{
|
package/dist/pr.mjs
CHANGED
|
@@ -36,6 +36,7 @@ import { toChecks } from "./pr-watch.mjs";
|
|
|
36
36
|
import { openCodeHost, } from "./code-host/index.mjs";
|
|
37
37
|
import { openRunner } from "./runner/index.mjs";
|
|
38
38
|
import { refuseBareTags, refuseOverride } from "./guard-ticket-text.mjs";
|
|
39
|
+
import { labelOf, PR_LABELS } from "./labels.mjs";
|
|
39
40
|
import { takeCost } from "./ticket.mjs";
|
|
40
41
|
/** The tickets a pull request builds, as the factory counts them. */
|
|
41
42
|
export async function pullTickets(d, pr) {
|
|
@@ -499,12 +500,13 @@ export async function main(argv, d) {
|
|
|
499
500
|
pr <= 0 ||
|
|
500
501
|
(add === undefined) === (remove === undefined))
|
|
501
502
|
throw new Error(USAGE);
|
|
503
|
+
const names = d.labels ? await d.labels() : PR_LABELS;
|
|
502
504
|
if (add !== undefined) {
|
|
503
|
-
refuseOverride(add);
|
|
504
|
-
await p.addLabel(pr, add);
|
|
505
|
+
refuseOverride(add, names["verdict-override"]);
|
|
506
|
+
await p.addLabel(pr, labelOf(names, add));
|
|
505
507
|
}
|
|
506
508
|
else
|
|
507
|
-
await p.removeLabel(pr, remove);
|
|
509
|
+
await p.removeLabel(pr, labelOf(names, remove));
|
|
508
510
|
d.out(add !== undefined ? "added" : "removed");
|
|
509
511
|
return 0;
|
|
510
512
|
}
|
|
@@ -665,6 +667,7 @@ export function prDeps(repository, codeHost, runner) {
|
|
|
665
667
|
});
|
|
666
668
|
return { tickets, own: ownLinks(settings) };
|
|
667
669
|
},
|
|
670
|
+
labels: async () => (await loadSettings()).codeHost.labels,
|
|
668
671
|
cost: {
|
|
669
672
|
env: process.env,
|
|
670
673
|
now: () => new Date(),
|
package/dist/remove.mjs
CHANGED
|
@@ -9,17 +9,10 @@ import { parseSettings, repoRoot, SETTINGS_FILE, } from "./config.mjs";
|
|
|
9
9
|
import { hasCommand, noTerminal } from "./lib/has-command.mjs";
|
|
10
10
|
import { listed } from "./lib/listed.mjs";
|
|
11
11
|
import { SIGNING_KEY } from "./parts.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { DEFAULT_LABELS } from "./labels.mjs";
|
|
13
13
|
import { LOCK, PACKAGE } from "./sync.mjs";
|
|
14
14
|
import { CHOICES_FILE } from "./preset.mjs";
|
|
15
15
|
import { builtOf, inUse, TOOLS } from "./tools.mjs";
|
|
16
|
-
const LABELS = [
|
|
17
|
-
"merge: automatic",
|
|
18
|
-
"merge: manual",
|
|
19
|
-
OVERRIDE,
|
|
20
|
-
"follow-up",
|
|
21
|
-
"spec",
|
|
22
|
-
];
|
|
23
16
|
/** The agents and skills the lock lists that presets shipped, a skill as
|
|
24
17
|
* its folder, and the packages of the presets it records. */
|
|
25
18
|
async function presetParts(root) {
|
|
@@ -49,6 +42,20 @@ async function presetParts(root) {
|
|
|
49
42
|
packages: [...new Set(lock.presets.map((p) => splitName(p.name).pkg))],
|
|
50
43
|
};
|
|
51
44
|
}
|
|
45
|
+
/** The labels the factory adds, by the names the settings give them: the
|
|
46
|
+
* pull request labels, then the ticket labels. */
|
|
47
|
+
function labelsOf(settings) {
|
|
48
|
+
const { codeHost, tickets } = settings
|
|
49
|
+
? { codeHost: settings.codeHost.labels, tickets: settings.tickets.labels }
|
|
50
|
+
: DEFAULT_LABELS;
|
|
51
|
+
return [
|
|
52
|
+
codeHost["merge-automatic"],
|
|
53
|
+
codeHost["merge-manual"],
|
|
54
|
+
codeHost["verdict-override"],
|
|
55
|
+
tickets["follow-up"],
|
|
56
|
+
tickets.spec,
|
|
57
|
+
];
|
|
58
|
+
}
|
|
52
59
|
/** The factory's own files and folders, each a path from the root. */
|
|
53
60
|
function factoryFiles(root) {
|
|
54
61
|
const named = (dir, match) => existsSync(join(root, dir))
|
|
@@ -151,7 +158,7 @@ export async function main(_argv, d) {
|
|
|
151
158
|
...(secrets === null || secrets.includes(SIGNING_KEY)
|
|
152
159
|
? [`Delete the secret ${SIGNING_KEY}${secrets === null ? " if set" : ""}`]
|
|
153
160
|
: []),
|
|
154
|
-
`Delete whichever of the labels ${listed(
|
|
161
|
+
`Delete whichever of the labels ${listed(labelsOf(settings))} exist, if you do not want their history: deleting one takes it off every ticket`,
|
|
155
162
|
`Run npm uninstall ${d.packageName}`,
|
|
156
163
|
...shipped.packages.map((p) => `Run npm uninstall ${p}`),
|
|
157
164
|
"Commit this on a branch, open a pull request, and merge it",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import type { CodeHost } from "./code-host/types.mts";
|
|
3
3
|
export declare const CONTEXT = "Review verdict";
|
|
4
|
-
|
|
4
|
+
/** The override's name when the settings give it no other. */
|
|
5
|
+
export declare const OVERRIDE: "verdict-override";
|
|
5
6
|
export type Verdict = "ready" | "changes" | null;
|
|
6
7
|
export type Input = {
|
|
7
8
|
event: "workflow_run" | "pull_request_target";
|
|
@@ -9,6 +10,8 @@ export type Input = {
|
|
|
9
10
|
action?: string;
|
|
10
11
|
/** The label added or removed, on a labeled or unlabeled action. */
|
|
11
12
|
label?: string;
|
|
13
|
+
/** The override's name, as `code-host.labels` gives it. */
|
|
14
|
+
override?: string;
|
|
12
15
|
isDependabot: boolean;
|
|
13
16
|
isDraft: boolean;
|
|
14
17
|
/** The override label is on the pull request. A push removes it, so it
|
|
@@ -63,6 +66,8 @@ export declare function apply(o: {
|
|
|
63
66
|
/** The page of the run posting the status. */
|
|
64
67
|
link?: string;
|
|
65
68
|
log: (line: string) => void;
|
|
69
|
+
/** The override's name, as `code-host.labels` gives it. */
|
|
70
|
+
override?: string;
|
|
66
71
|
}): Promise<void>;
|
|
67
72
|
/** `factory review verdict`. */
|
|
68
73
|
export declare function run(): Promise<number>;
|
package/dist/review-verdict.mjs
CHANGED
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
//
|
|
6
6
|
// Runs from main's copy, on two events: the Claude review finishing
|
|
7
7
|
// (workflow_run), and the pull request itself (pull_request_target: opened,
|
|
8
|
-
// pushed to, marked ready, or labeled
|
|
8
|
+
// pushed to, marked ready, or labeled with the override). The verdict is posted
|
|
9
9
|
// on one commit, so a new push always starts without one.
|
|
10
|
+
import { loadSettings } from "./config.mjs";
|
|
11
|
+
import { PR_LABELS } from "./labels.mjs";
|
|
10
12
|
import { readFileSync } from "node:fs";
|
|
11
13
|
import { openCodeHost } from "./code-host/index.mjs";
|
|
12
14
|
import { openRunner } from "./runner/index.mjs";
|
|
13
15
|
// The status's name, which the main ruleset requires by exactly this text.
|
|
14
16
|
export const CONTEXT = "Review verdict";
|
|
15
|
-
|
|
17
|
+
/** The override's name when the settings give it no other. */
|
|
18
|
+
export const OVERRIDE = PR_LABELS["verdict-override"];
|
|
16
19
|
const WAITING = {
|
|
17
20
|
state: "pending",
|
|
18
21
|
description: "Waiting for the review of this commit",
|
|
@@ -62,7 +65,7 @@ export function decide(input) {
|
|
|
62
65
|
}
|
|
63
66
|
switch (input.action) {
|
|
64
67
|
case "labeled":
|
|
65
|
-
if (input.label !== OVERRIDE)
|
|
68
|
+
if (input.label !== (input.override ?? OVERRIDE))
|
|
66
69
|
return null;
|
|
67
70
|
if (!input.senderIsApprover) {
|
|
68
71
|
return {
|
|
@@ -75,7 +78,7 @@ export function decide(input) {
|
|
|
75
78
|
}
|
|
76
79
|
return { ...OVERRIDDEN, announceOverride: true };
|
|
77
80
|
case "unlabeled":
|
|
78
|
-
return input.label === OVERRIDE
|
|
81
|
+
return input.label === (input.override ?? OVERRIDE)
|
|
79
82
|
? fromVerdict(input.verdict, WAITING)
|
|
80
83
|
: null;
|
|
81
84
|
case "synchronize":
|
|
@@ -120,6 +123,7 @@ export function verdictIn(comments, sha) {
|
|
|
120
123
|
* rejects with the reason. */
|
|
121
124
|
export async function apply(o) {
|
|
122
125
|
const { eventName, event, pulls, log } = o;
|
|
126
|
+
const override = o.override ?? OVERRIDE;
|
|
123
127
|
// Read the pull request as it is now. The event's copy can be stale: a
|
|
124
128
|
// "marked ready" event sent just after a push carries the previous commit.
|
|
125
129
|
let number;
|
|
@@ -143,7 +147,7 @@ export async function apply(o) {
|
|
|
143
147
|
}
|
|
144
148
|
let senderIsApprover;
|
|
145
149
|
let lookupFailure;
|
|
146
|
-
if (event.action === "labeled" && event.label?.name ===
|
|
150
|
+
if (event.action === "labeled" && event.label?.name === override)
|
|
147
151
|
try {
|
|
148
152
|
senderIsApprover = await pulls.canWrite(event.sender.login);
|
|
149
153
|
}
|
|
@@ -155,9 +159,10 @@ export async function apply(o) {
|
|
|
155
159
|
event: eventName,
|
|
156
160
|
action: event.action,
|
|
157
161
|
label: event.label?.name,
|
|
162
|
+
override,
|
|
158
163
|
isDependabot: pr.author === "dependabot[bot]",
|
|
159
164
|
isDraft: pr.isDraft,
|
|
160
|
-
hasOverride: labels.includes(
|
|
165
|
+
hasOverride: labels.includes(override),
|
|
161
166
|
senderIsApprover,
|
|
162
167
|
senderUnchecked: lookupFailure !== undefined,
|
|
163
168
|
runConclusion: event.workflow_run?.conclusion,
|
|
@@ -173,12 +178,12 @@ export async function apply(o) {
|
|
|
173
178
|
});
|
|
174
179
|
log(`${CONTEXT} on ${sha}: ${decision.state}, ${decision.description}`);
|
|
175
180
|
if (decision.removeOverride)
|
|
176
|
-
await pulls.removeLabel(pr.number,
|
|
181
|
+
await pulls.removeLabel(pr.number, override);
|
|
177
182
|
const who = event.sender?.login;
|
|
178
183
|
if (decision.explainRemoval === "not an approver")
|
|
179
|
-
await pulls.comment(pr.number, `Removed \`${
|
|
184
|
+
await pulls.comment(pr.number, `Removed \`${override}\`: @${who} cannot write to this repository, and only an account that can may pass the verdict.`);
|
|
180
185
|
if (decision.explainRemoval === "could not check") {
|
|
181
|
-
await pulls.comment(pr.number, `Removed \`${
|
|
186
|
+
await pulls.comment(pr.number, `Removed \`${override}\`: could not check whether @${who} can write to this repository. Add the label again to retry.`);
|
|
182
187
|
throw lookupFailure;
|
|
183
188
|
}
|
|
184
189
|
if (decision.announceOverride) {
|
|
@@ -199,6 +204,7 @@ export async function run() {
|
|
|
199
204
|
pulls: openCodeHost(repo),
|
|
200
205
|
link: openRunner(repo).thisRun(process.env)?.page,
|
|
201
206
|
log: (line) => console.log(line),
|
|
207
|
+
override: (await loadSettings()).codeHost.labels["verdict-override"],
|
|
202
208
|
});
|
|
203
209
|
return 0;
|
|
204
210
|
}
|
package/dist/status.d.mts
CHANGED
|
@@ -35,6 +35,8 @@ export declare function toRows(snapshot: RepoSnapshot, board: Board, blockers: M
|
|
|
35
35
|
* worth flagging; null when builds.trigger is manual. */
|
|
36
36
|
watch?: Watch | null;
|
|
37
37
|
columns?: Columns;
|
|
38
|
+
/** The name of the follow-ups ticket's label. */
|
|
39
|
+
followUp?: string;
|
|
38
40
|
/** How the ticket system writes a ticket. */
|
|
39
41
|
ref: (key: Key) => string;
|
|
40
42
|
}): {
|
package/dist/status.mjs
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// The repository and the board come from the factory's settings, whose
|
|
12
12
|
// loader needs dependencies installed; before npm ci the hook prints
|
|
13
13
|
// nothing.
|
|
14
|
+
import { TICKET_LABELS } from "./labels.mjs";
|
|
14
15
|
import { colorOn, painter } from "./lib/color.mjs";
|
|
15
16
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
16
17
|
import { NO_DEPENDENCIES, SettingsError, loadSettings, targetOf, } from "./config.mjs";
|
|
@@ -70,11 +71,12 @@ export function isWatching(body, now) {
|
|
|
70
71
|
export function toRows(snapshot, board, blockers, now, options) {
|
|
71
72
|
const watch = options.watch === undefined ? watchOf("own-server", 5) : options.watch;
|
|
72
73
|
const columns = options.columns ?? DEFAULT_COLUMNS;
|
|
74
|
+
const followUp = options.followUp ?? TICKET_LABELS["follow-up"];
|
|
73
75
|
const rows = [];
|
|
74
76
|
const closed = [];
|
|
75
77
|
const claimed = new Set();
|
|
76
78
|
for (const issue of snapshot.issues) {
|
|
77
|
-
const derived = derive(issue, cardOf(board, issue.key, columns), snapshot.pulls, columns);
|
|
79
|
+
const derived = derive(issue, cardOf(board, issue.key, columns), snapshot.pulls, columns, followUp);
|
|
78
80
|
const pulls = snapshot.pulls.filter((p) => derived.pulls.includes(p.number));
|
|
79
81
|
pulls.forEach((p) => claimed.add(p.number));
|
|
80
82
|
const flags = [];
|
|
@@ -99,7 +101,7 @@ export function toRows(snapshot, board, blockers, now, options) {
|
|
|
99
101
|
for (const pull of snapshot.pulls) {
|
|
100
102
|
if (claimed.has(pull.number))
|
|
101
103
|
continue;
|
|
102
|
-
const followUps = snapshot.issues.filter((i) => i.labels.includes(
|
|
104
|
+
const followUps = snapshot.issues.filter((i) => i.labels.includes(followUp) && pull.partOf.includes(i.key));
|
|
103
105
|
if (pull.closes.length > 0 || followUps.length > 0)
|
|
104
106
|
continue;
|
|
105
107
|
rows.push({
|
|
@@ -396,7 +398,7 @@ async function snapshotLines(source, target, now, hook, style = PLAIN) {
|
|
|
396
398
|
const blockers = new Map();
|
|
397
399
|
for (const issue of snapshot.issues) {
|
|
398
400
|
if (!source.tickets.blockers ||
|
|
399
|
-
derive(issue, cardOf(board, issue.key, target.columns), snapshot.pulls, target.columns).status !== "Ready")
|
|
401
|
+
derive(issue, cardOf(board, issue.key, target.columns), snapshot.pulls, target.columns, target.followUp).status !== "Ready")
|
|
400
402
|
continue;
|
|
401
403
|
const list = await source.tickets.blockers.list(issue.key);
|
|
402
404
|
blockers.set(issue.key, list.filter((b) => b.state === "open").map((b) => b.key));
|
|
@@ -404,6 +406,7 @@ async function snapshotLines(source, target, now, hook, style = PLAIN) {
|
|
|
404
406
|
return formatRows(toRows(snapshot, board, blockers, now, {
|
|
405
407
|
watch: target.watch,
|
|
406
408
|
columns: target.columns,
|
|
409
|
+
followUp: target.followUp,
|
|
407
410
|
ref: (k) => source.tickets.ref(k),
|
|
408
411
|
}), now, !hook, { ...style, links, columns: target.columns });
|
|
409
412
|
}
|
package/dist/sync.d.mts
CHANGED
|
@@ -16,6 +16,10 @@ export declare function withSchedule(text: string, minutes: number, file: string
|
|
|
16
16
|
/** A workflow with the one `branches:` line of its push trigger naming the
|
|
17
17
|
* default branch and nothing else. */
|
|
18
18
|
export declare function withDefaultBranch(text: string, name: string, file: string): string;
|
|
19
|
+
/** The verdict workflow starting on the override by the name the settings
|
|
20
|
+
* give it, written only when it is not the default, in single quotes as
|
|
21
|
+
* GitHub's expressions take text. */
|
|
22
|
+
export declare function withOverride(text: string, name: string, file: string): string;
|
|
19
23
|
/** The build workflow with its run named as the ticket system writes the
|
|
20
24
|
* ticket, such as `Build #12` on GitHub, which `factory build` finds the
|
|
21
25
|
* run by. */
|
package/dist/sync.mjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// the rules' numbers, and the default branch's name in the push triggers.
|
|
15
15
|
// Edit the source in the package, never the copy. A file the lock lists that the package no longer has is
|
|
16
16
|
// deleted. Nothing else is.
|
|
17
|
+
import { PR_LABELS } from "./labels.mjs";
|
|
17
18
|
import { colorOn, painter, plain } from "./lib/color.mjs";
|
|
18
19
|
import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
19
20
|
import { dirname, join, relative, sep } from "node:path";
|
|
@@ -77,6 +78,19 @@ export function withDefaultBranch(text, name, file) {
|
|
|
77
78
|
return text.replace(pattern, (_, lead) => `${lead}[${written}]`);
|
|
78
79
|
}
|
|
79
80
|
const BUILD_WORKFLOW = "workflows/factory-build.yml";
|
|
81
|
+
const VERDICT_WORKFLOW = "workflows/factory-review-verdict.yml";
|
|
82
|
+
/** The verdict workflow starting on the override by the name the settings
|
|
83
|
+
* give it, written only when it is not the default, in single quotes as
|
|
84
|
+
* GitHub's expressions take text. */
|
|
85
|
+
export function withOverride(text, name, file) {
|
|
86
|
+
const fallback = PR_LABELS["verdict-override"];
|
|
87
|
+
if (name === fallback)
|
|
88
|
+
return text;
|
|
89
|
+
const line = `github.event.label.name == '${fallback}'`;
|
|
90
|
+
if (text.split(line).length !== 2)
|
|
91
|
+
throw new Error(`${file}: expected one match for ${line}, to set the override's name`);
|
|
92
|
+
return text.replace(line, () => `github.event.label.name == '${name.replace(/'/g, "''")}'`);
|
|
93
|
+
}
|
|
80
94
|
/** The build workflow with its run named as the ticket system writes the
|
|
81
95
|
* ticket, such as `Build #12` on GitHub, which `factory build` finds the
|
|
82
96
|
* run by. */
|
|
@@ -524,7 +538,9 @@ export async function plan(pkg, root, r, branch) {
|
|
|
524
538
|
? withDefaultBranch(source, branch, from)
|
|
525
539
|
: from === BUILD_WORKFLOW
|
|
526
540
|
? withRunName(source, refOf(s.tickets.type), from)
|
|
527
|
-
:
|
|
541
|
+
: from === VERDICT_WORKFLOW
|
|
542
|
+
? withOverride(source, s.codeHost.labels["verdict-override"], from)
|
|
543
|
+
: source;
|
|
528
544
|
const kind = SESSION_WORKFLOWS[from.replace(/^workflows\//, "")];
|
|
529
545
|
const written = kind && from.startsWith("workflows/")
|
|
530
546
|
? withMinutes(text, s.sessionMinutes[kind], from)
|
package/dist/ticket-fields.d.mts
CHANGED
|
@@ -38,8 +38,10 @@ export declare function split(body: string, mapping: FieldMapping): {
|
|
|
38
38
|
error: string;
|
|
39
39
|
};
|
|
40
40
|
/** A ticket's document: its description with each ticket field's text under
|
|
41
|
-
* its key's heading, before the first later heading the description has.
|
|
42
|
-
|
|
41
|
+
* its key's heading, before the first later heading the description has.
|
|
42
|
+
* `specLabel` is the name of the label that puts a ticket on the spec
|
|
43
|
+
* track. */
|
|
44
|
+
export declare function join(description: string, values: Record<string, string>, mapping: FieldMapping, labels: readonly string[], specLabel?: string): string;
|
|
43
45
|
/** The agent's answer for a factory field no ticket field fits. A token,
|
|
44
46
|
* so a ticket field called "Description" stays usable. */
|
|
45
47
|
export declare const DESCRIPTION = "__description__";
|
package/dist/ticket-fields.mjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// Refinement's factory fields in a ticket's own fields: which heading each
|
|
2
|
+
// key names, and how a ticket's document is split into its description and
|
|
3
|
+
// its ticket fields and joined back, and `init`'s field step, which asks the
|
|
4
|
+
// coding agent where each goes. It names no agent and no ticket system.
|
|
5
|
+
import { TICKET_LABELS } from "./labels.mjs";
|
|
1
6
|
import { listed } from "./lib/listed.mjs";
|
|
2
7
|
/** The factory fields a refined ticket has, in the order its body has them. */
|
|
3
8
|
export const FACTORY_FIELDS = [
|
|
@@ -131,8 +136,10 @@ const ORDER = [
|
|
|
131
136
|
"for-the-builder",
|
|
132
137
|
];
|
|
133
138
|
/** A ticket's document: its description with each ticket field's text under
|
|
134
|
-
* its key's heading, before the first later heading the description has.
|
|
135
|
-
|
|
139
|
+
* its key's heading, before the first later heading the description has.
|
|
140
|
+
* `specLabel` is the name of the label that puts a ticket on the spec
|
|
141
|
+
* track. */
|
|
142
|
+
export function join(description, values, mapping, labels, specLabel = TICKET_LABELS.spec) {
|
|
136
143
|
const order = [
|
|
137
144
|
...Object.keys(mapping).filter((k) => !ORDER.includes(k)),
|
|
138
145
|
...ORDER,
|
|
@@ -141,7 +148,7 @@ export function join(description, values, mapping, labels) {
|
|
|
141
148
|
const shared = pairs.filter(([k]) => SHARED.includes(k)).length === 2 &&
|
|
142
149
|
mapping.spec === mapping["acceptance-criteria"];
|
|
143
150
|
const reads = shared
|
|
144
|
-
? labels.includes(
|
|
151
|
+
? labels.includes(specLabel)
|
|
145
152
|
? "spec"
|
|
146
153
|
: "acceptance-criteria"
|
|
147
154
|
: null;
|
package/dist/ticket.d.mts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Runner } from "./runner/types.mts";
|
|
3
3
|
import { type Settings } from "./config.mts";
|
|
4
4
|
import { type IssueComment, type PullRequest } from "./lib/work-status.mts";
|
|
5
|
+
import { type Labels } from "./labels.mts";
|
|
5
6
|
import { type Clock } from "./lib/clock.mts";
|
|
6
7
|
import type { Measured } from "./lib/usage.mts";
|
|
7
8
|
import { type Key, type Ticket, type TicketComment, type Tickets } from "./tickets/types.mts";
|
|
@@ -64,7 +65,7 @@ export declare function claimOutcome(comments: IssueComment[], mine: string): "c
|
|
|
64
65
|
export declare function withLine(body: string, line: string): string;
|
|
65
66
|
/** A ticket for a reader: title, state, labels, body, and each comment with
|
|
66
67
|
* its ID and author. */
|
|
67
|
-
export declare function formatTicket(t: Ticket, ref: string): string[];
|
|
68
|
+
export declare function formatTicket(t: Ticket, ref: string, names: Labels["tickets"]): string[];
|
|
68
69
|
/** One comment as `view` prints it: a line naming it, then its body. */
|
|
69
70
|
export declare function formatComment(c: TicketComment): string[];
|
|
70
71
|
export declare function main(argv: string[], deps: Deps): Promise<number>;
|