@davidbyoung/software-factory 0.1.4 → 0.1.5
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 +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/code-host/github-setup.mjs +1 -1
- package/dist/config.d.mts +17 -17
- package/dist/config.mjs +59 -59
- package/dist/explain.d.mts +1 -1
- package/dist/explain.mjs +11 -11
- package/dist/init.mjs +3 -3
- package/dist/lib/refined-check.mjs +1 -1
- package/dist/lib/work-status.d.mts +2 -2
- package/dist/lib/work-status.mjs +4 -4
- package/dist/parts.d.mts +1 -1
- package/dist/parts.mjs +2 -2
- package/dist/review-cost.mjs +1 -1
- package/dist/review-tools.mjs +3 -3
- package/dist/sync.mjs +1 -1
- package/docs/cli.md +6 -6
- package/docs/configuration.md +672 -715
- package/docs/design.md +1 -1
- package/docs/developing.md +12 -7
- package/docs/existing-repo.md +1 -1
- package/docs/github/by-hand.md +4 -4
- package/docs/github/reference.md +2 -2
- package/docs/github/setup.md +2 -2
- package/docs/glossary.md +6 -7
- package/docs/limitations.md +1 -1
- package/docs/plugins.md +22 -21
- package/docs/quick-start.md +1 -1
- package/docs/removing.md +1 -1
- package/docs/skills.md +7 -7
- package/docs/updating.md +8 -7
- package/docs/workflow.md +1 -1
- package/package.json +1 -1
- package/rules.md +1 -1
- package/settings.schema.json +8 -8
- package/skills/factory-build/SKILL.md +1 -1
- package/skills/factory-design/SKILL.md +1 -1
- package/skills/factory-refine/SKILL.md +2 -2
- package/workflows/factory-claude-review.yml +1 -1
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ else is optional and comes later.
|
|
|
104
104
|
| Page | For |
|
|
105
105
|
| -------------------------------------------------------------- | ------------------------------------------ |
|
|
106
106
|
| [Adopting it in an existing repository](docs/existing-repo.md) | Not JavaScript, an existing board, a team |
|
|
107
|
-
| [
|
|
107
|
+
| [Plugins](docs/plugins.md) | Putting your own skills and agents to work |
|
|
108
108
|
| [Builds in the cloud](docs/builds.md) | Starting builds from your board |
|
|
109
109
|
| [Updating](docs/updating.md) | Getting a new version |
|
|
110
110
|
| [What it changes, and removing it](docs/removing.md) | Everything it adds, and how to undo it |
|
package/dist/cli.mjs
CHANGED
|
@@ -123,7 +123,7 @@ export const githubCodeHostSetup = {
|
|
|
123
123
|
leftovers: (c) => {
|
|
124
124
|
const lines = [];
|
|
125
125
|
// init only ever adds the rule, so it can outlast the review.
|
|
126
|
-
const sure = c.settings?.
|
|
126
|
+
const sure = c.settings?.prReview != null;
|
|
127
127
|
lines.push(`Delete the "${RULE}" ruleset first${sure ? "" : ", if there is one"}, under Settings, Rules: until then every pull request waits on its "Review verdict" check`);
|
|
128
128
|
const names = ALL_TOKENS.filter((n) => c.secrets === null || c.secrets.includes(n));
|
|
129
129
|
if (names.length)
|
package/dist/config.d.mts
CHANGED
|
@@ -3,12 +3,12 @@ import { type Built } from "./tool-names.mts";
|
|
|
3
3
|
import { type Watch, type Columns, type StateKey } from "./lib/work-status.mts";
|
|
4
4
|
export declare class SettingsError extends Error {
|
|
5
5
|
}
|
|
6
|
-
/** What a
|
|
7
|
-
export declare const
|
|
8
|
-
export type
|
|
6
|
+
/** What a plugin does, in the order `factory plugins` prints them. */
|
|
7
|
+
export declare const ROLES: readonly ["refiner", "mockups", "builder", "reviewer", "prover", "test-reviewer", "resolver"];
|
|
8
|
+
export type Role = (typeof ROLES)[number];
|
|
9
9
|
/** The phases `plugins` is grouped by. */
|
|
10
10
|
export declare const PHASES: readonly ["refine", "build", "test", "conflicts"];
|
|
11
|
-
type
|
|
11
|
+
type RoleShape = {
|
|
12
12
|
phase: (typeof PHASES)[number];
|
|
13
13
|
key: string;
|
|
14
14
|
kind: Plugin["kind"];
|
|
@@ -16,10 +16,10 @@ type SlotShape = {
|
|
|
16
16
|
files: "required" | "optional" | "none";
|
|
17
17
|
labels: "required" | "none";
|
|
18
18
|
};
|
|
19
|
-
/** Each
|
|
20
|
-
* takes, whether it holds one
|
|
19
|
+
/** Each role: the phase and key it is written under, the one kind it
|
|
20
|
+
* takes, whether it holds one plugin or a list, and whether a plugin in
|
|
21
21
|
* it must have, may have, or cannot have `files` and `labels`. */
|
|
22
|
-
export declare const
|
|
22
|
+
export declare const ROLE_SHAPE: Record<Role, RoleShape>;
|
|
23
23
|
export declare const TRIGGERS: readonly ["own-server", "github-action", "manual"];
|
|
24
24
|
/** How often the scheduled poller may check the board, in minutes: each
|
|
25
25
|
* divides an hour, so a schedule every N minutes keeps an even beat. */
|
|
@@ -34,7 +34,7 @@ export type FieldKey = keyof typeof FIELD_DEFAULTS;
|
|
|
34
34
|
export type Plugin = {
|
|
35
35
|
kind: "skill" | "agent";
|
|
36
36
|
name: string;
|
|
37
|
-
|
|
37
|
+
role: Role;
|
|
38
38
|
files: string[];
|
|
39
39
|
labels: string[];
|
|
40
40
|
};
|
|
@@ -86,8 +86,8 @@ export type Settings = {
|
|
|
86
86
|
/** Rebuilds the package manager's lock file after a conflict in it. */
|
|
87
87
|
relock: string;
|
|
88
88
|
};
|
|
89
|
-
/** The
|
|
90
|
-
* the factory's own for each
|
|
89
|
+
/** The plugins the settings name, in the roles' order. `pluginsOf` adds
|
|
90
|
+
* the factory's own for each role left out. */
|
|
91
91
|
plugins: Plugin[];
|
|
92
92
|
/** Whether `plugins.test.reviewers` is written. Written, it is the whole
|
|
93
93
|
* list of test reviewers, even when it is empty. */
|
|
@@ -97,9 +97,9 @@ export type Settings = {
|
|
|
97
97
|
deny: string[];
|
|
98
98
|
commands: string[];
|
|
99
99
|
};
|
|
100
|
-
/** The
|
|
100
|
+
/** The pull request review, on when `pr-review` is written, with the commands it
|
|
101
101
|
* may run as prefixes beside the factory's own; null when it is off. */
|
|
102
|
-
|
|
102
|
+
prReview: {
|
|
103
103
|
commands: string[];
|
|
104
104
|
} | null;
|
|
105
105
|
/** How the factory looks at the repository's website; null when the
|
|
@@ -167,7 +167,7 @@ export declare function repoRoot(from?: string): string;
|
|
|
167
167
|
export declare const SETTINGS_FILE = ".claude/factory.yaml";
|
|
168
168
|
/** The settings with every default filled in. Throws a SettingsError naming
|
|
169
169
|
* the key on anything unsound. `exists` says whether a path from the root
|
|
170
|
-
* exists, for the
|
|
170
|
+
* exists, for the plugins' files. */
|
|
171
171
|
export declare function parseSettings(raw: unknown, exists: (path: string) => boolean, built?: Built): Settings;
|
|
172
172
|
/** One line for each pattern that matches none of `files`: a stale pattern
|
|
173
173
|
* is how a policy rots. */
|
|
@@ -199,15 +199,15 @@ export declare function fieldNamesOf(s: Settings): {
|
|
|
199
199
|
};
|
|
200
200
|
/** The settings of the checkout the command runs in. */
|
|
201
201
|
export declare const loadSettings: (d?: Deps) => Promise<Settings>;
|
|
202
|
-
/** Every
|
|
203
|
-
* own, and the factory's for each
|
|
202
|
+
/** Every plugin the factory will use, in the roles' order: the settings'
|
|
203
|
+
* own, and the factory's for each role they leave out. The refiner and the
|
|
204
204
|
* prover are always there. The factory's test reviewer is there unless the
|
|
205
|
-
* settings write the list. Its design skill is the mockups
|
|
205
|
+
* settings write the list. Its design skill is the mockups plugin of a
|
|
206
206
|
* site that names none, once it is synced. */
|
|
207
207
|
export declare function pluginsOf(s: Settings, exists: (path: string) => boolean): Plugin[];
|
|
208
208
|
export declare function main(argv: string[], d: Deps): Promise<number>;
|
|
209
209
|
/** `factory config get KEY`, `factory config check`, and
|
|
210
|
-
* `factory plugins [
|
|
210
|
+
* `factory plugins [ROLE]`. */
|
|
211
211
|
export declare function run(argv: string[]): Promise<number>;
|
|
212
212
|
/** What a reading needs from the settings. */
|
|
213
213
|
export type Target = {
|
package/dist/config.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// what its functions need, and nothing under src/lib/ loads them.
|
|
5
5
|
//
|
|
6
6
|
// factory config get KEY # e.g. repository, tickets.board
|
|
7
|
-
// factory plugins [
|
|
7
|
+
// factory plugins [ROLE] # kind, name, role, files or labels
|
|
8
8
|
// factory config check # prints nothing when sound
|
|
9
9
|
//
|
|
10
10
|
// A list prints one item per line. A failure names the key and exits 1.
|
|
@@ -19,8 +19,8 @@ import { BUILT, unsupported } from "./tool-names.mjs";
|
|
|
19
19
|
import { DEFAULT_COLUMNS, STATE_KEYS, sameName, watchOf, } from "./lib/work-status.mjs";
|
|
20
20
|
export class SettingsError extends Error {
|
|
21
21
|
}
|
|
22
|
-
/** What a
|
|
23
|
-
export const
|
|
22
|
+
/** What a plugin does, in the order `factory plugins` prints them. */
|
|
23
|
+
export const ROLES = [
|
|
24
24
|
"refiner",
|
|
25
25
|
"mockups",
|
|
26
26
|
"builder",
|
|
@@ -31,7 +31,7 @@ export const SLOTS = [
|
|
|
31
31
|
];
|
|
32
32
|
/** The phases `plugins` is grouped by. */
|
|
33
33
|
export const PHASES = ["refine", "build", "test", "conflicts"];
|
|
34
|
-
/** A
|
|
34
|
+
/** A role's shape: one plugin with no files and no labels, unless `takes`
|
|
35
35
|
* says otherwise. */
|
|
36
36
|
const shapeOf = (phase, key, kind, takes = {}) => ({
|
|
37
37
|
phase,
|
|
@@ -42,10 +42,10 @@ const shapeOf = (phase, key, kind, takes = {}) => ({
|
|
|
42
42
|
labels: "none",
|
|
43
43
|
...takes,
|
|
44
44
|
});
|
|
45
|
-
/** Each
|
|
46
|
-
* takes, whether it holds one
|
|
45
|
+
/** Each role: the phase and key it is written under, the one kind it
|
|
46
|
+
* takes, whether it holds one plugin or a list, and whether a plugin in
|
|
47
47
|
* it must have, may have, or cannot have `files` and `labels`. */
|
|
48
|
-
export const
|
|
48
|
+
export const ROLE_SHAPE = {
|
|
49
49
|
refiner: shapeOf("refine", "refiner", "skill"),
|
|
50
50
|
mockups: shapeOf("refine", "mockups", "skill"),
|
|
51
51
|
builder: shapeOf("build", "builders", "skill", {
|
|
@@ -66,14 +66,14 @@ export const SLOT_SHAPE = {
|
|
|
66
66
|
files: "required",
|
|
67
67
|
}),
|
|
68
68
|
};
|
|
69
|
-
/** A
|
|
70
|
-
const
|
|
71
|
-
/** The keys of each
|
|
69
|
+
/** A role's path in the settings, such as `plugins.build.reviewers`. */
|
|
70
|
+
const rolePath = (role) => `plugins.${ROLE_SHAPE[role].phase}.${ROLE_SHAPE[role].key}`;
|
|
71
|
+
/** The keys of each role's block, by its path in `SETTINGS_KEYS`: a list's
|
|
72
72
|
* items are under the path with `[]` after it. */
|
|
73
|
-
const
|
|
74
|
-
const shape =
|
|
73
|
+
const roleKeys = () => Object.fromEntries(ROLES.map((role) => {
|
|
74
|
+
const shape = ROLE_SHAPE[role];
|
|
75
75
|
return [
|
|
76
|
-
`${
|
|
76
|
+
`${rolePath(role)}${shape.list ? "[]" : ""}`,
|
|
77
77
|
[
|
|
78
78
|
shape.kind,
|
|
79
79
|
...(shape.files === "none" ? [] : ["files"]),
|
|
@@ -133,7 +133,7 @@ export const SETTINGS_KEYS = {
|
|
|
133
133
|
"commands",
|
|
134
134
|
"plugins",
|
|
135
135
|
"auto-merge",
|
|
136
|
-
"
|
|
136
|
+
"pr-review",
|
|
137
137
|
"site",
|
|
138
138
|
"session-minutes",
|
|
139
139
|
"rules",
|
|
@@ -155,7 +155,7 @@ export const SETTINGS_KEYS = {
|
|
|
155
155
|
],
|
|
156
156
|
"commands.coverage": ["run", "report"],
|
|
157
157
|
"auto-merge": ["allow", "deny", "commands"],
|
|
158
|
-
"
|
|
158
|
+
"pr-review": ["commands"],
|
|
159
159
|
site: [
|
|
160
160
|
"start",
|
|
161
161
|
"url",
|
|
@@ -172,9 +172,9 @@ export const SETTINGS_KEYS = {
|
|
|
172
172
|
plugins: PHASES,
|
|
173
173
|
...Object.fromEntries(PHASES.map((phase) => [
|
|
174
174
|
`plugins.${phase}`,
|
|
175
|
-
|
|
175
|
+
ROLES.filter((role) => ROLE_SHAPE[role].phase === phase).map((role) => ROLE_SHAPE[role].key),
|
|
176
176
|
])),
|
|
177
|
-
...
|
|
177
|
+
...roleKeys(),
|
|
178
178
|
"session-minutes": Object.keys(SESSION_MINUTES),
|
|
179
179
|
rules: Object.keys(RULE_NUMBERS),
|
|
180
180
|
};
|
|
@@ -277,11 +277,11 @@ function strings(v, key) {
|
|
|
277
277
|
? item
|
|
278
278
|
: fail(`${key}[${i}]`, "must be text"));
|
|
279
279
|
}
|
|
280
|
-
/** The
|
|
280
|
+
/** The pull request review's commands: each becomes `Bash(COMMAND:*)` in a list
|
|
281
281
|
* that commas separate, so none may hold a comma, a parenthesis, or a
|
|
282
282
|
* quote. */
|
|
283
283
|
function reviewCommands(v) {
|
|
284
|
-
const key = "
|
|
284
|
+
const key = "pr-review.commands";
|
|
285
285
|
return strings(v, key).map((command, i) => /[,()"]/.test(command)
|
|
286
286
|
? fail(`${key}[${i}]`, "must hold no comma, parenthesis, or quote")
|
|
287
287
|
: command);
|
|
@@ -314,13 +314,13 @@ function typed(v, key, extra) {
|
|
|
314
314
|
return { type: v };
|
|
315
315
|
return object(v, key, key, extra);
|
|
316
316
|
}
|
|
317
|
-
/** One
|
|
318
|
-
function plugin(v, key,
|
|
319
|
-
const shape =
|
|
317
|
+
/** One plugin, written at `key` in the role `role`. */
|
|
318
|
+
function plugin(v, key, role) {
|
|
319
|
+
const shape = ROLE_SHAPE[role];
|
|
320
320
|
const other = shape.kind === "skill" ? "agent" : "skill";
|
|
321
321
|
if (isObj(v) && (other in v || !(shape.kind in v)))
|
|
322
322
|
fail(key, shape.kind === "skill" ? "names a skill" : "names an agent");
|
|
323
|
-
const o = object(v, key, `${
|
|
323
|
+
const o = object(v, key, `${rolePath(role)}${shape.list ? "[]" : ""}`);
|
|
324
324
|
const name = o[shape.kind];
|
|
325
325
|
if (typeof name !== "string" || !/^[\w-]+$/.test(name))
|
|
326
326
|
fail(`${key}.${shape.kind}`, "must be a name");
|
|
@@ -333,47 +333,47 @@ function plugin(v, key, slot) {
|
|
|
333
333
|
return {
|
|
334
334
|
kind: shape.kind,
|
|
335
335
|
name: name,
|
|
336
|
-
|
|
336
|
+
role,
|
|
337
337
|
files: listed("files"),
|
|
338
338
|
labels: listed("labels"),
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
|
-
/** The
|
|
341
|
+
/** The plugins `plugins` names, in the roles' order, and whether it
|
|
342
342
|
* writes the list of test reviewers. */
|
|
343
343
|
function pluginsWritten(v) {
|
|
344
344
|
if (Array.isArray(v))
|
|
345
345
|
fail("plugins", `must be grouped by phase: ${PHASES.join(", ")}`);
|
|
346
346
|
const phases = object(v ?? {}, "plugins");
|
|
347
|
-
const
|
|
347
|
+
const roles = Object.fromEntries(PHASES.map((phase) => [
|
|
348
348
|
phase,
|
|
349
349
|
object(phases[phase] ?? {}, `plugins.${phase}`),
|
|
350
350
|
]));
|
|
351
|
-
const at = (
|
|
351
|
+
const at = (role) => roles[ROLE_SHAPE[role].phase][ROLE_SHAPE[role].key];
|
|
352
352
|
return {
|
|
353
|
-
plugins:
|
|
354
|
-
const written = at(
|
|
355
|
-
const key =
|
|
353
|
+
plugins: ROLES.flatMap((role) => {
|
|
354
|
+
const written = at(role);
|
|
355
|
+
const key = rolePath(role);
|
|
356
356
|
if (written === undefined)
|
|
357
357
|
return [];
|
|
358
|
-
if (!
|
|
359
|
-
return [plugin(written, key,
|
|
358
|
+
if (!ROLE_SHAPE[role].list)
|
|
359
|
+
return [plugin(written, key, role)];
|
|
360
360
|
if (!Array.isArray(written))
|
|
361
361
|
return fail(key, "must be a list");
|
|
362
|
-
return written.map((item, i) => plugin(item, `${key}[${i}]`,
|
|
362
|
+
return written.map((item, i) => plugin(item, `${key}[${i}]`, role));
|
|
363
363
|
}),
|
|
364
364
|
testReviewersWritten: at("test-reviewer") !== undefined,
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
|
-
/** Where each of the settings'
|
|
367
|
+
/** Where each of the settings' plugins is written, such as
|
|
368
368
|
* `plugins.build.reviewers[0]`. */
|
|
369
369
|
function pluginPaths(plugins) {
|
|
370
370
|
const seen = new Map();
|
|
371
371
|
return plugins.map((p) => {
|
|
372
|
-
if (!
|
|
373
|
-
return
|
|
374
|
-
const i = seen.get(p.
|
|
375
|
-
seen.set(p.
|
|
376
|
-
return `${
|
|
372
|
+
if (!ROLE_SHAPE[p.role].list)
|
|
373
|
+
return rolePath(p.role);
|
|
374
|
+
const i = seen.get(p.role) ?? 0;
|
|
375
|
+
seen.set(p.role, i + 1);
|
|
376
|
+
return `${rolePath(p.role)}[${i}]`;
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
/** A command written as one line of text, or null when it is not written. */
|
|
@@ -404,7 +404,7 @@ function commandsOf(v) {
|
|
|
404
404
|
}
|
|
405
405
|
/** The settings with every default filled in. Throws a SettingsError naming
|
|
406
406
|
* the key on anything unsound. `exists` says whether a path from the root
|
|
407
|
-
* exists, for the
|
|
407
|
+
* exists, for the plugins' files. */
|
|
408
408
|
export function parseSettings(raw, exists, built = BUILT) {
|
|
409
409
|
const written = raw ?? {};
|
|
410
410
|
// The version comes before any other key, so a file in the older shape is
|
|
@@ -488,9 +488,9 @@ export function parseSettings(raw, exists, built = BUILT) {
|
|
|
488
488
|
? (command(specsBlock.check, "specs.check") ?? OPENSPEC_CHECK)
|
|
489
489
|
: null;
|
|
490
490
|
const autoMerge = object(top["auto-merge"], "auto-merge");
|
|
491
|
-
const
|
|
491
|
+
const prReview = top["pr-review"] === undefined
|
|
492
492
|
? null
|
|
493
|
-
: object(top["
|
|
493
|
+
: object(top["pr-review"] ?? {}, "pr-review");
|
|
494
494
|
const site = parseSite(top.site, exists);
|
|
495
495
|
const commands = commandsOf(top.commands);
|
|
496
496
|
const { plugins, testReviewersWritten } = pluginsWritten(top.plugins);
|
|
@@ -531,7 +531,7 @@ export function parseSettings(raw, exists, built = BUILT) {
|
|
|
531
531
|
deny: strings(autoMerge.deny, "auto-merge.deny"),
|
|
532
532
|
commands: strings(autoMerge.commands, "auto-merge.commands"),
|
|
533
533
|
},
|
|
534
|
-
|
|
534
|
+
prReview: prReview && { commands: reviewCommands(prReview.commands) },
|
|
535
535
|
site,
|
|
536
536
|
sessionMinutes: sessionMinutesOf(top["session-minutes"]),
|
|
537
537
|
rules: rulesOf(top.rules),
|
|
@@ -647,7 +647,7 @@ function lookup(s, key) {
|
|
|
647
647
|
"test-one": "testOne",
|
|
648
648
|
"end-to-end": "endToEnd",
|
|
649
649
|
"auto-merge": "autoMerge",
|
|
650
|
-
"
|
|
650
|
+
"pr-review": "prReview",
|
|
651
651
|
"code-host": "codeHost",
|
|
652
652
|
"design-guide": "designGuide",
|
|
653
653
|
"max-pages": "maxPages",
|
|
@@ -665,16 +665,16 @@ function lookup(s, key) {
|
|
|
665
665
|
/** The factory's design skill, which `factory sync` writes where there is a
|
|
666
666
|
* site. */
|
|
667
667
|
const DESIGN_SKILL = ".claude/skills/factory-design/SKILL.md";
|
|
668
|
-
/** Every
|
|
669
|
-
* own, and the factory's for each
|
|
668
|
+
/** Every plugin the factory will use, in the roles' order: the settings'
|
|
669
|
+
* own, and the factory's for each role they leave out. The refiner and the
|
|
670
670
|
* prover are always there. The factory's test reviewer is there unless the
|
|
671
|
-
* settings write the list. Its design skill is the mockups
|
|
671
|
+
* settings write the list. Its design skill is the mockups plugin of a
|
|
672
672
|
* site that names none, once it is synced. */
|
|
673
673
|
export function pluginsOf(s, exists) {
|
|
674
|
-
const builtIn = (kind, name,
|
|
674
|
+
const builtIn = (kind, name, role) => ({
|
|
675
675
|
kind,
|
|
676
676
|
name,
|
|
677
|
-
|
|
677
|
+
role,
|
|
678
678
|
files: [],
|
|
679
679
|
labels: [],
|
|
680
680
|
});
|
|
@@ -691,15 +691,15 @@ export function pluginsOf(s, exists) {
|
|
|
691
691
|
: [builtIn("agent", "factory-test-reviewer", "test-reviewer")],
|
|
692
692
|
resolver: [],
|
|
693
693
|
};
|
|
694
|
-
return
|
|
695
|
-
const own = s.plugins.filter((p) => p.
|
|
696
|
-
return own.length ? own : fallback[
|
|
694
|
+
return ROLES.flatMap((role) => {
|
|
695
|
+
const own = s.plugins.filter((p) => p.role === role);
|
|
696
|
+
return own.length ? own : fallback[role];
|
|
697
697
|
});
|
|
698
698
|
}
|
|
699
699
|
export async function main(argv, d) {
|
|
700
700
|
const [command, arg] = argv;
|
|
701
701
|
if (!command) {
|
|
702
|
-
d.err("Usage: factory config get KEY | config check | config explain | plugins [
|
|
702
|
+
d.err("Usage: factory config get KEY | config check | config explain | plugins [ROLE]");
|
|
703
703
|
return 2;
|
|
704
704
|
}
|
|
705
705
|
let s;
|
|
@@ -721,7 +721,7 @@ export async function main(argv, d) {
|
|
|
721
721
|
}
|
|
722
722
|
for (const w of patternWarnings(s, d.listFiles()))
|
|
723
723
|
d.err(`warning: ${w}`);
|
|
724
|
-
if (s.site && !s.plugins.some((p) => p.
|
|
724
|
+
if (s.site && !s.plugins.some((p) => p.role === "mockups"))
|
|
725
725
|
if (!d.exists(DESIGN_SKILL))
|
|
726
726
|
d.err(`warning: ${DESIGN_SKILL} is missing: run \`npx --no-install factory sync\` to give the site its design skill`);
|
|
727
727
|
return 0;
|
|
@@ -733,14 +733,14 @@ export async function main(argv, d) {
|
|
|
733
733
|
return 0;
|
|
734
734
|
}
|
|
735
735
|
if (command === "plugins") {
|
|
736
|
-
if (arg && !
|
|
737
|
-
d.err(`${arg}: must be one of ${
|
|
736
|
+
if (arg && !ROLES.includes(arg)) {
|
|
737
|
+
d.err(`${arg}: must be one of ${ROLES.join(", ")}`);
|
|
738
738
|
return 1;
|
|
739
739
|
}
|
|
740
740
|
for (const p of pluginsOf(s, d.exists)) {
|
|
741
|
-
if (arg && p.
|
|
741
|
+
if (arg && p.role !== arg)
|
|
742
742
|
continue;
|
|
743
|
-
d.out([p.kind, p.name, p.
|
|
743
|
+
d.out([p.kind, p.name, p.role, ...p.files, ...p.labels].join(" "));
|
|
744
744
|
}
|
|
745
745
|
return 0;
|
|
746
746
|
}
|
|
@@ -767,7 +767,7 @@ export async function main(argv, d) {
|
|
|
767
767
|
return 0;
|
|
768
768
|
}
|
|
769
769
|
/** `factory config get KEY`, `factory config check`, and
|
|
770
|
-
* `factory plugins [
|
|
770
|
+
* `factory plugins [ROLE]`. */
|
|
771
771
|
export async function run(argv) {
|
|
772
772
|
return main(argv, defaultDeps());
|
|
773
773
|
}
|
package/dist/explain.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type Settings } from "./config.mts";
|
|
2
|
-
/** `exists` says whether a path from the root exists, for the
|
|
2
|
+
/** `exists` says whether a path from the root exists, for the plugins the
|
|
3
3
|
* factory uses where the settings name none. */
|
|
4
4
|
export declare function explainLines(s: Settings, raw: unknown, exists: (path: string) => boolean): Promise<string[]>;
|
package/dist/explain.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `factory config explain`: the settings as `.claude/factory.yaml` would
|
|
2
2
|
// read with every default written out, each line the file does not set
|
|
3
3
|
// marked `# default`, so any line can be copied into the file.
|
|
4
|
-
import { PHASES, pluginsOf,
|
|
4
|
+
import { PHASES, pluginsOf, ROLE_SHAPE, ROLES, } from "./config.mjs";
|
|
5
5
|
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
6
6
|
/** Whether the file sets `path`, each step a key into the raw file. A
|
|
7
7
|
* block written as one word, such as `code-host: github`, sets its `type`. */
|
|
@@ -16,7 +16,7 @@ function sets(raw, path) {
|
|
|
16
16
|
}
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
|
-
/** `exists` says whether a path from the root exists, for the
|
|
19
|
+
/** `exists` says whether a path from the root exists, for the plugins the
|
|
20
20
|
* factory uses where the settings name none. */
|
|
21
21
|
export async function explainLines(s, raw, exists) {
|
|
22
22
|
const { stringify } = await import("yaml");
|
|
@@ -92,16 +92,16 @@ export async function explainLines(s, raw, exists) {
|
|
|
92
92
|
put(["commands", "coverage", "report"], s.commands.coverage.report);
|
|
93
93
|
}
|
|
94
94
|
put(["commands", "relock"], s.commands.relock);
|
|
95
|
-
// Each
|
|
96
|
-
// own
|
|
95
|
+
// Each role holds what `factory plugins` prints for it: the settings'
|
|
96
|
+
// own plugins, or the factory's where they name none.
|
|
97
97
|
const used = pluginsOf(s, exists);
|
|
98
98
|
block(["plugins"]);
|
|
99
99
|
for (const phase of PHASES) {
|
|
100
100
|
block(["plugins", phase]);
|
|
101
|
-
for (const
|
|
102
|
-
const { key, list } =
|
|
101
|
+
for (const role of ROLES.filter((x) => ROLE_SHAPE[x].phase === phase)) {
|
|
102
|
+
const { key, list } = ROLE_SHAPE[role];
|
|
103
103
|
const path = ["plugins", phase, key];
|
|
104
|
-
const found = used.filter((p) => p.
|
|
104
|
+
const found = used.filter((p) => p.role === role);
|
|
105
105
|
if (!found.length) {
|
|
106
106
|
if (list)
|
|
107
107
|
put(path, []);
|
|
@@ -131,11 +131,11 @@ export async function explainLines(s, raw, exists) {
|
|
|
131
131
|
put(["auto-merge", "allow"], s.autoMerge.allow);
|
|
132
132
|
put(["auto-merge", "deny"], s.autoMerge.deny);
|
|
133
133
|
put(["auto-merge", "commands"], s.autoMerge.commands);
|
|
134
|
-
if (s.
|
|
135
|
-
comment(0, "
|
|
134
|
+
if (s.prReview === null)
|
|
135
|
+
comment(0, "pr-review: off");
|
|
136
136
|
else {
|
|
137
|
-
block(["
|
|
138
|
-
put(["
|
|
137
|
+
block(["pr-review"]);
|
|
138
|
+
put(["pr-review", "commands"], s.prReview.commands);
|
|
139
139
|
}
|
|
140
140
|
if (s.site === null)
|
|
141
141
|
comment(0, "site: off");
|
package/dist/init.mjs
CHANGED
|
@@ -277,10 +277,10 @@ export async function main(_argv, d) {
|
|
|
277
277
|
remove(doc, ["auto-merge", "allow"]);
|
|
278
278
|
// The review is on while its setting is written; the sync writes its
|
|
279
279
|
// workflow then, and removes it once the setting is gone.
|
|
280
|
-
if (parts.has("review") && !doc.has("
|
|
281
|
-
doc.setIn(["
|
|
280
|
+
if (parts.has("review") && !doc.has("pr-review"))
|
|
281
|
+
doc.setIn(["pr-review", "commands"], []);
|
|
282
282
|
if (!parts.has("review"))
|
|
283
|
-
doc.delete("
|
|
283
|
+
doc.delete("pr-review");
|
|
284
284
|
// The ticket system's own values: asked for once, and taken out with
|
|
285
285
|
// the part that needed them.
|
|
286
286
|
const values = (ps) => (d.tools.tickets[chosen.tickets].setup.steps?.(context(ps)) ?? []).filter((s) => s.kind === "value");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Whether a refined ticket's body is one a build can read: the check
|
|
2
2
|
// `factory ticket refined` makes before it posts the marker, for the
|
|
3
|
-
// factory's own refiner as for a
|
|
3
|
+
// factory's own refiner as for a plugin's. It reads headings only, never
|
|
4
4
|
// what a section says.
|
|
5
5
|
const SPEC_LABEL = "spec";
|
|
6
6
|
const FOLLOW_UP_LABEL = "follow-up";
|
|
@@ -65,7 +65,7 @@ export type Marked = IssueComment & {
|
|
|
65
65
|
/** The markers in one comment: each on a line of its own, outside a fenced
|
|
66
66
|
* code block, in a comment that also carries the agent mark. */
|
|
67
67
|
export declare function parseMarkers(body: string): Marker[];
|
|
68
|
-
/** The account the
|
|
68
|
+
/** The account the pull request review's summary is posted from. */
|
|
69
69
|
export declare const CI_BOT = "github-actions[bot]";
|
|
70
70
|
/** Whether a body already carries a cost marker, read as `parseCosts` reads
|
|
71
71
|
* one: on a line of its own, outside a fenced code block. A marker quoted in
|
|
@@ -73,7 +73,7 @@ export declare const CI_BOT = "github-actions[bot]";
|
|
|
73
73
|
export declare function hasCostMarker(body: string): boolean;
|
|
74
74
|
/** The cost markers in one comment, read as markers are: each on a line of
|
|
75
75
|
* its own, outside a fenced code block. Only the owner's account, which the
|
|
76
|
-
* agents post as, and the
|
|
76
|
+
* agents post as, and the pull request review's bot count; the owner's comments count
|
|
77
77
|
* only with the agent mark. */
|
|
78
78
|
export declare function parseCosts(comment: IssueComment, owner: string): number[];
|
|
79
79
|
/** Whether a pull request's body says it builds this issue, as "Closes #N"
|
package/dist/lib/work-status.mjs
CHANGED
|
@@ -101,10 +101,10 @@ export function parseMarkers(body) {
|
|
|
101
101
|
}
|
|
102
102
|
return found;
|
|
103
103
|
}
|
|
104
|
-
// Cost markers, which say what a session or a
|
|
104
|
+
// Cost markers, which say what a session or a pull request review spent at API list
|
|
105
105
|
// prices: `<!-- cost: 3.41 session=ID -->` from a session,
|
|
106
|
-
// `<!-- cost: 0.92 -->` from the
|
|
107
|
-
/** The account the
|
|
106
|
+
// `<!-- cost: 0.92 -->` from the pull request review's summary.
|
|
107
|
+
/** The account the pull request review's summary is posted from. */
|
|
108
108
|
export const CI_BOT = "github-actions[bot]";
|
|
109
109
|
const COST_LINE = /^<!-- cost: (\d+(?:\.\d+)?)(?: session=\S+)? -->$/;
|
|
110
110
|
/** Whether a body already carries a cost marker, read as `parseCosts` reads
|
|
@@ -115,7 +115,7 @@ export function hasCostMarker(body) {
|
|
|
115
115
|
}
|
|
116
116
|
/** The cost markers in one comment, read as markers are: each on a line of
|
|
117
117
|
* its own, outside a fenced code block. Only the owner's account, which the
|
|
118
|
-
* agents post as, and the
|
|
118
|
+
* agents post as, and the pull request review's bot count; the owner's comments count
|
|
119
119
|
* only with the agent mark. */
|
|
120
120
|
export function parseCosts(comment, owner) {
|
|
121
121
|
const fromAgent = comment.author === owner && comment.body.includes(AGENT_MARK);
|
package/dist/parts.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const PART_TEXT: Record<Part, {
|
|
|
8
8
|
gives: string;
|
|
9
9
|
}>;
|
|
10
10
|
/** The workflow that runs the automated review, which `factory sync`
|
|
11
|
-
* writes while the settings have `
|
|
11
|
+
* writes while the settings have `pr-review`. */
|
|
12
12
|
export declare const REVIEW_WORKFLOW = ".github/workflows/factory-claude-review.yml";
|
|
13
13
|
export declare const AGENT_TOKEN = "CLAUDE_CODE_OAUTH_TOKEN";
|
|
14
14
|
export declare const AGENT_KEY = "ANTHROPIC_API_KEY";
|
package/dist/parts.mjs
CHANGED
|
@@ -34,7 +34,7 @@ export const PART_TEXT = {
|
|
|
34
34
|
},
|
|
35
35
|
};
|
|
36
36
|
/** The workflow that runs the automated review, which `factory sync`
|
|
37
|
-
* writes while the settings have `
|
|
37
|
+
* writes while the settings have `pr-review`. */
|
|
38
38
|
export const REVIEW_WORKFLOW = ".github/workflows/factory-claude-review.yml";
|
|
39
39
|
export const AGENT_TOKEN = "CLAUDE_CODE_OAUTH_TOKEN";
|
|
40
40
|
export const AGENT_KEY = "ANTHROPIC_API_KEY";
|
|
@@ -48,7 +48,7 @@ export const SIGNING_KEY = "FACTORY_SIGNING_KEY";
|
|
|
48
48
|
export function partsOn(s, secrets, cloudNeeds) {
|
|
49
49
|
const has = (names) => names.some((n) => secrets.includes(n));
|
|
50
50
|
const on = new Set();
|
|
51
|
-
if (s?.
|
|
51
|
+
if (s?.prReview)
|
|
52
52
|
on.add("review");
|
|
53
53
|
if (s?.tickets.board != null)
|
|
54
54
|
on.add("board");
|
package/dist/review-cost.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Adds what the
|
|
2
|
+
// Adds what the pull request review cost to its summary comment, after the review
|
|
3
3
|
// step of .github/workflows/factory-claude-review.yml:
|
|
4
4
|
//
|
|
5
5
|
// Review cost: $0.03 of the subscription ($0.92 at API list prices).
|
package/dist/review-tools.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Prints the tools the
|
|
1
|
+
// Prints the tools the pull request review may use, as the one comma-separated value
|
|
2
2
|
// the review step passes to `--allowedTools`: the factory's own, then a
|
|
3
|
-
// `Bash(COMMAND:*)` for each of the settings' `
|
|
3
|
+
// `Bash(COMMAND:*)` for each of the settings' `pr-review.commands`.
|
|
4
4
|
//
|
|
5
5
|
// FACTORY_SETTINGS=base-settings.yaml npx --no-install factory review tools
|
|
6
6
|
//
|
|
@@ -34,7 +34,7 @@ export function allowedTools(commands) {
|
|
|
34
34
|
export async function run() {
|
|
35
35
|
try {
|
|
36
36
|
const s = await loadSettings();
|
|
37
|
-
console.log(allowedTools(s.
|
|
37
|
+
console.log(allowedTools(s.prReview?.commands ?? []));
|
|
38
38
|
return 0;
|
|
39
39
|
}
|
|
40
40
|
catch (e) {
|
package/dist/sync.mjs
CHANGED
|
@@ -39,7 +39,7 @@ const NEEDS = {
|
|
|
39
39
|
"workflows/factory-deps-auto-merge.yml": (_, has) => has(DEPENDABOT),
|
|
40
40
|
"workflows/factory-board-sync.yml": (s) => s.tickets.board !== null,
|
|
41
41
|
"workflows/factory-merge-policy.yml": (s) => s.autoMerge.allow.length > 0,
|
|
42
|
-
"workflows/factory-claude-review.yml": (s) => s.
|
|
42
|
+
"workflows/factory-claude-review.yml": (s) => s.prReview !== null,
|
|
43
43
|
"workflows/factory-poller.yml": (s) => s.builds.trigger === "github-action",
|
|
44
44
|
};
|
|
45
45
|
const POLLER_WORKFLOW = "workflows/factory-poller.yml";
|