@mu-crew/mu 4.2.1 → 4.2.2

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.
@@ -41,7 +41,7 @@ import {
41
41
  steerStallHandler,
42
42
  waitForEvents,
43
43
  waitWithActions
44
- } from "./chunk-RJQNDFBU.js";
44
+ } from "./chunk-FHGYHXFB.js";
45
45
  import {
46
46
  FRONTIER_MAX_DEPTH,
47
47
  HumanNeededInvalidError,
@@ -101,7 +101,7 @@ import {
101
101
  taskRecordCut,
102
102
  taskToOutput,
103
103
  workstreamIdOf
104
- } from "./chunk-FVRIKUBR.js";
104
+ } from "./chunk-FOWIQ4TP.js";
105
105
  import {
106
106
  AgentAbortNeedsCtlError,
107
107
  AgentAbortTimeoutError,
@@ -8104,7 +8104,7 @@ function openDashboardOrHelp(program2) {
8104
8104
  (syncDb) => withShutdown(syncDb, async (shutdown) => {
8105
8105
  const key = "NODE_ENV";
8106
8106
  process.env[key] ??= "production";
8107
- const { runDashboard } = await import("./tui-5ZARE7RS.js");
8107
+ const { runDashboard } = await import("./tui-32NIE76L.js");
8108
8108
  const first = program2.opts().workstream?.[0];
8109
8109
  await runDashboard({ dbPath: defaultDbPath(), syncDb, shutdown, initialWorkstream: first });
8110
8110
  }),
@@ -9572,7 +9572,7 @@ function planDelegatePrune(db, opts = {}) {
9572
9572
  FROM tasks t
9573
9573
  JOIN workstreams w ON w.id = t.workstream_id AND w.torn_down_at IS NULL
9574
9574
  JOIN delegate_calls d ON d.task_id = t.id
9575
- WHERE t.kind = 'delegate' AND t.status = 'CLOSED' AND t.updated_at < ?
9575
+ WHERE t.kind = 'delegate' AND t.status = 'CLOSED' AND t.updated_at <= ?
9576
9576
  AND (? IS NULL OR w.name = ?)
9577
9577
  ORDER BY w.name, t.updated_at, t.local_id`
9578
9578
  ).all(cutoff, opts.workstream ?? null, opts.workstream ?? null);
@@ -9676,12 +9676,23 @@ function pruneDelegates(db, plan) {
9676
9676
  function checkOldDelegates(db, opts = {}) {
9677
9677
  const plan = planDelegatePrune(db, opts);
9678
9678
  const n = plan.candidates.length;
9679
- if (n === 0)
9679
+ if (n === 0) {
9680
+ const all = planDelegatePrune(db, { ...opts, days: 0 }).candidates.length;
9681
+ if (all > 0)
9682
+ return {
9683
+ name: "delegates-old",
9684
+ severity: "ok",
9685
+ detail: `no closed delegate task older than ${plan.days} days; ${all} newer closed`,
9686
+ remediation: [
9687
+ " mu delegates prune --older-than 0 # dry run: every closed delegate task"
9688
+ ]
9689
+ };
9680
9690
  return {
9681
9691
  name: "delegates-old",
9682
9692
  severity: "ok",
9683
9693
  detail: `no closed delegate task older than ${plan.days} days`
9684
9694
  };
9695
+ }
9685
9696
  return {
9686
9697
  name: "delegates-old",
9687
9698
  severity: "ok",
@@ -10033,8 +10044,12 @@ function wireDelegatesCommands(program2) {
10033
10044
  return handle((db) => cmdDelegatesRun(db, callId, opts), this)();
10034
10045
  });
10035
10046
  d.command("prune").description(
10036
- `Delete this machine's closed delegate tasks older than --older-than days (default ${PRUNE_DEFAULT_DAYS}) and their pi session files; the deletion syncs. Dry run without --yes; --yes backs up, VACUUMs, checks drift`
10037
- ).option("--older-than <days>", "age in days since the task closed", parsePositiveNumber).option("--yes", "apply (default: dry run)").option("-w, --workstream <name>", "only this workstream (default: every live one)").option(...JSON_OPT).action(function() {
10047
+ `Delete this machine's closed delegate tasks older than --older-than days (default ${PRUNE_DEFAULT_DAYS}; 0: every closed one) and their pi session files; the deletion syncs. Dry run without --yes; --yes backs up, VACUUMs, checks drift`
10048
+ ).option(
10049
+ "--older-than <days>",
10050
+ "age in days since the task closed (0: all)",
10051
+ parseNonNegativeNumber
10052
+ ).option("--yes", "apply (default: dry run)").option("-w, --workstream <name>", "only this workstream (default: every live one)").option(...JSON_OPT).action(function() {
10038
10053
  const opts = this.optsWithGlobals();
10039
10054
  return handle((db) => cmdDelegatesPrune(db, opts), this)();
10040
10055
  });
@@ -11068,18 +11083,27 @@ function wireHostCommands(program2) {
11068
11083
  // src/cli/human-needed.ts
11069
11084
  async function cmdHumanNeeded(db, reason, opts) {
11070
11085
  const ws = await resolveExistingWorkstream(db, opts.workstream);
11071
- const r = recordHumanNeeded(db, { workstream: ws, caller: spawnerFromEnv() ?? "", reason });
11086
+ const stop = opts.stop !== false;
11087
+ const r = recordHumanNeeded(db, {
11088
+ workstream: ws,
11089
+ caller: spawnerFromEnv() ?? "",
11090
+ reason,
11091
+ stop
11092
+ });
11072
11093
  if (opts.json) {
11073
- emitJson({ workstream: ws, id: r.id, changed: r.changed });
11094
+ emitJson({ workstream: ws, id: r.id, changed: r.changed, stop });
11074
11095
  return;
11075
11096
  }
11076
11097
  console.log(
11077
- r.changed ? `Recorded human-needed ${pc.bold(r.id)} in ${ws}` : pc.dim(`${r.id} already records this reason (no-op)`)
11098
+ r.changed ? `Recorded human-needed ${pc.bold(r.id)} in ${ws}${stop ? "" : " (no stop: the loop goes on)"}` : pc.dim(`${r.id} already records this reason (no-op)`)
11078
11099
  );
11079
11100
  }
11080
11101
  function wireHumanNeededCommand(program2) {
11081
11102
  program2.command("human-needed <reason>").description(
11082
- "Stop the loop for a human decision: record a parked `human` task with <reason>. Scoped to the caller; closes only by `mu task close`. Never recorded automatically."
11103
+ "Stop the loop for a human decision: record a parked `human` task with <reason>. Scoped to the caller; closes only by `mu task close`. Running work is still collected; nothing new starts."
11104
+ ).option(
11105
+ "--no-stop",
11106
+ "record a human item that does NOT stop the loop (a to-do for later: 'tag it', 'the rollout week'); one task per reason"
11083
11107
  ).option(...WORKSTREAM_OPT).option(...JSON_OPT).action(function(reason) {
11084
11108
  const opts = this.opts();
11085
11109
  return handle((db) => cmdHumanNeeded(db, reason, opts), this)();
@@ -11958,6 +11982,17 @@ async function cmdTeardown(db, opts) {
11958
11982
  );
11959
11983
  }
11960
11984
  }
11985
+ printPruneHint(db);
11986
+ }
11987
+ function printPruneHint(db) {
11988
+ const n = planDelegatePrune(db, { days: 0, workstream: "scratch" }).candidates.length;
11989
+ if (n === 0) return;
11990
+ console.log("");
11991
+ console.log(
11992
+ pc.dim(
11993
+ `scratch holds ${n} closed delegate task(s); teardown never touches scratch. Dry run: mu delegates prune --older-than 0`
11994
+ )
11995
+ );
11961
11996
  }
11962
11997
  function workstreamCreatedAt(db, name) {
11963
11998
  const row = db.prepare("SELECT created_at FROM workstreams WHERE name = ?").get(name);
@@ -12066,6 +12101,7 @@ async function cmdTeardownEmpty(db, opts) {
12066
12101
  }
12067
12102
  console.log("");
12068
12103
  console.log(pc.dim(`Sweep complete: tornDown=${results.length}, failed=${failed.length}.`));
12104
+ printPruneHint(db);
12069
12105
  }
12070
12106
  function withPositionalWorkstream(opts, name) {
12071
12107
  if (name === void 0) return opts;
@@ -12329,6 +12365,13 @@ function parsePositiveNumber(value) {
12329
12365
  }
12330
12366
  return n;
12331
12367
  }
12368
+ function parseNonNegativeNumber(value) {
12369
+ const n = value.trim() === "" ? Number.NaN : Number(value);
12370
+ if (!Number.isFinite(n) || n < 0) {
12371
+ throw new InvalidArgumentError(`expected a non-negative number, got ${JSON.stringify(value)}`);
12372
+ }
12373
+ return n;
12374
+ }
12332
12375
  function parseSeconds(value) {
12333
12376
  const n = value.trim() === "" ? Number.NaN : Number(value);
12334
12377
  if (!Number.isFinite(n) || n < 0) {
@@ -12564,6 +12607,7 @@ export {
12564
12607
  parseImpact,
12565
12608
  parseLines,
12566
12609
  parseNonNegativeInt,
12610
+ parseNonNegativeNumber,
12567
12611
  parsePositiveInt,
12568
12612
  parsePositiveNumber,
12569
12613
  parseQualifiedRef,
@@ -12587,4 +12631,4 @@ export {
12587
12631
  truncate,
12588
12632
  truncateFront
12589
12633
  };
12590
- //# sourceMappingURL=cli-H3VVCP7M.js.map
12634
+ //# sourceMappingURL=cli-HKBFJISN.js.map