@mutmutco/cli 3.84.0 → 3.85.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.
Files changed (2) hide show
  1. package/dist/main.cjs +153 -91
  2. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -3415,7 +3415,7 @@ function useColor() {
3415
3415
  var program = new Command();
3416
3416
 
3417
3417
  // src/index.ts
3418
- var import_promises10 = require("node:fs/promises");
3418
+ var import_promises11 = require("node:fs/promises");
3419
3419
  var import_node_fs36 = require("node:fs");
3420
3420
  var import_node_child_process16 = require("node:child_process");
3421
3421
 
@@ -3982,10 +3982,10 @@ var import_node_fs4 = require("node:fs");
3982
3982
  var injectedStdin;
3983
3983
  function stdinHasPipedInput(statFd = () => (0, import_node_fs4.fstatSync)(0), getIsTTY = () => process.stdin.isTTY) {
3984
3984
  try {
3985
- const stat2 = statFd();
3986
- if (stat2.isFIFO() || stat2.isFile()) return true;
3987
- if (stat2.isCharacterDevice()) return false;
3988
- if (stat2.isSocket()) return false;
3985
+ const stat3 = statFd();
3986
+ if (stat3.isFIFO() || stat3.isFile()) return true;
3987
+ if (stat3.isCharacterDevice()) return false;
3988
+ if (stat3.isSocket()) return false;
3989
3989
  if (getIsTTY() === true) return false;
3990
3990
  return true;
3991
3991
  } catch {
@@ -4502,9 +4502,9 @@ function trackedPathStatus(c, realPath, repoAnchor) {
4502
4502
  return null;
4503
4503
  }
4504
4504
  }
4505
- function rootScratchDirSnapshot(root, readdir2, stat2) {
4505
+ function rootScratchDirSnapshot(root, readdir2, stat3) {
4506
4506
  try {
4507
- const rootStat = stat2(root);
4507
+ const rootStat = stat3(root);
4508
4508
  let mtimeMs = rootStat.mtimeMs;
4509
4509
  let bytes = 0;
4510
4510
  const stack = [root];
@@ -4518,7 +4518,7 @@ function rootScratchDirSnapshot(root, readdir2, stat2) {
4518
4518
  return null;
4519
4519
  } catch {
4520
4520
  }
4521
- const st = stat2(child2);
4521
+ const st = stat3(child2);
4522
4522
  mtimeMs = Math.max(mtimeMs, st.mtimeMs);
4523
4523
  if (ent.isDirectory()) stack.push(child2);
4524
4524
  else if (ent.isFile()) bytes += st.size;
@@ -4531,7 +4531,7 @@ function rootScratchDirSnapshot(root, readdir2, stat2) {
4531
4531
  }
4532
4532
  function collectScratchSnapshot(repoRoot2, deps = {}) {
4533
4533
  const readdir2 = deps.readdir ?? import_node_fs6.readdirSync;
4534
- const stat2 = deps.stat ?? import_node_fs6.statSync;
4534
+ const stat3 = deps.stat ?? import_node_fs6.statSync;
4535
4535
  const plansRoot = (0, import_node_path4.join)(repoRoot2, "plans");
4536
4536
  const rootScratchFiles = [];
4537
4537
  try {
@@ -4544,10 +4544,10 @@ function collectScratchSnapshot(repoRoot2, deps = {}) {
4544
4544
  const full = (0, import_node_path4.join)(repoRoot2, ent.name);
4545
4545
  try {
4546
4546
  if (isDir) {
4547
- const snap = rootScratchDirSnapshot(full, readdir2, stat2);
4547
+ const snap = rootScratchDirSnapshot(full, readdir2, stat3);
4548
4548
  if (snap) rootScratchFiles.push({ path: full, dir: repoRoot2, name: ent.name, mtimeMs: snap.mtimeMs, bytes: snap.bytes, kind: "dir" });
4549
4549
  } else {
4550
- const st = stat2(full);
4550
+ const st = stat3(full);
4551
4551
  rootScratchFiles.push({ path: full, dir: repoRoot2, name: ent.name, mtimeMs: st.mtimeMs, bytes: st.size, kind: "file" });
4552
4552
  }
4553
4553
  } catch {
@@ -4561,7 +4561,7 @@ function collectScratchSnapshot(repoRoot2, deps = {}) {
4561
4561
  if (!ent.isFile() || !ent.name.endsWith(".md")) continue;
4562
4562
  const full = (0, import_node_path4.join)(plansRoot, ent.name);
4563
4563
  try {
4564
- const st = stat2(full);
4564
+ const st = stat3(full);
4565
4565
  planMdFiles.push({ path: full, dir: plansRoot, name: ent.name, mtimeMs: st.mtimeMs, bytes: st.size, kind: "file" });
4566
4566
  } catch {
4567
4567
  }
@@ -7978,6 +7978,7 @@ function parseVerifyBroker(stdout) {
7978
7978
 
7979
7979
  // src/train-apply.ts
7980
7980
  var import_node_fs13 = require("node:fs");
7981
+ var import_promises2 = require("node:fs/promises");
7981
7982
  var import_node_path12 = require("node:path");
7982
7983
  function resolveDeployModel2(meta, repo) {
7983
7984
  const m = meta?.deployModel;
@@ -9015,35 +9016,41 @@ async function executeMergeToMain(deps, sourceRef, mergeLabel, tolerated, predic
9015
9016
  }
9016
9017
  }
9017
9018
  async function probeFoldFailureState(deps) {
9018
- const branch = await currentBranch(deps);
9019
+ const branch = await currentBranch(deps).catch(() => "");
9019
9020
  const mergeInProgress = await deps.run("git", ["rev-parse", "-q", "--verify", "MERGE_HEAD"]).then(() => true).catch(() => false);
9020
- const dirty = porcelainHasBlockingChanges(await deps.run("git", ["status", "--porcelain"]).catch(() => ""));
9021
+ const headSha = await deps.run("git", ["rev-parse", "HEAD"]).then(clean2).catch(() => "");
9022
+ const status = await deps.run("git", ["status", "--porcelain=v1"]).then(clean2).catch((e) => `(unavailable: ${e instanceof Error ? e.message : String(e)})`);
9021
9023
  const mainSha = await deps.run("git", ["rev-parse", "main"]).then(clean2).catch(() => "");
9022
9024
  const originMainSha = await deps.run("git", ["rev-parse", "origin/main"]).then(clean2).catch(() => "");
9023
9025
  const originIsAncestorOfMain = Boolean(mainSha) && Boolean(originMainSha) ? await deps.run("git", ["merge-base", "--is-ancestor", "origin/main", "main"]).then(() => true).catch(() => false) : false;
9024
- return { branch, mergeInProgress, dirty, mainSha, originMainSha, originIsAncestorOfMain };
9026
+ return { branch, mergeInProgress, headSha, status, mainSha, originMainSha, originIsAncestorOfMain };
9025
9027
  }
9026
9028
  function shaLabel(sha) {
9027
9029
  return sha ? sha.slice(0, 7) : "(unknown)";
9028
9030
  }
9029
- async function finishFoldAutoRestore(deps, causeMessage, startBranch, what) {
9031
+ async function finishFoldAutoRestore(deps, causeMessage, startBranch, preFoldMainSha, resumeCommand, what) {
9030
9032
  try {
9031
9033
  await deps.run("git", ["checkout", startBranch]);
9032
9034
  } catch (e) {
9033
- return new Error(
9035
+ return foldFailureGuidance(
9034
9036
  `${causeMessage}
9035
9037
 
9036
- fold failed; ${what}, but returning to ${startBranch} afterwards failed: ${e instanceof Error ? e.message : String(e)}. Finish manually: git checkout ${startBranch}`
9038
+ fold failed; ${what}, but returning to ${startBranch} afterwards failed: ${e instanceof Error ? e.message : String(e)}.`,
9039
+ await probeFoldFailureState(deps),
9040
+ startBranch,
9041
+ preFoldMainSha,
9042
+ `git checkout ${startBranch}`,
9043
+ resumeCommand
9037
9044
  );
9038
9045
  }
9039
9046
  return new Error(
9040
9047
  `${causeMessage}
9041
9048
 
9042
- fold failed; ${what} and the checkout was returned to ${startBranch}. Nothing was pushed to origin and no tag was created \u2014 rerun the release once the fold issue above is fixed.`
9049
+ fold failed; ${what} and the checkout was returned to ${startBranch}. Nothing was pushed to origin and no tag was created \u2014 rerun with \`${resumeCommand}\` once the fold issue above is fixed.`
9043
9050
  );
9044
9051
  }
9045
- function foldFailureGuidance(causeMessage, probe, startBranch, preFoldMainSha) {
9046
- const steps = preFoldMainSha ? [
9052
+ function foldFailureGuidance(causeMessage, probe, startBranch, preFoldMainSha, nextCommand, resumeCommand = "mmi-cli release --apply", foldStarted = true) {
9053
+ const steps = !foldStarted ? [` 1. Resolve or wait out the git index lock`, ` 2. ${resumeCommand}`] : nextCommand === "git merge --abort" ? [` 1. git merge --abort`, ` 2. git checkout ${startBranch}`, ` 3. ${resumeCommand}`] : nextCommand === `git checkout ${startBranch}` ? [` 1. git checkout ${startBranch}`, ` 2. ${resumeCommand}`] : preFoldMainSha ? [
9047
9054
  ` 1. git status # inspect what is actually there`,
9048
9055
  ` 2. git log --oneline ${preFoldMainSha}..main # commits beyond the pre-fold main \u2014 confirm they are only this run's merge/fold attempt`,
9049
9056
  ` 3. git checkout main && git reset --hard ${preFoldMainSha} # back to the exact commit the fold built on`,
@@ -9053,14 +9060,60 @@ function foldFailureGuidance(causeMessage, probe, startBranch, preFoldMainSha) {
9053
9060
  ` 2. git log --oneline origin/main..main # this run never committed to main (it failed before the merge) \u2014 any commits here predate this run; preserve them`,
9054
9061
  ` 3. git checkout ${startBranch}`
9055
9062
  ];
9063
+ const exactNextCommand = nextCommand ?? "git status";
9056
9064
  return new Error(
9057
9065
  `${causeMessage}
9058
9066
 
9059
- fold failed leaving the checkout in a state train --apply will not auto-restore (branch=${probe.branch || "(unknown)"}, dirty-working-tree=${probe.dirty}, main=${shaLabel(probe.mainSha)}, origin/main=${shaLabel(probe.originMainSha)}, pre-fold main=${preFoldMainSha ? shaLabel(preFoldMainSha) : "not captured"}, origin/main is${probe.originIsAncestorOfMain ? "" : " NOT"} an ancestor of main). Nothing was pushed to origin and no tag was created.
9067
+ fold failed leaving the checkout in a state train --apply will not auto-restore (branch=${probe.branch || "(unknown)"}, main=${shaLabel(probe.mainSha)}, origin/main=${shaLabel(probe.originMainSha)}, pre-fold main=${preFoldMainSha ? shaLabel(preFoldMainSha) : "not captured"}, origin/main is${probe.originIsAncestorOfMain ? "" : " NOT"} an ancestor of main). Nothing was pushed to origin and no tag was created.
9068
+ Resumable state:
9069
+ current branch: ${probe.branch || "(unknown)"}
9070
+ HEAD: ${probe.headSha || "(unknown)"}
9071
+ pre-fold main: ${preFoldMainSha || "(not captured)"}
9072
+ index/worktree status:
9073
+ ${probe.status || "(clean)"}
9074
+ Next command: ${exactNextCommand}
9075
+ Resume command after the checkout is clean: ${resumeCommand}
9060
9076
  Recovery sequence:
9061
9077
  ${steps.join("\n")}`
9062
9078
  );
9063
9079
  }
9080
+ var GIT_INDEX_LOCK_WAIT_MS = 5e3;
9081
+ var GIT_INDEX_LOCK_POLL_MS = 100;
9082
+ async function waitForFoldIndexLock(deps, startBranch, resumeCommand) {
9083
+ const preFoldMainSha = await deps.run("git", ["rev-parse", "main"]).then(clean2).catch(() => void 0);
9084
+ const lockPath = requireValue(clean2(await deps.run("git", ["rev-parse", "--git-path", "index.lock"])), "git index lock path");
9085
+ const now = deps.now ?? Date.now;
9086
+ const sleep3 = resolveSleep(deps);
9087
+ const deadline = now() + GIT_INDEX_LOCK_WAIT_MS;
9088
+ for (; ; ) {
9089
+ try {
9090
+ await (0, import_promises2.stat)(lockPath);
9091
+ } catch (e) {
9092
+ if (e.code === "ENOENT") return;
9093
+ throw foldFailureGuidance(
9094
+ `release fold could not inspect git index lock ${lockPath}: ${e instanceof Error ? e.message : String(e)}`,
9095
+ await probeFoldFailureState(deps),
9096
+ startBranch,
9097
+ preFoldMainSha,
9098
+ resumeCommand,
9099
+ resumeCommand,
9100
+ false
9101
+ );
9102
+ }
9103
+ if (now() >= deadline) {
9104
+ throw foldFailureGuidance(
9105
+ `release fold waited ${GIT_INDEX_LOCK_WAIT_MS}ms for active git index lock ${lockPath}; it is still held. The fold did not start. Do not delete the lock; let its owning git process finish.`,
9106
+ await probeFoldFailureState(deps),
9107
+ startBranch,
9108
+ preFoldMainSha,
9109
+ resumeCommand,
9110
+ resumeCommand,
9111
+ false
9112
+ );
9113
+ }
9114
+ await sleep3(Math.min(GIT_INDEX_LOCK_POLL_MS, Math.max(1, deadline - now())));
9115
+ }
9116
+ }
9064
9117
  async function recoverFailedRcand(deps, cause, preRcSha) {
9065
9118
  const causeMessage = cause instanceof Error ? cause.message : String(cause);
9066
9119
  const branch = await currentBranch(deps).catch(() => "");
@@ -9104,23 +9157,25 @@ Recovery sequence:
9104
9157
  3. mmi-cli rcand --apply`
9105
9158
  );
9106
9159
  }
9107
- async function recoverFailedFold(deps, cause, startBranch, preFoldMainSha) {
9160
+ async function recoverFailedFold(deps, cause, startBranch, preFoldMainSha, resumeCommand) {
9108
9161
  const causeMessage = cause instanceof Error ? cause.message : String(cause);
9109
9162
  const probe = await probeFoldFailureState(deps);
9110
9163
  if (probe.mergeInProgress) {
9111
9164
  try {
9112
9165
  await deps.run("git", ["merge", "--abort"]);
9113
9166
  } catch (e) {
9114
- return new Error(
9167
+ return foldFailureGuidance(
9115
9168
  `${causeMessage}
9116
9169
 
9117
- fold failed with an in-progress merge left on ${probe.branch || "(unknown branch)"}; automatic \`git merge --abort\` failed: ${e instanceof Error ? e.message : String(e)}. Nothing was pushed to origin and no tag was created.
9118
- Recovery sequence:
9119
- 1. git merge --abort
9120
- 2. git checkout ${startBranch}`
9170
+ fold failed with an in-progress merge; automatic \`git merge --abort\` failed: ${e instanceof Error ? e.message : String(e)}.`,
9171
+ await probeFoldFailureState(deps),
9172
+ startBranch,
9173
+ preFoldMainSha,
9174
+ "git merge --abort",
9175
+ resumeCommand
9121
9176
  );
9122
9177
  }
9123
- return finishFoldAutoRestore(deps, causeMessage, startBranch, "the in-progress merge was aborted");
9178
+ return finishFoldAutoRestore(deps, causeMessage, startBranch, preFoldMainSha, resumeCommand, "the in-progress merge was aborted");
9124
9179
  }
9125
9180
  if (probe.branch === "main" && preFoldMainSha) {
9126
9181
  const mainDescendsFromPreFold = await deps.run("git", ["merge-base", "--is-ancestor", preFoldMainSha, "main"]).then(() => true).catch(() => false);
@@ -9128,13 +9183,15 @@ Recovery sequence:
9128
9183
  try {
9129
9184
  await deps.run("git", ["reset", "--hard", preFoldMainSha]);
9130
9185
  } catch (e) {
9131
- return new Error(
9186
+ return foldFailureGuidance(
9132
9187
  `${causeMessage}
9133
9188
 
9134
- fold failed after this run's merge/fold committed locally on main (now ${shaLabel(probe.mainSha)}, unpushed, built on the pre-fold main ${shaLabel(preFoldMainSha)}); automatic \`git reset --hard ${shaLabel(preFoldMainSha)}\` failed: ${e instanceof Error ? e.message : String(e)}. Nothing was pushed to origin and no tag was created.
9135
- Recovery sequence:
9136
- 1. git reset --hard ${preFoldMainSha}
9137
- 2. git checkout ${startBranch}`
9189
+ fold failed after this run's merge/fold committed locally on main; automatic \`git reset --hard ${shaLabel(preFoldMainSha)}\` failed: ${e instanceof Error ? e.message : String(e)}.`,
9190
+ await probeFoldFailureState(deps),
9191
+ startBranch,
9192
+ preFoldMainSha,
9193
+ `git reset --hard ${preFoldMainSha}`,
9194
+ resumeCommand
9138
9195
  );
9139
9196
  }
9140
9197
  const aheadNote = probe.originMainSha && preFoldMainSha !== probe.originMainSha ? `; local main carried commit(s) origin/main (${shaLabel(probe.originMainSha)}) does not have \u2014 they were preserved` : "";
@@ -9142,17 +9199,20 @@ Recovery sequence:
9142
9199
  deps,
9143
9200
  causeMessage,
9144
9201
  startBranch,
9202
+ preFoldMainSha,
9203
+ resumeCommand,
9145
9204
  `local main was reset to its pre-fold state ${shaLabel(preFoldMainSha)} (discarding only this run's merge/fold commit(s) at ${shaLabel(probe.mainSha)})${aheadNote}`
9146
9205
  );
9147
9206
  }
9148
9207
  }
9149
- return foldFailureGuidance(causeMessage, probe, startBranch, preFoldMainSha);
9208
+ return foldFailureGuidance(causeMessage, probe, startBranch, preFoldMainSha, void 0, resumeCommand);
9150
9209
  }
9151
- async function runFoldStage(deps, startBranch, preFold, fn) {
9210
+ async function runFoldStage(deps, startBranch, preFold, resumeCommand, fn) {
9211
+ await waitForFoldIndexLock(deps, startBranch, resumeCommand);
9152
9212
  try {
9153
9213
  return await fn();
9154
9214
  } catch (e) {
9155
- throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha);
9215
+ throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha, resumeCommand);
9156
9216
  }
9157
9217
  }
9158
9218
  async function verifyPublishDryRun(deps, ctx, meta, deployModel) {
@@ -9211,30 +9271,31 @@ async function gateTrueMergeCommit(deps, ctx, tag, releaseSha, requiredChecks) {
9211
9271
  }
9212
9272
  }
9213
9273
  async function completeMainRelease(deps, ctx, meta, deployModel, watch, options, tag, releaseSha, startBranch, preFold, tagProbe) {
9274
+ const resumeCommand = options.dev ? "mmi-cli release --dev --apply" : "mmi-cli release --apply";
9214
9275
  try {
9215
9276
  await verifyPublishDryRun(deps, ctx, meta, deployModel);
9216
9277
  } catch (e) {
9217
- throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha);
9278
+ throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha, resumeCommand);
9218
9279
  }
9219
9280
  let requiredChecks;
9220
9281
  try {
9221
9282
  requiredChecks = await discoverRequiredCheckContexts(deps, ctx, "main");
9222
9283
  } catch (e) {
9223
- throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha);
9284
+ throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha, resumeCommand);
9224
9285
  }
9225
9286
  let trueMergeGateNote;
9226
9287
  if (preFold.isTrueMerge) {
9227
9288
  try {
9228
9289
  trueMergeGateNote = await gateTrueMergeCommit(deps, ctx, tag, releaseSha, requiredChecks);
9229
9290
  } catch (e) {
9230
- throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha);
9291
+ throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha, resumeCommand);
9231
9292
  }
9232
9293
  }
9233
9294
  let tagPush;
9234
9295
  try {
9235
9296
  tagPush = await ensureTagPushed(deps, tag, releaseSha, tagProbe, ctx.repo);
9236
9297
  } catch (e) {
9237
- throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha);
9298
+ throw await recoverFailedFold(deps, e, startBranch, preFold.mainSha, resumeCommand);
9238
9299
  }
9239
9300
  const tagPushSince = (deps.now ?? Date.now)();
9240
9301
  let checks;
@@ -9640,7 +9701,8 @@ async function runTrainApplyPipeline(mode, input) {
9640
9701
  );
9641
9702
  const tagProbe2 = { remoteSha: await probeRemoteTag(deps, tag2) };
9642
9703
  const preFold2 = {};
9643
- const { versionFold: versionFold2, releaseSha: releaseSha2 } = await runFoldStage(deps, "development", preFold2, async () => {
9704
+ const resumeCommand = options.dev ? "mmi-cli release --dev --apply" : "mmi-cli release --apply";
9705
+ const { versionFold: versionFold2, releaseSha: releaseSha2 } = await runFoldStage(deps, "development", preFold2, resumeCommand, async () => {
9644
9706
  await executeMergeToMain(deps, "development", "development -> main", tolerated2, predicted2, preFold2);
9645
9707
  const versionFold3 = await foldReleaseVersion(deps, deployModel2, tag2, foldPaths2);
9646
9708
  const releaseSha3 = requireValue(clean2(await deps.run("git", ["rev-parse", "main"])), "release sha");
@@ -9725,7 +9787,7 @@ async function runTrainApplyPipeline(mode, input) {
9725
9787
  const tag = requireValue(clean2(await deps.run("node", ["scripts/next-version.mjs", "release"])), "release tag");
9726
9788
  const tagProbe = { remoteSha: await probeRemoteTag(deps, tag) };
9727
9789
  const preFold = {};
9728
- const { versionFold, releaseSha } = await runFoldStage(deps, "rc", preFold, async () => {
9790
+ const { versionFold, releaseSha } = await runFoldStage(deps, "rc", preFold, "mmi-cli release --apply", async () => {
9729
9791
  await executeMergeToMain(deps, "rc", "rc -> main", tolerated, predicted, preFold);
9730
9792
  const versionFold2 = await foldReleaseVersion(deps, deployModel, tag, foldPaths);
9731
9793
  const releaseSha2 = requireValue(clean2(await deps.run("git", ["rev-parse", "main"])), "release sha");
@@ -12203,7 +12265,7 @@ var import_node_child_process6 = require("node:child_process");
12203
12265
  var import_node_os4 = require("node:os");
12204
12266
 
12205
12267
  // src/gh-create.ts
12206
- var import_promises2 = require("node:fs/promises");
12268
+ var import_promises3 = require("node:fs/promises");
12207
12269
  var import_node_os3 = require("node:os");
12208
12270
  var import_node_path14 = require("node:path");
12209
12271
  var import_node_crypto3 = require("node:crypto");
@@ -12255,9 +12317,9 @@ async function bodyArgsViaFile(args, deps = {}) {
12255
12317
  const i = args.indexOf("--body");
12256
12318
  if (i === -1 || i + 1 >= args.length) return { args, cleanup: async () => {
12257
12319
  } };
12258
- const write = deps.write ?? import_promises2.writeFile;
12259
- const remove2 = deps.remove ?? import_promises2.unlink;
12260
- const ensureDir = deps.ensureDir ?? import_promises2.mkdir;
12320
+ const write = deps.write ?? import_promises3.writeFile;
12321
+ const remove2 = deps.remove ?? import_promises3.unlink;
12322
+ const ensureDir = deps.ensureDir ?? import_promises3.mkdir;
12261
12323
  const dir = deps.dir ?? (0, import_node_os3.tmpdir)();
12262
12324
  const file = (0, import_node_path14.join)(dir, `mmi-gh-body-${process.pid}-${(0, import_node_crypto3.randomBytes)(4).toString("hex")}.md`);
12263
12325
  await ensureDir((0, import_node_path14.dirname)(file), { recursive: true }).catch(() => {
@@ -21004,7 +21066,7 @@ function formatBoxTable(boxes) {
21004
21066
  const addrW = w((b) => b.address || "(no public ipv4)", "ADDRESS");
21005
21067
  const projW = w((b) => b.project, "PROJECT");
21006
21068
  const statW = w((b) => b.status, "STATUS");
21007
- const row = (name, addr, proj, stat2, key) => `${name.padEnd(nameW)} ${addr.padEnd(addrW)} ${proj.padEnd(projW)} ${stat2.padEnd(statW)} ${key}`;
21069
+ const row = (name, addr, proj, stat3, key) => `${name.padEnd(nameW)} ${addr.padEnd(addrW)} ${proj.padEnd(projW)} ${stat3.padEnd(statW)} ${key}`;
21008
21070
  const lines = [row("BOX", "ADDRESS", "PROJECT", "STATUS", "SSH KEY (vault path)")];
21009
21071
  for (const b of boxes) {
21010
21072
  lines.push(row(b.name, b.address || "(no public ipv4)", b.project, b.status, b.sshKeyPath));
@@ -21142,7 +21204,7 @@ ${SSH_RECIPE_AGENT_NOTE}`);
21142
21204
  }
21143
21205
 
21144
21206
  // src/schedules-commands.ts
21145
- var import_promises3 = require("node:fs/promises");
21207
+ var import_promises4 = require("node:fs/promises");
21146
21208
  var import_node_child_process13 = require("node:child_process");
21147
21209
  var import_node_util7 = require("node:util");
21148
21210
 
@@ -21752,9 +21814,9 @@ function registerSchedulesCommands(program3) {
21752
21814
  await failGraceful("org schedules --doc: refusing to regenerate the doc from an incomplete read (see warnings above).");
21753
21815
  return;
21754
21816
  }
21755
- const docText = await (0, import_promises3.readFile)(o.doc, "utf8");
21817
+ const docText = await (0, import_promises4.readFile)(o.doc, "utf8");
21756
21818
  const spliced = spliceDoc(docText, renderDocSection(entries, (/* @__PURE__ */ new Date()).toISOString()));
21757
- await (0, import_promises3.writeFile)(o.doc, spliced, "utf8");
21819
+ await (0, import_promises4.writeFile)(o.doc, spliced, "utf8");
21758
21820
  reportDrift(drift);
21759
21821
  console.log(`org schedules: wrote ${entries.length} entries into ${o.doc}`);
21760
21822
  return;
@@ -21813,7 +21875,7 @@ function registerSchedulesCommands(program3) {
21813
21875
  }
21814
21876
 
21815
21877
  // src/file-lock.ts
21816
- var import_promises4 = require("node:fs/promises");
21878
+ var import_promises5 = require("node:fs/promises");
21817
21879
  var import_node_path24 = require("node:path");
21818
21880
  var sleep = (ms) => new Promise((resolve5) => setTimeout(resolve5, ms));
21819
21881
  var IMMEDIATE_RETRY_BUDGET = 3;
@@ -21838,7 +21900,7 @@ async function acquireFileLock(lockPath, opts, deadline) {
21838
21900
  for (; ; ) {
21839
21901
  let handle;
21840
21902
  try {
21841
- handle = await (0, import_promises4.open)(lockPath, "wx");
21903
+ handle = await (0, import_promises5.open)(lockPath, "wx");
21842
21904
  } catch (e) {
21843
21905
  const code = e.code;
21844
21906
  if (code !== "EEXIST" && code !== "EPERM" && code !== "EBUSY" && code !== "EACCES") throw e;
@@ -21847,10 +21909,10 @@ async function acquireFileLock(lockPath, opts, deadline) {
21847
21909
  if (++immediateRetries > IMMEDIATE_RETRY_BUDGET) await sleep(opts.retryMs);
21848
21910
  };
21849
21911
  try {
21850
- const age = Date.now() - (await (0, import_promises4.stat)(lockPath)).mtimeMs;
21912
+ const age = Date.now() - (await (0, import_promises5.stat)(lockPath)).mtimeMs;
21851
21913
  if (age > opts.staleMs) {
21852
21914
  try {
21853
- await (0, import_promises4.unlink)(lockPath);
21915
+ await (0, import_promises5.unlink)(lockPath);
21854
21916
  await retryNow();
21855
21917
  continue;
21856
21918
  } catch (unlinkError) {
@@ -21886,7 +21948,7 @@ async function acquireFileLock(lockPath, opts, deadline) {
21886
21948
  }
21887
21949
  async function fileLockHeldBy(lockPath, token) {
21888
21950
  try {
21889
- return await (0, import_promises4.readFile)(lockPath, "utf8") === token;
21951
+ return await (0, import_promises5.readFile)(lockPath, "utf8") === token;
21890
21952
  } catch {
21891
21953
  return false;
21892
21954
  }
@@ -21894,12 +21956,12 @@ async function fileLockHeldBy(lockPath, token) {
21894
21956
  async function releaseFileLock(lockPath, guard) {
21895
21957
  await guard.handle.close().catch(() => void 0);
21896
21958
  if (await fileLockHeldBy(lockPath, guard.token)) {
21897
- await (0, import_promises4.unlink)(lockPath).catch(() => void 0);
21959
+ await (0, import_promises5.unlink)(lockPath).catch(() => void 0);
21898
21960
  }
21899
21961
  }
21900
21962
  async function withFileLock(lockPath, opts, fn) {
21901
21963
  const resolved = resolveFileLockOpts(opts);
21902
- await (0, import_promises4.mkdir)((0, import_node_path24.dirname)(lockPath), { recursive: true }).catch(() => void 0);
21964
+ await (0, import_promises5.mkdir)((0, import_node_path24.dirname)(lockPath), { recursive: true }).catch(() => void 0);
21903
21965
  const guard = await acquireFileLock(lockPath, resolved, Date.now() + resolved.maxWaitMs);
21904
21966
  try {
21905
21967
  return await fn();
@@ -21909,7 +21971,7 @@ async function withFileLock(lockPath, opts, fn) {
21909
21971
  }
21910
21972
 
21911
21973
  // src/schedules-lift-command.ts
21912
- var import_promises5 = require("node:fs/promises");
21974
+ var import_promises6 = require("node:fs/promises");
21913
21975
  var import_node_path25 = require("node:path");
21914
21976
 
21915
21977
  // src/schedules-lift.ts
@@ -22009,14 +22071,14 @@ var RegistryUnreachableError = class extends Error {
22009
22071
  async function readWorkflowFiles(dir) {
22010
22072
  let names;
22011
22073
  try {
22012
- names = await (0, import_promises5.readdir)(dir);
22074
+ names = await (0, import_promises6.readdir)(dir);
22013
22075
  } catch {
22014
22076
  return [];
22015
22077
  }
22016
22078
  const files = [];
22017
22079
  for (const name of names.sort()) {
22018
22080
  if (!/\.ya?ml$/.test(name)) continue;
22019
- files.push({ path: `.github/workflows/${name}`, text: await (0, import_promises5.readFile)((0, import_node_path25.join)(dir, name), "utf8") });
22081
+ files.push({ path: `.github/workflows/${name}`, text: await (0, import_promises6.readFile)((0, import_node_path25.join)(dir, name), "utf8") });
22020
22082
  }
22021
22083
  return files;
22022
22084
  }
@@ -24298,7 +24360,7 @@ function registerBoardCommands(program3) {
24298
24360
 
24299
24361
  // src/merge-cleanup.ts
24300
24362
  var import_node_fs30 = require("node:fs");
24301
- var import_promises7 = require("node:fs/promises");
24363
+ var import_promises8 = require("node:fs/promises");
24302
24364
  var import_node_path30 = require("node:path");
24303
24365
  var import_node_os11 = require("node:os");
24304
24366
  var import_node_child_process14 = require("node:child_process");
@@ -24386,23 +24448,23 @@ function boardAdvanceFailureMessage(result) {
24386
24448
  }
24387
24449
 
24388
24450
  // src/deferred-registry-store.ts
24389
- var import_promises6 = require("node:fs/promises");
24451
+ var import_promises7 = require("node:fs/promises");
24390
24452
  var import_node_path29 = require("node:path");
24391
24453
  var sleep2 = (ms) => new Promise((resolve5) => setTimeout(resolve5, ms));
24392
24454
  async function atomicWrite(target, contents) {
24393
24455
  const tmp = `${target}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
24394
- await (0, import_promises6.writeFile)(tmp, contents, "utf8");
24456
+ await (0, import_promises7.writeFile)(tmp, contents, "utf8");
24395
24457
  try {
24396
24458
  await renameWithRetry(tmp, target);
24397
24459
  } catch (e) {
24398
- await (0, import_promises6.unlink)(tmp).catch(() => void 0);
24460
+ await (0, import_promises7.unlink)(tmp).catch(() => void 0);
24399
24461
  throw e;
24400
24462
  }
24401
24463
  }
24402
24464
  async function renameWithRetry(from, to, attempts = 5, backoffMs = 20) {
24403
24465
  for (let i = 0; ; i++) {
24404
24466
  try {
24405
- await (0, import_promises6.rename)(from, to);
24467
+ await (0, import_promises7.rename)(from, to);
24406
24468
  return;
24407
24469
  } catch (e) {
24408
24470
  const code = e.code;
@@ -24414,7 +24476,7 @@ async function renameWithRetry(from, to, attempts = 5, backoffMs = 20) {
24414
24476
  async function readStrict(registryPath) {
24415
24477
  let text;
24416
24478
  try {
24417
- text = await (0, import_promises6.readFile)(registryPath, "utf8");
24479
+ text = await (0, import_promises7.readFile)(registryPath, "utf8");
24418
24480
  } catch (e) {
24419
24481
  if (e.code === "ENOENT") return [];
24420
24482
  throw e;
@@ -24431,19 +24493,19 @@ function makeDeferredWorktreeStore(registryPath, lockOpts = {}) {
24431
24493
  // Lenient read for the sweep's initial fetch: any error (missing/corrupt) yields an empty queue.
24432
24494
  read: async () => {
24433
24495
  try {
24434
- return parseDeferredWorktreesFile(await (0, import_promises6.readFile)(registryPath, "utf8"));
24496
+ return parseDeferredWorktreesFile(await (0, import_promises7.readFile)(registryPath, "utf8"));
24435
24497
  } catch {
24436
24498
  return [];
24437
24499
  }
24438
24500
  },
24439
24501
  // Standalone atomic write — THROWS on failure (no best-effort swallow, #2846).
24440
24502
  write: async (entries) => {
24441
- await (0, import_promises6.mkdir)((0, import_node_path29.dirname)(registryPath), { recursive: true });
24503
+ await (0, import_promises7.mkdir)((0, import_node_path29.dirname)(registryPath), { recursive: true });
24442
24504
  await atomicWrite(registryPath, serializeDeferredWorktrees(entries));
24443
24505
  },
24444
24506
  // Serialized read-modify-write under the repo-wide lock (#2846).
24445
24507
  update: async (mutate) => {
24446
- await (0, import_promises6.mkdir)((0, import_node_path29.dirname)(registryPath), { recursive: true });
24508
+ await (0, import_promises7.mkdir)((0, import_node_path29.dirname)(registryPath), { recursive: true });
24447
24509
  const deadline = Date.now() + opts.maxWaitMs;
24448
24510
  for (; ; ) {
24449
24511
  const guard = await acquireLock(lockPath, opts, deadline);
@@ -24884,7 +24946,7 @@ var realWorktreeDirRemover = {
24884
24946
  (0, import_node_fs30.unlinkSync)(p);
24885
24947
  }
24886
24948
  },
24887
- removeTree: (p) => (0, import_promises7.rm)(p, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
24949
+ removeTree: (p) => (0, import_promises8.rm)(p, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 })
24888
24950
  };
24889
24951
  async function resolvePrimaryCheckout(execGit) {
24890
24952
  try {
@@ -25141,7 +25203,7 @@ async function fetchRestCorePool(gh = defaultGhApi) {
25141
25203
 
25142
25204
  // src/worktree-lifecycle-commands.ts
25143
25205
  var import_node_fs31 = require("node:fs");
25144
- var import_promises8 = require("node:fs/promises");
25206
+ var import_promises9 = require("node:fs/promises");
25145
25207
  var import_node_path31 = require("node:path");
25146
25208
  var GH_TIMEOUT_MS = 2e4;
25147
25209
  var DEFAULT_BASE = "origin/development";
@@ -25485,13 +25547,13 @@ function registerWorktreeCommands(program3) {
25485
25547
  }
25486
25548
  const landStatus = (await execFileP2("git", ["-C", wtPath, "status", "--porcelain"], { timeout: GIT_TIMEOUT_MS }).catch(() => ({ stdout: "unreadable" }))).stdout || "";
25487
25549
  const gitInWorktree = async (args) => (await execFileP2("git", ["-C", wtPath, ...args], { timeout: GIT_TIMEOUT_MS })).stdout;
25488
- const orphanDirt = headBorn ? void 0 : await classifyOrphanWorktreeDirt(landStatus, { git: gitInWorktree, readTextFile: (p) => (0, import_promises8.readFile)(p, "utf8") });
25550
+ const orphanDirt = headBorn ? void 0 : await classifyOrphanWorktreeDirt(landStatus, { git: gitInWorktree, readTextFile: (p) => (0, import_promises9.readFile)(p, "utf8") });
25489
25551
  const landDirty = headBorn ? landStatus.trim().length > 0 : orphanDirt.dirt !== "clean";
25490
25552
  if (landDirty) {
25491
25553
  return fail(`worktree land: refusing to land '${branch}' \u2014 uncommitted changes in ${wtPath}; commit, stash, or remove the worktree manually`, { code: ERROR_CODES.ERR_BAD_ENUM });
25492
25554
  }
25493
25555
  const orphanTip = orphan.orphan ? orphanDirt?.tip ?? await readOrphanWorktreeTip(
25494
- { git: gitInWorktree, readTextFile: (p) => (0, import_promises8.readFile)(p, "utf8") },
25556
+ { git: gitInWorktree, readTextFile: (p) => (0, import_promises9.readFile)(p, "utf8") },
25495
25557
  orphan.kind
25496
25558
  ) : void 0;
25497
25559
  const lastCommit = orphanTip ? {
@@ -26917,7 +26979,7 @@ function registerExplainCommand(program3) {
26917
26979
  }
26918
26980
 
26919
26981
  // src/pr-commands.ts
26920
- var import_promises9 = require("node:fs/promises");
26982
+ var import_promises10 = require("node:fs/promises");
26921
26983
  var GC_GH_TIMEOUT_MS4 = 2e4;
26922
26984
  var CHECKS_WATCH_POLL_MS = 15e3;
26923
26985
  var CHECKS_WATCH_TIMEOUT_MS = 10 * 6e4;
@@ -27061,10 +27123,10 @@ function registerPrLifecycleCommands(program3) {
27061
27123
  let body;
27062
27124
  try {
27063
27125
  if (o.title || o.titleFile) {
27064
- title = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises9.readFile, readStdin });
27126
+ title = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises10.readFile, readStdin });
27065
27127
  }
27066
27128
  if (o.body || o.bodyFile) {
27067
- body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises9.readFile, readStdin });
27129
+ body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises10.readFile, readStdin });
27068
27130
  }
27069
27131
  } catch (e) {
27070
27132
  return fail(`pr edit: ${e.message}`);
@@ -27094,7 +27156,7 @@ function registerPrLifecycleCommands(program3) {
27094
27156
  }
27095
27157
  let body;
27096
27158
  try {
27097
- body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises9.readFile, readStdin });
27159
+ body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises10.readFile, readStdin });
27098
27160
  } catch (e) {
27099
27161
  return fail(`pr comment: ${e.message}`);
27100
27162
  }
@@ -30669,7 +30731,7 @@ withExamples(mutating(
30669
30731
  try {
30670
30732
  title = await resolveIssueTitle(
30671
30733
  { title: opts.title, titleFile: opts.titleFile },
30672
- { readFile: import_promises10.readFile, readStdin }
30734
+ { readFile: import_promises11.readFile, readStdin }
30673
30735
  );
30674
30736
  } catch (e) {
30675
30737
  return fail(
@@ -30711,8 +30773,8 @@ withExamples(mutating(
30711
30773
  let surfaceFlagLabel;
30712
30774
  try {
30713
30775
  issueType = resolveCreateType(o.type, "issue create", o.label);
30714
- title = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises10.readFile, readStdin });
30715
- body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises10.readFile, readStdin });
30776
+ title = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises11.readFile, readStdin });
30777
+ body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises11.readFile, readStdin });
30716
30778
  if (o.idempotencyKey) body = appendIdempotencyMarker(body, o.idempotencyKey);
30717
30779
  priority = resolveCreatePriority(o.priority, "issue create");
30718
30780
  extraLabels = [...o.label ?? []];
@@ -30892,7 +30954,7 @@ jsonParity(issue.command("comment <ref>").description("post a Markdown comment t
30892
30954
  }
30893
30955
  let body;
30894
30956
  try {
30895
- body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises10.readFile, readStdin });
30957
+ body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises11.readFile, readStdin });
30896
30958
  } catch (e) {
30897
30959
  return fail(`issue comment: ${e.message}`);
30898
30960
  }
@@ -30952,8 +31014,8 @@ program2.command("report").description("file a friction report on the Hub board
30952
31014
  let title;
30953
31015
  const sourceRepo = o.repo ?? await resolveRepo(void 0);
30954
31016
  try {
30955
- title = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises10.readFile, readStdin });
30956
- body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises10.readFile, readStdin });
31017
+ title = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises11.readFile, readStdin });
31018
+ body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises11.readFile, readStdin });
30957
31019
  priority = resolveCreatePriority(o.priority, "report");
30958
31020
  if (!ISSUE_TYPES.includes(o.type)) {
30959
31021
  throw new Error(`unknown issue type "${o.type}" \u2014 expected one of: ${ISSUE_TYPES.join(", ")}`);
@@ -31005,8 +31067,8 @@ program2.command("skill-lesson").description("file a skill-lesson on the Hub boa
31005
31067
  let args;
31006
31068
  try {
31007
31069
  skill = assertSkillName(o.skill);
31008
- rawBody = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises10.readFile, readStdin });
31009
- const rawTitle = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises10.readFile, readStdin });
31070
+ rawBody = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises11.readFile, readStdin });
31071
+ const rawTitle = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises11.readFile, readStdin });
31010
31072
  title = buildSkillLessonTitle(skill, rawTitle);
31011
31073
  priority = resolveCreatePriority(o.priority, "skill-lesson");
31012
31074
  body = buildSkillLessonBody(rawBody, sourceRepo, pluginSha);
@@ -31065,8 +31127,8 @@ withExamples(pr.command("create").description("create a PR and print {number,url
31065
31127
  let body;
31066
31128
  let title;
31067
31129
  try {
31068
- title = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises10.readFile, readStdin });
31069
- body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises10.readFile, readStdin });
31130
+ title = await resolveIssueTitle({ title: o.title, titleFile: o.titleFile }, { readFile: import_promises11.readFile, readStdin });
31131
+ body = await resolveIssueBody({ body: o.body, bodyFile: o.bodyFile }, { readFile: import_promises11.readFile, readStdin });
31070
31132
  } catch (e) {
31071
31133
  return fail(`pr create: ${e.message}`, e instanceof TextArgError ? { code: e.code, offending_flag: e.offendingFlag } : void 0);
31072
31134
  }
@@ -31563,8 +31625,8 @@ function trainApplyDeps() {
31563
31625
  // Slack release announcement (#883): Hub-only + best-effort inside announceRelease itself.
31564
31626
  announce: (args) => announceRelease({
31565
31627
  run: async (file, cmdArgs) => (await execFileP2(file, cmdArgs, { timeout: GH_TRAIN_TIMEOUT_MS })).stdout,
31566
- readFile: (path2) => (0, import_promises10.readFile)(path2, "utf8"),
31567
- removeFile: (path2) => (0, import_promises10.unlink)(path2)
31628
+ readFile: (path2) => (0, import_promises11.readFile)(path2, "utf8"),
31629
+ removeFile: (path2) => (0, import_promises11.unlink)(path2)
31568
31630
  }, args),
31569
31631
  fetchEdgeDomains: async (slug) => {
31570
31632
  const proj = await fetchProjectBySlug(slug, registryClientDeps(await loadConfig()));
@@ -31747,7 +31809,7 @@ for (const commandName of ["rcand", "release"]) {
31747
31809
  }
31748
31810
  let summaryLines;
31749
31811
  try {
31750
- summaryLines = summaryFileLines(await (0, import_promises10.readFile)(o.announceSummaryFile, "utf8"));
31812
+ summaryLines = summaryFileLines(await (0, import_promises11.readFile)(o.announceSummaryFile, "utf8"));
31751
31813
  } catch (e) {
31752
31814
  return fail(`release: could not read --announce-summary-file ${o.announceSummaryFile}: ${e.message}`);
31753
31815
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutmutco/cli",
3
- "version": "3.84.0",
3
+ "version": "3.85.0",
4
4
  "description": "MMI Future CLI — the org dev toolbox and shared cross-IDE engine for every registry-declared MMI coding surface.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",