@open-tomato/rafa 0.48.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.48.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,23 +45395,55 @@ 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
  }
45365
- function cleanUpSteps(plan) {
45366
- const { base: base2, branch, remote = DEFAULT_REMOTE2, localBranchPresent, remoteBranchPresent } = plan;
45367
- const steps = [
45368
- { id: "switch-base", label: `switch to ${base2}`, argv: ["git", "switch", base2] },
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
+ }
45404
+ function baseSteps(base2, heldAt) {
45405
+ if (heldAt === null) {
45406
+ return [
45407
+ { id: "switch-base", label: `switch to ${base2}`, argv: ["git", "switch", base2] },
45408
+ {
45409
+ id: "pull-base",
45410
+ label: `pull ${base2}, fast-forward only`,
45411
+ argv: ["git", "pull", "--ff-only"],
45412
+ retry: pullRetry(["git"], base2)
45413
+ }
45414
+ ];
45415
+ }
45416
+ const git = ["git", "-C", heldAt];
45417
+ return [
45369
45418
  {
45370
45419
  id: "pull-base",
45371
- label: `pull ${base2}, fast-forward only`,
45372
- argv: ["git", "pull", "--ff-only"]
45420
+ label: `pull ${base2} in ${heldAt}, fast-forward only`,
45421
+ argv: [...git, "pull", "--ff-only"],
45422
+ retry: pullRetry(git, base2)
45373
45423
  },
45374
- {
45424
+ { id: "switch-base", label: `detach this checkout at ${base2}`, argv: ["git", "switch", "--detach", base2] }
45425
+ ];
45426
+ }
45427
+ function cleanUpSteps(plan) {
45428
+ const {
45429
+ base: base2,
45430
+ branch,
45431
+ remote = DEFAULT_REMOTE2,
45432
+ localBranchPresent,
45433
+ remoteBranchPresent,
45434
+ kept = false,
45435
+ baseHeldAt = null
45436
+ } = plan;
45437
+ const steps = baseSteps(base2, baseHeldAt);
45438
+ if (!kept) {
45439
+ steps.push({
45375
45440
  id: "delete-local",
45376
45441
  label: `delete the local branch ${branch}`,
45377
45442
  argv: ["git", "branch", "-D", branch],
45378
45443
  ...localBranchPresent ? {} : { skip: `no local branch ${branch}; nothing to delete` }
45379
- }
45380
- ];
45381
- if (remoteBranchPresent) {
45444
+ });
45445
+ }
45446
+ if (!kept && remoteBranchPresent) {
45382
45447
  steps.push({
45383
45448
  id: "delete-remote",
45384
45449
  label: `delete ${remote}/${branch}`,
@@ -45402,7 +45467,7 @@ function remainingFrom(steps, failed5) {
45402
45467
  const at = steps.findIndex((step) => step.id === failed5);
45403
45468
  return at === -1 ? Object.freeze([]) : Object.freeze(steps.slice(at).filter((step) => step.skip === undefined));
45404
45469
  }
45405
- 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";
45406
45471
  var init_merge2 = __esm(() => {
45407
45472
  init_git2();
45408
45473
  init_shell();
@@ -45876,7 +45941,7 @@ var init_declarations5 = __esm(() => {
45876
45941
  subject: PR_SUBJECT.name,
45877
45942
  action: "merge",
45878
45943
  summary: "merge a pull request and clean up both branches",
45879
- description: "Merges one pull request through the GitHub CLI and then, in code, switches to the base branch," + " pulls it fast-forward only, deletes the head branch locally and on the remote where it is still there," + " and prunes, reporting each step; a head branch this checkout has no local branch for is reported as a" + " skipped local delete, and the rest still run. Refuses before it asks anything on a tracked change in the working tree or an" + " untracked path the pull request's head or the base's remote-tracking branch holds, on a pull" + " request that is not green or does not merge, and on a head branch checked out in another worktree, except a" + " clean, ended loop worktree under `loop.worktreeDir`, which it removes after copying its two plan files out. It" + " shows the pull request, its branches and the method and asks `Merge? [y/N]`; `--yes` skips the question," + " and without a terminal and without `--yes` it refuses. A pull request that reports no checks at all is" + " refused unless `--skip-checks` is given, which is refused on any pull request that does report checks;" + " with it the command reads how many workflows the repository defines, prints a warning for that case, asks" + " `Merge #<n> with no checks? [y/N]` (which `--yes` answers only where the repository defines no workflow, or" + " where no workflow file on the base has a `pull_request` trigger naming it)," + " and after the merge posts one comment on the pull request saying so. Where the release runs, the release" + " guard reads the branch before the question: a `collision` is refused unless" + " `dangerous.acceptVersionCollision` is true, and `pr.versionCollision` sets whether a `missing` or" + " `stale` branch merges silently, with a warning, after its own question, or not at all. A step that fails never undoes the merge: it" + " prints what is left as commands to paste and exits 1. After the merge it ticks the `Closes #<n>` line of" + " every issue the pull request closes, first on the checklist of the open epic that issue's `epic:` label" + " names, printing one line per epic, then on every open board whose checklist lists it, or on the roadmap" + " issue while no issue carries `type:roadmap`, warning rather than failing when one of those writes" + ' does not land. It ends by reading every open issue whose "Blocked by:" line names an issue this pull' + " request closes, asking whether to remove `spec:blocked` from each one whose blockers have all closed;" + " `--yes` does not answer that question, and every failure of that reading is a warning. With" + " board.relationships set to native it ticks no epic checklist and, in place of that reading, prints the" + " open issues the merge freed, whose blockers GitHub clears by itself, asking nothing and writing nothing. With" + " `--output=json` the pull request, the method, the steps that ran, the follow-ups, the roadmap tick and" + " the unblock reading, or the freed issues in native mode, are the data of the terminal result event;" + " the tick of each closed issue's epic checklist is one line per epic and no key of that data, and under" + " native there is none. Refuses with exit code 2 where" + " `pr.provider` is not `gh`.",
45944
+ description: "Merges one pull request through the GitHub CLI and then, in code, switches to the base branch," + " pulls it fast-forward only, deletes the head branch locally and on the remote where it is still there," + " and prunes, reporting each step; a head branch this checkout has no local branch for is reported as a" + " skipped local delete, and the rest still run. A head branch that is a trunk (`pr.base`, the remote's default" + " branch, `main` where `pr.base` names none, or a branch `cleanup.keep` names) is kept on both sides, with one" + " line saying so, and `--keep-branch` keeps any other head branch the same way. Refuses before it asks anything on a tracked change in the working tree or an" + " untracked path the pull request's head or the base's remote-tracking branch holds, on a pull" + " request that is not green or does not merge, and on a head branch checked out in another worktree, except a" + " clean, ended loop worktree under `loop.worktreeDir`, which it removes after copying its two plan files out. It" + " shows the pull request, its branches and the method and asks `Merge? [y/N]`; `--yes` skips the question," + " and without a terminal and without `--yes` it refuses. A pull request that reports no checks at all is" + " refused unless `--skip-checks` is given, which is refused on any pull request that does report checks;" + " with it the command reads how many workflows the repository defines, prints a warning for that case, asks" + " `Merge #<n> with no checks? [y/N]` (which `--yes` answers only where the repository defines no workflow, or" + " where no workflow file on the base has a `pull_request` trigger naming it)," + " and after the merge posts one comment on the pull request saying so. Where the release runs, the release" + " guard reads the branch before the question: a `collision` is refused unless" + " `dangerous.acceptVersionCollision` is true, and `pr.versionCollision` sets whether a `missing` or" + " `stale` branch merges silently, with a warning, after its own question, or not at all. A step that fails never undoes the merge: it" + " prints what is left as commands to paste and exits 1. After the merge it ticks the `Closes #<n>` line of" + " every issue the pull request closes, first on the checklist of the open epic that issue's `epic:` label" + " names, printing one line per epic, then on every open board whose checklist lists it, or on the roadmap" + " issue while no issue carries `type:roadmap`, warning rather than failing when one of those writes" + ' does not land. It ends by reading every open issue whose "Blocked by:" line names an issue this pull' + " request closes, asking whether to remove `spec:blocked` from each one whose blockers have all closed;" + " `--yes` does not answer that question, and every failure of that reading is a warning. With" + " board.relationships set to native it ticks no epic checklist and, in place of that reading, prints the" + " open issues the merge freed, whose blockers GitHub clears by itself, asking nothing and writing nothing. With" + " `--output=json` the pull request, the method, the steps that ran, the follow-ups, the roadmap tick and" + " the unblock reading, or the freed issues in native mode, are the data of the terminal result event;" + " the tick of each closed issue's epic checklist is one line per epic and no key of that data, and under" + " native there is none. Refuses with exit code 2 where" + " `pr.provider` is not `gh`.",
45880
45945
  args: [
45881
45946
  {
45882
45947
  name: "n",
@@ -45895,6 +45960,11 @@ var init_declarations5 = __esm(() => {
45895
45960
  description: "Merge a pull request that reports no checks at all, after a warning and its own question." + " Refused where the pull request reports any check; `--yes` beside it is refused where the repository" + " defines a workflow that may run on pull requests into the base, or its workflow count could not be read.",
45896
45961
  type: "boolean"
45897
45962
  },
45963
+ {
45964
+ name: "keep-branch",
45965
+ description: "Keep the head branch locally and on the remote after the merge. A trunk is kept without it.",
45966
+ type: "boolean"
45967
+ },
45898
45968
  {
45899
45969
  name: "method",
45900
45970
  description: "How to merge: squash, merge or rebase. `pr.mergeMethod` when it is left out.",
@@ -45915,6 +45985,10 @@ var init_declarations5 = __esm(() => {
45915
45985
  cmd: "rafa pr merge 41 --skip-checks",
45916
45986
  note: "Warns that nothing on GitHub tested pull request 41, asks, merges it and comments that it had no checks."
45917
45987
  },
45988
+ {
45989
+ cmd: "rafa pr merge 41 --keep-branch",
45990
+ note: "Merges pull request 41 and keeps its head branch on both sides, deleting neither."
45991
+ },
45918
45992
  {
45919
45993
  cmd: "rafa pr merge 41 --method=rebase --output=json",
45920
45994
  note: "Merges by rebase and writes a result event holding each clean-up step and the follow-ups."
@@ -46667,6 +46741,7 @@ async function openPrContext(context, seams = DEFAULT_PR_SEAMS) {
46667
46741
  pulls: makeProvider(project.root),
46668
46742
  mergeMethod: config.prMergeMethod,
46669
46743
  base: config.prBase,
46744
+ cleanupKeep: config.cleanupKeep,
46670
46745
  resolveBudget: config.prResolveBudget,
46671
46746
  trustedAuthors: config.boardTrustedAuthors,
46672
46747
  roadmapIssue: config.roadmapIssue,
@@ -46731,7 +46806,7 @@ var init_pr_context = __esm(() => {
46731
46806
  show: "rafa pr show [<n>]",
46732
46807
  view: "rafa pr view [<n>]",
46733
46808
  list: "rafa pr list",
46734
- merge: "rafa pr merge [<n>] [--yes] [--skip-checks] [--method=squash|merge|rebase]",
46809
+ merge: "rafa pr merge [<n>] [--yes] [--skip-checks] [--keep-branch] [--method=squash|merge|rebase]",
46735
46810
  triage: "rafa pr triage [<n>] [--no-comment] [--resolve] [--allow-local-config] [--max-attempts=<count>]",
46736
46811
  wait: "rafa pr wait [<n>] [--timeout=<minutes>]",
46737
46812
  open: "rafa pr open --head=<branch> --base=<branch> --title=<text> --body-file=<path>",
@@ -50928,8 +51003,42 @@ function localHoldsBranch(git, branch, warn4) {
50928
51003
  warn4(`could not read whether this checkout holds a local branch ${branch}, so its delete runs: ${said}`);
50929
51004
  return true;
50930
51005
  }
50931
- function readyLine(base2, branch, present) {
50932
- const pulled = `${base2} is checked out and pulled`;
51006
+ function baseHeldElsewhere(git, base2, warn4) {
51007
+ const unread5 = (probe3) => {
51008
+ warn4(`could not read which worktree holds ${base2}, so it is switched to here: ${gitSaid(probe3)}`);
51009
+ return null;
51010
+ };
51011
+ const listed3 = git(["worktree", "list", "--porcelain"]);
51012
+ if (!listed3.ok)
51013
+ return unread5(listed3);
51014
+ const worktrees = parseWorktrees(listed3.stdout);
51015
+ if (!worktrees.some((entry) => entry.branch === base2))
51016
+ return null;
51017
+ const root = git(["rev-parse", "--show-toplevel"]);
51018
+ if (!root.ok)
51019
+ return unread5(root);
51020
+ return worktreesHolding(worktrees, base2, root.stdout.trim())[0]?.path ?? null;
51021
+ }
51022
+ function keptBecause(git, branch, settings) {
51023
+ if (settings.base !== null && branch === settings.base)
51024
+ return "it is pr.base";
51025
+ if (branch === readRemoteHead(git))
51026
+ return `it is ${REMOTE4}'s default branch`;
51027
+ if (settings.base === null && branch === DEFAULT_BASE_BRANCH) {
51028
+ return `it is ${DEFAULT_BASE_BRANCH}, the base where pr.base names none`;
51029
+ }
51030
+ if (isKept(branch, settings.keep))
51031
+ return "a cleanup.keep pattern names it";
51032
+ return settings.keepBranch ? "--keep-branch was given" : null;
51033
+ }
51034
+ function basePulled(base2, heldAt) {
51035
+ return heldAt === null ? `${base2} is checked out and pulled` : `${base2} is pulled in ${heldAt} and this checkout is detached at it`;
51036
+ }
51037
+ function keptLine2(base2, branch, why, heldAt = null) {
51038
+ return `${basePulled(base2, heldAt)}; ${branch} is kept locally and on ${REMOTE4}, since ${why}.`;
51039
+ }
51040
+ function readyLine(base2, branch, present, heldAt = null) {
51041
+ const pulled = basePulled(base2, heldAt);
50933
51042
  if (present.local) {
50934
51043
  return present.remote ? `${pulled}, and ${branch} is gone locally and on ${REMOTE4}.` : `${pulled}, and ${branch} is gone locally; ${REMOTE4} had already deleted it.`;
50935
51044
  }
@@ -50939,23 +51048,36 @@ function quotedLines2(said) {
50939
51048
  return said === "" ? [] : said.split(`
50940
51049
  `).map((line) => `${INDENT7}${line}`);
50941
51050
  }
50942
- function runCleanUp(git, merged, present, info2) {
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
+ }
51063
+ function runCleanUp(git, merged, present, info2, shape = {}) {
50943
51064
  const steps = cleanUpSteps({
50944
51065
  branch: merged.headRefName,
50945
51066
  base: merged.baseRefName,
50946
51067
  remote: REMOTE4,
50947
51068
  localBranchPresent: present.local,
50948
- remoteBranchPresent: present.remote
51069
+ remoteBranchPresent: present.remote,
51070
+ ...shape
50949
51071
  });
50950
51072
  const reports = [];
50951
51073
  for (const step2 of steps) {
50952
51074
  if (step2.skip !== undefined) {
50953
- 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 });
50954
51076
  info2(`${step2.label}: skipped \u2014 ${step2.skip}`);
50955
51077
  continue;
50956
51078
  }
50957
- const result2 = git(step2.argv.slice(1));
50958
- 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 });
50959
51081
  if (result2.ok) {
50960
51082
  info2(`${step2.label}: done`);
50961
51083
  continue;
@@ -50970,14 +51092,21 @@ function runCleanUp(git, merged, present, info2) {
50970
51092
  }
50971
51093
  return reports;
50972
51094
  }
50973
- function cleanUpAfterMerge(git, merged, report4) {
51095
+ function cleanUpAfterMerge(git, merged, settings, report4) {
51096
+ const kept = keptBecause(git, merged.headRefName, settings);
51097
+ const baseHeldAt = baseHeldElsewhere(git, merged.baseRefName, report4.warn);
51098
+ if (kept !== null) {
51099
+ const steps2 = runCleanUp(git, merged, { local: false, remote: false }, report4.info, { kept: true, baseHeldAt });
51100
+ report4.info(keptLine2(merged.baseRefName, merged.headRefName, kept, baseHeldAt));
51101
+ return { steps: steps2, kept };
51102
+ }
50974
51103
  const present = {
50975
51104
  remote: remoteHoldsBranch(git, merged.headRefName, report4.warn),
50976
51105
  local: localHoldsBranch(git, merged.headRefName, report4.warn)
50977
51106
  };
50978
- const steps = runCleanUp(git, merged, present, report4.info);
50979
- report4.info(readyLine(merged.baseRefName, merged.headRefName, present));
50980
- return steps;
51107
+ const steps = runCleanUp(git, merged, present, report4.info, { baseHeldAt });
51108
+ report4.info(readyLine(merged.baseRefName, merged.headRefName, present, baseHeldAt));
51109
+ return { steps, kept: null };
50981
51110
  }
50982
51111
  function textOf4(path3) {
50983
51112
  try {
@@ -51015,8 +51144,10 @@ function reportFollowUps(place2, git, info2) {
51015
51144
  var REMOTE4 = "origin", INDENT7 = " ";
51016
51145
  var init_merge_cleanup = __esm(() => {
51017
51146
  init_command2();
51147
+ init_sections();
51018
51148
  init_runtime();
51019
51149
  init_live_loops();
51150
+ init_branches();
51020
51151
  init_pr();
51021
51152
  init_settle_waiting();
51022
51153
  init_merge_followups();
@@ -51897,6 +52028,7 @@ async function askToMerge(context, pr, seams, ask) {
51897
52028
  async function runMerge(context, seams) {
51898
52029
  const yes = readBooleanFlag(context.flags, "yes", USAGE21);
51899
52030
  const skipChecks = readBooleanFlag(context.flags, "skip-checks", USAGE21);
52031
+ const keepBranch = readBooleanFlag(context.flags, "keep-branch", USAGE21);
51900
52032
  const wanted = readMethodFlag(context.flags, USAGE21);
51901
52033
  const asked = readPullArgument(context.args, USAGE21);
51902
52034
  const pr = await openPrContext(context, seams);
@@ -51945,6 +52077,7 @@ async function runMerge(context, seams) {
51945
52077
  declined: true,
51946
52078
  detail: "",
51947
52079
  steps: [],
52080
+ kept: null,
51948
52081
  followUps: [],
51949
52082
  roadmapTick: null,
51950
52083
  roadmapTicks: null,
@@ -51969,7 +52102,7 @@ async function runMerge(context, seams) {
51969
52102
  };
51970
52103
  const commentUrl = await commentIfUnchecked(pr.pulls, detail.number, answer4.unchecked, { info: info2, warn: warn4 });
51971
52104
  const roadmapTicks = await reportTick(context, pr, seams, detail);
51972
- const steps = cleanUpAfterMerge(git, detail, { info: info2, warn: warn4 });
52105
+ const { steps, kept } = cleanUpAfterMerge(git, detail, { base: pr.base, keep: pr.cleanupKeep, keepBranch }, { info: info2, warn: warn4 });
51973
52106
  const board = await reportAfterCleanUp(context, pr, seams, detail);
51974
52107
  await refreshProjectAfterMerge({
51975
52108
  body: detail.body,
@@ -51992,6 +52125,7 @@ async function runMerge(context, seams) {
51992
52125
  declined: false,
51993
52126
  detail: outcome2.detail,
51994
52127
  steps,
52128
+ kept,
51995
52129
  followUps,
51996
52130
  roadmapTick: roadmapTicks?.[0] ?? null,
51997
52131
  roadmapTicks,
@@ -53121,7 +53255,7 @@ function forcedPushRefusal(argv) {
53121
53255
  const words = forcing.map((word) => `\`${word}\``).join(", ");
53122
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.";
53123
53257
  }
53124
- function runStep3(git, step2) {
53258
+ function runStep4(git, step2) {
53125
53259
  const result2 = git(step2.argv.slice(1));
53126
53260
  return {
53127
53261
  id: step2.id,
@@ -53131,16 +53265,16 @@ function runStep3(git, step2) {
53131
53265
  };
53132
53266
  }
53133
53267
  function addResolveWorktree(git, path3, branch) {
53134
- return runStep3(git, addWorktreeStep(path3, branch));
53268
+ return runStep4(git, addWorktreeStep(path3, branch));
53135
53269
  }
53136
53270
  function removeResolveWorktree(git, path3) {
53137
- return runStep3(git, removeWorktreeStep(path3));
53271
+ return runStep4(git, removeWorktreeStep(path3));
53138
53272
  }
53139
53273
  function pushResolved(git, branch, remote = DEFAULT_REMOTE3) {
53140
53274
  const step2 = pushResolvedStep(branch, remote);
53141
53275
  const refusal13 = forcedPushRefusal(step2.argv);
53142
53276
  if (refusal13 === null)
53143
- return runStep3(git, step2);
53277
+ return runStep4(git, step2);
53144
53278
  return { id: step2.id, ok: false, command: worktreeCommandLine(step2), said: refusal13 };
53145
53279
  }
53146
53280
  function pathForms2(path3) {
@@ -60002,7 +60136,7 @@ function removeRun(files, step2) {
60002
60136
  }
60003
60137
  return { step: step2, ran: true, ok: true, command: command36, said: "" };
60004
60138
  }
60005
- function runStep4(git, files, step2, removed) {
60139
+ function runStep5(git, files, step2, removed) {
60006
60140
  const refusal16 = forcedFlagRefusal(step2.argv);
60007
60141
  if (refusal16 !== null)
60008
60142
  return notRun2(step2, refusal16);
@@ -60016,7 +60150,7 @@ function runStep4(git, files, step2, removed) {
60016
60150
  function runCleanupSteps(git, plan, files = DEFAULT_CLEANUP_FILES) {
60017
60151
  const removed = new Set;
60018
60152
  return plan.steps.map((step2) => {
60019
- const outcome2 = runStep4(git, files, step2, removed);
60153
+ const outcome2 = runStep5(git, files, step2, removed);
60020
60154
  if (outcome2.ok && step2.kind === "remove-worktree")
60021
60155
  removed.add(step2.subject);
60022
60156
  return outcome2;
@@ -66364,7 +66498,7 @@ function keepCommits(git, branch, template) {
66364
66498
  function thisDevice2(storeId) {
66365
66499
  return storeId === null ? "this device, whose store names no claimant" : `this device (store ${storeId})`;
66366
66500
  }
66367
- function keptLine2(lost) {
66501
+ function keptLine3(lost) {
66368
66502
  const { kept, branch } = lost;
66369
66503
  if (kept.state !== "failed")
66370
66504
  return `This device's commits are kept on the local branch ${kept.name} at ${kept.sha}.`;
@@ -66384,7 +66518,7 @@ function claimLostReport(lost) {
66384
66518
  return [
66385
66519
  `\u274C Claim lost: #${String(issue5)} is claimed by store ${owner} on ${branch}, not by ${thisDevice2(storeId)}.`,
66386
66520
  `${REMOTE} refused the push of ${branch}, and nothing was force-pushed over store ${owner}'s branch.`,
66387
- keptLine2(lost),
66521
+ keptLine3(lost),
66388
66522
  nextStep(lost)
66389
66523
  ].map((line, index) => index === 0 ? line : ` ${line}`).join(`
66390
66524
  `);
@@ -78852,8 +78986,8 @@ init_command2();
78852
78986
  init_sections();
78853
78987
  init_loop();
78854
78988
  init_plan();
78855
- import { closeSync as closeSync3, mkdirSync as mkdirSync34, openSync as openSync3, readdirSync as readdirSync28, readFileSync as readFileSync99, statSync as statSync33 } from "fs";
78856
- 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";
78857
78991
 
78858
78992
  // src/stretch/launch.ts
78859
78993
  init_shell();
@@ -79236,6 +79370,140 @@ function filedSinceLines(filed) {
79236
79370
  return [`Filed since ${since}: ${String(bugs.length)}.`, ...bugs.map(filedBugLine)];
79237
79371
  }
79238
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
+
79239
79507
  // src/commands/stretch/start.ts
79240
79508
  init_rafa_board();
79241
79509
  init_rafa_pr();
@@ -79323,15 +79591,15 @@ function squeezeBlankRuns(lines3) {
79323
79591
  }
79324
79592
 
79325
79593
  // src/commands/stretch/start.ts
79326
- var COMMAND_NAME14 = "rafa stretch start";
79594
+ var COMMAND_NAME16 = "rafa stretch start";
79327
79595
  var STRETCH_START_USAGE = "rafa stretch start [--n=<n>] [--remote-control] [--role=<role>] [--dry-run]";
79328
79596
  var REMOTE9 = "origin";
79329
79597
  var STRETCH_BRANCH_PREFIX = "stretch/";
79330
79598
  var STRETCH_RECORD_FILE = "stretch.json";
79331
79599
  var PR_BASE_KEY = "pr.base";
79332
79600
  var AGENT_WAIT_MS = 5000;
79333
- var REFUSED_EXIT3 = 1;
79334
- var FAILED_EXIT = 2;
79601
+ var REFUSED_EXIT4 = 1;
79602
+ var FAILED_EXIT3 = 2;
79335
79603
  var STRETCH_NUMBER = /^[1-9]\d*$/;
79336
79604
  function stretchBranch(n) {
79337
79605
  return `${STRETCH_BRANCH_PREFIX}${String(n)}`;
@@ -79339,8 +79607,8 @@ function stretchBranch(n) {
79339
79607
  function stretchRecordPath(root, n) {
79340
79608
  return join121(stretchFolder(root, n), STRETCH_RECORD_FILE);
79341
79609
  }
79342
- function refusal23(why) {
79343
- return new CommandExit(REFUSED_EXIT3, `\u274C ${COMMAND_NAME14}: ${why}`);
79610
+ function refusal24(why) {
79611
+ return new CommandExit(REFUSED_EXIT4, `\u274C ${COMMAND_NAME16}: ${why}`);
79344
79612
  }
79345
79613
  function readStartLine(context) {
79346
79614
  expectNoArgument(context.args, STRETCH_START_USAGE);
@@ -79380,7 +79648,7 @@ class Steps {
79380
79648
  const done = this.done.length === 0 ? "no step had run before it." : `already done:
79381
79649
  ${this.done.map((step2) => ` ${step2}`).join(`
79382
79650
  `)}`;
79383
- return new CommandExit(FAILED_EXIT, `\u274C ${COMMAND_NAME14}: ${line} failed: ${said}
79651
+ return new CommandExit(FAILED_EXIT3, `\u274C ${COMMAND_NAME16}: ${line} failed: ${said}
79384
79652
  ${done}`);
79385
79653
  }
79386
79654
  }
@@ -79395,7 +79663,7 @@ function refuseLiveStretch(root, seams) {
79395
79663
  ].filter((part) => part !== null);
79396
79664
  return ` stretch ${String(reading2.n)}: ${why.join(", ")}`;
79397
79665
  });
79398
- throw refusal23([
79666
+ throw refusal24([
79399
79667
  "a stretch of this project is live, and one runs at a time:",
79400
79668
  ...lines3,
79401
79669
  "Nothing was pushed, set or copied. End it first, or attach to its tmux session."
@@ -79407,13 +79675,13 @@ function refuseLiveLoop3(root, isAlive) {
79407
79675
  try {
79408
79676
  records = readSessions(root, { isAlive });
79409
79677
  } catch (error2) {
79410
- 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)}
79411
79679
  Nothing was pushed, set or copied.`);
79412
79680
  }
79413
79681
  const loops = records.filter((record2) => record2.state === "running" || record2.state === "paused");
79414
79682
  if (loops.length === 0)
79415
79683
  return;
79416
- throw refusal23([
79684
+ throw refusal24([
79417
79685
  `${String(loops.length)} loop(s) of this project run, and a stretch starts with none:`,
79418
79686
  ...loops.map((loop) => ` loop on ${loop.branch} (pid ${String(loop.pid)}, session ${loop.sessionId})`),
79419
79687
  "Nothing was pushed, set or copied. Wait for them to end, or stop them with rafa loop stop."
@@ -79423,7 +79691,7 @@ Nothing was pushed, set or copied.`);
79423
79691
  function requireProgram(context, seams, program) {
79424
79692
  if (seams.which(program, context.env["PATH"]) !== null)
79425
79693
  return;
79426
- 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.`);
79427
79695
  }
79428
79696
  function prBaseEdit(root, n) {
79429
79697
  const path6 = configFilePath(root);
@@ -79431,13 +79699,13 @@ function prBaseEdit(root, n) {
79431
79699
  try {
79432
79700
  text2 = readFileSync97(path6, "utf8");
79433
79701
  } catch (error2) {
79434
- 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.`);
79435
79703
  }
79436
79704
  try {
79437
79705
  return { path: path6, edit: withConfigSetting(text2, PR_BASE_KEY, stretchBranch(n), path6) };
79438
79706
  } catch (error2) {
79439
79707
  if (error2 instanceof ConfigSetRefusal) {
79440
- 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.`);
79441
79709
  }
79442
79710
  throw error2;
79443
79711
  }
@@ -79448,7 +79716,7 @@ function remoteHolds(git, branch) {
79448
79716
  return true;
79449
79717
  if (result2.stdout.trim() === "" && result2.stderr.trim() === "")
79450
79718
  return false;
79451
- 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)}
79452
79720
  Nothing was pushed, set or copied.`);
79453
79721
  }
79454
79722
  function gitStep(steps, git, args) {
@@ -79495,7 +79763,7 @@ function setPrBase(steps, root, n, defaultBranch, now, info2) {
79495
79763
  function copyStep2(steps, root, n, seams, info2) {
79496
79764
  const found = findOperators(seams);
79497
79765
  if (found.kind === "missing")
79498
- throw refusal23(missingOperatorsLine(found));
79766
+ throw refusal24(missingOperatorsLine(found));
79499
79767
  const copy2 = operatorsCopyPath(root, n);
79500
79768
  if (seams.fs.exists(copy2)) {
79501
79769
  info2(`keep ${copy2}, copied by an earlier start`);
@@ -79554,7 +79822,7 @@ async function openStretch(context, root, line, seams) {
79554
79822
  refuseLiveLoop3(root, seams.folder.isAlive);
79555
79823
  const found = findOperators(seams.operators);
79556
79824
  if (found.kind === "missing")
79557
- throw refusal23(missingOperatorsLine(found));
79825
+ throw refusal24(missingOperatorsLine(found));
79558
79826
  if (!line.dryRun)
79559
79827
  requireProgram(context, seams, "claude");
79560
79828
  prBaseEdit(root, n);
@@ -79580,7 +79848,7 @@ function roleStretch(root, line, role, seams) {
79580
79848
  const n = newestWatched(root, seams.folder.fs);
79581
79849
  if (n > 0)
79582
79850
  return n;
79583
- 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>");
79584
79852
  }
79585
79853
  async function waitForAgent(context, root, n, seams) {
79586
79854
  const file = agentFilePath(root, n);
@@ -79589,7 +79857,7 @@ async function waitForAgent(context, root, n, seams) {
79589
79857
  context.output.info(`waiting for ${file} \u2026`);
79590
79858
  while (seams.folder.fs.readText(file) === null) {
79591
79859
  if (context.signal.aborted)
79592
- throw refusal23(`stopped waiting for ${file}`);
79860
+ throw refusal24(`stopped waiting for ${file}`);
79593
79861
  await seams.sleep(AGENT_WAIT_MS);
79594
79862
  }
79595
79863
  }
@@ -79598,7 +79866,7 @@ function rolePrompt(context, root, role, n, seams) {
79598
79866
  return besideEngineerPrompt(role, n);
79599
79867
  const prompt = engineerPrompt(root, n, seams.prompt);
79600
79868
  if (prompt.kind === "missing")
79601
- throw refusal23(`the engineer's prompt ${prompt.reason}`);
79869
+ throw refusal24(`the engineer's prompt ${prompt.reason}`);
79602
79870
  context.output.info(`prompt: ${prompt.path}`);
79603
79871
  return prompt.text;
79604
79872
  }
@@ -79628,13 +79896,13 @@ async function runRole(context, root, line, seams, copied = false) {
79628
79896
  info2(`starting the ${role} of stretch ${String(n)}: ${argv.slice(0, 7).join(" ")} \u2026`);
79629
79897
  const exitCode = await seams.runSession(argv, root);
79630
79898
  if (exitCode === null)
79631
- 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`);
79632
79900
  if (exitCode !== 0)
79633
- 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)}`);
79634
79902
  }
79635
79903
  async function runStretchStart(context, seams) {
79636
79904
  const line = readStartLine(context);
79637
- const root = requireProject(context, COMMAND_NAME14).root;
79905
+ const root = requireProject(context, COMMAND_NAME16).root;
79638
79906
  if (line.role !== null) {
79639
79907
  await runRole(context, root, line, seams);
79640
79908
  return;
@@ -79715,24 +79983,24 @@ var command56 = createStretchStartCommand();
79715
79983
  var start_default = command56;
79716
79984
 
79717
79985
  // src/commands/stretch/item-merge.ts
79718
- var COMMAND_NAME15 = "rafa stretch item";
79986
+ var COMMAND_NAME17 = "rafa stretch item";
79719
79987
  var CI_POLL_MS = 30000;
79720
79988
  var CI_WAIT_MS = 90 * 60000;
79721
79989
  var CI_READ_TRIES = 3;
79722
- var MERGE_FLAGS = Object.freeze(["--skip-checks", "--yes"]);
79723
- 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;
79724
79993
  var ENDING_EVENTS = ["pr", "no-pr", "halt", "error"];
79725
- var REFUSED_EXIT4 = 1;
79726
- var FAILED_EXIT2 = 2;
79994
+ var REFUSED_EXIT5 = 1;
79995
+ var FAILED_EXIT4 = 2;
79727
79996
  var SHORT_SHA4 = 7;
79728
- var SHA = /^[0-9a-f]{40}$/;
79729
79997
  var MERGE_COMMIT_PLACEHOLDER = "<merge-commit>";
79730
79998
  var STAND_IN_SHA = "0".repeat(40);
79731
- function refusal24(why) {
79732
- return new CommandExit(REFUSED_EXIT4, `\u274C ${COMMAND_NAME15}: ${why}`);
79999
+ function refusal25(why) {
80000
+ return new CommandExit(REFUSED_EXIT5, `\u274C ${COMMAND_NAME17}: ${why}`);
79733
80001
  }
79734
- function failure8(why) {
79735
- return new CommandExit(FAILED_EXIT2, `\u274C ${COMMAND_NAME15}: ${why}`);
80002
+ function failure9(why) {
80003
+ return new CommandExit(FAILED_EXIT4, `\u274C ${COMMAND_NAME17}: ${why}`);
79736
80004
  }
79737
80005
  function short3(sha) {
79738
80006
  return sha.slice(0, SHORT_SHA4);
@@ -79766,57 +80034,12 @@ function noPullRequestLine(issue5, ending) {
79766
80034
  const how = ending.kind === "none" ? "ended without a pull request" : `ended on ${ending.kind}`;
79767
80035
  return `the loop of #${String(issue5)} ${how}: ${ending.reason}`;
79768
80036
  }
79769
- function prViewArgs(number) {
79770
- return ["pr", "view", String(number), "--json", PR_VIEW_FIELDS.join(",")];
79771
- }
79772
- function textField2(row2, field5, command57) {
79773
- const value = row2[field5];
79774
- if (typeof value !== "string")
79775
- throw failure8(`${command57} answered ${field5} ${describeValue(value)}, expected a string`);
79776
- return value;
79777
- }
79778
- function mergeCommitOf(value, command57) {
79779
- if (value === null || value === undefined)
79780
- return null;
79781
- const oid = isMapping(value) ? value["oid"] : undefined;
79782
- if (typeof oid !== "string" || !SHA.test(oid)) {
79783
- throw failure8(`${command57} answered mergeCommit ${describeValue(value)}, expected null or an object holding a 40-character oid`);
79784
- }
79785
- return oid;
79786
- }
79787
- async function viewPull(gh, number) {
79788
- const args = prViewArgs(number);
79789
- const command57 = `gh ${args.join(" ")}`;
79790
- const result2 = await gh(args);
79791
- if (!result2.ok) {
79792
- const said = result2.stderr.trim() || result2.stdout.trim() || "it exited non-zero and wrote nothing";
79793
- throw failure8(`${command57} failed: ${said}`);
79794
- }
79795
- let row2;
79796
- try {
79797
- row2 = JSON.parse(result2.stdout);
79798
- } catch (error2) {
79799
- throw failure8(`${command57} wrote output that is not JSON: ${messageOf(error2)}`);
79800
- }
79801
- if (!isMapping(row2))
79802
- throw failure8(`${command57} answered ${describeValue(row2)}, expected an object`);
79803
- if (row2["number"] !== number)
79804
- throw failure8(`${command57} answered number ${describeValue(row2["number"])}`);
79805
- return {
79806
- number,
79807
- state: textField2(row2, "state", command57),
79808
- base: textField2(row2, "baseRefName", command57),
79809
- head: textField2(row2, "headRefName", command57),
79810
- body: textField2(row2, "body", command57),
79811
- mergeCommit: mergeCommitOf(row2["mergeCommit"], command57)
79812
- };
79813
- }
79814
80037
  function refuseUnmergeable2(pull) {
79815
80038
  if (!pull.base.startsWith(STRETCH_BRANCH_PREFIX) || pull.base === STRETCH_BRANCH_PREFIX) {
79816
- 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.");
79817
80040
  }
79818
80041
  if (pull.state !== "OPEN") {
79819
- 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.`);
79820
80043
  }
79821
80044
  }
79822
80045
  function mergeArgv(rafa, number) {
@@ -79826,6 +80049,8 @@ function mergeDryRunLines(rafa, root, n) {
79826
80049
  const base2 = `${STRETCH_BRANCH_PREFIX}${String(n)}`;
79827
80050
  const runList5 = lineText(["gh", ...runListArgs({ branch: base2, commit: STAND_IN_SHA })]).replace(STAND_IN_SHA, MERGE_COMMIT_PLACEHOLDER);
79828
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)`,
79829
80054
  `${lineText([...rafa, "pr", "merge"])} <pr> ${lineText(MERGE_FLAGS)}`,
79830
80055
  `${runList5} (again every ${String(CI_POLL_MS / 1000)}s until the run on the merge commit ends)`,
79831
80056
  `append the item to ${itemsPath(root, n)}`,
@@ -79887,38 +80112,66 @@ async function mergeStep(context, item, number, seams) {
79887
80112
  context.output.info(lineText(argv));
79888
80113
  const exitCode = await seams.runRafa(argv, item.root, item.env);
79889
80114
  if (exitCode === null)
79890
- 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
+ }
79891
80146
  if (exitCode !== 0) {
79892
- 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.");
79893
80148
  }
80149
+ context.output.info(`merged #${String(number)} into ${pull.base} at ${short3(pull.mergeCommit)}`);
80150
+ return pull;
79894
80151
  }
79895
- async function mergeItem(context, item, number, seams) {
80152
+ async function finishItem(context, item, merged2, seams) {
79896
80153
  const info2 = (text2) => context.output.info(text2);
79897
80154
  const gh = seams.gh(item.root);
79898
- const pull = await viewPull(gh, number);
79899
- refuseUnmergeable2(pull);
79900
- const since = bugCutOff(item);
79901
- await mergeStep(context, item, number, seams);
79902
- const merged2 = await viewPull(gh, number);
79903
- if (merged2.state !== "MERGED" || merged2.mergeCommit === null) {
79904
- throw failure8(`rafa pr merge ended 0, and #${String(number)} reads ${merged2.state} with no merge commit.`);
79905
- }
79906
- info2(`merged #${String(number)} into ${merged2.base} at ${short3(merged2.mergeCommit)}`);
79907
80155
  await awaitRun(context, { gh, branch: merged2.base, commit: merged2.mergeCommit }, seams);
79908
80156
  const closes2 = [...new Set(closedIssuesIn(merged2.body))].map((issue5) => `Closes #${String(issue5)}`);
79909
80157
  appendItem2(item.root, item.n, {
79910
80158
  issue: String(item.issue),
79911
80159
  plan: item.stub,
79912
- pullRequest: number,
80160
+ pullRequest: merged2.number,
79913
80161
  mergeCommit: merged2.mergeCommit,
79914
80162
  closes: closes2,
79915
80163
  at: seams.now().toISOString()
79916
80164
  });
79917
80165
  info2(`ledger: #${String(item.issue)} appended to ${itemsPath(item.root, item.n)}${closes2.length === 0 ? ", closing no issue" : `, ${closes2.join(", ")}`}`);
79918
- 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 });
79919
80167
  for (const line of renderPitReadings(readings))
79920
80168
  info2(line);
79921
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
+ }
79922
80175
  async function afterLoopWait(context, item, waitExit, seams) {
79923
80176
  const ending = readLoopEnding(item.root, item.sessionId);
79924
80177
  if (waitExit === 0 && ending.kind === "pr") {
@@ -79928,20 +80181,126 @@ async function afterLoopWait(context, item, waitExit, seams) {
79928
80181
  if (ending.kind !== "pr")
79929
80182
  context.output.info(noPullRequestLine(item.issue, ending));
79930
80183
  context.output.info(`log: ${item.log}`);
79931
- const code = waitExit === 0 ? FAILED_EXIT2 : waitExit;
79932
- 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);
79933
80292
  }
79934
80293
 
79935
80294
  // src/commands/stretch/item.ts
79936
- var COMMAND_NAME16 = "rafa stretch item";
79937
- 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]";
79938
80297
  var LOOP_FLAGS = Object.freeze(["--as-worktree", "--no-ci-wait"]);
79939
80298
  var LOOP_OUTPUT = "events";
79940
80299
  var RECORD_POLL_MS = 2000;
79941
80300
  var RECORD_WAIT_MS = 5 * 60000;
79942
80301
  var LOG_TAIL_LINES = 20;
79943
- var REFUSED_EXIT5 = 1;
79944
- var FAILED_EXIT3 = 2;
80302
+ var REFUSED_EXIT7 = 1;
80303
+ var FAILED_EXIT6 = 2;
79945
80304
  var ISSUE_NUMBER18 = /^[1-9]\d*$/;
79946
80305
  var STRETCH_BASE = new RegExp(`^${STRETCH_BRANCH_PREFIX}([1-9]\\d*)$`);
79947
80306
  function itemLogPath(root, n, issue5) {
@@ -79951,31 +80310,37 @@ function stretchOfBase(prBase) {
79951
80310
  const word = prBase === null ? undefined : STRETCH_BASE.exec(prBase)?.[1];
79952
80311
  return word === undefined ? null : Number(word);
79953
80312
  }
79954
- function refusal25(why) {
79955
- return new CommandExit(REFUSED_EXIT5, `\u274C ${COMMAND_NAME16}: ${why}`);
80313
+ function refusal27(why) {
80314
+ return new CommandExit(REFUSED_EXIT7, `\u274C ${COMMAND_NAME19}: ${why}`);
79956
80315
  }
79957
- function failure9(why) {
79958
- return new CommandExit(FAILED_EXIT3, `\u274C ${COMMAND_NAME16}: ${why}`);
80316
+ function failure11(why) {
80317
+ return new CommandExit(FAILED_EXIT6, `\u274C ${COMMAND_NAME19}: ${why}`);
79959
80318
  }
79960
80319
  function readItemLine(context) {
79961
80320
  const word = expectOneArgument(context.args, STRETCH_ITEM_USAGE);
79962
80321
  if (!ISSUE_NUMBER18.test(word) || !Number.isSafeInteger(Number(word))) {
79963
- 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
79964
80323
  Usage: ${STRETCH_ITEM_USAGE}`);
79965
80324
  }
79966
80325
  const hint = `Usage: ${STRETCH_ITEM_USAGE}`;
79967
- return {
80326
+ const line = {
79968
80327
  issue: Number(word),
79969
80328
  wait: readSwitch2("wait", context.flags["wait"], hint),
80329
+ resume: readSwitch2("resume", context.flags["resume"], hint),
79970
80330
  dryRun: readSwitch2("dry-run", context.flags["dry-run"], hint)
79971
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;
79972
80337
  }
79973
80338
  function requireStretchBase(prBase) {
79974
80339
  const n = stretchOfBase(prBase);
79975
80340
  if (n !== null)
79976
80341
  return n;
79977
80342
  const found = prBase === null ? "not set, so pull requests open into the default branch" : `"${prBase}"`;
79978
- 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.`);
79979
80344
  }
79980
80345
  function issuePlans(plans, issue5) {
79981
80346
  const prefix = `${boardId(issue5)}-`;
@@ -79985,12 +80350,12 @@ function issuePlans(plans, issue5) {
79985
80350
  } catch {
79986
80351
  return [];
79987
80352
  }
79988
- 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));
79989
80354
  }
79990
80355
  function existingPlan(plans, issue5) {
79991
80356
  const found = issuePlans(plans, issue5);
79992
80357
  if (found.length > 1) {
79993
- throw refusal25([
80358
+ throw refusal27([
79994
80359
  `${plans.label} holds ${String(found.length)} plans of #${String(issue5)}, and an item runs one:`,
79995
80360
  ...found.map((plan) => ` ${plan}`),
79996
80361
  "Remove the ones not wanted. Nothing was run."
@@ -80003,7 +80368,7 @@ function sessionRecords(root, isAlive) {
80003
80368
  try {
80004
80369
  return readSessions(root, { isAlive });
80005
80370
  } catch (error2) {
80006
- throw failure9(`the session records could not be read: ${messageOf(error2)}`);
80371
+ throw failure11(`the session records could not be read: ${messageOf(error2)}`);
80007
80372
  }
80008
80373
  }
80009
80374
  function refuseRunningLoop(root, stub, isAlive) {
@@ -80011,7 +80376,7 @@ function refuseRunningLoop(root, stub, isAlive) {
80011
80376
  const [first] = running2;
80012
80377
  if (first === undefined)
80013
80378
  return;
80014
- 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.`);
80015
80380
  }
80016
80381
  function loopArgv(rafa, plan) {
80017
80382
  return [...rafa, "loop", "start", `--plan=${plan}`, ...LOOP_FLAGS];
@@ -80041,23 +80406,23 @@ async function planStep(context, root, plans, line, seams) {
80041
80406
  return null;
80042
80407
  const exitCode = await seams.runRafa(argv, root, childEnv(context));
80043
80408
  if (exitCode === null)
80044
- throw failure9(`${lineText(argv)} could not start. Nothing else was run.`);
80409
+ throw failure11(`${lineText(argv)} could not start. Nothing else was run.`);
80045
80410
  if (exitCode !== 0) {
80046
- 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.`);
80047
80412
  }
80048
80413
  const made = existingPlan(plans, line.issue);
80049
80414
  if (made === null) {
80050
- 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.`);
80051
80416
  }
80052
80417
  return made;
80053
80418
  }
80054
80419
  function sizeOf(path6) {
80055
- return statSync33(path6, { throwIfNoEntry: false })?.size ?? 0;
80420
+ return statSync34(path6, { throwIfNoEntry: false })?.size ?? 0;
80056
80421
  }
80057
80422
  function logTail(log, offset) {
80058
80423
  let text2;
80059
80424
  try {
80060
- text2 = readFileSync99(log).subarray(offset).toString("utf8");
80425
+ text2 = readFileSync100(log).subarray(offset).toString("utf8");
80061
80426
  } catch (error2) {
80062
80427
  return ` (the log could not be read: ${messageOf(error2)})`;
80063
80428
  }
@@ -80077,13 +80442,13 @@ async function awaitRecord(context, wait, seams) {
80077
80442
  return record2;
80078
80443
  const exitCode = wait.launched.exitCode();
80079
80444
  if (exitCode !== null) {
80080
- 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}:
80081
80446
  ${logTail(wait.log, wait.offset)}`);
80082
80447
  }
80083
80448
  if (!wait.patient && seams.now().getTime() - wait.since >= RECORD_WAIT_MS)
80084
80449
  return null;
80085
80450
  if (context.signal.aborted) {
80086
- 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}`);
80087
80452
  }
80088
80453
  await seams.sleep(RECORD_POLL_MS);
80089
80454
  }
@@ -80093,12 +80458,12 @@ function launchStep(context, root, plan, log, seams) {
80093
80458
  try {
80094
80459
  mkdirSync34(folder, { recursive: true });
80095
80460
  } catch (error2) {
80096
- 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.`);
80097
80462
  }
80098
80463
  const offset = sizeOf(log);
80099
80464
  const launched = seams.launch(loopArgv(seams.rafa, plan), root, childEnv(context, { RAFA_OUTPUT: LOOP_OUTPUT }), log);
80100
80465
  if (launched === null)
80101
- 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.`);
80102
80467
  return { launched, offset };
80103
80468
  }
80104
80469
  async function waitStep(context, wait, seams) {
@@ -80108,7 +80473,7 @@ async function waitStep(context, wait, seams) {
80108
80473
  const env = childEnv(context);
80109
80474
  const exitCode = await seams.runRafa(argv, root, env);
80110
80475
  if (exitCode === null)
80111
- throw failure9(`${lineText(argv)} could not start; the loop still runs.`);
80476
+ throw failure11(`${lineText(argv)} could not start; the loop still runs.`);
80112
80477
  await afterLoopWait(context, {
80113
80478
  root,
80114
80479
  n: wait.n,
@@ -80120,16 +80485,41 @@ async function waitStep(context, wait, seams) {
80120
80485
  env
80121
80486
  }, exitCode, seams);
80122
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
+ }
80123
80509
  async function runStretchItem(context, seams) {
80124
80510
  const line = readItemLine(context);
80125
- const project = requireProject(context, COMMAND_NAME16);
80511
+ const project = requireProject(context, COMMAND_NAME19);
80126
80512
  const { root } = project;
80127
80513
  const warn5 = (text2) => context.output.warn(text2);
80128
- const config = await resolveProjectConfig(project, COMMAND_NAME16, warn5);
80514
+ const config = await resolveProjectConfig(project, COMMAND_NAME19, warn5);
80129
80515
  const n = requireStretchBase(config.prBase);
80130
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
+ }
80131
80521
  const kept = existingPlan(plans, line.issue);
80132
- const keptStub = kept === null ? null : stubOfPlanFile(posix13.basename(kept));
80522
+ const keptStub = kept === null ? null : stubOfPlanFile(posix14.basename(kept));
80133
80523
  if (keptStub !== null)
80134
80524
  refuseRunningLoop(root, keptStub, seams.isAlive);
80135
80525
  const info2 = (text2) => context.output.info(text2);
@@ -80137,7 +80527,7 @@ async function runStretchItem(context, seams) {
80137
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" : ""}`);
80138
80528
  const log = itemLogPath(root, n, line.issue);
80139
80529
  const plan = await planStep(context, root, plans, line, seams);
80140
- 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`);
80141
80531
  info2(loopLineText(seams.rafa, plan, placeholder, log));
80142
80532
  if (plan === null || line.dryRun) {
80143
80533
  if (line.wait) {
@@ -80148,7 +80538,7 @@ async function runStretchItem(context, seams) {
80148
80538
  info2(`dry run: would start the loop of #${issue5} for ${STRETCH_BRANCH_PREFIX}${String(n)}; nothing was run`);
80149
80539
  return;
80150
80540
  }
80151
- const stub = stubOfPlanFile(posix13.basename(plan)) ?? "";
80541
+ const stub = stubOfPlanFile(posix14.basename(plan)) ?? "";
80152
80542
  if (keptStub === null)
80153
80543
  refuseRunningLoop(root, stub, seams.isAlive);
80154
80544
  const since = seams.now().getTime();
@@ -80209,21 +80599,27 @@ function createStretchItemCommand(seams) {
80209
80599
  subject: "stretch",
80210
80600
  action: "item",
80211
80601
  summary: "plan one issue of a stretch and start its loop, logging into the stretch folder",
80212
- 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.",
80213
80603
  args: [
80214
80604
  { name: "issue", description: "The number of the `type:spec` issue to plan and run.", type: "string", required: true }
80215
80605
  ],
80216
80606
  flags: [
80217
80607
  {
80218
80608
  name: "wait",
80219
- 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`.",
80220
80615
  type: "boolean"
80221
80616
  },
80222
80617
  { name: "dry-run", description: "Print every step in order, and run none of them.", type: "boolean" }
80223
80618
  ],
80224
80619
  examples: [
80225
80620
  { cmd: "rafa stretch item 812 --dry-run", note: "Prints the plan create line and the detached loop line." },
80226
- { 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." }
80227
80623
  ],
80228
80624
  outputs: ["text"],
80229
80625
  spends: { when: "unless", flag: "--dry-run", what: "one planning session and the loop it starts" },
@@ -80316,14 +80712,14 @@ init_rafa_board();
80316
80712
  init_rafa_effort();
80317
80713
  init_rafa_inventory();
80318
80714
  init_loop();
80319
- import { readFileSync as readFileSync100, realpathSync as realpathSync20 } from "fs";
80715
+ import { readFileSync as readFileSync101, realpathSync as realpathSync20 } from "fs";
80320
80716
  import { basename as basename29, dirname as dirname49 } from "path";
80321
80717
  var TIERS_SECTION_TITLE = "Skill tiers";
80322
80718
  var CLAUDE_VERSION_TIMEOUT_MS = 1e4;
80323
80719
  var VERSION_PATTERN = /^\s*(\d+\.\d+\.\d+)/;
80324
80720
  function readTextFile2(path6) {
80325
80721
  try {
80326
- return readFileSync100(path6, "utf8");
80722
+ return readFileSync101(path6, "utf8");
80327
80723
  } catch {
80328
80724
  return null;
80329
80725
  }
@@ -80410,10 +80806,14 @@ function cliVersionRows(installed, pinned = SERVE_CLI_VERSION) {
80410
80806
  }
80411
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')];
80412
80808
  }
80413
- function skillUseVersionRows(installed, pinned = SKILL_USE_CLI_VERSION) {
80414
- 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)
80415
80811
  return [];
80416
- 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`)];
80417
80817
  }
80418
80818
  function doctorTierRows(inventory, installed, readers = {}) {
80419
80819
  const readText13 = readers.readText ?? readTextFile2;
@@ -80459,7 +80859,7 @@ function renderDoctorTiers(reading2) {
80459
80859
  // src/commands/doctor.ts
80460
80860
  var DEFAULT_DOCTOR_SEAMS = Object.freeze({ checks: Object.freeze({}) });
80461
80861
  var NOTHING_CHECKED = "Nothing was checked.";
80462
- function refusal26(lines3) {
80862
+ function refusal28(lines3) {
80463
80863
  return new CommandExit(1, [...lines3, NOTHING_CHECKED].join(`
80464
80864
  `));
80465
80865
  }
@@ -80467,21 +80867,21 @@ function expectNoArgument2(args) {
80467
80867
  if (args.length === 0)
80468
80868
  return;
80469
80869
  const got = `${String(args.length)}: ${args.join(" ")}`;
80470
- 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>`]);
80471
80871
  }
80472
80872
  function readPlanFlag2(value) {
80473
80873
  if (value === undefined)
80474
80874
  return null;
80475
80875
  if (typeof value === "string" && value !== "")
80476
80876
  return value;
80477
- throw refusal26(["rafa doctor: --plan needs a file: --plan=<file>"]);
80877
+ throw refusal28(["rafa doctor: --plan needs a file: --plan=<file>"]);
80478
80878
  }
80479
80879
  function readDeepFlag(value) {
80480
80880
  if (value === undefined || value === false || value === "false")
80481
80881
  return false;
80482
80882
  if (value === true || value === "true")
80483
80883
  return true;
80484
- 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>`]);
80485
80885
  }
80486
80886
  async function resolvedConfig(project, warn5) {
80487
80887
  try {
@@ -80489,7 +80889,7 @@ async function resolvedConfig(project, warn5) {
80489
80889
  } catch (error2) {
80490
80890
  if (!(error2 instanceof ConfigError))
80491
80891
  throw error2;
80492
- 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}`)]);
80493
80893
  }
80494
80894
  }
80495
80895
  function defaultPlanPaths(root, planDir) {
@@ -80499,7 +80899,7 @@ function planFileAt(path6) {
80499
80899
  try {
80500
80900
  return isFile2(path6);
80501
80901
  } catch (error2) {
80502
- 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)})`]);
80503
80903
  }
80504
80904
  }
80505
80905
  function choosePlan(root, config, named8) {
@@ -80507,7 +80907,7 @@ function choosePlan(root, config, named8) {
80507
80907
  if (planFileAt(path6))
80508
80908
  return { plan: path6, lookedFor: [] };
80509
80909
  if (named8 !== null)
80510
- throw refusal26([`rafa doctor: no plan file at ${path6}`]);
80910
+ throw refusal28([`rafa doctor: no plan file at ${path6}`]);
80511
80911
  return { plan: null, lookedFor: defaultPlanPaths(root, config.planDir) };
80512
80912
  }
80513
80913
  async function loadItems2(plan, config) {
@@ -80516,7 +80916,7 @@ async function loadItems2(plan, config) {
80516
80916
  try {
80517
80917
  return await loadPlanPrerequisites(plan, config);
80518
80918
  } catch (error2) {
80519
- 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)}`]);
80520
80920
  }
80521
80921
  }
80522
80922
  function refuseMalformedItems2(plan, items2) {
@@ -80524,7 +80924,7 @@ function refuseMalformedItems2(plan, items2) {
80524
80924
  return;
80525
80925
  const file = basename30(prerequisitesPathForPlan(plan) ?? plan);
80526
80926
  const [head = "", ...rest] = malformedPrerequisiteLines(file, items2.malformed);
80527
- throw refusal26([
80927
+ throw refusal28([
80528
80928
  `rafa doctor: ${head}`,
80529
80929
  ...rest,
80530
80930
  "rafa loop start would refuse here, before any probe. No run was started and nothing was stored."
@@ -80682,9 +81082,9 @@ async function runDoctor(context, seams) {
80682
81082
  writeText(context, renderDoctorEffortSync(effortSync));
80683
81083
  const deep = await checkDeep(context, preflight, seams);
80684
81084
  writeText(context, deep === null ? [] : renderDeep(deep));
80685
- const refusal27 = doctorRefusal(preflight.report.halt, [effortSchemaRefusal(effortSchema), effortSyncRefusal(effortSync)]);
80686
- if (refusal27 !== null)
80687
- throw refusal27;
81085
+ const refusal29 = doctorRefusal(preflight.report.halt, [effortSchemaRefusal(effortSchema), effortSyncRefusal(effortSync)]);
81086
+ if (refusal29 !== null)
81087
+ throw refusal29;
80688
81088
  if (context.outputMode === "json")
80689
81089
  context.output.result(resultOf6(preflight, install, readings, deep));
80690
81090
  } finally {
@@ -80842,11 +81242,11 @@ init_copy();
80842
81242
  init_location();
80843
81243
  init_ndjson_files();
80844
81244
  import { join as join123, resolve as resolve44 } from "path";
80845
- var COMMAND_NAME17 = "rafa effort copy";
81245
+ var COMMAND_NAME20 = "rafa effort copy";
80846
81246
  var COPY_USAGE = "rafa effort copy [--to=<dir>]";
80847
81247
  var TO_FLAG2 = "to";
80848
- var REFUSED_EXIT6 = 1;
80849
- var FAILED_EXIT4 = 2;
81248
+ var REFUSED_EXIT8 = 1;
81249
+ var FAILED_EXIT7 = 2;
80850
81250
  var SCRATCH_DIR = join123(".rafa", "scratch");
80851
81251
  function effortDirLine(directory2) {
80852
81252
  return `${EFFORT_DIR_VARIABLE}=${directory2}`;
@@ -80856,7 +81256,7 @@ function readTarget(context, root) {
80856
81256
  if (value === undefined)
80857
81257
  return null;
80858
81258
  if (typeof value !== "string" || value === "") {
80859
- 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>
80860
81260
  Usage: ${COPY_USAGE}`);
80861
81261
  }
80862
81262
  return resolve44(root, value);
@@ -80865,7 +81265,7 @@ function refuseEffortDirOverride(context) {
80865
81265
  const value = context.env[EFFORT_DIR_VARIABLE];
80866
81266
  if (value === undefined || value === "")
80867
81267
  return;
80868
- 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}`);
80869
81269
  }
80870
81270
  function renderCopy(result2) {
80871
81271
  return [
@@ -80876,7 +81276,7 @@ function renderCopy(result2) {
80876
81276
  }
80877
81277
  function runCopy(context, seams) {
80878
81278
  expectNoArgument(context.args, COPY_USAGE);
80879
- const root = requireProject(context, COMMAND_NAME17).root;
81279
+ const root = requireProject(context, COMMAND_NAME20).root;
80880
81280
  const named8 = readTarget(context, root);
80881
81281
  refuseEffortDirOverride(context);
80882
81282
  const target = named8 ?? join123(root, SCRATCH_DIR, `effort-${fileStamp((seams.now ?? (() => new Date))())}`);
@@ -80885,9 +81285,9 @@ function runCopy(context, seams) {
80885
81285
  result2 = copyEffortStore({ source: join123(root, EFFORT_STORE_DIR), target });
80886
81286
  } catch (error2) {
80887
81287
  if (error2 instanceof EffortCopyRefusal)
80888
- throw new CommandExit(REFUSED_EXIT6, `\u274C ${COMMAND_NAME17}: ${error2.message}`);
81288
+ throw new CommandExit(REFUSED_EXIT8, `\u274C ${COMMAND_NAME20}: ${error2.message}`);
80889
81289
  if (error2 instanceof EffortCopyFailure)
80890
- throw new CommandExit(FAILED_EXIT4, `\u274C ${COMMAND_NAME17}: ${error2.message}`);
81290
+ throw new CommandExit(FAILED_EXIT7, `\u274C ${COMMAND_NAME20}: ${error2.message}`);
80891
81291
  throw error2;
80892
81292
  }
80893
81293
  if (context.outputMode === "json") {
@@ -80939,11 +81339,11 @@ init_plan_files2();
80939
81339
  init_command2();
80940
81340
  init_config2();
80941
81341
  import { homedir as homedir16 } from "os";
80942
- var COMMAND_NAME18 = "rafa effort dashboard";
81342
+ var COMMAND_NAME21 = "rafa effort dashboard";
80943
81343
  var USAGE33 = "rafa effort dashboard [--days=<n>] [--recent=<n>] [--loops=<n>] [--by=effort|model|agent]";
80944
81344
  var TREND_FLAGS = ["days", "recent", "loops", "by"];
80945
81345
  function refuse21(problems) {
80946
- 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(`
80947
81347
  `));
80948
81348
  }
80949
81349
  function trendOptionsOf(context) {
@@ -80960,7 +81360,7 @@ function trendOptionsOf(context) {
80960
81360
  }
80961
81361
  async function runDashboard(context, seams) {
80962
81362
  expectNoArgument(context.args, USAGE33);
80963
- const root = requireProject(context, COMMAND_NAME18).root;
81363
+ const root = requireProject(context, COMMAND_NAME21).root;
80964
81364
  const trend = trendOptionsOf(context);
80965
81365
  let dashboard;
80966
81366
  try {
@@ -81037,7 +81437,7 @@ init_command2();
81037
81437
  init_loop();
81038
81438
  init_fix_schema();
81039
81439
  init_sqlite();
81040
- var COMMAND_NAME19 = "rafa effort fix-schema";
81440
+ var COMMAND_NAME22 = "rafa effort fix-schema";
81041
81441
  var FIX_SCHEMA_USAGE = "rafa effort fix-schema [--dry-run]";
81042
81442
  var DRY_RUN_FLAG4 = "dry-run";
81043
81443
  function keepsIdLine(swapped) {
@@ -81048,12 +81448,12 @@ function refuseLiveLoop4(root, isAlive) {
81048
81448
  try {
81049
81449
  records = readSessions(root, isAlive === undefined ? {} : { isAlive });
81050
81450
  } catch (error2) {
81051
- 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)}`);
81052
81452
  }
81053
81453
  const live = records.find((record2) => record2.state === "running" || record2.state === "paused");
81054
81454
  if (live === undefined)
81055
81455
  return;
81056
- 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.`);
81057
81457
  }
81058
81458
  function migrationNames(result2) {
81059
81459
  return result2.unknown.map(({ id: id3, appliedBy }) => `${id3} (applied by ${appliedBy})`).join(", ");
@@ -81108,7 +81508,7 @@ function runFixSchema(context, seams) {
81108
81508
  expectNoArgument(context.args, FIX_SCHEMA_USAGE);
81109
81509
  const dryRun = readSwitch2(DRY_RUN_FLAG4, context.flags[DRY_RUN_FLAG4], `Usage: ${FIX_SCHEMA_USAGE}`);
81110
81510
  if (context.project === null)
81111
- 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`);
81112
81512
  const root = context.project.root;
81113
81513
  if (!dryRun)
81114
81514
  refuseLiveLoop4(root, seams.isAlive);
@@ -81124,7 +81524,7 @@ function runFixSchema(context, seams) {
81124
81524
  });
81125
81525
  } catch (error2) {
81126
81526
  if (error2 instanceof RebuildRefusal)
81127
- throw new CommandExit(1, `\u274C ${COMMAND_NAME19}: ${error2.message}`);
81527
+ throw new CommandExit(1, `\u274C ${COMMAND_NAME22}: ${error2.message}`);
81128
81528
  throw error2;
81129
81529
  }
81130
81530
  if (context.outputMode === "json") {
@@ -81187,10 +81587,10 @@ init_merge_union();
81187
81587
  init_rebuild_aside();
81188
81588
  init_sqlite();
81189
81589
  import { join as join124, resolve as resolve45 } from "path";
81190
- var COMMAND_NAME20 = "rafa effort merge";
81590
+ var COMMAND_NAME23 = "rafa effort merge";
81191
81591
  var MERGE_USAGE = "rafa effort merge <file> [--dry-run]";
81192
81592
  var DRY_RUN_FLAG5 = "dry-run";
81193
- var REFUSED_EXIT7 = 1;
81593
+ var REFUSED_EXIT9 = 1;
81194
81594
  var UNMERGEABLE_EXIT = 2;
81195
81595
  var UNMERGEABLE_REASONS = new Set(["other-project", "ndjson"]);
81196
81596
  function tableLine2(entry) {
@@ -81212,7 +81612,7 @@ function closingLine2(result2, command63) {
81212
81612
  }
81213
81613
  return `\u2705 Merged. Every row the original held is copied to ${String(result2.backupPath)}.` + ` ${keepsIdLine("merged store")}`;
81214
81614
  }
81215
- function renderMerge(result2, command63 = COMMAND_NAME20) {
81615
+ function renderMerge(result2, command63 = COMMAND_NAME23) {
81216
81616
  const other = result2.otherStore === null ? "a store that names no origin" : `store ${result2.otherStore}`;
81217
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.`];
81218
81618
  return [
@@ -81223,20 +81623,20 @@ function renderMerge(result2, command63 = COMMAND_NAME20) {
81223
81623
  closingLine2(result2, command63)
81224
81624
  ];
81225
81625
  }
81226
- function mergeTargetPath(context, root, command63 = COMMAND_NAME20) {
81626
+ function mergeTargetPath(context, root, command63 = COMMAND_NAME23) {
81227
81627
  try {
81228
81628
  return join124(effortStoreDir(root, context.env), SQLITE_STORE_FILE_NAME);
81229
81629
  } catch (error2) {
81230
- throw new CommandExit(REFUSED_EXIT7, `\u274C ${command63}: ${messageOf(error2)}`);
81630
+ throw new CommandExit(REFUSED_EXIT9, `\u274C ${command63}: ${messageOf(error2)}`);
81231
81631
  }
81232
81632
  }
81233
- function mergeRefusalExit(error2, command63 = COMMAND_NAME20) {
81633
+ function mergeRefusalExit(error2, command63 = COMMAND_NAME23) {
81234
81634
  if (error2 instanceof MergeRefusal) {
81235
- const code = UNMERGEABLE_REASONS.has(error2.reason) ? UNMERGEABLE_EXIT : REFUSED_EXIT7;
81635
+ const code = UNMERGEABLE_REASONS.has(error2.reason) ? UNMERGEABLE_EXIT : REFUSED_EXIT9;
81236
81636
  return new CommandExit(code, `\u274C ${command63}: ${error2.message}`);
81237
81637
  }
81238
81638
  const known = error2 instanceof RebuildRefusal || error2 instanceof DevelopmentBuildRefusedError || error2 instanceof UnionSchemaMismatch;
81239
- return known ? new CommandExit(REFUSED_EXIT7, `\u274C ${command63}: ${error2.message}`) : null;
81639
+ return known ? new CommandExit(REFUSED_EXIT9, `\u274C ${command63}: ${error2.message}`) : null;
81240
81640
  }
81241
81641
  function probeSeams(seams) {
81242
81642
  return {
@@ -81250,9 +81650,9 @@ function probeSeams(seams) {
81250
81650
  async function runMerge2(context, seams) {
81251
81651
  const file = expectOneArgument(context.args, MERGE_USAGE);
81252
81652
  const dryRun = readSwitch2(DRY_RUN_FLAG5, context.flags[DRY_RUN_FLAG5], `Usage: ${MERGE_USAGE}`);
81253
- const project = requireProject(context, COMMAND_NAME20);
81653
+ const project = requireProject(context, COMMAND_NAME23);
81254
81654
  const path6 = mergeTargetPath(context, project.root);
81255
- 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;
81256
81656
  const now = seams.now ?? (() => new Date);
81257
81657
  const otherPath = resolve45((seams.cwd ?? (() => process.cwd()))(), file);
81258
81658
  let result2;
@@ -81312,7 +81712,7 @@ var command63 = createMergeCommand();
81312
81712
  var merge_default2 = command63;
81313
81713
 
81314
81714
  // src/commands/effort/import.ts
81315
- var COMMAND_NAME21 = "rafa effort import";
81715
+ var COMMAND_NAME24 = "rafa effort import";
81316
81716
  var IMPORT_USAGE = "rafa effort import <file> [--dry-run]";
81317
81717
  var DRY_RUN_FLAG6 = "dry-run";
81318
81718
  function syncOptions(context, repoRoot, backend, seams) {
@@ -81332,19 +81732,19 @@ async function pull(sync, otherPath, dryRun) {
81332
81732
  try {
81333
81733
  pulled = await sync.pull({ from: otherPath, dryRun });
81334
81734
  } catch (error2) {
81335
- throw mergeRefusalExit(error2, COMMAND_NAME21) ?? error2;
81735
+ throw mergeRefusalExit(error2, COMMAND_NAME24) ?? error2;
81336
81736
  }
81337
81737
  if (pulled.status !== "pulled") {
81338
- 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`);
81339
81739
  }
81340
81740
  return pulled.merge;
81341
81741
  }
81342
81742
  async function runImport(context, seams) {
81343
81743
  const file = expectOneArgument(context.args, IMPORT_USAGE);
81344
81744
  const dryRun = readSwitch2(DRY_RUN_FLAG6, context.flags[DRY_RUN_FLAG6], `Usage: ${IMPORT_USAGE}`);
81345
- const project = requireProject(context, COMMAND_NAME21);
81346
- mergeTargetPath(context, project.root, COMMAND_NAME21);
81347
- 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;
81348
81748
  const otherPath = resolve46((seams.cwd ?? (() => process.cwd()))(), file);
81349
81749
  const sync = (seams.createSync ?? createFileSync)(syncOptions(context, project.root, backend, seams));
81350
81750
  const result2 = await pull(sync, otherPath, dryRun);
@@ -81352,7 +81752,7 @@ async function runImport(context, seams) {
81352
81752
  context.output.result(result2);
81353
81753
  return;
81354
81754
  }
81355
- for (const line of renderMerge(result2, COMMAND_NAME21))
81755
+ for (const line of renderMerge(result2, COMMAND_NAME24))
81356
81756
  context.output.info(line);
81357
81757
  }
81358
81758
  function createImportCommand(seams = {}) {
@@ -81407,10 +81807,10 @@ init_location();
81407
81807
  init_migrate();
81408
81808
  init_sqlite();
81409
81809
  import { join as join125 } from "path";
81410
- var COMMAND_NAME22 = "rafa effort migrate";
81810
+ var COMMAND_NAME25 = "rafa effort migrate";
81411
81811
  var MIGRATE_USAGE = "rafa effort migrate [--dry-run]";
81412
81812
  var DRY_RUN_FLAG7 = "dry-run";
81413
- var REFUSED_EXIT8 = 1;
81813
+ var REFUSED_EXIT10 = 1;
81414
81814
  function builtLines(result2) {
81415
81815
  const rows2 = result2.counted.reduce((sum, table2) => sum + table2.rows, 0);
81416
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.`;
@@ -81441,13 +81841,13 @@ function storePath(context, root) {
81441
81841
  try {
81442
81842
  return join125(effortStoreDir(root, context.env), SQLITE_STORE_FILE_NAME);
81443
81843
  } catch (error2) {
81444
- throw new CommandExit(REFUSED_EXIT8, `\u274C ${COMMAND_NAME22}: ${messageOf(error2)}`);
81844
+ throw new CommandExit(REFUSED_EXIT10, `\u274C ${COMMAND_NAME25}: ${messageOf(error2)}`);
81445
81845
  }
81446
81846
  }
81447
81847
  function runMigrate(context, seams) {
81448
81848
  expectNoArgument(context.args, MIGRATE_USAGE);
81449
81849
  const dryRun = readSwitch2(DRY_RUN_FLAG7, context.flags[DRY_RUN_FLAG7], `Usage: ${MIGRATE_USAGE}`);
81450
- const path6 = storePath(context, requireProject(context, COMMAND_NAME22).root);
81850
+ const path6 = storePath(context, requireProject(context, COMMAND_NAME25).root);
81451
81851
  const now = seams.now ?? (() => new Date);
81452
81852
  let result2;
81453
81853
  try {
@@ -81463,7 +81863,7 @@ function runMigrate(context, seams) {
81463
81863
  });
81464
81864
  } catch (error2) {
81465
81865
  if (error2 instanceof RebuildRefusal || error2 instanceof DevelopmentBuildRefusedError) {
81466
- throw new CommandExit(REFUSED_EXIT8, `\u274C ${COMMAND_NAME22}: ${error2.message}`);
81866
+ throw new CommandExit(REFUSED_EXIT10, `\u274C ${COMMAND_NAME25}: ${error2.message}`);
81467
81867
  }
81468
81868
  throw error2;
81469
81869
  }
@@ -81525,7 +81925,7 @@ init_sections();
81525
81925
  init_ndjson();
81526
81926
  init_sqlite();
81527
81927
  init_types();
81528
- import { readFileSync as readFileSync101, writeFileSync as writeFileSync37 } from "fs";
81928
+ import { readFileSync as readFileSync102, writeFileSync as writeFileSync37 } from "fs";
81529
81929
  var MOVED_KINDS = Object.freeze(["sessions", "commits"]);
81530
81930
  var MOVE_TARGET = "sqlite";
81531
81931
  var STORE_LINE = `store: ${MOVE_TARGET}`;
@@ -81567,7 +81967,7 @@ function withSqliteStoreSetting(text2) {
81567
81967
  function plannedConfig(path6) {
81568
81968
  let text2;
81569
81969
  try {
81570
- text2 = readFileSync101(path6, "utf8");
81970
+ text2 = readFileSync102(path6, "utf8");
81571
81971
  } catch (error2) {
81572
81972
  throw new MoveRefusal("config", `${path6} could not be read: ${messageOf(error2)}. Nothing was moved.`);
81573
81973
  }
@@ -81639,16 +82039,16 @@ function moveToSqlite(options) {
81639
82039
  }
81640
82040
 
81641
82041
  // src/commands/effort/move.ts
81642
- var COMMAND_NAME23 = "rafa effort move";
82042
+ var COMMAND_NAME26 = "rafa effort move";
81643
82043
  var MOVE_USAGE = MOVE_TO_SQLITE;
81644
82044
  var TO_FLAG3 = "to";
81645
- var REFUSED_EXIT9 = 1;
82045
+ var REFUSED_EXIT11 = 1;
81646
82046
  function readTarget2(context) {
81647
82047
  const value = context.flags[TO_FLAG3];
81648
82048
  if (value === MOVE_TARGET)
81649
82049
  return;
81650
82050
  const found = value === undefined ? "no --to" : `--${TO_FLAG3}=${String(value)}`;
81651
- 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.
81652
82052
  Usage: ${MOVE_USAGE}`);
81653
82053
  }
81654
82054
  function kindLine(move3) {
@@ -81671,17 +82071,17 @@ function renderMove(result2) {
81671
82071
  }
81672
82072
  function refusalExit(error2) {
81673
82073
  const known = error2 instanceof MoveRefusal || error2 instanceof SchemaRefusedError || error2 instanceof DevelopmentBuildRefusedError;
81674
- 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;
81675
82075
  }
81676
82076
  async function runMove(context) {
81677
82077
  expectNoArgument(context.args, MOVE_USAGE);
81678
82078
  readTarget2(context);
81679
- const project = requireProject(context, COMMAND_NAME23);
81680
- 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));
81681
82081
  try {
81682
82082
  effortStoreDir(project.root, context.env);
81683
82083
  } catch (error2) {
81684
- throw new CommandExit(REFUSED_EXIT9, `\u274C ${COMMAND_NAME23}: ${messageOf(error2)}`);
82084
+ throw new CommandExit(REFUSED_EXIT11, `\u274C ${COMMAND_NAME26}: ${messageOf(error2)}`);
81685
82085
  }
81686
82086
  let result2;
81687
82087
  try {
@@ -81819,11 +82219,11 @@ init_sections();
81819
82219
  init_location();
81820
82220
  import { join as join126 } from "path";
81821
82221
  init_sqlite();
81822
- var COMMAND_NAME24 = "rafa effort schema";
82222
+ var COMMAND_NAME27 = "rafa effort schema";
81823
82223
  var SCHEMA_USAGE = "rafa effort schema [--check]";
81824
82224
  var CHECK_FLAG2 = "check";
81825
- var REFUSED_EXIT10 = 1;
81826
- var FAILED_EXIT5 = 2;
82225
+ var REFUSED_EXIT12 = 1;
82226
+ var FAILED_EXIT8 = 2;
81827
82227
  function listLine(name2, items2) {
81828
82228
  const shown3 = items2.length === 0 ? "none" : items2.join(", ");
81829
82229
  return `${name2} (${String(items2.length)}): ${shown3}`;
@@ -81866,25 +82266,25 @@ function storePath2(context, root) {
81866
82266
  try {
81867
82267
  return join126(effortStoreDir(root, context.env), SQLITE_STORE_FILE_NAME);
81868
82268
  } catch (error2) {
81869
- throw new CommandExit(REFUSED_EXIT10, `\u274C ${COMMAND_NAME24}: ${messageOf(error2)}`);
82269
+ throw new CommandExit(REFUSED_EXIT12, `\u274C ${COMMAND_NAME27}: ${messageOf(error2)}`);
81870
82270
  }
81871
82271
  }
81872
82272
  function runSchema(context, seams) {
81873
82273
  expectNoArgument(context.args, SCHEMA_USAGE);
81874
82274
  const check2 = readSwitch2(CHECK_FLAG2, context.flags[CHECK_FLAG2], `Usage: ${SCHEMA_USAGE}`);
81875
- const path6 = storePath2(context, requireProject(context, COMMAND_NAME24).root);
82275
+ const path6 = storePath2(context, requireProject(context, COMMAND_NAME27).root);
81876
82276
  let report4;
81877
82277
  try {
81878
82278
  report4 = readSchemaReport(path6, seams);
81879
82279
  } catch (error2) {
81880
- 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)}`);
81881
82281
  }
81882
82282
  if (context.outputMode !== "json") {
81883
82283
  for (const line of renderSchema(report4))
81884
82284
  context.output.info(line);
81885
82285
  }
81886
82286
  if (check2 && report4.refused) {
81887
- 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}`);
81888
82288
  }
81889
82289
  if (context.outputMode === "json")
81890
82290
  context.output.result(report4);
@@ -81933,7 +82333,7 @@ init_command2();
81933
82333
  init_config2();
81934
82334
  init_load();
81935
82335
  init_sections();
81936
- import { existsSync as existsSync88, readFileSync as readFileSync103 } from "fs";
82336
+ import { existsSync as existsSync88, readFileSync as readFileSync104 } from "fs";
81937
82337
  import { homedir as homedir17 } from "os";
81938
82338
  import { join as join129, relative as relative31, sep as sep12 } from "path";
81939
82339
  init_project_id();
@@ -81945,7 +82345,7 @@ init_hop_record2();
81945
82345
  init_position();
81946
82346
  init_scope2();
81947
82347
  import { createHash as createHash10 } from "crypto";
81948
- 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";
81949
82349
  import { dirname as dirname50, isAbsolute as isAbsolute28, join as join127 } from "path";
81950
82350
  var GITIGNORE_FILE = ".gitignore";
81951
82351
  var DIGEST_NAME = "tracking.digest";
@@ -82032,17 +82432,17 @@ function requireAbsolute3(root) {
82032
82432
  throw new GitignoreError(`project root is ${describeValue(root)}, expected an absolute path`);
82033
82433
  }
82034
82434
  }
82035
- function attempt5(file, failure10, act) {
82435
+ function attempt5(file, failure12, act) {
82036
82436
  try {
82037
82437
  return act();
82038
82438
  } catch (error2) {
82039
- throw new GitignoreError(`${file} ${failure10} (${messageOf(error2)})`, { cause: error2 });
82439
+ throw new GitignoreError(`${file} ${failure12} (${messageOf(error2)})`, { cause: error2 });
82040
82440
  }
82041
82441
  }
82042
82442
  function readIfPresent4(file) {
82043
82443
  if (!existsSync86(file))
82044
82444
  return null;
82045
- return attempt5(file, "cannot be read", () => readFileSync102(file, "utf8"));
82445
+ return attempt5(file, "cannot be read", () => readFileSync103(file, "utf8"));
82046
82446
  }
82047
82447
  function writeTrackingGitignore(root, flags) {
82048
82448
  requireAbsolute3(root);
@@ -82140,9 +82540,9 @@ function firstCandidate(found) {
82140
82540
  }
82141
82541
  function namedRoot(typed, start, source, seams) {
82142
82542
  const path6 = resolve47(start, typed);
82143
- const refusal27 = rootRefusal(path6, seams);
82144
- if (refusal27 !== null)
82145
- return problem(refusal27.reason);
82543
+ const refusal29 = rootRefusal(path6, seams);
82544
+ if (refusal29 !== null)
82545
+ return problem(refusal29.reason);
82146
82546
  const fs3 = seams.fs ?? DISK_ROOTS_FILE_SYSTEM;
82147
82547
  return chosen(fs3.realpath(path6), source);
82148
82548
  }
@@ -82182,7 +82582,7 @@ async function promptForRoot(found, prompter, seams) {
82182
82582
  // src/project/scaffold.ts
82183
82583
  init_rafa_inventory();
82184
82584
  init_rafa_release();
82185
- 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";
82186
82586
  import { join as join128 } from "path";
82187
82587
  init_config2();
82188
82588
  init_sections();
@@ -82388,7 +82788,7 @@ function occupied(path6) {
82388
82788
  return lstatSync3(path6, { throwIfNoEntry: false }) !== undefined;
82389
82789
  }
82390
82790
  function isDirectory3(path6) {
82391
- return statSync34(path6, { throwIfNoEntry: false })?.isDirectory() === true;
82791
+ return statSync35(path6, { throwIfNoEntry: false })?.isDirectory() === true;
82392
82792
  }
82393
82793
  function directoryConflict(dir) {
82394
82794
  if (!occupied(dir) || isDirectory3(dir))
@@ -82407,11 +82807,11 @@ function layoutConflicts(layout) {
82407
82807
  function scaffoldConflicts(root, home) {
82408
82808
  return [...layoutConflicts(layoutOf2(root, PROJECT_TREE)), ...layoutConflicts(layoutOf2(home, USER_TREE))];
82409
82809
  }
82410
- function attempt6(path6, failure10, act) {
82810
+ function attempt6(path6, failure12, act) {
82411
82811
  try {
82412
82812
  act();
82413
82813
  } catch (error2) {
82414
- throw new ScaffoldError(`${path6} ${failure10} (${messageOf(error2)})`, { cause: error2 });
82814
+ throw new ScaffoldError(`${path6} ${failure12} (${messageOf(error2)})`, { cause: error2 });
82415
82815
  }
82416
82816
  }
82417
82817
  function ensureDirectory(path6) {
@@ -82566,7 +82966,7 @@ var SOURCE_PHRASES = {
82566
82966
  "root-flag": "named by --root",
82567
82967
  typed: "typed at the prompt"
82568
82968
  };
82569
- function refusal27(lines3) {
82969
+ function refusal29(lines3) {
82570
82970
  return new CommandExit(1, [...lines3, NOTHING_WRITTEN3].join(`
82571
82971
  `));
82572
82972
  }
@@ -82574,14 +82974,14 @@ function expectNoArgument3(args) {
82574
82974
  if (args.length === 0)
82575
82975
  return;
82576
82976
  const got = `${String(args.length)}: ${args.join(" ")}`;
82577
- 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>`]);
82578
82978
  }
82579
82979
  function readYesFlag(value) {
82580
82980
  if (value === undefined || value === false || value === "false")
82581
82981
  return false;
82582
82982
  if (value === true || value === "true")
82583
82983
  return true;
82584
- 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>`]);
82585
82985
  }
82586
82986
  function readBoardFlag(value) {
82587
82987
  if (value === undefined)
@@ -82590,7 +82990,7 @@ function readBoardFlag(value) {
82590
82990
  return true;
82591
82991
  if (value === false || value === "false")
82592
82992
  return false;
82593
- 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"]);
82594
82994
  }
82595
82995
  function readEpicGuardFlag(value) {
82596
82996
  if (value === undefined)
@@ -82599,7 +82999,7 @@ function readEpicGuardFlag(value) {
82599
82999
  return true;
82600
83000
  if (value === false || value === "false")
82601
83001
  return false;
82602
- 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"]);
82603
83003
  }
82604
83004
  function readProjectFlag(value) {
82605
83005
  if (value === undefined)
@@ -82608,7 +83008,7 @@ function readProjectFlag(value) {
82608
83008
  return true;
82609
83009
  if (value === false || value === "false")
82610
83010
  return false;
82611
- 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"]);
82612
83012
  }
82613
83013
  function readReleaseFlag(value) {
82614
83014
  if (value === undefined)
@@ -82617,27 +83017,27 @@ function readReleaseFlag(value) {
82617
83017
  return true;
82618
83018
  if (value === false || value === "false")
82619
83019
  return false;
82620
- 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"]);
82621
83021
  }
82622
83022
  function readRootFlag(value) {
82623
83023
  if (value === undefined)
82624
83024
  return null;
82625
83025
  if (typeof value === "string" && value !== "")
82626
83026
  return value;
82627
- throw refusal27(["rafa init: --root needs a path: --root=<path>"]);
83027
+ throw refusal29(["rafa init: --root needs a path: --root=<path>"]);
82628
83028
  }
82629
83029
  function takeReading(reading2, found) {
82630
83030
  if (reading2.root !== null)
82631
83031
  return reading2.root;
82632
83032
  const listed5 = found === null ? [] : [...candidateLines(found), "Name another root with --root=<path>."];
82633
- throw refusal27([`rafa init: refused: ${reading2.problem}`, ...listed5]);
83033
+ throw refusal29([`rafa init: refused: ${reading2.problem}`, ...listed5]);
82634
83034
  }
82635
83035
  async function promptedRoot(found, seams, refusalSeams) {
82636
83036
  const prompter = seams.openPrompter();
82637
83037
  try {
82638
83038
  const root = await promptForRoot(found, prompter, refusalSeams);
82639
83039
  if (root === null)
82640
- 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."]);
82641
83041
  return root;
82642
83042
  } finally {
82643
83043
  prompter.close();
@@ -82654,7 +83054,7 @@ async function chooseRoot(context, seams, start, home, yes) {
82654
83054
  if (yes)
82655
83055
  return takeReading(firstCandidate(found), found);
82656
83056
  if (!seams.isTerminal()) {
82657
- throw refusal27([
83057
+ throw refusal29([
82658
83058
  "rafa init: no terminal to choose a root on.",
82659
83059
  ...candidateLines(found),
82660
83060
  "Take the first candidate with --yes, or name a root with --root=<path>."
@@ -82668,24 +83068,24 @@ async function resolvedConfig2(root, home, warn5) {
82668
83068
  } catch (error2) {
82669
83069
  if (!(error2 instanceof ConfigError))
82670
83070
  throw error2;
82671
- 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}`)]);
82672
83072
  }
82673
83073
  }
82674
83074
  function checkGitignore(root, flags) {
82675
83075
  const file = join129(root, GITIGNORE_FILE);
82676
83076
  try {
82677
- const text2 = existsSync88(file) ? readFileSync103(file, "utf8") : null;
83077
+ const text2 = existsSync88(file) ? readFileSync104(file, "utf8") : null;
82678
83078
  withTrackingBlock(text2, flags, file);
82679
83079
  } catch (error2) {
82680
83080
  const message = error2 instanceof GitignoreError ? error2.message : `rafa init: ${file} cannot be read (${messageOf(error2)})`;
82681
- throw refusal27([message]);
83081
+ throw refusal29([message]);
82682
83082
  }
82683
83083
  }
82684
83084
  function checkConflicts(root, home) {
82685
83085
  const conflicts = scaffoldConflicts(root, home);
82686
83086
  if (conflicts.length === 0)
82687
83087
  return;
82688
- 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}`)]);
82689
83089
  }
82690
83090
  function digestChange(existed, rewritten2) {
82691
83091
  if (!rewritten2)
@@ -83950,7 +84350,7 @@ import { homedir as homedir18 } from "os";
83950
84350
 
83951
84351
  // src/notices/notices.ts
83952
84352
  init_sections();
83953
- 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";
83954
84354
  import { dirname as dirname51, join as join130 } from "path";
83955
84355
  var NOTICE_IDS = Object.freeze(["alpha", "danger"]);
83956
84356
  var FEEDBACK_URL = "https://github.com/open-tomato/rafa/issues/new/choose";
@@ -83964,7 +84364,7 @@ function isNoticeId(value) {
83964
84364
  function readDismissed(home) {
83965
84365
  let raw;
83966
84366
  try {
83967
- raw = readFileSync104(noticesPath(home), "utf8");
84367
+ raw = readFileSync105(noticesPath(home), "utf8");
83968
84368
  } catch {
83969
84369
  return [];
83970
84370
  }
@@ -85758,7 +86158,7 @@ init_rafa_inventory();
85758
86158
  init_sections();
85759
86159
  init_output();
85760
86160
  init_plan();
85761
- 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";
85762
86162
  import { basename as basename31, isAbsolute as isAbsolute30, join as join131, relative as relative34, resolve as resolve49, sep as sep13 } from "path";
85763
86163
  init_tiers();
85764
86164
  var SOURCE_DIR2 = "src";
@@ -85772,7 +86172,7 @@ function realPathOrNull(path7) {
85772
86172
  }
85773
86173
  }
85774
86174
  function isFilePath(path7) {
85775
- return statSync35(path7, { throwIfNoEntry: false })?.isFile() === true;
86175
+ return statSync36(path7, { throwIfNoEntry: false })?.isFile() === true;
85776
86176
  }
85777
86177
  function bundledAgents(root) {
85778
86178
  if (root === null)
@@ -85856,7 +86256,7 @@ function tierPinItem(edit, planFileName2) {
85856
86256
  }
85857
86257
  function readOrNull(path7) {
85858
86258
  try {
85859
- return readFileSync105(path7, "utf8");
86259
+ return readFileSync106(path7, "utf8");
85860
86260
  } catch (error2) {
85861
86261
  const isAbsent2 = typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
85862
86262
  if (isAbsent2)
@@ -85909,7 +86309,7 @@ function notePlanBundledEdits(repoRoot, generated, output = activeOutput()) {
85909
86309
  const planFile2 = resolve49(repoRoot, generated.planPath);
85910
86310
  if (!isFile2(planFile2))
85911
86311
  return generated;
85912
- const edits = findBundledEdits(readFileSync105(planFile2, "utf8"), { repoRoot });
86312
+ const edits = findBundledEdits(readFileSync106(planFile2, "utf8"), { repoRoot });
85913
86313
  if (edits.length === 0)
85914
86314
  return generated;
85915
86315
  const file = generated.prerequisitesPath ?? prerequisitesPathForPlan(generated.planPath);
@@ -86117,14 +86517,14 @@ async function settleReview(gate, generated, skipReview) {
86117
86517
  }
86118
86518
 
86119
86519
  // src/commands/plan/store-check.ts
86120
- 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";
86121
86521
  import { basename as basename32, dirname as dirname52, resolve as resolve50 } from "path";
86122
86522
  init_command2();
86123
86523
  init_sections();
86124
86524
  init_output();
86125
86525
  init_plan();
86126
86526
  function readFileOrNull(path8) {
86127
- return path8 !== null && isFile2(path8) ? readFileSync106(path8, "utf8") : null;
86527
+ return path8 !== null && isFile2(path8) ? readFileSync107(path8, "utf8") : null;
86128
86528
  }
86129
86529
  function checkStoreRules(file, markdown) {
86130
86530
  const prerequisitesPath = prerequisitesPathForPlan(file);
@@ -86151,7 +86551,7 @@ function enforceStoreRules(repoRoot, generated, output = activeOutput()) {
86151
86551
  const planFile2 = resolve50(repoRoot, generated.planPath);
86152
86552
  if (!isFile2(planFile2))
86153
86553
  return;
86154
- const problems = checkStoreRules(planFile2, readFileSync106(planFile2, "utf8"));
86554
+ const problems = checkStoreRules(planFile2, readFileSync107(planFile2, "utf8"));
86155
86555
  if (problems.length === 0)
86156
86556
  return;
86157
86557
  const prerequisites = generated.prerequisitesPath ?? prerequisitesPathForPlan(generated.planPath);
@@ -86626,7 +87026,7 @@ var list_default10 = command86;
86626
87026
  // src/commands/plan/risk.ts
86627
87027
  init_rafa_board();
86628
87028
  init_rafa_pr();
86629
- import { readFileSync as readFileSync107 } from "fs";
87029
+ import { readFileSync as readFileSync108 } from "fs";
86630
87030
  import { resolve as resolve51 } from "path";
86631
87031
  init_plan_files2();
86632
87032
  init_command2();
@@ -86658,7 +87058,7 @@ function strictRefusal(report4) {
86658
87058
  }
86659
87059
  async function readRisk(path9, project, config, context, seams) {
86660
87060
  const makeRunners = seams.runners ?? spawningRunners2;
86661
- return assessPlanRisk({ path: path9, text: readFileSync107(path9, "utf8") }, {
87061
+ return assessPlanRisk({ path: path9, text: readFileSync108(path9, "utf8") }, {
86662
87062
  repoRoot: project.root,
86663
87063
  home: project.home,
86664
87064
  settingSources: config.settingSources,
@@ -86745,7 +87145,7 @@ var risk_default = command87;
86745
87145
  init_plan_files2();
86746
87146
  init_command2();
86747
87147
  init_plan();
86748
- import { readFileSync as readFileSync108 } from "fs";
87148
+ import { readFileSync as readFileSync109 } from "fs";
86749
87149
  import { join as join132 } from "path";
86750
87150
  var USAGE48 = "rafa plan show <stub> [--tracker]";
86751
87151
  var COMMAND8 = "rafa plan show";
@@ -86767,7 +87167,7 @@ function showPlan(plans, stub, tracker) {
86767
87167
  const file = join132(plans.path, name2);
86768
87168
  if (!isFile2(file))
86769
87169
  throw new CommandExit(1, missingText(stub, tracker, join132(plans.label, name2)));
86770
- const model = parsePlan(readFileSync108(file, "utf8"));
87170
+ const model = parsePlan(readFileSync109(file, "utf8"));
86771
87171
  const { header } = model;
86772
87172
  return {
86773
87173
  stub,
@@ -86861,7 +87261,7 @@ var show_default7 = command88;
86861
87261
 
86862
87262
  // src/commands/plan/validate.ts
86863
87263
  init_rafa_inventory();
86864
- import { readFileSync as readFileSync109 } from "fs";
87264
+ import { readFileSync as readFileSync110 } from "fs";
86865
87265
  import { basename as basename33, resolve as resolve52 } from "path";
86866
87266
  init_plan_files2();
86867
87267
  init_command2();
@@ -86972,7 +87372,7 @@ function createPlanValidateCommand(workingDirectory = () => process.cwd()) {
86972
87372
  const file = resolve52(workingDirectory(), typed);
86973
87373
  const validation = validatePlan(file);
86974
87374
  const { issues, stages, tasks } = validation;
86975
- const markdown = readFileSync109(file, "utf8");
87375
+ const markdown = readFileSync110(file, "utf8");
86976
87376
  const findings = await checkRoster(context, markdown);
86977
87377
  const { missingAgents, skillCollisions, unresolvedSkills } = findings;
86978
87378
  const storeProblems = checkStoreRules(file, markdown);
@@ -87182,7 +87582,7 @@ var self_update_default = command91;
87182
87582
  init_rafa_inventory();
87183
87583
  init_command2();
87184
87584
  init_load();
87185
- import { statSync as statSync36 } from "fs";
87585
+ import { statSync as statSync37 } from "fs";
87186
87586
  import { join as join133, resolve as resolve53 } from "path";
87187
87587
  var DEFAULT_BACKFILL_SEAMS = Object.freeze({
87188
87588
  cwd: () => process.cwd()
@@ -87231,7 +87631,7 @@ Usage: ${BACKFILL_USAGE}`);
87231
87631
  }
87232
87632
  function isDirectory4(path9) {
87233
87633
  try {
87234
- return statSync36(path9).isDirectory();
87634
+ return statSync37(path9).isDirectory();
87235
87635
  } catch {
87236
87636
  return false;
87237
87637
  }
@@ -87519,7 +87919,7 @@ var check_default3 = command93;
87519
87919
  // src/commands/skill/demote.ts
87520
87920
  init_rafa_inventory();
87521
87921
  init_command2();
87522
- 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";
87523
87923
  import { dirname as dirname53, resolve as resolve54 } from "path";
87524
87924
  var DEFAULT_DEMOTE_SEAMS = Object.freeze({
87525
87925
  cwd: () => process.cwd()
@@ -87548,7 +87948,7 @@ Usage: ${DEMOTE_USAGE}`);
87548
87948
  }
87549
87949
  function isDirectory5(path9) {
87550
87950
  try {
87551
- return statSync37(path9).isDirectory();
87951
+ return statSync38(path9).isDirectory();
87552
87952
  } catch {
87553
87953
  return false;
87554
87954
  }
@@ -87578,7 +87978,7 @@ function verdictLine2(report4) {
87578
87978
  function previousReport(path9, context) {
87579
87979
  if (!existsSync89(path9))
87580
87980
  return null;
87581
- const parsed2 = parseDemotionReport(readFileSync110(path9, "utf8"));
87981
+ const parsed2 = parseDemotionReport(readFileSync111(path9, "utf8"));
87582
87982
  if (parsed2.report !== null)
87583
87983
  return parsed2.report;
87584
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(", ")}`);
@@ -87614,7 +88014,7 @@ function reviewedReport(scope) {
87614
88014
  if (!existsSync89(scope.reportPath)) {
87615
88015
  throw new CommandExit(1, `\u274C No report at ${scope.reportPath}; run "rafa skill demote ${scope.dir}" first, then review it`);
87616
88016
  }
87617
- const parsed2 = parseDemotionReport(readFileSync110(scope.reportPath, "utf8"));
88017
+ const parsed2 = parseDemotionReport(readFileSync111(scope.reportPath, "utf8"));
87618
88018
  if (parsed2.report === null) {
87619
88019
  const lines3 = parsed2.issues.map((issue5) => ` line ${String(issue5.line)} ${issue5.code}: ${issue5.message}`);
87620
88020
  throw new CommandExit(1, [`\u274C ${scope.reportPath} does not parse:`, ...lines3].join(`
@@ -87724,7 +88124,7 @@ init_rafa_inventory();
87724
88124
  init_plan_files2();
87725
88125
  init_command2();
87726
88126
  var DEFAULT_SKILL_SHOW_SEAMS = DEFAULT_SKILL_LIST_SEAMS;
87727
- var COMMAND_NAME25 = "rafa skill show";
88127
+ var COMMAND_NAME28 = "rafa skill show";
87728
88128
  var USAGE51 = "rafa skill show <name> [--full]";
87729
88129
  function unknownSkillMessage(name2, inventory) {
87730
88130
  const agent = findShown(inventory.records, "agent", name2);
@@ -87752,7 +88152,7 @@ async function runShow4(context, seams) {
87752
88152
  const full = readSwitch2("full", context.flags["full"], `Type the name ahead of it: ${USAGE51}`);
87753
88153
  const name2 = expectOneArgument(context.args, USAGE51);
87754
88154
  const project = projectOf16(context);
87755
- const { inventory, settingSources } = await projectInventory(project, context, seams, COMMAND_NAME25);
88155
+ const { inventory, settingSources } = await projectInventory(project, context, seams, COMMAND_NAME28);
87756
88156
  const warnings = warningLines(inventory);
87757
88157
  for (const warning of warnings)
87758
88158
  context.output.warn(warning);
@@ -88391,7 +88791,7 @@ async function readStatusSections(input, seams = {}) {
88391
88791
  }
88392
88792
 
88393
88793
  // src/commands/status.ts
88394
- var COMMAND_NAME26 = "rafa status";
88794
+ var COMMAND_NAME29 = "rafa status";
88395
88795
  var STATUS_USAGE = "rafa status";
88396
88796
  var STATUS_ARGUMENT_EXIT = 2;
88397
88797
  var DEFAULT_STATUS_SEAMS = Object.freeze({});
@@ -88403,13 +88803,13 @@ function projectOf17(context) {
88403
88803
  function expectNoWord(args) {
88404
88804
  if (args.length === 0)
88405
88805
  return;
88406
- 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(" ")}
88407
88807
  Usage: ${STATUS_USAGE}`);
88408
88808
  }
88409
88809
  async function runStatus2(context, seams) {
88410
88810
  expectNoWord(context.args);
88411
88811
  const project = projectOf17(context);
88412
- const config = await resolveProjectConfig(project, COMMAND_NAME26, (message) => {
88812
+ const config = await resolveProjectConfig(project, COMMAND_NAME29, (message) => {
88413
88813
  context.output.warn(message);
88414
88814
  });
88415
88815
  const warn5 = (message) => {
@@ -88463,14 +88863,14 @@ init_command2();
88463
88863
  init_config2();
88464
88864
  init_sections();
88465
88865
  init_git2();
88466
- 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";
88467
88867
  import { dirname as dirname54, join as join134 } from "path";
88468
- var COMMAND_NAME27 = "rafa stretch end";
88868
+ var COMMAND_NAME30 = "rafa stretch end";
88469
88869
  var STRETCH_END_USAGE = "rafa stretch end [--dry-run]";
88470
88870
  var REPORT_FILE2 = "report.md";
88471
88871
  var BODY_FILE = "pr-body.md";
88472
- var REFUSED_EXIT11 = 1;
88473
- var FAILED_EXIT6 = 2;
88872
+ var REFUSED_EXIT13 = 1;
88873
+ var FAILED_EXIT9 = 2;
88474
88874
  function reportPath(root, n) {
88475
88875
  return join134(stretchFolder(root, n), REPORT_FILE2);
88476
88876
  }
@@ -88492,11 +88892,11 @@ ${closes2.join(`
88492
88892
  `)}
88493
88893
  `;
88494
88894
  }
88495
- function refusal28(why) {
88496
- return new CommandExit(REFUSED_EXIT11, `\u274C ${COMMAND_NAME27}: ${why}`);
88895
+ function refusal30(why) {
88896
+ return new CommandExit(REFUSED_EXIT13, `\u274C ${COMMAND_NAME30}: ${why}`);
88497
88897
  }
88498
- function failure10(why) {
88499
- return new CommandExit(FAILED_EXIT6, `\u274C ${COMMAND_NAME27}: ${why}`);
88898
+ function failure12(why) {
88899
+ return new CommandExit(FAILED_EXIT9, `\u274C ${COMMAND_NAME30}: ${why}`);
88500
88900
  }
88501
88901
  function readEndLine(context) {
88502
88902
  expectNoArgument(context.args, STRETCH_END_USAGE);
@@ -88507,24 +88907,24 @@ function requireStretchBase2(prBase) {
88507
88907
  if (n !== null)
88508
88908
  return n;
88509
88909
  const found = prBase === null ? "not set" : `"${prBase}"`;
88510
- 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.`);
88511
88911
  }
88512
88912
  function readReport2(root, n) {
88513
88913
  const path9 = reportPath(root, n);
88514
88914
  if (!existsSync91(path9)) {
88515
- 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.`);
88516
88916
  }
88517
88917
  try {
88518
- return readFileSync111(path9, "utf8");
88918
+ return readFileSync112(path9, "utf8");
88519
88919
  } catch (error2) {
88520
- 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.`);
88521
88921
  }
88522
88922
  }
88523
88923
  function recordText(record2, name2, path9) {
88524
88924
  const value = record2[name2];
88525
88925
  if (typeof value === "string" && value !== "")
88526
88926
  return value;
88527
- 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.`);
88528
88928
  }
88529
88929
  function readStretchRecord(root, n) {
88530
88930
  const path9 = stretchRecordPath(root, n);
@@ -88532,15 +88932,15 @@ function readStretchRecord(root, n) {
88532
88932
  return null;
88533
88933
  let value;
88534
88934
  try {
88535
- value = JSON.parse(readFileSync111(path9, "utf8"));
88935
+ value = JSON.parse(readFileSync112(path9, "utf8"));
88536
88936
  } catch (error2) {
88537
- 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.`);
88538
88938
  }
88539
88939
  if (!isMapping(value))
88540
- 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.`);
88541
88941
  const prBase = value["prBase"];
88542
88942
  if (prBase !== null && (typeof prBase !== "string" || prBase === "")) {
88543
- 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.`);
88544
88944
  }
88545
88945
  const startedAt = value["startedAt"];
88546
88946
  return {
@@ -88551,12 +88951,12 @@ function readStretchRecord(root, n) {
88551
88951
  startedAt: typeof startedAt === "string" ? startedAt : ""
88552
88952
  };
88553
88953
  }
88554
- function ledgerItems(context, root, n) {
88954
+ function ledgerItems2(context, root, n) {
88555
88955
  let reading2;
88556
88956
  try {
88557
88957
  reading2 = readItems(root, n);
88558
88958
  } catch (error2) {
88559
- 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.`);
88560
88960
  }
88561
88961
  for (const line of malformedItemLines(root, n, reading2.malformed))
88562
88962
  context.output.warn(line);
@@ -88568,7 +88968,7 @@ function putBack(context, input, merged2) {
88568
88968
  info3(`#${String(merged2.number)} from ${branch} merged at ${merged2.mergedAt}`);
88569
88969
  const { record: record2 } = input;
88570
88970
  if (record2 === null) {
88571
- 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.`);
88572
88972
  }
88573
88973
  const value = record2.prBase ?? record2.defaultBranch;
88574
88974
  if (record2.prBase === null) {
@@ -88577,10 +88977,10 @@ function putBack(context, input, merged2) {
88577
88977
  const path9 = configFilePath(input.root);
88578
88978
  let edit;
88579
88979
  try {
88580
- edit = withConfigSetting(readFileSync111(path9, "utf8"), PR_BASE_KEY, value, path9);
88980
+ edit = withConfigSetting(readFileSync112(path9, "utf8"), PR_BASE_KEY, value, path9);
88581
88981
  } catch (error2) {
88582
88982
  const why = error2 instanceof ConfigSetRefusal ? `${PR_BASE_KEY} cannot be set: ${error2.message}` : `${path9} could not be read: ${messageOf(error2)}`;
88583
- throw refusal28(`${why}. Nothing was set.`);
88983
+ throw refusal30(`${why}. Nothing was set.`);
88584
88984
  }
88585
88985
  if (!edit.changed) {
88586
88986
  info3(`${path9} already reads ${PR_BASE_KEY}: ${value}`);
@@ -88594,7 +88994,7 @@ function putBack(context, input, merged2) {
88594
88994
  try {
88595
88995
  writeFileSync44(path9, edit.text, "utf8");
88596
88996
  } catch (error2) {
88597
- 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}.`);
88598
88998
  }
88599
88999
  info3(`${PR_BASE_KEY}: ${branch} \u2192 ${value}; stretch ${String(input.n)} is ended`);
88600
89000
  }
@@ -88617,7 +89017,7 @@ async function openEnd(context, input, body, seams) {
88617
89017
  mkdirSync40(dirname54(path9), { recursive: true });
88618
89018
  writeFileSync44(path9, body, "utf8");
88619
89019
  } catch (error2) {
88620
- 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.`);
88621
89021
  }
88622
89022
  const result2 = await openPull2({ ...context, args: [], flags }, seams.pr);
88623
89023
  const warning = baseWarning(result2);
@@ -88628,12 +89028,12 @@ async function openEnd(context, input, body, seams) {
88628
89028
  }
88629
89029
  async function runStretchEnd(context, seams) {
88630
89030
  const line = readEndLine(context);
88631
- const project = requireProject(context, COMMAND_NAME27);
89031
+ const project = requireProject(context, COMMAND_NAME30);
88632
89032
  const { root } = project;
88633
- 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));
88634
89034
  const n = requireStretchBase2(config.prBase);
88635
89035
  const report4 = readReport2(root, n);
88636
- const closes2 = closesLines(ledgerItems(context, root, n));
89036
+ const closes2 = closesLines(ledgerItems2(context, root, n));
88637
89037
  const record2 = readStretchRecord(root, n);
88638
89038
  const defaultBranch = record2?.defaultBranch ?? readRemoteHead(seams.git(root)) ?? DEFAULT_BASE_BRANCH;
88639
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" : ""}`);
@@ -89021,9 +89421,9 @@ async function runUpdateCurrent(context, seams) {
89021
89421
  }
89022
89422
  const applied = await applyAndReport(plan2, access.gh, context);
89023
89423
  finish2(applied);
89024
- const refusal29 = refusedLabels(applied);
89025
- if (refusal29 !== null)
89026
- throw refusal29;
89424
+ const refusal31 = refusedLabels(applied);
89425
+ if (refusal31 !== null)
89426
+ throw refusal31;
89027
89427
  }
89028
89428
  function createUpdateCurrentCommand(seams = DEFAULT_UPDATE_CURRENT_SEAMS) {
89029
89429
  const command99 = {
@@ -89285,7 +89685,7 @@ function noticeLine(previous, current) {
89285
89685
 
89286
89686
  // src/status/seen.ts
89287
89687
  init_rafa_pr();
89288
- 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";
89289
89689
  import { dirname as dirname55, join as join136 } from "path";
89290
89690
  init_sections();
89291
89691
  init_loop();
@@ -89349,7 +89749,7 @@ function asSnapshot(value) {
89349
89749
  function readSeenFile(root) {
89350
89750
  let text2;
89351
89751
  try {
89352
- text2 = readFileSync112(seenFilePath(root), "utf8");
89752
+ text2 = readFileSync113(seenFilePath(root), "utf8");
89353
89753
  } catch {
89354
89754
  return null;
89355
89755
  }