monoban 1.9.0 → 1.11.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 +429 -65
  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),
@@ -5970,15 +5970,10 @@ const CONTINUE_STEPS = [
5970
5970
  "merge"
5971
5971
  ];
5972
5972
  /**
5973
- * Why a deliver run stops before `merge` (plan §1.12): the loop doesn't merge (`mergeOff`); nobody queued its task
5974
- * from a browser (`queuedOutside`); or its title or description was written outside a browser after it was queued
5975
- * (`textChanged`). A loop merges on its own only what a person queued from a browser, and nothing has rewritten since.
5973
+ * Why a deliver run stops before `merge`: the loop doesn't merge (`mergeOff`). The rule that also held back a task
5974
+ * not queued from a browser (plan §1.12) was removed by the owner on 2026-11-16.
5976
5975
  */
5977
- const MERGE_HOLDS = [
5978
- "mergeOff",
5979
- "queuedOutside",
5980
- "textChanged"
5981
- ];
5976
+ const MERGE_HOLDS = ["mergeOff"];
5982
5977
  /**
5983
5978
  * Why a loop is paused: you paused it; `pauseAfter` runs in a row failed or needed you; or a run couldn't start
5984
5979
  * (the folder, agentpipe missing, a refusing precondition: the run says which).
@@ -7033,7 +7028,7 @@ const deliverFields = {
7033
7028
  column: IdSchema,
7034
7029
  /** Only tasks with this tag, which it takes off when it takes the task; null: every task in the column. */
7035
7030
  tag: IdSchema.nullable(),
7036
- /** Merge each pull request when its checks pass (only a task queued from the browser, plan §1.12). */
7031
+ /** Merge each pull request when its checks pass. */
7037
7032
  merge: boolean(),
7038
7033
  /** Its pull requests that may wait for you before it stops taking tasks. */
7039
7034
  maxOpen: wholeBetween(LOOP_LIMITS.deliverMaxOpen),
@@ -7122,6 +7117,14 @@ const RunStepSchema = object({
7122
7117
  * its column and tag had, and for a run that continues a pull request, the step it starts at, the pull request and
7123
7118
  * the run that opened it. Only the server writes it.
7124
7119
  */
7120
+ /**
7121
+ * The provisional decisions a person accepted for a continued run's merge: agentpipe's decision ids (`agentpipe
7122
+ * ratify` takes them) and the pull request's head commit they read them at.
7123
+ */
7124
+ const DecisionsAcceptSchema = strictObject({
7125
+ decisions: array(string().regex(/^[0-9a-f]{12}$/, "A decision id is 12 hex characters")).min(1).max(20),
7126
+ headSha: string().regex(/^[0-9a-f]{40}$/, "The full commit the decisions were read at")
7127
+ }).meta({ id: "DecisionsAccept" });
7125
7128
  const LoopRunPlanSchema = object({
7126
7129
  /** The loop's options when the run was made (its recipe's: DeliverOptionsSet or ScavengeOptionsSet). */
7127
7130
  options: union([DeliverOptionsSetSchema, ScavengeOptionsSetSchema]),
@@ -7135,8 +7138,15 @@ const LoopRunPlanSchema = object({
7135
7138
  prUrl: string().nullable(),
7136
7139
  /** The run that opened that pull request. */
7137
7140
  continues: IdSchema.nullable(),
7141
+ /**
7142
+ * That run's external id: agentpipe's run that opened the pull request (its branch is `agentpipe/<id>`), which
7143
+ * `agentpipe merge --expect-run` checks. Null when that run never said it.
7144
+ */
7145
+ externalId: string().nullable(),
7138
7146
  /** scavenge: how many tasks it may file (its `maxOpen` less its open tasks); null for deliver. */
7139
- limit: number$1().int().nonnegative().nullable()
7147
+ limit: number$1().int().nonnegative().nullable(),
7148
+ /** A run continued from merge after a person accepted the earlier run's provisional decisions; else null. */
7149
+ accept: DecisionsAcceptSchema.nullable().optional()
7140
7150
  }).meta({ id: "LoopRunPlan" });
7141
7151
  /** A coding agent working on a task, on one of your runners. */
7142
7152
  const TaskRunSchema = object({
@@ -7150,12 +7160,11 @@ const TaskRunSchema = object({
7150
7160
  /** What a loop's run was started with; null for a run started on a task. */
7151
7161
  loopRun: LoopRunPlanSchema.nullable(),
7152
7162
  /**
7153
- * A deliver loop's run: whether it may merge its pull request on its own (its loop merges, a browser queued its
7154
- * task, and nothing but a browser has written the task's text since; docs/PLAN-AGENT-LOOPS.md §1.12), read now.
7155
- * Null for a run that isn't a deliver loop's.
7163
+ * A deliver loop's run: whether it may merge its pull request on its own (its loop merges), read now. Null for a
7164
+ * run that isn't a deliver loop's.
7156
7165
  */
7157
7166
  mayMerge: boolean().nullable(),
7158
- /** Why it may not (`mergeOff`, `queuedOutside`, `textChanged`); null when it may, or isn't a deliver loop's. */
7167
+ /** Why it may not (`mergeOff`); null when it may, or isn't a deliver loop's. */
7159
7168
  mergeHold: _enum(MERGE_HOLDS).nullable(),
7160
7169
  runner: object({
7161
7170
  /** Null once the runner is gone. */
@@ -7381,13 +7390,24 @@ strictObject({
7381
7390
  /** The task's number in the loop's project (12 for MON-12). */
7382
7391
  task: number$1().int().min(1).max(2147483647).optional(),
7383
7392
  /** Continue the task's pull request from this step (`merge` only when the loop merges); needs `task`. */
7384
- from: _enum(CONTINUE_STEPS).optional()
7393
+ from: _enum(CONTINUE_STEPS).optional(),
7394
+ /**
7395
+ * With `from: "merge"`, from the browser only: the provisional decisions the last run reported, accepted. The run
7396
+ * ratifies them (`agentpipe ratify`) before it merges.
7397
+ */
7398
+ accept: DecisionsAcceptSchema.optional()
7385
7399
  }).refine((body) => body.from === void 0 || body.task !== void 0, {
7386
7400
  message: "Name the task whose pull request to continue",
7387
7401
  path: ["from"]
7402
+ }).refine((body) => body.accept === void 0 || body.from === "merge", {
7403
+ message: "Decisions are accepted for a merge: continue from merge",
7404
+ path: ["accept"]
7388
7405
  }).meta({
7389
7406
  id: "LoopRunCreate",
7390
- dependentRequired: { from: ["task"] }
7407
+ dependentRequired: {
7408
+ from: ["task"],
7409
+ accept: ["from"]
7410
+ }
7391
7411
  });
7392
7412
  PageQuerySchema.extend({
7393
7413
  from: DaySchema.describe("The first day (the client's today, for Today)"),
@@ -8105,7 +8125,7 @@ function matchColumn(columns, query) {
8105
8125
  choices: [...columns]
8106
8126
  };
8107
8127
  }
8108
- const DAY_MS = 864e5;
8128
+ const DAY_MS$1 = 864e5;
8109
8129
  /**
8110
8130
  * Whether a task is archived: archived by hand (in any column: in Done it's done, elsewhere it won't be), or
8111
8131
  * in its project's Done column (`doneColumnId`: doneColumn()) for longer than the project's
@@ -8118,11 +8138,11 @@ function isArchived(task, doneColumnId, archiveAfterDays, now = Date.now()) {
8118
8138
  }
8119
8139
  /** Whether a task has been in its column for longer than `archiveAfterDays` (in Done, that archives it). */
8120
8140
  function archivedByTime(task, archiveAfterDays, now = Date.now()) {
8121
- return archiveAfterDays !== null && Date.parse(task.columnSince) < now - archiveAfterDays * DAY_MS;
8141
+ return archiveAfterDays !== null && Date.parse(task.columnSince) < now - archiveAfterDays * DAY_MS$1;
8122
8142
  }
8123
8143
  // src/version.ts
8124
8144
  /** This CLI's version, from package.json (set at build time by tsdown, and by vitest in tests). */
8125
- const VERSION = "1.9.0";
8145
+ const VERSION = "1.11.0";
8126
8146
  /** Sent as X-Monoban-Client, and shown in Settings › CLI sessions. */
8127
8147
  const CLIENT = `cli/${VERSION}`;
8128
8148
  // src/api.ts
@@ -11667,8 +11687,8 @@ const RELEASES = `https://github.com/thiagodmont/homebrew-tap/releases`;
11667
11687
  * agentpipe comes with a new monoban: change these three lines (from the release's checksums.txt) and release.
11668
11688
  */
11669
11689
  const AGENTPIPE = {
11670
- version: "0.8.0",
11671
- wheelSha256: "e1e92ec985827359abd4fbb71c54ebcbdaf5636e810695b2ef321c64a7e20c26",
11690
+ version: "0.10.0",
11691
+ wheelSha256: "19f73117601ab8dabc8caabf63f6777c8eecf114e7e11acea2d6b40b653200d4",
11672
11692
  requirementsSha256: "41a8d073b0087efb80efafeb6a2b4750340d0f64920159cd4c723ed9167d0a98"
11673
11693
  };
11674
11694
  const agentpipeWheel = (version) => `agentpipe-${version}-py3-none-any.whl`;
@@ -11782,7 +11802,7 @@ async function latestVersion(ctx) {
11782
11802
  async function upgrade(ctx, options, kind = thisInstall()) {
11783
11803
  const latest = await latestVersion(ctx);
11784
11804
  const { how, command } = UPGRADE[kind];
11785
- const outdated = latest !== null && newer(latest, "1.9.0");
11805
+ const outdated = latest !== null && newer(latest, "1.11.0");
11786
11806
  if (options.json) {
11787
11807
  ctx.out(JSON.stringify({
11788
11808
  version: VERSION,
@@ -12367,6 +12387,46 @@ const str = (v) => typeof v === "string" && v.trim() ? v.trim() : null;
12367
12387
  const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
12368
12388
  /** A message the API takes: one line or more, at most 2000 characters. */
12369
12389
  const clip$1 = (text) => text.length > 2e3 ? `${text.slice(0, 1999)}…` : text;
12390
+ /** `merge.blocked`'s decisions: each with its id, question id, category and answer; anything else is left out. */
12391
+ function decisionsOf(value) {
12392
+ if (!Array.isArray(value)) return [];
12393
+ return value.flatMap((x) => {
12394
+ if (!x || typeof x !== "object") return [];
12395
+ const o = x;
12396
+ const [decisionId, questionId, category, answer] = [
12397
+ str(o.decision_id),
12398
+ str(o.question_id),
12399
+ str(o.category),
12400
+ str(o.answer)
12401
+ ];
12402
+ if (!decisionId || !/^[0-9a-f]{12}$/.test(decisionId) || !questionId || !category || !answer) return [];
12403
+ return [{
12404
+ decisionId,
12405
+ questionId,
12406
+ category,
12407
+ answer,
12408
+ question: str(o.question)
12409
+ }];
12410
+ });
12411
+ }
12412
+ /** `question.asked`'s questions: each with an id, a category and its text; anything else is left out. */
12413
+ function questionsOf(value) {
12414
+ if (!Array.isArray(value)) return [];
12415
+ return value.flatMap((q) => {
12416
+ if (!q || typeof q !== "object") return [];
12417
+ const { id, category, text } = q;
12418
+ const [i, c, t] = [
12419
+ str(id),
12420
+ str(category),
12421
+ str(text)
12422
+ ];
12423
+ return i && c && t ? [{
12424
+ id: i,
12425
+ category: c,
12426
+ text: t
12427
+ }] : [];
12428
+ });
12429
+ }
12370
12430
  /**
12371
12431
  * Turns agentpipe's events into monoban's, one at a time, remembering what it needs across them. agentpipe ends
12372
12432
  * each step twice: first with what the step decided (a skip says `skipped`, with its reason), then with what it
@@ -12387,6 +12447,9 @@ function agentpipeMapper(report) {
12387
12447
  let runEnded = false;
12388
12448
  /** CI's state as last said (`ci.check`), so only a change is reported: the loop polls every few seconds. */
12389
12449
  let ci = null;
12450
+ /** `scout --track`: the tasks its `file` step filed (their refs, else their URLs), and `run.end`'s counts. */
12451
+ const filed = [];
12452
+ let counts = null;
12390
12453
  const spent = () => report.update({ costUsd: Math.round((total + shipped) * 1e4) / 1e4 });
12391
12454
  const flush = (cost) => {
12392
12455
  if (!pending) return;
@@ -12567,6 +12630,20 @@ function agentpipeMapper(report) {
12567
12630
  });
12568
12631
  return;
12569
12632
  }
12633
+ case "issue.created": {
12634
+ const url = str(d.url);
12635
+ if (step !== "file" || d.reused === true || !url) return;
12636
+ const what = str(d.display) ?? (num(d.number) !== null ? `#${num(d.number)}` : url);
12637
+ filed.push(what);
12638
+ report.event({
12639
+ kind: "board",
12640
+ ...step && { step },
12641
+ message: clip$1(`filed ${what}`),
12642
+ data: { url: clip$1(url) },
12643
+ ...at && { at }
12644
+ });
12645
+ return;
12646
+ }
12570
12647
  case "issue.comment": {
12571
12648
  const milestone = str(d.milestone);
12572
12649
  report.event({
@@ -12587,6 +12664,20 @@ function agentpipeMapper(report) {
12587
12664
  });
12588
12665
  return;
12589
12666
  }
12667
+ const asked = e.kind === "question.asked" ? questionsOf(d.questions) : [];
12668
+ if (asked.length) {
12669
+ for (const q of asked) report.event({
12670
+ kind: "question",
12671
+ ...step && { step },
12672
+ message: clip$1(q.text),
12673
+ data: {
12674
+ questionId: q.id,
12675
+ category: q.category
12676
+ },
12677
+ ...at && { at }
12678
+ });
12679
+ return;
12680
+ }
12590
12681
  const text = str(d.question) ?? str(d.text) ?? str(d.message) ?? str(d.reason) ?? "It needs an answer.";
12591
12682
  report.event({
12592
12683
  kind: "question",
@@ -12611,6 +12702,7 @@ function agentpipeMapper(report) {
12611
12702
  runEnded = true;
12612
12703
  const status = str(d.status) ?? "failed";
12613
12704
  said = status;
12705
+ if (d.counts && typeof d.counts === "object") counts = Object.fromEntries(Object.entries(d.counts).flatMap(([k, v]) => num(v) === null ? [] : [[k, v]]));
12614
12706
  const reason = str(d.reason);
12615
12707
  const says = SAYS[status];
12616
12708
  ending = {
@@ -12645,6 +12737,20 @@ function agentpipeMapper(report) {
12645
12737
  message: ending.reason ?? "",
12646
12738
  ...at && { at }
12647
12739
  });
12740
+ const headSha = str(d.head_sha);
12741
+ if (headSha && /^[0-9a-f]{40}$/.test(headSha)) for (const decision of decisionsOf(d.decisions)) report.event({
12742
+ kind: "question",
12743
+ ...step && { step },
12744
+ message: clip$1(decision.question ?? decision.answer),
12745
+ data: {
12746
+ decisionId: decision.decisionId,
12747
+ questionId: decision.questionId,
12748
+ category: decision.category,
12749
+ answer: decision.answer.slice(0, 2e3),
12750
+ headSha
12751
+ },
12752
+ ...at && { at }
12753
+ });
12648
12754
  return;
12649
12755
  }
12650
12756
  case "ship.end": {
@@ -12689,6 +12795,9 @@ function agentpipeMapper(report) {
12689
12795
  said: () => said,
12690
12796
  /** Its `run.end` came: anything after is a ship loop's (`address --ship`). */
12691
12797
  runEnded: () => runEnded,
12798
+ /** What `scout --track` filed (refs, in order), and the numbers behind how it ended (`run.end`'s counts). */
12799
+ filed: () => [...filed],
12800
+ counts: () => counts,
12692
12801
  flush: () => flush()
12693
12802
  };
12694
12803
  }
@@ -12866,7 +12975,11 @@ const RECIPE_NEEDS = {
12866
12975
  "merge.json",
12867
12976
  "merge.expect_run"
12868
12977
  ],
12869
- scavenge: ["scout.json", "scout.track"]
12978
+ scavenge: [
12979
+ "scout.json",
12980
+ "scout.track",
12981
+ "run.dry_run_json"
12982
+ ]
12870
12983
  };
12871
12984
  /** The recipes an agentpipe can run, from what it says it has. */
12872
12985
  function recipesOf(capabilities) {
@@ -18005,6 +18118,11 @@ var en_US_default = {
18005
18118
  "label": "Run {name} now",
18006
18119
  "help": "Run loop now"
18007
18120
  },
18121
+ "continue": {
18122
+ "label": "Continue {ref}'s pull request from {step}",
18123
+ "help": "Continue a run's pull request",
18124
+ "keywords": "continue resume retry pull request merge checks feedback"
18125
+ },
18008
18126
  "delete": {
18009
18127
  "label": "Delete {name}",
18010
18128
  "help": "Delete loop"
@@ -18094,10 +18212,12 @@ var en_US_default = {
18094
18212
  "now": "now",
18095
18213
  "task": "task",
18096
18214
  "pr": "PR",
18097
- "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}}.",
18215
+ "hold": "{going, select, yes {Stops before merge} other {Stopped before merge}}: merge is off for this loop.",
18098
18216
  "waiting": "Waiting for you",
18099
- "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."
18217
+ "waits": "<pr>{ref}'s pull request</pr> is ready for you to merge: merge is off for this loop.",
18218
+ "waitsOpen": "<pr>{ref}'s pull request</pr> waits for you.",
18219
+ "continue": "Continue {ref}'s pull request",
18220
+ "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
18221
  },
18102
18222
  runs: {
18103
18223
  "heading": "Runs",
@@ -18133,7 +18253,7 @@ var en_US_default = {
18133
18253
  "onlyTagged": "Only tasks tagged",
18134
18254
  "anyTag": "any tag: every task in the column",
18135
18255
  "merge": "Merge each pull request when its checks pass",
18136
- "mergeHint": "Only the tasks you queued from the browser. The others wait for you to merge.",
18256
+ "mergeHint": "Off: each pull request waits for you to merge.",
18137
18257
  "deliverMaxOpen": "Pull requests that may wait for you",
18138
18258
  "checksMinutes": "Wait for checks (minutes)",
18139
18259
  "reviewTier": "Review on",
@@ -18151,7 +18271,7 @@ var en_US_default = {
18151
18271
  "budgetUsdPerDay": "Budget per day (US$)",
18152
18272
  "pauseAfter": "Pause after runs in a row",
18153
18273
  "summary": {
18154
- "deliver": "Every {interval}, on {runner}, it takes {tagged, select, yes {the tasks tagged #{tag} in {column}} other {every task in {column}}}, one at a time, up to {perDay} a day, and opens a pull request for each. {merge, select, yes {It merges each one when its checks pass, for the tasks you queued from the browser; the others wait for you to merge.} other {It leaves each one for you to merge.}} It stops taking tasks while {maxOpen, plural, one {# pull request waits} other {# pull requests wait}} for you, spends at most {budget} a run and {budgetDay} a day, and pauses after {pauseAfter, plural, one {a run that fails or needs you} other {# runs in a row that fail or need you}}.",
18274
+ "deliver": "Every {interval}, on {runner}, it takes {tagged, select, yes {the tasks tagged #{tag} in {column}} other {every task in {column}}}, one at a time, up to {perDay} a day, and opens a pull request for each. {merge, select, yes {It merges each one when its checks pass.} other {It leaves each one for you to merge.}} It stops taking tasks while {maxOpen, plural, one {# pull request waits} other {# pull requests wait}} for you, spends at most {budget} a run and {budgetDay} a day, and pauses after {pauseAfter, plural, one {a run that fails or needs you} other {# runs in a row that fail or need you}}.",
18155
18275
  "scavenge": "Every {interval}, on {runner}, it looks for: {focus}. It files what it finds in {column}, tagged #{tag}, and stops filing while {maxOpen, plural, one {# of those tasks is} other {# of those tasks are}} open. It spends at most {budget} a run and {budgetDay} a day, and pauses after {pauseAfter, plural, one {a run that fails or needs you} other {# runs in a row that fail or need you}}.",
18156
18276
  "incomplete": "Fill in the fields above to see what the loop will do."
18157
18277
  },
@@ -18190,7 +18310,8 @@ var en_US_default = {
18190
18310
  "pause": "Pause",
18191
18311
  "resume": "Resume",
18192
18312
  "edit": "Edit",
18193
- "delete": "Delete"
18313
+ "delete": "Delete",
18314
+ "continueFrom": "From {step}"
18194
18315
  },
18195
18316
  toast: {
18196
18317
  "created": "Created {name}.",
@@ -18199,7 +18320,8 @@ var en_US_default = {
18199
18320
  "resumed": "Resumed {name}.",
18200
18321
  "queued": "{name} runs at its runner's next check-in.",
18201
18322
  "deleted": "Deleted {name}.",
18202
- "failed": "That didn't work: try again."
18323
+ "failed": "That didn't work: try again.",
18324
+ "continued": "{ref} continues from {step} at its runner's next check-in."
18203
18325
  }
18204
18326
  },
18205
18327
  notes: {
@@ -18629,6 +18751,7 @@ var en_US_default = {
18629
18751
  "took": "took",
18630
18752
  "pr": "PR",
18631
18753
  "why": "why",
18754
+ "result": "result",
18632
18755
  "queuedOnline": "{runner} starts it when it next checks in, within a minute.",
18633
18756
  "queuedOffline": "{runner} is offline: it starts once <code>monoban runner</code> runs there.",
18634
18757
  "steps": "Steps",
@@ -18638,6 +18761,7 @@ var en_US_default = {
18638
18761
  "none": "none",
18639
18762
  "now": "now",
18640
18763
  "reported": "What it reported",
18764
+ "yoursToDecide": "only you can decide this",
18641
18765
  "latest": "latest",
18642
18766
  "event": {
18643
18767
  "pr_opened": "PR",
@@ -18812,11 +18936,7 @@ var en_US_default = {
18812
18936
  "due": "starting",
18813
18937
  "next": "next at {time}"
18814
18938
  },
18815
- "hold": {
18816
- "mergeOff": "merge is off for this loop",
18817
- "queuedOutside": "its task was queued outside the browser",
18818
- "textChanged": "its text was changed outside the browser after you queued it"
18819
- }
18939
+ "hold": { "mergeOff": "merge is off for this loop" }
18820
18940
  },
18821
18941
  history: {
18822
18942
  "verb": {
@@ -19660,9 +19780,43 @@ function formatCost(usd, { locale }) {
19660
19780
  }).format(usd);
19661
19781
  }
19662
19782
  // ../../packages/i18n/src/loops.ts
19783
+ const DAY_MS = 864e5;
19663
19784
  /**
19664
- * Why a deliver run won't merge on its own (contract's `mergeHoldOf`, plan §1.12), in a few words: "its task was
19665
- * queued outside the browser". The loops tab says the same in its own sentences (loops.json `detail.waits`).
19785
+ * A loop's state in a few words (contract's `loopState`): "paused", "mbp is offline", "a pull request waits for
19786
+ * you", "next at 14:05". A start more than a day away says its day too ("next at Fri 09:00"). `now`: the
19787
+ * clock it's said against, for that. The time is in the reader's own time zone (the browser's, the terminal's),
19788
+ * so this is for the web and the CLI, never an email (those say UTC: `momentFormat`).
19789
+ */
19790
+ function describeLoopState({ state, nextAt, why }, words, now = Date.now()) {
19791
+ const { t, locale } = words;
19792
+ const count = why.count ?? 0;
19793
+ switch (state) {
19794
+ case "paused": return t(`loop.state.paused.${why.reason ?? "you"}`);
19795
+ case "noRunner":
19796
+ case "running":
19797
+ case "waitingForTask":
19798
+ case "due": return t(`loop.state.${state}`);
19799
+ case "runnerOffline":
19800
+ case "runnerOutdated": return t(`loop.state.${state}`, { runner: why.runner ?? "" });
19801
+ case "waitingForYou": return t(`loop.state.waitingForYou.${why.of ?? "pullRequests"}`, { count });
19802
+ case "dailyLimit": return t("loop.state.dailyLimit", { count });
19803
+ case "budget": return t("loop.state.budget", {
19804
+ spent: formatCost(why.spent ?? 0, words),
19805
+ limit: formatCost(why.limit ?? 0, words)
19806
+ });
19807
+ case "next": {
19808
+ const at = nextAt ? Date.parse(nextAt) : now;
19809
+ return t("loop.state.next", { time: new Intl.DateTimeFormat(locale, {
19810
+ ...at - now >= DAY_MS && { weekday: "short" },
19811
+ hour: "2-digit",
19812
+ minute: "2-digit"
19813
+ }).format(at) });
19814
+ }
19815
+ }
19816
+ }
19817
+ /**
19818
+ * Why a deliver run won't merge on its own (contract's `mergeHoldOf`), in a few words: "merge is off for this loop".
19819
+ * The loops tab says the same in its own sentences (loops.json `detail.waits`).
19666
19820
  */
19667
19821
  function describeMergeHold(hold, { t }) {
19668
19822
  return t(`loop.hold.${hold}`);
@@ -19895,15 +20049,15 @@ async function projects(ctx, options) {
19895
20049
  const { bold, dim } = ctx.style;
19896
20050
  const keyWidth = Math.max(...all.map((p) => p.key.length));
19897
20051
  const nameWidth = Math.max(...all.map((p) => [...p.name].length));
19898
- const countWidth = Math.max(...all.map((p) => tasks(p).length));
20052
+ const countWidth = Math.max(...all.map((p) => tasks$1(p).length));
19899
20053
  for (const p of all) {
19900
20054
  const mark = here ? p.key === here ? "* " : " " : "";
19901
20055
  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 ?? "")}`;
20056
+ const line = `${mark}${bold(p.key.padEnd(keyWidth))} ${name} ${dim(tasks$1(p).padEnd(countWidth))} ${dim(p.repo ?? "")}`;
19903
20057
  ctx.out(line.trimEnd());
19904
20058
  }
19905
20059
  }
19906
- const tasks = (p) => `${p.taskCount} ${p.taskCount === 1 ? "task" : "tasks"}`;
20060
+ const tasks$1 = (p) => `${p.taskCount} ${p.taskCount === 1 ? "task" : "tasks"}`;
19907
20061
  /**
19908
20062
  * `monoban list [COLUMN…]`: the board, by column (every column, or the ones named); `--tag` keeps a tag's
19909
20063
  * tasks. `--archived`: the archived ones instead (done a while ago, or won't do: with why).
@@ -21419,9 +21573,8 @@ codexSpec();
21419
21573
  /**
21420
21574
  * `deliver` (docs/PLAN-AGENT-LOOPS.md §1.6): takes a task and delivers it as a pull request: `implement` opens it
21421
21575
  * (a draft), `review` reviews and fixes it, `checks` sees CI green (repairing it) and marks it ready, `feedback`
21422
- * answers its review comments, and `merge` merges it when the run may (plan §1.12: the loop merges, a browser queued
21423
- * the task, nothing but a browser rewrote it since, and this machine allows it). Otherwise the run ends with its pull
21424
- * request ready for you to merge, saying why.
21576
+ * answers its review comments, and `merge` merges it when the run may (the loop merges, and this machine allows it).
21577
+ * Otherwise the run ends with its pull request ready for you to merge, saying why.
21425
21578
  */
21426
21579
  /** A deliver loop's options this recipe reads (the run's plan has them as the loop had them). */
21427
21580
  function options(run) {
@@ -21516,6 +21669,35 @@ function mergeArgs(run, pr, runId) {
21516
21669
  "--json"
21517
21670
  ];
21518
21671
  }
21672
+ /** `agentpipe ratify`: accepts one provisional decision of the run that opened the pull request, at a commit. */
21673
+ function ratifyArgs(decision, runId, headSha) {
21674
+ return [
21675
+ "ratify",
21676
+ decision,
21677
+ runId,
21678
+ "--at",
21679
+ headSha,
21680
+ "--by",
21681
+ "monoban (accepted in the browser)"
21682
+ ];
21683
+ }
21684
+ /**
21685
+ * Continued after a person accepted the last run's decisions in the browser: each ratified at the commit they read,
21686
+ * so a merge of anything newer still refuses (agentpipe binds a ratification to its commit). How it stopped, or
21687
+ * null when agentpipe took them all.
21688
+ */
21689
+ async function ratify(ctx, runId, accept) {
21690
+ for (const decision of accept.decisions) {
21691
+ const ratified = await ctx.agentpipe(ratifyArgs(decision, runId, accept.headSha));
21692
+ if (ratified.ending?.status === "cancelled") return endOf(ratified, "agentpipe ratify");
21693
+ const { exit } = ratified;
21694
+ if (exit.code !== 0) return {
21695
+ status: "needs_human",
21696
+ message: `agentpipe didn't accept decision ${decision}: ${exit.spawnError ?? exit.lastError ?? `\`agentpipe ratify ${decision} ${runId}\` says why`}.`
21697
+ };
21698
+ }
21699
+ return null;
21700
+ }
21519
21701
  /** A step on the run's pull request, skipped when it has none (`implement` found nothing to change). */
21520
21702
  const onPr = (fn) => (ctx) => ctx.pr ? fn(ctx, ctx.pr) : Promise.resolve(skipped("There's no pull request."));
21521
21703
  /** A step's ending from how its command ended: agentpipe's word, else why it stopped without one. */
@@ -21594,6 +21776,8 @@ const deliver = {
21594
21776
  if (!ctx.runId) return skipped("Ready for you to merge: agentpipe didn't say which run opened it.");
21595
21777
  const why = await ctx.mayMerge();
21596
21778
  if (why) return skipped(`Ready for you to merge: ${why}.`);
21779
+ const refused = ctx.run.plan.accept ? await ratify(ctx, ctx.runId, ctx.run.plan.accept) : null;
21780
+ if (refused) return refused;
21597
21781
  const end = endOf(await ctx.agentpipe(mergeArgs(ctx.run, pr, ctx.runId)), "agentpipe merge");
21598
21782
  return end.status === "needs_human" ? {
21599
21783
  ...end,
@@ -21602,8 +21786,8 @@ const deliver = {
21602
21786
  })
21603
21787
  }
21604
21788
  },
21605
- dryRun: (run) => run.ref ? [...implementArgs(run, run.budgetUsd), "--dry-run"] : null,
21606
- tier: reviewTierOf,
21789
+ dryRun: (run) => run.ref && run.plan.from !== "merge" ? [...implementArgs(run, run.budgetUsd), "--dry-run"] : null,
21790
+ tier: (run) => run.plan.from ? null : reviewTierOf(run),
21607
21791
  finished: ({ pr, last }) => {
21608
21792
  if (!pr) return null;
21609
21793
  if (last?.step === "merge" && last.status === "ok") return last.message ?? "Merged.";
@@ -21659,6 +21843,72 @@ function alive(pid) {
21659
21843
  return err.code === "EPERM";
21660
21844
  }
21661
21845
  }
21846
+ /**
21847
+ * `agentpipe scout`: surveys origin's default branch (`--fresh-base`) for what the loop's focus asks, and files what it
21848
+ * finds where the loop says, on what is left of the budget. The user's words go after `=`, so a focus starting with
21849
+ * `-` stays a value.
21850
+ */
21851
+ function scoutArgs(run, budgetUsd) {
21852
+ const { focus } = run.plan.options;
21853
+ return [
21854
+ "scout",
21855
+ run.workdir,
21856
+ "--json",
21857
+ "--fresh-base",
21858
+ `--focus=${focus}`,
21859
+ "--limit",
21860
+ String(Math.min(run.plan.limit ?? 0, 20)),
21861
+ "--track",
21862
+ `--column=${run.plan.columnName ?? ""}`,
21863
+ `--label=${run.plan.tagName ?? ""}`,
21864
+ "--budget",
21865
+ usd(budgetUsd)
21866
+ ];
21867
+ }
21868
+ const tasks = (n) => n === 1 ? "1 task" : `${n} tasks`;
21869
+ /** What a scout run filed, in words: the refs, what it left for later, and what was on the board already. */
21870
+ function filedSaying(result) {
21871
+ const { filed, counts } = result;
21872
+ const later = counts?.over_limit ?? 0;
21873
+ const already = counts?.already_filed ?? 0;
21874
+ const more = later ? `; ${later === 1 ? "1 more waits" : `${later} more wait`} until you close some` : "";
21875
+ if (filed.length) return `Filed ${tasks(filed.length)}: ${filed.join(", ")}${more}.`;
21876
+ if (already) return `Nothing new to file (${tasks(already)} it found ${already === 1 ? "is" : "are"} filed already)${more}.`;
21877
+ return `Nothing new to file${more}.`;
21878
+ }
21879
+ const scavenge = {
21880
+ steps: { scout: {
21881
+ pollSeconds: 15,
21882
+ run: async (ctx) => {
21883
+ const { limit, columnName, tagName } = ctx.run.plan;
21884
+ if (!limit || limit < 1) return skipped("Nothing to file: its open tasks are at its limit.");
21885
+ if (!columnName) return failed("The column it files in is gone: choose another for the loop.");
21886
+ if (!tagName) return failed("The tag it files with is gone: choose another for the loop.");
21887
+ const result = await ctx.agentpipe(scoutArgs(ctx.run, ctx.budgetUsd));
21888
+ const end = endOf(result, "agentpipe scout");
21889
+ if (end.status === "ok") return {
21890
+ ...end,
21891
+ message: filedSaying(result)
21892
+ };
21893
+ if (result.filed.length) return {
21894
+ ...end,
21895
+ message: `${end.message ?? "It stopped"} (it filed ${result.filed.join(", ")} first)`
21896
+ };
21897
+ return end;
21898
+ }
21899
+ } },
21900
+ dryRun: (run) => [
21901
+ "run",
21902
+ run.workdir,
21903
+ "--json",
21904
+ "--fresh-base",
21905
+ "--budget",
21906
+ usd(run.budgetUsd),
21907
+ "--dry-run"
21908
+ ],
21909
+ sandboxed: ["scout"],
21910
+ finished: ({ last }) => last?.message ?? null
21911
+ };
21662
21912
  // src/runner/recipes/index.ts
21663
21913
  /** A pull request's number, from its URL (…/pull/42), or null. */
21664
21914
  function prOf(url) {
@@ -21670,7 +21920,7 @@ function prOf(url) {
21670
21920
  }
21671
21921
  const RECIPES = {
21672
21922
  deliver,
21673
- scavenge: null
21923
+ scavenge
21674
21924
  };
21675
21925
  /** The recipes this monoban runs: a runner names these, of those its agentpipe can run (MON-202). */
21676
21926
  const RECIPES_HERE = RECIPE_NAMES.filter((name) => RECIPES[name] !== null);
@@ -21698,10 +21948,17 @@ function runRecipe(name, run, report, deps) {
21698
21948
  const { step } = steps(report, () => cancelled);
21699
21949
  /** What the run has spent so far, over all its commands. */
21700
21950
  let spent = 0;
21701
- /** Its pull request, and the run id the server keeps: the first agentpipe run's (`merge --expect-run` needs it). */
21951
+ /**
21952
+ * Its pull request, and the run id the server keeps: the first agentpipe run's (`merge --expect-run` needs it). A
21953
+ * run that continues a pull request has both from the run that opened it (its plan, through the server).
21954
+ */
21702
21955
  let pr = prOf(run.plan.prUrl);
21703
- let runId = null;
21956
+ let runId = run.plan.from ? run.plan.externalId : null;
21704
21957
  const leases = deps.leases ?? shipLeases(deps.env);
21958
+ const projectEnv = {
21959
+ ...deps.env,
21960
+ MONOBAN_PROJECT: run.project
21961
+ };
21705
21962
  const command = (outer) => async (args) => {
21706
21963
  if (cancelled) return {
21707
21964
  ending: {
@@ -21716,7 +21973,9 @@ function runRecipe(name, run, report, deps) {
21716
21973
  externalId: null,
21717
21974
  prUrl: null,
21718
21975
  costUsd: 0,
21719
- said: null
21976
+ said: null,
21977
+ filed: [],
21978
+ counts: null
21720
21979
  };
21721
21980
  let externalId = null;
21722
21981
  let prUrl = null;
@@ -21775,7 +22034,7 @@ function runRecipe(name, run, report, deps) {
21775
22034
  command: deps.command,
21776
22035
  args,
21777
22036
  cwd: run.workdir,
21778
- env: deps.env,
22037
+ env: projectEnv,
21779
22038
  monobanBin: deps.monobanBin,
21780
22039
  map: (event) => {
21781
22040
  feed.take(event);
@@ -21803,7 +22062,9 @@ function runRecipe(name, run, report, deps) {
21803
22062
  externalId,
21804
22063
  prUrl,
21805
22064
  costUsd: cost,
21806
- said
22065
+ said,
22066
+ filed: feed.filed(),
22067
+ counts: feed.counts()
21807
22068
  };
21808
22069
  };
21809
22070
  return {
@@ -21812,15 +22073,26 @@ function runRecipe(name, run, report, deps) {
21812
22073
  status: "failed",
21813
22074
  reason: `This monoban can't run ${name} loops yet.`
21814
22075
  };
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
22076
  const order = RECIPES$1[name].steps;
22077
+ const from = run.plan.from ? order.indexOf(run.plan.from) : 0;
22078
+ if (run.plan.from) {
22079
+ if (from < 0 || !pr) return {
22080
+ status: "failed",
22081
+ reason: `There's no pull request to continue from ${run.plan.from}.`
22082
+ };
22083
+ report.update({
22084
+ prUrl: pr.url,
22085
+ ...runId && { externalId: runId }
22086
+ });
22087
+ }
21820
22088
  let last = null;
21821
- for (const stepName of order) {
22089
+ for (const [i, stepName] of order.entries()) {
21822
22090
  const s = recipe.steps[stepName];
21823
22091
  if (!s) continue;
22092
+ if (i < from) {
22093
+ await step(stepName, async () => skipped(`The run it continues did this (it continues from ${run.plan.from}).`));
22094
+ continue;
22095
+ }
21824
22096
  const stop = await deps.recheck?.() ?? null;
21825
22097
  if (stop) return {
21826
22098
  status: "cancelled",
@@ -22037,7 +22309,7 @@ function runBoard(api) {
22037
22309
  async function preflight(run, recipe, deps) {
22038
22310
  const args = recipe.dryRun(run);
22039
22311
  if (args) {
22040
- const refused = await dryRun(run, args, deps);
22312
+ const refused = await dryRun(run, args, recipe.sandboxed ?? null, deps);
22041
22313
  if (refused) return refused;
22042
22314
  }
22043
22315
  const tier = recipe.tier?.(run) ?? null;
@@ -22048,7 +22320,7 @@ async function preflight(run, recipe, deps) {
22048
22320
  }
22049
22321
  return null;
22050
22322
  }
22051
- async function dryRun(run, args, deps) {
22323
+ async function dryRun(run, args, only, deps) {
22052
22324
  let preview = null;
22053
22325
  const exit = await agentpipeCommand({
22054
22326
  command: deps.command,
@@ -22070,7 +22342,10 @@ async function dryRun(run, args, deps) {
22070
22342
  return clip(`agentpipe's dry run refused it (exit code ${exit.code ?? "none"})${last}`, 1e3);
22071
22343
  }
22072
22344
  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");
22345
+ const steps = said.steps ?? [];
22346
+ const unseen = (only ?? []).filter((name) => !steps.some((s) => s.name === name && s.boundary));
22347
+ if (unseen.length) return `agentpipe's dry run didn't show ${unseen.join(", ")}, so its sandbox can't be checked.`;
22348
+ 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
22349
  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
22350
  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
22351
  return null;
@@ -22338,6 +22613,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
22338
22613
  loopRun = {
22339
22614
  id: run.id,
22340
22615
  ref,
22616
+ project: run.project.key,
22341
22617
  workdir: run.workdir,
22342
22618
  plan: run.loopRun,
22343
22619
  budgetUsd: Math.min(budget, left)
@@ -22420,7 +22696,7 @@ async function runRunner(ctx, settings, deps, options = {}) {
22420
22696
  }
22421
22697
  }
22422
22698
  /**
22423
- * Right before a loop's run merges (plan §1.12): null when it may, else why not. This machine's `loops.merge:
22699
+ * Right before a loop's run merges: null when it may, else why not. This machine's `loops.merge:
22424
22700
  * false` says no; otherwise the server, reading the run now (`mayMerge`). Anything but its yes is a no.
22425
22701
  */
22426
22702
  async function mayMerge(runId) {
@@ -22994,7 +23270,7 @@ function describe({ state, running }, board, now) {
22994
23270
  const seenAgo = `checked in ${since(board.lastSeenAt, now)} ago (every ${board.pollSeconds}s)`;
22995
23271
  row("board", `${board.online ? "online" : "offline"} · ${seenAgo}`);
22996
23272
  } else if (!state.runnerId) row("board", "not on the board yet: it's starting");
22997
- if (state.version !== "1.9.0") {
23273
+ if (state.version !== "1.11.0") {
22998
23274
  const again = state.background ? "`monoban runner restart`" : "start it again in its terminal";
22999
23275
  row("update", `it runs monoban ${state.version}, this is ${VERSION}: ${again}`);
23000
23276
  }
@@ -23432,7 +23708,7 @@ async function checks(ctx, deps = {}) {
23432
23708
  const found = [];
23433
23709
  const latest = await (deps.latest ?? latestVersion)(ctx);
23434
23710
  const upgrade = UPGRADE[thisInstall()].command;
23435
- found.push(latest && newer(latest, "1.9.0") ? {
23711
+ found.push(latest && newer(latest, "1.11.0") ? {
23436
23712
  name: "monoban",
23437
23713
  status: "warn",
23438
23714
  detail: `${VERSION}; ${latest} is out`,
@@ -23595,6 +23871,89 @@ async function doctor(ctx, options, deps = {}) {
23595
23871
  }
23596
23872
  if (found.some((c) => c.status === "fail")) throw new CliError("", EXIT.error);
23597
23873
  }
23874
+ // src/commands/loops.ts
23875
+ /** Every loop of the project, in the API's order (oldest first). */
23876
+ async function loopsOf(api, key) {
23877
+ const all = [];
23878
+ for await (const loop of pages((cursor) => unwrap(api.GET("/v1/projects/{key}/loops", { params: {
23879
+ path: { key },
23880
+ query: { cursor }
23881
+ } })).then((page) => ({
23882
+ items: page.loops,
23883
+ nextCursor: page.nextCursor
23884
+ })))) all.push(loop);
23885
+ return all;
23886
+ }
23887
+ /** Where a project's loops are made, changed and resumed. */
23888
+ const loopsTab = (ctx, key) => `${ctx.webUrl}/p/${key}?view=loops`;
23889
+ /** What it's doing, in a few words: its state, and while a run goes, the step and task. */
23890
+ function loopDoing(loop, now = Date.now()) {
23891
+ const state = describeLoopState(loop.state, ENGLISH, now);
23892
+ const going = loop.going && [loop.going.step, loop.going.ref].filter(Boolean).join(" on ");
23893
+ return going ? `${state}: ${going}` : state;
23894
+ }
23895
+ /** "Deliver deliver running: implement on MON-12 mbp 24h: 2 runs, $1.23". */
23896
+ function loopLine(loop, widths, now = Date.now()) {
23897
+ const day = loop.last24h.runs ? `24h: ${loop.last24h.runs} ${loop.last24h.runs === 1 ? "run" : "runs"}, ${formatCost(loop.last24h.costUsd, ENGLISH)}` : "24h: no runs";
23898
+ return [
23899
+ loop.name.padEnd(widths.name),
23900
+ loop.recipe.padEnd(widths.recipe),
23901
+ loopDoing(loop, now),
23902
+ loop.runner.name,
23903
+ day
23904
+ ].join(" ");
23905
+ }
23906
+ /** `monoban loops`: the project's loops and what each is doing. */
23907
+ async function loops(ctx, options) {
23908
+ const api = apis(ctx).signedIn;
23909
+ const key = await resolveProject(ctx, api, options.project);
23910
+ const all = await loopsOf(api, key);
23911
+ if (options.json) return ctx.out(JSON.stringify(all, null, 2));
23912
+ if (!all.length) {
23913
+ ctx.err(`${key} has no loops yet. Make one in its loops tab: ${loopsTab(ctx, key)}`);
23914
+ return;
23915
+ }
23916
+ const widths = {
23917
+ name: Math.max(...all.map((l) => [...l.name].length)),
23918
+ recipe: Math.max(...all.map((l) => l.recipe.length))
23919
+ };
23920
+ for (const loop of all) ctx.out(loopLine(loop, widths));
23921
+ }
23922
+ /** The loop named `name` (any case, or its id), or a not-found error that names the project's loops. */
23923
+ function findLoop(all, name, key) {
23924
+ const wanted = name.trim().toLowerCase();
23925
+ const found = all.find((l) => l.name.toLowerCase() === wanted || l.id === name.trim());
23926
+ if (found) return found;
23927
+ const names = all.map((l) => `"${l.name}"`).join(", ");
23928
+ throw new CliError(`${key} has no loop named "${name}"${names ? ` (its loops: ${names})` : ""}.`, EXIT.notFound);
23929
+ }
23930
+ /**
23931
+ * `monoban loop pause NAME`: it starts no new run until it's resumed in the browser. A run it has going goes on:
23932
+ * cancel that from the board.
23933
+ */
23934
+ async function loopPause(ctx, name, options) {
23935
+ const api = apis(ctx).signedIn;
23936
+ const key = await resolveProject(ctx, api, options.project);
23937
+ const loop = findLoop(await loopsOf(api, key), name, key);
23938
+ let paused = loop;
23939
+ if (!loop.paused) paused = await unwrap(api.PATCH("/v1/loops/{loopId}", {
23940
+ params: {
23941
+ path: { loopId: loop.id },
23942
+ header: ifMatch(loop.version)
23943
+ },
23944
+ body: { paused: true }
23945
+ })).catch((err) => {
23946
+ if (err instanceof ApiProblem && err.status === 412) throw new CliError(`${loop.name} changed elsewhere in the meantime. Run \`monoban loops\` and try again.`);
23947
+ throw err;
23948
+ });
23949
+ if (options.json) ctx.out(JSON.stringify(paused, null, 2));
23950
+ else ctx.out(loop.paused ? `${loop.name} is already ${describeLoopState(loop.state, ENGLISH)}.` : `Paused ${loop.name}.`);
23951
+ if (paused.going) {
23952
+ const what = paused.going.ref ?? "its run";
23953
+ ctx.err(`Its run going now (${what}) goes on: cancel it from the board if it should stop too.`);
23954
+ }
23955
+ ctx.err(`Resume it in the browser: ${loopsTab(ctx, key)}`);
23956
+ }
23598
23957
  // src/commands/notes.ts
23599
23958
  const printNotes = (ctx, key, notes) => ctx.out(JSON.stringify({
23600
23959
  project: key,
@@ -23852,6 +24211,7 @@ const READ_ONLY = [
23852
24211
  "monoban comments",
23853
24212
  "monoban runs",
23854
24213
  "monoban runner status",
24214
+ "monoban loops",
23855
24215
  "monoban today",
23856
24216
  "monoban search",
23857
24217
  "monoban tags",
@@ -23988,6 +24348,7 @@ go?"). Once the user agrees:
23988
24348
  | \`monoban tags\` | the tags the project's tasks can have |
23989
24349
  | \`monoban notes show\` | the project's notes |
23990
24350
  | \`monoban runner status\` | whether this machine's runner (it runs agents on tasks, \`R\` on the board) is running, and why it stopped |
24351
+ | \`monoban loops\` | the project's agent loops (agents a runner starts on a timer) and what each is doing |
23991
24352
  | \`monoban add "TITLE" [-c COLUMN] [-t TAG]… [--date DAY] [-d TEXT \\| -d -]\` | add a task |
23992
24353
  | \`monoban edit MON-12 [--title TEXT] [-d TEXT \\| -d -]\` | replace its title or description |
23993
24354
  | \`monoban move MON-12 COLUMN\` | move it to the end of a column |
@@ -23999,6 +24360,7 @@ go?"). Once the user agrees:
23999
24360
  | \`monoban attach MON-12 --pr\` or \`monoban attach MON-12 URL\` | attach this branch's pull request, or any link |
24000
24361
  | \`monoban comment MON-12 TEXT\` (or \`-\` for stdin) | comment on it, in Markdown |
24001
24362
  | \`monoban notes add TEXT\` (or \`-\` for stdin) | add lines at the end of the notes |
24363
+ | \`monoban loop pause NAME\` | pause a loop when the user asks: it starts no new run until they resume it in the browser |
24002
24364
 
24003
24365
  Every command takes \`--json\`; project commands take \`-p KEY\`. \`monoban COMMAND --help\` has the rest.
24004
24366
  `;
@@ -24306,6 +24668,8 @@ too when agentpipe can run them: --no-loops, or "enabled": false, says no; "merg
24306
24668
  "full"
24307
24669
  ])).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
24670
  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));
24671
+ 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));
24672
+ 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
24673
  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
24674
  It goes in ~/.claude/skills/monoban (Claude Code) or ~/.agents/skills/monoban (Codex); with --project,
24311
24675
  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.11.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",