@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/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Software factory
|
|
2
2
|
|
|
3
|
+
[](https://codecov.io/gh/davidbyoung/software-factory)
|
|
4
|
+
|
|
3
5
|
> **Early, and not yet for general use.** This is below 1.0: it changes
|
|
4
6
|
> weekly, and any minor version may break what the one before it did,
|
|
5
7
|
> without notice. Pin an exact version if you try it.
|
|
@@ -9,32 +9,26 @@ import { AGENT_KEY, AGENT_TOKEN } from "../parts.mjs";
|
|
|
9
9
|
import { CLAUDE_MD, hasAnyFactoryHook, hasFactoryHooks, hasImport, SETTINGS_JSON, withoutHooks, withoutImport, } from "../sync.mjs";
|
|
10
10
|
export const LABEL = "Claude Code";
|
|
11
11
|
const COMMAND = "claude";
|
|
12
|
-
const SYNC = "Run
|
|
12
|
+
const SYNC = "Run factory sync";
|
|
13
13
|
const READS = ["review", "cloud"];
|
|
14
14
|
const read = (root, path) => existsSync(join(root, path)) ? readFileSync(join(root, path), "utf8") : null;
|
|
15
15
|
export const claudeCodeSetup = {
|
|
16
|
-
found: (c) => c.hasCommand(COMMAND)
|
|
17
|
-
? LABEL
|
|
18
|
-
: `${LABEL}, which is not installed: sessions and its token need it`,
|
|
19
16
|
steps: (c) => {
|
|
20
17
|
const parts = READS.filter((p) => c.parts.has(p));
|
|
21
18
|
if (!parts.length)
|
|
22
19
|
return [];
|
|
23
|
-
const installed = c.hasCommand(COMMAND);
|
|
24
|
-
const name = installed ? AGENT_TOKEN : AGENT_KEY;
|
|
25
20
|
return [
|
|
26
21
|
{
|
|
27
22
|
kind: "secret",
|
|
28
23
|
needs: parts.map((part) => ({ part, anyOf: [AGENT_TOKEN, AGENT_KEY] })),
|
|
29
|
-
storeAs: [
|
|
30
|
-
intro:
|
|
31
|
-
|
|
32
|
-
:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
skipped: `No ${name} stored.`,
|
|
24
|
+
storeAs: [AGENT_TOKEN],
|
|
25
|
+
intro: [
|
|
26
|
+
"",
|
|
27
|
+
`The coding agent's token: running ${COMMAND} setup-token...`,
|
|
28
|
+
],
|
|
29
|
+
get: { command: [COMMAND, "setup-token"] },
|
|
30
|
+
prompt: "Paste the token it printed (leave empty to do this later):",
|
|
31
|
+
skipped: `No ${AGENT_TOKEN} stored.`,
|
|
38
32
|
stored: (names) => `Stored as ${names.join(", ")}.`,
|
|
39
33
|
},
|
|
40
34
|
];
|
|
@@ -43,28 +37,28 @@ export const claudeCodeSetup = {
|
|
|
43
37
|
hasImport(read(c.root, CLAUDE_MD))
|
|
44
38
|
? {
|
|
45
39
|
state: "pass",
|
|
46
|
-
text: `${
|
|
40
|
+
text: `${CLAUDE_MD} imports the factory's rules`,
|
|
47
41
|
}
|
|
48
42
|
: {
|
|
49
43
|
state: "fail",
|
|
50
|
-
text: `${
|
|
44
|
+
text: `${CLAUDE_MD} imports the factory's rules`,
|
|
51
45
|
fix: SYNC,
|
|
52
46
|
},
|
|
53
47
|
hasFactoryHooks(read(c.root, SETTINGS_JSON))
|
|
54
48
|
? {
|
|
55
49
|
state: "pass",
|
|
56
|
-
text: `${
|
|
50
|
+
text: `${SETTINGS_JSON} has the factory's hooks`,
|
|
57
51
|
}
|
|
58
52
|
: {
|
|
59
53
|
state: "fail",
|
|
60
|
-
text: `${
|
|
54
|
+
text: `${SETTINGS_JSON} has the factory's hooks`,
|
|
61
55
|
fix: SYNC,
|
|
62
56
|
},
|
|
63
57
|
c.hasCommand(COMMAND)
|
|
64
|
-
? { state: "pass", text:
|
|
58
|
+
? { state: "pass", text: `The ${COMMAND} command is installed` }
|
|
65
59
|
: {
|
|
66
60
|
state: "fail",
|
|
67
|
-
text:
|
|
61
|
+
text: `The ${COMMAND} command is installed`,
|
|
68
62
|
fix: "Install Claude Code, then sign in",
|
|
69
63
|
},
|
|
70
64
|
],
|
package/dist/board.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { type Paint } from "./lib/color.mts";
|
|
2
3
|
import { type Settings } from "./config.mts";
|
|
3
4
|
import { type Columns, type Board, type BoardField, type Derived, type PullRequest, type RepoSnapshot } from "./lib/work-status.mts";
|
|
4
5
|
import { type Runner } from "./runner/index.mts";
|
|
@@ -47,9 +48,22 @@ export declare function inspectBoard(fields: BoardField[], cfg?: BoardConfig): I
|
|
|
47
48
|
/** The board's fields, or an error naming everything that is wrong with
|
|
48
49
|
* them. */
|
|
49
50
|
export declare function checkFields(fields: BoardField[], cfg?: BoardConfig): Fields;
|
|
50
|
-
/**
|
|
51
|
-
* field
|
|
52
|
-
|
|
51
|
+
/** A row of `factory board check`: a state, a column no state names, or a
|
|
52
|
+
* field the sync writes. `none` is a state whose column cannot be told,
|
|
53
|
+
* when the board has no Status field to read. */
|
|
54
|
+
export type BoardRow = {
|
|
55
|
+
state: "pass" | "fail" | "unknown" | "off" | "none";
|
|
56
|
+
key: string;
|
|
57
|
+
text: string;
|
|
58
|
+
};
|
|
59
|
+
/** What `factory board check` says of each state and each field. */
|
|
60
|
+
export declare function boardRows(fields: BoardField[], cfg: BoardConfig, settings: Pick<Settings, "builds">): {
|
|
61
|
+
columns: BoardRow[];
|
|
62
|
+
fields: BoardRow[];
|
|
63
|
+
};
|
|
64
|
+
/** The report `factory board check` prints: each state's column, then each
|
|
65
|
+
* field, under the setting each comes from. */
|
|
66
|
+
export declare function boardReport(number: number, board: Board, cfg: BoardConfig, settings: Pick<Settings, "builds">, paint?: Paint): string[];
|
|
53
67
|
export type Plan = {
|
|
54
68
|
number: number;
|
|
55
69
|
itemId: string | null;
|
|
@@ -122,7 +136,10 @@ export type Deps = {
|
|
|
122
136
|
* and the repository where FACTORY_BOARD_NUMBER and GITHUB_REPOSITORY do
|
|
123
137
|
* not name them. */
|
|
124
138
|
settings: () => Promise<Settings>;
|
|
139
|
+
paint?: Paint;
|
|
125
140
|
};
|
|
126
141
|
export declare function main(argv: string[], deps: Deps): Promise<number>;
|
|
142
|
+
/** The dependencies `run` gives `main`. */
|
|
143
|
+
export declare function boardDeps(argv: string[]): Deps;
|
|
127
144
|
/** `factory board collect` and `factory board apply`. */
|
|
128
145
|
export declare function run(argv: string[]): Promise<number>;
|
package/dist/board.mjs
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
//
|
|
21
21
|
// Tickets and the board go through the ticket interface (`tickets/`); the
|
|
22
22
|
// pull requests through `code-host/`.
|
|
23
|
+
import { colorOn, painter, plain, } from "./lib/color.mjs";
|
|
23
24
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
24
25
|
import { join } from "node:path";
|
|
25
26
|
import { columnsOf, fieldNamesOf, loadSettings, } from "./config.mjs";
|
|
@@ -139,41 +140,120 @@ export function checkFields(fields, cfg = DEFAULT_BOARD) {
|
|
|
139
140
|
throw new Error(`The board: ${found.problems.join("; ")}.`);
|
|
140
141
|
return { status: found.status, ...found.fields };
|
|
141
142
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const column = cfg.columns[status];
|
|
154
|
-
out.push(pad(key) +
|
|
155
|
-
(column !== null
|
|
156
|
-
? column.join(", ")
|
|
157
|
-
: key === "ready"
|
|
158
|
-
? "no column: builds start only when you ask"
|
|
159
|
-
: `no column, shows in ${columnFor(status, cfg.columns)}`));
|
|
160
|
-
}
|
|
161
|
-
out.push("");
|
|
162
|
-
for (const line of found.lines)
|
|
163
|
-
out.push(pad(line.label) + line.text);
|
|
143
|
+
const KIND_WORDS = {
|
|
144
|
+
TEXT: "text field",
|
|
145
|
+
SINGLE_SELECT: "single select field",
|
|
146
|
+
NUMBER: "number field",
|
|
147
|
+
};
|
|
148
|
+
/** What `factory board check` says of each state and each field. */
|
|
149
|
+
export function boardRows(fields, cfg, settings) {
|
|
150
|
+
const find = (name) => fields.find((f) => sameName(f.name, name));
|
|
151
|
+
const status = find("Status") ?? null;
|
|
152
|
+
const readable = status?.dataType === "SINGLE_SELECT";
|
|
153
|
+
const options = readable ? (status.options ?? []).map((o) => o.name) : [];
|
|
164
154
|
const ready = cfg.columns.Ready?.[0] ?? null;
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
155
|
+
const columns = Object.keys(STATE_KEYS).map((key) => {
|
|
156
|
+
const names = cfg.columns[STATE_KEYS[key]];
|
|
157
|
+
if (names === null)
|
|
158
|
+
return {
|
|
159
|
+
state: "off",
|
|
160
|
+
key,
|
|
161
|
+
text: key === "ready"
|
|
162
|
+
? "none"
|
|
163
|
+
: `none, shows in ${columnFor(STATE_KEYS[key], cfg.columns)}`,
|
|
164
|
+
};
|
|
165
|
+
const joined = names.join(", ");
|
|
166
|
+
if (!readable)
|
|
167
|
+
return { state: "none", key, text: joined };
|
|
168
|
+
const missing = names.filter((n) => !options.some((o) => sameName(o, n)));
|
|
169
|
+
if (missing.length)
|
|
170
|
+
return {
|
|
171
|
+
state: "fail",
|
|
172
|
+
key,
|
|
173
|
+
text: `${joined}: no such column on the board${names.length > 1 ? `: ${missing.join(", ")}` : ""}`,
|
|
174
|
+
};
|
|
175
|
+
if (key === "ready" &&
|
|
168
176
|
ready !== DEFAULT_COLUMNS.Ready[0] &&
|
|
169
|
-
settings.builds.trigger === "own-server"
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
177
|
+
settings.builds.trigger === "own-server")
|
|
178
|
+
return {
|
|
179
|
+
state: "unknown",
|
|
180
|
+
key,
|
|
181
|
+
text: `${joined}: the poller needs FACTORY_READY_COLUMN set to "${ready}"`,
|
|
182
|
+
};
|
|
183
|
+
return { state: "pass", key, text: joined };
|
|
184
|
+
});
|
|
185
|
+
for (const name of options)
|
|
186
|
+
if (statusOfColumn(name, cfg.columns) === null)
|
|
187
|
+
columns.push({
|
|
188
|
+
state: "unknown",
|
|
189
|
+
key: name,
|
|
190
|
+
text: "no state: left alone",
|
|
191
|
+
});
|
|
192
|
+
const rows = [
|
|
193
|
+
status === null
|
|
194
|
+
? { state: "fail", key: "Status", text: "no such field" }
|
|
195
|
+
: readable
|
|
196
|
+
? { state: "pass", key: "Status", text: "synced" }
|
|
197
|
+
: { state: "fail", key: "Status", text: "not a single select" },
|
|
198
|
+
];
|
|
199
|
+
for (const kind of FIELD_KINDS) {
|
|
200
|
+
const name = cfg.fields[kind.key];
|
|
201
|
+
const key = kind.label;
|
|
202
|
+
if (name === null) {
|
|
203
|
+
rows.push({ state: "off", key, text: "off" });
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const named = !sameName(name, DEFAULT_FIELDS[kind.key]);
|
|
207
|
+
const setting = `tickets.fields.${kind.setting}`;
|
|
208
|
+
const field = find(name);
|
|
209
|
+
if (!field) {
|
|
210
|
+
rows.push(named
|
|
211
|
+
? { state: "fail", key, text: `no such field: ${name}` }
|
|
212
|
+
: { state: "unknown", key, text: "skipped: no such field" });
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const wrong = field.dataType !== kind.type
|
|
216
|
+
? `not a ${KIND_WORDS[kind.type]}`
|
|
217
|
+
: (() => {
|
|
218
|
+
const lacking = kind.options.filter((o) => !(field.options ?? []).some((x) => sameName(x.name, o)));
|
|
219
|
+
return lacking.length ? `lacks ${lacking.join(", ")}` : null;
|
|
220
|
+
})();
|
|
221
|
+
rows.push(wrong === null
|
|
222
|
+
? { state: "pass", key, text: "synced" }
|
|
223
|
+
: {
|
|
224
|
+
state: "fail",
|
|
225
|
+
key,
|
|
226
|
+
text: named
|
|
227
|
+
? `${name}: ${wrong}`
|
|
228
|
+
: `${wrong}: name another field in ${setting}, or set it to none`,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return { columns, fields: rows };
|
|
232
|
+
}
|
|
233
|
+
const MARKS = {
|
|
234
|
+
pass: ["✓", "green"],
|
|
235
|
+
fail: ["✗", "red"],
|
|
236
|
+
unknown: ["?", "yellow"],
|
|
237
|
+
off: ["-", "dim"],
|
|
238
|
+
none: [" ", null],
|
|
239
|
+
};
|
|
240
|
+
/** The report `factory board check` prints: each state's column, then each
|
|
241
|
+
* field, under the setting each comes from. */
|
|
242
|
+
export function boardReport(number, board, cfg, settings, paint = plain) {
|
|
243
|
+
const rows = boardRows(board.fields, cfg, settings);
|
|
244
|
+
const row = (r) => {
|
|
245
|
+
const [mark, color] = MARKS[r.state];
|
|
246
|
+
return ` ${color ? paint(color, mark) : mark} ${r.key.padEnd(10)} ${r.text}`;
|
|
247
|
+
};
|
|
248
|
+
return [
|
|
249
|
+
board.title ? `Board ${number}, "${board.title}"` : `Board ${number}`,
|
|
250
|
+
"",
|
|
251
|
+
"tickets.columns",
|
|
252
|
+
...rows.columns.map(row),
|
|
253
|
+
"",
|
|
254
|
+
"tickets.fields",
|
|
255
|
+
...rows.fields.map(row),
|
|
173
256
|
];
|
|
174
|
-
if (extra.length)
|
|
175
|
-
out.push("", ...extra);
|
|
176
|
-
return out;
|
|
177
257
|
}
|
|
178
258
|
/** What each issue's fields should hold, and which writes get them there.
|
|
179
259
|
* A card's Session is an Actions run's page, which `runPage` gives for its
|
|
@@ -410,9 +490,12 @@ export async function main(argv, deps) {
|
|
|
410
490
|
if (argv[0] === "check") {
|
|
411
491
|
const found = await boardOps.read();
|
|
412
492
|
const number = await projectNumber(deps);
|
|
413
|
-
for (const line of boardReport(number, found, config, settings))
|
|
493
|
+
for (const line of boardReport(number, found, config, settings, d.paint))
|
|
414
494
|
d.out(line);
|
|
415
|
-
|
|
495
|
+
const rows = boardRows(found.fields, config, settings);
|
|
496
|
+
return [...rows.columns, ...rows.fields].some((r) => r.state === "fail")
|
|
497
|
+
? 1
|
|
498
|
+
: 0;
|
|
416
499
|
}
|
|
417
500
|
if (argv[0] === "apply") {
|
|
418
501
|
const input = option(argv, "--in");
|
|
@@ -432,10 +515,10 @@ export async function main(argv, deps) {
|
|
|
432
515
|
return 1;
|
|
433
516
|
}
|
|
434
517
|
}
|
|
435
|
-
/**
|
|
436
|
-
export
|
|
518
|
+
/** The dependencies `run` gives `main`. */
|
|
519
|
+
export function boardDeps(argv) {
|
|
437
520
|
const nowArg = option(argv, "--now");
|
|
438
|
-
return
|
|
521
|
+
return {
|
|
439
522
|
open: async (settings, target) => {
|
|
440
523
|
const { tickets } = await openTickets(settings, target);
|
|
441
524
|
return {
|
|
@@ -450,5 +533,10 @@ export async function run(argv) {
|
|
|
450
533
|
readFile: (path) => readFileSync(path, "utf8"),
|
|
451
534
|
writeFile: (path, text) => writeFileSync(path, text),
|
|
452
535
|
settings: () => loadSettings(),
|
|
453
|
-
|
|
536
|
+
paint: painter(colorOn()),
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
/** `factory board collect` and `factory board apply`. */
|
|
540
|
+
export async function run(argv) {
|
|
541
|
+
return main(argv, boardDeps(argv));
|
|
454
542
|
}
|
package/dist/cli.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
//
|
|
5
5
|
// factory COMMAND [ARGS]
|
|
6
6
|
//
|
|
7
|
-
// An unknown command, or none, prints the
|
|
7
|
+
// An unknown command, or none, prints the commands a person runs and exits 2.
|
|
8
8
|
const TICKET_STEPS = [
|
|
9
9
|
"refining",
|
|
10
10
|
"waiting",
|
|
@@ -284,14 +284,77 @@ export const COMMANDS = [
|
|
|
284
284
|
run: async () => (await import("./guard.mjs")).run("ticket-text"),
|
|
285
285
|
},
|
|
286
286
|
];
|
|
287
|
+
/** The commands a person runs, in the groups and words of docs/cli.md. */
|
|
288
|
+
const USAGE = [
|
|
289
|
+
[
|
|
290
|
+
"Setting up",
|
|
291
|
+
[
|
|
292
|
+
["init", "Set a repository up, or turn a part on or off"],
|
|
293
|
+
[
|
|
294
|
+
"sync [--check]",
|
|
295
|
+
"Write the factory's files from your settings, or check they match",
|
|
296
|
+
],
|
|
297
|
+
["config check", "Check your settings"],
|
|
298
|
+
["board check", "See how the factory reads your board"],
|
|
299
|
+
["doctor", "Check everything, when something seems off"],
|
|
300
|
+
],
|
|
301
|
+
],
|
|
302
|
+
[
|
|
303
|
+
"Every day",
|
|
304
|
+
[
|
|
305
|
+
["status [--watch]", "Each ticket's state and which session is on it"],
|
|
306
|
+
["build N", "Build ticket N in the cloud"],
|
|
307
|
+
["pr watch N", "Wait until pull request N needs you"],
|
|
308
|
+
],
|
|
309
|
+
],
|
|
310
|
+
[
|
|
311
|
+
"Now and then",
|
|
312
|
+
[
|
|
313
|
+
["config get KEY", "Print one setting in effect"],
|
|
314
|
+
["config explain", "Print every setting in effect, defaults included"],
|
|
315
|
+
["plugins [ROLE]", "List the plugins the factory uses, by role"],
|
|
316
|
+
["site compare", "Picture a website's pages before and after a change"],
|
|
317
|
+
["site stop", "End the sites compare --keep left running"],
|
|
318
|
+
["remove", "Take the factory out of this repository"],
|
|
319
|
+
],
|
|
320
|
+
],
|
|
321
|
+
[
|
|
322
|
+
"Presets",
|
|
323
|
+
[
|
|
324
|
+
["preset add NAME", "Follow a preset"],
|
|
325
|
+
["preset remove NAME", "Stop following one"],
|
|
326
|
+
["preset choices", "See where two presets disagree, and choose"],
|
|
327
|
+
[
|
|
328
|
+
"preset choose KEY PRESET",
|
|
329
|
+
"Record one of those choices without questions",
|
|
330
|
+
],
|
|
331
|
+
["preset check", "Check a preset's own package before publishing it"],
|
|
332
|
+
["preset changes REF", "See what a preset update changed since REF"],
|
|
333
|
+
],
|
|
334
|
+
],
|
|
335
|
+
[
|
|
336
|
+
"Your repository's commands",
|
|
337
|
+
[
|
|
338
|
+
["gate", "Run the commands under commands.gate"],
|
|
339
|
+
["test-one FILE [NAME]", "Run one test file, or one test in it"],
|
|
340
|
+
["end-to-end FILE", "Run one end-to-end spec"],
|
|
341
|
+
["specs check", "Check your written specs"],
|
|
342
|
+
["default-branch", "Print the default branch's name"],
|
|
343
|
+
],
|
|
344
|
+
],
|
|
345
|
+
];
|
|
346
|
+
const NAME_WIDTH = 21;
|
|
287
347
|
export function usage() {
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
"
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
348
|
+
const lines = ["Usage: factory COMMAND"];
|
|
349
|
+
for (const [group, commands] of USAGE) {
|
|
350
|
+
lines.push("", group);
|
|
351
|
+
for (const [name, summary] of commands)
|
|
352
|
+
lines.push(...(name.length < NAME_WIDTH
|
|
353
|
+
? [` ${name.padEnd(NAME_WIDTH)}${summary}`]
|
|
354
|
+
: [` ${name}`, ` ${" ".repeat(NAME_WIDTH)}${summary}`]));
|
|
355
|
+
}
|
|
356
|
+
lines.push("", 'The commands skills, hooks, and workflows run are under "Run for you" in docs/cli.md.');
|
|
357
|
+
return lines.join("\n");
|
|
295
358
|
}
|
|
296
359
|
/** The command `argv` names, the longest match first, with the arguments
|
|
297
360
|
* left after its words; null when none matches. */
|
|
@@ -310,7 +373,10 @@ export async function main(argv) {
|
|
|
310
373
|
// `guard` alone runs both guards, but `guard WORD` with a word that is
|
|
311
374
|
// not a guard is a mistake, not a request for both.
|
|
312
375
|
if (!found || (found.command.words.join(" ") === "guard" && found.rest[0])) {
|
|
313
|
-
|
|
376
|
+
const asked = argv.length > 0 && argv[0] !== "--help" && argv[0] !== "-h";
|
|
377
|
+
console.error(asked
|
|
378
|
+
? `factory has no command "${argv.join(" ")}".\n\n${usage()}`
|
|
379
|
+
: usage());
|
|
314
380
|
return 2;
|
|
315
381
|
}
|
|
316
382
|
return (await found.command.run(found.rest)) ?? 0;
|
|
@@ -106,7 +106,7 @@ export const githubCodeHostSetup = {
|
|
|
106
106
|
return [
|
|
107
107
|
{
|
|
108
108
|
state: "pass",
|
|
109
|
-
text: `Signed in
|
|
109
|
+
text: `Signed in as ${await c.opened.codeHost.signedInAs()}`,
|
|
110
110
|
},
|
|
111
111
|
];
|
|
112
112
|
}
|
|
@@ -114,7 +114,7 @@ export const githubCodeHostSetup = {
|
|
|
114
114
|
return [
|
|
115
115
|
{
|
|
116
116
|
state: "fail",
|
|
117
|
-
text: "Signed in
|
|
117
|
+
text: "Signed in",
|
|
118
118
|
fix: e instanceof Error ? e.message : String(e),
|
|
119
119
|
},
|
|
120
120
|
];
|
|
@@ -33,7 +33,6 @@ export type SuggestDeps = {
|
|
|
33
33
|
agent: Agent;
|
|
34
34
|
/** The agent's registered label, which every line names it by. */
|
|
35
35
|
label: string;
|
|
36
|
-
hasCommand: (name: string) => boolean;
|
|
37
36
|
};
|
|
38
37
|
/** The board's columns, as init's first line about them says. */
|
|
39
38
|
export declare const boardLine: (board: number, columns: readonly string[]) => string;
|
package/dist/columns-suggest.mjs
CHANGED
|
@@ -108,8 +108,8 @@ function shown(key, mapping) {
|
|
|
108
108
|
if (c !== "none")
|
|
109
109
|
return c.column;
|
|
110
110
|
if (key === "ready")
|
|
111
|
-
return "
|
|
112
|
-
return `
|
|
111
|
+
return "none";
|
|
112
|
+
return `none, shows in ${columnFor(STATE_KEYS[key], toColumns(mapping))}`;
|
|
113
113
|
}
|
|
114
114
|
/** The table of each state's column, as `factory board check` words it. */
|
|
115
115
|
export function table(mapping) {
|
|
@@ -190,12 +190,6 @@ async function changeSome(d, mapping, columns, fromBoard) {
|
|
|
190
190
|
export async function suggestColumns(d, o) {
|
|
191
191
|
d.out("");
|
|
192
192
|
d.out(boardLine(o.board, o.columns));
|
|
193
|
-
if (!d.agent.installed(d.hasCommand)) {
|
|
194
|
-
d.out(`Matching them to the factory's six states needs ${d.label}, which is not installed.`);
|
|
195
|
-
d.out(`Install it and run factory init again, or ${AGAIN_OR_WRITE}`);
|
|
196
|
-
d.out("Nothing changed.");
|
|
197
|
-
return 1;
|
|
198
|
-
}
|
|
199
193
|
d.out(`Asking ${d.label} which of them shows each of the factory's six states...`);
|
|
200
194
|
const got = await d.agent.answer({
|
|
201
195
|
prompt: prompt(o.columns, o.fromBoard),
|
package/dist/commands.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Paint } from "./lib/color.mts";
|
|
1
2
|
import { type Settings } from "./config.mts";
|
|
2
3
|
export type Deps = {
|
|
3
4
|
/** The repository's root, where every command runs. */
|
|
@@ -8,6 +9,7 @@ export type Deps = {
|
|
|
8
9
|
exec: (command: string, cwd: string, env: Record<string, string>) => number;
|
|
9
10
|
out: (line: string) => void;
|
|
10
11
|
err: (line: string) => void;
|
|
12
|
+
paint?: Paint;
|
|
11
13
|
};
|
|
12
14
|
/** `argv` is the command's name, then its arguments. */
|
|
13
15
|
export declare function main(argv: string[], d: Deps): Promise<number>;
|
package/dist/commands.mjs
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// environment, `end-to-end` FILE, and the spec check DO_NOT_TRACK=1. An
|
|
12
12
|
// argument a command does not know prints its usage and exits 2.
|
|
13
13
|
import { spawnSync } from "node:child_process";
|
|
14
|
+
import { colorOn, painter, plain } from "./lib/color.mjs";
|
|
14
15
|
import { defaultDeps, loadSettings, repoRoot, SETTINGS_FILE, SettingsError, } from "./config.mjs";
|
|
15
16
|
const USAGE = {
|
|
16
17
|
gate: "Usage: factory gate",
|
|
@@ -67,6 +68,15 @@ export async function main(argv, d) {
|
|
|
67
68
|
d.err(e.message);
|
|
68
69
|
return 1;
|
|
69
70
|
}
|
|
71
|
+
const paint = d.paint ?? plain;
|
|
72
|
+
/** The command's own closing line, after the output passed through. */
|
|
73
|
+
const ended = (status, passed, failed) => {
|
|
74
|
+
if (status === 0)
|
|
75
|
+
d.out(`${paint("green", "✓")} ${passed}`);
|
|
76
|
+
else
|
|
77
|
+
d.err(`${paint("red", "✗")} ${failed}`);
|
|
78
|
+
return status;
|
|
79
|
+
};
|
|
70
80
|
const notSet = (key) => {
|
|
71
81
|
d.err(`commands.${key} is not set`);
|
|
72
82
|
return 1;
|
|
@@ -78,38 +88,37 @@ export async function main(argv, d) {
|
|
|
78
88
|
}
|
|
79
89
|
for (const command of s.commands.gate) {
|
|
80
90
|
d.out(`$ ${command}`);
|
|
81
|
-
if (d.exec(command, d.root, {}) !== 0)
|
|
82
|
-
|
|
83
|
-
return 1;
|
|
84
|
-
}
|
|
91
|
+
if (d.exec(command, d.root, {}) !== 0)
|
|
92
|
+
return ended(1, "", `The gate failed on: ${command}`);
|
|
85
93
|
}
|
|
86
|
-
return 0;
|
|
94
|
+
return ended(0, "Every gate command passed.", "");
|
|
87
95
|
}
|
|
88
96
|
if (name === "test-one") {
|
|
89
97
|
if (s.commands.testOne === null)
|
|
90
98
|
return notSet("test-one");
|
|
91
99
|
const [file, test = ""] = args;
|
|
92
|
-
return d.exec(s.commands.testOne, d.root, { FILE: file, NAME: test });
|
|
100
|
+
return ended(d.exec(s.commands.testOne, d.root, { FILE: file, NAME: test }), "The test passed.", "The test failed.");
|
|
93
101
|
}
|
|
94
102
|
if (name === "end-to-end") {
|
|
95
103
|
const { file, times } = e2e;
|
|
96
104
|
const command = s.commands.endToEnd;
|
|
97
105
|
if (command === null)
|
|
98
106
|
return notSet("end-to-end");
|
|
107
|
+
const test = (status) => ended(status, "The test passed.", "The test failed.");
|
|
99
108
|
if (times === null)
|
|
100
|
-
return d.exec(command, d.root, { FILE: file });
|
|
109
|
+
return test(d.exec(command, d.root, { FILE: file }));
|
|
101
110
|
for (let run = 1; run <= times; run++)
|
|
102
111
|
if (d.exec(command, d.root, { FILE: file }) !== 0) {
|
|
103
112
|
d.err(`failed on run ${run} of ${times}`);
|
|
104
|
-
return 1;
|
|
113
|
+
return test(1);
|
|
105
114
|
}
|
|
106
|
-
return 0;
|
|
115
|
+
return test(0);
|
|
107
116
|
}
|
|
108
117
|
if (s.specCheck === null) {
|
|
109
118
|
d.out("specs are off");
|
|
110
119
|
return 0;
|
|
111
120
|
}
|
|
112
|
-
return d.exec(s.specCheck, d.root, { DO_NOT_TRACK: "1" });
|
|
121
|
+
return ended(d.exec(s.specCheck, d.root, { DO_NOT_TRACK: "1" }), "The specs check passed.", "The specs check failed.");
|
|
113
122
|
}
|
|
114
123
|
/** `factory gate`, `factory test-one`, `factory end-to-end`, and
|
|
115
124
|
* `factory specs check`, the last as `specs-check`. */
|
|
@@ -120,10 +129,12 @@ export async function run(argv) {
|
|
|
120
129
|
settings: () => loadSettings(defaultDeps(root)),
|
|
121
130
|
exec: (command, cwd, env) => spawnSync("bash", ["-c", command], {
|
|
122
131
|
cwd,
|
|
123
|
-
|
|
132
|
+
// npm 11 prints a notice line for every script and npx it runs.
|
|
133
|
+
env: { npm_config_loglevel: "warn", ...process.env, ...env },
|
|
124
134
|
stdio: ["ignore", "inherit", "inherit"],
|
|
125
135
|
}).status ?? 1,
|
|
126
136
|
out: (line) => console.log(line),
|
|
127
137
|
err: (line) => console.error(line),
|
|
138
|
+
paint: painter(colorOn()),
|
|
128
139
|
});
|
|
129
140
|
}
|
package/dist/config.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { type Paint } from "./lib/color.mts";
|
|
3
|
+
import { type FieldMapping } from "./ticket-fields.mts";
|
|
2
4
|
import { type Built } from "./tool-names.mts";
|
|
3
5
|
import { type Watch, type Columns, type StateKey } from "./lib/work-status.mts";
|
|
4
6
|
export declare class SettingsError extends Error {
|
|
@@ -52,6 +54,10 @@ export type Settings = {
|
|
|
52
54
|
columns: Record<StateKey, readonly string[] | null>;
|
|
53
55
|
/** The board's field for each of three the sync writes, null for none. */
|
|
54
56
|
fields: Record<FieldKey, string | null>;
|
|
57
|
+
/** Each ticket-side key under `tickets.fields`, the four factory fields
|
|
58
|
+
* first and then any heading of the repository's own, with the ticket
|
|
59
|
+
* field that holds it, or null for the description. */
|
|
60
|
+
ticketFields: FieldMapping;
|
|
55
61
|
};
|
|
56
62
|
/** Where pull requests are. */
|
|
57
63
|
codeHost: {
|
|
@@ -167,6 +173,8 @@ export declare function siteLines(site: Site): string[];
|
|
|
167
173
|
* above `from` that holds `.git`, or `from` itself when none does. */
|
|
168
174
|
export declare function repoRoot(from?: string): string;
|
|
169
175
|
export declare const SETTINGS_FILE = ".claude/factory.yaml";
|
|
176
|
+
/** A key under `tickets.fields` naming a heading of the repository's own. */
|
|
177
|
+
export declare const OWN_HEADING: RegExp;
|
|
170
178
|
/** The settings with every default filled in. Throws a SettingsError naming
|
|
171
179
|
* the key on anything unsound. `exists` says whether a path from the root
|
|
172
180
|
* exists, for the plugins' files. */
|
|
@@ -185,6 +193,7 @@ export type Deps = {
|
|
|
185
193
|
loadYaml: () => Promise<YamlLoad>;
|
|
186
194
|
out: (line: string) => void;
|
|
187
195
|
err: (line: string) => void;
|
|
196
|
+
paint?: Paint;
|
|
188
197
|
/** Where the settings come from when every command reads the lock:
|
|
189
198
|
* `check` stops on a stale one. Unset, they are resolved from the files
|
|
190
199
|
* the lock is made from. */
|