@davidbyoung/software-factory 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/agent/claude-code.d.mts +16 -0
  2. package/dist/agent/claude-code.mjs +75 -3
  3. package/dist/agent/index.d.mts +1 -1
  4. package/dist/agent/index.mjs +1 -1
  5. package/dist/agent/types.d.mts +24 -0
  6. package/dist/agent/types.mjs +3 -0
  7. package/dist/board.mjs +9 -11
  8. package/dist/code-host/github.mjs +4 -0
  9. package/dist/code-host/types.d.mts +2 -0
  10. package/dist/columns-suggest.d.mts +52 -0
  11. package/dist/columns-suggest.mjs +259 -0
  12. package/dist/config.d.mts +6 -1
  13. package/dist/config.mjs +45 -8
  14. package/dist/doctor.d.mts +3 -0
  15. package/dist/doctor.mjs +133 -5
  16. package/dist/explain.mjs +1 -1
  17. package/dist/init.mjs +155 -7
  18. package/dist/lib/work-status.d.mts +10 -7
  19. package/dist/lib/work-status.mjs +20 -19
  20. package/dist/npmrc.d.mts +29 -0
  21. package/dist/npmrc.mjs +98 -0
  22. package/dist/poller.mjs +2 -2
  23. package/dist/preset-commands.d.mts +0 -2
  24. package/dist/preset-commands.mjs +2 -12
  25. package/dist/preset.d.mts +4 -0
  26. package/dist/preset.mjs +10 -0
  27. package/dist/runner/github-actions.mjs +47 -10
  28. package/dist/runner/types.d.mts +13 -0
  29. package/dist/setup.d.mts +3 -1
  30. package/dist/status.mjs +1 -1
  31. package/dist/sync.d.mts +7 -0
  32. package/dist/sync.mjs +66 -2
  33. package/dist/ticket.mjs +1 -1
  34. package/dist/tickets/github.mjs +10 -2
  35. package/dist/tickets/types.d.mts +3 -0
  36. package/dist/tools.d.mts +4 -1
  37. package/dist/tools.mjs +9 -2
  38. package/docs/configuration.md +33 -5
  39. package/docs/design.md +15 -0
  40. package/docs/developing.md +15 -6
  41. package/docs/existing-repo.md +104 -31
  42. package/docs/github/by-hand.md +4 -0
  43. package/docs/github/reference.md +5 -0
  44. package/docs/github/setup.md +141 -8
  45. package/docs/limitations.md +0 -8
  46. package/docs/presets.md +5 -9
  47. package/docs/removing.md +2 -2
  48. package/package.json +1 -1
  49. package/settings.schema.json +45 -15
  50. package/skills/factory-deps/SKILL.md +4 -0
package/dist/doctor.mjs CHANGED
@@ -4,7 +4,9 @@
4
4
  //
5
5
  // A stored secret cannot be read back, so a secret is checked only for
6
6
  // being set.
7
- import { readFileSync } from "node:fs";
7
+ import { existsSync, readFileSync } from "node:fs";
8
+ import { load } from "js-yaml";
9
+ import { bareRegistry, npmrcAt, privateRegistries } from "./npmrc.mjs";
8
10
  import { join } from "node:path";
9
11
  import { defaultDeps, filesDeps, repoRoot, resolveFiles, staleOf, } from "./config.mjs";
10
12
  import { presetChecks } from "./preset-commands.mjs";
@@ -97,25 +99,34 @@ export async function checks(d) {
97
99
  const [agent, codeHost, tickets, runner] = inUse(d.tools, chosen);
98
100
  out.push(...((await codeHost.setup.checks?.({ ...context([]), secrets: null })) ??
99
101
  []));
100
- let secrets;
102
+ // A secret the organization shares with the repository counts as set.
103
+ const isOrganization = await opened.codeHost
104
+ .ownerIsOrganization()
105
+ .catch(() => true);
106
+ const shared = isOrganization
107
+ ? await opened.runner.organizationSecretNames().catch(() => [])
108
+ : [];
109
+ let own;
101
110
  try {
102
- secrets = await opened.runner.secretNames();
111
+ own = await opened.runner.secretNames();
103
112
  }
104
113
  catch (e) {
105
- secrets = null;
114
+ own = null;
106
115
  out.push({
107
116
  state: "fail",
108
117
  text: "The secrets can be listed",
109
118
  fix: message(e),
110
119
  });
111
120
  }
121
+ const secrets = own === null ? null : [...own, ...shared];
112
122
  const cloudNeeds = secretSteps(d.tools, context(["cloud"])).flatMap((x) => x.step.needs.filter((n) => n.part === "cloud"));
113
123
  const on = partsOn(s, secrets ?? [], cloudNeeds);
114
124
  const needed = neededSecrets(on, secretSteps(d.tools, context(on)));
115
125
  const secretLine = (anyOf, forWhat) => {
116
126
  const found = anyOf.find((n) => secrets.includes(n));
127
+ const by = found && !own.includes(found) ? " by the organization" : "";
117
128
  return found
118
- ? { state: "pass", text: `${found} is set, for ${forWhat}` }
129
+ ? { state: "pass", text: `${found} is set${by}, for ${forWhat}` }
119
130
  : {
120
131
  state: "fail",
121
132
  text: `${anyOf.join(" or ")} is not set, for ${forWhat}`,
@@ -143,15 +154,132 @@ export async function checks(d) {
143
154
  if (secrets !== null)
144
155
  for (const need of needed.filter((n) => n.part === null))
145
156
  out.push(secretLine(need.anyOf, need.tool));
157
+ out.push(...(await npmChecks(d.root, opened, isOrganization, own, shared)));
146
158
  for (const tool of [tickets, runner, agent])
147
159
  out.push(...((await tool.setup.checks?.({ ...context(on), secrets })) ?? []));
148
160
  return out;
149
161
  }
162
+ const DEPENDABOT = ".github/dependabot.yml";
163
+ const FOR_NPM = "for installing what .npmrc names";
164
+ const FOR_DEPENDABOT = "for installing on Dependabot's pull requests";
165
+ /** The checks for the variables `.npmrc`'s sign-in lines read: each one's
166
+ * secret for Actions and for Dependabot, and whether Dependabot's settings
167
+ * use each registry `.npmrc` names. */
168
+ async function npmChecks(root, opened, isOrganization, own, shared) {
169
+ const npmrc = npmrcAt(root);
170
+ if (!npmrc.names.length)
171
+ return [];
172
+ const out = [];
173
+ let dependabot;
174
+ try {
175
+ dependabot = await opened.runner.dependabotSecretNames();
176
+ }
177
+ catch (e) {
178
+ dependabot = null;
179
+ out.push({
180
+ state: "fail",
181
+ text: "The Dependabot secrets can be listed",
182
+ fix: message(e),
183
+ });
184
+ }
185
+ const tokens = npmrc.names.filter((n) => n !== "GITHUB_TOKEN");
186
+ const organizations = isOrganization &&
187
+ dependabot !== null &&
188
+ tokens.some((n) => !dependabot.includes(n))
189
+ ? await opened.runner.organizationDependabotSecretNames(await opened.codeHost.isPrivate())
190
+ : [];
191
+ for (const name of npmrc.names) {
192
+ if (name === "GITHUB_TOKEN") {
193
+ out.push({
194
+ state: "off",
195
+ text: "GITHUB_TOKEN is the workflow's own token: it installs only the packages that give this repository access",
196
+ });
197
+ continue;
198
+ }
199
+ if (own !== null)
200
+ out.push(own.includes(name)
201
+ ? { state: "pass", text: `${name} is set, ${FOR_NPM}` }
202
+ : shared.includes(name)
203
+ ? {
204
+ state: "pass",
205
+ text: `${name} is set by the organization, ${FOR_NPM}`,
206
+ }
207
+ : {
208
+ state: "fail",
209
+ text: `${name} is not set, ${FOR_NPM}`,
210
+ fix: INIT,
211
+ });
212
+ if (dependabot === null)
213
+ continue;
214
+ out.push(dependabot.includes(name)
215
+ ? {
216
+ state: "pass",
217
+ text: `${name} is set for Dependabot, ${FOR_DEPENDABOT}`,
218
+ }
219
+ : organizations === null
220
+ ? {
221
+ state: "unknown",
222
+ text: `${name} is not set for Dependabot on the repository, and only an organization admin can see whether the organization sets it`,
223
+ }
224
+ : organizations.includes(name)
225
+ ? {
226
+ state: "pass",
227
+ text: `${name} is set by the organization for Dependabot, ${FOR_DEPENDABOT}`,
228
+ }
229
+ : {
230
+ state: "fail",
231
+ text: `${name} is not set for Dependabot, ${FOR_DEPENDABOT}`,
232
+ fix: INIT,
233
+ });
234
+ }
235
+ const path = join(root, DEPENDABOT);
236
+ if (existsSync(path)) {
237
+ const settings = readFileSync(path, "utf8");
238
+ for (const url of privateRegistries(npmrc))
239
+ out.push(usesRegistry(settings, url)
240
+ ? {
241
+ state: "pass",
242
+ text: `${DEPENDABOT} uses ${url} for its npm updates`,
243
+ }
244
+ : {
245
+ state: "unknown",
246
+ text: `${DEPENDABOT} doesn't use ${url} for its npm updates: unless your organization sets that registry for Dependabot, it never sees a new version of a package from there. Add it under registries, and name it in the npm entry's registries`,
247
+ });
248
+ }
249
+ return out;
250
+ }
251
+ /** Whether Dependabot's settings name the registry at `url` under their
252
+ * `registries`, and every npm update lists it, or all of them. */
253
+ export function usesRegistry(settings, url) {
254
+ let o;
255
+ try {
256
+ o = load(settings);
257
+ }
258
+ catch {
259
+ return false;
260
+ }
261
+ const isObj = (x) => typeof x === "object" && x !== null && !Array.isArray(x);
262
+ if (!isObj(o) || !isObj(o.registries))
263
+ return false;
264
+ const names = Object.entries(o.registries)
265
+ .filter(([, r]) => isObj(r) &&
266
+ typeof r.url === "string" &&
267
+ bareRegistry(r.url) === bareRegistry(url))
268
+ .map(([name]) => name);
269
+ const npm = (Array.isArray(o.updates) ? o.updates : []).filter((u) => isObj(u) && u["package-ecosystem"] === "npm");
270
+ return (names.length > 0 &&
271
+ npm.length > 0 &&
272
+ npm.every((u) => u.registries === "*" ||
273
+ (Array.isArray(u.registries) &&
274
+ u.registries.some((r) => names.includes(String(r))))));
275
+ }
150
276
  /** One check as a line: a tick, a cross with what to do, or a dash for a
151
277
  * part that is off. */
152
278
  export function line(c) {
153
279
  if (c.state === "off")
154
280
  return `- ${c.text}`;
281
+ if (c.state === "unknown")
282
+ return `? ${c.text}`;
155
283
  if (c.state === "pass")
156
284
  return `✓ ${c.text}`;
157
285
  const fix = c.fix ?? "";
package/dist/explain.mjs CHANGED
@@ -66,7 +66,7 @@ export async function explainLines(s, marks, exists) {
66
66
  put(["tickets", "board"], s.tickets.board);
67
67
  block(["tickets", "columns"]);
68
68
  for (const [k, v] of Object.entries(s.tickets.columns))
69
- put(["tickets", "columns", k], v ?? "none");
69
+ put(["tickets", "columns", k], v === null ? "none" : v.length === 1 ? v[0] : v);
70
70
  block(["tickets", "fields"]);
71
71
  for (const [k, v] of Object.entries(s.tickets.fields))
72
72
  put(["tickets", "fields", k], v ?? "none");
package/dist/init.mjs CHANGED
@@ -18,12 +18,14 @@ import { checks as doctorChecks, doctorDeps, line } from "./doctor.mjs";
18
18
  import { branchDeps, needDefaultBranch, NoDefaultBranch, } from "./lib/default-branch.mjs";
19
19
  import { hasCommand, noTerminal } from "./lib/has-command.mjs";
20
20
  import { DEFAULT_RUNNER } from "./runner/index.mjs";
21
+ import { addressOf, firstRefusal, NPMRC, npmrcAt, } from "./npmrc.mjs";
21
22
  import { listed } from "./lib/listed.mjs";
22
23
  import { neededSecrets, PART_TEXT, PARTS, partsOn, resolveParts, SIGNING_KEY, } from "./parts.mjs";
23
24
  import { CONTEXT as REVIEW_VERDICT } from "./review-verdict.mjs";
24
25
  import { RULE } from "./setup.mjs";
25
26
  import { differences, PACKAGE, plan as syncPlan } from "./sync.mjs";
26
- import { DEFAULT_COLUMNS } from "./lib/work-status.mjs";
27
+ import { DEFAULT_COLUMNS, STATE_KEYS, sameName } from "./lib/work-status.mjs";
28
+ import { askReady, suggestColumns } from "./columns-suggest.mjs";
27
29
  const SIGNING_TITLE = "software factory builds";
28
30
  /** Where each release's poller image is published. */
29
31
  const POLLER_IMAGE = "ghcr.io/davidbyoung/software-factory-poller";
@@ -33,7 +35,7 @@ const AGAIN = "Run npx --no-install factory init again to add it.";
33
35
  /** The columns and fields the board sync uses: the settings' names where
34
36
  * they rename one, and none for one they set to none. */
35
37
  function boardShape(s) {
36
- const columns = Object.values(s ? columnsOf(s) : DEFAULT_COLUMNS).filter((c) => c !== null);
38
+ const columns = Object.values(s ? columnsOf(s) : DEFAULT_COLUMNS).flatMap((c) => c ?? []);
37
39
  const names = s
38
40
  ? fieldNamesOf(s)
39
41
  : { session: "Session", runsIn: "Runs in", cost: "Cost" };
@@ -102,6 +104,16 @@ export async function main(_argv, d) {
102
104
  return 1;
103
105
  }
104
106
  }
107
+ /** The settings as the file will stand, for the board's columns and
108
+ * fields; files the sync has yet to write don't matter to those. */
109
+ const standing = () => {
110
+ try {
111
+ return parseSettings(doc.toJS(), () => true, builtOf(d.tools));
112
+ }
113
+ catch {
114
+ return settings;
115
+ }
116
+ };
105
117
  const hasPackage = existsSync(at("package.json"));
106
118
  // A kind with one tool is that tool; with several, the settings' choice,
107
119
  // or one asked for below.
@@ -127,6 +139,7 @@ export async function main(_argv, d) {
127
139
  ? `${tools[choice[kind]].label}, from your settings`
128
140
  : "chosen below";
129
141
  };
142
+ const npmrc = npmrcAt(d.root);
130
143
  d.out(`Setting up the software factory for ${repository}`);
131
144
  d.out("");
132
145
  d.out("Found");
@@ -136,11 +149,18 @@ export async function main(_argv, d) {
136
149
  row("Coding agent", agent.setup.found?.({ hasCommand: d.hasCommand }) ?? agent.label);
137
150
  row("Cloud builds", shown("runner"));
138
151
  row("package.json", hasPackage ? "yes" : "none, so a private one will be created");
152
+ if (npmrc.names.length)
153
+ row(NPMRC, `reads ${npmrc.names.join(", ")}`);
139
154
  row("Settings", settingsText === null ? "none yet" : SETTINGS_FILE);
140
155
  row("Board", settings?.tickets.board != null
141
156
  ? `${settings.tickets.board}, from your settings`
142
157
  : "none yet");
143
158
  d.out("");
159
+ const refused = firstRefusal(npmrc);
160
+ if (refused) {
161
+ d.out(refused);
162
+ return 1;
163
+ }
144
164
  const pick = async (kind, question) => {
145
165
  const tools = d.tools[kind];
146
166
  if (only(tools))
@@ -167,14 +187,22 @@ export async function main(_argv, d) {
167
187
  hasCommand: d.hasCommand,
168
188
  opened: { codeHost, runner, tickets },
169
189
  });
170
- let secrets;
190
+ let own;
191
+ let npm;
192
+ // A secret the organization shares with the repository counts as set.
193
+ const isOrganization = await codeHost.ownerIsOrganization().catch(() => true);
194
+ let shared = [];
171
195
  try {
172
- secrets = await runner.secretNames();
196
+ own = await runner.secretNames();
197
+ if (isOrganization)
198
+ shared = await runner.organizationSecretNames().catch(() => []);
199
+ npm = await npmSecrets(npmrc, runner, codeHost, isOrganization);
173
200
  }
174
201
  catch (e) {
175
202
  d.out(`Could not reach the code host: ${message(e)}`);
176
203
  return 1;
177
204
  }
205
+ const secrets = [...own, ...shared];
178
206
  const isSet = (n) => secrets.includes(n);
179
207
  const cloudNeeds = secretSteps(d.tools, context(["cloud"])).flatMap((s) => s.step.needs.filter((n) => n.part === "cloud"));
180
208
  const before = partsOn(settings, secrets, cloudNeeds);
@@ -248,6 +276,48 @@ export async function main(_argv, d) {
248
276
  })), "30"));
249
277
  }
250
278
  }
279
+ // The board's columns: the coding agent suggests them when an existing
280
+ // board lacks one of the factory's and the settings name none, and a
281
+ // ready column is asked for when builds from the board turn on without
282
+ // one.
283
+ let columnLines = [];
284
+ let readyColumn;
285
+ if (parts.has("board") && typeof board === "number" && boardOps) {
286
+ const asksReady = parts.has("from-board") &&
287
+ !before.has("from-board") &&
288
+ settings?.tickets.columns.ready === null;
289
+ const suggests = !doc.hasIn(["tickets", "columns"]);
290
+ let names = [];
291
+ if (suggests || asksReady)
292
+ try {
293
+ names = await boardOps.columns(board);
294
+ }
295
+ catch (e) {
296
+ d.out(`Could not read board ${board}'s columns: ${message(e)}`);
297
+ d.out("Nothing changed.");
298
+ return 1;
299
+ }
300
+ const lacks = Object.values(STATE_KEYS).some((f) => !names.some((n) => sameName(n, f)));
301
+ if (suggests && names.length && lacks) {
302
+ const got = await suggestColumns({
303
+ ask: d.ask,
304
+ out: d.out,
305
+ agent: agent.agent,
306
+ label: agent.label,
307
+ hasCommand: d.hasCommand,
308
+ }, {
309
+ board,
310
+ columns: names,
311
+ fromBoard: parts.has("from-board") && trigger !== "manual",
312
+ });
313
+ if (got === 1)
314
+ return 1;
315
+ if (got !== "default")
316
+ columnLines = got;
317
+ }
318
+ else if (asksReady && settings)
319
+ readyColumn = await askReady({ ask: d.ask, out: d.out }, { columns: names, current: columnsOf(settings) });
320
+ }
251
321
  // The settings as they will stand, keeping every other key and comment.
252
322
  if (!doc.has("version"))
253
323
  doc.set("version", 2);
@@ -260,6 +330,12 @@ export async function main(_argv, d) {
260
330
  doc.setIn(["builds", "runner"], chosen.runner);
261
331
  if (parts.has("board") && typeof board === "number")
262
332
  doc.setIn(["tickets", "board"], board);
333
+ for (const [key, name] of columnLines)
334
+ doc.setIn(["tickets", "columns", key], name);
335
+ if (readyColumn === null)
336
+ remove(doc, ["tickets", "columns", "ready"]);
337
+ else if (readyColumn !== undefined)
338
+ doc.setIn(["tickets", "columns", "ready"], readyColumn);
263
339
  if (!parts.has("board"))
264
340
  for (const key of ["board", "columns", "fields"])
265
341
  remove(doc, ["tickets", key]);
@@ -298,7 +374,13 @@ export async function main(_argv, d) {
298
374
  // you choose to replace them.
299
375
  const steps = secretSteps(d.tools, context(parts));
300
376
  const needed = neededSecrets(parts, steps);
301
- const alreadySet = [...new Set(needed.flatMap((n) => n.anyOf.filter(isSet)))];
377
+ const npmBothSet = npm.tokens.filter((n) => isSet(n) && npm.dependabot(n) === "set");
378
+ const alreadySet = [
379
+ ...new Set([
380
+ ...needed.flatMap((n) => n.anyOf.filter(isSet)),
381
+ ...npmBothSet,
382
+ ]),
383
+ ];
302
384
  let replace = false;
303
385
  if (alreadySet.length)
304
386
  replace = await d.ask.confirm(alreadySet.length === 1
@@ -313,11 +395,22 @@ export async function main(_argv, d) {
313
395
  }))
314
396
  .filter((a) => a.names.length > 0);
315
397
  const wantsKey = parts.has("signing") && (replace || !isSet(SIGNING_KEY));
398
+ const npmAsked = npm.tokens
399
+ .map((name) => {
400
+ const again = replace && npmBothSet.includes(name);
401
+ return {
402
+ name,
403
+ actions: again || !isSet(name),
404
+ dependabot: again || npm.dependabot(name) !== "set",
405
+ unseen: !again && npm.dependabot(name) === "unknown",
406
+ };
407
+ })
408
+ .filter((a) => a.actions || a.dependabot);
316
409
  const stillRead = new Set(needed.flatMap((n) => n.anyOf));
317
410
  const deletable = [
318
411
  ...new Set(neededSecrets(new Set(removed), secretSteps(d.tools, context(removed)))
319
412
  .flatMap((n) => n.anyOf)
320
- .filter((n) => isSet(n) && !stillRead.has(n))),
413
+ .filter((n) => own.includes(n) && !stillRead.has(n))),
321
414
  ];
322
415
  // The plan.
323
416
  const newText = String(doc);
@@ -353,6 +446,8 @@ export async function main(_argv, d) {
353
446
  planRow("Board", `give board ${board} any of the factory's columns and fields it lacks`);
354
447
  if (toStore.length)
355
448
  planRow("Secrets", toStore.join(", "));
449
+ for (const a of npmAsked)
450
+ planRow("Secrets", `${a.name} ${forWhich(a)}`);
356
451
  if (parts.has("auto-merge"))
357
452
  planRow("Settings", "allow auto-merge on the repository");
358
453
  if (parts.has("review"))
@@ -378,7 +473,7 @@ export async function main(_argv, d) {
378
473
  if (typeof board === "number") {
379
474
  doc.setIn(["tickets", "board"], board);
380
475
  try {
381
- const shape = boardShape(settings);
476
+ const shape = boardShape(standing());
382
477
  const columns = await boardOps.addColumns(board, shape.columns);
383
478
  const fields = await boardOps.addFields(board, shape.fields);
384
479
  const added = [...columns, ...fields];
@@ -437,6 +532,32 @@ export async function main(_argv, d) {
437
532
  break;
438
533
  }
439
534
  }
535
+ // The tokens .npmrc reads, each stored where it is missing.
536
+ for (const a of npmAsked) {
537
+ d.out("");
538
+ let prompt = "Paste the same token again (leave empty to do this later):";
539
+ if (a.actions && a.dependabot) {
540
+ d.out(`${NPMRC} reads ${a.name} for ${addressOf(npmrc, a.name)}.`);
541
+ d.out("The factory's workflows install with it. Use a token that can only read.");
542
+ prompt = "Paste it (leave empty to do this later):";
543
+ }
544
+ else if (!a.unseen)
545
+ d.out(a.actions
546
+ ? `${a.name} is set for Dependabot but not for Actions, and GitHub never shows a secret's value.`
547
+ : `${a.name} is set for Actions but not for Dependabot, and GitHub never shows a secret's value.`);
548
+ if (a.unseen)
549
+ d.out(`${a.name} isn't set for Dependabot on this repository, and only an organization admin can see whether your organization sets it. If it does, leave this empty.`);
550
+ const value = await d.ask.secret(prompt);
551
+ if (!value) {
552
+ d.out(`No ${a.name} stored. The factory's workflows fail at npm ci until it is. ${AGAIN}`);
553
+ continue;
554
+ }
555
+ if (a.actions)
556
+ await runner.setSecret(a.name, value);
557
+ if (a.dependabot)
558
+ await runner.setDependabotSecret(a.name, value);
559
+ d.out(`Stored ${a.name} ${forWhich(a)}.`);
560
+ }
440
561
  // The signing key.
441
562
  if (wantsKey) {
442
563
  const key = await d.keygen();
@@ -614,3 +735,30 @@ export async function run(argv) {
614
735
  throw e;
615
736
  }
616
737
  }
738
+ /** The tokens `.npmrc` reads, and whether each is set for Dependabot. */
739
+ async function npmSecrets(npmrc, runner, codeHost, isOrganization) {
740
+ const tokens = npmrc.names.filter((n) => n !== "GITHUB_TOKEN");
741
+ if (!tokens.length)
742
+ return { tokens, dependabot: () => "set" };
743
+ const own = await runner.dependabotSecretNames();
744
+ const organization = isOrganization && tokens.some((n) => !own.includes(n))
745
+ ? await runner.organizationDependabotSecretNames(await codeHost.isPrivate())
746
+ : [];
747
+ return {
748
+ tokens,
749
+ dependabot: (name) => own.includes(name)
750
+ ? "set"
751
+ : organization === null
752
+ ? isOrganization
753
+ ? "unknown"
754
+ : "missing"
755
+ : organization.includes(name)
756
+ ? "set"
757
+ : "missing",
758
+ };
759
+ }
760
+ const forWhich = (a) => a.actions && a.dependabot
761
+ ? "for Actions and for Dependabot"
762
+ : a.actions
763
+ ? "for Actions"
764
+ : "for Dependabot";
@@ -16,17 +16,20 @@ export declare const STATE_KEYS: {
16
16
  readonly done: "Done";
17
17
  };
18
18
  export type StateKey = keyof typeof STATE_KEYS;
19
- /** The column each state has on the board, or null for a board with none. */
20
- export type Columns = Record<Status, string | null>;
19
+ /** The columns each state has on the board, the first the one a ticket
20
+ * moves to, or null for a board with none. */
21
+ export type Columns = Record<Status, readonly string[] | null>;
21
22
  /** The factory's own board: every state has the column of its own name. */
22
23
  export declare const DEFAULT_COLUMNS: Columns;
23
24
  /** A name matches whatever its capitals and the spaces around it. */
24
25
  export declare const sameName: (a: string, b: string) => boolean;
25
- /** The column a ticket in `status` shows in: its own, or else the nearest
26
- * earlier state's. Nothing but an approved ticket shows in the Ready
27
- * column, so a state with no column passes over it. */
28
- export declare function columnFor(status: Status, columns: Columns): string;
29
- /** The state whose column is named `name`, or null when none is. */
26
+ /** The columns a ticket in `status` shows in: its own, or else the
27
+ * nearest earlier state's. Nothing but an approved ticket shows in the
28
+ * Ready column, so a state with no column passes over it. */
29
+ export declare function columnsFor(status: Status, columns: Columns): readonly string[];
30
+ /** The column a ticket in `status` moves to: the first of `columnsFor`. */
31
+ export declare const columnFor: (status: Status, columns: Columns) => string;
32
+ /** The state that lists a column named `name`, or null when none does. */
30
33
  export declare function statusOfColumn(name: string, columns: Columns): Status | null;
31
34
  export type RunsIn = "Local" | "Actions" | "";
32
35
  /** Where a session runs: on a person's machine, or in a GitHub Actions run. */
@@ -21,30 +21,31 @@ export const STATE_KEYS = {
21
21
  };
22
22
  /** The factory's own board: every state has the column of its own name. */
23
23
  export const DEFAULT_COLUMNS = {
24
- Backlog: "Backlog",
25
- "In refinement": "In refinement",
26
- Ready: "Ready",
27
- "In progress": "In progress",
28
- "In review": "In review",
29
- Done: "Done",
24
+ Backlog: ["Backlog"],
25
+ "In refinement": ["In refinement"],
26
+ Ready: ["Ready"],
27
+ "In progress": ["In progress"],
28
+ "In review": ["In review"],
29
+ Done: ["Done"],
30
30
  };
31
31
  /** A name matches whatever its capitals and the spaces around it. */
32
32
  export const sameName = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
33
- /** The column a ticket in `status` shows in: its own, or else the nearest
34
- * earlier state's. Nothing but an approved ticket shows in the Ready
35
- * column, so a state with no column passes over it. */
36
- export function columnFor(status, columns) {
33
+ /** The columns a ticket in `status` shows in: its own, or else the
34
+ * nearest earlier state's. Nothing but an approved ticket shows in the
35
+ * Ready column, so a state with no column passes over it. */
36
+ export function columnsFor(status, columns) {
37
37
  for (let i = STATUSES.indexOf(status); i >= 0; i--) {
38
- const name = columns[STATUSES[i]];
39
- if (name !== null && (STATUSES[i] !== "Ready" || status === "Ready"))
40
- return name;
38
+ const names = columns[STATUSES[i]];
39
+ if (names !== null && (STATUSES[i] !== "Ready" || status === "Ready"))
40
+ return names;
41
41
  }
42
- return columns.Backlog ?? "Backlog";
42
+ return columns.Backlog ?? ["Backlog"];
43
43
  }
44
- /** The state whose column is named `name`, or null when none is. */
44
+ /** The column a ticket in `status` moves to: the first of `columnsFor`. */
45
+ export const columnFor = (status, columns) => columnsFor(status, columns)[0];
46
+ /** The state that lists a column named `name`, or null when none does. */
45
47
  export function statusOfColumn(name, columns) {
46
- return (STATUSES.find((s) => columns[s] !== null && sameName(columns[s], name)) ??
47
- null);
48
+ return (STATUSES.find((s) => columns[s]?.some((c) => sameName(c, name))) ?? null);
48
49
  }
49
50
  /** How a sentence names where the card is: "In progress" when the state has
50
51
  * a column of its own, "in Todo" when it shows in another's. */
@@ -441,7 +442,7 @@ const waiting = (columns) => `The card stays ${cardAt("In progress", columns)},
441
442
  /** Where a ticket can be sent to build again: the Ready column when the
442
443
  * board has one, and always a session. */
443
444
  const again = (issue, columns) => {
444
- const ready = columns.Ready;
445
+ const ready = columns.Ready?.[0] ?? null;
445
446
  if (ready === null)
446
447
  return `To try again, tell a session to build #${issue}, or run \`factory build ${issue}\`.`;
447
448
  return `Move it to ${ready} to try again.`;
@@ -451,7 +452,7 @@ export function commentBody(c, columns = DEFAULT_COLUMNS) {
451
452
  // A session's cost note goes after what the comment says.
452
453
  const withCost = (text, cost) => cost ? `${text}\n\n${cost}` : text;
453
454
  const WAITING = waiting(columns);
454
- const ready = columns.Ready;
455
+ const ready = columns.Ready?.[0] ?? null;
455
456
  switch (c.kind) {
456
457
  case "cost":
457
458
  return `${c.cost}\n${AGENT_MARK}`;
@@ -0,0 +1,29 @@
1
+ export declare const NPMRC = ".npmrc";
2
+ export type SignIn = {
3
+ name: string;
4
+ key: string;
5
+ };
6
+ export type Npmrc = {
7
+ /** Each variable a sign-in line reads, once, in the order first read. */
8
+ names: string[];
9
+ signIns: SignIn[];
10
+ /** Each registry URL a `registry=` or `@scope:registry=` line names. */
11
+ registries: string[];
12
+ };
13
+ export declare function readNpmrc(text: string | null): Npmrc;
14
+ /** The `.npmrc` at the root, read; nothing when there is none. */
15
+ export declare function npmrcAt(root: string): Npmrc;
16
+ /** Why a name can't be set from a secret, or null when it can. */
17
+ export declare function refusal(name: string): string | null;
18
+ /** The first refusal among the names, or null. */
19
+ export declare const firstRefusal: (n: Npmrc) => string | null;
20
+ declare const bare: (url: string) => string;
21
+ /** The registry a sign-in line is for: the registry URL whose host and
22
+ * path its key starts with, the longest when several do, or else the
23
+ * key's own `//host/path/`. */
24
+ export declare function addressOf(n: Npmrc, name: string): string;
25
+ /** The registries Dependabot has to be told, the public one aside. */
26
+ export declare const privateRegistries: (n: Npmrc) => string[];
27
+ /** The registry `.npmrc` sends a package's scope to, or null. */
28
+ export declare function npmrcRegistry(text: string | null, pkg: string): string | null;
29
+ export { bare as bareRegistry };