@davidbyoung/software-factory 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/board.mjs +1 -3
- package/dist/cli.mjs +9 -0
- package/dist/code-host/github.d.mts +1 -1
- package/dist/code-host/github.mjs +29 -2
- package/dist/code-host/types.d.mts +16 -1
- package/dist/code-host/types.mjs +8 -0
- package/dist/columns-suggest.d.mts +25 -5
- package/dist/columns-suggest.mjs +117 -21
- package/dist/commands.d.mts +3 -2
- package/dist/commands.mjs +16 -2
- package/dist/config.d.mts +16 -3
- package/dist/config.mjs +102 -22
- package/dist/doctor.mjs +1 -2
- package/dist/explain.mjs +7 -1
- package/dist/init.d.mts +8 -0
- package/dist/init.mjs +83 -22
- package/dist/lib/gh.d.mts +6 -0
- package/dist/lib/gh.mjs +11 -1
- package/dist/lib/listed.d.mts +3 -2
- package/dist/lib/listed.mjs +5 -4
- package/dist/poller.d.mts +1 -1
- package/dist/poller.mjs +9 -6
- package/dist/pr.mjs +9 -1
- package/dist/ticket.d.mts +3 -0
- package/dist/ticket.mjs +27 -1
- package/docs/builds.md +26 -13
- package/docs/cli.md +30 -27
- package/docs/configuration.md +187 -35
- package/docs/existing-repo.md +47 -26
- package/docs/github/by-hand.md +13 -1
- package/docs/github/setup.md +9 -2
- package/docs/presets.md +15 -3
- package/docs/updating.md +129 -2
- package/docs/workflow.md +1 -1
- package/package.json +1 -1
- package/settings.schema.json +14 -9
- package/skills/factory-build/SKILL.md +39 -7
- package/skills/factory-deps/SKILL.md +6 -4
package/dist/board.mjs
CHANGED
|
@@ -172,9 +172,7 @@ export function boardRows(fields, cfg, settings) {
|
|
|
172
172
|
key,
|
|
173
173
|
text: `${joined}: no such column on the board${names.length > 1 ? `: ${missing.join(", ")}` : ""}`,
|
|
174
174
|
};
|
|
175
|
-
if (key === "ready" &&
|
|
176
|
-
ready !== DEFAULT_COLUMNS.Ready[0] &&
|
|
177
|
-
settings.builds.trigger === "own-server")
|
|
175
|
+
if (key === "ready" && settings.builds.trigger === "own-server")
|
|
178
176
|
return {
|
|
179
177
|
state: "unknown",
|
|
180
178
|
key,
|
package/dist/cli.mjs
CHANGED
|
@@ -22,6 +22,7 @@ const TICKET_STEPS = [
|
|
|
22
22
|
"open",
|
|
23
23
|
"label",
|
|
24
24
|
"link",
|
|
25
|
+
"branch",
|
|
25
26
|
"blockers",
|
|
26
27
|
"block",
|
|
27
28
|
"unblock",
|
|
@@ -34,6 +35,7 @@ const PR_STEPS = [
|
|
|
34
35
|
"resolve",
|
|
35
36
|
"ready",
|
|
36
37
|
"closes",
|
|
38
|
+
"for-branch",
|
|
37
39
|
"comments",
|
|
38
40
|
"comment",
|
|
39
41
|
"comment-view",
|
|
@@ -85,6 +87,7 @@ const PR_ARGS = {
|
|
|
85
87
|
label: "N --add LABEL | --remove LABEL",
|
|
86
88
|
"review-pending": "N REVIEW",
|
|
87
89
|
conflicts: "",
|
|
90
|
+
"for-branch": "BRANCH",
|
|
88
91
|
uncovered: "[BASE] [LCOV]",
|
|
89
92
|
};
|
|
90
93
|
export const COMMANDS = [
|
|
@@ -203,6 +206,11 @@ export const COMMANDS = [
|
|
|
203
206
|
args: "",
|
|
204
207
|
run: async (argv) => (await import("./commands.mjs")).run(["specs-check", ...argv]),
|
|
205
208
|
},
|
|
209
|
+
{
|
|
210
|
+
words: ["specs", "change-name"],
|
|
211
|
+
args: "N",
|
|
212
|
+
run: async (argv) => (await import("./commands.mjs")).run(["specs-change-name", ...argv]),
|
|
213
|
+
},
|
|
206
214
|
{
|
|
207
215
|
words: ["default-branch"],
|
|
208
216
|
args: "",
|
|
@@ -339,6 +347,7 @@ const USAGE = [
|
|
|
339
347
|
["test-one FILE [NAME]", "Run one test file, or one test in it"],
|
|
340
348
|
["end-to-end FILE", "Run one end-to-end spec"],
|
|
341
349
|
["specs check", "Check your written specs"],
|
|
350
|
+
["specs change-name N", "Print the name of ticket N's spec change"],
|
|
342
351
|
["default-branch", "Print the default branch's name"],
|
|
343
352
|
],
|
|
344
353
|
],
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
// GitHub as the code host: pull requests, reviews, checks, and commit
|
|
2
|
+
// statuses. With `src/tickets/` and `src/runner/`, this is the only code
|
|
3
|
+
// that calls GitHub: every command reaches a pull request through here.
|
|
4
|
+
//
|
|
5
|
+
// GitHub serves a pull request's conversation comments and labels from its
|
|
6
|
+
// issues API, so those calls are here too, not in the ticket adapter.
|
|
7
|
+
import { GhError } from "../lib/gh.mjs";
|
|
1
8
|
import { NotFoundError } from "../tickets/types.mjs";
|
|
2
9
|
import { statusOf } from "../tickets/transport.mjs";
|
|
3
|
-
import { NeedsScopeError } from "./types.mjs";
|
|
10
|
+
import { NeedsScopeError, NotSignedInError } from "./types.mjs";
|
|
4
11
|
/** What a check wrote about its result: its title and its summary. */
|
|
5
12
|
const reportOf = (output) => [output?.title, output?.summary].filter(Boolean).join("\n") || undefined;
|
|
6
13
|
const endOf = (end) => ({
|
|
@@ -214,6 +221,19 @@ export function githubCodeHost(o) {
|
|
|
214
221
|
const open = await t.rest("GET", `${API}/pulls?head=${owner}:${branch}&state=open`);
|
|
215
222
|
return open[0]?.number ?? null;
|
|
216
223
|
},
|
|
224
|
+
async lastForBranch(branch) {
|
|
225
|
+
const [newest] = await t.rest("GET", `${API}/pulls?head=${owner}:${encodeURIComponent(branch)}&state=all&sort=created&direction=desc&per_page=1`);
|
|
226
|
+
if (!newest)
|
|
227
|
+
return null;
|
|
228
|
+
return {
|
|
229
|
+
number: newest.number,
|
|
230
|
+
state: newest.state === "open"
|
|
231
|
+
? "open"
|
|
232
|
+
: newest.merged_at
|
|
233
|
+
? "merged"
|
|
234
|
+
: "closed",
|
|
235
|
+
};
|
|
236
|
+
},
|
|
217
237
|
forCommit: async (sha) => (await t.rest("GET", `${API}/commits/${sha}/pulls`)).map(({ number, state }) => ({ number, state })),
|
|
218
238
|
files: async (n) => (await list(`${API}/pulls/${n}/files?per_page=100`)).map((f) => ({
|
|
219
239
|
path: f.filename,
|
|
@@ -348,7 +368,14 @@ export function githubCodeHost(o) {
|
|
|
348
368
|
},
|
|
349
369
|
address: (n) => `https://github.com/${o.repository}/pull/${n}`,
|
|
350
370
|
async signedInAs() {
|
|
351
|
-
|
|
371
|
+
try {
|
|
372
|
+
return (await t.rest("GET", "user")).login;
|
|
373
|
+
}
|
|
374
|
+
catch (e) {
|
|
375
|
+
if (statusOf(e) === 401 || (e instanceof GhError && e.exitCode === 4))
|
|
376
|
+
throw new NotSignedInError();
|
|
377
|
+
throw e;
|
|
378
|
+
}
|
|
352
379
|
},
|
|
353
380
|
async tokenOwner(token) {
|
|
354
381
|
const response = await (o.fetch ?? fetch)("https://api.github.com/user", {
|
|
@@ -88,6 +88,12 @@ export type NewStatus = {
|
|
|
88
88
|
description: string;
|
|
89
89
|
link?: string;
|
|
90
90
|
};
|
|
91
|
+
/** A pull request as `lastForBranch` finds it: `closed` is closed without
|
|
92
|
+
* merging. */
|
|
93
|
+
export type LastPull = {
|
|
94
|
+
number: number;
|
|
95
|
+
state: "open" | "merged" | "closed";
|
|
96
|
+
};
|
|
91
97
|
/** A pull request to open: from the `head` branch into the `base` branch. */
|
|
92
98
|
export type NewPull = {
|
|
93
99
|
title: string;
|
|
@@ -112,6 +118,9 @@ export type CodeHost = {
|
|
|
112
118
|
listOpen(): Promise<Pull[]>;
|
|
113
119
|
/** The open pull request from this branch, or null. */
|
|
114
120
|
forBranch(branch: string): Promise<number | null>;
|
|
121
|
+
/** The newest pull request from this branch, open or not, or null when
|
|
122
|
+
* none came from it. */
|
|
123
|
+
lastForBranch(branch: string): Promise<LastPull | null>;
|
|
115
124
|
/** The pull requests that hold the commit, open or not. */
|
|
116
125
|
forCommit(sha: string): Promise<{
|
|
117
126
|
number: number;
|
|
@@ -172,7 +181,8 @@ export type CodeHost = {
|
|
|
172
181
|
linking(skip?: number[]): Promise<PullRequest[]>;
|
|
173
182
|
/** The address of a pull request's page. */
|
|
174
183
|
address(pull: number): string;
|
|
175
|
-
/** Who the code host's command-line tool is signed in as.
|
|
184
|
+
/** Who the code host's command-line tool is signed in as. Rejects with
|
|
185
|
+
* NotSignedInError when it is signed in as nobody, or refused. */
|
|
176
186
|
signedInAs(): Promise<string>;
|
|
177
187
|
/** The account a token belongs to, and its scopes: null when the code
|
|
178
188
|
* host does not say, as for a token with fine-grained permissions.
|
|
@@ -200,6 +210,11 @@ export type CodeHost = {
|
|
|
200
210
|
/** What a token for the factory's jobs may need to do: push a branch,
|
|
201
211
|
* change a workflow's file, and write the board. */
|
|
202
212
|
export type TokenNeed = "push" | "workflows" | "board";
|
|
213
|
+
/** The code host's CLI is signed in as nobody, or its sign-in is
|
|
214
|
+
* refused. */
|
|
215
|
+
export declare class NotSignedInError extends Error {
|
|
216
|
+
constructor();
|
|
217
|
+
}
|
|
203
218
|
/** A call the signed-in account's sign-in lacks the permission for. `fix`
|
|
204
219
|
* is the command that asks for it. */
|
|
205
220
|
export declare class NeedsScopeError extends Error {
|
package/dist/code-host/types.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/** The code host's CLI is signed in as nobody, or its sign-in is
|
|
2
|
+
* refused. */
|
|
3
|
+
export class NotSignedInError extends Error {
|
|
4
|
+
constructor() {
|
|
5
|
+
super("The code host's command-line tool is not signed in.");
|
|
6
|
+
this.name = "NotSignedInError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
1
9
|
/** A call the signed-in account's sign-in lacks the permission for. `fix`
|
|
2
10
|
* is the command that asks for it. */
|
|
3
11
|
export class NeedsScopeError extends Error {
|
|
@@ -24,9 +24,12 @@ export declare function check(answer: unknown, columns: readonly string[], fromB
|
|
|
24
24
|
export declare function toColumns(mapping: Mapping): Columns;
|
|
25
25
|
/** The table of each state's column, as `factory board check` words it. */
|
|
26
26
|
export declare function table(mapping: Mapping): string[];
|
|
27
|
-
/** What `Yes` writes under `tickets.columns`:
|
|
28
|
-
*
|
|
27
|
+
/** What `Yes` writes under `tickets.columns`: every state, a column init
|
|
28
|
+
* adds by its factory name. */
|
|
29
29
|
export declare function written(mapping: Mapping): [StateKey, string][];
|
|
30
|
+
/** Every state written with the factory's own name: a board init creates,
|
|
31
|
+
* one with no columns, and the answer No. */
|
|
32
|
+
export declare const FACTORY_LINES: [StateKey, string][];
|
|
30
33
|
export type SuggestDeps = {
|
|
31
34
|
ask: Ask;
|
|
32
35
|
out: (line: string) => void;
|
|
@@ -36,16 +39,33 @@ export type SuggestDeps = {
|
|
|
36
39
|
};
|
|
37
40
|
/** The board's columns, as init's first line about them says. */
|
|
38
41
|
export declare const boardLine: (board: number, columns: readonly string[]) => string;
|
|
39
|
-
/** The column step: the mapping's `tickets.columns` lines to write,
|
|
40
|
-
*
|
|
42
|
+
/** The column step: the mapping's `tickets.columns` lines to write, or 1
|
|
43
|
+
* when init stops. */
|
|
41
44
|
export declare function suggestColumns(d: SuggestDeps, o: {
|
|
42
45
|
board: number;
|
|
43
46
|
columns: readonly string[];
|
|
44
47
|
fromBoard: boolean;
|
|
45
|
-
}): Promise<[StateKey, string][] |
|
|
48
|
+
}): Promise<[StateKey, string][] | 1>;
|
|
46
49
|
/** A ready column, asked for when builds from the board turn on and the
|
|
47
50
|
* settings give ready none: one of the board's, or null to add Ready. */
|
|
48
51
|
export declare function askReady(d: Pick<SuggestDeps, "ask" | "out">, o: {
|
|
49
52
|
columns: readonly string[];
|
|
50
53
|
current: Columns;
|
|
51
54
|
}): Promise<string | null>;
|
|
55
|
+
/** A board with a column of each of the factory's names: init says so,
|
|
56
|
+
* shows them as the board spells them, and writes them. */
|
|
57
|
+
export declare function everyColumn(d: Pick<SuggestDeps, "out">, o: {
|
|
58
|
+
board: number;
|
|
59
|
+
columns: readonly string[];
|
|
60
|
+
}): [StateKey, string][];
|
|
61
|
+
/** A re-run's column step for a block that leaves states out. Each state
|
|
62
|
+
* left out takes the board's column of its factory name, when the board
|
|
63
|
+
* has one no written state names, since that is the column the factory
|
|
64
|
+
* read for it; any other is asked for. The lines to write for the states
|
|
65
|
+
* left out. */
|
|
66
|
+
export declare function fillColumns(d: Pick<SuggestDeps, "ask" | "out">, o: {
|
|
67
|
+
board: number;
|
|
68
|
+
columns: readonly string[];
|
|
69
|
+
written: Partial<Record<StateKey, readonly string[] | null>>;
|
|
70
|
+
fromBoard: boolean;
|
|
71
|
+
}): Promise<[StateKey, string][]>;
|
package/dist/columns-suggest.mjs
CHANGED
|
@@ -119,18 +119,20 @@ export function table(mapping) {
|
|
|
119
119
|
...KEYS.map((k) => pad(k) + shown(k, mapping)),
|
|
120
120
|
];
|
|
121
121
|
}
|
|
122
|
-
/** What `Yes` writes under `tickets.columns`:
|
|
123
|
-
*
|
|
122
|
+
/** What `Yes` writes under `tickets.columns`: every state, a column init
|
|
123
|
+
* adds by its factory name. */
|
|
124
124
|
export function written(mapping) {
|
|
125
|
-
return KEYS.
|
|
125
|
+
return KEYS.map((k) => {
|
|
126
126
|
const c = mapping[k];
|
|
127
|
-
|
|
128
|
-
return [];
|
|
129
|
-
if (c === "none")
|
|
130
|
-
return [[k, "none"]];
|
|
131
|
-
return sameName(c.column, STATE_KEYS[k]) ? [] : [[k, c.column]];
|
|
127
|
+
return [k, c === "none" ? "none" : c === "add" ? STATE_KEYS[k] : c.column];
|
|
132
128
|
});
|
|
133
129
|
}
|
|
130
|
+
/** Every state written with the factory's own name: a board init creates,
|
|
131
|
+
* one with no columns, and the answer No. */
|
|
132
|
+
export const FACTORY_LINES = KEYS.map((k) => [
|
|
133
|
+
k,
|
|
134
|
+
STATE_KEYS[k],
|
|
135
|
+
]);
|
|
134
136
|
const AGAIN_OR_WRITE = "write tickets.columns in .claude/factory.yaml yourself.";
|
|
135
137
|
/** The board's columns, as init's first line about them says. */
|
|
136
138
|
export const boardLine = (board, columns) => `Board ${board} has the columns ${listed(columns)}.`;
|
|
@@ -139,6 +141,14 @@ function showing(name, key, current) {
|
|
|
139
141
|
return (KEYS.find((k) => k !== key &&
|
|
140
142
|
(current[STATE_KEYS[k]] ?? []).some((c) => sameName(c, name))) ?? null);
|
|
141
143
|
}
|
|
144
|
+
/** The "No column" choice for `key`, saying where its tickets show with
|
|
145
|
+
* `columns` and no column of its own, or null where it has none. */
|
|
146
|
+
function noColumnFor(key, columns, fromBoard) {
|
|
147
|
+
if (key === "backlog" || (key === "ready" && fromBoard))
|
|
148
|
+
return null;
|
|
149
|
+
const others = { ...columns, [STATE_KEYS[key]]: null };
|
|
150
|
+
return NO_COLUMN[key](columnFor(STATE_KEYS[key], others));
|
|
151
|
+
}
|
|
142
152
|
/** Asks which column shows `key`, with `current` selected. */
|
|
143
153
|
async function pickColumn(d, key, columns, current, noColumn) {
|
|
144
154
|
const factory = STATE_KEYS[key];
|
|
@@ -154,26 +164,30 @@ async function pickColumn(d, key, columns, current, noColumn) {
|
|
|
154
164
|
}
|
|
155
165
|
const valueOf = (c) => c === "none" ? NONE : c === "add" ? ADD : `column:${c.column}`;
|
|
156
166
|
const choiceOf = (v) => v === NONE ? "none" : v === ADD ? "add" : { column: v.slice(7) };
|
|
157
|
-
/** "Change some": the states you pick, then a column for each,
|
|
158
|
-
* two states share one.
|
|
159
|
-
|
|
167
|
+
/** "Change some": the states you pick, of `keys`, then a column for each,
|
|
168
|
+
* until no two states share one. `written` holds the states the settings
|
|
169
|
+
* already give, by their whole lists, which the mapping shows joined. */
|
|
170
|
+
async function changeSome(d, mapping, columns, fromBoard, keys = KEYS, written = {}) {
|
|
171
|
+
const shownBy = (m) => {
|
|
172
|
+
const out = toColumns(m);
|
|
173
|
+
for (const [k, list] of Object.entries(written))
|
|
174
|
+
out[STATE_KEYS[k]] = list;
|
|
175
|
+
return out;
|
|
176
|
+
};
|
|
160
177
|
const m = { ...mapping };
|
|
161
178
|
let picked = [];
|
|
162
179
|
for (;;) {
|
|
163
|
-
picked = await d.ask.checkbox("Which states do you want to change?",
|
|
180
|
+
picked = await d.ask.checkbox("Which states do you want to change?", keys.map((k) => ({
|
|
164
181
|
name: `${k}: ${shown(k, m)}`,
|
|
165
182
|
value: k,
|
|
166
183
|
checked: picked.includes(k),
|
|
167
184
|
})));
|
|
168
185
|
let clash = false;
|
|
169
|
-
for (const key of
|
|
170
|
-
const
|
|
171
|
-
const noColumn = key === "backlog" || (key === "ready" && fromBoard)
|
|
172
|
-
? null
|
|
173
|
-
: NO_COLUMN[key](columnFor(STATE_KEYS[key], toColumns(others)));
|
|
186
|
+
for (const key of keys.filter((k) => picked.includes(k))) {
|
|
187
|
+
const noColumn = noColumnFor(key, toColumns(m), fromBoard);
|
|
174
188
|
const choice = choiceOf(await pickColumn(d, key, columns, valueOf(m[key]), noColumn));
|
|
175
189
|
const name = nameOf(key, choice);
|
|
176
|
-
const other = name === null ? null : showing(name, key,
|
|
190
|
+
const other = name === null ? null : showing(name, key, shownBy(m));
|
|
177
191
|
if (other) {
|
|
178
192
|
d.out(`${name} already shows ${other}. Pick another column for ${key}.`);
|
|
179
193
|
clash = true;
|
|
@@ -185,8 +199,8 @@ async function changeSome(d, mapping, columns, fromBoard) {
|
|
|
185
199
|
return m;
|
|
186
200
|
}
|
|
187
201
|
}
|
|
188
|
-
/** The column step: the mapping's `tickets.columns` lines to write,
|
|
189
|
-
*
|
|
202
|
+
/** The column step: the mapping's `tickets.columns` lines to write, or 1
|
|
203
|
+
* when init stops. */
|
|
190
204
|
export async function suggestColumns(d, o) {
|
|
191
205
|
d.out("");
|
|
192
206
|
d.out(boardLine(o.board, o.columns));
|
|
@@ -225,7 +239,7 @@ export async function suggestColumns(d, o) {
|
|
|
225
239
|
if (use === "yes")
|
|
226
240
|
return written(mapping);
|
|
227
241
|
if (use === "no")
|
|
228
|
-
return
|
|
242
|
+
return FACTORY_LINES;
|
|
229
243
|
mapping = await changeSome(d, mapping, o.columns, o.fromBoard);
|
|
230
244
|
}
|
|
231
245
|
}
|
|
@@ -251,3 +265,85 @@ export async function askReady(d, o) {
|
|
|
251
265
|
d.out(`${name} already shows ${other}. Pick another column for ready.`);
|
|
252
266
|
}
|
|
253
267
|
}
|
|
268
|
+
/** A board with a column of each of the factory's names: init says so,
|
|
269
|
+
* shows them as the board spells them, and writes them. */
|
|
270
|
+
export function everyColumn(d, o) {
|
|
271
|
+
const mapping = Object.fromEntries(KEYS.map((k) => [k, { column: onBoard(STATE_KEYS[k], o.columns) }]));
|
|
272
|
+
d.out("");
|
|
273
|
+
d.out(`Board ${o.board} has a column for each of the factory's six states:`);
|
|
274
|
+
d.out("");
|
|
275
|
+
for (const line of table(mapping))
|
|
276
|
+
d.out(line);
|
|
277
|
+
return written(mapping);
|
|
278
|
+
}
|
|
279
|
+
/** A re-run's column step for a block that leaves states out. Each state
|
|
280
|
+
* left out takes the board's column of its factory name, when the board
|
|
281
|
+
* has one no written state names, since that is the column the factory
|
|
282
|
+
* read for it; any other is asked for. The lines to write for the states
|
|
283
|
+
* left out. */
|
|
284
|
+
export async function fillColumns(d, o) {
|
|
285
|
+
const missing = KEYS.filter((k) => !(k in o.written));
|
|
286
|
+
const lists = {
|
|
287
|
+
...o.written,
|
|
288
|
+
};
|
|
289
|
+
const now = () => Object.fromEntries(KEYS.map((k) => [STATE_KEYS[k], lists[k] ?? null]));
|
|
290
|
+
const mapping = {};
|
|
291
|
+
for (const k of KEYS)
|
|
292
|
+
if (k in o.written)
|
|
293
|
+
mapping[k] =
|
|
294
|
+
o.written[k] === null ? "none" : { column: o.written[k].join(", ") };
|
|
295
|
+
const asks = [];
|
|
296
|
+
for (const k of missing) {
|
|
297
|
+
const name = onBoard(STATE_KEYS[k], o.columns);
|
|
298
|
+
const other = name === null ? null : showing(name, k, now());
|
|
299
|
+
if (name !== null && other === null) {
|
|
300
|
+
mapping[k] = { column: name };
|
|
301
|
+
lists[k] = [name];
|
|
302
|
+
}
|
|
303
|
+
else
|
|
304
|
+
asks.push([
|
|
305
|
+
k,
|
|
306
|
+
name === null
|
|
307
|
+
? `board ${o.board} has no ${STATE_KEYS[k]} column`
|
|
308
|
+
: `${name} already shows ${other}`,
|
|
309
|
+
]);
|
|
310
|
+
}
|
|
311
|
+
const lines = (m) => written(m).filter(([k]) => missing.includes(k));
|
|
312
|
+
d.out("");
|
|
313
|
+
if (!asks.length) {
|
|
314
|
+
d.out(`Your settings give no column to ${listed(missing, "or")}.`);
|
|
315
|
+
d.out(`Board ${o.board} has a column of the factory's name for each:`);
|
|
316
|
+
d.out("");
|
|
317
|
+
for (const line of table(mapping))
|
|
318
|
+
d.out(line);
|
|
319
|
+
return lines(mapping);
|
|
320
|
+
}
|
|
321
|
+
for (const [k, why] of asks) {
|
|
322
|
+
d.out(`Your settings give no column to ${k}, and ${why}.`);
|
|
323
|
+
for (;;) {
|
|
324
|
+
const choice = choiceOf(await pickColumn(d, k, o.columns, ADD, noColumnFor(k, now(), o.fromBoard)));
|
|
325
|
+
const name = nameOf(k, choice);
|
|
326
|
+
const other = name === null ? null : showing(name, k, now());
|
|
327
|
+
if (other === null) {
|
|
328
|
+
mapping[k] = choice;
|
|
329
|
+
lists[k] = name === null ? null : [name];
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
d.out(`${name} already shows ${other}. Pick another column for ${k}.`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
let m = mapping;
|
|
336
|
+
for (;;) {
|
|
337
|
+
d.out("");
|
|
338
|
+
for (const line of table(m))
|
|
339
|
+
d.out(line);
|
|
340
|
+
d.out("");
|
|
341
|
+
const use = await d.ask.select("Use these columns?", [
|
|
342
|
+
{ name: "Yes", value: "yes" },
|
|
343
|
+
{ name: "Change some", value: "change" },
|
|
344
|
+
], "yes");
|
|
345
|
+
if (use === "yes")
|
|
346
|
+
return lines(m);
|
|
347
|
+
m = await changeSome(d, m, o.columns, o.fromBoard, missing, o.written);
|
|
348
|
+
}
|
|
349
|
+
}
|
package/dist/commands.d.mts
CHANGED
|
@@ -13,6 +13,7 @@ export type Deps = {
|
|
|
13
13
|
};
|
|
14
14
|
/** `argv` is the command's name, then its arguments. */
|
|
15
15
|
export declare function main(argv: string[], d: Deps): Promise<number>;
|
|
16
|
-
/** `factory gate`, `factory test-one`, `factory end-to-end`,
|
|
17
|
-
* `factory specs check`, the last as
|
|
16
|
+
/** `factory gate`, `factory test-one`, `factory end-to-end`,
|
|
17
|
+
* `factory specs check`, and `factory specs change-name`, the last two as
|
|
18
|
+
* `specs-check` and `specs-change-name`. */
|
|
18
19
|
export declare function run(argv: string[]): Promise<number>;
|
package/dist/commands.mjs
CHANGED
|
@@ -18,6 +18,7 @@ const USAGE = {
|
|
|
18
18
|
"test-one": "Usage: factory test-one FILE [NAME]",
|
|
19
19
|
"end-to-end": "Usage: factory end-to-end FILE [--times K]",
|
|
20
20
|
"specs-check": "Usage: factory specs check",
|
|
21
|
+
"specs-change-name": "Usage: factory specs change-name N",
|
|
21
22
|
};
|
|
22
23
|
/** What `factory end-to-end` was asked: the file, and how many runs when
|
|
23
24
|
* `--times` is given; null when the arguments are not ones it knows. */
|
|
@@ -50,6 +51,10 @@ export async function main(argv, d) {
|
|
|
50
51
|
if (args.length > 0)
|
|
51
52
|
return usage();
|
|
52
53
|
}
|
|
54
|
+
else if (name === "specs-change-name") {
|
|
55
|
+
if (args.length !== 1 || !/^[1-9]\d*$/.test(args[0]))
|
|
56
|
+
return usage();
|
|
57
|
+
}
|
|
53
58
|
else if (name === "test-one") {
|
|
54
59
|
if (args.length < 1 || args.length > 2)
|
|
55
60
|
return usage();
|
|
@@ -114,14 +119,23 @@ export async function main(argv, d) {
|
|
|
114
119
|
}
|
|
115
120
|
return test(0);
|
|
116
121
|
}
|
|
122
|
+
if (name === "specs-change-name") {
|
|
123
|
+
if (s.specs === "none") {
|
|
124
|
+
d.err("specs are off: there is no spec change to name");
|
|
125
|
+
return 1;
|
|
126
|
+
}
|
|
127
|
+
d.out(`issue-${args[0]}`);
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
117
130
|
if (s.specCheck === null) {
|
|
118
131
|
d.out("specs are off");
|
|
119
132
|
return 0;
|
|
120
133
|
}
|
|
121
134
|
return ended(d.exec(s.specCheck, d.root, { DO_NOT_TRACK: "1" }), "The specs check passed.", "The specs check failed.");
|
|
122
135
|
}
|
|
123
|
-
/** `factory gate`, `factory test-one`, `factory end-to-end`,
|
|
124
|
-
* `factory specs check`, the last as
|
|
136
|
+
/** `factory gate`, `factory test-one`, `factory end-to-end`,
|
|
137
|
+
* `factory specs check`, and `factory specs change-name`, the last two as
|
|
138
|
+
* `specs-check` and `specs-change-name`. */
|
|
125
139
|
export async function run(argv) {
|
|
126
140
|
const root = repoRoot();
|
|
127
141
|
return main(argv, {
|
package/dist/config.d.mts
CHANGED
|
@@ -59,9 +59,12 @@ export type Settings = {
|
|
|
59
59
|
* field that holds it, or null for the description. */
|
|
60
60
|
ticketFields: FieldMapping;
|
|
61
61
|
};
|
|
62
|
-
/** Where pull requests are
|
|
62
|
+
/** Where pull requests are, and the pattern a build's branch is named
|
|
63
|
+
* by. The pattern is null only when init reads settings without it, to
|
|
64
|
+
* ask for it. */
|
|
63
65
|
codeHost: {
|
|
64
66
|
type: string;
|
|
67
|
+
branchName: string | null;
|
|
65
68
|
};
|
|
66
69
|
builds: {
|
|
67
70
|
/** What notices a card moved to Ready and starts its build. */
|
|
@@ -175,10 +178,18 @@ export declare function repoRoot(from?: string): string;
|
|
|
175
178
|
export declare const SETTINGS_FILE = ".claude/factory.yaml";
|
|
176
179
|
/** A key under `tickets.fields` naming a heading of the repository's own. */
|
|
177
180
|
export declare const OWN_HEADING: RegExp;
|
|
181
|
+
export declare const BRANCH_PLACEHOLDERS: readonly ["ticket", "user"];
|
|
182
|
+
/** Why a branch name pattern can't be used, in the words the settings
|
|
183
|
+
* check prints after its key, or null when it can. The placeholders are
|
|
184
|
+
* filled before git's rules are applied, so only the pattern's own text
|
|
185
|
+
* can break them. */
|
|
186
|
+
export declare function branchPatternFault(pattern: string): string | null;
|
|
178
187
|
/** The settings with every default filled in. Throws a SettingsError naming
|
|
179
188
|
* the key on anything unsound. `exists` says whether a path from the root
|
|
180
189
|
* exists, for the plugins' files. */
|
|
181
|
-
export declare function parseSettings(raw: unknown, exists: (path: string) => boolean, built?: Built
|
|
190
|
+
export declare function parseSettings(raw: unknown, exists: (path: string) => boolean, built?: Built, { partial }?: {
|
|
191
|
+
partial?: boolean;
|
|
192
|
+
}): Settings;
|
|
182
193
|
/** One line for each pattern that matches none of `files`: a stale pattern
|
|
183
194
|
* is how a policy rots. */
|
|
184
195
|
export declare function patternWarnings(s: Settings, files: string[]): string[];
|
|
@@ -235,9 +246,11 @@ export declare function parseChoices(text: string | null, load: YamlLoad): Recor
|
|
|
235
246
|
* `presets`, and `.claude/factory.yaml`, as `factory sync` combines them
|
|
236
247
|
* into the lock. `factoryFile` and `ownFile` say which preset files are
|
|
237
248
|
* kept back: the factory's own, and the repository's own. */
|
|
238
|
-
export declare function resolveFiles(d: Deps, keep?: {
|
|
249
|
+
export declare function resolveFiles(d: Deps, { partial, ...keep }?: {
|
|
239
250
|
factoryFile?: (path: string) => boolean;
|
|
240
251
|
ownFile?: (path: string) => boolean;
|
|
252
|
+
/** Read settings init fills in, as `parseSettings` takes it. */
|
|
253
|
+
partial?: boolean;
|
|
241
254
|
}): Promise<Resolved>;
|
|
242
255
|
/** Why the lock `d` reads is stale, or null when it is current or `d`
|
|
243
256
|
* reads none. */
|