@davidbyoung/software-factory 0.1.9 → 0.1.11
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/agents/factory-ticket-readiness.md +20 -15
- package/dist/board.d.mts +1 -1
- package/dist/board.mjs +4 -7
- package/dist/cli.mjs +23 -1
- package/dist/code-host/github.d.mts +1 -1
- package/dist/code-host/github.mjs +31 -2
- package/dist/code-host/types.d.mts +20 -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 +8 -2
- package/dist/commands.mjs +92 -8
- package/dist/config.d.mts +19 -7
- package/dist/config.mjs +109 -30
- package/dist/doctor.mjs +1 -2
- package/dist/explain.mjs +7 -1
- package/dist/init.d.mts +19 -0
- package/dist/init.mjs +139 -23
- 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/lib/work-status.d.mts +5 -5
- package/dist/lib/work-status.mjs +7 -8
- package/dist/merge-policy.mjs +7 -3
- package/dist/poller.d.mts +1 -1
- package/dist/poller.mjs +9 -6
- package/dist/pr.d.mts +8 -6
- package/dist/pr.mjs +47 -22
- package/dist/review-verdict.d.mts +22 -4
- package/dist/review-verdict.mjs +55 -17
- package/dist/specs/index.d.mts +6 -0
- package/dist/specs/index.mjs +15 -0
- package/dist/specs/openspec.d.mts +2 -0
- package/dist/specs/openspec.mjs +78 -0
- package/dist/specs/types.d.mts +53 -0
- package/dist/specs/types.mjs +4 -0
- package/dist/ticket.d.mts +6 -1
- package/dist/ticket.mjs +62 -3
- package/dist/tickets/github-access.d.mts +5 -0
- package/dist/tickets/github-access.mjs +22 -0
- package/dist/tickets/github.mjs +2 -0
- package/dist/tickets/types.d.mts +4 -0
- package/dist/tool-names.d.mts +2 -0
- package/dist/tool-names.mjs +3 -0
- package/dist/tools.d.mts +2 -0
- package/dist/tools.mjs +3 -0
- package/docs/builds.md +30 -14
- package/docs/cli.md +48 -30
- package/docs/configuration.md +237 -73
- package/docs/developing.md +104 -59
- package/docs/existing-repo.md +51 -29
- package/docs/github/by-hand.md +13 -1
- package/docs/github/setup.md +26 -2
- package/docs/glossary.md +7 -6
- package/docs/limitations.md +8 -5
- package/docs/presets.md +15 -3
- package/docs/updating.md +147 -2
- package/docs/workflow.md +26 -9
- package/package.json +1 -1
- package/rules.md +36 -30
- package/settings.schema.json +14 -9
- package/skills/factory-address-review/SKILL.md +40 -39
- package/skills/factory-build/SKILL.md +77 -52
- package/skills/factory-deps/SKILL.md +6 -4
- package/skills/factory-refine/SKILL.md +30 -22
- package/skills/factory-resolve-conflicts/SKILL.md +8 -7
|
@@ -21,7 +21,7 @@ Whichever skill refined the issue, `factory-refine` or the repository's own
|
|
|
21
21
|
refiner, read what it left against the same list, what refinement
|
|
22
22
|
delivers: the `spec` label decided, each build order recorded as a
|
|
23
23
|
blocked-by relationship, and a body with the sections `factory-build`
|
|
24
|
-
reads, in the shape
|
|
24
|
+
reads, in the shape a spec tool takes when there is one. "What to look for"
|
|
25
25
|
says how each is checked.
|
|
26
26
|
|
|
27
27
|
**Read-only.** Never comment on, edit, or label the issue, and never change a
|
|
@@ -38,16 +38,18 @@ unverified, for the builder to check.
|
|
|
38
38
|
`For the builder` on the `spec` track, or `Acceptance criteria` without
|
|
39
39
|
the label. An issue without `spec` has no `For the builder`: the area's
|
|
40
40
|
rules ("Rules by area" in `CLAUDE.md`) say how it is built.
|
|
41
|
-
2. The latest refinement round in the comments, and any reply
|
|
42
|
-
|
|
41
|
+
2. The latest refinement round in the comments, and any reply
|
|
42
|
+
`npx --no-install factory ticket answers N` prints after it. Until it prints one, each proposed default
|
|
43
43
|
stands.
|
|
44
44
|
3. `CLAUDE.md`, the files it imports, and the `CLAUDE.md` for every area
|
|
45
45
|
the notes name.
|
|
46
46
|
4. Every file the notes name, to check that it exists and works the way the
|
|
47
47
|
notes say.
|
|
48
|
-
5. On the `spec` track, `
|
|
49
|
-
capability the Spec names, to check that a "modified"
|
|
50
|
-
the spec says today and a "No longer" line names a
|
|
48
|
+
5. On the `spec` track, the file `npx --no-install factory specs list`
|
|
49
|
+
prints for every capability the Spec names, to check that a "modified"
|
|
50
|
+
line changes what the spec says today and a "No longer" line names a
|
|
51
|
+
requirement it has. With no spec tool it lists none: check those lines
|
|
52
|
+
against the code instead.
|
|
51
53
|
|
|
52
54
|
## The question you are answering
|
|
53
55
|
|
|
@@ -71,8 +73,8 @@ anything?
|
|
|
71
73
|
- **A blocking step with no owner,** such as an account, key, or form that
|
|
72
74
|
only the owner can create, with no word on whether it exists.
|
|
73
75
|
- **A conflict** between the criteria, the notes, and the repository's rules.
|
|
74
|
-
- **A build order with no relationship behind it.** The body or
|
|
75
|
-
|
|
76
|
+
- **A build order with no relationship behind it.** The body or an answer
|
|
77
|
+
`factory ticket answers N` prints says to build this after another issue that is
|
|
76
78
|
still open, and
|
|
77
79
|
`npx --no-install factory ticket blockers N` does not list it. `factory-build` stops only on a recorded relationship, so
|
|
78
80
|
the prose alone lets the build start too soon. Word the finding as:
|
|
@@ -80,13 +82,16 @@ anything?
|
|
|
80
82
|
`.claude/factory/rules.md`
|
|
81
83
|
and needs the relationship, or the sentence comes out. A prerequisite
|
|
82
84
|
that is already closed is not a finding.
|
|
83
|
-
- **A missing track or shape.**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
- **A missing track or shape.** A change a user would see, and that is not
|
|
86
|
+
small, needs the `spec` label, whatever the spec tool. On the `spec`
|
|
87
|
+
track the body needs "Decisions", "Spec" grouped by capability, and "For
|
|
88
|
+
the builder" with "Design" and "Tasks", which `factory-build` builds
|
|
89
|
+
from and, with a spec tool, writes into the repository's specs; also a
|
|
90
|
+
Spec line that could not stand as one WHEN/THEN scenario on its own, a
|
|
91
|
+
capability named unlike those `factory specs list` prints (with no
|
|
92
|
+
spec tool, which lists none, one not in lowercase words joined by
|
|
93
|
+
hyphens), or a
|
|
94
|
+
"modified" line that restates the current spec instead of changing it. Without the label the body needs "Decisions" and
|
|
90
95
|
"Acceptance criteria", and a missing "For the builder" is not a finding:
|
|
91
96
|
ask only what the criteria and the area's rules leave open.
|
|
92
97
|
|
package/dist/board.d.mts
CHANGED
|
@@ -79,7 +79,7 @@ export type Plan = {
|
|
|
79
79
|
/** What each issue's fields should hold, and which writes get them there.
|
|
80
80
|
* A card's Session is an Actions run's page, which `runPage` gives for its
|
|
81
81
|
* ID, and any other session as it is. */
|
|
82
|
-
export declare function planSync(snapshot: RepoSnapshot, board: Board,
|
|
82
|
+
export declare function planSync(snapshot: RepoSnapshot, board: Board, runPage: (id: string) => string, cfg?: BoardConfig): Plan[];
|
|
83
83
|
export declare function logLine(plan: Plan): string;
|
|
84
84
|
export type Comment = {
|
|
85
85
|
issue: number;
|
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,
|
|
@@ -258,13 +256,12 @@ export function boardReport(number, board, cfg, settings, paint = plain) {
|
|
|
258
256
|
/** What each issue's fields should hold, and which writes get them there.
|
|
259
257
|
* A card's Session is an Actions run's page, which `runPage` gives for its
|
|
260
258
|
* ID, and any other session as it is. */
|
|
261
|
-
export function planSync(snapshot, board,
|
|
262
|
-
const owner = repository.split("/")[0];
|
|
259
|
+
export function planSync(snapshot, board, runPage, cfg = DEFAULT_BOARD) {
|
|
263
260
|
const everyPull = [...snapshot.pulls, ...(snapshot.donePulls ?? [])];
|
|
264
261
|
const fields = checkFields(board.fields, cfg);
|
|
265
262
|
return snapshot.issues.map((issue) => {
|
|
266
263
|
const derived = derive(issue, cardOf(board, issue.number, cfg.columns), snapshot.pulls, cfg.columns);
|
|
267
|
-
const listPrice = issueCost(issue, everyPull
|
|
264
|
+
const listPrice = issueCost(issue, everyPull);
|
|
268
265
|
const cost = listPrice === null
|
|
269
266
|
? null
|
|
270
267
|
: Math.round(subscriptionDollars(listPrice) * 100) / 100;
|
|
@@ -423,7 +420,7 @@ async function apply(saved, board, d, write) {
|
|
|
423
420
|
for (const line of inspected.lines)
|
|
424
421
|
if (line.text.startsWith("skipped"))
|
|
425
422
|
d.out(`${line.label} ${line.text}`);
|
|
426
|
-
const plans = planSync(snapshotOf(saved, d.now()), board, d.
|
|
423
|
+
const plans = planSync(snapshotOf(saved, d.now()), board, d.runPage, d.config);
|
|
427
424
|
for (const plan of plans) {
|
|
428
425
|
d.out(logLine(plan));
|
|
429
426
|
if (!write || plan.writes.length === 0)
|
package/dist/cli.mjs
CHANGED
|
@@ -16,12 +16,14 @@ const TICKET_STEPS = [
|
|
|
16
16
|
"end",
|
|
17
17
|
"cost",
|
|
18
18
|
"view",
|
|
19
|
+
"answers",
|
|
19
20
|
"list",
|
|
20
21
|
"edit",
|
|
21
22
|
"comment",
|
|
22
23
|
"open",
|
|
23
24
|
"label",
|
|
24
25
|
"link",
|
|
26
|
+
"branch",
|
|
25
27
|
"blockers",
|
|
26
28
|
"block",
|
|
27
29
|
"unblock",
|
|
@@ -34,6 +36,7 @@ const PR_STEPS = [
|
|
|
34
36
|
"resolve",
|
|
35
37
|
"ready",
|
|
36
38
|
"closes",
|
|
39
|
+
"for-branch",
|
|
37
40
|
"comments",
|
|
38
41
|
"comment",
|
|
39
42
|
"comment-view",
|
|
@@ -79,12 +82,13 @@ const PR_ARGS = {
|
|
|
79
82
|
review: "N REVIEW",
|
|
80
83
|
reply: "N COMMENT --body-file FILE",
|
|
81
84
|
resolve: "N COMMENT",
|
|
82
|
-
comments: "N [--author LOGIN] [--contains TEXT] [--json]",
|
|
85
|
+
comments: "N [--author LOGIN] [--contains TEXT] [--from-approvers] [--json]",
|
|
83
86
|
comment: "N --body-file FILE",
|
|
84
87
|
"comment-view": "ID",
|
|
85
88
|
label: "N --add LABEL | --remove LABEL",
|
|
86
89
|
"review-pending": "N REVIEW",
|
|
87
90
|
conflicts: "",
|
|
91
|
+
"for-branch": "BRANCH",
|
|
88
92
|
uncovered: "[BASE] [LCOV]",
|
|
89
93
|
};
|
|
90
94
|
export const COMMANDS = [
|
|
@@ -203,6 +207,21 @@ export const COMMANDS = [
|
|
|
203
207
|
args: "",
|
|
204
208
|
run: async (argv) => (await import("./commands.mjs")).run(["specs-check", ...argv]),
|
|
205
209
|
},
|
|
210
|
+
{
|
|
211
|
+
words: ["specs", "list"],
|
|
212
|
+
args: "",
|
|
213
|
+
run: async (argv) => (await import("./commands.mjs")).run(["specs-list", ...argv]),
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
words: ["specs", "new"],
|
|
217
|
+
args: "N",
|
|
218
|
+
run: async (argv) => (await import("./commands.mjs")).run(["specs-new", ...argv]),
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
words: ["specs", "finish"],
|
|
222
|
+
args: "N",
|
|
223
|
+
run: async (argv) => (await import("./commands.mjs")).run(["specs-finish", ...argv]),
|
|
224
|
+
},
|
|
206
225
|
{
|
|
207
226
|
words: ["default-branch"],
|
|
208
227
|
args: "",
|
|
@@ -338,7 +357,10 @@ const USAGE = [
|
|
|
338
357
|
["gate", "Run the commands under commands.gate"],
|
|
339
358
|
["test-one FILE [NAME]", "Run one test file, or one test in it"],
|
|
340
359
|
["end-to-end FILE", "Run one end-to-end spec"],
|
|
360
|
+
["specs list", "List the specs your spec tool keeps"],
|
|
361
|
+
["specs new N", "Start ticket N's spec"],
|
|
341
362
|
["specs check", "Check your written specs"],
|
|
363
|
+
["specs finish N", "Fold ticket N's spec into your specs"],
|
|
342
364
|
["default-branch", "Print the default branch's name"],
|
|
343
365
|
],
|
|
344
366
|
],
|
|
@@ -1,6 +1,14 @@
|
|
|
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";
|
|
9
|
+
import { writeAccess } from "../tickets/github-access.mjs";
|
|
2
10
|
import { statusOf } from "../tickets/transport.mjs";
|
|
3
|
-
import { NeedsScopeError } from "./types.mjs";
|
|
11
|
+
import { NeedsScopeError, NotSignedInError } from "./types.mjs";
|
|
4
12
|
/** What a check wrote about its result: its title and its summary. */
|
|
5
13
|
const reportOf = (output) => [output?.title, output?.summary].filter(Boolean).join("\n") || undefined;
|
|
6
14
|
const endOf = (end) => ({
|
|
@@ -214,6 +222,19 @@ export function githubCodeHost(o) {
|
|
|
214
222
|
const open = await t.rest("GET", `${API}/pulls?head=${owner}:${branch}&state=open`);
|
|
215
223
|
return open[0]?.number ?? null;
|
|
216
224
|
},
|
|
225
|
+
async lastForBranch(branch) {
|
|
226
|
+
const [newest] = await t.rest("GET", `${API}/pulls?head=${owner}:${encodeURIComponent(branch)}&state=all&sort=created&direction=desc&per_page=1`);
|
|
227
|
+
if (!newest)
|
|
228
|
+
return null;
|
|
229
|
+
return {
|
|
230
|
+
number: newest.number,
|
|
231
|
+
state: newest.state === "open"
|
|
232
|
+
? "open"
|
|
233
|
+
: newest.merged_at
|
|
234
|
+
? "merged"
|
|
235
|
+
: "closed",
|
|
236
|
+
};
|
|
237
|
+
},
|
|
217
238
|
forCommit: async (sha) => (await t.rest("GET", `${API}/commits/${sha}/pulls`)).map(({ number, state }) => ({ number, state })),
|
|
218
239
|
files: async (n) => (await list(`${API}/pulls/${n}/files?per_page=100`)).map((f) => ({
|
|
219
240
|
path: f.filename,
|
|
@@ -238,6 +259,7 @@ export function githubCodeHost(o) {
|
|
|
238
259
|
const repo = await t.rest("GET", API);
|
|
239
260
|
return repo.owner.type === "Organization";
|
|
240
261
|
},
|
|
262
|
+
canWrite: (login) => writeAccess(t, o.repository, login),
|
|
241
263
|
async checkRuns(sha) {
|
|
242
264
|
const answer = await t.rest("GET", `${API}/commits/${sha}/check-runs?per_page=100`);
|
|
243
265
|
return answer.check_runs.map((c) => ({
|
|
@@ -348,7 +370,14 @@ export function githubCodeHost(o) {
|
|
|
348
370
|
},
|
|
349
371
|
address: (n) => `https://github.com/${o.repository}/pull/${n}`,
|
|
350
372
|
async signedInAs() {
|
|
351
|
-
|
|
373
|
+
try {
|
|
374
|
+
return (await t.rest("GET", "user")).login;
|
|
375
|
+
}
|
|
376
|
+
catch (e) {
|
|
377
|
+
if (statusOf(e) === 401 || (e instanceof GhError && e.exitCode === 4))
|
|
378
|
+
throw new NotSignedInError();
|
|
379
|
+
throw e;
|
|
380
|
+
}
|
|
352
381
|
},
|
|
353
382
|
async tokenOwner(token) {
|
|
354
383
|
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;
|
|
@@ -125,6 +134,10 @@ export type CodeHost = {
|
|
|
125
134
|
isPrivate(): Promise<boolean>;
|
|
126
135
|
/** Whether an organization owns the repository, rather than a person. */
|
|
127
136
|
ownerIsOrganization(): Promise<boolean>;
|
|
137
|
+
/** Whether the account can write to the repository: an approver, whose
|
|
138
|
+
* words a session takes as instructions. Rejects when the code host
|
|
139
|
+
* cannot say. */
|
|
140
|
+
canWrite(login: string): Promise<boolean>;
|
|
128
141
|
/** The check runs on a commit, without its statuses. */
|
|
129
142
|
checkRuns(sha: string): Promise<CheckRun[]>;
|
|
130
143
|
/** The statuses on a commit, without its check runs. */
|
|
@@ -172,7 +185,8 @@ export type CodeHost = {
|
|
|
172
185
|
linking(skip?: number[]): Promise<PullRequest[]>;
|
|
173
186
|
/** The address of a pull request's page. */
|
|
174
187
|
address(pull: number): string;
|
|
175
|
-
/** Who the code host's command-line tool is signed in as.
|
|
188
|
+
/** Who the code host's command-line tool is signed in as. Rejects with
|
|
189
|
+
* NotSignedInError when it is signed in as nobody, or refused. */
|
|
176
190
|
signedInAs(): Promise<string>;
|
|
177
191
|
/** The account a token belongs to, and its scopes: null when the code
|
|
178
192
|
* host does not say, as for a token with fine-grained permissions.
|
|
@@ -200,6 +214,11 @@ export type CodeHost = {
|
|
|
200
214
|
/** What a token for the factory's jobs may need to do: push a branch,
|
|
201
215
|
* change a workflow's file, and write the board. */
|
|
202
216
|
export type TokenNeed = "push" | "workflows" | "board";
|
|
217
|
+
/** The code host's CLI is signed in as nobody, or its sign-in is
|
|
218
|
+
* refused. */
|
|
219
|
+
export declare class NotSignedInError extends Error {
|
|
220
|
+
constructor();
|
|
221
|
+
}
|
|
203
222
|
/** A call the signed-in account's sign-in lacks the permission for. `fix`
|
|
204
223
|
* is the command that asks for it. */
|
|
205
224
|
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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Paint } from "./lib/color.mts";
|
|
2
2
|
import { type Settings } from "./config.mts";
|
|
3
|
+
import { type SpecTools } from "./specs/index.mts";
|
|
3
4
|
export type Deps = {
|
|
4
5
|
/** The repository's root, where every command runs. */
|
|
5
6
|
root: string;
|
|
@@ -10,9 +11,14 @@ export type Deps = {
|
|
|
10
11
|
out: (line: string) => void;
|
|
11
12
|
err: (line: string) => void;
|
|
12
13
|
paint?: Paint;
|
|
14
|
+
specTools: SpecTools;
|
|
15
|
+
/** Ticket `id`'s labels; throws when it can't be read. */
|
|
16
|
+
labels: (settings: Settings, id: number) => Promise<string[]>;
|
|
13
17
|
};
|
|
14
18
|
/** `argv` is the command's name, then its arguments. */
|
|
15
19
|
export declare function main(argv: string[], d: Deps): Promise<number>;
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
export declare const NO_SPEC_TOOL = "No spec tool (specs: none): each ticket holds its own spec.";
|
|
21
|
+
/** `factory gate`, `factory test-one`, `factory end-to-end`,
|
|
22
|
+
* and `factory specs check`, `list`, `new`, and `finish`, as `specs-check`
|
|
23
|
+
* and the rest. */
|
|
18
24
|
export declare function run(argv: string[]): Promise<number>;
|