@open-tomato/rafa 0.49.0 → 0.50.0

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/cli.js CHANGED
@@ -3963,7 +3963,7 @@ var init_shared_flags = __esm(() => {
3963
3963
  });
3964
3964
 
3965
3965
  // package.json
3966
- var name = "@open-tomato/rafa", version = "0.49.0";
3966
+ var name = "@open-tomato/rafa", version = "0.50.0";
3967
3967
  var init_package = () => {};
3968
3968
 
3969
3969
  // packages/rafa/src/core/command/version.ts
@@ -13270,6 +13270,7 @@ var init_retry = __esm(() => {
13270
13270
  RETRIED = Object.freeze([
13271
13271
  /operation timed out|i\/o timeout|TLS handshake timeout/u,
13272
13272
  /connection reset|\bEOF\b/u,
13273
+ /unexpected end of JSON input/u,
13273
13274
  /\bHTTP 50[234]\b/u
13274
13275
  ]);
13275
13276
  FIRST_FIELD = /\{\s*([A-Za-z_]\w*)/u;
@@ -31214,17 +31215,16 @@ function triggerCandidate(lesson) {
31214
31215
  return { record: record2, description: null, body: "" };
31215
31216
  }
31216
31217
  function triggerMatches(lesson, words) {
31217
- return words.length > 0 && scoreCandidate(triggerCandidate(lesson), words).score > RANK_FLOOR;
31218
+ return scoreCandidate(triggerCandidate(lesson), words).words.length >= TRIGGER_WORD_FLOOR;
31218
31219
  }
31219
31220
  function selectLessons(task, bundle) {
31220
31221
  const words = questionWords(task.text);
31221
31222
  const kept = bundle.instincts.filter((lesson) => artifactMatches(lesson, task) || triggerMatches(lesson, words));
31222
31223
  return [...kept].sort((a, b) => b.confidence - a.confidence).slice(0, LESSON_LIMIT);
31223
31224
  }
31224
- var LESSON_LIMIT = 5;
31225
+ var LESSON_LIMIT = 5, TRIGGER_WORD_FLOOR = 2;
31225
31226
  var init_select_lessons = __esm(() => {
31226
31227
  init_rank();
31227
- init_resolve_skills();
31228
31228
  });
31229
31229
 
31230
31230
  // packages/rafa-inventory/src/tiers/routing.ts
@@ -31297,14 +31297,35 @@ function subagentLogPaths(sessionLogPath) {
31297
31297
  return [];
31298
31298
  return readdirSync14(dir, { withFileTypes: true }).filter((entry) => entry.isFile() && SUBAGENT_LOG_NAME.test(entry.name)).map((entry) => join49(dir, entry.name)).sort((a, b) => a.localeCompare(b));
31299
31299
  }
31300
- function applyVersion(tally, record2, cliVersion) {
31300
+ function versionFields(version2) {
31301
+ if (typeof version2 !== "string")
31302
+ return null;
31303
+ const match = CLI_VERSION_SHAPE.exec(version2);
31304
+ return match === null ? null : match.slice(1).map(Number);
31305
+ }
31306
+ function compareCliVersions(a, b) {
31307
+ const left = versionFields(a);
31308
+ const right = versionFields(b);
31309
+ if (left === null || right === null) {
31310
+ if (left !== right) {
31311
+ return left === null ? -1 : 1;
31312
+ }
31313
+ return a.localeCompare(b);
31314
+ }
31315
+ const differing = left.findIndex((field5, index) => field5 !== right[index]);
31316
+ return differing === -1 ? 0 : (left[differing] ?? 0) - (right[differing] ?? 0);
31317
+ }
31318
+ function applyVersion(tally, record2, floor) {
31301
31319
  const version2 = record2["version"];
31302
31320
  if (version2 === undefined)
31303
31321
  return;
31304
- if (version2 === cliVersion)
31305
- tally.pinned += 1;
31306
- else
31307
- tally.mismatched += 1;
31322
+ const text2 = String(version2);
31323
+ tally.versions.add(text2);
31324
+ if (typeof version2 === "string" && compareCliVersions(version2, floor) >= 0) {
31325
+ tally.atOrAbove += 1;
31326
+ } else {
31327
+ tally.belowFloor += 1;
31328
+ }
31308
31329
  }
31309
31330
  function applyCalls(tally, record2, sidechain) {
31310
31331
  if (record2["type"] !== "assistant")
@@ -31325,7 +31346,7 @@ function applyCalls(tally, record2, sidechain) {
31325
31346
  tally.counts.set(key, (tally.counts.get(key) ?? 0) + 1);
31326
31347
  }
31327
31348
  }
31328
- async function applySource(tally, source, cliVersion) {
31349
+ async function applySource(tally, source, floor) {
31329
31350
  for await (const rawLine of source.lines) {
31330
31351
  const line = rawLine.trim();
31331
31352
  if (line.length === 0)
@@ -31335,7 +31356,7 @@ async function applySource(tally, source, cliVersion) {
31335
31356
  tally.unreadable += 1;
31336
31357
  continue;
31337
31358
  }
31338
- applyVersion(tally, record2, cliVersion);
31359
+ applyVersion(tally, record2, floor);
31339
31360
  applyCalls(tally, record2, source.subagent || record2["isSidechain"] === true);
31340
31361
  }
31341
31362
  }
@@ -31346,27 +31367,32 @@ function usesOf(counts) {
31346
31367
  });
31347
31368
  return uses.sort((a, b) => a.name.localeCompare(b.name) || Number(a.sidechain) - Number(b.sidechain));
31348
31369
  }
31349
- async function collectSkillUse(sessionId, sources, cliVersion = SKILL_USE_CLI_VERSION) {
31350
- const tally = { counts: new Map, mismatched: 0, pinned: 0, unreadable: 0 };
31370
+ async function collectSkillUse(sessionId, sources, floor = SKILL_USE_CLI_FLOOR) {
31371
+ if (versionFields(floor) === null)
31372
+ throw new TypeError(`skill-use floor ${JSON.stringify(floor)} is not an X.Y.Z version`);
31373
+ const tally = { counts: new Map, belowFloor: 0, atOrAbove: 0, versions: new Set, unreadable: 0 };
31351
31374
  for (const source of sources)
31352
- await applySource(tally, source, cliVersion);
31353
- if (tally.mismatched > 0 || tally.pinned === 0 || tally.unreadable > 0) {
31354
- return { sessionId, uses: UNKNOWN_SKILL_COUNT };
31375
+ await applySource(tally, source, floor);
31376
+ const versions = [...tally.versions].sort(compareCliVersions);
31377
+ if (tally.belowFloor > 0 || tally.atOrAbove === 0 || tally.unreadable > 0) {
31378
+ return { sessionId, uses: UNKNOWN_SKILL_COUNT, vouched: false, versions };
31355
31379
  }
31356
- return { sessionId, uses: usesOf(tally.counts) };
31380
+ const vouched = versions.length === 1 && versions[0] === SKILL_USE_FIXTURE_VERSION;
31381
+ return { sessionId, uses: usesOf(tally.counts), vouched, versions };
31357
31382
  }
31358
- async function readSkillUse(sessionLogPath, cliVersion = SKILL_USE_CLI_VERSION) {
31383
+ async function readSkillUse(sessionLogPath, floor = SKILL_USE_CLI_FLOOR) {
31359
31384
  const sources = [
31360
31385
  { lines: readLines2(sessionLogPath), subagent: false },
31361
31386
  ...subagentLogPaths(sessionLogPath).map((path3) => ({ lines: readLines2(path3), subagent: true }))
31362
31387
  ];
31363
- return collectSkillUse(sessionIdFromPath(sessionLogPath), sources, cliVersion);
31388
+ return collectSkillUse(sessionIdFromPath(sessionLogPath), sources, floor);
31364
31389
  }
31365
- var SKILL_USE_CLI_VERSION = "2.1.280", SKILL_TOOL = "Skill", SUBAGENT_LOG_NAME;
31390
+ var SKILL_USE_CLI_FLOOR = "2.1.280", SKILL_USE_FIXTURE_VERSION = "2.1.280", CLI_VERSION_SHAPE, SKILL_TOOL = "Skill", SUBAGENT_LOG_NAME;
31366
31391
  var init_skill_use = __esm(() => {
31367
31392
  init_session_log();
31368
31393
  init_skill_invocations();
31369
31394
  init_rafa_inventory();
31395
+ CLI_VERSION_SHAPE = /^(\d+)\.(\d+)\.(\d+)$/u;
31370
31396
  SUBAGENT_LOG_NAME = /^agent-.+\.jsonl$/;
31371
31397
  });
31372
31398
 
@@ -31374,6 +31400,11 @@ var init_skill_use = __esm(() => {
31374
31400
  function messageOf9(error2) {
31375
31401
  return error2 instanceof Error ? error2.message : String(error2);
31376
31402
  }
31403
+ function readingNote(reading2) {
31404
+ const versions = reading2.versions.length === 0 ? "no version" : reading2.versions.join(", ");
31405
+ const standing = reading2.uses === UNKNOWN_SKILL_COUNT ? "unknown" : reading2.vouched ? "vouched" : "unvouched";
31406
+ return `skills: read ${reading2.sessionId} (${versions}, ${standing})`;
31407
+ }
31377
31408
  function countedSessions(repoRoot) {
31378
31409
  return new Set(readSkillInvocations(repoRoot).map((row) => row.sessionId));
31379
31410
  }
@@ -31384,8 +31415,9 @@ async function collectSkillHalf(input) {
31384
31415
  let failed3 = 0;
31385
31416
  for (const log of pending) {
31386
31417
  try {
31387
- readings.push(await readSkillUse(log.path));
31388
- input.note(`skills: read ${log.sessionId}`);
31418
+ const reading2 = await readSkillUse(log.path);
31419
+ readings.push(reading2);
31420
+ input.note(readingNote(reading2));
31389
31421
  } catch (error2) {
31390
31422
  failed3 += 1;
31391
31423
  input.log(`skills: FAILED ${log.path}: ${messageOf9(error2)}`);
@@ -31398,6 +31430,7 @@ async function collectSkillHalf(input) {
31398
31430
  candidates: input.logs.length,
31399
31431
  alreadyCounted: input.logs.length - pending.length,
31400
31432
  read: readings.length,
31433
+ unvouched: readings.filter((reading2) => reading2.uses !== UNKNOWN_SKILL_COUNT && !reading2.vouched).length,
31401
31434
  unknown: readings.filter((reading2) => reading2.uses === UNKNOWN_SKILL_COUNT).length,
31402
31435
  failed: failed3,
31403
31436
  appended: written5.appended,
@@ -31408,7 +31441,7 @@ function formatSkillSummary(skills) {
31408
31441
  if (skills === null)
31409
31442
  return " skills skipped (--no-sessions)";
31410
31443
  const scope = skills.scope === "held" ? "stored" : "appended";
31411
- return ` skills ${skills.candidates} ${scope} sessions` + `, ${skills.alreadyCounted} already counted` + `, ${skills.read} read` + `, ${skills.unknown} unknown` + `, ${skills.failed} failed` + `, +${skills.appended} rows`;
31444
+ return ` skills ${skills.candidates} ${scope} sessions` + `, ${skills.alreadyCounted} already counted` + `, ${skills.read} read` + `, ${skills.unvouched} unvouched` + `, ${skills.unknown} unknown` + `, ${skills.failed} failed` + `, +${skills.appended} rows`;
31412
31445
  }
31413
31446
  var init_collect_skills = __esm(() => {
31414
31447
  init_skill_invocations();
@@ -45362,18 +45395,31 @@ function readMergeRefusal(reading2) {
45362
45395
  const held2 = worktreesHolding(reading2.worktrees, reading2.branch, reading2.at);
45363
45396
  return held2.length === 0 ? null : worktreeRefusal(reading2.branch, held2);
45364
45397
  }
45398
+ function pullRetry(git, base2) {
45399
+ return Object.freeze({
45400
+ when: MULTIPLE_BRANCHES_TEXT,
45401
+ before: Object.freeze([...git, "fetch", DEFAULT_REMOTE2, base2])
45402
+ });
45403
+ }
45365
45404
  function baseSteps(base2, heldAt) {
45366
45405
  if (heldAt === null) {
45367
45406
  return [
45368
45407
  { id: "switch-base", label: `switch to ${base2}`, argv: ["git", "switch", base2] },
45369
- { id: "pull-base", label: `pull ${base2}, fast-forward only`, argv: ["git", "pull", "--ff-only"] }
45408
+ {
45409
+ id: "pull-base",
45410
+ label: `pull ${base2}, fast-forward only`,
45411
+ argv: ["git", "pull", "--ff-only"],
45412
+ retry: pullRetry(["git"], base2)
45413
+ }
45370
45414
  ];
45371
45415
  }
45416
+ const git = ["git", "-C", heldAt];
45372
45417
  return [
45373
45418
  {
45374
45419
  id: "pull-base",
45375
45420
  label: `pull ${base2} in ${heldAt}, fast-forward only`,
45376
- argv: ["git", "-C", heldAt, "pull", "--ff-only"]
45421
+ argv: [...git, "pull", "--ff-only"],
45422
+ retry: pullRetry(git, base2)
45377
45423
  },
45378
45424
  { id: "switch-base", label: `detach this checkout at ${base2}`, argv: ["git", "switch", "--detach", base2] }
45379
45425
  ];
@@ -45421,7 +45467,7 @@ function remainingFrom(steps, failed5) {
45421
45467
  const at = steps.findIndex((step) => step.id === failed5);
45422
45468
  return at === -1 ? Object.freeze([]) : Object.freeze(steps.slice(at).filter((step) => step.skip === undefined));
45423
45469
  }
45424
- var REFUSAL_PREFIX = "rafa pr merge refuses", MAX_LISTED_CHANGES2 = 10, DEFAULT_REMOTE2 = "origin", BRANCH_REF_PREFIX = "refs/heads/", INDENT3 = " ", UNTRACKED_PREFIX3 = "?? ";
45470
+ var REFUSAL_PREFIX = "rafa pr merge refuses", MAX_LISTED_CHANGES2 = 10, DEFAULT_REMOTE2 = "origin", BRANCH_REF_PREFIX = "refs/heads/", INDENT3 = " ", UNTRACKED_PREFIX3 = "?? ", MULTIPLE_BRANCHES_TEXT = "Cannot fast-forward to multiple branches";
45425
45471
  var init_merge2 = __esm(() => {
45426
45472
  init_git2();
45427
45473
  init_shell();
@@ -51002,6 +51048,18 @@ function quotedLines2(said) {
51002
51048
  return said === "" ? [] : said.split(`
51003
51049
  `).map((line) => `${INDENT7}${line}`);
51004
51050
  }
51051
+ function runStep3(git, step2, info2) {
51052
+ const first = git(step2.argv.slice(1));
51053
+ const retry = step2.retry;
51054
+ if (first.ok || retry === undefined || !gitSaid(first).includes(retry.when)) {
51055
+ return { result: first, retried: false };
51056
+ }
51057
+ info2(`${step2.label}: retrying after ${retry.before.join(" ")}`);
51058
+ const before = git(retry.before.slice(1));
51059
+ if (!before.ok)
51060
+ return { result: before, retried: true };
51061
+ return { result: git(step2.argv.slice(1)), retried: true };
51062
+ }
51005
51063
  function runCleanUp(git, merged, present, info2, shape = {}) {
51006
51064
  const steps = cleanUpSteps({
51007
51065
  branch: merged.headRefName,
@@ -51014,12 +51072,12 @@ function runCleanUp(git, merged, present, info2, shape = {}) {
51014
51072
  const reports = [];
51015
51073
  for (const step2 of steps) {
51016
51074
  if (step2.skip !== undefined) {
51017
- reports.push({ id: step2.id, label: step2.label, command: commandLine(step2), ok: true, skipped: true });
51075
+ reports.push({ id: step2.id, label: step2.label, command: commandLine(step2), ok: true, skipped: true, retried: false });
51018
51076
  info2(`${step2.label}: skipped \u2014 ${step2.skip}`);
51019
51077
  continue;
51020
51078
  }
51021
- const result2 = git(step2.argv.slice(1));
51022
- reports.push({ id: step2.id, label: step2.label, command: commandLine(step2), ok: result2.ok, skipped: false });
51079
+ const { result: result2, retried } = runStep3(git, step2, info2);
51080
+ reports.push({ id: step2.id, label: step2.label, command: commandLine(step2), ok: result2.ok, skipped: false, retried });
51023
51081
  if (result2.ok) {
51024
51082
  info2(`${step2.label}: done`);
51025
51083
  continue;
@@ -53197,7 +53255,7 @@ function forcedPushRefusal(argv) {
53197
53255
  const words = forcing.map((word) => `\`${word}\``).join(", ");
53198
53256
  return `${REFUSAL_PREFIX4} a push that git would force: ${words}.` + " A resolve run never overwrites what is on the remote, so nothing was pushed.";
53199
53257
  }
53200
- function runStep3(git, step2) {
53258
+ function runStep4(git, step2) {
53201
53259
  const result2 = git(step2.argv.slice(1));
53202
53260
  return {
53203
53261
  id: step2.id,
@@ -53207,16 +53265,16 @@ function runStep3(git, step2) {
53207
53265
  };
53208
53266
  }
53209
53267
  function addResolveWorktree(git, path3, branch) {
53210
- return runStep3(git, addWorktreeStep(path3, branch));
53268
+ return runStep4(git, addWorktreeStep(path3, branch));
53211
53269
  }
53212
53270
  function removeResolveWorktree(git, path3) {
53213
- return runStep3(git, removeWorktreeStep(path3));
53271
+ return runStep4(git, removeWorktreeStep(path3));
53214
53272
  }
53215
53273
  function pushResolved(git, branch, remote = DEFAULT_REMOTE3) {
53216
53274
  const step2 = pushResolvedStep(branch, remote);
53217
53275
  const refusal13 = forcedPushRefusal(step2.argv);
53218
53276
  if (refusal13 === null)
53219
- return runStep3(git, step2);
53277
+ return runStep4(git, step2);
53220
53278
  return { id: step2.id, ok: false, command: worktreeCommandLine(step2), said: refusal13 };
53221
53279
  }
53222
53280
  function pathForms2(path3) {
@@ -60078,7 +60136,7 @@ function removeRun(files, step2) {
60078
60136
  }
60079
60137
  return { step: step2, ran: true, ok: true, command: command36, said: "" };
60080
60138
  }
60081
- function runStep4(git, files, step2, removed) {
60139
+ function runStep5(git, files, step2, removed) {
60082
60140
  const refusal16 = forcedFlagRefusal(step2.argv);
60083
60141
  if (refusal16 !== null)
60084
60142
  return notRun2(step2, refusal16);
@@ -60092,7 +60150,7 @@ function runStep4(git, files, step2, removed) {
60092
60150
  function runCleanupSteps(git, plan, files = DEFAULT_CLEANUP_FILES) {
60093
60151
  const removed = new Set;
60094
60152
  return plan.steps.map((step2) => {
60095
- const outcome2 = runStep4(git, files, step2, removed);
60153
+ const outcome2 = runStep5(git, files, step2, removed);
60096
60154
  if (outcome2.ok && step2.kind === "remove-worktree")
60097
60155
  removed.add(step2.subject);
60098
60156
  return outcome2;
@@ -78928,8 +78986,8 @@ init_command2();
78928
78986
  init_sections();
78929
78987
  init_loop();
78930
78988
  init_plan();
78931
- import { closeSync as closeSync3, mkdirSync as mkdirSync34, openSync as openSync3, readdirSync as readdirSync28, readFileSync as readFileSync99, statSync as statSync33 } from "fs";
78932
- import { dirname as dirname48, join as join122, posix as posix13 } from "path";
78989
+ import { closeSync as closeSync3, mkdirSync as mkdirSync34, openSync as openSync3, readdirSync as readdirSync28, readFileSync as readFileSync100, statSync as statSync34 } from "fs";
78990
+ import { dirname as dirname48, join as join122, posix as posix14 } from "path";
78933
78991
 
78934
78992
  // src/stretch/launch.ts
78935
78993
  init_shell();
@@ -79312,6 +79370,140 @@ function filedSinceLines(filed) {
79312
79370
  return [`Filed since ${since}: ${String(bugs.length)}.`, ...bugs.map(filedBugLine)];
79313
79371
  }
79314
79372
 
79373
+ // src/commands/stretch/item-checks.ts
79374
+ init_rafa_pr();
79375
+ init_command2();
79376
+ init_sections();
79377
+
79378
+ // src/commands/stretch/item-pull.ts
79379
+ init_command2();
79380
+ init_sections();
79381
+ var COMMAND_NAME14 = "rafa stretch item";
79382
+ var FAILED_EXIT = 2;
79383
+ var SHA = /^[0-9a-f]{40}$/;
79384
+ var PR_VIEW_FIELDS = ["number", "state", "baseRefName", "headRefName", "body", "mergeCommit", "mergeable"];
79385
+ function failure8(why) {
79386
+ return new CommandExit(FAILED_EXIT, `\u274C ${COMMAND_NAME14}: ${why}`);
79387
+ }
79388
+ function prViewArgs(number) {
79389
+ return ["pr", "view", String(number), "--json", PR_VIEW_FIELDS.join(",")];
79390
+ }
79391
+ function textField2(row2, field5, command56) {
79392
+ const value = row2[field5];
79393
+ if (typeof value !== "string")
79394
+ throw failure8(`${command56} answered ${field5} ${describeValue(value)}, expected a string`);
79395
+ return value;
79396
+ }
79397
+ function mergeCommitOf(value, command56) {
79398
+ if (value === null || value === undefined)
79399
+ return null;
79400
+ const oid = isMapping(value) ? value["oid"] : undefined;
79401
+ if (typeof oid !== "string" || !SHA.test(oid)) {
79402
+ throw failure8(`${command56} answered mergeCommit ${describeValue(value)}, expected null or an object holding a 40-character oid`);
79403
+ }
79404
+ return oid;
79405
+ }
79406
+ async function viewPull(gh, number) {
79407
+ const args = prViewArgs(number);
79408
+ const command56 = `gh ${args.join(" ")}`;
79409
+ const result2 = await gh(args);
79410
+ if (!result2.ok) {
79411
+ const said = result2.stderr.trim() || result2.stdout.trim() || "it exited non-zero and wrote nothing";
79412
+ throw failure8(`${command56} failed: ${said}`);
79413
+ }
79414
+ let row2;
79415
+ try {
79416
+ row2 = JSON.parse(result2.stdout);
79417
+ } catch (error2) {
79418
+ throw failure8(`${command56} wrote output that is not JSON: ${messageOf(error2)}`);
79419
+ }
79420
+ if (!isMapping(row2))
79421
+ throw failure8(`${command56} answered ${describeValue(row2)}, expected an object`);
79422
+ if (row2["number"] !== number)
79423
+ throw failure8(`${command56} answered number ${describeValue(row2["number"])}`);
79424
+ return {
79425
+ number,
79426
+ state: textField2(row2, "state", command56),
79427
+ base: textField2(row2, "baseRefName", command56),
79428
+ head: textField2(row2, "headRefName", command56),
79429
+ body: textField2(row2, "body", command56),
79430
+ mergeCommit: mergeCommitOf(row2["mergeCommit"], command56),
79431
+ mergeable: textField2(row2, "mergeable", command56)
79432
+ };
79433
+ }
79434
+
79435
+ // src/commands/stretch/item-checks.ts
79436
+ var COMMAND_NAME15 = "rafa stretch item";
79437
+ var MERGEABILITY_POLL_MS = 5000;
79438
+ var MERGEABILITY_WAIT_MS = 2 * 60000;
79439
+ var CHECKS_POLL_MS = CI_POLL_INTERVAL_MS;
79440
+ var CHECKS_WAIT_MS = DEFAULT_CI_TIMEOUT_MIN * 60000;
79441
+ var UNKNOWN2 = "UNKNOWN";
79442
+ var CONFLICTING = "CONFLICTING";
79443
+ var REFUSED_EXIT3 = 1;
79444
+ var FAILED_EXIT2 = 2;
79445
+ function resumeLine(issue5) {
79446
+ return `${COMMAND_NAME15} ${String(issue5)} --resume`;
79447
+ }
79448
+ function refusal23(target, why, then) {
79449
+ return new CommandExit(REFUSED_EXIT3, `\u274C ${COMMAND_NAME15}: ${why} Nothing was merged; ${then}` + ` finish the item with ${resumeLine(target.issue)}.`);
79450
+ }
79451
+ function boundText(ms) {
79452
+ return ms >= 60000 ? `${String(ms / 60000)} minutes` : `${String(ms / 1000)}s`;
79453
+ }
79454
+ async function awaitMergeability(context, gh, target, seams) {
79455
+ const pr = `#${String(target.number)}`;
79456
+ const since = seams.now().getTime();
79457
+ for (;; ) {
79458
+ const pull = await viewPull(gh, target.number);
79459
+ context.output.info(`${pr} mergeability: ${pull.mergeable}`);
79460
+ if (pull.mergeable === CONFLICTING) {
79461
+ throw refusal23(target, `${pr} reads ${CONFLICTING}: its head does not merge into ${pull.base}.`, `read it with rafa pr show ${String(target.number)}, resolve the conflict on ${pull.head}, then`);
79462
+ }
79463
+ if (pull.mergeable !== UNKNOWN2)
79464
+ return pull;
79465
+ if (seams.now().getTime() - since >= MERGEABILITY_WAIT_MS) {
79466
+ throw refusal23(target, `${pr} still reads ${UNKNOWN2} mergeability after ${boundText(MERGEABILITY_WAIT_MS)}.`, "once GitHub has computed it,");
79467
+ }
79468
+ await seams.sleep(MERGEABILITY_POLL_MS);
79469
+ }
79470
+ }
79471
+ async function awaitChecks(context, gh, target, seams) {
79472
+ const pr = `#${String(target.number)}`;
79473
+ const pulls = createGhPullRequests({ gh });
79474
+ const probe3 = async () => {
79475
+ try {
79476
+ return (await pulls.checks(target.number)).rows;
79477
+ } catch (error2) {
79478
+ throw new CommandExit(FAILED_EXIT2, `\u274C ${COMMAND_NAME15}: the checks of ${pr} could not be read: ${messageOf(error2)}`);
79479
+ }
79480
+ };
79481
+ const now = () => seams.now().getTime();
79482
+ context.output.info(`waiting for the checks of ${pr}, up to ${boundText(CHECKS_WAIT_MS)}`);
79483
+ const waited = await waitForChecks({
79484
+ probe: probe3,
79485
+ timeoutMs: CHECKS_WAIT_MS,
79486
+ intervalMs: CHECKS_POLL_MS,
79487
+ now,
79488
+ sleep: seams.sleep,
79489
+ headCommittedAtMs: now(),
79490
+ onPoll: (rows2, verdict, elapsedMs) => {
79491
+ context.output.info(`checks of ${pr} after ${String(Math.round(elapsedMs / 1000))}s: ${verdict}
79492
+ ${formatRows(rows2)}`);
79493
+ }
79494
+ });
79495
+ const number = String(target.number);
79496
+ if (waited.verdict === "green")
79497
+ return;
79498
+ if (waited.verdict === "red") {
79499
+ throw refusal23(target, `a check of ${pr} failed.`, `read it with rafa pr triage ${number}, and once the checks pass,`);
79500
+ }
79501
+ if (waited.verdict === "none") {
79502
+ throw refusal23(target, `${pr} reports no check, and rafa pr merge ${number} --yes refuses it.`, `merge it by hand with rafa pr merge ${number} --skip-checks --yes, then`);
79503
+ }
79504
+ throw refusal23(target, `the checks of ${pr} had not ended after ${boundText(CHECKS_WAIT_MS)}.`, "once they pass,");
79505
+ }
79506
+
79315
79507
  // src/commands/stretch/start.ts
79316
79508
  init_rafa_board();
79317
79509
  init_rafa_pr();
@@ -79399,15 +79591,15 @@ function squeezeBlankRuns(lines3) {
79399
79591
  }
79400
79592
 
79401
79593
  // src/commands/stretch/start.ts
79402
- var COMMAND_NAME14 = "rafa stretch start";
79594
+ var COMMAND_NAME16 = "rafa stretch start";
79403
79595
  var STRETCH_START_USAGE = "rafa stretch start [--n=<n>] [--remote-control] [--role=<role>] [--dry-run]";
79404
79596
  var REMOTE9 = "origin";
79405
79597
  var STRETCH_BRANCH_PREFIX = "stretch/";
79406
79598
  var STRETCH_RECORD_FILE = "stretch.json";
79407
79599
  var PR_BASE_KEY = "pr.base";
79408
79600
  var AGENT_WAIT_MS = 5000;
79409
- var REFUSED_EXIT3 = 1;
79410
- var FAILED_EXIT = 2;
79601
+ var REFUSED_EXIT4 = 1;
79602
+ var FAILED_EXIT3 = 2;
79411
79603
  var STRETCH_NUMBER = /^[1-9]\d*$/;
79412
79604
  function stretchBranch(n) {
79413
79605
  return `${STRETCH_BRANCH_PREFIX}${String(n)}`;
@@ -79415,8 +79607,8 @@ function stretchBranch(n) {
79415
79607
  function stretchRecordPath(root, n) {
79416
79608
  return join121(stretchFolder(root, n), STRETCH_RECORD_FILE);
79417
79609
  }
79418
- function refusal23(why) {
79419
- return new CommandExit(REFUSED_EXIT3, `\u274C ${COMMAND_NAME14}: ${why}`);
79610
+ function refusal24(why) {
79611
+ return new CommandExit(REFUSED_EXIT4, `\u274C ${COMMAND_NAME16}: ${why}`);
79420
79612
  }
79421
79613
  function readStartLine(context) {
79422
79614
  expectNoArgument(context.args, STRETCH_START_USAGE);
@@ -79456,7 +79648,7 @@ class Steps {
79456
79648
  const done = this.done.length === 0 ? "no step had run before it." : `already done:
79457
79649
  ${this.done.map((step2) => ` ${step2}`).join(`
79458
79650
  `)}`;
79459
- return new CommandExit(FAILED_EXIT, `\u274C ${COMMAND_NAME14}: ${line} failed: ${said}
79651
+ return new CommandExit(FAILED_EXIT3, `\u274C ${COMMAND_NAME16}: ${line} failed: ${said}
79460
79652
  ${done}`);
79461
79653
  }
79462
79654
  }
@@ -79471,7 +79663,7 @@ function refuseLiveStretch(root, seams) {
79471
79663
  ].filter((part) => part !== null);
79472
79664
  return ` stretch ${String(reading2.n)}: ${why.join(", ")}`;
79473
79665
  });
79474
- throw refusal23([
79666
+ throw refusal24([
79475
79667
  "a stretch of this project is live, and one runs at a time:",
79476
79668
  ...lines3,
79477
79669
  "Nothing was pushed, set or copied. End it first, or attach to its tmux session."
@@ -79483,13 +79675,13 @@ function refuseLiveLoop3(root, isAlive) {
79483
79675
  try {
79484
79676
  records = readSessions(root, { isAlive });
79485
79677
  } catch (error2) {
79486
- throw new CommandExit(FAILED_EXIT, `\u274C ${COMMAND_NAME14}: the session records could not be read: ${messageOf(error2)}
79678
+ throw new CommandExit(FAILED_EXIT3, `\u274C ${COMMAND_NAME16}: the session records could not be read: ${messageOf(error2)}
79487
79679
  Nothing was pushed, set or copied.`);
79488
79680
  }
79489
79681
  const loops = records.filter((record2) => record2.state === "running" || record2.state === "paused");
79490
79682
  if (loops.length === 0)
79491
79683
  return;
79492
- throw refusal23([
79684
+ throw refusal24([
79493
79685
  `${String(loops.length)} loop(s) of this project run, and a stretch starts with none:`,
79494
79686
  ...loops.map((loop) => ` loop on ${loop.branch} (pid ${String(loop.pid)}, session ${loop.sessionId})`),
79495
79687
  "Nothing was pushed, set or copied. Wait for them to end, or stop them with rafa loop stop."
@@ -79499,7 +79691,7 @@ Nothing was pushed, set or copied.`);
79499
79691
  function requireProgram(context, seams, program) {
79500
79692
  if (seams.which(program, context.env["PATH"]) !== null)
79501
79693
  return;
79502
- throw refusal23(`${program} is not on PATH. Nothing was pushed, set or copied.`);
79694
+ throw refusal24(`${program} is not on PATH. Nothing was pushed, set or copied.`);
79503
79695
  }
79504
79696
  function prBaseEdit(root, n) {
79505
79697
  const path6 = configFilePath(root);
@@ -79507,13 +79699,13 @@ function prBaseEdit(root, n) {
79507
79699
  try {
79508
79700
  text2 = readFileSync97(path6, "utf8");
79509
79701
  } catch (error2) {
79510
- throw refusal23(`${path6} could not be read (${messageOf(error2)}). Nothing was pushed, set or copied.`);
79702
+ throw refusal24(`${path6} could not be read (${messageOf(error2)}). Nothing was pushed, set or copied.`);
79511
79703
  }
79512
79704
  try {
79513
79705
  return { path: path6, edit: withConfigSetting(text2, PR_BASE_KEY, stretchBranch(n), path6) };
79514
79706
  } catch (error2) {
79515
79707
  if (error2 instanceof ConfigSetRefusal) {
79516
- throw refusal23(`${PR_BASE_KEY} cannot be set: ${error2.message}. Nothing was pushed, set or copied.`);
79708
+ throw refusal24(`${PR_BASE_KEY} cannot be set: ${error2.message}. Nothing was pushed, set or copied.`);
79517
79709
  }
79518
79710
  throw error2;
79519
79711
  }
@@ -79524,7 +79716,7 @@ function remoteHolds(git, branch) {
79524
79716
  return true;
79525
79717
  if (result2.stdout.trim() === "" && result2.stderr.trim() === "")
79526
79718
  return false;
79527
- throw new CommandExit(FAILED_EXIT, `\u274C ${COMMAND_NAME14}: git ls-remote ${REMOTE9} could not be read: ${gitSaid(result2)}
79719
+ throw new CommandExit(FAILED_EXIT3, `\u274C ${COMMAND_NAME16}: git ls-remote ${REMOTE9} could not be read: ${gitSaid(result2)}
79528
79720
  Nothing was pushed, set or copied.`);
79529
79721
  }
79530
79722
  function gitStep(steps, git, args) {
@@ -79571,7 +79763,7 @@ function setPrBase(steps, root, n, defaultBranch, now, info2) {
79571
79763
  function copyStep2(steps, root, n, seams, info2) {
79572
79764
  const found = findOperators(seams);
79573
79765
  if (found.kind === "missing")
79574
- throw refusal23(missingOperatorsLine(found));
79766
+ throw refusal24(missingOperatorsLine(found));
79575
79767
  const copy2 = operatorsCopyPath(root, n);
79576
79768
  if (seams.fs.exists(copy2)) {
79577
79769
  info2(`keep ${copy2}, copied by an earlier start`);
@@ -79630,7 +79822,7 @@ async function openStretch(context, root, line, seams) {
79630
79822
  refuseLiveLoop3(root, seams.folder.isAlive);
79631
79823
  const found = findOperators(seams.operators);
79632
79824
  if (found.kind === "missing")
79633
- throw refusal23(missingOperatorsLine(found));
79825
+ throw refusal24(missingOperatorsLine(found));
79634
79826
  if (!line.dryRun)
79635
79827
  requireProgram(context, seams, "claude");
79636
79828
  prBaseEdit(root, n);
@@ -79656,7 +79848,7 @@ function roleStretch(root, line, role, seams) {
79656
79848
  const n = newestWatched(root, seams.folder.fs);
79657
79849
  if (n > 0)
79658
79850
  return n;
79659
- throw refusal23("no .rafa/stretch/<n>/agent.json yet: start the engineer first, or pass --n=<n>");
79851
+ throw refusal24("no .rafa/stretch/<n>/agent.json yet: start the engineer first, or pass --n=<n>");
79660
79852
  }
79661
79853
  async function waitForAgent(context, root, n, seams) {
79662
79854
  const file = agentFilePath(root, n);
@@ -79665,7 +79857,7 @@ async function waitForAgent(context, root, n, seams) {
79665
79857
  context.output.info(`waiting for ${file} \u2026`);
79666
79858
  while (seams.folder.fs.readText(file) === null) {
79667
79859
  if (context.signal.aborted)
79668
- throw refusal23(`stopped waiting for ${file}`);
79860
+ throw refusal24(`stopped waiting for ${file}`);
79669
79861
  await seams.sleep(AGENT_WAIT_MS);
79670
79862
  }
79671
79863
  }
@@ -79674,7 +79866,7 @@ function rolePrompt(context, root, role, n, seams) {
79674
79866
  return besideEngineerPrompt(role, n);
79675
79867
  const prompt = engineerPrompt(root, n, seams.prompt);
79676
79868
  if (prompt.kind === "missing")
79677
- throw refusal23(`the engineer's prompt ${prompt.reason}`);
79869
+ throw refusal24(`the engineer's prompt ${prompt.reason}`);
79678
79870
  context.output.info(`prompt: ${prompt.path}`);
79679
79871
  return prompt.text;
79680
79872
  }
@@ -79704,13 +79896,13 @@ async function runRole(context, root, line, seams, copied = false) {
79704
79896
  info2(`starting the ${role} of stretch ${String(n)}: ${argv.slice(0, 7).join(" ")} \u2026`);
79705
79897
  const exitCode = await seams.runSession(argv, root);
79706
79898
  if (exitCode === null)
79707
- throw new CommandExit(FAILED_EXIT, `\u274C ${COMMAND_NAME14}: claude could not start`);
79899
+ throw new CommandExit(FAILED_EXIT3, `\u274C ${COMMAND_NAME16}: claude could not start`);
79708
79900
  if (exitCode !== 0)
79709
- throw new CommandExit(exitCode, `\u274C ${COMMAND_NAME14}: the ${role} session ended with exit code ${String(exitCode)}`);
79901
+ throw new CommandExit(exitCode, `\u274C ${COMMAND_NAME16}: the ${role} session ended with exit code ${String(exitCode)}`);
79710
79902
  }
79711
79903
  async function runStretchStart(context, seams) {
79712
79904
  const line = readStartLine(context);
79713
- const root = requireProject(context, COMMAND_NAME14).root;
79905
+ const root = requireProject(context, COMMAND_NAME16).root;
79714
79906
  if (line.role !== null) {
79715
79907
  await runRole(context, root, line, seams);
79716
79908
  return;
@@ -79791,24 +79983,24 @@ var command56 = createStretchStartCommand();
79791
79983
  var start_default = command56;
79792
79984
 
79793
79985
  // src/commands/stretch/item-merge.ts
79794
- var COMMAND_NAME15 = "rafa stretch item";
79986
+ var COMMAND_NAME17 = "rafa stretch item";
79795
79987
  var CI_POLL_MS = 30000;
79796
79988
  var CI_WAIT_MS = 90 * 60000;
79797
79989
  var CI_READ_TRIES = 3;
79798
- var MERGE_FLAGS = Object.freeze(["--skip-checks", "--yes"]);
79799
- var PR_VIEW_FIELDS = ["number", "state", "baseRefName", "headRefName", "body", "mergeCommit"];
79990
+ var MERGE_FLAGS = Object.freeze(["--yes"]);
79991
+ var MERGED_READ_TRIES = 5;
79992
+ var MERGED_POLL_MS = 5000;
79800
79993
  var ENDING_EVENTS = ["pr", "no-pr", "halt", "error"];
79801
- var REFUSED_EXIT4 = 1;
79802
- var FAILED_EXIT2 = 2;
79994
+ var REFUSED_EXIT5 = 1;
79995
+ var FAILED_EXIT4 = 2;
79803
79996
  var SHORT_SHA4 = 7;
79804
- var SHA = /^[0-9a-f]{40}$/;
79805
79997
  var MERGE_COMMIT_PLACEHOLDER = "<merge-commit>";
79806
79998
  var STAND_IN_SHA = "0".repeat(40);
79807
- function refusal24(why) {
79808
- return new CommandExit(REFUSED_EXIT4, `\u274C ${COMMAND_NAME15}: ${why}`);
79999
+ function refusal25(why) {
80000
+ return new CommandExit(REFUSED_EXIT5, `\u274C ${COMMAND_NAME17}: ${why}`);
79809
80001
  }
79810
- function failure8(why) {
79811
- return new CommandExit(FAILED_EXIT2, `\u274C ${COMMAND_NAME15}: ${why}`);
80002
+ function failure9(why) {
80003
+ return new CommandExit(FAILED_EXIT4, `\u274C ${COMMAND_NAME17}: ${why}`);
79812
80004
  }
79813
80005
  function short3(sha) {
79814
80006
  return sha.slice(0, SHORT_SHA4);
@@ -79842,57 +80034,12 @@ function noPullRequestLine(issue5, ending) {
79842
80034
  const how = ending.kind === "none" ? "ended without a pull request" : `ended on ${ending.kind}`;
79843
80035
  return `the loop of #${String(issue5)} ${how}: ${ending.reason}`;
79844
80036
  }
79845
- function prViewArgs(number) {
79846
- return ["pr", "view", String(number), "--json", PR_VIEW_FIELDS.join(",")];
79847
- }
79848
- function textField2(row2, field5, command57) {
79849
- const value = row2[field5];
79850
- if (typeof value !== "string")
79851
- throw failure8(`${command57} answered ${field5} ${describeValue(value)}, expected a string`);
79852
- return value;
79853
- }
79854
- function mergeCommitOf(value, command57) {
79855
- if (value === null || value === undefined)
79856
- return null;
79857
- const oid = isMapping(value) ? value["oid"] : undefined;
79858
- if (typeof oid !== "string" || !SHA.test(oid)) {
79859
- throw failure8(`${command57} answered mergeCommit ${describeValue(value)}, expected null or an object holding a 40-character oid`);
79860
- }
79861
- return oid;
79862
- }
79863
- async function viewPull(gh, number) {
79864
- const args = prViewArgs(number);
79865
- const command57 = `gh ${args.join(" ")}`;
79866
- const result2 = await gh(args);
79867
- if (!result2.ok) {
79868
- const said = result2.stderr.trim() || result2.stdout.trim() || "it exited non-zero and wrote nothing";
79869
- throw failure8(`${command57} failed: ${said}`);
79870
- }
79871
- let row2;
79872
- try {
79873
- row2 = JSON.parse(result2.stdout);
79874
- } catch (error2) {
79875
- throw failure8(`${command57} wrote output that is not JSON: ${messageOf(error2)}`);
79876
- }
79877
- if (!isMapping(row2))
79878
- throw failure8(`${command57} answered ${describeValue(row2)}, expected an object`);
79879
- if (row2["number"] !== number)
79880
- throw failure8(`${command57} answered number ${describeValue(row2["number"])}`);
79881
- return {
79882
- number,
79883
- state: textField2(row2, "state", command57),
79884
- base: textField2(row2, "baseRefName", command57),
79885
- head: textField2(row2, "headRefName", command57),
79886
- body: textField2(row2, "body", command57),
79887
- mergeCommit: mergeCommitOf(row2["mergeCommit"], command57)
79888
- };
79889
- }
79890
80037
  function refuseUnmergeable2(pull) {
79891
80038
  if (!pull.base.startsWith(STRETCH_BRANCH_PREFIX) || pull.base === STRETCH_BRANCH_PREFIX) {
79892
- throw refusal24(`#${String(pull.number)} opens into ${pull.base}, not a ${STRETCH_BRANCH_PREFIX}* branch: an item is` + " merged with its checks skipped only into an integration branch. Nothing was merged.");
80039
+ throw refusal25(`#${String(pull.number)} opens into ${pull.base}, not a ${STRETCH_BRANCH_PREFIX}* branch: an item` + " merges into an integration branch, never the default branch. Nothing was merged.");
79893
80040
  }
79894
80041
  if (pull.state !== "OPEN") {
79895
- throw refusal24(`#${String(pull.number)} is ${pull.state}, not open. Nothing was merged.`);
80042
+ throw refusal25(`#${String(pull.number)} is ${pull.state}, not open. Nothing was merged.`);
79896
80043
  }
79897
80044
  }
79898
80045
  function mergeArgv(rafa, number) {
@@ -79902,6 +80049,8 @@ function mergeDryRunLines(rafa, root, n) {
79902
80049
  const base2 = `${STRETCH_BRANCH_PREFIX}${String(n)}`;
79903
80050
  const runList5 = lineText(["gh", ...runListArgs({ branch: base2, commit: STAND_IN_SHA })]).replace(STAND_IN_SHA, MERGE_COMMIT_PLACEHOLDER);
79904
80051
  return [
80052
+ `wait for GitHub to compute the mergeability of <pr> (again every ${String(MERGEABILITY_POLL_MS / 1000)}s while it reads` + ` UNKNOWN, up to ${String(MERGEABILITY_WAIT_MS / 60000)} minutes)`,
80053
+ `wait for the checks of <pr> to pass (again every ${String(CHECKS_POLL_MS / 1000)}s, up to` + ` ${String(CHECKS_WAIT_MS / 60000)} minutes)`,
79905
80054
  `${lineText([...rafa, "pr", "merge"])} <pr> ${lineText(MERGE_FLAGS)}`,
79906
80055
  `${runList5} (again every ${String(CI_POLL_MS / 1000)}s until the run on the merge commit ends)`,
79907
80056
  `append the item to ${itemsPath(root, n)}`,
@@ -79963,38 +80112,66 @@ async function mergeStep(context, item, number, seams) {
79963
80112
  context.output.info(lineText(argv));
79964
80113
  const exitCode = await seams.runRafa(argv, item.root, item.env);
79965
80114
  if (exitCode === null)
79966
- throw failure8(`${lineText(argv)} could not start; #${String(number)} is not merged.`);
80115
+ throw failure9(`${lineText(argv)} could not start; #${String(number)} is not merged.`);
80116
+ return exitCode;
80117
+ }
80118
+ function isMerged(pull) {
80119
+ return pull.state === "MERGED" && pull.mergeCommit !== null;
80120
+ }
80121
+ async function readMerged2(gh, number, seams) {
80122
+ let pull = await viewPull(gh, number);
80123
+ for (let read2 = 1;read2 < MERGED_READ_TRIES && !isMerged(pull); read2 += 1) {
80124
+ await seams.sleep(MERGED_POLL_MS);
80125
+ pull = await viewPull(gh, number);
80126
+ }
80127
+ return pull;
80128
+ }
80129
+ async function mergePull(context, item, number, seams) {
80130
+ const gh = seams.gh(item.root);
80131
+ refuseUnmergeable2(await viewPull(gh, number));
80132
+ const target = { issue: item.issue, number };
80133
+ await awaitMergeability(context, gh, target, seams);
80134
+ await awaitChecks(context, gh, target, seams);
80135
+ const exitCode = await mergeStep(context, item, number, seams);
80136
+ const line = lineText(mergeArgv(seams.rafa, number));
80137
+ const pull = await readMerged2(gh, number, seams);
80138
+ const reads = `after ${String(MERGED_READ_TRIES)} reads`;
80139
+ if (!isMerged(pull)) {
80140
+ const how = `#${String(number)} reads ${pull.state} with no merge commit ${reads}`;
80141
+ if (exitCode !== 0) {
80142
+ throw new CommandExit(exitCode, `\u274C ${COMMAND_NAME17}: ${line} ended with exit code ${String(exitCode)}, and ${how};` + " no CI wait, ledger line or pit-stop reading followed.");
80143
+ }
80144
+ throw failure9(`${line} ended 0, and ${how}.`);
80145
+ }
79967
80146
  if (exitCode !== 0) {
79968
- throw new CommandExit(exitCode, `\u274C ${COMMAND_NAME15}: ${lineText(argv)} ended with exit code ${String(exitCode)};` + " no CI wait, ledger line or pit-stop reading followed.");
80147
+ context.output.warn(`${line} ended with exit code ${String(exitCode)}, and #${String(number)} is merged: the clean-up` + " after the merge is what failed; finish it with rafa cleanup.");
79969
80148
  }
80149
+ context.output.info(`merged #${String(number)} into ${pull.base} at ${short3(pull.mergeCommit)}`);
80150
+ return pull;
79970
80151
  }
79971
- async function mergeItem(context, item, number, seams) {
80152
+ async function finishItem(context, item, merged2, seams) {
79972
80153
  const info2 = (text2) => context.output.info(text2);
79973
80154
  const gh = seams.gh(item.root);
79974
- const pull = await viewPull(gh, number);
79975
- refuseUnmergeable2(pull);
79976
- const since = bugCutOff(item);
79977
- await mergeStep(context, item, number, seams);
79978
- const merged2 = await viewPull(gh, number);
79979
- if (merged2.state !== "MERGED" || merged2.mergeCommit === null) {
79980
- throw failure8(`rafa pr merge ended 0, and #${String(number)} reads ${merged2.state} with no merge commit.`);
79981
- }
79982
- info2(`merged #${String(number)} into ${merged2.base} at ${short3(merged2.mergeCommit)}`);
79983
80155
  await awaitRun(context, { gh, branch: merged2.base, commit: merged2.mergeCommit }, seams);
79984
80156
  const closes2 = [...new Set(closedIssuesIn(merged2.body))].map((issue5) => `Closes #${String(issue5)}`);
79985
80157
  appendItem2(item.root, item.n, {
79986
80158
  issue: String(item.issue),
79987
80159
  plan: item.stub,
79988
- pullRequest: number,
80160
+ pullRequest: merged2.number,
79989
80161
  mergeCommit: merged2.mergeCommit,
79990
80162
  closes: closes2,
79991
80163
  at: seams.now().toISOString()
79992
80164
  });
79993
80165
  info2(`ledger: #${String(item.issue)} appended to ${itemsPath(item.root, item.n)}${closes2.length === 0 ? ", closing no issue" : `, ${closes2.join(", ")}`}`);
79994
- const readings = await readPitReadings({ gh, tracker: seams.tracker(gh) }, { branch: merged2.base, since });
80166
+ const readings = await readPitReadings({ gh, tracker: seams.tracker(gh) }, { branch: merged2.base, since: item.since });
79995
80167
  for (const line of renderPitReadings(readings))
79996
80168
  info2(line);
79997
80169
  }
80170
+ async function mergeItem(context, item, number, seams) {
80171
+ const since = bugCutOff(item);
80172
+ const merged2 = await mergePull(context, item, number, seams);
80173
+ await finishItem(context, { root: item.root, n: item.n, issue: item.issue, stub: item.stub, since }, merged2, seams);
80174
+ }
79998
80175
  async function afterLoopWait(context, item, waitExit, seams) {
79999
80176
  const ending = readLoopEnding(item.root, item.sessionId);
80000
80177
  if (waitExit === 0 && ending.kind === "pr") {
@@ -80004,20 +80181,126 @@ async function afterLoopWait(context, item, waitExit, seams) {
80004
80181
  if (ending.kind !== "pr")
80005
80182
  context.output.info(noPullRequestLine(item.issue, ending));
80006
80183
  context.output.info(`log: ${item.log}`);
80007
- const code = waitExit === 0 ? FAILED_EXIT2 : waitExit;
80008
- throw new CommandExit(code, `\u274C ${COMMAND_NAME15}: rafa loop wait --session-id=${item.sessionId} ended with exit code` + ` ${String(waitExit)} and no pull request to merge; nothing was merged.`);
80184
+ const code = waitExit === 0 ? FAILED_EXIT4 : waitExit;
80185
+ throw new CommandExit(code, `\u274C ${COMMAND_NAME17}: rafa loop wait --session-id=${item.sessionId} ended with exit code` + ` ${String(waitExit)} and no pull request to merge; nothing was merged.`);
80186
+ }
80187
+
80188
+ // src/commands/stretch/item-resume.ts
80189
+ import { readFileSync as readFileSync99, statSync as statSync33 } from "fs";
80190
+ import { posix as posix13 } from "path";
80191
+ init_command2();
80192
+ init_sections();
80193
+ init_loop();
80194
+ init_plan();
80195
+ var COMMAND_NAME18 = "rafa stretch item";
80196
+ var REFUSED_EXIT6 = 1;
80197
+ var FAILED_EXIT5 = 2;
80198
+ var SHORT_SHA5 = 7;
80199
+ var PR_OPENED = /^pr #([1-9]\d*) opened$/;
80200
+ function refusal26(why) {
80201
+ return new CommandExit(REFUSED_EXIT6, `\u274C ${COMMAND_NAME18}: ${why}`);
80202
+ }
80203
+ function failure10(why) {
80204
+ return new CommandExit(FAILED_EXIT5, `\u274C ${COMMAND_NAME18}: ${why}`);
80205
+ }
80206
+ function readLogPullRequest(log) {
80207
+ let text2;
80208
+ try {
80209
+ text2 = readFileSync99(log, "utf8");
80210
+ } catch (error2) {
80211
+ return errorCode(error2) === "ENOENT" ? { kind: "none", reason: `there is no log at ${log}` } : { kind: "none", reason: `the log ${log} could not be read: ${messageOf(error2)}` };
80212
+ }
80213
+ const numbers = text2.split(`
80214
+ `).map((line) => line.trimEnd()).filter((line) => line.startsWith(EVENT_PREFIX)).map((line) => PR_OPENED.exec(line.slice(EVENT_PREFIX.length))?.[1]).filter((word) => word !== undefined);
80215
+ const last = numbers.at(-1);
80216
+ return last === undefined || !Number.isSafeInteger(Number(last)) ? { kind: "none", reason: `the log ${log} holds no "${EVENT_PREFIX}pr #<n> opened" line` } : { kind: "pr", number: Number(last) };
80217
+ }
80218
+ function resumeDryRunLines(rafa, root, n, log) {
80219
+ const merge3 = `${lineText([...rafa, "pr", "merge"])} <pr> `;
80220
+ return [
80221
+ `read the pull request from ${log}`,
80222
+ ...mergeDryRunLines(rafa, root, n).map((line) => line.startsWith(merge3) ? `${line} (skipped when #<pr> is merged already)` : line)
80223
+ ];
80224
+ }
80225
+ function ledgerItems(root, n) {
80226
+ try {
80227
+ return readItems(root, n).items;
80228
+ } catch (error2) {
80229
+ throw failure10(`${itemsPath(root, n)} could not be read: ${messageOf(error2)}. Nothing was run.`);
80230
+ }
80231
+ }
80232
+ function refuseLedgered(input, items2) {
80233
+ const issue5 = String(input.issue);
80234
+ const held2 = items2.find((item) => item.issue === issue5);
80235
+ if (held2 === undefined)
80236
+ return;
80237
+ throw refusal26(`#${issue5} is in ${itemsPath(input.root, input.n)} already: pull request #${String(held2.pullRequest)},` + ` written at ${held2.at}. The item is finished. Nothing was run.`);
80238
+ }
80239
+ function resumedStub(input) {
80240
+ const issue5 = String(input.issue);
80241
+ const [plan, ...others] = input.plans;
80242
+ if (plan === undefined) {
80243
+ throw refusal26(`${input.plansLabel} holds no plan of #${issue5}, and the ledger line keeps the plan's stub. Nothing was run.`);
80244
+ }
80245
+ if (others.length > 0) {
80246
+ throw refusal26([
80247
+ `${input.plansLabel} holds ${String(input.plans.length)} plans of #${issue5}, and an item runs one:`,
80248
+ ...input.plans.map((name2) => ` ${name2}`),
80249
+ "Remove the ones not wanted. Nothing was run."
80250
+ ].join(`
80251
+ `));
80252
+ }
80253
+ const stub = stubOfPlanFile(posix13.basename(plan));
80254
+ if (stub === null)
80255
+ throw refusal26(`${plan} is no PLAN-<stub>.md file. Nothing was run.`);
80256
+ return stub;
80257
+ }
80258
+ function resumeCutOff(input, items2, seams) {
80259
+ const times = items2.map((item) => Date.parse(item.at)).filter((time) => !Number.isNaN(time));
80260
+ if (times.length > 0)
80261
+ return new Date(Math.max(...times));
80262
+ return stretchStartedAt(input.root, input.n) ?? statSync33(input.log, { throwIfNoEntry: false })?.mtime ?? seams.now();
80263
+ }
80264
+ function mergedAlready(context, pull) {
80265
+ if (!pull.base.startsWith(STRETCH_BRANCH_PREFIX) || pull.base === STRETCH_BRANCH_PREFIX) {
80266
+ throw refusal26(`#${String(pull.number)} merged into ${pull.base}, not a ${STRETCH_BRANCH_PREFIX}* branch: an item` + " merges into an integration branch, never the default branch. Nothing was run.");
80267
+ }
80268
+ context.output.info(`#${String(pull.number)} is merged already at ${pull.mergeCommit.slice(0, SHORT_SHA5)}; skipping the merge`);
80269
+ return pull;
80270
+ }
80271
+ async function resumeItem(context, input, seams) {
80272
+ const items2 = ledgerItems(input.root, input.n);
80273
+ refuseLedgered(input, items2);
80274
+ const stub = resumedStub(input);
80275
+ const read2 = readLogPullRequest(input.log);
80276
+ if (read2.kind === "none") {
80277
+ throw refusal26(`${read2.reason}, so there is no pull request to resume #${String(input.issue)} from. Nothing was run.`);
80278
+ }
80279
+ const { number } = read2;
80280
+ context.output.info(`read #${String(number)} from ${input.log}`);
80281
+ const since = resumeCutOff(input, items2, seams);
80282
+ const pull = await viewPull(seams.gh(input.root), number);
80283
+ let merged2;
80284
+ if (pull.state === "OPEN") {
80285
+ merged2 = await mergePull(context, input, number, seams);
80286
+ } else if (pull.state === "MERGED" && pull.mergeCommit !== null) {
80287
+ merged2 = mergedAlready(context, { ...pull, mergeCommit: pull.mergeCommit });
80288
+ } else {
80289
+ throw refusal26(`#${String(number)} is ${pull.state}, neither open nor merged. Nothing was run.`);
80290
+ }
80291
+ await finishItem(context, { root: input.root, n: input.n, issue: input.issue, stub, since }, merged2, seams);
80009
80292
  }
80010
80293
 
80011
80294
  // src/commands/stretch/item.ts
80012
- var COMMAND_NAME16 = "rafa stretch item";
80013
- var STRETCH_ITEM_USAGE = "rafa stretch item <issue> [--wait] [--dry-run]";
80295
+ var COMMAND_NAME19 = "rafa stretch item";
80296
+ var STRETCH_ITEM_USAGE = "rafa stretch item <issue> [--wait | --resume] [--dry-run]";
80014
80297
  var LOOP_FLAGS = Object.freeze(["--as-worktree", "--no-ci-wait"]);
80015
80298
  var LOOP_OUTPUT = "events";
80016
80299
  var RECORD_POLL_MS = 2000;
80017
80300
  var RECORD_WAIT_MS = 5 * 60000;
80018
80301
  var LOG_TAIL_LINES = 20;
80019
- var REFUSED_EXIT5 = 1;
80020
- var FAILED_EXIT3 = 2;
80302
+ var REFUSED_EXIT7 = 1;
80303
+ var FAILED_EXIT6 = 2;
80021
80304
  var ISSUE_NUMBER18 = /^[1-9]\d*$/;
80022
80305
  var STRETCH_BASE = new RegExp(`^${STRETCH_BRANCH_PREFIX}([1-9]\\d*)$`);
80023
80306
  function itemLogPath(root, n, issue5) {
@@ -80027,31 +80310,37 @@ function stretchOfBase(prBase) {
80027
80310
  const word = prBase === null ? undefined : STRETCH_BASE.exec(prBase)?.[1];
80028
80311
  return word === undefined ? null : Number(word);
80029
80312
  }
80030
- function refusal25(why) {
80031
- return new CommandExit(REFUSED_EXIT5, `\u274C ${COMMAND_NAME16}: ${why}`);
80313
+ function refusal27(why) {
80314
+ return new CommandExit(REFUSED_EXIT7, `\u274C ${COMMAND_NAME19}: ${why}`);
80032
80315
  }
80033
- function failure9(why) {
80034
- return new CommandExit(FAILED_EXIT3, `\u274C ${COMMAND_NAME16}: ${why}`);
80316
+ function failure11(why) {
80317
+ return new CommandExit(FAILED_EXIT6, `\u274C ${COMMAND_NAME19}: ${why}`);
80035
80318
  }
80036
80319
  function readItemLine(context) {
80037
80320
  const word = expectOneArgument(context.args, STRETCH_ITEM_USAGE);
80038
80321
  if (!ISSUE_NUMBER18.test(word) || !Number.isSafeInteger(Number(word))) {
80039
- throw new CommandExit(REFUSED_EXIT5, `\u274C "${word}" is no issue number, expected a whole number from 1
80322
+ throw new CommandExit(REFUSED_EXIT7, `\u274C "${word}" is no issue number, expected a whole number from 1
80040
80323
  Usage: ${STRETCH_ITEM_USAGE}`);
80041
80324
  }
80042
80325
  const hint = `Usage: ${STRETCH_ITEM_USAGE}`;
80043
- return {
80326
+ const line = {
80044
80327
  issue: Number(word),
80045
80328
  wait: readSwitch2("wait", context.flags["wait"], hint),
80329
+ resume: readSwitch2("resume", context.flags["resume"], hint),
80046
80330
  dryRun: readSwitch2("dry-run", context.flags["dry-run"], hint)
80047
80331
  };
80332
+ if (line.wait && line.resume) {
80333
+ throw new CommandExit(REFUSED_EXIT7, "\u274C --resume finishes an item whose loop has ended, and --wait waits on a loop it" + ` starts: pass one of them.
80334
+ ${hint}`);
80335
+ }
80336
+ return line;
80048
80337
  }
80049
80338
  function requireStretchBase(prBase) {
80050
80339
  const n = stretchOfBase(prBase);
80051
80340
  if (n !== null)
80052
80341
  return n;
80053
80342
  const found = prBase === null ? "not set, so pull requests open into the default branch" : `"${prBase}"`;
80054
- throw refusal25(`${PR_BASE_KEY} is ${found}, expected a ${STRETCH_BRANCH_PREFIX}<n> branch: an item merges into the` + " integration branch, never the default branch. Run rafa stretch start, or push the branch and run" + ` rafa config set ${PR_BASE_KEY}=${STRETCH_BRANCH_PREFIX}<n>. Nothing was run.`);
80343
+ throw refusal27(`${PR_BASE_KEY} is ${found}, expected a ${STRETCH_BRANCH_PREFIX}<n> branch: an item merges into the` + " integration branch, never the default branch. Run rafa stretch start, or push the branch and run" + ` rafa config set ${PR_BASE_KEY}=${STRETCH_BRANCH_PREFIX}<n>. Nothing was run.`);
80055
80344
  }
80056
80345
  function issuePlans(plans, issue5) {
80057
80346
  const prefix = `${boardId(issue5)}-`;
@@ -80061,12 +80350,12 @@ function issuePlans(plans, issue5) {
80061
80350
  } catch {
80062
80351
  return [];
80063
80352
  }
80064
- return names2.filter((name2) => stubOfPlanFile(name2)?.startsWith(prefix) === true).sort().map((name2) => posix13.join(plans.label, name2));
80353
+ return names2.filter((name2) => stubOfPlanFile(name2)?.startsWith(prefix) === true).sort().map((name2) => posix14.join(plans.label, name2));
80065
80354
  }
80066
80355
  function existingPlan(plans, issue5) {
80067
80356
  const found = issuePlans(plans, issue5);
80068
80357
  if (found.length > 1) {
80069
- throw refusal25([
80358
+ throw refusal27([
80070
80359
  `${plans.label} holds ${String(found.length)} plans of #${String(issue5)}, and an item runs one:`,
80071
80360
  ...found.map((plan) => ` ${plan}`),
80072
80361
  "Remove the ones not wanted. Nothing was run."
@@ -80079,7 +80368,7 @@ function sessionRecords(root, isAlive) {
80079
80368
  try {
80080
80369
  return readSessions(root, { isAlive });
80081
80370
  } catch (error2) {
80082
- throw failure9(`the session records could not be read: ${messageOf(error2)}`);
80371
+ throw failure11(`the session records could not be read: ${messageOf(error2)}`);
80083
80372
  }
80084
80373
  }
80085
80374
  function refuseRunningLoop(root, stub, isAlive) {
@@ -80087,7 +80376,7 @@ function refuseRunningLoop(root, stub, isAlive) {
80087
80376
  const [first] = running2;
80088
80377
  if (first === undefined)
80089
80378
  return;
80090
- throw refusal25(`a loop of ${stub} runs already: session ${first.sessionId} (pid ${String(first.pid)}, ${first.state}).` + ` Wait on it with rafa loop wait --session-id=${first.sessionId}. Nothing was run.`);
80379
+ throw refusal27(`a loop of ${stub} runs already: session ${first.sessionId} (pid ${String(first.pid)}, ${first.state}).` + ` Wait on it with rafa loop wait --session-id=${first.sessionId}. Nothing was run.`);
80091
80380
  }
80092
80381
  function loopArgv(rafa, plan) {
80093
80382
  return [...rafa, "loop", "start", `--plan=${plan}`, ...LOOP_FLAGS];
@@ -80117,23 +80406,23 @@ async function planStep(context, root, plans, line, seams) {
80117
80406
  return null;
80118
80407
  const exitCode = await seams.runRafa(argv, root, childEnv(context));
80119
80408
  if (exitCode === null)
80120
- throw failure9(`${lineText(argv)} could not start. Nothing else was run.`);
80409
+ throw failure11(`${lineText(argv)} could not start. Nothing else was run.`);
80121
80410
  if (exitCode !== 0) {
80122
- throw new CommandExit(exitCode, `\u274C ${COMMAND_NAME16}: ${lineText(argv)} ended with exit code ${String(exitCode)}; no loop was started.`);
80411
+ throw new CommandExit(exitCode, `\u274C ${COMMAND_NAME19}: ${lineText(argv)} ended with exit code ${String(exitCode)}; no loop was started.`);
80123
80412
  }
80124
80413
  const made = existingPlan(plans, line.issue);
80125
80414
  if (made === null) {
80126
- throw failure9(`${lineText(argv)} ended with exit code 0 and wrote no ${boardId(line.issue)}-* plan in ${plans.label}; no loop was started.`);
80415
+ throw failure11(`${lineText(argv)} ended with exit code 0 and wrote no ${boardId(line.issue)}-* plan in ${plans.label}; no loop was started.`);
80127
80416
  }
80128
80417
  return made;
80129
80418
  }
80130
80419
  function sizeOf(path6) {
80131
- return statSync33(path6, { throwIfNoEntry: false })?.size ?? 0;
80420
+ return statSync34(path6, { throwIfNoEntry: false })?.size ?? 0;
80132
80421
  }
80133
80422
  function logTail(log, offset) {
80134
80423
  let text2;
80135
80424
  try {
80136
- text2 = readFileSync99(log).subarray(offset).toString("utf8");
80425
+ text2 = readFileSync100(log).subarray(offset).toString("utf8");
80137
80426
  } catch (error2) {
80138
80427
  return ` (the log could not be read: ${messageOf(error2)})`;
80139
80428
  }
@@ -80153,13 +80442,13 @@ async function awaitRecord(context, wait, seams) {
80153
80442
  return record2;
80154
80443
  const exitCode = wait.launched.exitCode();
80155
80444
  if (exitCode !== null) {
80156
- throw failure9(`the loop (pid ${String(wait.launched.pid)}) ended with exit code ${String(exitCode)} before it` + ` wrote a session record. The last lines of ${wait.log}:
80445
+ throw failure11(`the loop (pid ${String(wait.launched.pid)}) ended with exit code ${String(exitCode)} before it` + ` wrote a session record. The last lines of ${wait.log}:
80157
80446
  ${logTail(wait.log, wait.offset)}`);
80158
80447
  }
80159
80448
  if (!wait.patient && seams.now().getTime() - wait.since >= RECORD_WAIT_MS)
80160
80449
  return null;
80161
80450
  if (context.signal.aborted) {
80162
- throw refusal25(`stopped looking for the loop's session record; the loop (pid ${String(wait.launched.pid)}) still runs, logging to ${wait.log}`);
80451
+ throw refusal27(`stopped looking for the loop's session record; the loop (pid ${String(wait.launched.pid)}) still runs, logging to ${wait.log}`);
80163
80452
  }
80164
80453
  await seams.sleep(RECORD_POLL_MS);
80165
80454
  }
@@ -80169,12 +80458,12 @@ function launchStep(context, root, plan, log, seams) {
80169
80458
  try {
80170
80459
  mkdirSync34(folder, { recursive: true });
80171
80460
  } catch (error2) {
80172
- throw failure9(`${folder} could not be made: ${messageOf(error2)}; ${plan} is planned and no loop was started.`);
80461
+ throw failure11(`${folder} could not be made: ${messageOf(error2)}; ${plan} is planned and no loop was started.`);
80173
80462
  }
80174
80463
  const offset = sizeOf(log);
80175
80464
  const launched = seams.launch(loopArgv(seams.rafa, plan), root, childEnv(context, { RAFA_OUTPUT: LOOP_OUTPUT }), log);
80176
80465
  if (launched === null)
80177
- throw failure9(`the loop could not start; ${plan} is planned and no loop runs.`);
80466
+ throw failure11(`the loop could not start; ${plan} is planned and no loop runs.`);
80178
80467
  return { launched, offset };
80179
80468
  }
80180
80469
  async function waitStep(context, wait, seams) {
@@ -80184,7 +80473,7 @@ async function waitStep(context, wait, seams) {
80184
80473
  const env = childEnv(context);
80185
80474
  const exitCode = await seams.runRafa(argv, root, env);
80186
80475
  if (exitCode === null)
80187
- throw failure9(`${lineText(argv)} could not start; the loop still runs.`);
80476
+ throw failure11(`${lineText(argv)} could not start; the loop still runs.`);
80188
80477
  await afterLoopWait(context, {
80189
80478
  root,
80190
80479
  n: wait.n,
@@ -80196,16 +80485,41 @@ async function waitStep(context, wait, seams) {
80196
80485
  env
80197
80486
  }, exitCode, seams);
80198
80487
  }
80488
+ async function resumeStep(context, step2, seams) {
80489
+ const info2 = (text2) => context.output.info(text2);
80490
+ const { root, n, issue: issue5 } = step2;
80491
+ const log = itemLogPath(root, n, issue5);
80492
+ info2(`stretch item #${String(issue5)}: stretch ${String(n)} (${PR_BASE_KEY} ${STRETCH_BRANCH_PREFIX}${String(n)}), resumed${step2.dryRun ? ", dry run: each step is printed and none is run" : ""}`);
80493
+ if (step2.dryRun) {
80494
+ for (const text2 of resumeDryRunLines(seams.rafa, root, n, log))
80495
+ info2(text2);
80496
+ info2(`dry run: would resume #${String(issue5)} for ${STRETCH_BRANCH_PREFIX}${String(n)}; nothing was run`);
80497
+ return;
80498
+ }
80499
+ await resumeItem(context, {
80500
+ root,
80501
+ n,
80502
+ issue: issue5,
80503
+ plans: issuePlans(step2.plans, issue5),
80504
+ plansLabel: step2.plans.label,
80505
+ log,
80506
+ env: childEnv(context)
80507
+ }, seams);
80508
+ }
80199
80509
  async function runStretchItem(context, seams) {
80200
80510
  const line = readItemLine(context);
80201
- const project = requireProject(context, COMMAND_NAME16);
80511
+ const project = requireProject(context, COMMAND_NAME19);
80202
80512
  const { root } = project;
80203
80513
  const warn5 = (text2) => context.output.warn(text2);
80204
- const config = await resolveProjectConfig(project, COMMAND_NAME16, warn5);
80514
+ const config = await resolveProjectConfig(project, COMMAND_NAME19, warn5);
80205
80515
  const n = requireStretchBase(config.prBase);
80206
80516
  const plans = plansDirAt(root, config.planDir);
80517
+ if (line.resume) {
80518
+ await resumeStep(context, { root, n, plans, dryRun: line.dryRun, issue: line.issue }, seams);
80519
+ return;
80520
+ }
80207
80521
  const kept = existingPlan(plans, line.issue);
80208
- const keptStub = kept === null ? null : stubOfPlanFile(posix13.basename(kept));
80522
+ const keptStub = kept === null ? null : stubOfPlanFile(posix14.basename(kept));
80209
80523
  if (keptStub !== null)
80210
80524
  refuseRunningLoop(root, keptStub, seams.isAlive);
80211
80525
  const info2 = (text2) => context.output.info(text2);
@@ -80213,7 +80527,7 @@ async function runStretchItem(context, seams) {
80213
80527
  info2(`stretch item #${issue5}: stretch ${String(n)} (${PR_BASE_KEY} ${STRETCH_BRANCH_PREFIX}${String(n)})${line.dryRun ? ", dry run: each step is printed and none is run" : ""}`);
80214
80528
  const log = itemLogPath(root, n, line.issue);
80215
80529
  const plan = await planStep(context, root, plans, line, seams);
80216
- const placeholder = posix13.join(plans.label, `PLAN-${boardId(line.issue)}-<slug>.md`);
80530
+ const placeholder = posix14.join(plans.label, `PLAN-${boardId(line.issue)}-<slug>.md`);
80217
80531
  info2(loopLineText(seams.rafa, plan, placeholder, log));
80218
80532
  if (plan === null || line.dryRun) {
80219
80533
  if (line.wait) {
@@ -80224,7 +80538,7 @@ async function runStretchItem(context, seams) {
80224
80538
  info2(`dry run: would start the loop of #${issue5} for ${STRETCH_BRANCH_PREFIX}${String(n)}; nothing was run`);
80225
80539
  return;
80226
80540
  }
80227
- const stub = stubOfPlanFile(posix13.basename(plan)) ?? "";
80541
+ const stub = stubOfPlanFile(posix14.basename(plan)) ?? "";
80228
80542
  if (keptStub === null)
80229
80543
  refuseRunningLoop(root, stub, seams.isAlive);
80230
80544
  const since = seams.now().getTime();
@@ -80285,21 +80599,27 @@ function createStretchItemCommand(seams) {
80285
80599
  subject: "stretch",
80286
80600
  action: "item",
80287
80601
  summary: "plan one issue of a stretch and start its loop, logging into the stretch folder",
80288
- description: "Takes the integration branch from `pr.base`, refusing one that names no `stretch/<n>`" + " branch, then runs `rafa plan create --issue=<issue>` on this terminal, keeping a plan of the issue" + " already in `plan.dir` instead, and starts `rafa loop start --plan=<plan> --as-worktree --no-ci-wait`" + " detached with `RAFA_OUTPUT=events`, its output appended to `.rafa/stretch/<n>/loop-<issue>.log`." + " It waits for the loop's session record and prints its id. With `--wait` it then runs" + " `rafa loop wait --session-id=<id>`; once the loop has opened a pull request it refuses one whose base" + " is not a `stretch/*` branch, runs `rafa pr merge <pr> --skip-checks --yes`, waits for the run on the" + " merge commit to end, appends the item to `.rafa/stretch/<n>/items.ndjson` and prints the pit-stop" + " readings. A loop that opened no pull request has its reason printed, merges nothing and exits with" + " `loop wait`'s code. `--dry-run` prints every step in order and runs none. Exit code 1 for a refusal," + " 2 for a step that failed, and the code of `plan create`, `loop wait` or `pr merge` when it fails.",
80602
+ description: "Takes the integration branch from `pr.base`, refusing one that names no `stretch/<n>`" + " branch, then runs `rafa plan create --issue=<issue>` on this terminal, keeping a plan of the issue" + " already in `plan.dir` instead, and starts `rafa loop start --plan=<plan> --as-worktree --no-ci-wait`" + " detached with `RAFA_OUTPUT=events`, its output appended to `.rafa/stretch/<n>/loop-<issue>.log`." + " It waits for the loop's session record and prints its id. With `--wait` it then runs" + " `rafa loop wait --session-id=<id>`; once the loop has opened a pull request it refuses one whose base" + " is not a `stretch/*` branch, waits for GitHub to compute its mergeability and for its checks to pass," + " runs `rafa pr merge <pr> --yes`, waits for the run on the merge commit to end, appends the item to" + " `.rafa/stretch/<n>/items.ndjson` and prints the pit-stop readings. A loop that opened no pull request has its reason printed, merges nothing and exits with" + " `loop wait`'s code. With `--resume` instead of `--wait` it starts no planning session and no loop: it" + " finishes an item whose loop has ended from the last `rafa\xB7 pr #<n> opened` line of its log, skipping" + " the merge of a pull request merged already, and refuses an issue the ledger holds." + " `--dry-run` prints every step in order and runs none. Exit code 1 for a refusal," + " 2 for a step that failed, and the code of `plan create`, `loop wait` or `pr merge` when it fails.",
80289
80603
  args: [
80290
80604
  { name: "issue", description: "The number of the `type:spec` issue to plan and run.", type: "string", required: true }
80291
80605
  ],
80292
80606
  flags: [
80293
80607
  {
80294
80608
  name: "wait",
80295
- description: "Wait on the loop through `rafa loop wait`, then merge its pull request into the integration branch" + " with checks skipped, wait for CI and print the pit-stop readings.",
80609
+ description: "Wait on the loop through `rafa loop wait`, then wait for its pull request's checks, merge it into" + " the integration branch, wait for CI and print the pit-stop readings.",
80610
+ type: "boolean"
80611
+ },
80612
+ {
80613
+ name: "resume",
80614
+ description: "Finish an item whose loop has ended: read its pull request from the item's log, merge it unless it is" + " merged already, wait for CI, append the ledger line and print the pit-stop readings. Refused beside `--wait`.",
80296
80615
  type: "boolean"
80297
80616
  },
80298
80617
  { name: "dry-run", description: "Print every step in order, and run none of them.", type: "boolean" }
80299
80618
  ],
80300
80619
  examples: [
80301
80620
  { cmd: "rafa stretch item 812 --dry-run", note: "Prints the plan create line and the detached loop line." },
80302
- { cmd: "rafa stretch item 812 --wait", note: "Plans #812, starts its loop, waits on it and merges its pull request." }
80621
+ { cmd: "rafa stretch item 812 --wait", note: "Plans #812, starts its loop, waits on it and on its pull request's checks, and merges it." },
80622
+ { cmd: "rafa stretch item 812 --resume", note: "Finishes #812 once its loop has ended, from the pull request its log names." }
80303
80623
  ],
80304
80624
  outputs: ["text"],
80305
80625
  spends: { when: "unless", flag: "--dry-run", what: "one planning session and the loop it starts" },
@@ -80392,14 +80712,14 @@ init_rafa_board();
80392
80712
  init_rafa_effort();
80393
80713
  init_rafa_inventory();
80394
80714
  init_loop();
80395
- import { readFileSync as readFileSync100, realpathSync as realpathSync20 } from "fs";
80715
+ import { readFileSync as readFileSync101, realpathSync as realpathSync20 } from "fs";
80396
80716
  import { basename as basename29, dirname as dirname49 } from "path";
80397
80717
  var TIERS_SECTION_TITLE = "Skill tiers";
80398
80718
  var CLAUDE_VERSION_TIMEOUT_MS = 1e4;
80399
80719
  var VERSION_PATTERN = /^\s*(\d+\.\d+\.\d+)/;
80400
80720
  function readTextFile2(path6) {
80401
80721
  try {
80402
- return readFileSync100(path6, "utf8");
80722
+ return readFileSync101(path6, "utf8");
80403
80723
  } catch {
80404
80724
  return null;
80405
80725
  }
@@ -80486,10 +80806,14 @@ function cliVersionRows(installed, pinned = SERVE_CLI_VERSION) {
80486
80806
  }
80487
80807
  return [row2("cli-version", "warn", name2, `${installed} is installed, and skill delivery was probed against ${pinned}`, 'run the delivery probe again (context/inventory.md, "Serving") before trusting SERVE_CLI_VERSION')];
80488
80808
  }
80489
- function skillUseVersionRows(installed, pinned = SKILL_USE_CLI_VERSION) {
80490
- if (installed === null || installed === pinned)
80809
+ function skillUseVersionRows(installed, floor = SKILL_USE_CLI_FLOOR, fixture = SKILL_USE_FIXTURE_VERSION) {
80810
+ if (installed === null || installed === fixture)
80491
80811
  return [];
80492
- return [row2("skill-use-version", "warn", "Claude Code", `${installed} is installed, and the skill-use collector reads logs of ${pinned}, ` + "so skill_invocations stores the skill counts of the sessions it logs as unknown", "record the skill-use fixture again under the installed version (packages/rafa-effort/src/effort/skill-use.ts) before moving SKILL_USE_CLI_VERSION")];
80812
+ const source = "packages/rafa-effort/src/effort/skill-use.ts";
80813
+ if (compareCliVersions(installed, floor) < 0) {
80814
+ return [row2("skill-use-version", "warn", "Claude Code", `${installed} is installed, and the skill-use collector stores the skill counts of sessions logged below ${floor} as unknown`, `read a log of ${installed} and lower SKILL_USE_CLI_FLOOR (${source}) when its Skill call shape is the fixture's`)];
80815
+ }
80816
+ return [row2("skill-use-version", "note", "Claude Code", `${installed} is installed, and the skill-use collector reads its logs by skill name as unvouched: its fixture was recorded under ${fixture}`, `record the skill-use fixture again under ${installed} (${source}) and move SKILL_USE_FIXTURE_VERSION`)];
80493
80817
  }
80494
80818
  function doctorTierRows(inventory, installed, readers = {}) {
80495
80819
  const readText13 = readers.readText ?? readTextFile2;
@@ -80535,7 +80859,7 @@ function renderDoctorTiers(reading2) {
80535
80859
  // src/commands/doctor.ts
80536
80860
  var DEFAULT_DOCTOR_SEAMS = Object.freeze({ checks: Object.freeze({}) });
80537
80861
  var NOTHING_CHECKED = "Nothing was checked.";
80538
- function refusal26(lines3) {
80862
+ function refusal28(lines3) {
80539
80863
  return new CommandExit(1, [...lines3, NOTHING_CHECKED].join(`
80540
80864
  `));
80541
80865
  }
@@ -80543,21 +80867,21 @@ function expectNoArgument2(args) {
80543
80867
  if (args.length === 0)
80544
80868
  return;
80545
80869
  const got = `${String(args.length)}: ${args.join(" ")}`;
80546
- throw refusal26([`rafa doctor: expected no argument, got ${got}; name a plan with --plan=<file>`]);
80870
+ throw refusal28([`rafa doctor: expected no argument, got ${got}; name a plan with --plan=<file>`]);
80547
80871
  }
80548
80872
  function readPlanFlag2(value) {
80549
80873
  if (value === undefined)
80550
80874
  return null;
80551
80875
  if (typeof value === "string" && value !== "")
80552
80876
  return value;
80553
- throw refusal26(["rafa doctor: --plan needs a file: --plan=<file>"]);
80877
+ throw refusal28(["rafa doctor: --plan needs a file: --plan=<file>"]);
80554
80878
  }
80555
80879
  function readDeepFlag(value) {
80556
80880
  if (value === undefined || value === false || value === "false")
80557
80881
  return false;
80558
80882
  if (value === true || value === "true")
80559
80883
  return true;
80560
- throw refusal26([`rafa doctor: --deep takes no value, and read "${value}" as one; name a plan with --plan=<file>`]);
80884
+ throw refusal28([`rafa doctor: --deep takes no value, and read "${value}" as one; name a plan with --plan=<file>`]);
80561
80885
  }
80562
80886
  async function resolvedConfig(project, warn5) {
80563
80887
  try {
@@ -80565,7 +80889,7 @@ async function resolvedConfig(project, warn5) {
80565
80889
  } catch (error2) {
80566
80890
  if (!(error2 instanceof ConfigError))
80567
80891
  throw error2;
80568
- throw refusal26(["rafa doctor: the config cannot be used:", ...error2.problems.map((problem) => ` ${problem}`)]);
80892
+ throw refusal28(["rafa doctor: the config cannot be used:", ...error2.problems.map((problem) => ` ${problem}`)]);
80569
80893
  }
80570
80894
  }
80571
80895
  function defaultPlanPaths(root, planDir) {
@@ -80575,7 +80899,7 @@ function planFileAt(path6) {
80575
80899
  try {
80576
80900
  return isFile2(path6);
80577
80901
  } catch (error2) {
80578
- throw refusal26([`rafa doctor: the plan at ${path6} cannot be checked (${messageOf(error2)})`]);
80902
+ throw refusal28([`rafa doctor: the plan at ${path6} cannot be checked (${messageOf(error2)})`]);
80579
80903
  }
80580
80904
  }
80581
80905
  function choosePlan(root, config, named8) {
@@ -80583,7 +80907,7 @@ function choosePlan(root, config, named8) {
80583
80907
  if (planFileAt(path6))
80584
80908
  return { plan: path6, lookedFor: [] };
80585
80909
  if (named8 !== null)
80586
- throw refusal26([`rafa doctor: no plan file at ${path6}`]);
80910
+ throw refusal28([`rafa doctor: no plan file at ${path6}`]);
80587
80911
  return { plan: null, lookedFor: defaultPlanPaths(root, config.planDir) };
80588
80912
  }
80589
80913
  async function loadItems2(plan, config) {
@@ -80592,7 +80916,7 @@ async function loadItems2(plan, config) {
80592
80916
  try {
80593
80917
  return await loadPlanPrerequisites(plan, config);
80594
80918
  } catch (error2) {
80595
- throw refusal26(["rafa doctor: the plan's prerequisites cannot be read:", ` ${messageOf(error2)}`]);
80919
+ throw refusal28(["rafa doctor: the plan's prerequisites cannot be read:", ` ${messageOf(error2)}`]);
80596
80920
  }
80597
80921
  }
80598
80922
  function refuseMalformedItems2(plan, items2) {
@@ -80600,7 +80924,7 @@ function refuseMalformedItems2(plan, items2) {
80600
80924
  return;
80601
80925
  const file = basename30(prerequisitesPathForPlan(plan) ?? plan);
80602
80926
  const [head = "", ...rest] = malformedPrerequisiteLines(file, items2.malformed);
80603
- throw refusal26([
80927
+ throw refusal28([
80604
80928
  `rafa doctor: ${head}`,
80605
80929
  ...rest,
80606
80930
  "rafa loop start would refuse here, before any probe. No run was started and nothing was stored."
@@ -80758,9 +81082,9 @@ async function runDoctor(context, seams) {
80758
81082
  writeText(context, renderDoctorEffortSync(effortSync));
80759
81083
  const deep = await checkDeep(context, preflight, seams);
80760
81084
  writeText(context, deep === null ? [] : renderDeep(deep));
80761
- const refusal27 = doctorRefusal(preflight.report.halt, [effortSchemaRefusal(effortSchema), effortSyncRefusal(effortSync)]);
80762
- if (refusal27 !== null)
80763
- throw refusal27;
81085
+ const refusal29 = doctorRefusal(preflight.report.halt, [effortSchemaRefusal(effortSchema), effortSyncRefusal(effortSync)]);
81086
+ if (refusal29 !== null)
81087
+ throw refusal29;
80764
81088
  if (context.outputMode === "json")
80765
81089
  context.output.result(resultOf6(preflight, install, readings, deep));
80766
81090
  } finally {
@@ -80918,11 +81242,11 @@ init_copy();
80918
81242
  init_location();
80919
81243
  init_ndjson_files();
80920
81244
  import { join as join123, resolve as resolve44 } from "path";
80921
- var COMMAND_NAME17 = "rafa effort copy";
81245
+ var COMMAND_NAME20 = "rafa effort copy";
80922
81246
  var COPY_USAGE = "rafa effort copy [--to=<dir>]";
80923
81247
  var TO_FLAG2 = "to";
80924
- var REFUSED_EXIT6 = 1;
80925
- var FAILED_EXIT4 = 2;
81248
+ var REFUSED_EXIT8 = 1;
81249
+ var FAILED_EXIT7 = 2;
80926
81250
  var SCRATCH_DIR = join123(".rafa", "scratch");
80927
81251
  function effortDirLine(directory2) {
80928
81252
  return `${EFFORT_DIR_VARIABLE}=${directory2}`;
@@ -80932,7 +81256,7 @@ function readTarget(context, root) {
80932
81256
  if (value === undefined)
80933
81257
  return null;
80934
81258
  if (typeof value !== "string" || value === "") {
80935
- throw new CommandExit(REFUSED_EXIT6, `\u274C --${TO_FLAG2} takes a directory: --${TO_FLAG2}=<dir>
81259
+ throw new CommandExit(REFUSED_EXIT8, `\u274C --${TO_FLAG2} takes a directory: --${TO_FLAG2}=<dir>
80936
81260
  Usage: ${COPY_USAGE}`);
80937
81261
  }
80938
81262
  return resolve44(root, value);
@@ -80941,7 +81265,7 @@ function refuseEffortDirOverride(context) {
80941
81265
  const value = context.env[EFFORT_DIR_VARIABLE];
80942
81266
  if (value === undefined || value === "")
80943
81267
  return;
80944
- throw new CommandExit(REFUSED_EXIT6, `\u274C ${COMMAND_NAME17}: ${EFFORT_DIR_VARIABLE} is set (${value}); a copy is taken from the project's own store.` + ` Nothing was copied. Unset it and run again: ${EFFORT_DIR_VARIABLE}= ${COMMAND_NAME17}`);
81268
+ throw new CommandExit(REFUSED_EXIT8, `\u274C ${COMMAND_NAME20}: ${EFFORT_DIR_VARIABLE} is set (${value}); a copy is taken from the project's own store.` + ` Nothing was copied. Unset it and run again: ${EFFORT_DIR_VARIABLE}= ${COMMAND_NAME20}`);
80945
81269
  }
80946
81270
  function renderCopy(result2) {
80947
81271
  return [
@@ -80952,7 +81276,7 @@ function renderCopy(result2) {
80952
81276
  }
80953
81277
  function runCopy(context, seams) {
80954
81278
  expectNoArgument(context.args, COPY_USAGE);
80955
- const root = requireProject(context, COMMAND_NAME17).root;
81279
+ const root = requireProject(context, COMMAND_NAME20).root;
80956
81280
  const named8 = readTarget(context, root);
80957
81281
  refuseEffortDirOverride(context);
80958
81282
  const target = named8 ?? join123(root, SCRATCH_DIR, `effort-${fileStamp((seams.now ?? (() => new Date))())}`);
@@ -80961,9 +81285,9 @@ function runCopy(context, seams) {
80961
81285
  result2 = copyEffortStore({ source: join123(root, EFFORT_STORE_DIR), target });
80962
81286
  } catch (error2) {
80963
81287
  if (error2 instanceof EffortCopyRefusal)
80964
- throw new CommandExit(REFUSED_EXIT6, `\u274C ${COMMAND_NAME17}: ${error2.message}`);
81288
+ throw new CommandExit(REFUSED_EXIT8, `\u274C ${COMMAND_NAME20}: ${error2.message}`);
80965
81289
  if (error2 instanceof EffortCopyFailure)
80966
- throw new CommandExit(FAILED_EXIT4, `\u274C ${COMMAND_NAME17}: ${error2.message}`);
81290
+ throw new CommandExit(FAILED_EXIT7, `\u274C ${COMMAND_NAME20}: ${error2.message}`);
80967
81291
  throw error2;
80968
81292
  }
80969
81293
  if (context.outputMode === "json") {
@@ -81015,11 +81339,11 @@ init_plan_files2();
81015
81339
  init_command2();
81016
81340
  init_config2();
81017
81341
  import { homedir as homedir16 } from "os";
81018
- var COMMAND_NAME18 = "rafa effort dashboard";
81342
+ var COMMAND_NAME21 = "rafa effort dashboard";
81019
81343
  var USAGE33 = "rafa effort dashboard [--days=<n>] [--recent=<n>] [--loops=<n>] [--by=effort|model|agent]";
81020
81344
  var TREND_FLAGS = ["days", "recent", "loops", "by"];
81021
81345
  function refuse21(problems) {
81022
- throw new CommandExit(1, [...problems.map((problem) => `\u274C ${COMMAND_NAME18}: ${problem}`), `Usage: ${USAGE33}`].join(`
81346
+ throw new CommandExit(1, [...problems.map((problem) => `\u274C ${COMMAND_NAME21}: ${problem}`), `Usage: ${USAGE33}`].join(`
81023
81347
  `));
81024
81348
  }
81025
81349
  function trendOptionsOf(context) {
@@ -81036,7 +81360,7 @@ function trendOptionsOf(context) {
81036
81360
  }
81037
81361
  async function runDashboard(context, seams) {
81038
81362
  expectNoArgument(context.args, USAGE33);
81039
- const root = requireProject(context, COMMAND_NAME18).root;
81363
+ const root = requireProject(context, COMMAND_NAME21).root;
81040
81364
  const trend = trendOptionsOf(context);
81041
81365
  let dashboard;
81042
81366
  try {
@@ -81113,7 +81437,7 @@ init_command2();
81113
81437
  init_loop();
81114
81438
  init_fix_schema();
81115
81439
  init_sqlite();
81116
- var COMMAND_NAME19 = "rafa effort fix-schema";
81440
+ var COMMAND_NAME22 = "rafa effort fix-schema";
81117
81441
  var FIX_SCHEMA_USAGE = "rafa effort fix-schema [--dry-run]";
81118
81442
  var DRY_RUN_FLAG4 = "dry-run";
81119
81443
  function keepsIdLine(swapped) {
@@ -81124,12 +81448,12 @@ function refuseLiveLoop4(root, isAlive) {
81124
81448
  try {
81125
81449
  records = readSessions(root, isAlive === undefined ? {} : { isAlive });
81126
81450
  } catch (error2) {
81127
- throw new CommandExit(1, `\u274C ${COMMAND_NAME19}: the loop's run records cannot be read, so a live loop cannot be ruled out: ${String(error2)}`);
81451
+ throw new CommandExit(1, `\u274C ${COMMAND_NAME22}: the loop's run records cannot be read, so a live loop cannot be ruled out: ${String(error2)}`);
81128
81452
  }
81129
81453
  const live = records.find((record2) => record2.state === "running" || record2.state === "paused");
81130
81454
  if (live === undefined)
81131
81455
  return;
81132
- throw new CommandExit(1, `\u274C ${COMMAND_NAME19}: loop session ${live.sessionId} on ${live.branch} is ${live.state} and writes the store;` + ` stop it with \`rafa loop stop -s ${live.sessionId}\` first. \`--dry-run\` runs beside it.`);
81456
+ throw new CommandExit(1, `\u274C ${COMMAND_NAME22}: loop session ${live.sessionId} on ${live.branch} is ${live.state} and writes the store;` + ` stop it with \`rafa loop stop -s ${live.sessionId}\` first. \`--dry-run\` runs beside it.`);
81133
81457
  }
81134
81458
  function migrationNames(result2) {
81135
81459
  return result2.unknown.map(({ id: id3, appliedBy }) => `${id3} (applied by ${appliedBy})`).join(", ");
@@ -81184,7 +81508,7 @@ function runFixSchema(context, seams) {
81184
81508
  expectNoArgument(context.args, FIX_SCHEMA_USAGE);
81185
81509
  const dryRun = readSwitch2(DRY_RUN_FLAG4, context.flags[DRY_RUN_FLAG4], `Usage: ${FIX_SCHEMA_USAGE}`);
81186
81510
  if (context.project === null)
81187
- throw new Error(`${COMMAND_NAME19} runs inside a project, and was handed none`);
81511
+ throw new Error(`${COMMAND_NAME22} runs inside a project, and was handed none`);
81188
81512
  const root = context.project.root;
81189
81513
  if (!dryRun)
81190
81514
  refuseLiveLoop4(root, seams.isAlive);
@@ -81200,7 +81524,7 @@ function runFixSchema(context, seams) {
81200
81524
  });
81201
81525
  } catch (error2) {
81202
81526
  if (error2 instanceof RebuildRefusal)
81203
- throw new CommandExit(1, `\u274C ${COMMAND_NAME19}: ${error2.message}`);
81527
+ throw new CommandExit(1, `\u274C ${COMMAND_NAME22}: ${error2.message}`);
81204
81528
  throw error2;
81205
81529
  }
81206
81530
  if (context.outputMode === "json") {
@@ -81263,10 +81587,10 @@ init_merge_union();
81263
81587
  init_rebuild_aside();
81264
81588
  init_sqlite();
81265
81589
  import { join as join124, resolve as resolve45 } from "path";
81266
- var COMMAND_NAME20 = "rafa effort merge";
81590
+ var COMMAND_NAME23 = "rafa effort merge";
81267
81591
  var MERGE_USAGE = "rafa effort merge <file> [--dry-run]";
81268
81592
  var DRY_RUN_FLAG5 = "dry-run";
81269
- var REFUSED_EXIT7 = 1;
81593
+ var REFUSED_EXIT9 = 1;
81270
81594
  var UNMERGEABLE_EXIT = 2;
81271
81595
  var UNMERGEABLE_REASONS = new Set(["other-project", "ndjson"]);
81272
81596
  function tableLine2(entry) {
@@ -81288,7 +81612,7 @@ function closingLine2(result2, command63) {
81288
81612
  }
81289
81613
  return `\u2705 Merged. Every row the original held is copied to ${String(result2.backupPath)}.` + ` ${keepsIdLine("merged store")}`;
81290
81614
  }
81291
- function renderMerge(result2, command63 = COMMAND_NAME20) {
81615
+ function renderMerge(result2, command63 = COMMAND_NAME23) {
81292
81616
  const other = result2.otherStore === null ? "a store that names no origin" : `store ${result2.otherStore}`;
81293
81617
  const forward = result2.otherBroughtForward.length === 0 ? [] : [`A copy of the other store was brought forward through ${result2.otherBroughtForward.join(", ")}; the file itself was only read.`];
81294
81618
  return [
@@ -81299,20 +81623,20 @@ function renderMerge(result2, command63 = COMMAND_NAME20) {
81299
81623
  closingLine2(result2, command63)
81300
81624
  ];
81301
81625
  }
81302
- function mergeTargetPath(context, root, command63 = COMMAND_NAME20) {
81626
+ function mergeTargetPath(context, root, command63 = COMMAND_NAME23) {
81303
81627
  try {
81304
81628
  return join124(effortStoreDir(root, context.env), SQLITE_STORE_FILE_NAME);
81305
81629
  } catch (error2) {
81306
- throw new CommandExit(REFUSED_EXIT7, `\u274C ${command63}: ${messageOf(error2)}`);
81630
+ throw new CommandExit(REFUSED_EXIT9, `\u274C ${command63}: ${messageOf(error2)}`);
81307
81631
  }
81308
81632
  }
81309
- function mergeRefusalExit(error2, command63 = COMMAND_NAME20) {
81633
+ function mergeRefusalExit(error2, command63 = COMMAND_NAME23) {
81310
81634
  if (error2 instanceof MergeRefusal) {
81311
- const code = UNMERGEABLE_REASONS.has(error2.reason) ? UNMERGEABLE_EXIT : REFUSED_EXIT7;
81635
+ const code = UNMERGEABLE_REASONS.has(error2.reason) ? UNMERGEABLE_EXIT : REFUSED_EXIT9;
81312
81636
  return new CommandExit(code, `\u274C ${command63}: ${error2.message}`);
81313
81637
  }
81314
81638
  const known = error2 instanceof RebuildRefusal || error2 instanceof DevelopmentBuildRefusedError || error2 instanceof UnionSchemaMismatch;
81315
- return known ? new CommandExit(REFUSED_EXIT7, `\u274C ${command63}: ${error2.message}`) : null;
81639
+ return known ? new CommandExit(REFUSED_EXIT9, `\u274C ${command63}: ${error2.message}`) : null;
81316
81640
  }
81317
81641
  function probeSeams(seams) {
81318
81642
  return {
@@ -81326,9 +81650,9 @@ function probeSeams(seams) {
81326
81650
  async function runMerge2(context, seams) {
81327
81651
  const file = expectOneArgument(context.args, MERGE_USAGE);
81328
81652
  const dryRun = readSwitch2(DRY_RUN_FLAG5, context.flags[DRY_RUN_FLAG5], `Usage: ${MERGE_USAGE}`);
81329
- const project = requireProject(context, COMMAND_NAME20);
81653
+ const project = requireProject(context, COMMAND_NAME23);
81330
81654
  const path6 = mergeTargetPath(context, project.root);
81331
- const backend = (await resolveProjectConfig(project, COMMAND_NAME20, (message) => context.output.warn(message))).store;
81655
+ const backend = (await resolveProjectConfig(project, COMMAND_NAME23, (message) => context.output.warn(message))).store;
81332
81656
  const now = seams.now ?? (() => new Date);
81333
81657
  const otherPath = resolve45((seams.cwd ?? (() => process.cwd()))(), file);
81334
81658
  let result2;
@@ -81388,7 +81712,7 @@ var command63 = createMergeCommand();
81388
81712
  var merge_default2 = command63;
81389
81713
 
81390
81714
  // src/commands/effort/import.ts
81391
- var COMMAND_NAME21 = "rafa effort import";
81715
+ var COMMAND_NAME24 = "rafa effort import";
81392
81716
  var IMPORT_USAGE = "rafa effort import <file> [--dry-run]";
81393
81717
  var DRY_RUN_FLAG6 = "dry-run";
81394
81718
  function syncOptions(context, repoRoot, backend, seams) {
@@ -81408,19 +81732,19 @@ async function pull(sync, otherPath, dryRun) {
81408
81732
  try {
81409
81733
  pulled = await sync.pull({ from: otherPath, dryRun });
81410
81734
  } catch (error2) {
81411
- throw mergeRefusalExit(error2, COMMAND_NAME21) ?? error2;
81735
+ throw mergeRefusalExit(error2, COMMAND_NAME24) ?? error2;
81412
81736
  }
81413
81737
  if (pulled.status !== "pulled") {
81414
- throw new TypeError(`${COMMAND_NAME21}: the ${sync.kind} strategy answered ${pulled.status}, expected a merge`);
81738
+ throw new TypeError(`${COMMAND_NAME24}: the ${sync.kind} strategy answered ${pulled.status}, expected a merge`);
81415
81739
  }
81416
81740
  return pulled.merge;
81417
81741
  }
81418
81742
  async function runImport(context, seams) {
81419
81743
  const file = expectOneArgument(context.args, IMPORT_USAGE);
81420
81744
  const dryRun = readSwitch2(DRY_RUN_FLAG6, context.flags[DRY_RUN_FLAG6], `Usage: ${IMPORT_USAGE}`);
81421
- const project = requireProject(context, COMMAND_NAME21);
81422
- mergeTargetPath(context, project.root, COMMAND_NAME21);
81423
- const backend = (await resolveProjectConfig(project, COMMAND_NAME21, (message) => context.output.warn(message))).store;
81745
+ const project = requireProject(context, COMMAND_NAME24);
81746
+ mergeTargetPath(context, project.root, COMMAND_NAME24);
81747
+ const backend = (await resolveProjectConfig(project, COMMAND_NAME24, (message) => context.output.warn(message))).store;
81424
81748
  const otherPath = resolve46((seams.cwd ?? (() => process.cwd()))(), file);
81425
81749
  const sync = (seams.createSync ?? createFileSync)(syncOptions(context, project.root, backend, seams));
81426
81750
  const result2 = await pull(sync, otherPath, dryRun);
@@ -81428,7 +81752,7 @@ async function runImport(context, seams) {
81428
81752
  context.output.result(result2);
81429
81753
  return;
81430
81754
  }
81431
- for (const line of renderMerge(result2, COMMAND_NAME21))
81755
+ for (const line of renderMerge(result2, COMMAND_NAME24))
81432
81756
  context.output.info(line);
81433
81757
  }
81434
81758
  function createImportCommand(seams = {}) {
@@ -81483,10 +81807,10 @@ init_location();
81483
81807
  init_migrate();
81484
81808
  init_sqlite();
81485
81809
  import { join as join125 } from "path";
81486
- var COMMAND_NAME22 = "rafa effort migrate";
81810
+ var COMMAND_NAME25 = "rafa effort migrate";
81487
81811
  var MIGRATE_USAGE = "rafa effort migrate [--dry-run]";
81488
81812
  var DRY_RUN_FLAG7 = "dry-run";
81489
- var REFUSED_EXIT8 = 1;
81813
+ var REFUSED_EXIT10 = 1;
81490
81814
  function builtLines(result2) {
81491
81815
  const rows2 = result2.counted.reduce((sum, table2) => sum + table2.rows, 0);
81492
81816
  const breaking = result2.breaking.length === 0 ? "Every one is additive." : `${result2.breaking.join(", ")} breaks older runtimes: a rafa that does not know it refuses the store once it runs.`;
@@ -81517,13 +81841,13 @@ function storePath(context, root) {
81517
81841
  try {
81518
81842
  return join125(effortStoreDir(root, context.env), SQLITE_STORE_FILE_NAME);
81519
81843
  } catch (error2) {
81520
- throw new CommandExit(REFUSED_EXIT8, `\u274C ${COMMAND_NAME22}: ${messageOf(error2)}`);
81844
+ throw new CommandExit(REFUSED_EXIT10, `\u274C ${COMMAND_NAME25}: ${messageOf(error2)}`);
81521
81845
  }
81522
81846
  }
81523
81847
  function runMigrate(context, seams) {
81524
81848
  expectNoArgument(context.args, MIGRATE_USAGE);
81525
81849
  const dryRun = readSwitch2(DRY_RUN_FLAG7, context.flags[DRY_RUN_FLAG7], `Usage: ${MIGRATE_USAGE}`);
81526
- const path6 = storePath(context, requireProject(context, COMMAND_NAME22).root);
81850
+ const path6 = storePath(context, requireProject(context, COMMAND_NAME25).root);
81527
81851
  const now = seams.now ?? (() => new Date);
81528
81852
  let result2;
81529
81853
  try {
@@ -81539,7 +81863,7 @@ function runMigrate(context, seams) {
81539
81863
  });
81540
81864
  } catch (error2) {
81541
81865
  if (error2 instanceof RebuildRefusal || error2 instanceof DevelopmentBuildRefusedError) {
81542
- throw new CommandExit(REFUSED_EXIT8, `\u274C ${COMMAND_NAME22}: ${error2.message}`);
81866
+ throw new CommandExit(REFUSED_EXIT10, `\u274C ${COMMAND_NAME25}: ${error2.message}`);
81543
81867
  }
81544
81868
  throw error2;
81545
81869
  }
@@ -81601,7 +81925,7 @@ init_sections();
81601
81925
  init_ndjson();
81602
81926
  init_sqlite();
81603
81927
  init_types();
81604
- import { readFileSync as readFileSync101, writeFileSync as writeFileSync37 } from "fs";
81928
+ import { readFileSync as readFileSync102, writeFileSync as writeFileSync37 } from "fs";
81605
81929
  var MOVED_KINDS = Object.freeze(["sessions", "commits"]);
81606
81930
  var MOVE_TARGET = "sqlite";
81607
81931
  var STORE_LINE = `store: ${MOVE_TARGET}`;
@@ -81643,7 +81967,7 @@ function withSqliteStoreSetting(text2) {
81643
81967
  function plannedConfig(path6) {
81644
81968
  let text2;
81645
81969
  try {
81646
- text2 = readFileSync101(path6, "utf8");
81970
+ text2 = readFileSync102(path6, "utf8");
81647
81971
  } catch (error2) {
81648
81972
  throw new MoveRefusal("config", `${path6} could not be read: ${messageOf(error2)}. Nothing was moved.`);
81649
81973
  }
@@ -81715,16 +82039,16 @@ function moveToSqlite(options) {
81715
82039
  }
81716
82040
 
81717
82041
  // src/commands/effort/move.ts
81718
- var COMMAND_NAME23 = "rafa effort move";
82042
+ var COMMAND_NAME26 = "rafa effort move";
81719
82043
  var MOVE_USAGE = MOVE_TO_SQLITE;
81720
82044
  var TO_FLAG3 = "to";
81721
- var REFUSED_EXIT9 = 1;
82045
+ var REFUSED_EXIT11 = 1;
81722
82046
  function readTarget2(context) {
81723
82047
  const value = context.flags[TO_FLAG3];
81724
82048
  if (value === MOVE_TARGET)
81725
82049
  return;
81726
82050
  const found = value === undefined ? "no --to" : `--${TO_FLAG3}=${String(value)}`;
81727
- throw new CommandExit(REFUSED_EXIT9, `\u274C ${COMMAND_NAME23}: ${found}; a move writes to ${MOVE_TARGET} and nothing else. Nothing was moved.
82051
+ throw new CommandExit(REFUSED_EXIT11, `\u274C ${COMMAND_NAME26}: ${found}; a move writes to ${MOVE_TARGET} and nothing else. Nothing was moved.
81728
82052
  Usage: ${MOVE_USAGE}`);
81729
82053
  }
81730
82054
  function kindLine(move3) {
@@ -81747,17 +82071,17 @@ function renderMove(result2) {
81747
82071
  }
81748
82072
  function refusalExit(error2) {
81749
82073
  const known = error2 instanceof MoveRefusal || error2 instanceof SchemaRefusedError || error2 instanceof DevelopmentBuildRefusedError;
81750
- return known ? new CommandExit(REFUSED_EXIT9, `\u274C ${COMMAND_NAME23}: ${error2.message}`) : null;
82074
+ return known ? new CommandExit(REFUSED_EXIT11, `\u274C ${COMMAND_NAME26}: ${error2.message}`) : null;
81751
82075
  }
81752
82076
  async function runMove(context) {
81753
82077
  expectNoArgument(context.args, MOVE_USAGE);
81754
82078
  readTarget2(context);
81755
- const project = requireProject(context, COMMAND_NAME23);
81756
- await resolveProjectConfig(project, COMMAND_NAME23, (message) => context.output.warn(message));
82079
+ const project = requireProject(context, COMMAND_NAME26);
82080
+ await resolveProjectConfig(project, COMMAND_NAME26, (message) => context.output.warn(message));
81757
82081
  try {
81758
82082
  effortStoreDir(project.root, context.env);
81759
82083
  } catch (error2) {
81760
- throw new CommandExit(REFUSED_EXIT9, `\u274C ${COMMAND_NAME23}: ${messageOf(error2)}`);
82084
+ throw new CommandExit(REFUSED_EXIT11, `\u274C ${COMMAND_NAME26}: ${messageOf(error2)}`);
81761
82085
  }
81762
82086
  let result2;
81763
82087
  try {
@@ -81895,11 +82219,11 @@ init_sections();
81895
82219
  init_location();
81896
82220
  import { join as join126 } from "path";
81897
82221
  init_sqlite();
81898
- var COMMAND_NAME24 = "rafa effort schema";
82222
+ var COMMAND_NAME27 = "rafa effort schema";
81899
82223
  var SCHEMA_USAGE = "rafa effort schema [--check]";
81900
82224
  var CHECK_FLAG2 = "check";
81901
- var REFUSED_EXIT10 = 1;
81902
- var FAILED_EXIT5 = 2;
82225
+ var REFUSED_EXIT12 = 1;
82226
+ var FAILED_EXIT8 = 2;
81903
82227
  function listLine(name2, items2) {
81904
82228
  const shown3 = items2.length === 0 ? "none" : items2.join(", ");
81905
82229
  return `${name2} (${String(items2.length)}): ${shown3}`;
@@ -81942,25 +82266,25 @@ function storePath2(context, root) {
81942
82266
  try {
81943
82267
  return join126(effortStoreDir(root, context.env), SQLITE_STORE_FILE_NAME);
81944
82268
  } catch (error2) {
81945
- throw new CommandExit(REFUSED_EXIT10, `\u274C ${COMMAND_NAME24}: ${messageOf(error2)}`);
82269
+ throw new CommandExit(REFUSED_EXIT12, `\u274C ${COMMAND_NAME27}: ${messageOf(error2)}`);
81946
82270
  }
81947
82271
  }
81948
82272
  function runSchema(context, seams) {
81949
82273
  expectNoArgument(context.args, SCHEMA_USAGE);
81950
82274
  const check2 = readSwitch2(CHECK_FLAG2, context.flags[CHECK_FLAG2], `Usage: ${SCHEMA_USAGE}`);
81951
- const path6 = storePath2(context, requireProject(context, COMMAND_NAME24).root);
82275
+ const path6 = storePath2(context, requireProject(context, COMMAND_NAME27).root);
81952
82276
  let report4;
81953
82277
  try {
81954
82278
  report4 = readSchemaReport(path6, seams);
81955
82279
  } catch (error2) {
81956
- throw new CommandExit(FAILED_EXIT5, `\u274C ${COMMAND_NAME24}: ${path6} cannot be read as an effort store: ${messageOf(error2)}`);
82280
+ throw new CommandExit(FAILED_EXIT8, `\u274C ${COMMAND_NAME27}: ${path6} cannot be read as an effort store: ${messageOf(error2)}`);
81957
82281
  }
81958
82282
  if (context.outputMode !== "json") {
81959
82283
  for (const line of renderSchema(report4))
81960
82284
  context.output.info(line);
81961
82285
  }
81962
82286
  if (check2 && report4.refused) {
81963
- throw new CommandExit(REFUSED_EXIT10, `\u274C ${COMMAND_NAME24} --check: this rafa refuses ${path6} (${report4.status}). Next safe step: ${report4.nextStep}`);
82287
+ throw new CommandExit(REFUSED_EXIT12, `\u274C ${COMMAND_NAME27} --check: this rafa refuses ${path6} (${report4.status}). Next safe step: ${report4.nextStep}`);
81964
82288
  }
81965
82289
  if (context.outputMode === "json")
81966
82290
  context.output.result(report4);
@@ -82009,7 +82333,7 @@ init_command2();
82009
82333
  init_config2();
82010
82334
  init_load();
82011
82335
  init_sections();
82012
- import { existsSync as existsSync88, readFileSync as readFileSync103 } from "fs";
82336
+ import { existsSync as existsSync88, readFileSync as readFileSync104 } from "fs";
82013
82337
  import { homedir as homedir17 } from "os";
82014
82338
  import { join as join129, relative as relative31, sep as sep12 } from "path";
82015
82339
  init_project_id();
@@ -82021,7 +82345,7 @@ init_hop_record2();
82021
82345
  init_position();
82022
82346
  init_scope2();
82023
82347
  import { createHash as createHash10 } from "crypto";
82024
- import { existsSync as existsSync86, mkdirSync as mkdirSync35, readFileSync as readFileSync102, writeFileSync as writeFileSync38 } from "fs";
82348
+ import { existsSync as existsSync86, mkdirSync as mkdirSync35, readFileSync as readFileSync103, writeFileSync as writeFileSync38 } from "fs";
82025
82349
  import { dirname as dirname50, isAbsolute as isAbsolute28, join as join127 } from "path";
82026
82350
  var GITIGNORE_FILE = ".gitignore";
82027
82351
  var DIGEST_NAME = "tracking.digest";
@@ -82108,17 +82432,17 @@ function requireAbsolute3(root) {
82108
82432
  throw new GitignoreError(`project root is ${describeValue(root)}, expected an absolute path`);
82109
82433
  }
82110
82434
  }
82111
- function attempt5(file, failure10, act) {
82435
+ function attempt5(file, failure12, act) {
82112
82436
  try {
82113
82437
  return act();
82114
82438
  } catch (error2) {
82115
- throw new GitignoreError(`${file} ${failure10} (${messageOf(error2)})`, { cause: error2 });
82439
+ throw new GitignoreError(`${file} ${failure12} (${messageOf(error2)})`, { cause: error2 });
82116
82440
  }
82117
82441
  }
82118
82442
  function readIfPresent4(file) {
82119
82443
  if (!existsSync86(file))
82120
82444
  return null;
82121
- return attempt5(file, "cannot be read", () => readFileSync102(file, "utf8"));
82445
+ return attempt5(file, "cannot be read", () => readFileSync103(file, "utf8"));
82122
82446
  }
82123
82447
  function writeTrackingGitignore(root, flags) {
82124
82448
  requireAbsolute3(root);
@@ -82216,9 +82540,9 @@ function firstCandidate(found) {
82216
82540
  }
82217
82541
  function namedRoot(typed, start, source, seams) {
82218
82542
  const path6 = resolve47(start, typed);
82219
- const refusal27 = rootRefusal(path6, seams);
82220
- if (refusal27 !== null)
82221
- return problem(refusal27.reason);
82543
+ const refusal29 = rootRefusal(path6, seams);
82544
+ if (refusal29 !== null)
82545
+ return problem(refusal29.reason);
82222
82546
  const fs3 = seams.fs ?? DISK_ROOTS_FILE_SYSTEM;
82223
82547
  return chosen(fs3.realpath(path6), source);
82224
82548
  }
@@ -82258,7 +82582,7 @@ async function promptForRoot(found, prompter, seams) {
82258
82582
  // src/project/scaffold.ts
82259
82583
  init_rafa_inventory();
82260
82584
  init_rafa_release();
82261
- import { existsSync as existsSync87, lstatSync as lstatSync3, mkdirSync as mkdirSync36, statSync as statSync34, writeFileSync as writeFileSync39 } from "fs";
82585
+ import { existsSync as existsSync87, lstatSync as lstatSync3, mkdirSync as mkdirSync36, statSync as statSync35, writeFileSync as writeFileSync39 } from "fs";
82262
82586
  import { join as join128 } from "path";
82263
82587
  init_config2();
82264
82588
  init_sections();
@@ -82464,7 +82788,7 @@ function occupied(path6) {
82464
82788
  return lstatSync3(path6, { throwIfNoEntry: false }) !== undefined;
82465
82789
  }
82466
82790
  function isDirectory3(path6) {
82467
- return statSync34(path6, { throwIfNoEntry: false })?.isDirectory() === true;
82791
+ return statSync35(path6, { throwIfNoEntry: false })?.isDirectory() === true;
82468
82792
  }
82469
82793
  function directoryConflict(dir) {
82470
82794
  if (!occupied(dir) || isDirectory3(dir))
@@ -82483,11 +82807,11 @@ function layoutConflicts(layout) {
82483
82807
  function scaffoldConflicts(root, home) {
82484
82808
  return [...layoutConflicts(layoutOf2(root, PROJECT_TREE)), ...layoutConflicts(layoutOf2(home, USER_TREE))];
82485
82809
  }
82486
- function attempt6(path6, failure10, act) {
82810
+ function attempt6(path6, failure12, act) {
82487
82811
  try {
82488
82812
  act();
82489
82813
  } catch (error2) {
82490
- throw new ScaffoldError(`${path6} ${failure10} (${messageOf(error2)})`, { cause: error2 });
82814
+ throw new ScaffoldError(`${path6} ${failure12} (${messageOf(error2)})`, { cause: error2 });
82491
82815
  }
82492
82816
  }
82493
82817
  function ensureDirectory(path6) {
@@ -82642,7 +82966,7 @@ var SOURCE_PHRASES = {
82642
82966
  "root-flag": "named by --root",
82643
82967
  typed: "typed at the prompt"
82644
82968
  };
82645
- function refusal27(lines3) {
82969
+ function refusal29(lines3) {
82646
82970
  return new CommandExit(1, [...lines3, NOTHING_WRITTEN3].join(`
82647
82971
  `));
82648
82972
  }
@@ -82650,14 +82974,14 @@ function expectNoArgument3(args) {
82650
82974
  if (args.length === 0)
82651
82975
  return;
82652
82976
  const got = `${String(args.length)}: ${args.join(" ")}`;
82653
- throw refusal27([`rafa init: expected no argument, got ${got}; name a root with --root=<path>`]);
82977
+ throw refusal29([`rafa init: expected no argument, got ${got}; name a root with --root=<path>`]);
82654
82978
  }
82655
82979
  function readYesFlag(value) {
82656
82980
  if (value === undefined || value === false || value === "false")
82657
82981
  return false;
82658
82982
  if (value === true || value === "true")
82659
82983
  return true;
82660
- throw refusal27([`rafa init: --yes takes no value, and read "${value}" as one; name a root with --root=<path>`]);
82984
+ throw refusal29([`rafa init: --yes takes no value, and read "${value}" as one; name a root with --root=<path>`]);
82661
82985
  }
82662
82986
  function readBoardFlag(value) {
82663
82987
  if (value === undefined)
@@ -82666,7 +82990,7 @@ function readBoardFlag(value) {
82666
82990
  return true;
82667
82991
  if (value === false || value === "false")
82668
82992
  return false;
82669
- throw refusal27([`rafa init: --board takes no value, and read "${value}" as one;` + " set the board up with --board, or leave it alone with --no-board"]);
82993
+ throw refusal29([`rafa init: --board takes no value, and read "${value}" as one;` + " set the board up with --board, or leave it alone with --no-board"]);
82670
82994
  }
82671
82995
  function readEpicGuardFlag(value) {
82672
82996
  if (value === undefined)
@@ -82675,7 +82999,7 @@ function readEpicGuardFlag(value) {
82675
82999
  return true;
82676
83000
  if (value === false || value === "false")
82677
83001
  return false;
82678
- throw refusal27([`rafa init: --epic-guard takes no value, and read "${value}" as one;` + " install the workflow with --epic-guard, or leave it out with --no-epic-guard"]);
83002
+ throw refusal29([`rafa init: --epic-guard takes no value, and read "${value}" as one;` + " install the workflow with --epic-guard, or leave it out with --no-epic-guard"]);
82679
83003
  }
82680
83004
  function readProjectFlag(value) {
82681
83005
  if (value === undefined)
@@ -82684,7 +83008,7 @@ function readProjectFlag(value) {
82684
83008
  return true;
82685
83009
  if (value === false || value === "false")
82686
83010
  return false;
82687
- throw refusal27([`rafa init: --project takes no value, and read "${value}" as one;` + " create the GitHub project with --project, or leave it out with --no-project"]);
83011
+ throw refusal29([`rafa init: --project takes no value, and read "${value}" as one;` + " create the GitHub project with --project, or leave it out with --no-project"]);
82688
83012
  }
82689
83013
  function readReleaseFlag(value) {
82690
83014
  if (value === undefined)
@@ -82693,27 +83017,27 @@ function readReleaseFlag(value) {
82693
83017
  return true;
82694
83018
  if (value === false || value === "false")
82695
83019
  return false;
82696
- throw refusal27([`rafa init: --release takes no value, and read "${value}" as one;` + " turn the release on with --release, or leave it alone with --no-release"]);
83020
+ throw refusal29([`rafa init: --release takes no value, and read "${value}" as one;` + " turn the release on with --release, or leave it alone with --no-release"]);
82697
83021
  }
82698
83022
  function readRootFlag(value) {
82699
83023
  if (value === undefined)
82700
83024
  return null;
82701
83025
  if (typeof value === "string" && value !== "")
82702
83026
  return value;
82703
- throw refusal27(["rafa init: --root needs a path: --root=<path>"]);
83027
+ throw refusal29(["rafa init: --root needs a path: --root=<path>"]);
82704
83028
  }
82705
83029
  function takeReading(reading2, found) {
82706
83030
  if (reading2.root !== null)
82707
83031
  return reading2.root;
82708
83032
  const listed5 = found === null ? [] : [...candidateLines(found), "Name another root with --root=<path>."];
82709
- throw refusal27([`rafa init: refused: ${reading2.problem}`, ...listed5]);
83033
+ throw refusal29([`rafa init: refused: ${reading2.problem}`, ...listed5]);
82710
83034
  }
82711
83035
  async function promptedRoot(found, seams, refusalSeams) {
82712
83036
  const prompter = seams.openPrompter();
82713
83037
  try {
82714
83038
  const root = await promptForRoot(found, prompter, refusalSeams);
82715
83039
  if (root === null)
82716
- throw refusal27(["rafa init: the input ended before a root was chosen."]);
83040
+ throw refusal29(["rafa init: the input ended before a root was chosen."]);
82717
83041
  return root;
82718
83042
  } finally {
82719
83043
  prompter.close();
@@ -82730,7 +83054,7 @@ async function chooseRoot(context, seams, start, home, yes) {
82730
83054
  if (yes)
82731
83055
  return takeReading(firstCandidate(found), found);
82732
83056
  if (!seams.isTerminal()) {
82733
- throw refusal27([
83057
+ throw refusal29([
82734
83058
  "rafa init: no terminal to choose a root on.",
82735
83059
  ...candidateLines(found),
82736
83060
  "Take the first candidate with --yes, or name a root with --root=<path>."
@@ -82744,24 +83068,24 @@ async function resolvedConfig2(root, home, warn5) {
82744
83068
  } catch (error2) {
82745
83069
  if (!(error2 instanceof ConfigError))
82746
83070
  throw error2;
82747
- throw refusal27(["rafa init: the config cannot be used:", ...error2.problems.map((problem2) => ` ${problem2}`)]);
83071
+ throw refusal29(["rafa init: the config cannot be used:", ...error2.problems.map((problem2) => ` ${problem2}`)]);
82748
83072
  }
82749
83073
  }
82750
83074
  function checkGitignore(root, flags) {
82751
83075
  const file = join129(root, GITIGNORE_FILE);
82752
83076
  try {
82753
- const text2 = existsSync88(file) ? readFileSync103(file, "utf8") : null;
83077
+ const text2 = existsSync88(file) ? readFileSync104(file, "utf8") : null;
82754
83078
  withTrackingBlock(text2, flags, file);
82755
83079
  } catch (error2) {
82756
83080
  const message = error2 instanceof GitignoreError ? error2.message : `rafa init: ${file} cannot be read (${messageOf(error2)})`;
82757
- throw refusal27([message]);
83081
+ throw refusal29([message]);
82758
83082
  }
82759
83083
  }
82760
83084
  function checkConflicts(root, home) {
82761
83085
  const conflicts = scaffoldConflicts(root, home);
82762
83086
  if (conflicts.length === 0)
82763
83087
  return;
82764
- throw refusal27(["rafa init: the scopes cannot be written:", ...conflicts.map((conflict) => ` ${conflict}`)]);
83088
+ throw refusal29(["rafa init: the scopes cannot be written:", ...conflicts.map((conflict) => ` ${conflict}`)]);
82765
83089
  }
82766
83090
  function digestChange(existed, rewritten2) {
82767
83091
  if (!rewritten2)
@@ -84026,7 +84350,7 @@ import { homedir as homedir18 } from "os";
84026
84350
 
84027
84351
  // src/notices/notices.ts
84028
84352
  init_sections();
84029
- import { mkdirSync as mkdirSync37, readFileSync as readFileSync104, writeFileSync as writeFileSync41 } from "fs";
84353
+ import { mkdirSync as mkdirSync37, readFileSync as readFileSync105, writeFileSync as writeFileSync41 } from "fs";
84030
84354
  import { dirname as dirname51, join as join130 } from "path";
84031
84355
  var NOTICE_IDS = Object.freeze(["alpha", "danger"]);
84032
84356
  var FEEDBACK_URL = "https://github.com/open-tomato/rafa/issues/new/choose";
@@ -84040,7 +84364,7 @@ function isNoticeId(value) {
84040
84364
  function readDismissed(home) {
84041
84365
  let raw;
84042
84366
  try {
84043
- raw = readFileSync104(noticesPath(home), "utf8");
84367
+ raw = readFileSync105(noticesPath(home), "utf8");
84044
84368
  } catch {
84045
84369
  return [];
84046
84370
  }
@@ -85834,7 +86158,7 @@ init_rafa_inventory();
85834
86158
  init_sections();
85835
86159
  init_output();
85836
86160
  init_plan();
85837
- import { readdirSync as readdirSync29, readFileSync as readFileSync105, realpathSync as realpathSync21, statSync as statSync35, writeFileSync as writeFileSync42 } from "fs";
86161
+ import { readdirSync as readdirSync29, readFileSync as readFileSync106, realpathSync as realpathSync21, statSync as statSync36, writeFileSync as writeFileSync42 } from "fs";
85838
86162
  import { basename as basename31, isAbsolute as isAbsolute30, join as join131, relative as relative34, resolve as resolve49, sep as sep13 } from "path";
85839
86163
  init_tiers();
85840
86164
  var SOURCE_DIR2 = "src";
@@ -85848,7 +86172,7 @@ function realPathOrNull(path7) {
85848
86172
  }
85849
86173
  }
85850
86174
  function isFilePath(path7) {
85851
- return statSync35(path7, { throwIfNoEntry: false })?.isFile() === true;
86175
+ return statSync36(path7, { throwIfNoEntry: false })?.isFile() === true;
85852
86176
  }
85853
86177
  function bundledAgents(root) {
85854
86178
  if (root === null)
@@ -85932,7 +86256,7 @@ function tierPinItem(edit, planFileName2) {
85932
86256
  }
85933
86257
  function readOrNull(path7) {
85934
86258
  try {
85935
- return readFileSync105(path7, "utf8");
86259
+ return readFileSync106(path7, "utf8");
85936
86260
  } catch (error2) {
85937
86261
  const isAbsent2 = typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
85938
86262
  if (isAbsent2)
@@ -85985,7 +86309,7 @@ function notePlanBundledEdits(repoRoot, generated, output = activeOutput()) {
85985
86309
  const planFile2 = resolve49(repoRoot, generated.planPath);
85986
86310
  if (!isFile2(planFile2))
85987
86311
  return generated;
85988
- const edits = findBundledEdits(readFileSync105(planFile2, "utf8"), { repoRoot });
86312
+ const edits = findBundledEdits(readFileSync106(planFile2, "utf8"), { repoRoot });
85989
86313
  if (edits.length === 0)
85990
86314
  return generated;
85991
86315
  const file = generated.prerequisitesPath ?? prerequisitesPathForPlan(generated.planPath);
@@ -86193,14 +86517,14 @@ async function settleReview(gate, generated, skipReview) {
86193
86517
  }
86194
86518
 
86195
86519
  // src/commands/plan/store-check.ts
86196
- import { mkdirSync as mkdirSync38, readFileSync as readFileSync106, renameSync as renameSync14 } from "fs";
86520
+ import { mkdirSync as mkdirSync38, readFileSync as readFileSync107, renameSync as renameSync14 } from "fs";
86197
86521
  import { basename as basename32, dirname as dirname52, resolve as resolve50 } from "path";
86198
86522
  init_command2();
86199
86523
  init_sections();
86200
86524
  init_output();
86201
86525
  init_plan();
86202
86526
  function readFileOrNull(path8) {
86203
- return path8 !== null && isFile2(path8) ? readFileSync106(path8, "utf8") : null;
86527
+ return path8 !== null && isFile2(path8) ? readFileSync107(path8, "utf8") : null;
86204
86528
  }
86205
86529
  function checkStoreRules(file, markdown) {
86206
86530
  const prerequisitesPath = prerequisitesPathForPlan(file);
@@ -86227,7 +86551,7 @@ function enforceStoreRules(repoRoot, generated, output = activeOutput()) {
86227
86551
  const planFile2 = resolve50(repoRoot, generated.planPath);
86228
86552
  if (!isFile2(planFile2))
86229
86553
  return;
86230
- const problems = checkStoreRules(planFile2, readFileSync106(planFile2, "utf8"));
86554
+ const problems = checkStoreRules(planFile2, readFileSync107(planFile2, "utf8"));
86231
86555
  if (problems.length === 0)
86232
86556
  return;
86233
86557
  const prerequisites = generated.prerequisitesPath ?? prerequisitesPathForPlan(generated.planPath);
@@ -86702,7 +87026,7 @@ var list_default10 = command86;
86702
87026
  // src/commands/plan/risk.ts
86703
87027
  init_rafa_board();
86704
87028
  init_rafa_pr();
86705
- import { readFileSync as readFileSync107 } from "fs";
87029
+ import { readFileSync as readFileSync108 } from "fs";
86706
87030
  import { resolve as resolve51 } from "path";
86707
87031
  init_plan_files2();
86708
87032
  init_command2();
@@ -86734,7 +87058,7 @@ function strictRefusal(report4) {
86734
87058
  }
86735
87059
  async function readRisk(path9, project, config, context, seams) {
86736
87060
  const makeRunners = seams.runners ?? spawningRunners2;
86737
- return assessPlanRisk({ path: path9, text: readFileSync107(path9, "utf8") }, {
87061
+ return assessPlanRisk({ path: path9, text: readFileSync108(path9, "utf8") }, {
86738
87062
  repoRoot: project.root,
86739
87063
  home: project.home,
86740
87064
  settingSources: config.settingSources,
@@ -86821,7 +87145,7 @@ var risk_default = command87;
86821
87145
  init_plan_files2();
86822
87146
  init_command2();
86823
87147
  init_plan();
86824
- import { readFileSync as readFileSync108 } from "fs";
87148
+ import { readFileSync as readFileSync109 } from "fs";
86825
87149
  import { join as join132 } from "path";
86826
87150
  var USAGE48 = "rafa plan show <stub> [--tracker]";
86827
87151
  var COMMAND8 = "rafa plan show";
@@ -86843,7 +87167,7 @@ function showPlan(plans, stub, tracker) {
86843
87167
  const file = join132(plans.path, name2);
86844
87168
  if (!isFile2(file))
86845
87169
  throw new CommandExit(1, missingText(stub, tracker, join132(plans.label, name2)));
86846
- const model = parsePlan(readFileSync108(file, "utf8"));
87170
+ const model = parsePlan(readFileSync109(file, "utf8"));
86847
87171
  const { header } = model;
86848
87172
  return {
86849
87173
  stub,
@@ -86937,7 +87261,7 @@ var show_default7 = command88;
86937
87261
 
86938
87262
  // src/commands/plan/validate.ts
86939
87263
  init_rafa_inventory();
86940
- import { readFileSync as readFileSync109 } from "fs";
87264
+ import { readFileSync as readFileSync110 } from "fs";
86941
87265
  import { basename as basename33, resolve as resolve52 } from "path";
86942
87266
  init_plan_files2();
86943
87267
  init_command2();
@@ -87048,7 +87372,7 @@ function createPlanValidateCommand(workingDirectory = () => process.cwd()) {
87048
87372
  const file = resolve52(workingDirectory(), typed);
87049
87373
  const validation = validatePlan(file);
87050
87374
  const { issues, stages, tasks } = validation;
87051
- const markdown = readFileSync109(file, "utf8");
87375
+ const markdown = readFileSync110(file, "utf8");
87052
87376
  const findings = await checkRoster(context, markdown);
87053
87377
  const { missingAgents, skillCollisions, unresolvedSkills } = findings;
87054
87378
  const storeProblems = checkStoreRules(file, markdown);
@@ -87258,7 +87582,7 @@ var self_update_default = command91;
87258
87582
  init_rafa_inventory();
87259
87583
  init_command2();
87260
87584
  init_load();
87261
- import { statSync as statSync36 } from "fs";
87585
+ import { statSync as statSync37 } from "fs";
87262
87586
  import { join as join133, resolve as resolve53 } from "path";
87263
87587
  var DEFAULT_BACKFILL_SEAMS = Object.freeze({
87264
87588
  cwd: () => process.cwd()
@@ -87307,7 +87631,7 @@ Usage: ${BACKFILL_USAGE}`);
87307
87631
  }
87308
87632
  function isDirectory4(path9) {
87309
87633
  try {
87310
- return statSync36(path9).isDirectory();
87634
+ return statSync37(path9).isDirectory();
87311
87635
  } catch {
87312
87636
  return false;
87313
87637
  }
@@ -87595,7 +87919,7 @@ var check_default3 = command93;
87595
87919
  // src/commands/skill/demote.ts
87596
87920
  init_rafa_inventory();
87597
87921
  init_command2();
87598
- import { existsSync as existsSync89, mkdirSync as mkdirSync39, readFileSync as readFileSync110, statSync as statSync37, writeFileSync as writeFileSync43 } from "fs";
87922
+ import { existsSync as existsSync89, mkdirSync as mkdirSync39, readFileSync as readFileSync111, statSync as statSync38, writeFileSync as writeFileSync43 } from "fs";
87599
87923
  import { dirname as dirname53, resolve as resolve54 } from "path";
87600
87924
  var DEFAULT_DEMOTE_SEAMS = Object.freeze({
87601
87925
  cwd: () => process.cwd()
@@ -87624,7 +87948,7 @@ Usage: ${DEMOTE_USAGE}`);
87624
87948
  }
87625
87949
  function isDirectory5(path9) {
87626
87950
  try {
87627
- return statSync37(path9).isDirectory();
87951
+ return statSync38(path9).isDirectory();
87628
87952
  } catch {
87629
87953
  return false;
87630
87954
  }
@@ -87654,7 +87978,7 @@ function verdictLine2(report4) {
87654
87978
  function previousReport(path9, context) {
87655
87979
  if (!existsSync89(path9))
87656
87980
  return null;
87657
- const parsed2 = parseDemotionReport(readFileSync110(path9, "utf8"));
87981
+ const parsed2 = parseDemotionReport(readFileSync111(path9, "utf8"));
87658
87982
  if (parsed2.report !== null)
87659
87983
  return parsed2.report;
87660
87984
  context.output.warn(`the report already at ${path9} does not parse, so no override in it is carried forward:` + ` ${parsed2.issues.map((issue5) => `line ${String(issue5.line)} ${issue5.code}`).join(", ")}`);
@@ -87690,7 +88014,7 @@ function reviewedReport(scope) {
87690
88014
  if (!existsSync89(scope.reportPath)) {
87691
88015
  throw new CommandExit(1, `\u274C No report at ${scope.reportPath}; run "rafa skill demote ${scope.dir}" first, then review it`);
87692
88016
  }
87693
- const parsed2 = parseDemotionReport(readFileSync110(scope.reportPath, "utf8"));
88017
+ const parsed2 = parseDemotionReport(readFileSync111(scope.reportPath, "utf8"));
87694
88018
  if (parsed2.report === null) {
87695
88019
  const lines3 = parsed2.issues.map((issue5) => ` line ${String(issue5.line)} ${issue5.code}: ${issue5.message}`);
87696
88020
  throw new CommandExit(1, [`\u274C ${scope.reportPath} does not parse:`, ...lines3].join(`
@@ -87800,7 +88124,7 @@ init_rafa_inventory();
87800
88124
  init_plan_files2();
87801
88125
  init_command2();
87802
88126
  var DEFAULT_SKILL_SHOW_SEAMS = DEFAULT_SKILL_LIST_SEAMS;
87803
- var COMMAND_NAME25 = "rafa skill show";
88127
+ var COMMAND_NAME28 = "rafa skill show";
87804
88128
  var USAGE51 = "rafa skill show <name> [--full]";
87805
88129
  function unknownSkillMessage(name2, inventory) {
87806
88130
  const agent = findShown(inventory.records, "agent", name2);
@@ -87828,7 +88152,7 @@ async function runShow4(context, seams) {
87828
88152
  const full = readSwitch2("full", context.flags["full"], `Type the name ahead of it: ${USAGE51}`);
87829
88153
  const name2 = expectOneArgument(context.args, USAGE51);
87830
88154
  const project = projectOf16(context);
87831
- const { inventory, settingSources } = await projectInventory(project, context, seams, COMMAND_NAME25);
88155
+ const { inventory, settingSources } = await projectInventory(project, context, seams, COMMAND_NAME28);
87832
88156
  const warnings = warningLines(inventory);
87833
88157
  for (const warning of warnings)
87834
88158
  context.output.warn(warning);
@@ -88467,7 +88791,7 @@ async function readStatusSections(input, seams = {}) {
88467
88791
  }
88468
88792
 
88469
88793
  // src/commands/status.ts
88470
- var COMMAND_NAME26 = "rafa status";
88794
+ var COMMAND_NAME29 = "rafa status";
88471
88795
  var STATUS_USAGE = "rafa status";
88472
88796
  var STATUS_ARGUMENT_EXIT = 2;
88473
88797
  var DEFAULT_STATUS_SEAMS = Object.freeze({});
@@ -88479,13 +88803,13 @@ function projectOf17(context) {
88479
88803
  function expectNoWord(args) {
88480
88804
  if (args.length === 0)
88481
88805
  return;
88482
- throw new CommandExit(STATUS_ARGUMENT_EXIT, `\u274C ${COMMAND_NAME26}: expected no argument, got ${String(args.length)}: ${args.join(" ")}
88806
+ throw new CommandExit(STATUS_ARGUMENT_EXIT, `\u274C ${COMMAND_NAME29}: expected no argument, got ${String(args.length)}: ${args.join(" ")}
88483
88807
  Usage: ${STATUS_USAGE}`);
88484
88808
  }
88485
88809
  async function runStatus2(context, seams) {
88486
88810
  expectNoWord(context.args);
88487
88811
  const project = projectOf17(context);
88488
- const config = await resolveProjectConfig(project, COMMAND_NAME26, (message) => {
88812
+ const config = await resolveProjectConfig(project, COMMAND_NAME29, (message) => {
88489
88813
  context.output.warn(message);
88490
88814
  });
88491
88815
  const warn5 = (message) => {
@@ -88539,14 +88863,14 @@ init_command2();
88539
88863
  init_config2();
88540
88864
  init_sections();
88541
88865
  init_git2();
88542
- import { existsSync as existsSync91, mkdirSync as mkdirSync40, readFileSync as readFileSync111, writeFileSync as writeFileSync44 } from "fs";
88866
+ import { existsSync as existsSync91, mkdirSync as mkdirSync40, readFileSync as readFileSync112, writeFileSync as writeFileSync44 } from "fs";
88543
88867
  import { dirname as dirname54, join as join134 } from "path";
88544
- var COMMAND_NAME27 = "rafa stretch end";
88868
+ var COMMAND_NAME30 = "rafa stretch end";
88545
88869
  var STRETCH_END_USAGE = "rafa stretch end [--dry-run]";
88546
88870
  var REPORT_FILE2 = "report.md";
88547
88871
  var BODY_FILE = "pr-body.md";
88548
- var REFUSED_EXIT11 = 1;
88549
- var FAILED_EXIT6 = 2;
88872
+ var REFUSED_EXIT13 = 1;
88873
+ var FAILED_EXIT9 = 2;
88550
88874
  function reportPath(root, n) {
88551
88875
  return join134(stretchFolder(root, n), REPORT_FILE2);
88552
88876
  }
@@ -88568,11 +88892,11 @@ ${closes2.join(`
88568
88892
  `)}
88569
88893
  `;
88570
88894
  }
88571
- function refusal28(why) {
88572
- return new CommandExit(REFUSED_EXIT11, `\u274C ${COMMAND_NAME27}: ${why}`);
88895
+ function refusal30(why) {
88896
+ return new CommandExit(REFUSED_EXIT13, `\u274C ${COMMAND_NAME30}: ${why}`);
88573
88897
  }
88574
- function failure10(why) {
88575
- return new CommandExit(FAILED_EXIT6, `\u274C ${COMMAND_NAME27}: ${why}`);
88898
+ function failure12(why) {
88899
+ return new CommandExit(FAILED_EXIT9, `\u274C ${COMMAND_NAME30}: ${why}`);
88576
88900
  }
88577
88901
  function readEndLine(context) {
88578
88902
  expectNoArgument(context.args, STRETCH_END_USAGE);
@@ -88583,24 +88907,24 @@ function requireStretchBase2(prBase) {
88583
88907
  if (n !== null)
88584
88908
  return n;
88585
88909
  const found = prBase === null ? "not set" : `"${prBase}"`;
88586
- throw refusal28(`${PR_BASE_KEY} is ${found}, expected a ${STRETCH_BRANCH_PREFIX}<n> branch: the stretch to end is the one` + ` ${PR_BASE_KEY} points at, and a ${PR_BASE_KEY} already put back leaves none to end. Nothing was run.`);
88910
+ throw refusal30(`${PR_BASE_KEY} is ${found}, expected a ${STRETCH_BRANCH_PREFIX}<n> branch: the stretch to end is the one` + ` ${PR_BASE_KEY} points at, and a ${PR_BASE_KEY} already put back leaves none to end. Nothing was run.`);
88587
88911
  }
88588
88912
  function readReport2(root, n) {
88589
88913
  const path9 = reportPath(root, n);
88590
88914
  if (!existsSync91(path9)) {
88591
- throw refusal28(`there is no ${path9}: write the stretch report first, since it is the pull request's body. Nothing was run.`);
88915
+ throw refusal30(`there is no ${path9}: write the stretch report first, since it is the pull request's body. Nothing was run.`);
88592
88916
  }
88593
88917
  try {
88594
- return readFileSync111(path9, "utf8");
88918
+ return readFileSync112(path9, "utf8");
88595
88919
  } catch (error2) {
88596
- throw refusal28(`${path9} could not be read: ${messageOf(error2)}. Nothing was run.`);
88920
+ throw refusal30(`${path9} could not be read: ${messageOf(error2)}. Nothing was run.`);
88597
88921
  }
88598
88922
  }
88599
88923
  function recordText(record2, name2, path9) {
88600
88924
  const value = record2[name2];
88601
88925
  if (typeof value === "string" && value !== "")
88602
88926
  return value;
88603
- throw refusal28(`${path9} holds ${name2} ${describeValue(value)}, expected a branch name. Nothing was run.`);
88927
+ throw refusal30(`${path9} holds ${name2} ${describeValue(value)}, expected a branch name. Nothing was run.`);
88604
88928
  }
88605
88929
  function readStretchRecord(root, n) {
88606
88930
  const path9 = stretchRecordPath(root, n);
@@ -88608,15 +88932,15 @@ function readStretchRecord(root, n) {
88608
88932
  return null;
88609
88933
  let value;
88610
88934
  try {
88611
- value = JSON.parse(readFileSync111(path9, "utf8"));
88935
+ value = JSON.parse(readFileSync112(path9, "utf8"));
88612
88936
  } catch (error2) {
88613
- throw refusal28(`${path9} could not be read as JSON: ${messageOf(error2)}. Nothing was run.`);
88937
+ throw refusal30(`${path9} could not be read as JSON: ${messageOf(error2)}. Nothing was run.`);
88614
88938
  }
88615
88939
  if (!isMapping(value))
88616
- throw refusal28(`${path9} holds ${describeValue(value)}, expected an object. Nothing was run.`);
88940
+ throw refusal30(`${path9} holds ${describeValue(value)}, expected an object. Nothing was run.`);
88617
88941
  const prBase = value["prBase"];
88618
88942
  if (prBase !== null && (typeof prBase !== "string" || prBase === "")) {
88619
- throw refusal28(`${path9} holds prBase ${describeValue(prBase)}, expected a branch name or null. Nothing was run.`);
88943
+ throw refusal30(`${path9} holds prBase ${describeValue(prBase)}, expected a branch name or null. Nothing was run.`);
88620
88944
  }
88621
88945
  const startedAt = value["startedAt"];
88622
88946
  return {
@@ -88627,12 +88951,12 @@ function readStretchRecord(root, n) {
88627
88951
  startedAt: typeof startedAt === "string" ? startedAt : ""
88628
88952
  };
88629
88953
  }
88630
- function ledgerItems(context, root, n) {
88954
+ function ledgerItems2(context, root, n) {
88631
88955
  let reading2;
88632
88956
  try {
88633
88957
  reading2 = readItems(root, n);
88634
88958
  } catch (error2) {
88635
- throw refusal28(`the item ledger could not be read: ${messageOf(error2)}. Nothing was run.`);
88959
+ throw refusal30(`the item ledger could not be read: ${messageOf(error2)}. Nothing was run.`);
88636
88960
  }
88637
88961
  for (const line of malformedItemLines(root, n, reading2.malformed))
88638
88962
  context.output.warn(line);
@@ -88644,7 +88968,7 @@ function putBack(context, input, merged2) {
88644
88968
  info3(`#${String(merged2.number)} from ${branch} merged at ${merged2.mergedAt}`);
88645
88969
  const { record: record2 } = input;
88646
88970
  if (record2 === null) {
88647
- throw refusal28(`no ${stretchRecordPath(input.root, input.n)} records the ${PR_BASE_KEY} to put back, as when the branch` + ` and ${PR_BASE_KEY} were made by hand. Set it yourself: rafa config set ${PR_BASE_KEY}=<branch>. Nothing was set.`);
88971
+ throw refusal30(`no ${stretchRecordPath(input.root, input.n)} records the ${PR_BASE_KEY} to put back, as when the branch` + ` and ${PR_BASE_KEY} were made by hand. Set it yourself: rafa config set ${PR_BASE_KEY}=<branch>. Nothing was set.`);
88648
88972
  }
88649
88973
  const value = record2.prBase ?? record2.defaultBranch;
88650
88974
  if (record2.prBase === null) {
@@ -88653,10 +88977,10 @@ function putBack(context, input, merged2) {
88653
88977
  const path9 = configFilePath(input.root);
88654
88978
  let edit;
88655
88979
  try {
88656
- edit = withConfigSetting(readFileSync111(path9, "utf8"), PR_BASE_KEY, value, path9);
88980
+ edit = withConfigSetting(readFileSync112(path9, "utf8"), PR_BASE_KEY, value, path9);
88657
88981
  } catch (error2) {
88658
88982
  const why = error2 instanceof ConfigSetRefusal ? `${PR_BASE_KEY} cannot be set: ${error2.message}` : `${path9} could not be read: ${messageOf(error2)}`;
88659
- throw refusal28(`${why}. Nothing was set.`);
88983
+ throw refusal30(`${why}. Nothing was set.`);
88660
88984
  }
88661
88985
  if (!edit.changed) {
88662
88986
  info3(`${path9} already reads ${PR_BASE_KEY}: ${value}`);
@@ -88670,7 +88994,7 @@ function putBack(context, input, merged2) {
88670
88994
  try {
88671
88995
  writeFileSync44(path9, edit.text, "utf8");
88672
88996
  } catch (error2) {
88673
- throw failure10(`${path9} could not be written: ${messageOf(error2)}. ${PR_BASE_KEY} still reads ${branch}.`);
88997
+ throw failure12(`${path9} could not be written: ${messageOf(error2)}. ${PR_BASE_KEY} still reads ${branch}.`);
88674
88998
  }
88675
88999
  info3(`${PR_BASE_KEY}: ${branch} \u2192 ${value}; stretch ${String(input.n)} is ended`);
88676
89000
  }
@@ -88693,7 +89017,7 @@ async function openEnd(context, input, body, seams) {
88693
89017
  mkdirSync40(dirname54(path9), { recursive: true });
88694
89018
  writeFileSync44(path9, body, "utf8");
88695
89019
  } catch (error2) {
88696
- throw failure10(`${path9} could not be written: ${messageOf(error2)}. No pull request was opened.`);
89020
+ throw failure12(`${path9} could not be written: ${messageOf(error2)}. No pull request was opened.`);
88697
89021
  }
88698
89022
  const result2 = await openPull2({ ...context, args: [], flags }, seams.pr);
88699
89023
  const warning = baseWarning(result2);
@@ -88704,12 +89028,12 @@ async function openEnd(context, input, body, seams) {
88704
89028
  }
88705
89029
  async function runStretchEnd(context, seams) {
88706
89030
  const line = readEndLine(context);
88707
- const project = requireProject(context, COMMAND_NAME27);
89031
+ const project = requireProject(context, COMMAND_NAME30);
88708
89032
  const { root } = project;
88709
- const config = await resolveProjectConfig(project, COMMAND_NAME27, (text2) => context.output.warn(text2));
89033
+ const config = await resolveProjectConfig(project, COMMAND_NAME30, (text2) => context.output.warn(text2));
88710
89034
  const n = requireStretchBase2(config.prBase);
88711
89035
  const report4 = readReport2(root, n);
88712
- const closes2 = closesLines(ledgerItems(context, root, n));
89036
+ const closes2 = closesLines(ledgerItems2(context, root, n));
88713
89037
  const record2 = readStretchRecord(root, n);
88714
89038
  const defaultBranch = record2?.defaultBranch ?? readRemoteHead(seams.git(root)) ?? DEFAULT_BASE_BRANCH;
88715
89039
  context.output.info(`stretch end: stretch ${String(n)} (${stretchBranch(n)} into ${defaultBranch}), ${String(closes2.length)}` + ` Closes line(s) from the ledger${line.dryRun ? ", dry run: each step is printed and none is run" : ""}`);
@@ -89097,9 +89421,9 @@ async function runUpdateCurrent(context, seams) {
89097
89421
  }
89098
89422
  const applied = await applyAndReport(plan2, access.gh, context);
89099
89423
  finish2(applied);
89100
- const refusal29 = refusedLabels(applied);
89101
- if (refusal29 !== null)
89102
- throw refusal29;
89424
+ const refusal31 = refusedLabels(applied);
89425
+ if (refusal31 !== null)
89426
+ throw refusal31;
89103
89427
  }
89104
89428
  function createUpdateCurrentCommand(seams = DEFAULT_UPDATE_CURRENT_SEAMS) {
89105
89429
  const command99 = {
@@ -89361,7 +89685,7 @@ function noticeLine(previous, current) {
89361
89685
 
89362
89686
  // src/status/seen.ts
89363
89687
  init_rafa_pr();
89364
- import { mkdirSync as mkdirSync41, readFileSync as readFileSync112, renameSync as renameSync15, writeFileSync as writeFileSync45 } from "fs";
89688
+ import { mkdirSync as mkdirSync41, readFileSync as readFileSync113, renameSync as renameSync15, writeFileSync as writeFileSync45 } from "fs";
89365
89689
  import { dirname as dirname55, join as join136 } from "path";
89366
89690
  init_sections();
89367
89691
  init_loop();
@@ -89425,7 +89749,7 @@ function asSnapshot(value) {
89425
89749
  function readSeenFile(root) {
89426
89750
  let text2;
89427
89751
  try {
89428
- text2 = readFileSync112(seenFilePath(root), "utf8");
89752
+ text2 = readFileSync113(seenFilePath(root), "utf8");
89429
89753
  } catch {
89430
89754
  return null;
89431
89755
  }