@davidbyoung/software-factory 0.1.8 → 0.1.9
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 +2 -0
- package/dist/agent/claude-code.mjs +15 -21
- package/dist/board.d.mts +20 -3
- package/dist/board.mjs +126 -38
- package/dist/cli.mjs +75 -9
- package/dist/code-host/github-setup.mjs +2 -2
- package/dist/columns-suggest.d.mts +0 -1
- package/dist/columns-suggest.mjs +2 -8
- package/dist/commands.d.mts +2 -0
- package/dist/commands.mjs +22 -11
- package/dist/config.d.mts +9 -0
- package/dist/config.mjs +57 -11
- package/dist/doctor.d.mts +6 -1
- package/dist/doctor.mjs +79 -18
- package/dist/explain.d.mts +5 -0
- package/dist/explain.mjs +29 -0
- package/dist/init.d.mts +2 -0
- package/dist/init.mjs +50 -9
- package/dist/lib/color.d.mts +11 -0
- package/dist/lib/color.mjs +15 -0
- package/dist/preset-commands.d.mts +2 -0
- package/dist/preset-commands.mjs +18 -12
- package/dist/preset.mjs +3 -2
- package/dist/setup.d.mts +3 -0
- package/dist/site.d.mts +3 -0
- package/dist/site.mjs +8 -1
- package/dist/status.d.mts +5 -2
- package/dist/status.mjs +13 -22
- package/dist/sync.d.mts +7 -1
- package/dist/sync.mjs +17 -5
- package/dist/ticket-fields.d.mts +84 -0
- package/dist/ticket-fields.mjs +374 -0
- package/dist/ticket.mjs +8 -7
- package/dist/tickets/github-setup.mjs +1 -1
- package/dist/tickets/github.mjs +69 -0
- package/dist/tickets/index.d.mts +8 -1
- package/dist/tickets/index.mjs +67 -7
- package/dist/tickets/types.d.mts +27 -1
- package/dist/tickets/types.mjs +4 -0
- package/dist/tools.d.mts +1 -1
- package/docs/cli.md +44 -10
- package/docs/configuration.md +78 -25
- package/docs/design.md +10 -0
- package/docs/developing.md +49 -18
- package/docs/existing-repo.md +137 -8
- package/docs/github/setup.md +5 -0
- package/docs/quick-start.md +3 -3
- package/docs/skills.md +3 -1
- package/docs/updating.md +3 -3
- package/package.json +4 -2
- package/settings.schema.json +68 -11
package/dist/preset-commands.mjs
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// factory preset choose KEY PRESET
|
|
9
9
|
// factory preset check
|
|
10
10
|
// factory preset changes REF
|
|
11
|
+
import { colorOn, painter, plain } from "./lib/color.mjs";
|
|
11
12
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
12
13
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
13
14
|
import { STATUS_CODES } from "node:http";
|
|
@@ -82,19 +83,21 @@ function valueInEffect(r, key) {
|
|
|
82
83
|
return r.resolution.files.get(key)?.source;
|
|
83
84
|
return getPath(r.resolution.raw, key.split("."));
|
|
84
85
|
}
|
|
85
|
-
function summary(head, groups, files) {
|
|
86
|
+
function summary(head, groups, files, paint) {
|
|
86
87
|
const shown = groups.filter((g) => g.rows.length);
|
|
87
88
|
const width = Math.max(0, ...shown.flatMap((g) => g.rows.map((r) => r.key.length))) + 3;
|
|
88
89
|
return [
|
|
89
90
|
head,
|
|
90
91
|
"",
|
|
91
92
|
...shown.flatMap((g) => [
|
|
92
|
-
` ${g.title}`,
|
|
93
|
+
` ${paint("bold", g.title)}`,
|
|
93
94
|
...g.rows.map((r) => ` ${r.key.padEnd(width)}${r.text}`),
|
|
94
95
|
]),
|
|
95
96
|
...(files.length ? ["", ...files.map((f) => ` ${f}`)] : []),
|
|
96
97
|
];
|
|
97
98
|
}
|
|
99
|
+
/** An `OLD → NEW` row: the old value dim, the new one bold. */
|
|
100
|
+
const change = (paint, was, now) => `${paint("dim", was)} → ${paint("bold", now)}`;
|
|
98
101
|
/** A question asked until the answer is one of `options`. */
|
|
99
102
|
async function choose(d, question, options) {
|
|
100
103
|
for (;;) {
|
|
@@ -282,6 +285,7 @@ async function syncing(d, wroteChoices) {
|
|
|
282
285
|
// ---------------------------------------------------------------- add
|
|
283
286
|
const PAREN = "this preset";
|
|
284
287
|
export async function add(argv, d) {
|
|
288
|
+
const paint = d.paint ?? plain;
|
|
285
289
|
const name = argv.find((a) => !a.startsWith("--"));
|
|
286
290
|
const yes = argv.includes("--yes");
|
|
287
291
|
const dry = argv.includes("--dry-run");
|
|
@@ -291,7 +295,7 @@ export async function add(argv, d) {
|
|
|
291
295
|
}
|
|
292
296
|
const ownText = d.read(SETTINGS_FILE);
|
|
293
297
|
if (ownText === null) {
|
|
294
|
-
d.err(`${SETTINGS_FILE} is missing. Run:
|
|
298
|
+
d.err(`${SETTINGS_FILE} is missing. Run: factory init`);
|
|
295
299
|
return 1;
|
|
296
300
|
}
|
|
297
301
|
const own = (await loadYaml(ownText));
|
|
@@ -380,13 +384,13 @@ export async function add(argv, d) {
|
|
|
380
384
|
continue;
|
|
381
385
|
}
|
|
382
386
|
if (list) {
|
|
383
|
-
added.push({ key: list, text: `+ ${show(mine)}` });
|
|
387
|
+
added.push({ key: list, text: paint("green", `+ ${show(mine)}`) });
|
|
384
388
|
continue;
|
|
385
389
|
}
|
|
386
390
|
const was = getPath(effNow, key.split("."));
|
|
387
391
|
if (stable(was) === stable(mine))
|
|
388
392
|
continue;
|
|
389
|
-
replacesDefault.push({ key, text:
|
|
393
|
+
replacesDefault.push({ key, text: change(paint, show(was), show(mine)) });
|
|
390
394
|
}
|
|
391
395
|
for (const path of VALUE_LISTS) {
|
|
392
396
|
const was = getPath(effNow, path.split("."));
|
|
@@ -397,7 +401,7 @@ export async function add(argv, d) {
|
|
|
397
401
|
for (const item of is)
|
|
398
402
|
if (!had.has(stable(item)) &&
|
|
399
403
|
after.resolution.sources.get(`${path}[${stable(item)}]`)?.from === name)
|
|
400
|
-
added.push({ key: path, text: `+ ${show(item)}` });
|
|
404
|
+
added.push({ key: path, text: paint("green", `+ ${show(item)}`) });
|
|
401
405
|
}
|
|
402
406
|
const locked = await lockFiles(d);
|
|
403
407
|
const writes = [...after.resolution.files]
|
|
@@ -412,7 +416,7 @@ export async function add(argv, d) {
|
|
|
412
416
|
rows,
|
|
413
417
|
})),
|
|
414
418
|
{ title: `replaced by your ${SETTINGS_FILE}`, rows: yours },
|
|
415
|
-
], writes))
|
|
419
|
+
], writes, paint))
|
|
416
420
|
d.out(line);
|
|
417
421
|
if (dry) {
|
|
418
422
|
undo();
|
|
@@ -471,6 +475,7 @@ async function lockFiles(d) {
|
|
|
471
475
|
}
|
|
472
476
|
// ---------------------------------------------------------------- remove
|
|
473
477
|
export async function remove(argv, d) {
|
|
478
|
+
const paint = d.paint ?? plain;
|
|
474
479
|
const name = argv.find((a) => !a.startsWith("--"));
|
|
475
480
|
const yes = argv.includes("--yes");
|
|
476
481
|
const dry = argv.includes("--dry-run");
|
|
@@ -521,17 +526,17 @@ export async function remove(argv, d) {
|
|
|
521
526
|
if (!after.resolution.sources.has(key))
|
|
522
527
|
removed.push({
|
|
523
528
|
key: path,
|
|
524
|
-
text: `− ${show(JSON.parse(key.slice(path.length + 1, -1)))}
|
|
529
|
+
text: paint("red", `− ${show(JSON.parse(key.slice(path.length + 1, -1)))}`),
|
|
525
530
|
});
|
|
526
531
|
continue;
|
|
527
532
|
}
|
|
528
533
|
if (!nextSrc) {
|
|
529
534
|
if (list)
|
|
530
|
-
removed.push({ key: list, text: `− ${show(old)}` });
|
|
535
|
+
removed.push({ key: list, text: paint("red", `− ${show(old)}`) });
|
|
531
536
|
else
|
|
532
537
|
toDefault.push({
|
|
533
538
|
key,
|
|
534
|
-
text:
|
|
539
|
+
text: change(paint, show(old), show(getPath(effAfter, key.split(".")))),
|
|
535
540
|
});
|
|
536
541
|
continue;
|
|
537
542
|
}
|
|
@@ -540,7 +545,7 @@ export async function remove(argv, d) {
|
|
|
540
545
|
continue;
|
|
541
546
|
const row = {
|
|
542
547
|
key: list ?? key,
|
|
543
|
-
text: `${show(old)
|
|
548
|
+
text: `${change(paint, show(old), show(next))}, from ${nextSrc.from}`,
|
|
544
549
|
};
|
|
545
550
|
if (src.state === "chosen") {
|
|
546
551
|
chosenAgainst.push(row);
|
|
@@ -559,7 +564,7 @@ export async function remove(argv, d) {
|
|
|
559
564
|
{ title: "back to the default", rows: toDefault },
|
|
560
565
|
{ title: "back to another preset's value", rows: toOther },
|
|
561
566
|
{ title: "back to a value you chose against", rows: chosenAgainst },
|
|
562
|
-
], deletes))
|
|
567
|
+
], deletes, paint))
|
|
563
568
|
d.out(line);
|
|
564
569
|
if (dry)
|
|
565
570
|
return 0;
|
|
@@ -1075,6 +1080,7 @@ export function presetDeps(root = repoRoot()) {
|
|
|
1075
1080
|
out: (l) => console.log(l),
|
|
1076
1081
|
err: (l) => console.error(l),
|
|
1077
1082
|
terminal: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
1083
|
+
paint: painter(colorOn()),
|
|
1078
1084
|
ask: async (question) => {
|
|
1079
1085
|
const { createInterface } = await import("node:readline/promises");
|
|
1080
1086
|
const rl = createInterface({
|
package/dist/preset.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { createHash } from "node:crypto";
|
|
|
7
7
|
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
8
8
|
import { dirname, join, relative, sep } from "node:path";
|
|
9
9
|
import { DEFAULT_CODE_HOST } from "./code-host/index.mjs";
|
|
10
|
-
import { ROLE_SHAPE, ROLES, SETTINGS_FILE, SETTINGS_KEYS } from "./config.mjs";
|
|
10
|
+
import { OWN_HEADING, ROLE_SHAPE, ROLES, SETTINGS_FILE, SETTINGS_KEYS, } from "./config.mjs";
|
|
11
11
|
import { BUILT } from "./tool-names.mjs";
|
|
12
12
|
import { NPMRC, refusal } from "./npmrc.mjs";
|
|
13
13
|
export const PRESET_FILE = "factory-preset.yaml";
|
|
@@ -131,7 +131,8 @@ export function unknownKey(raw) {
|
|
|
131
131
|
for (const [k, value] of Object.entries(v)) {
|
|
132
132
|
const at = path ? `${path}.${k}` : k;
|
|
133
133
|
const show = shown ? `${shown}.${k}` : k;
|
|
134
|
-
|
|
134
|
+
const own = path === "tickets.fields" && OWN_HEADING.test(k);
|
|
135
|
+
if (!allowed.includes(k) && !extra.includes(k) && !own)
|
|
135
136
|
return `${show}: unknown key`;
|
|
136
137
|
const inner = SETTINGS_KEYS[`${at}[]`] && Array.isArray(value)
|
|
137
138
|
? value
|
package/dist/setup.d.mts
CHANGED
|
@@ -13,6 +13,9 @@ export type Check = {
|
|
|
13
13
|
text: string;
|
|
14
14
|
/** What to do about a failure. */
|
|
15
15
|
fix?: string;
|
|
16
|
+
/** The heading `doctor` prints it under: a tool's name, or one of its
|
|
17
|
+
* own. */
|
|
18
|
+
group?: string;
|
|
16
19
|
};
|
|
17
20
|
/** A secret is needed for a part that is on, or always when `part` is
|
|
18
21
|
* null, and any one of `anyOf` being set meets it. */
|
package/dist/site.d.mts
CHANGED
|
@@ -57,4 +57,7 @@ export declare function givenUrls(argv: string[]): {
|
|
|
57
57
|
before: string;
|
|
58
58
|
after: string;
|
|
59
59
|
} | null;
|
|
60
|
+
/** What `factory site stop` says: a kept comparison is always two sites,
|
|
61
|
+
* this branch's and the base's. */
|
|
62
|
+
export declare function stopMessage(stopped: boolean): string;
|
|
60
63
|
export declare function run(argv: string[]): Promise<number>;
|
package/dist/site.mjs
CHANGED
|
@@ -317,13 +317,20 @@ async function compare(argv) {
|
|
|
317
317
|
cleanup();
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
|
+
/** What `factory site stop` says: a kept comparison is always two sites,
|
|
321
|
+
* this branch's and the base's. */
|
|
322
|
+
export function stopMessage(stopped) {
|
|
323
|
+
return stopped
|
|
324
|
+
? "Stopped the 2 sites site compare --keep left running."
|
|
325
|
+
: "No sites were left running.";
|
|
326
|
+
}
|
|
320
327
|
export async function run(argv) {
|
|
321
328
|
const [command, ...rest] = argv;
|
|
322
329
|
try {
|
|
323
330
|
if (command === "compare")
|
|
324
331
|
return await compare(rest);
|
|
325
332
|
if (command === "stop") {
|
|
326
|
-
stopKept(repoRoot());
|
|
333
|
+
console.log(stopMessage(stopKept(repoRoot())));
|
|
327
334
|
return 0;
|
|
328
335
|
}
|
|
329
336
|
console.error("Usage: factory site compare | site stop");
|
package/dist/status.d.mts
CHANGED
|
@@ -51,8 +51,9 @@ export type Style = {
|
|
|
51
51
|
columns?: Columns;
|
|
52
52
|
};
|
|
53
53
|
export declare const PLAIN: Style;
|
|
54
|
-
/**
|
|
55
|
-
|
|
54
|
+
/** Colors, links, and fitting to the window go together, where `colorOn`
|
|
55
|
+
* says the output is colored. */
|
|
56
|
+
export declare function styleFor(color: boolean, columns: number | undefined): Style;
|
|
56
57
|
/** One reviewer's row under its card: a mark that carries the result
|
|
57
58
|
* without color, the name, the model, the result, how long it ran, and its
|
|
58
59
|
* cost in subscription dollars. */
|
|
@@ -96,5 +97,7 @@ export type Deps = {
|
|
|
96
97
|
* frame as tall as the window. */
|
|
97
98
|
export declare function frame(lines: string[]): string;
|
|
98
99
|
export declare function main(argv: string[], d: Deps): Promise<number>;
|
|
100
|
+
/** The style for what `run` prints to stdout. */
|
|
101
|
+
export declare const terminalStyle: () => Style;
|
|
99
102
|
/** `factory status [--watch]`, and `factory session-start`'s second half. */
|
|
100
103
|
export declare function run(argv: string[]): Promise<number>;
|
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 { colorOn, painter } from "./lib/color.mjs";
|
|
14
15
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
15
16
|
import { NO_DEPENDENCIES, SettingsError, loadSettings, targetOf, } from "./config.mjs";
|
|
16
17
|
import { appSessionLink } from "./lib/gh.mjs";
|
|
@@ -114,26 +115,14 @@ watch = watchOf("own-server", 5), columns = DEFAULT_COLUMNS) {
|
|
|
114
115
|
return { rows, closed };
|
|
115
116
|
}
|
|
116
117
|
export const PLAIN = { color: false, width: null };
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
/** Colors, links, and fitting to the window go together, where `colorOn`
|
|
119
|
+
* says the output is colored. */
|
|
120
|
+
export function styleFor(color, columns) {
|
|
121
|
+
return color ? { color: true, width: columns ?? 80 } : PLAIN;
|
|
120
122
|
}
|
|
121
123
|
const ESC = "\x1B";
|
|
122
|
-
const SGR = {
|
|
123
|
-
bold: 1,
|
|
124
|
-
dim: 2,
|
|
125
|
-
underline: 4,
|
|
126
|
-
red: 31,
|
|
127
|
-
green: 32,
|
|
128
|
-
yellow: 33,
|
|
129
|
-
magenta: 35,
|
|
130
|
-
cyan: 36,
|
|
131
|
-
white: 37,
|
|
132
|
-
brightBlue: 94,
|
|
133
|
-
brightWhite: 97,
|
|
134
|
-
};
|
|
135
124
|
const GROUPS = [
|
|
136
|
-
{ name: "Backlog", color: "
|
|
125
|
+
{ name: "Backlog", color: "whiteBright" },
|
|
137
126
|
{ name: "In refinement", color: "yellow" },
|
|
138
127
|
{ name: "Ready", color: "green" },
|
|
139
128
|
{ name: "In progress", color: "cyan" },
|
|
@@ -149,7 +138,7 @@ const width = (segs) => segs.reduce((n, s) => n + [...s.text].length, 0);
|
|
|
149
138
|
function paint(text, style, ...codes) {
|
|
150
139
|
if (!style.color || codes.length === 0)
|
|
151
140
|
return text;
|
|
152
|
-
return
|
|
141
|
+
return painter(true)(codes, text);
|
|
153
142
|
}
|
|
154
143
|
function render(segs, style) {
|
|
155
144
|
return segs
|
|
@@ -324,7 +313,7 @@ export function formatRows({ rows, closed }, now, withClosed = true, style = PLA
|
|
|
324
313
|
{
|
|
325
314
|
name: UNLINKED,
|
|
326
315
|
label: UNLINKED,
|
|
327
|
-
color: "
|
|
316
|
+
color: "whiteBright",
|
|
328
317
|
cells: cells.filter((c) => c.row.kind === "pull"),
|
|
329
318
|
always: false,
|
|
330
319
|
},
|
|
@@ -342,7 +331,7 @@ export function formatRows({ rows, closed }, now, withClosed = true, style = PLA
|
|
|
342
331
|
? paint(c.session, style, "bold", "yellow")
|
|
343
332
|
: render(sessionSegs(c.session, c.row.derived, style.links), style);
|
|
344
333
|
lines.push((INDENT +
|
|
345
|
-
paint(render([{ text: c.number, url: c.url }], style), style, "
|
|
334
|
+
paint(render([{ text: c.number, url: c.url }], style), style, "blueBright") +
|
|
346
335
|
pad(c.number, numW) +
|
|
347
336
|
GAP +
|
|
348
337
|
render(title, style) +
|
|
@@ -373,7 +362,7 @@ export function formatRows({ rows, closed }, now, withClosed = true, style = PLA
|
|
|
373
362
|
text: `#${r.number}`,
|
|
374
363
|
url: linkTo("ticket", style, r.number),
|
|
375
364
|
},
|
|
376
|
-
], style), style, "
|
|
365
|
+
], style), style, "blueBright"))
|
|
377
366
|
.join(", ")}`);
|
|
378
367
|
return lines;
|
|
379
368
|
}
|
|
@@ -484,6 +473,8 @@ export async function main(argv, d) {
|
|
|
484
473
|
await d.sleep(WATCH_MS);
|
|
485
474
|
}
|
|
486
475
|
}
|
|
476
|
+
/** The style for what `run` prints to stdout. */
|
|
477
|
+
export const terminalStyle = () => styleFor(colorOn(), process.stdout.columns);
|
|
487
478
|
/** `factory status [--watch]`, and `factory session-start`'s second half. */
|
|
488
479
|
export async function run(argv) {
|
|
489
480
|
const code = await main(argv, {
|
|
@@ -506,7 +497,7 @@ export async function run(argv) {
|
|
|
506
497
|
process.exit(130);
|
|
507
498
|
});
|
|
508
499
|
},
|
|
509
|
-
style:
|
|
500
|
+
style: terminalStyle,
|
|
510
501
|
settings: () => loadSettings(),
|
|
511
502
|
env: process.env,
|
|
512
503
|
});
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Paint } from "./lib/color.mts";
|
|
1
2
|
import { type Resolved, type Settings } from "./config.mts";
|
|
2
3
|
import { type Replaced } from "./preset.mts";
|
|
3
4
|
/** The package's own folder: the parent of `src/`, or of `dist/` once
|
|
@@ -111,6 +112,10 @@ export declare function main(argv: string[], d: {
|
|
|
111
112
|
defaultBranch: (s: Settings) => Promise<string | null>;
|
|
112
113
|
out: (line: string) => void;
|
|
113
114
|
err: (line: string) => void;
|
|
115
|
+
paint?: Paint;
|
|
116
|
+
/** Whether a person ran it, so a sync that changes nothing says so;
|
|
117
|
+
* `init` and the preset commands run it inside their own output. */
|
|
118
|
+
announce?: boolean;
|
|
114
119
|
}): Promise<number>;
|
|
115
120
|
/** The sync of the repository at `root`. */
|
|
116
121
|
export declare const syncDeps: (root: string) => {
|
|
@@ -122,5 +127,6 @@ export declare const syncDeps: (root: string) => {
|
|
|
122
127
|
out: (line: string) => void;
|
|
123
128
|
err: (line: string) => void;
|
|
124
129
|
};
|
|
125
|
-
|
|
130
|
+
/** `announce` is false when `init` runs the sync inside its own output. */
|
|
131
|
+
export declare function run(argv: string[], announce?: boolean): Promise<number>;
|
|
126
132
|
export {};
|
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 { colorOn, painter, plain } from "./lib/color.mjs";
|
|
17
18
|
import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
18
19
|
import { dirname, join, relative, sep } from "node:path";
|
|
19
20
|
import { fileURLToPath } from "node:url";
|
|
@@ -587,6 +588,7 @@ export function differences(root, p) {
|
|
|
587
588
|
}
|
|
588
589
|
export async function main(argv, d) {
|
|
589
590
|
const check = argv.includes("--check");
|
|
591
|
+
const paint = d.paint ?? plain;
|
|
590
592
|
let r;
|
|
591
593
|
try {
|
|
592
594
|
if (check) {
|
|
@@ -617,12 +619,15 @@ export async function main(argv, d) {
|
|
|
617
619
|
const p = await plan(d.pkg, d.root, r, branch);
|
|
618
620
|
const differ = differences(d.root, p);
|
|
619
621
|
if (check) {
|
|
620
|
-
if (differ.length === 0)
|
|
622
|
+
if (differ.length === 0) {
|
|
623
|
+
d.out(`${paint("green", "✓")} The factory's files match the settings.`);
|
|
621
624
|
return 0;
|
|
622
|
-
|
|
625
|
+
}
|
|
626
|
+
const n = differ.length;
|
|
627
|
+
d.err(`${paint("red", "✗")} ${n} of the factory's files ${n === 1 ? "doesn't" : "don't"} match the settings:`);
|
|
623
628
|
for (const path of differ)
|
|
624
629
|
d.err(` ${path}`);
|
|
625
|
-
d.err("Run
|
|
630
|
+
d.err("Run factory sync and commit what it writes.");
|
|
626
631
|
return 1;
|
|
627
632
|
}
|
|
628
633
|
for (const line of [...p.kept, ...p.dropped])
|
|
@@ -640,6 +645,8 @@ export async function main(argv, d) {
|
|
|
640
645
|
d.out(`wrote ${path}`);
|
|
641
646
|
}
|
|
642
647
|
}
|
|
648
|
+
if (differ.length === 0 && d.announce)
|
|
649
|
+
d.out("The factory's files already match the settings. Nothing changed.");
|
|
643
650
|
return 0;
|
|
644
651
|
}
|
|
645
652
|
/** The sync of the repository at `root`. */
|
|
@@ -652,6 +659,11 @@ export const syncDeps = (root) => ({
|
|
|
652
659
|
out: (line) => console.log(line),
|
|
653
660
|
err: (line) => console.error(line),
|
|
654
661
|
});
|
|
655
|
-
|
|
656
|
-
|
|
662
|
+
/** `announce` is false when `init` runs the sync inside its own output. */
|
|
663
|
+
export async function run(argv, announce = true) {
|
|
664
|
+
return main(argv, {
|
|
665
|
+
...syncDeps(repoRoot()),
|
|
666
|
+
paint: painter(colorOn()),
|
|
667
|
+
announce,
|
|
668
|
+
});
|
|
657
669
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Agent } from "./agent/types.mts";
|
|
2
|
+
import type { Ask } from "./init.mts";
|
|
3
|
+
import type { Check } from "./setup.mts";
|
|
4
|
+
import type { Tickets } from "./tickets/types.mts";
|
|
5
|
+
/** The factory fields a refined ticket has, in the order its body has them. */
|
|
6
|
+
export declare const FACTORY_FIELDS: readonly [{
|
|
7
|
+
readonly key: "decisions";
|
|
8
|
+
readonly heading: "Decisions";
|
|
9
|
+
readonly holds: "the questions refinement settled, and what was chosen";
|
|
10
|
+
}, {
|
|
11
|
+
readonly key: "spec";
|
|
12
|
+
readonly heading: "Spec";
|
|
13
|
+
readonly holds: "what a change users will notice must do, line by line";
|
|
14
|
+
}, {
|
|
15
|
+
readonly key: "acceptance-criteria";
|
|
16
|
+
readonly heading: "Acceptance criteria";
|
|
17
|
+
readonly holds: "what must be true for any other ticket to be done";
|
|
18
|
+
}, {
|
|
19
|
+
readonly key: "for-the-builder";
|
|
20
|
+
readonly heading: "For the builder";
|
|
21
|
+
readonly holds: "how to build it, as a design and a list of tasks";
|
|
22
|
+
}];
|
|
23
|
+
export type FactoryKey = (typeof FACTORY_FIELDS)[number]["key"];
|
|
24
|
+
/** Each ticket-side key under `tickets.fields`, in settings order, with
|
|
25
|
+
* the ticket field that holds it, or null for the description. */
|
|
26
|
+
export type FieldMapping = Record<string, string | null>;
|
|
27
|
+
/** The heading a key stands for: the factory's own, or the key with its
|
|
28
|
+
* hyphens as spaces and its first letter capitalized. */
|
|
29
|
+
export declare function headingOf(key: string): string;
|
|
30
|
+
/** The key a heading stands for: lowercase, with hyphens for spaces. */
|
|
31
|
+
export declare const keyOf: (heading: string) => string;
|
|
32
|
+
/** A ticket's document taken apart: the description, and each named ticket
|
|
33
|
+
* field's text, or null to clear it. */
|
|
34
|
+
export declare function split(body: string, mapping: FieldMapping): {
|
|
35
|
+
description: string;
|
|
36
|
+
values: Record<string, string | null>;
|
|
37
|
+
} | {
|
|
38
|
+
error: string;
|
|
39
|
+
};
|
|
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
|
+
export declare function join(description: string, values: Record<string, string>, mapping: FieldMapping, labels: readonly string[]): string;
|
|
43
|
+
/** The agent's answer for a factory field no ticket field fits. A token,
|
|
44
|
+
* so a ticket field called "Description" stays usable. */
|
|
45
|
+
export declare const DESCRIPTION = "__description__";
|
|
46
|
+
export declare const TIMEOUT_MS = 60000;
|
|
47
|
+
/** Each factory field's ticket field, or null for the description. */
|
|
48
|
+
export type Suggestion = Record<FactoryKey, string | null>;
|
|
49
|
+
export declare function prompt(fields: readonly TicketFieldInfo[]): string;
|
|
50
|
+
/** A field as the prompt and the checks need it. */
|
|
51
|
+
export type TicketFieldInfo = {
|
|
52
|
+
name: string;
|
|
53
|
+
description: string | null;
|
|
54
|
+
};
|
|
55
|
+
export declare function schema(fields: readonly TicketFieldInfo[]): object;
|
|
56
|
+
/** The suggestion the agent's answer gives, or the reason it can't be
|
|
57
|
+
* used, the first that applies in the order the issue lists them. */
|
|
58
|
+
export declare function check(answer: unknown, fields: readonly TicketFieldInfo[], repository: string): {
|
|
59
|
+
suggestion: Suggestion;
|
|
60
|
+
} | {
|
|
61
|
+
reason: string;
|
|
62
|
+
};
|
|
63
|
+
/** The table of each factory field's ticket field. */
|
|
64
|
+
export declare function table(suggestion: Suggestion): string[];
|
|
65
|
+
export type FieldStepDeps = {
|
|
66
|
+
ask: Ask;
|
|
67
|
+
out: (line: string) => void;
|
|
68
|
+
agent: Agent;
|
|
69
|
+
/** The agent's registered label, which every line names it by. */
|
|
70
|
+
label: string;
|
|
71
|
+
};
|
|
72
|
+
/** The field step: the four factory fields' lines to write under
|
|
73
|
+
* `tickets.fields`, or 1 when init stops. */
|
|
74
|
+
export declare function suggestFields(d: FieldStepDeps, o: {
|
|
75
|
+
repository: string;
|
|
76
|
+
fields: readonly TicketFieldInfo[];
|
|
77
|
+
/** The ticket system's label, when its fields show text as typed. */
|
|
78
|
+
plainText: string | null;
|
|
79
|
+
}): Promise<[FactoryKey, string][] | 1>;
|
|
80
|
+
/** The checks `factory doctor` and `init` end with: that each ticket field
|
|
81
|
+
* the settings name exists and holds text. None when they name none. */
|
|
82
|
+
export declare function fieldChecks(tickets: Tickets, mapping: FieldMapping, repository: string,
|
|
83
|
+
/** The ticket system's registered label. */
|
|
84
|
+
label: string): Promise<Check[]>;
|