@open-tomato/rafa 0.50.0 → 0.52.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/index.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  runPreflight,
22
22
  runShellProbe,
23
23
  spawnShell
24
- } from "./index-w5qbpdtp.js";
24
+ } from "./index-amevawhe.js";
25
25
  import {
26
26
  ACROSS_STORES_ORDER,
27
27
  DEVELOPMENT_NEXT_STEP,
@@ -82,7 +82,7 @@ import {
82
82
  withSqliteStore,
83
83
  writeNames,
84
84
  writeSqliteStore
85
- } from "./index-kcbs6fp9.js";
85
+ } from "./index-hyp1sraj.js";
86
86
  import {
87
87
  ACTION_SHAPE,
88
88
  CONFIG_DEFAULTS,
@@ -98,7 +98,7 @@ import {
98
98
  renderTitle,
99
99
  suggestedEnvironment,
100
100
  titleRoundTrips
101
- } from "./index-zsak0jy6.js";
101
+ } from "./index-nqaqh4zz.js";
102
102
  import {
103
103
  ABSENT,
104
104
  ACCEPT_REFS_FLAG,
@@ -269,7 +269,7 @@ import {
269
269
  writeHopRecord,
270
270
  writePositionFile,
271
271
  writeRefsBlock
272
- } from "./index-q1tkqxnh.js";
272
+ } from "./index-mbxgc1zv.js";
273
273
  import {
274
274
  BLOCKER_GAP,
275
275
  PLAN_BLOCK_KINDS,
@@ -294,7 +294,7 @@ import {
294
294
  stubOfPlanFile,
295
295
  trackerPathFor,
296
296
  unescapeBlockerText
297
- } from "./index-ajv88fkm.js";
297
+ } from "./index-n2r3wf2z.js";
298
298
  import {
299
299
  CORE_ADAPTER_REGISTRY,
300
300
  CommandExit,
@@ -321,7 +321,7 @@ import {
321
321
  parseWorkingTree,
322
322
  registerAdapters,
323
323
  restoreAdapters
324
- } from "./index-7rg3jbsz.js";
324
+ } from "./index-91cag9fr.js";
325
325
  import {
326
326
  activeOutput,
327
327
  activeOutputMode,
@@ -340,7 +340,7 @@ import {
340
340
  codeProblem,
341
341
  familyOf,
342
342
  isKnownCode
343
- } from "./index-g91ys6kw.js";
343
+ } from "./index-jjxnyqvy.js";
344
344
  import {
345
345
  CONFIG_FILE,
346
346
  CORE_SECTION,
@@ -11981,6 +11981,12 @@ function readTags(git) {
11981
11981
  const tags = releaseTagsOf(result.stdout);
11982
11982
  return { tags, latest: tags.find((tag) => tag.package === null) ?? null, problem: null };
11983
11983
  }
11984
+ function newestRootRelease(git) {
11985
+ const reading = readTags(git);
11986
+ if (reading.problem !== null)
11987
+ return;
11988
+ return reading.latest?.version ?? null;
11989
+ }
11984
11990
  function readUntagged(root, configured, tags) {
11985
11991
  const resolved = join25(root, configured);
11986
11992
  const text = textOf(resolved);
@@ -12967,6 +12973,21 @@ var DOC_UPDATE_TASK_PREFIX = "Repair the stale doc line at ";
12967
12973
  function staleDocsTitle(version) {
12968
12974
  return `Release ${version}: update stale docs`;
12969
12975
  }
12976
+ var STALE_DOCS_TITLE = /^Release (\S+): update stale docs$/;
12977
+ function staleDocsTitleVersion(title) {
12978
+ return STALE_DOCS_TITLE.exec(title)?.[1] ?? null;
12979
+ }
12980
+ function isUnreleasedVersion(version, newestRelease) {
12981
+ if (version === NEXT_VERSION)
12982
+ return true;
12983
+ const parsed = parseSemanticVersion(version);
12984
+ if (parsed === null)
12985
+ return false;
12986
+ if (newestRelease === null)
12987
+ return true;
12988
+ const newest = parseSemanticVersion(newestRelease);
12989
+ return newest !== null && compareVersions(parsed, newest) > 0;
12990
+ }
12970
12991
  function staleDocsVersion(input) {
12971
12992
  if (!input.releaseEnabled)
12972
12993
  return NEXT_VERSION;
@@ -13021,8 +13042,81 @@ async function call(step, action) {
13021
13042
  return { ok: false, problem: oneLine5(`${step} failed: ${messageOf(error)}`) };
13022
13043
  }
13023
13044
  }
13024
- function findIssue(open, title) {
13025
- return open.find((issue4) => issue4.body.includes(STALE_DOCS_MARKER) && issue4.title === title);
13045
+ function createdMs(issue4) {
13046
+ if (issue4.createdAt === null)
13047
+ return null;
13048
+ const ms = Date.parse(issue4.createdAt);
13049
+ return Number.isNaN(ms) ? null : ms;
13050
+ }
13051
+ function idOrder(left, right) {
13052
+ const [a, b] = [Number(left), Number(right)];
13053
+ if (Number.isSafeInteger(a) && Number.isSafeInteger(b))
13054
+ return a - b;
13055
+ return left.localeCompare(right);
13056
+ }
13057
+ function olderFirst(left, right) {
13058
+ const [a, b] = [createdMs(left), createdMs(right)];
13059
+ if (a !== null && b !== null && a !== b)
13060
+ return a - b;
13061
+ return idOrder(left.ref.externalId, right.ref.externalId);
13062
+ }
13063
+ function releaseReading(newestRelease) {
13064
+ return typeof newestRelease === "string" && parseSemanticVersion(newestRelease) === null ? undefined : newestRelease;
13065
+ }
13066
+ function mayTake(issue4, choice) {
13067
+ if (!issue4.body.includes(STALE_DOCS_MARKER))
13068
+ return false;
13069
+ if (choice.newestRelease === undefined)
13070
+ return issue4.title === choice.title;
13071
+ const version = staleDocsTitleVersion(issue4.title);
13072
+ return version !== null && isUnreleasedVersion(version, choice.newestRelease);
13073
+ }
13074
+ function chooseIssue(open, choice) {
13075
+ const candidates = open.filter((issue4) => mayTake(issue4, choice)).sort(olderFirst);
13076
+ return candidates.find((issue4) => issue4.title === choice.title) ?? candidates[0];
13077
+ }
13078
+ function issueChange(found, title, line, held) {
13079
+ if (held)
13080
+ return { title };
13081
+ const body = appendItem(found.body, line.item);
13082
+ return found.title === title ? { body } : { title, body };
13083
+ }
13084
+ async function addToIssue(tracker, found, title, line) {
13085
+ const held = bodyHoldsLine(found.body, line.text);
13086
+ const action = held ? "held" : "appended";
13087
+ if (held && found.title === title)
13088
+ return { action, title, ref: found.ref };
13089
+ const change = issueChange(found, title, line, held);
13090
+ const edited = await call("editing the stale-docs issue", () => tracker.edit(found.ref, change));
13091
+ if (!edited.ok)
13092
+ return { action: "failed", title, problem: edited.problem };
13093
+ return found.title === title ? { action, title, ref: found.ref } : { action, title, ref: found.ref, retitledFrom: found.title };
13094
+ }
13095
+ async function closeDuplicate(tracker, duplicate, older) {
13096
+ const id = duplicate.externalId;
13097
+ const commented = await call(`commenting on the duplicate issue ${id}`, () => tracker.comment(duplicate, `Duplicate of #${older.externalId}`));
13098
+ if (!commented.ok)
13099
+ return commented;
13100
+ return call(`closing the duplicate issue ${id}`, () => tracker.transition(duplicate, "cancelled"));
13101
+ }
13102
+ async function createAndConverge(tracker, choice, line) {
13103
+ const { title } = choice;
13104
+ const created = await call("creating the stale-docs issue", () => tracker.create(issueDraft(title, line.item)));
13105
+ if (!created.ok)
13106
+ return { action: "failed", title, problem: created.problem };
13107
+ const ref = created.value;
13108
+ const relisted = await call(`listing the open chore issues after creating issue ${ref.externalId}`, () => tracker.openIssues("chore"));
13109
+ if (!relisted.ok)
13110
+ return { action: "failed", title, problem: relisted.problem };
13111
+ const own = relisted.value.find((issue4) => issue4.ref.externalId === ref.externalId) ?? { ref, title, body: "", createdAt: null };
13112
+ const older = chooseIssue(relisted.value.filter((issue4) => issue4.ref.externalId !== ref.externalId && olderFirst(issue4, own) < 0), choice);
13113
+ if (older === undefined)
13114
+ return { action: "created", title, ref };
13115
+ const added = await addToIssue(tracker, older, title, line);
13116
+ if (added.action !== "appended" && added.action !== "held")
13117
+ return added;
13118
+ const closed = await closeDuplicate(tracker, ref, older.ref);
13119
+ return closed.ok ? { ...added, duplicate: ref } : { action: "failed", title, problem: closed.problem };
13026
13120
  }
13027
13121
  async function addStaleDocLine(options) {
13028
13122
  const { tracker, version, entry } = options;
@@ -13030,20 +13124,13 @@ async function addStaleDocLine(options) {
13030
13124
  if (!canHoldIssue(tracker))
13031
13125
  return { action: "kept", title, reason: NO_EDITABLE_TRACKER };
13032
13126
  const text = staleDocLineText(entry);
13033
- const item = `${UNTICKED}${text}`;
13127
+ const line = { text, item: `${UNTICKED}${text}` };
13128
+ const choice = { title, newestRelease: releaseReading(options.newestRelease) };
13034
13129
  const listed2 = await call("listing the open chore issues", () => tracker.openIssues("chore"));
13035
13130
  if (!listed2.ok)
13036
13131
  return { action: "failed", title, problem: listed2.problem };
13037
- const found = findIssue(listed2.value, title);
13038
- if (found === undefined) {
13039
- const created = await call("creating the stale-docs issue", () => tracker.create(issueDraft(title, item)));
13040
- return created.ok ? { action: "created", title, ref: created.value } : { action: "failed", title, problem: created.problem };
13041
- }
13042
- if (bodyHoldsLine(found.body, text))
13043
- return { action: "held", title, ref: found.ref };
13044
- const body = appendItem(found.body, item);
13045
- const edited = await call("editing the stale-docs issue", () => tracker.edit(found.ref, { body }));
13046
- return edited.ok ? { action: "appended", title, ref: found.ref } : { action: "failed", title, problem: edited.problem };
13132
+ const found = chooseIssue(listed2.value, choice);
13133
+ return found === undefined ? createAndConverge(tracker, choice, line) : addToIssue(tracker, found, title, line);
13047
13134
  }
13048
13135
  function docUpdateLineText(taskText) {
13049
13136
  if (!taskText.startsWith(DOC_UPDATE_TASK_PREFIX))
@@ -13684,6 +13771,11 @@ function formatRows(rows) {
13684
13771
  `);
13685
13772
  }
13686
13773
  var FIRST_CHECK_GRACE_MS = 120000;
13774
+ function headTimeOf(detail) {
13775
+ const committedAt = detail?.headCommittedAt ?? null;
13776
+ const ms = committedAt === null ? Number.NaN : Date.parse(committedAt);
13777
+ return Number.isNaN(ms) ? null : ms;
13778
+ }
13687
13779
  function defaultSleep(ms) {
13688
13780
  return new Promise((resolve12) => {
13689
13781
  setTimeout(resolve12, ms);
@@ -23116,20 +23208,22 @@ async function runStartPreflight(options) {
23116
23208
  }
23117
23209
 
23118
23210
  // packages/rafa-run/src/start/type-step.ts
23119
- import { existsSync as existsSync32, mkdtempSync as mkdtempSync2, realpathSync as realpathSync4, rmSync as rmSync6, symlinkSync as symlinkSync2, writeFileSync as writeFileSync10 } from "fs";
23211
+ import { closeSync as closeSync2, existsSync as existsSync32, mkdtempSync as mkdtempSync2, openSync as openSync2, readSync as readSync2, realpathSync as realpathSync4, rmSync as rmSync6, symlinkSync as symlinkSync2, writeFileSync as writeFileSync10 } from "fs";
23120
23212
  import { tmpdir as tmpdir2 } from "os";
23121
- import { dirname as dirname15, join as join41, relative as relative14, resolve as resolve18, sep as sep6 } from "path";
23213
+ import { basename as basename11, dirname as dirname15, join as join41, relative as relative14, resolve as resolve18, sep as sep6 } from "path";
23122
23214
  var TEST_FILE_SUFFIX = ".test.ts";
23123
23215
  var TSC_FLAGS = ["--noEmit", "--pretty", "false"];
23216
+ var CANNOT_START_CODES = [126, 127];
23217
+ var SHEBANG_BYTES = 256;
23124
23218
  var ERRORS_LISTED = 10;
23125
23219
  var NODE_MODULES2 = "node_modules";
23126
23220
  var TSC_BIN = [".bin", "tsc"];
23127
23221
  var SCRATCH_NAME = "tsconfig.json";
23128
23222
  var FILE_ERROR = /^(.+)\((\d+),(\d+)\): error (TS\d+): (.*)$/;
23129
23223
  var GLOBAL_ERROR = /^error (TS\d+): (.*)$/;
23130
- var NOTHING_RAN = { ran: false, red: false, interrupted: false, blocker: null };
23131
- var GREEN = { ran: true, red: false, interrupted: false, blocker: null };
23132
- var INTERRUPTED2 = { ran: true, red: false, interrupted: true, blocker: null };
23224
+ var NOTHING_RAN = { ran: false, red: false, interrupted: false, cannotStart: false, blocker: null };
23225
+ var GREEN = { ran: true, red: false, interrupted: false, cannotStart: false, blocker: null };
23226
+ var INTERRUPTED2 = { ran: true, red: false, interrupted: true, cannotStart: false, blocker: null };
23133
23227
  async function runTsc(options) {
23134
23228
  const proc = Bun.spawn([...options.argv], {
23135
23229
  cwd: options.cwd,
@@ -23276,6 +23370,32 @@ function typeBlockerText(label, base2, errors) {
23276
23370
  function brokenBlockerText(label, run, said) {
23277
23371
  return `The runner's ${label} could not type-check the task's test files: tsc exited ${run.exitCode}${said === undefined ? " and printed no error." : `: ${said}`}`;
23278
23372
  }
23373
+ function scriptInterpreter(path3) {
23374
+ let head;
23375
+ try {
23376
+ const fd = openSync2(path3, "r");
23377
+ try {
23378
+ const buffer = Buffer.alloc(SHEBANG_BYTES);
23379
+ head = buffer.toString("utf8", 0, readSync2(fd, buffer, 0, SHEBANG_BYTES, 0));
23380
+ } finally {
23381
+ closeSync2(fd);
23382
+ }
23383
+ } catch {
23384
+ return null;
23385
+ }
23386
+ const first = head.split(`
23387
+ `)[0] ?? "";
23388
+ if (!first.startsWith("#!"))
23389
+ return null;
23390
+ const [program = "", ...rest] = first.slice(2).trim().split(/\s+/u);
23391
+ const named = basename11(program) === "env" ? rest.find((word) => !word.startsWith("-") && !word.includes("=")) : program;
23392
+ return named === undefined || named === "" ? null : basename11(named);
23393
+ }
23394
+ function cannotStartBlockerText(label, tsc, run, said, interpreter) {
23395
+ const heard = said === undefined ? "" : ` (${said})`;
23396
+ const fix = interpreter === null ? `Its first line names no interpreter, so make ${tsc} runnable from the PATH the loop runs under` : `tsc runs under ${interpreter}, which its first line names: put ${interpreter} on the PATH the loop runs under`;
23397
+ return `The runner's ${label} could not start tsc: ${tsc} exited ${run.exitCode}${heard}. ` + `${fix}, then run the task again. This is no type error of the task's, and no change to its files fixes it.`;
23398
+ }
23279
23399
  function configError(errors, scratch, cwd) {
23280
23400
  const config = relative14(cwd, scratch);
23281
23401
  return errors.find((error) => error.file === null || error.file === config);
@@ -23298,6 +23418,8 @@ async function checkTree(input, modules, tree, files) {
23298
23418
  }
23299
23419
  if (run.exitCode === input.stopCode || input.isInterrupted?.() === true)
23300
23420
  return { kind: "interrupted" };
23421
+ if (CANNOT_START_CODES.includes(run.exitCode))
23422
+ return { kind: "cannot-start", run, said: firstLine7(run) };
23301
23423
  const errors = parseTscOutput(run.stdout, tree);
23302
23424
  const config = configError(errors, scratch, tree);
23303
23425
  if (config !== undefined)
@@ -23343,6 +23465,8 @@ async function baseErrors(input, label, modules, files) {
23343
23465
  return { outcome: GREEN };
23344
23466
  if (run.kind === "interrupted")
23345
23467
  return { outcome: interrupted(label) };
23468
+ if (run.kind === "cannot-start")
23469
+ return { outcome: cannotStart(label, modules, run) };
23346
23470
  if (run.kind !== "read") {
23347
23471
  const why = run.kind === "threw" ? run.why : brokenBlockerText(label, run.run, run.said);
23348
23472
  activeOutput().warn(`\u26A0\uFE0F The ${label} could not check the files at ${input.base} (${why}); it reads no error as new.`);
@@ -23355,6 +23479,12 @@ function interrupted(label) {
23355
23479
  activeOutput().info(`\u23F9 The ${label} was interrupted by SIGINT: read as a stop, not as errors.`);
23356
23480
  return INTERRUPTED2;
23357
23481
  }
23482
+ function cannotStart(label, modules, run) {
23483
+ const tsc = join41(modules, ...TSC_BIN);
23484
+ const blocker = cannotStartBlockerText(label, tsc, run.run, run.said, scriptInterpreter(tsc));
23485
+ activeOutput().warn(`\u26A0\uFE0F ${blocker}`);
23486
+ return { ran: false, red: false, interrupted: false, cannotStart: true, blocker };
23487
+ }
23358
23488
  function filesToCheck(input, label) {
23359
23489
  if (!existsSync32(join41(input.checkout, "tsconfig.json"))) {
23360
23490
  activeOutput().info(`\uD83D\uDD0E ${label}: no tsconfig.json at the checkout root; nothing to type-check.`);
@@ -23381,10 +23511,12 @@ async function runTypeStep(input) {
23381
23511
  }
23382
23512
  if (head.kind === "interrupted")
23383
23513
  return interrupted(label);
23514
+ if (head.kind === "cannot-start")
23515
+ return cannotStart(label, modules, head);
23384
23516
  if (head.kind === "broken") {
23385
23517
  const blocker = brokenBlockerText(label, head.run, head.said);
23386
23518
  activeOutput().info(`\uD83D\uDD0E ${label}: ${blocker}`);
23387
- return { ran: true, red: true, interrupted: false, blocker };
23519
+ return { ran: true, red: true, interrupted: false, cannotStart: false, blocker };
23388
23520
  }
23389
23521
  const ran = `\uD83D\uDD0E ${label}: tsc over ${files.length} test file(s)`;
23390
23522
  if (head.errors.length === 0) {
@@ -23400,7 +23532,7 @@ async function runTypeStep(input) {
23400
23532
  activeOutput().info(` ${line}`);
23401
23533
  if (added.length === 0)
23402
23534
  return GREEN;
23403
- return { ran: true, red: true, interrupted: false, blocker: typeBlockerText(label, input.base, added) };
23535
+ return { ran: true, red: true, interrupted: false, cannotStart: false, blocker: typeBlockerText(label, input.base, added) };
23404
23536
  }
23405
23537
 
23406
23538
  // packages/rafa-run/src/start/task-gate-lines.ts
@@ -23454,6 +23586,20 @@ function typeCheckLines(recipe) {
23454
23586
  ];
23455
23587
  }
23456
23588
 
23589
+ // packages/rafa-run/src/start/tracker-line.ts
23590
+ import { isAbsolute as isAbsolute12 } from "path";
23591
+ var TRACKER_PROMPT_PREFIX = "The tracker holding this task's line is ";
23592
+ function trackerLines(trackerPath) {
23593
+ if (trackerPath === null)
23594
+ return [];
23595
+ if (!isAbsolute12(trackerPath)) {
23596
+ throw new Error(`The tracker path \`${trackerPath}\` is not absolute; the session may run in a worktree it does not resolve against.`);
23597
+ }
23598
+ return [
23599
+ `${TRACKER_PROMPT_PREFIX}\`${trackerPath}\`, by its absolute path, since a worktree checkout holds no copy of it: write any close-out notes there, indented below this task's line, never as a \`- [ ]\` line (the loop dispatches any such line) and never above this task's line (the loop marks it by its line number).`
23600
+ ];
23601
+ }
23602
+
23457
23603
  // packages/rafa-run/src/start/dispatch.ts
23458
23604
  function runTaskSession(prompt, flags, sessionId, settingSources, served2 = [], cwd, spawn) {
23459
23605
  const options = cwd === undefined ? {} : { cwd };
@@ -23468,10 +23614,11 @@ var NO_TASK_SECTIONS = { skills: "", lessons: "" };
23468
23614
  function sectionLines(sections) {
23469
23615
  return [sections.skills, sections.lessons, sections.inherited].filter((section2) => section2.trim().length > 0).flatMap((section2) => [section2, ""]);
23470
23616
  }
23471
- function buildTaskPrompt(taskText, promptContent, planText, knownMissing = [], blocker = null, sections = NO_TASK_SECTIONS, base2 = null, inherited = [], alwaysRun = [], typeCheck = null) {
23617
+ function buildTaskPrompt(taskText, promptContent, planText, knownMissing = [], blocker = null, sections = NO_TASK_SECTIONS, base2 = null, inherited = [], alwaysRun = [], typeCheck = null, trackerPath = null) {
23472
23618
  return [
23473
23619
  `Your scoped task is: ${taskText}`,
23474
23620
  "Consider tasks listed above this one in the plan checklist as completed. Do not re-evaluate or re-do them. Focus only on the scoped task.",
23621
+ ...trackerLines(trackerPath),
23475
23622
  ...blockerLines(blocker),
23476
23623
  ...baseLines(base2),
23477
23624
  ...alwaysRunLines(alwaysRun),
@@ -23520,7 +23667,7 @@ async function dispatchTask(options) {
23520
23667
  const resolution = options.serving === null ? EMPTY_RESOLUTION : resolveSessionTiers(options.serving);
23521
23668
  const task = taskInputFor(taskInfo, taskText, declaration, options.planContent);
23522
23669
  const handed = await handOut(options.handout, task, resolution, options.repoRoot);
23523
- const prompt = withStamp(buildTaskPrompt(taskText, docTaskPrompt(options.promptContent, { ...options, declaration, place: options.docTask }), injection.text, options.knownMissing, taskInfo.blocker ?? null, { skills: renderSkillsSection(handed.skills), lessons: renderLessonsSection(handed.lessons) }, options.base, options.inherited, options.alwaysRun, options.typeCheck ?? null));
23670
+ const prompt = withStamp(buildTaskPrompt(taskText, docTaskPrompt(options.promptContent, { ...options, declaration, place: options.docTask }), injection.text, options.knownMissing, taskInfo.blocker ?? null, { skills: renderSkillsSection(handed.skills), lessons: renderLessonsSection(handed.lessons) }, options.base, options.inherited, options.alwaysRun, options.typeCheck ?? null, options.trackerPath ?? null));
23524
23671
  const served2 = serveForSession(options.serving, resolution);
23525
23672
  const record = {
23526
23673
  taskText,
@@ -24001,16 +24148,18 @@ async function verifyAttempt(io, branch, timeoutMs, isLastAttempt) {
24001
24148
  const merge2 = await io.pulls.get(prNumber);
24002
24149
  return result.verdict === "none" ? handleNoChecks(io, branch, prNumber, merge2) : handleRedChecks(io, branch, prNumber, result.rows);
24003
24150
  }
24004
- function pollChecks(io, prNumber, timeoutMs) {
24151
+ async function pollChecks(io, prNumber, timeoutMs) {
24005
24152
  io.phases.ciStarted();
24006
24153
  activeOutput().info(`
24007
24154
  \u23F3 Waiting for CI on PR #${prNumber} (up to ${Math.round(timeoutMs / 60000)} min)...`);
24155
+ const headCommittedAtMs = headTimeOf(await io.pulls.get(prNumber));
24008
24156
  return waitForChecks({
24009
24157
  probe: async () => (await io.pulls.checks(prNumber)).rows,
24010
24158
  timeoutMs,
24011
24159
  intervalMs: CI_POLL_INTERVAL_MS,
24012
24160
  now: io.now,
24013
24161
  sleep: io.sleep,
24162
+ ...headCommittedAtMs === null ? {} : { headCommittedAtMs },
24014
24163
  onPoll: (rows, verdict, elapsedMs) => {
24015
24164
  const secs = Math.round(elapsedMs / 1000);
24016
24165
  activeOutput().info(` [${secs}s] ${verdict} \u2014 ${rows.length} check(s)`);
@@ -24906,12 +25055,19 @@ function createStartStaleDocs(options) {
24906
25055
  const redact = (text) => local(redactSecrets(text, secrets));
24907
25056
  const kept = new Map;
24908
25057
  let version = null;
25058
+ let newestRelease = null;
24909
25059
  let tracker = null;
24910
25060
  let docUpdatePlan;
24911
25061
  const versionOnce = () => {
24912
25062
  version ??= (options.readVersion ?? (() => readStaleDocsVersion(options)))();
24913
25063
  return version;
24914
25064
  };
25065
+ const newestReleaseOnce = () => {
25066
+ newestRelease ??= {
25067
+ value: (options.readNewestRelease ?? (() => newestRootRelease(createGitRunner(options.checkout))))()
25068
+ };
25069
+ return newestRelease.value;
25070
+ };
24915
25071
  const resolveOnce = () => {
24916
25072
  tracker ??= (options.resolve ?? resolveTracker)({
24917
25073
  config: options.config,
@@ -24939,7 +25095,12 @@ function createStartStaleDocs(options) {
24939
25095
  }
24940
25096
  };
24941
25097
  const addLine = async (entry) => {
24942
- const result = await addStaleDocLine({ tracker: await resolveOnce(), version: versionOnce(), entry });
25098
+ const result = await addStaleDocLine({
25099
+ tracker: await resolveOnce(),
25100
+ version: versionOnce(),
25101
+ entry,
25102
+ newestRelease: newestReleaseOnce()
25103
+ });
24943
25104
  const text = staleDocLineText(entry);
24944
25105
  if (result.action === "kept")
24945
25106
  kept.set(text, result.title);
@@ -25096,17 +25257,17 @@ function announceRunStepOnly(items) {
25096
25257
  // packages/rafa-run/src/start/suite-step.ts
25097
25258
  import { readFileSync as readFileSync38 } from "fs";
25098
25259
  import { constants as constants3 } from "os";
25099
- import { basename as basename13, join as join48 } from "path";
25260
+ import { basename as basename14, join as join48 } from "path";
25100
25261
 
25101
25262
  // packages/rafa-run/src/suite/baseline.ts
25102
25263
  import { existsSync as existsSync35, mkdirSync as mkdirSync6, readFileSync as readFileSync33, renameSync as renameSync2, writeFileSync as writeFileSync11 } from "fs";
25103
- import { basename as basename11, dirname as dirname16, join as join43 } from "path";
25264
+ import { basename as basename12, dirname as dirname16, join as join43 } from "path";
25104
25265
  var BASELINE_VERSION = 1;
25105
25266
  var BASELINE_FILE_PREFIX = "SUITE_BASELINE";
25106
25267
  var PLAN_FILE_NAME2 = /^PLAN(?:_TRACKER)?(-.+)?\.md$/;
25107
25268
  var JUNIT_READINGS = ["read", "missing", "unreadable"];
25108
25269
  function baselinePathFor(trackerPath) {
25109
- const match = PLAN_FILE_NAME2.exec(basename11(trackerPath));
25270
+ const match = PLAN_FILE_NAME2.exec(basename12(trackerPath));
25110
25271
  if (match === null) {
25111
25272
  throw new RangeError(`baselinePathFor: ${trackerPath} is not a PLAN or PLAN_TRACKER file`);
25112
25273
  }
@@ -25275,7 +25436,7 @@ async function readPlanOwns(options) {
25275
25436
 
25276
25437
  // packages/rafa-run/src/suite/scope.ts
25277
25438
  import { existsSync as existsSync36, readdirSync as readdirSync11, readFileSync as readFileSync34 } from "fs";
25278
- import { isAbsolute as isAbsolute12, join as join44, relative as relative15, sep as sep7 } from "path";
25439
+ import { isAbsolute as isAbsolute13, join as join44, relative as relative15, sep as sep7 } from "path";
25279
25440
  var BUNFIG_FILE = "bunfig.toml";
25280
25441
  var TEST_FILE_NAME = /[._](?:test|spec)\.(?:tsx?|jsx?|[cm][jt]s)$/;
25281
25442
  var DEPENDENCY_FOLDER = "node_modules";
@@ -25283,9 +25444,9 @@ function sortedUnique(paths) {
25283
25444
  return [...new Set(paths)].sort((a, b) => a.localeCompare(b));
25284
25445
  }
25285
25446
  function preloadPath(root, entry) {
25286
- const path3 = isAbsolute12(entry) ? relative15(root, entry).split(sep7).join("/") : entry;
25447
+ const path3 = isAbsolute13(entry) ? relative15(root, entry).split(sep7).join("/") : entry;
25287
25448
  const repoRelative2 = normaliseFolder(path3);
25288
- if (repoRelative2 === "" || isAbsolute12(repoRelative2))
25449
+ if (repoRelative2 === "" || isAbsolute13(repoRelative2))
25289
25450
  return null;
25290
25451
  return repoRelative2.split("/").includes("..") ? null : repoRelative2;
25291
25452
  }
@@ -25595,12 +25756,12 @@ function announceStepOnly(context, settling) {
25595
25756
 
25596
25757
  // packages/rafa-run/src/start/suite-stage-ledger.ts
25597
25758
  import { existsSync as existsSync38, mkdirSync as mkdirSync7, readFileSync as readFileSync35, renameSync as renameSync3, writeFileSync as writeFileSync12 } from "fs";
25598
- import { basename as basename12, dirname as dirname17, join as join47 } from "path";
25759
+ import { basename as basename13, dirname as dirname17, join as join47 } from "path";
25599
25760
  var STAGE_LEDGER_PREFIX = "SUITE_STAGES";
25600
25761
  var STAGE_LEDGER_VERSION = 1;
25601
25762
  function stageLedgerPathFor(trackerPath) {
25602
25763
  const baselinePath = baselinePathFor(trackerPath);
25603
- const name = basename12(baselinePath).replace(BASELINE_FILE_PREFIX, STAGE_LEDGER_PREFIX);
25764
+ const name = basename13(baselinePath).replace(BASELINE_FILE_PREFIX, STAGE_LEDGER_PREFIX);
25604
25765
  return join47(dirname17(baselinePath), name);
25605
25766
  }
25606
25767
  function isLedgerEntry(value) {
@@ -25635,7 +25796,7 @@ function readStageLedger(path3) {
25635
25796
  }
25636
25797
  if (typeof parsed !== "string")
25637
25798
  return parsed;
25638
- activeOutput().warn(`\u26A0\uFE0F ${basename12(path3)} does not read (${parsed}); every finished stage's step is taken again.`);
25799
+ activeOutput().warn(`\u26A0\uFE0F ${basename13(path3)} does not read (${parsed}); every finished stage's step is taken again.`);
25639
25800
  return [];
25640
25801
  }
25641
25802
  function writeStageLedger(path3, entries) {
@@ -25654,7 +25815,7 @@ function addToLedger(trackerPath, added) {
25654
25815
  try {
25655
25816
  writeStageLedger(path3, [...entries, ...fresh]);
25656
25817
  } catch (error) {
25657
- activeOutput().warn(`\u26A0\uFE0F Could not write ${basename12(path3)} (${messageOf(error)}); the next run takes these stage steps again.`);
25818
+ activeOutput().warn(`\u26A0\uFE0F Could not write ${basename13(path3)} (${messageOf(error)}); the next run takes these stage steps again.`);
25658
25819
  }
25659
25820
  }
25660
25821
  function sameStage(a, b) {
@@ -26001,6 +26162,9 @@ function typeCheckTask(context, seams, input) {
26001
26162
  const isInterrupted = context.isInterrupted ?? (() => false);
26002
26163
  return runTypeStep({ checkout: context.checkout, base: input.base, task: input.task, git: seams.git, runTypes: seams.runTypes, stopCode: SIGINT_EXIT_CODE, isInterrupted });
26003
26164
  }
26165
+ function isCheckUnstartable(settling) {
26166
+ return settling.types?.cannotStart === true;
26167
+ }
26004
26168
  async function taskDiffChecks(context, seams, input, result) {
26005
26169
  if (isStepInterrupted(context, result))
26006
26170
  return {};
@@ -26246,7 +26410,7 @@ function settleStep(context, seams, settling) {
26246
26410
  const tested = isRed(verdict) ? [blockerText(label, result, verdict, alone)] : [];
26247
26411
  const blocker = [...tested, ...checked].join(" ");
26248
26412
  activeOutput().error(`\u274C ${blocker}`);
26249
- const written = settling.repair === null ? null : writeRepairTask(context.trackerPath, blocker, { ...settling.repair, commit: readHead(seams.git) });
26413
+ const written = settling.repair === null || isCheckUnstartable(settling) ? null : writeRepairTask(context.trackerPath, blocker, { ...settling.repair, commit: readHead(seams.git) });
26250
26414
  if (written !== null)
26251
26415
  activeOutput().error(written.inserted ? ` A repair task (line ${written.line + 1}) is inserted, blocked on it.` : ` The repair task (line ${written.line + 1}) is marked blocked on it again.`);
26252
26416
  return { kind, step: step2, red: true, interrupted: false, blocker, blockedLine: written?.line ?? null, repairInserted: written?.inserted ?? false };
@@ -26290,13 +26454,13 @@ async function ensureBaseline(context) {
26290
26454
  const reading = readBaseline(path3);
26291
26455
  if (reading.state === "read" && !failedOutsideAnyCase(reading.baseline)) {
26292
26456
  const known = reading.baseline.failures.length;
26293
- activeOutput().info(`\uD83D\uDCCF Suite baseline reused from ${basename13(path3)} (${reading.baseline.recordedAt}): ${known} known failure(s).`);
26457
+ activeOutput().info(`\uD83D\uDCCF Suite baseline reused from ${basename14(path3)} (${reading.baseline.recordedAt}): ${known} known failure(s).`);
26294
26458
  return { baseline: reading.baseline, step: null, interrupted: false, halted: false };
26295
26459
  }
26296
26460
  if (reading.state === "unreadable")
26297
- activeOutput().warn(`\u26A0\uFE0F ${basename13(path3)} does not read (${reading.reason}); recording the baseline again.`);
26461
+ activeOutput().warn(`\u26A0\uFE0F ${basename14(path3)} does not read (${reading.reason}); recording the baseline again.`);
26298
26462
  if (reading.state === "read")
26299
- activeOutput().warn(storedOutsideCaseLine(basename13(path3), reading.baseline));
26463
+ activeOutput().warn(storedOutsideCaseLine(basename14(path3), reading.baseline));
26300
26464
  const commit = readHead(seams.git);
26301
26465
  const result = await runOne(context, seams, "baseline", {});
26302
26466
  const baseline = baselineOf(result, seams.now(), commit);
@@ -26312,7 +26476,7 @@ async function ensureBaseline(context) {
26312
26476
  try {
26313
26477
  writeBaseline(path3, baseline);
26314
26478
  } catch (error) {
26315
- activeOutput().warn(`\u26A0\uFE0F Could not write ${basename13(path3)} (${messageOf(error)}); the next run records the baseline again.`);
26479
+ activeOutput().warn(`\u26A0\uFE0F Could not write ${basename14(path3)} (${messageOf(error)}); the next run records the baseline again.`);
26316
26480
  }
26317
26481
  const outcome = settleStep(context, seams, settling);
26318
26482
  const covered = completeStages(readFileSync38(context.trackerPath, "utf8"));
@@ -27232,7 +27396,7 @@ function issueDraft2(stub, lines) {
27232
27396
  function canHoldIssue2(tracker) {
27233
27397
  return tracker !== null && tracker.openIssues !== undefined && tracker.edit !== undefined;
27234
27398
  }
27235
- function findIssue2(open, stub) {
27399
+ function findIssue(open, stub) {
27236
27400
  const marker = followUpsMarker(stub);
27237
27401
  const title = followUpsTitle(stub);
27238
27402
  return open.find((issue4) => issue4.body.includes(marker) && issue4.title === title);
@@ -27249,7 +27413,7 @@ async function fileOn(tracker, stub, lines) {
27249
27413
  const listed3 = await call2("listing the open bug issues", () => tracker.openIssues("bug"));
27250
27414
  if ("problem" in listed3)
27251
27415
  return { action: "failed", problem: listed3.problem };
27252
- const found = findIssue2(listed3.value, stub);
27416
+ const found = findIssue(listed3.value, stub);
27253
27417
  if (found === undefined) {
27254
27418
  const created = await call2("creating the follow-up issue", () => tracker.create(issueDraft2(stub, lines)));
27255
27419
  return "problem" in created ? { action: "failed", problem: created.problem } : { action: "created", title, ref: created.value, lines };
@@ -27609,9 +27773,13 @@ function fragmentNotesIn(checkout, fragment) {
27609
27773
  const reading = parseFragment(text);
27610
27774
  return reading.ok ? reading.fragment.notes : [];
27611
27775
  }
27612
- function runnerPullRequestBody(issue4, notes) {
27776
+ function closedIssues(issue4, closes) {
27777
+ return [...new Set([issue4, ...closes])];
27778
+ }
27779
+ function runnerPullRequestBody(issue4, closes, notes) {
27613
27780
  const section2 = notes.length === 0 ? [] : [RELEASE_NOTES_HEADING, "", ...notes, ""];
27614
- return [`Closes #${String(issue4)}`, "", ...section2, UNFINISHED_WRAP_UP_LINE].join(`
27781
+ const closing = closedIssues(issue4, closes).map((closed) => `Closes #${String(closed)}`);
27782
+ return [...closing, "", ...section2, UNFINISHED_WRAP_UP_LINE].join(`
27615
27783
  `);
27616
27784
  }
27617
27785
  function blocked2(branch, step2, detail) {
@@ -27630,11 +27798,11 @@ function dirtyDetail(entries) {
27630
27798
  ].join(`
27631
27799
  `);
27632
27800
  }
27633
- async function refreshAfterOpen(seams, issue4) {
27801
+ async function refreshAfterOpen(seams, issues) {
27634
27802
  try {
27635
- return await seams.refreshProject([issue4]);
27803
+ return await seams.refreshProject(issues);
27636
27804
  } catch (error) {
27637
- return [refreshFailedWarning(issue4, error)];
27805
+ return [refreshFailedWarning(issues[0] ?? 0, error)];
27638
27806
  }
27639
27807
  }
27640
27808
  async function openRunnerPullRequest(input, seams) {
@@ -27655,19 +27823,19 @@ async function openRunnerPullRequest(input, seams) {
27655
27823
  head: branch,
27656
27824
  base: input.base,
27657
27825
  title: pullRequestTitle(input.issue, input.planTitle),
27658
- body: runnerPullRequestBody(input.issue, input.notes)
27826
+ body: runnerPullRequestBody(input.issue, input.closes, input.notes)
27659
27827
  });
27660
27828
  } catch (error) {
27661
27829
  return blocked2(branch, "create", messageOf(error));
27662
27830
  }
27663
- return { kind: "opened", pull, warnings: await refreshAfterOpen(seams, input.issue) };
27831
+ return { kind: "opened", pull, warnings: await refreshAfterOpen(seams, closedIssues(input.issue, input.closes)) };
27664
27832
  }
27665
27833
 
27666
27834
  // packages/rafa-run/src/start/wrap-up.ts
27667
27835
  import { posix as posix7 } from "path";
27668
27836
 
27669
27837
  // packages/rafa-run/src/start/promoted-check.ts
27670
- import { isAbsolute as isAbsolute13, posix as posix6, relative as relative18 } from "path";
27838
+ import { isAbsolute as isAbsolute14, posix as posix6, relative as relative18 } from "path";
27671
27839
 
27672
27840
  // packages/rafa-run/src/start/promoted.ts
27673
27841
  var PROMOTED_BLOCK_KIND = "promoted";
@@ -27758,9 +27926,9 @@ function changedSince(git, head) {
27758
27926
  return { ok: true, head, paths: new Set(paths) };
27759
27927
  }
27760
27928
  function repoPath3(path4, repoRoot) {
27761
- const inside = isAbsolute13(path4) ? relative18(repoRoot, path4) : path4;
27929
+ const inside = isAbsolute14(path4) ? relative18(repoRoot, path4) : path4;
27762
27930
  const normal = posix6.normalize(inside.replaceAll("\\", "/"));
27763
- if (normal === "." || normal === ".." || normal.startsWith("../") || isAbsolute13(normal))
27931
+ if (normal === "." || normal === ".." || normal.startsWith("../") || isAbsolute14(normal))
27764
27932
  return null;
27765
27933
  return normal.replace(/^(\.\/)+/, "");
27766
27934
  }
@@ -27919,7 +28087,7 @@ function pullRequestNamingBullets(branch, provider) {
27919
28087
  return [
27920
28088
  "* Find the plan's issue number `<n>`: the plan below carries it in its `rafa:plan` block as `issue: <n>`.",
27921
28089
  `* If the plan carries no \`issue:\` field, read the number from the branch name (${branch}), which is the \`naming.branch\` template with the plan's stub, \`feat/rafa-<n>-<slug>\` by default.`,
27922
- '* Title the PR `rafa-<n>: <title>`, taking `<title>` from the plan title, e.g. "rafa-20: Add pull-request commands". Open the PR body with `Closes #<n>` \u2014 the GitHub issue number on its own, never `#rafa-<n>`, since the `rafa-` prefix is this project\'s naming convention and not a GitHub alias. If no number was found, title the PR with the plan title alone and write no closing line rather than inventing one.',
28090
+ "* Title the PR `rafa-<n>: <title>`, taking `<title>` from the plan title, e.g. \"rafa-20: Add pull-request commands\". Open the PR body with `Closes #<n>` \u2014 the GitHub issue number on its own, never `#rafa-<n>`, since the `rafa-` prefix is this project's naming convention and not a GitHub alias. Below `Closes #<n>`, write one more `Closes #<m>` line for each number `<m>` of the plan's `closes:` list, in its `rafa:plan` block, never writing a number twice and writing none when the plan has no `closes:` list. If no number was found, title the PR with the plan title alone and write no closing line rather than inventing one.",
27923
28091
  "* Create a concise yet descriptive PR description that summarizes the overall work done based on the completed plan and progress notes."
27924
28092
  ];
27925
28093
  }
@@ -28275,6 +28443,7 @@ function runnerPrInputFor(source) {
28275
28443
  branch: source.branch,
28276
28444
  base: source.base,
28277
28445
  issue: issue4,
28446
+ closes: parsePlan(source.planContent).header.closes,
28278
28447
  planTitle: planTitleIn(source.planContent, source.planStub),
28279
28448
  notes: source.notes
28280
28449
  };
@@ -28319,8 +28488,24 @@ function deliverySeamsIn(context) {
28319
28488
  };
28320
28489
  }
28321
28490
  // src/service-registry.ts
28491
+ function newestReleaseHere() {
28492
+ return newestRootRelease(createGitRunner(process.cwd()));
28493
+ }
28494
+ function addStaleDocLineWithRelease(readNewestRelease = newestReleaseHere) {
28495
+ return (options) => {
28496
+ if (options.newestRelease !== undefined)
28497
+ return addStaleDocLine(options);
28498
+ let newestRelease;
28499
+ try {
28500
+ newestRelease = readNewestRelease();
28501
+ } catch {
28502
+ newestRelease = undefined;
28503
+ }
28504
+ return addStaleDocLine({ ...options, newestRelease });
28505
+ };
28506
+ }
28322
28507
  var CORE_SERVICES = Object.freeze({
28323
- addStaleDocLine,
28508
+ addStaleDocLine: addStaleDocLineWithRelease(),
28324
28509
  endWithNextStep,
28325
28510
  pullRequestsIn: ghPullRequestsIn,
28326
28511
  readStaleDocsVersion,
@@ -28333,14 +28518,14 @@ function registerCoreServices() {
28333
28518
  return activeServices();
28334
28519
  }
28335
28520
  // src/plan.ts
28336
- import fs4 from "fs";
28521
+ import fs5 from "fs";
28337
28522
  import { homedir as homedir15 } from "os";
28338
- import path6 from "path";
28523
+ import path7 from "path";
28339
28524
  import { fileURLToPath as fileURLToPath5 } from "url";
28340
28525
 
28341
28526
  // src/commands/plan/bundled-check.ts
28342
28527
  import { readdirSync as readdirSync12, readFileSync as readFileSync40, realpathSync as realpathSync6, statSync as statSync10, writeFileSync as writeFileSync13 } from "fs";
28343
- import { basename as basename14, isAbsolute as isAbsolute14, join as join49, relative as relative19, resolve as resolve21, sep as sep8 } from "path";
28528
+ import { basename as basename15, isAbsolute as isAbsolute15, join as join49, relative as relative19, resolve as resolve21, sep as sep8 } from "path";
28344
28529
  var SOURCE_DIR2 = "src";
28345
28530
  var CODE_SPAN6 = /`([^`]+)`/gu;
28346
28531
  var PATH_LIKE = /^\S+$/u;
@@ -28376,7 +28561,7 @@ function skillHolding(bundle, realPath2) {
28376
28561
  if (bundle.skillsRoot === null)
28377
28562
  return null;
28378
28563
  const inside = relative19(bundle.skillsRoot, realPath2);
28379
- if (inside === "" || inside.startsWith("..") || isAbsolute14(inside))
28564
+ if (inside === "" || inside.startsWith("..") || isAbsolute15(inside))
28380
28565
  return null;
28381
28566
  const name = inside.split(sep8)[0] ?? "";
28382
28567
  return bundle.skills.includes(name) ? name : null;
@@ -28496,7 +28681,7 @@ function notePlanBundledEdits(repoRoot, generated, output = activeOutput()) {
28496
28681
  let written = [];
28497
28682
  if (file !== null) {
28498
28683
  try {
28499
- written = writeTierPins(resolve21(repoRoot, file), basename14(generated.planPath), edits);
28684
+ written = writeTierPins(resolve21(repoRoot, file), basename15(generated.planPath), edits);
28500
28685
  } catch (error) {
28501
28686
  output.warn(`${file}: the tier pins could not be written: ${messageOf(error)}`);
28502
28687
  written = null;
@@ -28708,7 +28893,7 @@ function createPlanBlockedOffer(seams = DEFAULT_BLOCKED_SEAMS) {
28708
28893
 
28709
28894
  // src/commands/plan/ready-offer.ts
28710
28895
  var runIssueReadyLazily = async (options) => {
28711
- const { runIssueReady: run } = await import("./ready-stwsr9ws.js");
28896
+ const { runIssueReady: run } = await import("./ready-3ccr65a2.js");
28712
28897
  return run(options);
28713
28898
  };
28714
28899
  var DEFAULT_OFFER_SEAMS = Object.freeze({});
@@ -28798,6 +28983,7 @@ async function resolveCreateSpec(options, seams = DEFAULT_ROUTE_SEAMS) {
28798
28983
  const makeReadyOffer = seams.makeReadyOffer ?? createPlanReadyOffer;
28799
28984
  const makeAlternativeOffer = seams.makeAlternativeOffer ?? createPlanBlockedOffer;
28800
28985
  const makeRefreshOffer = seams.makeRefreshOffer ?? createPlanRefreshOffer;
28986
+ const rules = source.request.kind === "spec" ? null : options.readRules?.() ?? null;
28801
28987
  return await resolve22({
28802
28988
  request: source.request,
28803
28989
  refresh: source.refresh,
@@ -28813,13 +28999,14 @@ async function resolveCreateSpec(options, seams = DEFAULT_ROUTE_SEAMS) {
28813
28999
  offerRefresh: makeRefreshOffer(),
28814
29000
  ...options.passOver === undefined ? {} : { passOver: options.passOver },
28815
29001
  ...options.branchTemplate === undefined ? {} : { branchTemplate: options.branchTemplate },
28816
- ...options.projectConfig === undefined ? {} : { projectConfig: options.projectConfig }
29002
+ ...options.projectConfig === undefined ? {} : { projectConfig: options.projectConfig },
29003
+ ...rules === null ? {} : { rules }
28817
29004
  });
28818
29005
  }
28819
29006
 
28820
29007
  // src/commands/plan/store-check.ts
28821
29008
  import { mkdirSync as mkdirSync8, readFileSync as readFileSync41, renameSync as renameSync4 } from "fs";
28822
- import { basename as basename15, dirname as dirname18, resolve as resolve22 } from "path";
29009
+ import { basename as basename16, dirname as dirname18, resolve as resolve22 } from "path";
28823
29010
  function readFileOrNull(path6) {
28824
29011
  return path6 !== null && isFile(path6) ? readFileSync41(path6, "utf8") : null;
28825
29012
  }
@@ -28828,7 +29015,7 @@ function checkStoreRules(file, markdown) {
28828
29015
  return findStoreRuleProblems({
28829
29016
  plan: markdown,
28830
29017
  prerequisites: readFileOrNull(prerequisitesPath),
28831
- prerequisitesName: basename15(prerequisitesPath ?? "PREREQUISITES-<stub>.md")
29018
+ prerequisitesName: basename16(prerequisitesPath ?? "PREREQUISITES-<stub>.md")
28832
29019
  });
28833
29020
  }
28834
29021
  function moveRejected(repoRoot, path6, output) {
@@ -28863,6 +29050,66 @@ function enforceStoreRules(repoRoot, generated, output = activeOutput()) {
28863
29050
  `));
28864
29051
  }
28865
29052
 
29053
+ // src/commands/plan/stretch-rules.ts
29054
+ import fs4 from "fs";
29055
+ import path6 from "path";
29056
+ var STRETCH_RULES_ENV = "RAFA_STRETCH_RULES";
29057
+ var STRETCH_RULES_REFUSAL_EXIT = 1;
29058
+ function missingRulesMessage(value) {
29059
+ return `${STRETCH_RULES_ENV}=${value} names no file; a stretch's rules are read from its rules.md,` + ` so write that file or unset ${STRETCH_RULES_ENV}`;
29060
+ }
29061
+ function notRulesFileMessage(value, what) {
29062
+ return `${STRETCH_RULES_ENV}=${value} names ${what}, not a file; point it at the stretch's rules.md`;
29063
+ }
29064
+ function unreadableRulesMessage(value, reason) {
29065
+ return `${STRETCH_RULES_ENV}=${value} could not be read: ${reason}`;
29066
+ }
29067
+ function describeEntry(stat) {
29068
+ return stat.isDirectory() ? "a directory" : "something other than a file";
29069
+ }
29070
+ function displayPath2(repoRoot, absolute) {
29071
+ const relative20 = path6.relative(repoRoot, absolute);
29072
+ return relative20 === "" || relative20.startsWith("..") || path6.isAbsolute(relative20) ? absolute : relative20;
29073
+ }
29074
+ function readStretchRules(env, repoRoot) {
29075
+ const value = env[STRETCH_RULES_ENV];
29076
+ if (value === undefined || value.trim() === "")
29077
+ return null;
29078
+ const absolute = path6.resolve(repoRoot, value);
29079
+ let stat;
29080
+ try {
29081
+ stat = fs4.statSync(absolute);
29082
+ } catch (error) {
29083
+ if (errorCode(error) === "ENOENT") {
29084
+ throw new CommandExit(STRETCH_RULES_REFUSAL_EXIT, missingRulesMessage(value));
29085
+ }
29086
+ throw new CommandExit(STRETCH_RULES_REFUSAL_EXIT, unreadableRulesMessage(value, messageOf(error)));
29087
+ }
29088
+ if (!stat.isFile()) {
29089
+ throw new CommandExit(STRETCH_RULES_REFUSAL_EXIT, notRulesFileMessage(value, describeEntry(stat)));
29090
+ }
29091
+ try {
29092
+ return Object.freeze({ path: displayPath2(repoRoot, absolute), text: fs4.readFileSync(absolute, "utf8") });
29093
+ } catch (error) {
29094
+ throw new CommandExit(STRETCH_RULES_REFUSAL_EXIT, unreadableRulesMessage(value, messageOf(error)));
29095
+ }
29096
+ }
29097
+ function stretchRulesReader(env, repoRoot) {
29098
+ let reading = null;
29099
+ return () => {
29100
+ if (reading === null) {
29101
+ try {
29102
+ reading = { ok: true, rules: readStretchRules(env, repoRoot) };
29103
+ } catch (error) {
29104
+ reading = { ok: false, error };
29105
+ }
29106
+ }
29107
+ if (reading.ok)
29108
+ return reading.rules;
29109
+ throw reading.error;
29110
+ };
29111
+ }
29112
+
28866
29113
  // src/notices/run.ts
28867
29114
  import { homedir as homedir14 } from "os";
28868
29115
 
@@ -28899,9 +29146,9 @@ function readDismissed(home) {
28899
29146
  }
28900
29147
  function writeDismissed(home, ids) {
28901
29148
  const all = NOTICE_IDS.filter((id2) => ids.includes(id2) || readDismissed(home).includes(id2));
28902
- const path6 = noticesPath(home);
28903
- mkdirSync9(dirname19(path6), { recursive: true });
28904
- writeFileSync14(path6, `${JSON.stringify({ dismissed: all }, null, 2)}
29149
+ const path7 = noticesPath(home);
29150
+ mkdirSync9(dirname19(path7), { recursive: true });
29151
+ writeFileSync14(path7, `${JSON.stringify({ dismissed: all }, null, 2)}
28905
29152
  `);
28906
29153
  }
28907
29154
  function pendingNotices(dismissed) {
@@ -28991,7 +29238,7 @@ async function requireNoticesAnswered(settingSources) {
28991
29238
  }
28992
29239
 
28993
29240
  // src/plan.ts
28994
- var __dirname2 = path6.dirname(fileURLToPath5(import.meta.url));
29241
+ var __dirname2 = path7.dirname(fileURLToPath5(import.meta.url));
28995
29242
  function argValue2(args, flag) {
28996
29243
  const hit = args.find((a) => a.startsWith(`${flag}=`));
28997
29244
  return hit?.slice(flag.length + 1);
@@ -29017,16 +29264,16 @@ ${trimmed.slice(-PROGRESS_CAP_CHARS)}` : trimmed;
29017
29264
  ].join(`
29018
29265
  `);
29019
29266
  }
29020
- var PLAN_FORMAT_SKILL = path6.join(BUNDLED_SKILLS_DIR, "dev-planner", "SKILL.md");
29267
+ var PLAN_FORMAT_SKILL = path7.join(BUNDLED_SKILLS_DIR, "dev-planner", "SKILL.md");
29021
29268
  function planFormatPath(moduleDir) {
29022
- return path6.join(moduleDir, PLAN_FORMAT_SKILL);
29269
+ return path7.join(moduleDir, PLAN_FORMAT_SKILL);
29023
29270
  }
29024
29271
  function readPlanFormat(moduleDir) {
29025
29272
  const skill = planFormatPath(moduleDir);
29026
- if (!fs4.existsSync(skill)) {
29273
+ if (!fs5.existsSync(skill)) {
29027
29274
  throw new Error(`The plan format is missing: no dev-planner SKILL.md at ${skill}`);
29028
29275
  }
29029
- return fs4.readFileSync(skill, "utf8");
29276
+ return fs5.readFileSync(skill, "utf8");
29030
29277
  }
29031
29278
  var FRONTMATTER2 = /^---\r?\n[\s\S]*?\r?\n---\r?\n(?:\r?\n)*/;
29032
29279
  function planFormatBody(skill) {
@@ -29150,7 +29397,7 @@ function buildPlanPrompt(template, planFormat, specContent, stub, planDir, progr
29150
29397
  return template.replace(SLOT_PATTERN3, (_slot, name) => values[name]);
29151
29398
  }
29152
29399
  function stubFromSpecPath(specPath) {
29153
- return path6.basename(specPath).replace(/\.md$/, "");
29400
+ return path7.basename(specPath).replace(/\.md$/, "");
29154
29401
  }
29155
29402
  function runBranchLine(planPath) {
29156
29403
  const stub = planStubFromPath(planPath);
@@ -29182,6 +29429,7 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
29182
29429
  dangerousAcceptStaleRefs
29183
29430
  } = config;
29184
29431
  const flags = readGateFlags(args);
29432
+ const readRules = stretchRulesReader(process.env, repoRoot);
29185
29433
  const resolved = await resolveAndClaim({
29186
29434
  resolve: (passOver) => resolveCreateSpec({
29187
29435
  args,
@@ -29192,12 +29440,13 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
29192
29440
  relationships: boardRelationships,
29193
29441
  passOver,
29194
29442
  branchTemplate: namingBranch,
29195
- projectConfig: config
29443
+ projectConfig: config,
29444
+ readRules
29196
29445
  }),
29197
29446
  prepare: async (spec) => {
29198
- const stub2 = argValue2(args, "--stub") ?? stubFromSpecPath(path6.resolve(repoRoot, spec.path));
29447
+ const stub2 = argValue2(args, "--stub") ?? stubFromSpecPath(path7.resolve(repoRoot, spec.path));
29199
29448
  const planFile2 = planFilePath(planDir, `PLAN-${stub2}.md`);
29200
- if (fs4.existsSync(path6.resolve(repoRoot, planFile2))) {
29449
+ if (fs5.existsSync(path7.resolve(repoRoot, planFile2))) {
29201
29450
  throw new CommandExit(1, `\u274C ${planFile2} already exists \u2014 remove it or pass a different --stub.`);
29202
29451
  }
29203
29452
  await checkCreateRefs({ spec, repoRoot, args, acceptStaleRefs: dangerousAcceptStaleRefs, roster });
@@ -29211,15 +29460,15 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
29211
29460
  return;
29212
29461
  const { stub } = resolved;
29213
29462
  const specRequest = resolved.spec.path;
29214
- const specPath = path6.resolve(repoRoot, specRequest);
29463
+ const specPath = path7.resolve(repoRoot, specRequest);
29215
29464
  const planFile = planFilePath(planDir, `PLAN-${stub}.md`);
29216
- const progressPath = path6.join(repoRoot, "progress.txt");
29217
- const progressContent = !args.includes("--no-progress") && fs4.existsSync(progressPath) ? fs4.readFileSync(progressPath, "utf8") : undefined;
29465
+ const progressPath = path7.join(repoRoot, "progress.txt");
29466
+ const progressContent = !args.includes("--no-progress") && fs5.existsSync(progressPath) ? fs5.readFileSync(progressPath, "utf8") : undefined;
29218
29467
  if (progressContent?.trim()) {
29219
29468
  activeOutput().info("\uD83D\uDCCE Including findings from progress.txt (disable with --no-progress).");
29220
29469
  }
29221
29470
  const epic = await readPlanEpicContext(resolved.spec, createGhRunner({ cwd: repoRoot }));
29222
- const template = fs4.readFileSync(path6.join(__dirname2, "plan-prompt.md"), "utf8");
29471
+ const template = fs5.readFileSync(path7.join(__dirname2, "plan-prompt.md"), "utf8");
29223
29472
  const planFormat = readPlanFormat(__dirname2);
29224
29473
  const skillIndex = readPlanSkillIndex(repoRoot, home, config, fileURLToPath5(import.meta.url));
29225
29474
  const planner = registry.resolve("planner", "claude").create({
@@ -29237,7 +29486,7 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
29237
29486
  comment: flags.comment
29238
29487
  };
29239
29488
  await requireNoticesAnswered(settingSources);
29240
- activeOutput().info(`\uD83D\uDCDD Generating ${planFile} from ${path6.basename(specPath)}...`);
29489
+ activeOutput().info(`\uD83D\uDCDD Generating ${planFile} from ${path7.basename(specPath)}...`);
29241
29490
  const answered = await generateOrExit(planner, { specPath: specRequest, stub }, gate, flags.skipReview);
29242
29491
  enforceStoreRules(repoRoot, answered);
29243
29492
  const generated = notePlanBundledEdits(repoRoot, answered);
@@ -29257,9 +29506,9 @@ async function plan(args, repoRoot, roster, registry = CORE_ADAPTER_REGISTRY) {
29257
29506
  }
29258
29507
  }
29259
29508
  // src/start.ts
29260
- import fs5 from "fs";
29509
+ import fs6 from "fs";
29261
29510
  import { homedir as homedir16 } from "os";
29262
- import path7 from "path";
29511
+ import path8 from "path";
29263
29512
  import { fileURLToPath as fileURLToPath6 } from "url";
29264
29513
 
29265
29514
  // src/utils/schedule.ts
@@ -29292,7 +29541,7 @@ async function deferUntil(startAt, now = new Date, sleep = sleepFor) {
29292
29541
  }
29293
29542
 
29294
29543
  // src/start.ts
29295
- var __dirname3 = path7.dirname(fileURLToPath6(import.meta.url));
29544
+ var __dirname3 = path8.dirname(fileURLToPath6(import.meta.url));
29296
29545
  var interrupted2 = false;
29297
29546
  async function start(args, repoRoot) {
29298
29547
  refuseDetachedRun(args);
@@ -29319,10 +29568,10 @@ async function start(args, repoRoot) {
29319
29568
  if (startAt)
29320
29569
  await deferUntil(startAt);
29321
29570
  const planPath = resolvePlanPath(repoRoot, runConfig.config.planDir, plan2);
29322
- const rootPromptPath = path7.join(repoRoot, "PROMPT.md");
29323
- const promptPath = fs5.existsSync(rootPromptPath) ? rootPromptPath : path7.join(__dirname3, "PROMPT.md");
29571
+ const rootPromptPath = path8.join(repoRoot, "PROMPT.md");
29572
+ const promptPath = fs6.existsSync(rootPromptPath) ? rootPromptPath : path8.join(__dirname3, "PROMPT.md");
29324
29573
  const trackerPath = trackerPathFor(planPath);
29325
- if (!fs5.existsSync(planPath)) {
29574
+ if (!fs6.existsSync(planPath)) {
29326
29575
  throw new CommandExit(1, `\u274C Plan file not found: ${planPath}`);
29327
29576
  }
29328
29577
  const planStub = planStubFromPath(planPath);
@@ -29353,8 +29602,8 @@ async function start(args, repoRoot) {
29353
29602
  return;
29354
29603
  };
29355
29604
  try {
29356
- const planContent = fs5.readFileSync(planPath, "utf8");
29357
- const promptContent = fs5.readFileSync(promptPath, "utf8");
29605
+ const planContent = fs6.readFileSync(planPath, "utf8");
29606
+ const promptContent = fs6.readFileSync(promptPath, "utf8");
29358
29607
  const injectSource = injectSourceLabel(runConfig);
29359
29608
  announceRunDirs({ projectRoot: repoRoot, checkout });
29360
29609
  activeOutput().info(`\uD83E\uDDED Task sessions are handed the plan as \`${injectMode}\` (${injectSource}); the wrap-up is handed all of it.`);
@@ -29430,11 +29679,11 @@ async function start(args, repoRoot) {
29430
29679
  previousNeeded: continueRun.directive === null ? null : readPreviousDecisionNeeded(repoRoot, runPlace)
29431
29680
  });
29432
29681
  decisionsAtEnd = decisions.atRunEnd;
29433
- if (!fs5.existsSync(trackerPath)) {
29434
- activeOutput().info(`\uD83D\uDCCB Creating new plan tracker at ${path7.basename(trackerPath)}...`);
29435
- fs5.copyFileSync(planPath, trackerPath);
29682
+ if (!fs6.existsSync(trackerPath)) {
29683
+ activeOutput().info(`\uD83D\uDCCB Creating new plan tracker at ${path8.basename(trackerPath)}...`);
29684
+ fs6.copyFileSync(planPath, trackerPath);
29436
29685
  } else {
29437
- activeOutput().info(`\uD83D\uDCCB Resuming from existing ${path7.basename(trackerPath)}...`);
29686
+ activeOutput().info(`\uD83D\uDCCB Resuming from existing ${path8.basename(trackerPath)}...`);
29438
29687
  }
29439
29688
  process.on("SIGINT", () => {
29440
29689
  interrupted2 = true;
@@ -29446,7 +29695,7 @@ async function start(args, repoRoot) {
29446
29695
  await holdWhilePaused({ repoRoot, sessionId: session.id, isInterrupted: () => interrupted2 });
29447
29696
  if (interrupted2)
29448
29697
  break;
29449
- const trackerContent = fs5.readFileSync(trackerPath, "utf8");
29698
+ const trackerContent = fs6.readFileSync(trackerPath, "utf8");
29450
29699
  const taskInfo = findNextTask(trackerContent, { skipLines: decisions.skipLines(trackerContent) });
29451
29700
  const passedOver = taskInfo ? [] : decisions.atPlanEnd(trackerContent);
29452
29701
  if (await decisions.atFirstTask(taskInfo, trackerContent))
@@ -29515,6 +29764,7 @@ async function start(args, repoRoot) {
29515
29764
  serving,
29516
29765
  handout,
29517
29766
  base: base2,
29767
+ trackerPath,
29518
29768
  guard: { expected: expected2, trackerPath },
29519
29769
  docTask: { planStub, prBase: runConfig.config.prBase }
29520
29770
  });