monoban 1.9.0 → 1.10.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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.mjs +285 -32
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -33,7 +33,7 @@ monoban done SHOP-14
33
33
  | **Across projects** | `today` (what's planned, overdue first) · `search` · `schedule SHOP-14 fri` · `move --to` |
34
34
  | **Your repository** | `link` · `start` (branch + In progress) · `attach --pr` |
35
35
  | **History** | `log` (what happened to a task) · `comment` · `comments` |
36
- | **Coding agents** | `setup claude` · `setup codex` · `runner` · `run` · `runs` · `agentpipe install` |
36
+ | **Coding agents** | `setup claude` · `setup codex` · `runner` · `run` · `runs` · `loops` · `agentpipe install` |
37
37
  | **This machine** | `doctor` (what's missing, and how to fix it) · `upgrade` |
38
38
 
39
39
  `monoban <command> --help` says more, and [the guide](https://monoban.dev/guide) walks through it all. Columns match loosely (`move SHOP-14 in-prog`), and Tab completes
package/dist/index.mjs CHANGED
@@ -5782,7 +5782,7 @@ const LIMITS = {
5782
5782
  * Days, as tasks are scheduled: "2026-10-02", no time and no time zone. "Today" is the user's own: clients
5783
5783
  * work it out from their clock (today()) and send it, so the API never guesses a time zone.
5784
5784
  */
5785
- const DAY_MS$1 = 864e5;
5785
+ const DAY_MS$2 = 864e5;
5786
5786
  const DAY_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
5787
5787
  const pad$1 = (n) => String(n).padStart(2, "0");
5788
5788
  const fromUtc = (ms) => {
@@ -5803,11 +5803,11 @@ function today$1(now = /* @__PURE__ */ new Date()) {
5803
5803
  return `${now.getFullYear()}-${pad$1(now.getMonth() + 1)}-${pad$1(now.getDate())}`;
5804
5804
  }
5805
5805
  function addDays(day, days) {
5806
- return fromUtc(utc$1(day) + days * DAY_MS$1);
5806
+ return fromUtc(utc$1(day) + days * DAY_MS$2);
5807
5807
  }
5808
5808
  /** How many days from `from` to `to` (negative when `to` is earlier). */
5809
5809
  function daysBetween(from, to) {
5810
- return Math.round((utc$1(to) - utc$1(from)) / DAY_MS$1);
5810
+ return Math.round((utc$1(to) - utc$1(from)) / DAY_MS$2);
5811
5811
  }
5812
5812
  /**
5813
5813
  * A project's Done column, as `monoban done` and the Today view read it: the one named Done (any case),
@@ -7135,6 +7135,11 @@ const LoopRunPlanSchema = object({
7135
7135
  prUrl: string().nullable(),
7136
7136
  /** The run that opened that pull request. */
7137
7137
  continues: IdSchema.nullable(),
7138
+ /**
7139
+ * That run's external id: agentpipe's run that opened the pull request (its branch is `agentpipe/<id>`), which
7140
+ * `agentpipe merge --expect-run` checks. Null when that run never said it.
7141
+ */
7142
+ externalId: string().nullable(),
7138
7143
  /** scavenge: how many tasks it may file (its `maxOpen` less its open tasks); null for deliver. */
7139
7144
  limit: number$1().int().nonnegative().nullable()
7140
7145
  }).meta({ id: "LoopRunPlan" });
@@ -8105,7 +8110,7 @@ function matchColumn(columns, query) {
8105
8110
  choices: [...columns]
8106
8111
  };
8107
8112
  }
8108
- const DAY_MS = 864e5;
8113
+ const DAY_MS$1 = 864e5;
8109
8114
  /**
8110
8115
  * Whether a task is archived: archived by hand (in any column: in Done it's done, elsewhere it won't be), or
8111
8116
  * in its project's Done column (`doneColumnId`: doneColumn()) for longer than the project's
@@ -8118,11 +8123,11 @@ function isArchived(task, doneColumnId, archiveAfterDays, now = Date.now()) {
8118
8123
  }
8119
8124
  /** Whether a task has been in its column for longer than `archiveAfterDays` (in Done, that archives it). */
8120
8125
  function archivedByTime(task, archiveAfterDays, now = Date.now()) {
8121
- return archiveAfterDays !== null && Date.parse(task.columnSince) < now - archiveAfterDays * DAY_MS;
8126
+ return archiveAfterDays !== null && Date.parse(task.columnSince) < now - archiveAfterDays * DAY_MS$1;
8122
8127
  }
8123
8128
  // src/version.ts
8124
8129
  /** This CLI's version, from package.json (set at build time by tsdown, and by vitest in tests). */
8125
- const VERSION = "1.9.0";
8130
+ const VERSION = "1.10.0";
8126
8131
  /** Sent as X-Monoban-Client, and shown in Settings › CLI sessions. */
8127
8132
  const CLIENT = `cli/${VERSION}`;
8128
8133
  // src/api.ts
@@ -11782,7 +11787,7 @@ async function latestVersion(ctx) {
11782
11787
  async function upgrade(ctx, options, kind = thisInstall()) {
11783
11788
  const latest = await latestVersion(ctx);
11784
11789
  const { how, command } = UPGRADE[kind];
11785
- const outdated = latest !== null && newer(latest, "1.9.0");
11790
+ const outdated = latest !== null && newer(latest, "1.10.0");
11786
11791
  if (options.json) {
11787
11792
  ctx.out(JSON.stringify({
11788
11793
  version: VERSION,
@@ -12387,6 +12392,9 @@ function agentpipeMapper(report) {
12387
12392
  let runEnded = false;
12388
12393
  /** CI's state as last said (`ci.check`), so only a change is reported: the loop polls every few seconds. */
12389
12394
  let ci = null;
12395
+ /** `scout --track`: the tasks its `file` step filed (their refs, else their URLs), and `run.end`'s counts. */
12396
+ const filed = [];
12397
+ let counts = null;
12390
12398
  const spent = () => report.update({ costUsd: Math.round((total + shipped) * 1e4) / 1e4 });
12391
12399
  const flush = (cost) => {
12392
12400
  if (!pending) return;
@@ -12567,6 +12575,20 @@ function agentpipeMapper(report) {
12567
12575
  });
12568
12576
  return;
12569
12577
  }
12578
+ case "issue.created": {
12579
+ const url = str(d.url);
12580
+ if (step !== "file" || d.reused === true || !url) return;
12581
+ const what = str(d.display) ?? (num(d.number) !== null ? `#${num(d.number)}` : url);
12582
+ filed.push(what);
12583
+ report.event({
12584
+ kind: "board",
12585
+ ...step && { step },
12586
+ message: clip$1(`filed ${what}`),
12587
+ data: { url: clip$1(url) },
12588
+ ...at && { at }
12589
+ });
12590
+ return;
12591
+ }
12570
12592
  case "issue.comment": {
12571
12593
  const milestone = str(d.milestone);
12572
12594
  report.event({
@@ -12611,6 +12633,7 @@ function agentpipeMapper(report) {
12611
12633
  runEnded = true;
12612
12634
  const status = str(d.status) ?? "failed";
12613
12635
  said = status;
12636
+ if (d.counts && typeof d.counts === "object") counts = Object.fromEntries(Object.entries(d.counts).flatMap(([k, v]) => num(v) === null ? [] : [[k, v]]));
12614
12637
  const reason = str(d.reason);
12615
12638
  const says = SAYS[status];
12616
12639
  ending = {
@@ -12689,6 +12712,9 @@ function agentpipeMapper(report) {
12689
12712
  said: () => said,
12690
12713
  /** Its `run.end` came: anything after is a ship loop's (`address --ship`). */
12691
12714
  runEnded: () => runEnded,
12715
+ /** What `scout --track` filed (refs, in order), and the numbers behind how it ended (`run.end`'s counts). */
12716
+ filed: () => [...filed],
12717
+ counts: () => counts,
12692
12718
  flush: () => flush()
12693
12719
  };
12694
12720
  }
@@ -12866,7 +12892,11 @@ const RECIPE_NEEDS = {
12866
12892
  "merge.json",
12867
12893
  "merge.expect_run"
12868
12894
  ],
12869
- scavenge: ["scout.json", "scout.track"]
12895
+ scavenge: [
12896
+ "scout.json",
12897
+ "scout.track",
12898
+ "run.dry_run_json"
12899
+ ]
12870
12900
  };
12871
12901
  /** The recipes an agentpipe can run, from what it says it has. */
12872
12902
  function recipesOf(capabilities) {
@@ -18005,6 +18035,11 @@ var en_US_default = {
18005
18035
  "label": "Run {name} now",
18006
18036
  "help": "Run loop now"
18007
18037
  },
18038
+ "continue": {
18039
+ "label": "Continue {ref}'s pull request from {step}",
18040
+ "help": "Continue a run's pull request",
18041
+ "keywords": "continue resume retry pull request merge checks feedback"
18042
+ },
18008
18043
  "delete": {
18009
18044
  "label": "Delete {name}",
18010
18045
  "help": "Delete loop"
@@ -18097,7 +18132,9 @@ var en_US_default = {
18097
18132
  "hold": "{going, select, yes {Stops before merge} other {Stopped before merge}}: {why, select, mergeOff {merge is off for this loop} queuedOutside {its task was queued outside the browser} other {its text was changed outside the browser after you queued it}}.",
18098
18133
  "waiting": "Waiting for you",
18099
18134
  "waits": "<pr>{ref}'s pull request</pr> is ready for you to merge: {why, select, mergeOff {merge is off for this loop} queuedOutside {its task was queued outside the browser} other {its text was changed outside the browser after you queued it}}.",
18100
- "waitsOpen": "<pr>{ref}'s pull request</pr> waits for you."
18135
+ "waitsOpen": "<pr>{ref}'s pull request</pr> waits for you.",
18136
+ "continue": "Continue {ref}'s pull request",
18137
+ "continueHint": "A run picks it up from the step you choose, at the runner's next check-in.{merges, select, yes { Continued from here, it may merge on its own.} other {}}"
18101
18138
  },
18102
18139
  runs: {
18103
18140
  "heading": "Runs",
@@ -18190,7 +18227,8 @@ var en_US_default = {
18190
18227
  "pause": "Pause",
18191
18228
  "resume": "Resume",
18192
18229
  "edit": "Edit",
18193
- "delete": "Delete"
18230
+ "delete": "Delete",
18231
+ "continueFrom": "From {step}"
18194
18232
  },
18195
18233
  toast: {
18196
18234
  "created": "Created {name}.",
@@ -18199,7 +18237,8 @@ var en_US_default = {
18199
18237
  "resumed": "Resumed {name}.",
18200
18238
  "queued": "{name} runs at its runner's next check-in.",
18201
18239
  "deleted": "Deleted {name}.",
18202
- "failed": "That didn't work: try again."
18240
+ "failed": "That didn't work: try again.",
18241
+ "continued": "{ref} continues from {step} at its runner's next check-in."
18203
18242
  }
18204
18243
  },
18205
18244
  notes: {
@@ -19660,6 +19699,40 @@ function formatCost(usd, { locale }) {
19660
19699
  }).format(usd);
19661
19700
  }
19662
19701
  // ../../packages/i18n/src/loops.ts
19702
+ const DAY_MS = 864e5;
19703
+ /**
19704
+ * A loop's state in a few words (contract's `loopState`): "paused", "mbp is offline", "a pull request waits for
19705
+ * you", "next at 14:05". A start more than a day away says its day too ("next at Fri 09:00"). `now`: the
19706
+ * clock it's said against, for that. The time is in the reader's own time zone (the browser's, the terminal's),
19707
+ * so this is for the web and the CLI, never an email (those say UTC: `momentFormat`).
19708
+ */
19709
+ function describeLoopState({ state, nextAt, why }, words, now = Date.now()) {
19710
+ const { t, locale } = words;
19711
+ const count = why.count ?? 0;
19712
+ switch (state) {
19713
+ case "paused": return t(`loop.state.paused.${why.reason ?? "you"}`);
19714
+ case "noRunner":
19715
+ case "running":
19716
+ case "waitingForTask":
19717
+ case "due": return t(`loop.state.${state}`);
19718
+ case "runnerOffline":
19719
+ case "runnerOutdated": return t(`loop.state.${state}`, { runner: why.runner ?? "" });
19720
+ case "waitingForYou": return t(`loop.state.waitingForYou.${why.of ?? "pullRequests"}`, { count });
19721
+ case "dailyLimit": return t("loop.state.dailyLimit", { count });
19722
+ case "budget": return t("loop.state.budget", {
19723
+ spent: formatCost(why.spent ?? 0, words),
19724
+ limit: formatCost(why.limit ?? 0, words)
19725
+ });
19726
+ case "next": {
19727
+ const at = nextAt ? Date.parse(nextAt) : now;
19728
+ return t("loop.state.next", { time: new Intl.DateTimeFormat(locale, {
19729
+ ...at - now >= DAY_MS && { weekday: "short" },
19730
+ hour: "2-digit",
19731
+ minute: "2-digit"
19732
+ }).format(at) });
19733
+ }
19734
+ }
19735
+ }
19663
19736
  /**
19664
19737
  * Why a deliver run won't merge on its own (contract's `mergeHoldOf`, plan §1.12), in a few words: "its task was
19665
19738
  * queued outside the browser". The loops tab says the same in its own sentences (loops.json `detail.waits`).
@@ -19895,15 +19968,15 @@ async function projects(ctx, options) {
19895
19968
  const { bold, dim } = ctx.style;
19896
19969
  const keyWidth = Math.max(...all.map((p) => p.key.length));
19897
19970
  const nameWidth = Math.max(...all.map((p) => [...p.name].length));
19898
- const countWidth = Math.max(...all.map((p) => tasks(p).length));
19971
+ const countWidth = Math.max(...all.map((p) => tasks$1(p).length));
19899
19972
  for (const p of all) {
19900
19973
  const mark = here ? p.key === here ? "* " : " " : "";
19901
19974
  const name = `${p.name}${" ".repeat(nameWidth - [...p.name].length)}`;
19902
- const line = `${mark}${bold(p.key.padEnd(keyWidth))} ${name} ${dim(tasks(p).padEnd(countWidth))} ${dim(p.repo ?? "")}`;
19975
+ const line = `${mark}${bold(p.key.padEnd(keyWidth))} ${name} ${dim(tasks$1(p).padEnd(countWidth))} ${dim(p.repo ?? "")}`;
19903
19976
  ctx.out(line.trimEnd());
19904
19977
  }
19905
19978
  }
19906
- const tasks = (p) => `${p.taskCount} ${p.taskCount === 1 ? "task" : "tasks"}`;
19979
+ const tasks$1 = (p) => `${p.taskCount} ${p.taskCount === 1 ? "task" : "tasks"}`;
19907
19980
  /**
19908
19981
  * `monoban list [COLUMN…]`: the board, by column (every column, or the ones named); `--tag` keeps a tag's
19909
19982
  * tasks. `--archived`: the archived ones instead (done a while ago, or won't do: with why).
@@ -21602,8 +21675,8 @@ const deliver = {
21602
21675
  })
21603
21676
  }
21604
21677
  },
21605
- dryRun: (run) => run.ref ? [...implementArgs(run, run.budgetUsd), "--dry-run"] : null,
21606
- tier: reviewTierOf,
21678
+ dryRun: (run) => run.ref && run.plan.from !== "merge" ? [...implementArgs(run, run.budgetUsd), "--dry-run"] : null,
21679
+ tier: (run) => run.plan.from ? null : reviewTierOf(run),
21607
21680
  finished: ({ pr, last }) => {
21608
21681
  if (!pr) return null;
21609
21682
  if (last?.step === "merge" && last.status === "ok") return last.message ?? "Merged.";
@@ -21659,6 +21732,72 @@ function alive(pid) {
21659
21732
  return err.code === "EPERM";
21660
21733
  }
21661
21734
  }
21735
+ /**
21736
+ * `agentpipe scout`: surveys origin's default branch (`--fresh-base`) for what the loop's focus asks, and files what it
21737
+ * finds where the loop says, on what is left of the budget. The user's words go after `=`, so a focus starting with
21738
+ * `-` stays a value.
21739
+ */
21740
+ function scoutArgs(run, budgetUsd) {
21741
+ const { focus } = run.plan.options;
21742
+ return [
21743
+ "scout",
21744
+ run.workdir,
21745
+ "--json",
21746
+ "--fresh-base",
21747
+ `--focus=${focus}`,
21748
+ "--limit",
21749
+ String(Math.min(run.plan.limit ?? 0, 20)),
21750
+ "--track",
21751
+ `--column=${run.plan.columnName ?? ""}`,
21752
+ `--label=${run.plan.tagName ?? ""}`,
21753
+ "--budget",
21754
+ usd(budgetUsd)
21755
+ ];
21756
+ }
21757
+ const tasks = (n) => n === 1 ? "1 task" : `${n} tasks`;
21758
+ /** What a scout run filed, in words: the refs, what it left for later, and what was on the board already. */
21759
+ function filedSaying(result) {
21760
+ const { filed, counts } = result;
21761
+ const later = counts?.over_limit ?? 0;
21762
+ const already = counts?.already_filed ?? 0;
21763
+ const more = later ? `; ${later === 1 ? "1 more waits" : `${later} more wait`} until you close some` : "";
21764
+ if (filed.length) return `Filed ${tasks(filed.length)}: ${filed.join(", ")}${more}.`;
21765
+ if (already) return `Nothing new to file (${tasks(already)} it found ${already === 1 ? "is" : "are"} filed already)${more}.`;
21766
+ return `Nothing new to file${more}.`;
21767
+ }
21768
+ const scavenge = {
21769
+ steps: { scout: {
21770
+ pollSeconds: 15,
21771
+ run: async (ctx) => {
21772
+ const { limit, columnName, tagName } = ctx.run.plan;
21773
+ if (!limit || limit < 1) return skipped("Nothing to file: its open tasks are at its limit.");
21774
+ if (!columnName) return failed("The column it files in is gone: choose another for the loop.");
21775
+ if (!tagName) return failed("The tag it files with is gone: choose another for the loop.");
21776
+ const result = await ctx.agentpipe(scoutArgs(ctx.run, ctx.budgetUsd));
21777
+ const end = endOf(result, "agentpipe scout");
21778
+ if (end.status === "ok") return {
21779
+ ...end,
21780
+ message: filedSaying(result)
21781
+ };
21782
+ if (result.filed.length) return {
21783
+ ...end,
21784
+ message: `${end.message ?? "It stopped"} (it filed ${result.filed.join(", ")} first)`
21785
+ };
21786
+ return end;
21787
+ }
21788
+ } },
21789
+ dryRun: (run) => [
21790
+ "run",
21791
+ run.workdir,
21792
+ "--json",
21793
+ "--fresh-base",
21794
+ "--budget",
21795
+ usd(run.budgetUsd),
21796
+ "--dry-run"
21797
+ ],
21798
+ sandboxed: ["scout"],
21799
+ finished: ({ last }) => last?.message ?? null
21800
+ };
21662
21801
  // src/runner/recipes/index.ts
21663
21802
  /** A pull request's number, from its URL (…/pull/42), or null. */
21664
21803
  function prOf(url) {
@@ -21670,7 +21809,7 @@ function prOf(url) {
21670
21809
  }
21671
21810
  const RECIPES = {
21672
21811
  deliver,
21673
- scavenge: null
21812
+ scavenge
21674
21813
  };
21675
21814
  /** The recipes this monoban runs: a runner names these, of those its agentpipe can run (MON-202). */
21676
21815
  const RECIPES_HERE = RECIPE_NAMES.filter((name) => RECIPES[name] !== null);
@@ -21698,10 +21837,17 @@ function runRecipe(name, run, report, deps) {
21698
21837
  const { step } = steps(report, () => cancelled);
21699
21838
  /** What the run has spent so far, over all its commands. */
21700
21839
  let spent = 0;
21701
- /** Its pull request, and the run id the server keeps: the first agentpipe run's (`merge --expect-run` needs it). */
21840
+ /**
21841
+ * Its pull request, and the run id the server keeps: the first agentpipe run's (`merge --expect-run` needs it). A
21842
+ * run that continues a pull request has both from the run that opened it (its plan, through the server).
21843
+ */
21702
21844
  let pr = prOf(run.plan.prUrl);
21703
- let runId = null;
21845
+ let runId = run.plan.from ? run.plan.externalId : null;
21704
21846
  const leases = deps.leases ?? shipLeases(deps.env);
21847
+ const projectEnv = {
21848
+ ...deps.env,
21849
+ MONOBAN_PROJECT: run.project
21850
+ };
21705
21851
  const command = (outer) => async (args) => {
21706
21852
  if (cancelled) return {
21707
21853
  ending: {
@@ -21716,7 +21862,9 @@ function runRecipe(name, run, report, deps) {
21716
21862
  externalId: null,
21717
21863
  prUrl: null,
21718
21864
  costUsd: 0,
21719
- said: null
21865
+ said: null,
21866
+ filed: [],
21867
+ counts: null
21720
21868
  };
21721
21869
  let externalId = null;
21722
21870
  let prUrl = null;
@@ -21775,7 +21923,7 @@ function runRecipe(name, run, report, deps) {
21775
21923
  command: deps.command,
21776
21924
  args,
21777
21925
  cwd: run.workdir,
21778
- env: deps.env,
21926
+ env: projectEnv,
21779
21927
  monobanBin: deps.monobanBin,
21780
21928
  map: (event) => {
21781
21929
  feed.take(event);
@@ -21803,7 +21951,9 @@ function runRecipe(name, run, report, deps) {
21803
21951
  externalId,
21804
21952
  prUrl,
21805
21953
  costUsd: cost,
21806
- said
21954
+ said,
21955
+ filed: feed.filed(),
21956
+ counts: feed.counts()
21807
21957
  };
21808
21958
  };
21809
21959
  return {
@@ -21812,15 +21962,26 @@ function runRecipe(name, run, report, deps) {
21812
21962
  status: "failed",
21813
21963
  reason: `This monoban can't run ${name} loops yet.`
21814
21964
  };
21815
- if (run.plan.from) return {
21816
- status: "failed",
21817
- reason: `This monoban can't continue a run from ${run.plan.from} yet.`
21818
- };
21819
21965
  const order = RECIPES$1[name].steps;
21966
+ const from = run.plan.from ? order.indexOf(run.plan.from) : 0;
21967
+ if (run.plan.from) {
21968
+ if (from < 0 || !pr) return {
21969
+ status: "failed",
21970
+ reason: `There's no pull request to continue from ${run.plan.from}.`
21971
+ };
21972
+ report.update({
21973
+ prUrl: pr.url,
21974
+ ...runId && { externalId: runId }
21975
+ });
21976
+ }
21820
21977
  let last = null;
21821
- for (const stepName of order) {
21978
+ for (const [i, stepName] of order.entries()) {
21822
21979
  const s = recipe.steps[stepName];
21823
21980
  if (!s) continue;
21981
+ if (i < from) {
21982
+ await step(stepName, async () => skipped(`The run it continues did this (it continues from ${run.plan.from}).`));
21983
+ continue;
21984
+ }
21824
21985
  const stop = await deps.recheck?.() ?? null;
21825
21986
  if (stop) return {
21826
21987
  status: "cancelled",
@@ -22037,7 +22198,7 @@ function runBoard(api) {
22037
22198
  async function preflight(run, recipe, deps) {
22038
22199
  const args = recipe.dryRun(run);
22039
22200
  if (args) {
22040
- const refused = await dryRun(run, args, deps);
22201
+ const refused = await dryRun(run, args, recipe.sandboxed ?? null, deps);
22041
22202
  if (refused) return refused;
22042
22203
  }
22043
22204
  const tier = recipe.tier?.(run) ?? null;
@@ -22048,7 +22209,7 @@ async function preflight(run, recipe, deps) {
22048
22209
  }
22049
22210
  return null;
22050
22211
  }
22051
- async function dryRun(run, args, deps) {
22212
+ async function dryRun(run, args, only, deps) {
22052
22213
  let preview = null;
22053
22214
  const exit = await agentpipeCommand({
22054
22215
  command: deps.command,
@@ -22070,7 +22231,10 @@ async function dryRun(run, args, deps) {
22070
22231
  return clip(`agentpipe's dry run refused it (exit code ${exit.code ?? "none"})${last}`, 1e3);
22071
22232
  }
22072
22233
  if (!said) return "agentpipe's dry run didn't say what the run would do, so its sandbox can't be checked.";
22073
- const off = (said.steps ?? []).filter((s) => s.boundary && s.boundary.sandbox !== true).map((s) => typeof s.name === "string" ? s.name : "a step");
22234
+ const steps = said.steps ?? [];
22235
+ const unseen = (only ?? []).filter((name) => !steps.some((s) => s.name === name && s.boundary));
22236
+ if (unseen.length) return `agentpipe's dry run didn't show ${unseen.join(", ")}, so its sandbox can't be checked.`;
22237
+ const off = steps.filter((s) => s.boundary && s.boundary.sandbox !== true).filter((s) => !only || typeof s.name === "string" && only.includes(s.name)).map((s) => typeof s.name === "string" ? s.name : "a step");
22074
22238
  if (off.length) return clip(`agentpipe's sandbox is off for ${off.join(", ")}: a loop runs only with it on (each step's sandbox in .agentpipe/config.toml).`, 1e3);
22075
22239
  if (said.commands?.sandbox !== true) return "agentpipe's sandbox is off for the repository's own commands: a loop runs only with it on ([commands] sandbox = true in .agentpipe/config.toml).";
22076
22240
  return null;
@@ -22338,6 +22502,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
22338
22502
  loopRun = {
22339
22503
  id: run.id,
22340
22504
  ref,
22505
+ project: run.project.key,
22341
22506
  workdir: run.workdir,
22342
22507
  plan: run.loopRun,
22343
22508
  budgetUsd: Math.min(budget, left)
@@ -22994,7 +23159,7 @@ function describe({ state, running }, board, now) {
22994
23159
  const seenAgo = `checked in ${since(board.lastSeenAt, now)} ago (every ${board.pollSeconds}s)`;
22995
23160
  row("board", `${board.online ? "online" : "offline"} · ${seenAgo}`);
22996
23161
  } else if (!state.runnerId) row("board", "not on the board yet: it's starting");
22997
- if (state.version !== "1.9.0") {
23162
+ if (state.version !== "1.10.0") {
22998
23163
  const again = state.background ? "`monoban runner restart`" : "start it again in its terminal";
22999
23164
  row("update", `it runs monoban ${state.version}, this is ${VERSION}: ${again}`);
23000
23165
  }
@@ -23432,7 +23597,7 @@ async function checks(ctx, deps = {}) {
23432
23597
  const found = [];
23433
23598
  const latest = await (deps.latest ?? latestVersion)(ctx);
23434
23599
  const upgrade = UPGRADE[thisInstall()].command;
23435
- found.push(latest && newer(latest, "1.9.0") ? {
23600
+ found.push(latest && newer(latest, "1.10.0") ? {
23436
23601
  name: "monoban",
23437
23602
  status: "warn",
23438
23603
  detail: `${VERSION}; ${latest} is out`,
@@ -23595,6 +23760,89 @@ async function doctor(ctx, options, deps = {}) {
23595
23760
  }
23596
23761
  if (found.some((c) => c.status === "fail")) throw new CliError("", EXIT.error);
23597
23762
  }
23763
+ // src/commands/loops.ts
23764
+ /** Every loop of the project, in the API's order (oldest first). */
23765
+ async function loopsOf(api, key) {
23766
+ const all = [];
23767
+ for await (const loop of pages((cursor) => unwrap(api.GET("/v1/projects/{key}/loops", { params: {
23768
+ path: { key },
23769
+ query: { cursor }
23770
+ } })).then((page) => ({
23771
+ items: page.loops,
23772
+ nextCursor: page.nextCursor
23773
+ })))) all.push(loop);
23774
+ return all;
23775
+ }
23776
+ /** Where a project's loops are made, changed and resumed. */
23777
+ const loopsTab = (ctx, key) => `${ctx.webUrl}/p/${key}?view=loops`;
23778
+ /** What it's doing, in a few words: its state, and while a run goes, the step and task. */
23779
+ function loopDoing(loop, now = Date.now()) {
23780
+ const state = describeLoopState(loop.state, ENGLISH, now);
23781
+ const going = loop.going && [loop.going.step, loop.going.ref].filter(Boolean).join(" on ");
23782
+ return going ? `${state}: ${going}` : state;
23783
+ }
23784
+ /** "Deliver deliver running: implement on MON-12 mbp 24h: 2 runs, $1.23". */
23785
+ function loopLine(loop, widths, now = Date.now()) {
23786
+ const day = loop.last24h.runs ? `24h: ${loop.last24h.runs} ${loop.last24h.runs === 1 ? "run" : "runs"}, ${formatCost(loop.last24h.costUsd, ENGLISH)}` : "24h: no runs";
23787
+ return [
23788
+ loop.name.padEnd(widths.name),
23789
+ loop.recipe.padEnd(widths.recipe),
23790
+ loopDoing(loop, now),
23791
+ loop.runner.name,
23792
+ day
23793
+ ].join(" ");
23794
+ }
23795
+ /** `monoban loops`: the project's loops and what each is doing. */
23796
+ async function loops(ctx, options) {
23797
+ const api = apis(ctx).signedIn;
23798
+ const key = await resolveProject(ctx, api, options.project);
23799
+ const all = await loopsOf(api, key);
23800
+ if (options.json) return ctx.out(JSON.stringify(all, null, 2));
23801
+ if (!all.length) {
23802
+ ctx.err(`${key} has no loops yet. Make one in its loops tab: ${loopsTab(ctx, key)}`);
23803
+ return;
23804
+ }
23805
+ const widths = {
23806
+ name: Math.max(...all.map((l) => [...l.name].length)),
23807
+ recipe: Math.max(...all.map((l) => l.recipe.length))
23808
+ };
23809
+ for (const loop of all) ctx.out(loopLine(loop, widths));
23810
+ }
23811
+ /** The loop named `name` (any case, or its id), or a not-found error that names the project's loops. */
23812
+ function findLoop(all, name, key) {
23813
+ const wanted = name.trim().toLowerCase();
23814
+ const found = all.find((l) => l.name.toLowerCase() === wanted || l.id === name.trim());
23815
+ if (found) return found;
23816
+ const names = all.map((l) => `"${l.name}"`).join(", ");
23817
+ throw new CliError(`${key} has no loop named "${name}"${names ? ` (its loops: ${names})` : ""}.`, EXIT.notFound);
23818
+ }
23819
+ /**
23820
+ * `monoban loop pause NAME`: it starts no new run until it's resumed in the browser. A run it has going goes on:
23821
+ * cancel that from the board.
23822
+ */
23823
+ async function loopPause(ctx, name, options) {
23824
+ const api = apis(ctx).signedIn;
23825
+ const key = await resolveProject(ctx, api, options.project);
23826
+ const loop = findLoop(await loopsOf(api, key), name, key);
23827
+ let paused = loop;
23828
+ if (!loop.paused) paused = await unwrap(api.PATCH("/v1/loops/{loopId}", {
23829
+ params: {
23830
+ path: { loopId: loop.id },
23831
+ header: ifMatch(loop.version)
23832
+ },
23833
+ body: { paused: true }
23834
+ })).catch((err) => {
23835
+ if (err instanceof ApiProblem && err.status === 412) throw new CliError(`${loop.name} changed elsewhere in the meantime. Run \`monoban loops\` and try again.`);
23836
+ throw err;
23837
+ });
23838
+ if (options.json) ctx.out(JSON.stringify(paused, null, 2));
23839
+ else ctx.out(loop.paused ? `${loop.name} is already ${describeLoopState(loop.state, ENGLISH)}.` : `Paused ${loop.name}.`);
23840
+ if (paused.going) {
23841
+ const what = paused.going.ref ?? "its run";
23842
+ ctx.err(`Its run going now (${what}) goes on: cancel it from the board if it should stop too.`);
23843
+ }
23844
+ ctx.err(`Resume it in the browser: ${loopsTab(ctx, key)}`);
23845
+ }
23598
23846
  // src/commands/notes.ts
23599
23847
  const printNotes = (ctx, key, notes) => ctx.out(JSON.stringify({
23600
23848
  project: key,
@@ -23852,6 +24100,7 @@ const READ_ONLY = [
23852
24100
  "monoban comments",
23853
24101
  "monoban runs",
23854
24102
  "monoban runner status",
24103
+ "monoban loops",
23855
24104
  "monoban today",
23856
24105
  "monoban search",
23857
24106
  "monoban tags",
@@ -23988,6 +24237,7 @@ go?"). Once the user agrees:
23988
24237
  | \`monoban tags\` | the tags the project's tasks can have |
23989
24238
  | \`monoban notes show\` | the project's notes |
23990
24239
  | \`monoban runner status\` | whether this machine's runner (it runs agents on tasks, \`R\` on the board) is running, and why it stopped |
24240
+ | \`monoban loops\` | the project's agent loops (agents a runner starts on a timer) and what each is doing |
23991
24241
  | \`monoban add "TITLE" [-c COLUMN] [-t TAG]… [--date DAY] [-d TEXT \\| -d -]\` | add a task |
23992
24242
  | \`monoban edit MON-12 [--title TEXT] [-d TEXT \\| -d -]\` | replace its title or description |
23993
24243
  | \`monoban move MON-12 COLUMN\` | move it to the end of a column |
@@ -23999,6 +24249,7 @@ go?"). Once the user agrees:
23999
24249
  | \`monoban attach MON-12 --pr\` or \`monoban attach MON-12 URL\` | attach this branch's pull request, or any link |
24000
24250
  | \`monoban comment MON-12 TEXT\` (or \`-\` for stdin) | comment on it, in Markdown |
24001
24251
  | \`monoban notes add TEXT\` (or \`-\` for stdin) | add lines at the end of the notes |
24252
+ | \`monoban loop pause NAME\` | pause a loop when the user asks: it starts no new run until they resume it in the browser |
24002
24253
 
24003
24254
  Every command takes \`--json\`; project commands take \`-p KEY\`. \`monoban COMMAND --help\` has the rest.
24004
24255
  `;
@@ -24306,6 +24557,8 @@ too when agentpipe can run them: --no-loops, or "enabled": false, says no; "merg
24306
24557
  "full"
24307
24558
  ])).option("--ask", "wait for answers to its questions instead of deciding on its own (agentpipe)").option("-f, --follow", "print its steps until it ends (exit 0 only if it succeeded)").addOption(json()).action(async (ref, options) => run(await ctx(), ref, options));
24308
24559
  cli.command("runs").argument("<task>", "like MON-12").description("List a task's agent runs, newest first").addOption(json()).action(async (ref, options) => runs(await ctx(), ref, options));
24560
+ cli.command("loops").description("List a project's agent loops and what each is doing (make, change and resume them in the browser)").addOption(project()).addOption(json()).action(async (options) => loops(await ctx(), options));
24561
+ cli.command("loop").description("An agent loop: pause it (resume it in the browser)").command("pause").argument("<name>", "the loop's name, as `monoban loops` lists it").description("Pause a loop: it starts no new run until you resume it in the browser").addOption(project()).addOption(json()).action(async (name, options) => loopPause(await ctx(), name, options));
24309
24562
  cli.command("setup").addArgument(new Argument("<agent>", "which agent: claude (Claude Code) or codex").choices(AGENTS)).description("Teach a coding agent monoban: a skill to plan work as tasks (phases as tags) and keep them current").option("--project", "install it in this repository (to commit), not for you in every one").option("--print", "print the skill instead of installing it").option("--remove", "remove the skill").option("-f, --force", "replace (or remove) a skill monoban didn't write").addOption(json()).addHelpText("after", `
24310
24563
  It goes in ~/.claude/skills/monoban (Claude Code) or ~/.agents/skills/monoban (Codex); with --project,
24311
24564
  in .claude/skills or .agents/skills at the top of this repository. Run it again after upgrading monoban.`).action(async (agent, options) => setup(await ctx(), agent, options));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monoban",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Your monoban.dev kanban board in the terminal: add, move and start tasks, and hand them to coding agents.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://monoban.dev",