@davidbyoung/software-factory 0.1.4 → 0.1.6

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.
Files changed (57) hide show
  1. package/README.md +9 -8
  2. package/dist/cli.mjs +13 -1
  3. package/dist/code-host/github-setup.mjs +1 -1
  4. package/dist/config.d.mts +74 -20
  5. package/dist/config.mjs +326 -76
  6. package/dist/deps.d.mts +6 -4
  7. package/dist/deps.mjs +29 -7
  8. package/dist/doctor.d.mts +3 -0
  9. package/dist/doctor.mjs +7 -4
  10. package/dist/explain.d.mts +13 -2
  11. package/dist/explain.mjs +58 -43
  12. package/dist/init.mjs +9 -7
  13. package/dist/lib/default-branch.d.mts +1 -1
  14. package/dist/lib/default-branch.mjs +2 -2
  15. package/dist/lib/refined-check.mjs +1 -1
  16. package/dist/lib/work-status.d.mts +2 -2
  17. package/dist/lib/work-status.mjs +4 -4
  18. package/dist/parts.d.mts +1 -1
  19. package/dist/parts.mjs +2 -2
  20. package/dist/preset-commands.d.mts +65 -0
  21. package/dist/preset-commands.mjs +1148 -0
  22. package/dist/preset.d.mts +169 -0
  23. package/dist/preset.mjs +550 -0
  24. package/dist/remove.mjs +34 -1
  25. package/dist/review-cost.mjs +1 -1
  26. package/dist/review-tools.mjs +3 -3
  27. package/dist/session-start.d.mts +3 -0
  28. package/dist/session-start.mjs +12 -1
  29. package/dist/sync.d.mts +42 -7
  30. package/dist/sync.mjs +166 -32
  31. package/docs/builds.md +12 -11
  32. package/docs/cli.md +27 -8
  33. package/docs/configuration.md +723 -714
  34. package/docs/design.md +1 -1
  35. package/docs/developing.md +20 -8
  36. package/docs/existing-repo.md +1 -1
  37. package/docs/github/by-hand.md +9 -9
  38. package/docs/github/reference.md +4 -19
  39. package/docs/github/setup.md +3 -3
  40. package/docs/glossary.md +18 -9
  41. package/docs/limitations.md +4 -1
  42. package/docs/plugins.md +36 -24
  43. package/docs/presets.md +410 -0
  44. package/docs/quick-start.md +21 -18
  45. package/docs/removing.md +1 -1
  46. package/docs/skills.md +28 -23
  47. package/docs/updating.md +22 -14
  48. package/docs/workflow.md +13 -14
  49. package/package.json +1 -1
  50. package/rules.md +1 -1
  51. package/settings.schema.json +60 -11
  52. package/skills/factory-build/SKILL.md +1 -1
  53. package/skills/factory-deps/SKILL.md +23 -12
  54. package/skills/factory-design/SKILL.md +2 -2
  55. package/skills/factory-refine/SKILL.md +2 -2
  56. package/skills/factory-resolve-conflicts/SKILL.md +6 -0
  57. package/workflows/factory-claude-review.yml +8 -3
package/dist/deps.mjs CHANGED
@@ -18,8 +18,10 @@ export function isMajor(title) {
18
18
  return match !== null && match[1] !== match[2];
19
19
  }
20
20
  /** What the skill does with a bump, in the order its steps take them.
21
- * `branch` is the default branch, which a conflicting bump merges. */
22
- export function nextStep(bump, branch) {
21
+ * `branch` is the default branch, which a conflicting bump merges, and
22
+ * `synced` the packages whose update needs `factory sync`: the factory's
23
+ * own and each preset's. */
24
+ export function nextStep(bump, branch, synced = []) {
23
25
  if (bump.mergeableState === "unknown")
24
26
  return "leave: state not computed yet";
25
27
  if (bump.checks.some((c) => c.status !== "completed"))
@@ -31,6 +33,8 @@ export function nextStep(bump, branch) {
31
33
  steps.push(`merge ${branch} (step 2)`);
32
34
  if (failing(bump).length > 0)
33
35
  steps.push(`fix ${failing(bump).join(", ")} (step 3)`);
36
+ if (synced.some((name) => bump.title.includes(name)))
37
+ steps.push("sync (step 4)");
34
38
  if (bump.major)
35
39
  steps.push("migrate (step 4)");
36
40
  return steps.length > 0 ? steps.join("; ") : "nothing: waits on its merge";
@@ -68,13 +72,13 @@ export function checksLine(bump) {
68
72
  ].filter(Boolean);
69
73
  return `checks: ${parts.join("; ")}`;
70
74
  }
71
- export function formatBump(bump, branch) {
75
+ export function formatBump(bump, branch, synced = []) {
72
76
  return [
73
77
  `#${bump.number} ${bump.title}`,
74
78
  ` ${bump.major ? "major" : "minor or patch"}; head ${bump.head} at ${bump.sha.slice(0, 7)}; mergeable ${bump.mergeableState}; auto-merge ${bump.autoMerge ? "on" : "off"}`,
75
79
  ` ${checksLine(bump)}`,
76
80
  ` earlier shepherd comments: ${bump.shepherdComments}`,
77
- ` next: ${nextStep(bump, branch)}`,
81
+ ` next: ${nextStep(bump, branch, synced)}`,
78
82
  ];
79
83
  }
80
84
  async function readBump(p, number) {
@@ -98,7 +102,7 @@ async function readBump(p, number) {
98
102
  }
99
103
  /** `defaultBranch` gives the default branch's name, and rejects when it
100
104
  * cannot be told. It is asked only when a pull request is listed. */
101
- export async function main(p, out, argv, defaultBranch) {
105
+ export async function main(p, out, argv, defaultBranch, synced = []) {
102
106
  try {
103
107
  const pulls = (await p.listOpen())
104
108
  .filter((pull) => pull.author === "dependabot[bot]")
@@ -115,7 +119,7 @@ export async function main(p, out, argv, defaultBranch) {
115
119
  }
116
120
  const branch = await defaultBranch();
117
121
  for (const pull of pulls) {
118
- formatBump(await readBump(p, pull.number), branch).forEach((l) => out(l));
122
+ formatBump(await readBump(p, pull.number), branch, synced).forEach((l) => out(l));
119
123
  }
120
124
  return 0;
121
125
  }
@@ -124,6 +128,24 @@ export async function main(p, out, argv, defaultBranch) {
124
128
  return argv.includes("--any") ? 2 : 1;
125
129
  }
126
130
  }
131
+ /** The factory's package and each preset's the lock records, whose
132
+ * updates each need a sync. */
133
+ async function syncedPackages(root) {
134
+ const { readFileSync } = await import("node:fs");
135
+ const { join } = await import("node:path");
136
+ const { PACKAGE } = await import("./sync.mjs");
137
+ const { readLock, splitName, LOCK_FILE } = await import("./preset.mjs");
138
+ const { load } = await import("js-yaml");
139
+ const own = JSON.parse(readFileSync(join(PACKAGE, "package.json"), "utf8"))
140
+ .name;
141
+ try {
142
+ const lock = readLock(readFileSync(join(root, LOCK_FILE), "utf8"), load);
143
+ return [own, ...new Set(lock.presets.map((p) => splitName(p.name).pkg))];
144
+ }
145
+ catch {
146
+ return [own];
147
+ }
148
+ }
127
149
  /** `factory deps`. */
128
150
  export async function run(argv = []) {
129
151
  const { repository, codeHost } = await reachOf(process.env);
@@ -133,5 +155,5 @@ export async function run(argv = []) {
133
155
  return main(p, (line) => console.log(line), argv, () => needDefaultBranch({
134
156
  ...branchDeps(repoRoot()),
135
157
  host: () => p.defaultBranch(),
136
- }));
158
+ }), await syncedPackages(repoRoot()));
137
159
  }
package/dist/doctor.d.mts CHANGED
@@ -12,6 +12,9 @@ export type DoctorDeps = {
12
12
  installed: string;
13
13
  locked: string | null;
14
14
  };
15
+ /** Whether the lock is current, and each preset it records is installed
16
+ * and has a Dependabot group of its own. */
17
+ lockChecks?: () => Promise<Check[]>;
15
18
  root: string;
16
19
  hasCommand: (name: string) => boolean;
17
20
  tools: Registry;
package/dist/doctor.mjs CHANGED
@@ -6,7 +6,8 @@
6
6
  // being set.
7
7
  import { readFileSync } from "node:fs";
8
8
  import { join } from "node:path";
9
- import { defaultDeps, loadSettings, repoRoot, } from "./config.mjs";
9
+ import { defaultDeps, filesDeps, repoRoot, resolveFiles, staleOf, } from "./config.mjs";
10
+ import { presetChecks } from "./preset-commands.mjs";
10
11
  import { hasCommand } from "./lib/has-command.mjs";
11
12
  import { neededSecrets, PART_TEXT, PARTS, partsOn, } from "./parts.mjs";
12
13
  import { branchDeps, CANNOT_TELL, needDefaultBranch, NoDefaultBranch, } from "./lib/default-branch.mjs";
@@ -72,6 +73,7 @@ export async function checks(d) {
72
73
  text: `Version ${installed} is installed, but the repository records ${locked}`,
73
74
  fix: compareVersions(installed, locked) < 0 ? "Run npm ci" : SYNC,
74
75
  });
76
+ out.push(...((await d.lockChecks?.()) ?? []));
75
77
  const chosen = {
76
78
  codeHost: s.codeHost.type,
77
79
  tickets: s.tickets.type,
@@ -164,10 +166,11 @@ export async function main(_argv, d) {
164
166
  }
165
167
  /** The checks, run in the repository this command runs in. */
166
168
  export function doctorDeps(root = repoRoot()) {
167
- const settings = () => loadSettings(defaultDeps(root));
169
+ const resolved = () => resolveFiles(filesDeps(root));
168
170
  return {
169
- settings,
170
- outOfStep: async (s) => differences(root, plan(PACKAGE, root, s, await needDefaultBranch(branchDeps(root)))),
171
+ settings: async () => (await resolved()).settings,
172
+ outOfStep: async (s) => differences(root, await plan(PACKAGE, root, await resolved(), await needDefaultBranch(branchDeps(root, process.env, async () => s)))),
173
+ lockChecks: async () => presetChecks(root, await staleOf(defaultDeps(root))),
171
174
  versions: () => {
172
175
  const installed = JSON.parse(readFileSync(join(PACKAGE, "package.json"), "utf8")).version;
173
176
  let locked = null;
@@ -1,4 +1,15 @@
1
1
  import { type Settings } from "./config.mts";
2
- /** `exists` says whether a path from the root exists, for the plug-ins the
2
+ import { type Resolution } from "./preset.mts";
3
+ /** The mark of the value at `path`, or of one item of the list there:
4
+ * `item` is the item for a list of values and the plugin's name for a
5
+ * list of plugins. */
6
+ export type Marker = {
7
+ value: (path: string[]) => string | null;
8
+ item: (path: string[], item: unknown) => string | null;
9
+ plugin: (path: string[], name: string) => string | null;
10
+ };
11
+ /** The marks of the values a resolution combined. */
12
+ export declare function markerOf(r: Resolution): Marker;
13
+ /** `exists` says whether a path from the root exists, for the plugins the
3
14
  * factory uses where the settings name none. */
4
- export declare function explainLines(s: Settings, raw: unknown, exists: (path: string) => boolean): Promise<string[]>;
15
+ export declare function explainLines(s: Settings, marks: Marker, exists: (path: string) => boolean): Promise<string[]>;
package/dist/explain.mjs CHANGED
@@ -1,24 +1,37 @@
1
1
  // `factory config explain`: the settings as `.claude/factory.yaml` would
2
- // read with every default written out, each line the file does not set
3
- // marked `# default`, so any line can be copied into the file.
4
- import { PHASES, pluginsOf, SLOT_SHAPE, SLOTS, } from "./config.mjs";
5
- const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
6
- /** Whether the file sets `path`, each step a key into the raw file. A
7
- * block written as one word, such as `code-host: github`, sets its `type`. */
8
- function sets(raw, path) {
9
- let at = raw;
10
- for (const key of path) {
11
- if (typeof at === "string" && key === "type")
12
- return true;
13
- if (!isObj(at) || !(key in at))
14
- return false;
15
- at = at[key];
16
- }
17
- return true;
2
+ // read with every default written out, each line marked with where its
3
+ // value came from: `# default`, a preset's name, or nothing for a value
4
+ // only `.claude/factory.yaml` sets. `factory sync` writes the same lines
5
+ // into the lock.
6
+ import { PHASES, pluginsOf, ROLE_SHAPE, ROLES, } from "./config.mjs";
7
+ import { itemKey, markText } from "./preset.mjs";
8
+ /** The marks of the values a resolution combined. */
9
+ export function markerOf(r) {
10
+ const at = (key) => r.sources.get(key) ?? r.sources.get(`${key}.type`);
11
+ return {
12
+ value: (path) => markText(at(path.join("."))),
13
+ item: (path, item) => {
14
+ const key = path.join(".");
15
+ return markText(r.sources.get(itemKey(key, item)) ?? at(key));
16
+ },
17
+ plugin: (path, name) => markText(r.sources.get(`${path.join(".")}.${name}`)),
18
+ };
18
19
  }
19
- /** `exists` says whether a path from the root exists, for the plug-ins the
20
+ /** The value lists that add up across layers, whose items each carry
21
+ * their own mark. */
22
+ const ADDS_UP = new Set([
23
+ "pr-review.commands",
24
+ "auto-merge.allow",
25
+ "auto-merge.deny",
26
+ "auto-merge.commands",
27
+ "site.pages",
28
+ "site.widths",
29
+ "site.checks",
30
+ "site.hide",
31
+ ]);
32
+ /** `exists` says whether a path from the root exists, for the plugins the
20
33
  * factory uses where the settings name none. */
21
- export async function explainLines(s, raw, exists) {
34
+ export async function explainLines(s, marks, exists) {
22
35
  const { stringify } = await import("yaml");
23
36
  const value = (v) => stringify(v, { lineWidth: 0 }).trim();
24
37
  const lines = [];
@@ -26,20 +39,21 @@ export async function explainLines(s, raw, exists) {
26
39
  /** One key, its value printed under it when it is a list or a block. */
27
40
  const put = (path, v, depth = path.length - 1) => {
28
41
  const key = path.at(-1);
29
- const byDefault = !sets(raw, path);
42
+ const mark = marks.value(path);
30
43
  if (Array.isArray(v) && v.length && typeof v[0] !== "object") {
31
- lines.push({ text: `${pad(depth)}${key}:`, byDefault });
44
+ const each = ADDS_UP.has(path.join("."));
45
+ lines.push({ text: `${pad(depth)}${key}:`, mark });
32
46
  for (const item of v)
33
- lines.push({ text: `${pad(depth + 1)}- ${value(item)}`, byDefault });
47
+ lines.push({
48
+ text: `${pad(depth + 1)}- ${value(item)}`,
49
+ mark: each ? marks.item(path, item) : mark,
50
+ });
34
51
  return;
35
52
  }
36
- lines.push({ text: `${pad(depth)}${key}: ${value(v)}`, byDefault });
53
+ lines.push({ text: `${pad(depth)}${key}: ${value(v)}`, mark });
37
54
  };
38
- const block = (path) => lines.push({
39
- text: `${pad(path.length - 1)}${path.at(-1)}:`,
40
- byDefault: false,
41
- });
42
- const comment = (depth, text) => lines.push({ text: `${pad(depth)}# ${text}`, byDefault: false });
55
+ const block = (path) => lines.push({ text: `${pad(path.length - 1)}${path.at(-1)}:`, mark: null });
56
+ const comment = (depth, text) => lines.push({ text: `${pad(depth)}# ${text}`, mark: null });
43
57
  put(["version"], s.version);
44
58
  put(["repository"], s.repository);
45
59
  block(["tickets"]);
@@ -92,16 +106,16 @@ export async function explainLines(s, raw, exists) {
92
106
  put(["commands", "coverage", "report"], s.commands.coverage.report);
93
107
  }
94
108
  put(["commands", "relock"], s.commands.relock);
95
- // Each slot holds what `factory plugins` prints for it: the settings'
96
- // own plug-ins, or the factory's where they name none.
109
+ // Each role holds what `factory plugins` prints for it: the settings'
110
+ // own plugins, or the factory's where they name none.
97
111
  const used = pluginsOf(s, exists);
98
112
  block(["plugins"]);
99
113
  for (const phase of PHASES) {
100
114
  block(["plugins", phase]);
101
- for (const slot of SLOTS.filter((x) => SLOT_SHAPE[x].phase === phase)) {
102
- const { key, list } = SLOT_SHAPE[slot];
115
+ for (const role of ROLES.filter((x) => ROLE_SHAPE[x].phase === phase)) {
116
+ const { key, list } = ROLE_SHAPE[role];
103
117
  const path = ["plugins", phase, key];
104
- const found = used.filter((p) => p.slot === slot);
118
+ const found = used.filter((p) => p.role === role);
105
119
  if (!found.length) {
106
120
  if (list)
107
121
  put(path, []);
@@ -109,10 +123,11 @@ export async function explainLines(s, raw, exists) {
109
123
  comment(2, `${key}: none (default)`);
110
124
  continue;
111
125
  }
112
- const byDefault = !sets(raw, path);
113
- const add = (depth, text) => lines.push({ text: `${pad(depth)}${text}`, byDefault });
114
- add(2, `${key}:`);
126
+ const roleMark = marks.value(path);
127
+ lines.push({ text: `${pad(2)}${key}:`, mark: roleMark });
115
128
  for (const p of found) {
129
+ const mark = list ? marks.plugin(path, p.name) : marks.value(path);
130
+ const add = (depth, text) => lines.push({ text: `${pad(depth)}${text}`, mark });
116
131
  add(3, `${list ? "- " : ""}${p.kind}: ${value(p.name)}`);
117
132
  const under = list ? 4 : 3;
118
133
  for (const [k, items] of [
@@ -131,11 +146,11 @@ export async function explainLines(s, raw, exists) {
131
146
  put(["auto-merge", "allow"], s.autoMerge.allow);
132
147
  put(["auto-merge", "deny"], s.autoMerge.deny);
133
148
  put(["auto-merge", "commands"], s.autoMerge.commands);
134
- if (s.ciReview === null)
135
- comment(0, "ci-review: off");
149
+ if (s.prReview === null)
150
+ comment(0, "pr-review: off");
136
151
  else {
137
- block(["ci-review"]);
138
- put(["ci-review", "commands"], s.ciReview.commands);
152
+ block(["pr-review"]);
153
+ put(["pr-review", "commands"], s.prReview.commands);
139
154
  }
140
155
  if (s.site === null)
141
156
  comment(0, "site: off");
@@ -166,9 +181,9 @@ export async function explainLines(s, raw, exists) {
166
181
  block(["rules"]);
167
182
  put(["rules", "small-change-lines"], s.rules.smallChangeLines);
168
183
  put(["rules", "review-rounds"], s.rules.reviewRounds);
169
- // Each default's mark lines up with the others, two spaces past the
170
- // longest line that carries one.
171
- const marked = lines.filter((l) => l.byDefault);
184
+ // Each mark lines up with the others, two spaces past the longest line
185
+ // that carries one.
186
+ const marked = lines.filter((l) => l.mark !== null);
172
187
  const at = Math.max(0, ...marked.map((l) => l.text.length)) + 2;
173
- return lines.map((l) => l.byDefault ? `${l.text.padEnd(at)}# default` : l.text);
188
+ return lines.map((l) => l.mark !== null ? `${l.text.padEnd(at)}# ${l.mark}` : l.text);
174
189
  }
package/dist/init.mjs CHANGED
@@ -13,7 +13,7 @@ import { dirname, join } from "node:path";
13
13
  import { isMap, parseDocument } from "yaml";
14
14
  import { builtOf, secretSteps, TOOLS, } from "./tools.mjs";
15
15
  import { NeedsScopeError } from "./code-host/types.mjs";
16
- import { columnsOf, fieldNamesOf, parseSettings, POLL_MINUTES, repoRoot, SETTINGS_FILE, SettingsError, } from "./config.mjs";
16
+ import { columnsOf, fieldNamesOf, filesDeps, parseSettings, resolveFiles, POLL_MINUTES, repoRoot, SETTINGS_FILE, SettingsError, } from "./config.mjs";
17
17
  import { checks as doctorChecks, doctorDeps, line } from "./doctor.mjs";
18
18
  import { branchDeps, needDefaultBranch, NoDefaultBranch, } from "./lib/default-branch.mjs";
19
19
  import { hasCommand, noTerminal } from "./lib/has-command.mjs";
@@ -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("ci-review"))
281
- doc.setIn(["ci-review", "commands"], []);
280
+ if (parts.has("review") && !doc.has("pr-review"))
281
+ doc.setIn(["pr-review", "commands"], []);
282
282
  if (!parts.has("review"))
283
- doc.delete("ci-review");
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");
@@ -557,10 +557,12 @@ export async function run(argv) {
557
557
  // The settings are not written yet, so the code host asked is the one
558
558
  // setup has just opened, not the one a settings file names.
559
559
  syncChanges: async (text, host) => {
560
- const raw = parseDocument(text).toJS();
561
- const s = parseSettings(raw, (p) => existsSync(join(root, p)));
560
+ const r = await resolveFiles({
561
+ ...filesDeps(root),
562
+ readFile: () => text,
563
+ });
562
564
  const branch = await needDefaultBranch({ ...branchDeps(root), host });
563
- return differences(root, syncPlan(PACKAGE, root, s, branch));
565
+ return differences(root, await syncPlan(PACKAGE, root, r, branch));
564
566
  },
565
567
  interactive: async (argv2) => spawnSync(argv2[0], argv2.slice(1), { stdio: "inherit" }).status ?? 1,
566
568
  hasCommand,
@@ -29,7 +29,7 @@ export declare function needDefaultBranch(d: Deps, sources?: Sources): Promise<s
29
29
  /** The sources of the checkout at `root`. The code host is the one the
30
30
  * checkout's settings name, and is loaded only when it is asked, so a
31
31
  * caller that runs before every command stays quick. */
32
- export declare const branchDeps: (root: string, env?: Record<string, string | undefined>) => Deps;
32
+ export declare const branchDeps: (root: string, env?: Record<string, string | undefined>, settings?: () => Promise<import("../config.mts").Settings>) => Deps;
33
33
  export declare function main(argv: string[], d: Deps, out: (line: string) => void, err: (line: string) => void): Promise<number>;
34
34
  /** `factory default-branch`. */
35
35
  export declare function run(argv: string[]): Promise<number>;
@@ -86,14 +86,14 @@ export async function needDefaultBranch(d, sources = "all") {
86
86
  /** The sources of the checkout at `root`. The code host is the one the
87
87
  * checkout's settings name, and is loaded only when it is asked, so a
88
88
  * caller that runs before every command stays quick. */
89
- export const branchDeps = (root, env = process.env) => ({
89
+ export const branchDeps = (root, env = process.env, settings) => ({
90
90
  env,
91
91
  readFile: (path) => readFileSync(path, "utf8"),
92
92
  git: gitIn(root),
93
93
  host: async () => {
94
94
  const { defaultDeps, loadSettings, reachOf } = await import("../config.mjs");
95
95
  const { openCodeHost } = await import("../code-host/index.mjs");
96
- const { repository, codeHost } = await reachOf(env, () => loadSettings(defaultDeps(root)));
96
+ const { repository, codeHost } = await reachOf(env, settings ?? (() => loadSettings(defaultDeps(root))));
97
97
  return openCodeHost(repository, codeHost).defaultBranch();
98
98
  },
99
99
  });
@@ -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 plug-in's. It reads headings only, never
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 CI review's summary is posted from. */
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 CI review's bot count; the owner's comments count
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"
@@ -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 CI review spent at API list
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 CI review's summary.
107
- /** The account the CI review's summary is posted from. */
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 CI review's bot count; the owner's comments count
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 `ci-review`. */
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 `ci-review`. */
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?.ciReview)
51
+ if (s?.prReview)
52
52
  on.add("review");
53
53
  if (s?.tickets.board != null)
54
54
  on.add("board");
@@ -0,0 +1,65 @@
1
+ import { type Resolved } from "./config.mts";
2
+ import type { Check } from "./setup.mts";
3
+ export type PresetDeps = {
4
+ root: string;
5
+ /** Where `preset check` looks for a package, the folder it runs in. */
6
+ cwd: string;
7
+ out: (line: string) => void;
8
+ err: (line: string) => void;
9
+ /** Whether the questions can be asked. */
10
+ terminal: boolean;
11
+ /** Asks one question and gives the answer typed. */
12
+ ask: (question: string) => Promise<string>;
13
+ /** Runs npm with these arguments in the root. */
14
+ npm: (args: string[]) => {
15
+ status: number;
16
+ stdout: string;
17
+ stderr: string;
18
+ };
19
+ /** Runs `factory sync`, giving each line it prints to `out`. */
20
+ sync: (out: (line: string) => void) => Promise<number>;
21
+ /** A file's text at a git revision, or null when it has none there. */
22
+ show: (ref: string, path: string) => string | null;
23
+ /** The settings resolved from the files, as `factory sync` resolves them,
24
+ * with `.claude/factory.yaml` and the choices file as given. */
25
+ resolve: (own: string, choices: string | null) => Promise<Resolved>;
26
+ write: (path: string, text: string | null) => void;
27
+ read: (path: string) => string | null;
28
+ };
29
+ /** A value as the summaries show it: a list's items joined, a plugin by its
30
+ * name. */
31
+ export declare function show(v: unknown): string;
32
+ /** npm's failure in the factory's words. */
33
+ export declare function installError(name: string, stderr: string, registry: string): string[];
34
+ /** Whether a group in `.github/dependabot.yml` has the package as its only
35
+ * pattern. */
36
+ export declare function hasOwnGroup(text: string | null, pkg: string): Promise<boolean>;
37
+ /** The registry `.npmrc` sends a package's scope to, or null. */
38
+ export declare function npmrcRegistry(text: string | null, pkg: string): string | null;
39
+ /** The lines `preset add` ends with for what Dependabot still needs. */
40
+ export declare function nextLines(dependabot: string | null, npmrc: string | null, pkg: string): Promise<string[]>;
41
+ export declare function add(argv: string[], d: PresetDeps): Promise<number>;
42
+ export declare function remove(argv: string[], d: PresetDeps): Promise<number>;
43
+ export declare function choices(_argv: string[], d: PresetDeps): Promise<number>;
44
+ export declare function chooseOne(argv: string[], d: PresetDeps): Promise<number>;
45
+ export declare function check(_argv: string[], d: PresetDeps): Promise<number>;
46
+ type Mark = {
47
+ from: string;
48
+ state?: "chosen" | "not-chosen";
49
+ };
50
+ /** A mark's text read back: who a value came from, and whether it was
51
+ * chosen. No mark is `.claude/factory.yaml`'s own. */
52
+ export declare function readMark(text: string | undefined | null): Mark;
53
+ /** Each setting's mark in a lock, by the key `combine` gives it. */
54
+ export declare function lockMarks(text: string): Promise<Map<string, Mark>>;
55
+ /** `factory preset changes REF`: what the presets' update changed here,
56
+ * as `factory-deps` comments it. */
57
+ export declare function changes(argv: string[], d: PresetDeps): Promise<number>;
58
+ /** Doctor's lines for the lock and the presets it records. */
59
+ export declare function presetChecks(root: string, stale: string | null): Promise<Check[]>;
60
+ export declare function main(argv: string[], d: PresetDeps): Promise<number>;
61
+ /** The preset commands' dependencies in the repository at `root`. */
62
+ export declare function presetDeps(root?: string): PresetDeps;
63
+ /** `factory preset ...`. */
64
+ export declare function run(argv: string[]): Promise<number>;
65
+ export {};