wildcrane-runner 0.6.96 → 0.6.97

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // ai4kanban 0.11.77 — built by runner/scripts/build.mjs. Do not edit.
2
+ // ai4kanban 0.11.78 — built by runner/scripts/build.mjs. Do not edit.
3
3
  import { createRequire as __ai4kanbanRequire } from 'node:module'
4
4
  const require = __ai4kanbanRequire(import.meta.url)
5
5
  var __create = Object.create;
@@ -20853,11 +20853,40 @@ function parseReviewPlan(value, previews) {
20853
20853
  }
20854
20854
  return plan;
20855
20855
  }
20856
+ function parseReviewFlow(flow, catalog) {
20857
+ if (flow === "") return [];
20858
+ if (!catalog) throw new Error("Preview outputs are unavailable; update Runner and try again.");
20859
+ const names2 = catalog.map(({ id: id2, title }) => {
20860
+ const labels = Object.values(title ?? {}).map((label2) => label2.trim()).filter(Boolean);
20861
+ return { id: id2, labels: labels.length ? [...new Set(labels)] : [id2] };
20862
+ });
20863
+ const available = names2.map(({ labels }) => labels.join(" / ")).join(", ") || "none";
20864
+ const seen = /* @__PURE__ */ new Set();
20865
+ const nodes = [];
20866
+ let after2 = [];
20867
+ for (const group of flow.split("->")) {
20868
+ const current = group.split("+").map((entry) => {
20869
+ const name = entry.trim();
20870
+ if (!name) throw new Error("The review flow contains an empty Preview name.");
20871
+ const matches = names2.filter(({ labels }) => labels.includes(name));
20872
+ if (matches.length !== 1) {
20873
+ throw new Error(`${matches.length ? "Ambiguous" : "Unknown"} Preview "${name}". Available Previews: ${available}.`);
20874
+ }
20875
+ const { id: id2 } = matches[0];
20876
+ if (seen.has(id2)) throw new Error(`Repeated Preview "${name}". Available Previews: ${available}.`);
20877
+ seen.add(id2);
20878
+ nodes.push({ id: id2, after: after2, previews: [id2] });
20879
+ return id2;
20880
+ });
20881
+ after2 = current;
20882
+ }
20883
+ nodes.push({ id: seen.has("delivery-handoff") ? "delivery-handoff:flow" : "delivery-handoff", after: after2, previews: [] });
20884
+ return parseReviewPlan(nodes);
20885
+ }
20856
20886
  function readReviewPlan(plan) {
20857
20887
  return plan?.map(({ id: id2, after: after2, previews, kind }) => ({ id: id2, after: after2, previews, ...kind && { kind } })) ?? null;
20858
20888
  }
20859
20889
  function reviewAuthorization(review, assigned, dispatchRevision) {
20860
- if (review.pending_plan) return { kind: "pending" };
20861
20890
  const states2 = new Map(review.stages.map((stage) => [stage.id, stage]));
20862
20891
  const nodes = (review.plan ?? []).filter((node2) => {
20863
20892
  const stage = states2.get(node2.id);
@@ -20877,9 +20906,7 @@ function reviewAllows(authorization, action) {
20877
20906
  function reviewInstruction(authorization) {
20878
20907
  switch (authorization.kind) {
20879
20908
  case "plan":
20880
- return "Planning only. Submit a review plan. Wait for confirmation if it is pending, and work only on dispatched stages.";
20881
- case "pending":
20882
- return "Wait for the proposed plan decision. Do not start new stages.";
20909
+ return "Planning only. Submit a review plan. Work only on dispatched stages.";
20883
20910
  case "unreviewed":
20884
20911
  return "No extra review. Complete the authorized work and Studio delivery checks.";
20885
20912
  case "stages":
@@ -20899,7 +20926,7 @@ function reviewBoundary(review, assigned) {
20899
20926
  return [
20900
20927
  "Task review: " + JSON.stringify(review),
20901
20928
  reviewInstruction(reviewAuthorization(review, assigned)),
20902
- "Read akb task review before reporting running/done with its revision. Sync content and assets before done. Revise a stage before changing its approved output. Questions and plan approval never approve outputs."
20929
+ "Read akb task review before reporting running/done with its revision. Sync content and assets before done. Revise a stage before changing its approved output. Only stage approval accepts reviewable outputs."
20903
20930
  ].join("\n");
20904
20931
  }
20905
20932
  var id, reviewNodeSchema, reviewPlanSchema;
@@ -22211,17 +22238,22 @@ function reviewRevision(value) {
22211
22238
  return Number(value);
22212
22239
  }
22213
22240
  async function taskReview(id2, opts = {}, location = {}) {
22241
+ const count3 = [opts.review, opts.file, opts.status, opts.reviseFrom].filter((v) => v !== void 0).length;
22242
+ if (count3 > 1 || opts.stage !== void 0 && opts.status === void 0) die("Use one of --review, --file, --stage with --status, or --revise-from.");
22214
22243
  const ref = await taskRef(id2, location);
22215
- const count3 = [opts.file, opts.status, opts.reviseFrom].filter((v) => v !== void 0).length;
22216
- if (count3 > 1 || opts.stage && !opts.status) die("Use one of --file, --stage with --status, or --revise-from.");
22217
22244
  let task;
22218
22245
  if (!count3) task = await cloud("GET", `/v1/tasks/${enc(ref)}`);
22219
22246
  else {
22220
22247
  const review_revision = reviewRevision(opts.revision);
22221
22248
  let fields2;
22222
- if (opts.file) fields2 = { operation: "plan", review_plan: parseReviewPlan(JSON.parse(fs7.readFileSync(opts.file, "utf8"))) };
22223
- else if (opts.reviseFrom) fields2 = { operation: "revise", stage: opts.reviseFrom };
22224
- else {
22249
+ if (opts.review !== void 0) {
22250
+ const studio = opts.review === "" ? void 0 : await cloud("GET", `/v1/tasks/${enc(ref)}/studio`);
22251
+ fields2 = { operation: "plan", review_plan: parseReviewFlow(opts.review, studio?.previews) };
22252
+ } else if (opts.file !== void 0) {
22253
+ fields2 = { operation: "plan", review_plan: parseReviewPlan(JSON.parse(fs7.readFileSync(opts.file, "utf8"))) };
22254
+ } else if (opts.reviseFrom !== void 0) {
22255
+ fields2 = { operation: "revise", stage: opts.reviseFrom };
22256
+ } else {
22225
22257
  if (!opts.stage || !["running", "done"].includes(opts.status)) die("--stage and --status running|done are required.");
22226
22258
  fields2 = { operation: "status", stage: opts.stage, status: opts.status };
22227
22259
  }
@@ -37639,7 +37671,7 @@ function cmdGoal(args2, opts) {
37639
37671
  const body = readBody(opts.bodyFile);
37640
37672
  const studio = opts.studio ? studioOf(held4, opts.studio) : fallbackStudio(held4);
37641
37673
  const id2 = `new_${held4.goals.filter((i) => i.id.startsWith("new_")).length + 1}`;
37642
- const review_plan = goalReview(held4, studio, opts.reviewFile);
37674
+ const review_plan = goalReview(held4, studio, opts);
37643
37675
  held4.goals.push({ id: id2, title, ...body, studio, review_plan, task: null });
37644
37676
  write2();
37645
37677
  say(`Saved goal ${id2}: ${title} (${shortStudioId(studio)}).`);
@@ -37649,7 +37681,7 @@ function cmdGoal(args2, opts) {
37649
37681
  if (goal.task) die(`${goal.id} is already a task; it no longer changes here.`);
37650
37682
  if (sub === "save") {
37651
37683
  const studio = opts.studio !== void 0 ? studioOf(held4, opts.studio) : goal.studio;
37652
- const review_plan = opts.reviewFile !== void 0 ? goalReview(held4, studio, opts.reviewFile) : checkGoalReview(held4, studio, goal.review_plan ?? null);
37684
+ const review_plan = goalReview(held4, studio, opts, goal.review_plan ?? null);
37653
37685
  if (opts.title !== void 0) {
37654
37686
  if (!opts.title.trim()) die("--title must not be empty");
37655
37687
  goal.title = opts.title.trim();
@@ -37693,8 +37725,14 @@ function checkGoalReview(held4, studio, value) {
37693
37725
  return die(e.message);
37694
37726
  }
37695
37727
  }
37696
- function goalReview(held4, studio, file2) {
37697
- return checkGoalReview(held4, studio, file2 ? JSON.parse(fs15.readFileSync(file2, "utf8")) : null);
37728
+ function goalReview(held4, studio, opts, previous = null) {
37729
+ if (opts.review !== void 0) {
37730
+ if (opts.reviewFile !== void 0) die("Use either --review or --review-file.");
37731
+ const catalog = held4.studios.find((w) => w.id === studio)?.previews;
37732
+ return parseReviewFlow(opts.review, catalog);
37733
+ }
37734
+ const value = opts.reviewFile === void 0 ? previous : JSON.parse(fs15.readFileSync(opts.reviewFile, "utf8"));
37735
+ return checkGoalReview(held4, studio, value);
37698
37736
  }
37699
37737
  function cmdGoalPreviews(studio) {
37700
37738
  const { held: held4 } = loadGoals();
@@ -41437,6 +41475,13 @@ var init_connection_process = __esm({
41437
41475
  });
41438
41476
 
41439
41477
  // ../cli/src/lib/agent/retry.ts
41478
+ function agentRecovery(evidence) {
41479
+ if (!evidence.stopped) return "unsafe";
41480
+ if (evidence.completed) return "report";
41481
+ if (evidence.unconfirmedCleanup) return "unsafe";
41482
+ if (evidence.session) return "resume";
41483
+ return evidence.replayable ? "replay" : "unsafe";
41484
+ }
41440
41485
  function backoffMs(attempt2, random = Math.random) {
41441
41486
  const step = Math.min(CAP_MS, BASE_MS * 2 ** Math.max(0, attempt2 - 2));
41442
41487
  return Math.round(step * (1 - 0.25 * random()));
@@ -41488,11 +41533,12 @@ function syncRepairPrompt(reason) {
41488
41533
 
41489
41534
  ${reason}`;
41490
41535
  }
41491
- var BASE_MS, CAP_MS;
41536
+ var recoveryPrompt, BASE_MS, CAP_MS;
41492
41537
  var init_retry = __esm({
41493
41538
  "../cli/src/lib/agent/retry.ts"() {
41494
41539
  "use strict";
41495
41540
  init_language();
41541
+ recoveryPrompt = "Continue the interrupted turn in this session. Check the current state and the results of previous operations first. Preserve completed work and user decisions. Do not repeat an operation whose result has already taken effect.";
41496
41542
  BASE_MS = 15e3;
41497
41543
  CAP_MS = 12e4;
41498
41544
  }
@@ -41815,8 +41861,8 @@ var init_package = __esm({
41815
41861
  "../cli/package.json"() {
41816
41862
  package_default = {
41817
41863
  name: "wildcrane",
41818
- version: "0.11.77",
41819
- akbContract: 24,
41864
+ version: "0.11.78",
41865
+ akbContract: 25,
41820
41866
  description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
41821
41867
  keywords: [
41822
41868
  "kanban",
@@ -48888,6 +48934,7 @@ function parseStore() {
48888
48934
  if (!knownAction(entry.action)) continue;
48889
48935
  runs.push({
48890
48936
  sessionId: entry.sessionId,
48937
+ cloudExecution: executionOf(entry.cloudExecution ?? null),
48891
48938
  cardId: typeof entry.cardId === "number" ? entry.cardId : null,
48892
48939
  createdCardIds: Array.isArray(entry.createdCardIds) ? [...new Set(entry.createdCardIds.filter((id2) => Number.isInteger(id2) && id2 > 0))] : void 0,
48893
48940
  discard: entry.discard === true || void 0,
@@ -49357,7 +49404,12 @@ var init_flows = __esm({
49357
49404
  argument: "<id> [note...]",
49358
49405
  argumentNote: NOTE,
49359
49406
  gloss: "build the card",
49360
- options: [RUNTIME_OPTION, ...CARRY_OPTIONS.map((option) => ({ ...option, description: "accepted for compatibility; ignored by implementation" }))]
49407
+ options: [
49408
+ RUNTIME_OPTION,
49409
+ ...CARRY_OPTIONS.map(
49410
+ (option) => option.flags.startsWith("--transcript") ? { ...option, description: "read-only discussion transcript for lazy background lookup" } : { ...option, description: "accepted for compatibility; ignored by implementation" }
49411
+ )
49412
+ ]
49361
49413
  },
49362
49414
  {
49363
49415
  command: "refine",
@@ -51335,7 +51387,7 @@ var init_pictures = __esm({
51335
51387
  var Asset_default;
51336
51388
  var init_Asset = __esm({
51337
51389
  "../cli/src/components/Asset.md"() {
51338
- Asset_default = '# Asset\n\nShow a file as a Preview with `<Asset src=".assets/<card id>/<file>" label="..." />` alone in a paragraph.\nInline and fenced examples remain text.\n\n- **Label**: use a few words; an image\'s optional `alt` is its shipped caption and cannot contain `<`, `>` or its enclosing quote.\n- **Device**: use a separate tag for each device view, with `device="mobile"` or `device="desktop"`; both may reference the same responsive page.\n- **Variants**: versions of the same content on the same device share one tag with `variants=\'{"English": ".assets/<card id>/page.en.html", "\u4E2D\u6587": ".assets/<card id>/page.zh.html"}\'`, with `src` shown first; alternatives stay separate tags.\n- **Loop**: add `loop` for muted, looping video without controls.\n- **Tiled map**: a `.tmx` or `.tmj` `src` draws as a map; keep its `.tsx`/`.tsj` tilesets and images beside it, at the relative paths it names.\n- **Sprite animation**: a TexturePacker JSON (Hash or Array) `src` plays as an animation; keep its sheet image beside it, at the relative path `meta.image` names.\n- **Web page**: an `.html` `src` loads only the files its tags and styles name by relative path, never paths that appear only in its scripts.\n- **Text**: code and other text files show as highlighted text; a `.diff` or `.patch` shows its added and removed lines.\n';
51390
+ Asset_default = '# Asset\n\nShow a file as a Preview with `<Asset src=".assets/<card id>/<file>" label="..." />` alone in a paragraph.\nInline and fenced examples remain text.\n\n- **Label**: use a few words; an image\'s optional `alt` is its shipped caption and cannot contain `<`, `>` or its enclosing quote.\n- **Device**: use a separate tag for each device view, with `device="mobile"` or `device="desktop"`; both may reference the same responsive page.\n- **Variants**: versions of the same content on the same device share one tag with `variants=\'{"English": ".assets/<card id>/page.en.html", "\u4E2D\u6587": ".assets/<card id>/page.zh.html"}\'`, with `src` shown first; alternatives stay separate tags.\n- **Loop**: add `loop` for muted, looping video without controls.\n- **Tiled map**: a `.tmx` or `.tmj` `src` draws as a map; keep its `.tsx`/`.tsj` tilesets and images beside it, at the relative paths it names.\n- **Sprite animation**: a TexturePacker JSON (Hash or Array) `src` plays as an animation; keep its sheet image beside it, at the relative path `meta.image` names.\n- **Web page**: an `.html` or `.htm` `src` loads only the relative paths named in its tags and styles.\n- **Mermaid**: a `.mmd` or `.mermaid` `src` draws a diagram and shows its source if it cannot render.\n- **Text**: code and other text files show as highlighted text; a `.diff` or `.patch` shows its added and removed lines.\n';
51339
51391
  }
51340
51392
  });
51341
51393
 
@@ -51639,6 +51691,9 @@ function answeredNote(cardId2, command) {
51639
51691
  return `Delivery ${delivery.deliveryId} is already building this card. Once your answers are on it, say what they did to what it was approved to build: \`${command} raw delivery answered ${delivery.deliveryId} --changed|--unchanged "<why>"\`, before you drop the questions. Judge the meaning, not the words \u2014 say nothing and the board carries the build on as unchanged.`;
51640
51692
  }
51641
51693
  function carriedNote(req) {
51694
+ if (req.action === "implement") {
51695
+ return req.carry?.transcript ? `This card came out of a discussion. The card is the final word; the read-only transcript at \`${req.carry.transcript}\` is background reference only \u2014 consult it on demand if the card leaves details out, using keyword search or sectioned reads rather than reading the whole file.` : "";
51696
+ }
51642
51697
  if (req.session !== "resume" && req.session !== "fork") {
51643
51698
  return req.carry?.transcript ? `This card came out of a discussion. The card is the final word: the discussion only fills in the background, and what it dropped stays dropped. Read it for what the card leaves out: ${req.carry.transcript}` : "";
51644
51699
  }
@@ -51660,6 +51715,7 @@ function actionPrompt(req, command, notes) {
51660
51715
  }
51661
51716
  return [
51662
51717
  `Implement task ${req.id} ${named2} following \`akb guide implement\`. Read its current card before starting.`,
51718
+ carriedNote(req),
51663
51719
  req.notes ? `Extra notes: ${req.notes}` : ""
51664
51720
  ].filter(Boolean).join(" ");
51665
51721
  case "archive":
@@ -52359,6 +52415,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID6(), said2) {
52359
52415
  if (plan.note) notes = [...notes, plan.note];
52360
52416
  const record2 = {
52361
52417
  sessionId,
52418
+ cloudExecution: executionOf(),
52362
52419
  cardId: cardId2,
52363
52420
  action: req.action,
52364
52421
  deliveryId: joining?.deliveryId,
@@ -52525,7 +52582,7 @@ async function openResume(id2, options) {
52525
52582
  const root2 = prev.agentPid ? { pid: prev.agentPid, since: prev.agentStartedAt ?? prev.startedAt, identity: prev.agentIdentity } : void 0;
52526
52583
  const stopped2 = prev.managedProcess ? connectionStopped(root2) : processesStopped(runMark(prev.sessionId, prev.agentStartedAt), root2);
52527
52584
  const session2 = resumeSessionId(prev);
52528
- if (!stopped2 || !session2 || prev.managedProcess && pending.failure.code === "idle_timeout" && !idleStopConfirmed(prev.cleanup, session2)) {
52585
+ if (!stopped2 || !session2 && !neverStarted(prev) || prev.managedProcess && pending.failure.code === "idle_timeout" && !idleStopConfirmed(prev.cleanup, session2)) {
52529
52586
  return retryRefusal(prev, "unsafe");
52530
52587
  }
52531
52588
  await new Promise((resolve2) => setTimeout(resolve2, Math.max(0, pending.at - Date.now())));
@@ -52561,7 +52618,8 @@ async function openResume(id2, options) {
52561
52618
  if ("error" in opened) return opened;
52562
52619
  if (!opened.spec.prompt && buildResume) opened.spec.prompt = buildResume;
52563
52620
  if (build?.notes?.trim()) opened.spec.prompt = [opened.spec.prompt || resumePrompt(prev.deliveryId, prev.action), build.notes.trim()].join("\n\n");
52564
- if (build || buildResume) writeSpec(opened.spec);
52621
+ if (session && pending) opened.spec.prompt = [recoveryPrompt, opened.spec.prompt].filter(Boolean).join("\n\n");
52622
+ if (build || buildResume || pending) writeSpec(opened.spec);
52565
52623
  return opened;
52566
52624
  }
52567
52625
  async function planRetry2(prev, ask2, sessionId, cwd) {
@@ -52586,6 +52644,7 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh, automatic = fa
52586
52644
  const retry2 = fresh?.retry === true;
52587
52645
  const record2 = {
52588
52646
  sessionId,
52647
+ cloudExecution: executionOf(),
52589
52648
  cardId: prev.cardId,
52590
52649
  createdCardIds: prev.createdCardIds,
52591
52650
  triage: prev.triage,
@@ -53712,10 +53771,10 @@ function bodyReferences(body) {
53712
53771
  return out;
53713
53772
  }
53714
53773
  function kindOf2(ext) {
53715
- if (ext === ".tsx" || ext === ".html") return "html";
53774
+ const type = TYPES[ext] ?? "";
53775
+ if (ext === ".tsx" || type === "text/html") return "html";
53716
53776
  if (ext === ".md" || ext === ".mdx") return "markdown";
53717
53777
  if (ext === ".tmx" || ext === ".tmj" || ext === ".tsj") return "tiled";
53718
- const type = TYPES[ext] ?? "";
53719
53778
  if (type.startsWith("image/")) return "image";
53720
53779
  return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
53721
53780
  }
@@ -53743,6 +53802,7 @@ var init_references = __esm({
53743
53802
  ".mp3": "audio/mpeg",
53744
53803
  ".pdf": "application/pdf",
53745
53804
  ".html": "text/html",
53805
+ ".htm": "text/html",
53746
53806
  ".md": "text/markdown",
53747
53807
  ".mdx": "text/markdown",
53748
53808
  ".mov": "video/quicktime",
@@ -53993,13 +54053,14 @@ function dressPage(file2) {
53993
54053
  const at = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
53994
54054
  return /<!doctype\b|<html[\s>]|<head[\s>]/i.test(html) ? html.slice(0, at) + head + html.slice(at) : `<!doctype html><html><head>${head}</head><body>${html}</body></html>`;
53995
54055
  }
53996
- var CSP, head, referenceText;
54056
+ var isHtmlFile, CSP, head, referenceText;
53997
54057
  var init_dress_page = __esm({
53998
54058
  "../cli/src/lib/dress-page.ts"() {
53999
54059
  "use strict";
54060
+ isHtmlFile = (file2) => /\.html?$/i.test(file2);
54000
54061
  CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src 'none'; base-uri 'none'; form-action 'none'";
54001
54062
  head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
54002
- referenceText = (file2) => /\.html$/i.test(file2) ? dressPage(file2) : fs53.readFileSync(file2, "utf8");
54063
+ referenceText = (file2) => isHtmlFile(file2) ? dressPage(file2) : fs53.readFileSync(file2, "utf8");
54003
54064
  }
54004
54065
  });
54005
54066
 
@@ -62088,7 +62149,7 @@ var init_board3 = __esm({
62088
62149
  var card_chat_default;
62089
62150
  var init_card_chat = __esm({
62090
62151
  "../cli/src/guide/card-chat.md"() {
62091
- card_chat_default = '# Answer a card\'s conversation\n\nRead the task\u2019s review plan and work only on unlocked stages. An empty plan needs no extra approval; an undecided plan allows planning only.\n\n- **Where the task stands**: read `akb task show <id>` and `akb task review <id>`.\n- **Button labels**: name actions by their labels on the page, in the user\'s language: "Approve" or "Approve, start \u2026" (\u6279\u51C6 / \u6279\u51C6\uFF0C\u5F00\u59CB\u2026), "Resume" (\u7EED\u8DD1), "Start again" (\u91CD\u65B0\u53D1\u8D77).\n\n- **Change requirements or drafts**: when the user changes the scope, expected behavior, or draft, use `akb raw card revise <id> --print "<change>"`.\n- **Record an answer**: when the user answers an open question on the card, use `akb raw card resolve <id> --print`.\n- **Manage open questions**: when a decision needs the user\'s input, follow `akb guide update-questions` and use `akb raw update-questions <id>` to edit the question list.\n- **Change card fields**: when the user changes metadata such as priority, modules, or dependencies, use `akb raw update <id>`.\n- **Previews**: prepare or revise only requested outputs, using the task-bound Studio\u2019s Preview instructions and supplied component documentation. Before changing approved output, invalidate its stage with `akb task review <id> --revise-from <stage> --revision <n>`. Preserve unrelated work.\n- **Create a separate task**: when the user asks to capture work unrelated to this card, follow `akb guide add-task`.\n- **Split this card**: when the user asks to break this card\'s outcome into subtasks, follow the group procedure in `akb guide add-task`.\n- **Change a studio**: use `akb guide update-studio` for shared Studio instructions; a correction to this card\'s draft alone stays on this card.\n- **Check card edits**: after writing a card, run `akb raw validate <id>` and fix what it reports.\n- **Anything else**: for a request this guide does not cover, read `akb help` once, then the matching command\'s `--help`.\n\nReply in plain, natural language. Do not write memory, including through any flow this conversation starts.\n\n- **Approve**: only on an explicit request, use `akb task approve <id> --stage <stage> --revision <reviewed revision>`; omit `--stage` for a pending plan. In a reply this commits after successful synchronization. Finish the reply without further edits or waiting. Never substitute the latest revision for the one reviewed.\n- **Change the plan**: propose a complete replacement with `akb task review <id> --file <json> --revision <n>` and wait for confirmation if `pending_plan` is set. Answers to questions never approve work.\n';
62152
+ card_chat_default = '# Answer a card\'s conversation\n\nRead the task\u2019s review plan and work only on unlocked stages. An empty plan needs no extra approval; an undecided plan allows planning only.\n\n- **Where the task stands**: read `akb task show <id>` and `akb task review <id>`.\n- **Button labels**: name actions by their labels on the page, in the user\'s language: "Approve" or "Approve, start \u2026" (\u6279\u51C6 / \u6279\u51C6\uFF0C\u5F00\u59CB\u2026), "Resume" (\u7EED\u8DD1), "Start again" (\u91CD\u65B0\u53D1\u8D77).\n\n- **Change requirements or drafts**: when the user changes the scope, expected behavior, or draft, use `akb raw card revise <id> --print "<change>"`.\n- **Record an answer**: when the user answers an open question on the card, use `akb raw card resolve <id> --print`.\n- **Manage open questions**: when a decision needs the user\'s input, follow `akb guide update-questions` and use `akb raw update-questions <id>` to edit the question list.\n- **Change card fields**: when the user changes metadata such as priority, modules, or dependencies, use `akb raw update <id>`.\n- **Previews**: prepare or revise only requested outputs, using the task-bound Studio\u2019s Preview instructions and supplied component documentation. Before changing approved output, invalidate its stage with `akb task review <id> --revise-from <stage> --revision <n>`. Preserve unrelated work.\n- **Create a separate task**: when the user asks to capture work unrelated to this card, follow `akb guide add-task`.\n- **Split this card**: when the user asks to break this card\'s outcome into subtasks, follow the group procedure in `akb guide add-task`.\n- **Change a studio**: use `akb guide update-studio` for shared Studio instructions; a correction to this card\'s draft alone stays on this card.\n- **Check card edits**: after writing a card, run `akb raw validate <id>` and fix what it reports.\n- **Anything else**: for a request this guide does not cover, read `akb help` once, then the matching command\'s `--help`.\n\nReply in plain, natural language. Do not write memory, including through any flow this conversation starts.\n\n- **Approve**: only on an explicit request, use `akb task approve <id> --stage <stage> --revision <reviewed revision>`. In a reply this commits after successful synchronization. Finish the reply without further edits or waiting. Never substitute the latest revision for the one reviewed.\n- **Change the plan**: submit a complete replacement with `akb task review <id> --file <json> --revision <n>`. It takes effect immediately. Answers to questions never approve work.\n';
62092
62153
  }
62093
62154
  });
62094
62155
 
@@ -62112,7 +62173,7 @@ var init_describe_project = __esm({
62112
62173
  var discuss_goal_default;
62113
62174
  var init_discuss_goal = __esm({
62114
62175
  "../cli/src/guide/discuss-goal.md"() {
62115
- discuss_goal_default = '# Discuss a goal\n\nExplain feasible options and key tradeoffs, then save the result the user can choose to start.\n\n- **Investigations**: finish checks and diagnosis here; save a change only when findings establish it. Report unverified work plainly.\n- **Goals**: save independent deliverables separately. Update existing goals rather than duplicate them.\n- **Studio**: choose the fitting installed Studio, preferring the user\'s choice; read its Additional Notes with `akb studio rule <studio>` and honor their scope. Its Preview IDs name outputs, not agents.\n- **Review**: save the Goal\'s review plan with `--review-file <json>` (`{id,after?,previews?,kind?}`). Use the Studio\'s Preview IDs and stable node IDs. An `after` edge between review nodes requires approval; mark ordinary work with `"kind":"work"` for completion-only dependencies.\n- **Review state**: save `[]` when no extra review is needed and `null` only while a decision is missing. Keep the saved arrangement when editing other details.\n- **Decisions**: explain the proposed outcome and review arrangement before saving. Ask only for choices the user must make, with a recommendation.\n- **Start**: the user starts each Goal from the page; starting accepts its arrangement, never skips its review gates. Changing the arrangement after starting requires plan confirmation.\n- **Communication**: the remote user sees tasks and previews. Use plain words and button labels, omitting internal paths, commands and tools.\n\n## Goal format\n\nUse exactly these three fields on create and update. Include only what the user requested or confirmed.\n\nPass the one-line title separately with `--title`. Use this template for `--body-file`:\n\n```markdown\n<The requested outcome in at most 150 words.>\n\n## Done when\n\n- <A verifiable condition for the requested outcome.>\n```\n';
62176
+ discuss_goal_default = "# Discuss a goal\n\nExplain feasible options and key tradeoffs, then save the result the user can choose to start.\n\n- **Investigations**: finish checks and diagnosis here; save a change only when findings establish it. Report unverified work plainly.\n- **Goals**: save independent deliverables separately. Update existing goals rather than duplicate them.\n- **Studio**: choose the fitting installed Studio, preferring the user's choice; read its Additional Notes with `akb studio rule <studio>` and honor their scope.\n- **Review** independent Previews in parallel by default. Use Studio Preview names, e.g. `--review 'Tech choices + UI design'`. Add `->` only when the next group needs the previous group's approvals. Delivery waits for all approvals in the last group. Verify the saved plan even when no flowchart appears.\n- **Review state**: pass `--review ''` for no extra approval, leave the plan undecided while a decision is missing, and omit the option when keeping a saved plan.\n- **Decisions**: explain the proposed outcome and review arrangement before saving. Ask only for choices the user must make, with a recommendation.\n- **Start**: the user starts each Goal from the page; its effective review arrangement governs output approval.\n- **Communication**: the remote user sees tasks and previews. Use plain words and button labels, omitting internal paths, commands and tools.\n\n## Goal format\n\nUse exactly these three fields on create and update. Include only what the user requested or confirmed.\n\nPass the one-line title separately with `--title`. Use this template for `--body-file`:\n\n```markdown\n<The requested outcome in at most 150 words.>\n\n## Done when\n\n- <A verifiable condition for the requested outcome.>\n```\n";
62116
62177
  }
62117
62178
  });
62118
62179
 
@@ -62168,7 +62229,7 @@ var init_review_rejections = __esm({
62168
62229
  var refine_default;
62169
62230
  var init_refine = __esm({
62170
62231
  "../cli/src/guide/refine.md"() {
62171
- refine_default = '# Refine a card\n\nPlan one card until it is buildable.\n\n- **Unchecked cards**: check cards with `triage:` and empty `## Scope` against the project, rejecting obsolete or completed work with `akb raw reject <id> --reason "<evidence>"` and stopping.\n- **Other obsolete or completed cards**: ask whether to discard, run no previews, and stop.\n- **Groups**: preserve subtask coverage and progress, fill gaps without duplication, and do not mark the parent ready merely because its split is complete.\n- **Verification**: plan representative checks for the outcome, project rules and material risks, confirm prerequisites, and keep optional coverage optional.\n- **Review**: read `akb task review <id>`. If the arrangement is undecided, propose it with `--file <json> --revision <n>` and wait for confirmation if `pending_plan` is set. Work only on dispatched, unlocked nodes; keep independent work moving while other nodes await review.\n- **Previews**: prepare only the unlocked nodes\u2019 outputs per the Studio\u2019s `<Preview>` blocks. Before revising an approved output, use `--revise-from <stage> --revision <n>`; preserve unrelated outputs and approvals.\n- **Submit**: synchronize body and assets, then report `--stage <id> --status done --revision <n>`. Re-read after conflicts; never treat submission, question answers or plan confirmation as product approval.\n- **Delivery handoff**: for Studios with separate delivery, finish the review plan with a handoff; implementation and its checks run in delivery.\n- **References**: rewrite mentions of cards no longer on the board.\n- **Decisions**: settle choices supported by evidence and ask only as `akb guide update-questions` allows.\n- **Card**: follow studio rules and `akb guide writing`, fixing all errors from `akb raw validate <id>`.\n- **Ready**: when validated and buildable with prerequisites settled, run `akb raw update <id> --status ready`; otherwise leave blockers as open questions.\n\nFollow the printed closing steps. Wait only for required approvals; completion still requires Studio delivery checks.\n';
62232
+ refine_default = '# Refine a card\n\nPlan one card until it is buildable.\n\n- **Unchecked cards**: check cards with `triage:` and empty `## Scope` against the project, rejecting obsolete or completed work with `akb raw reject <id> --reason "<evidence>"` and stopping.\n- **Other obsolete or completed cards**: ask whether to discard, run no previews, and stop.\n- **Groups**: preserve subtask coverage and progress, fill gaps without duplication, and do not mark the parent ready merely because its split is complete.\n- **Verification**: plan representative checks for the outcome, project rules and material risks, confirm prerequisites, and keep optional coverage optional.\n- **Review**: read `akb task review <id>`. If the arrangement is undecided, set it with `--file <json> --revision <n>`. Work only on dispatched, unlocked nodes; keep independent work moving while other nodes await review.\n- **Previews**: prepare only the unlocked nodes\u2019 outputs per the Studio\u2019s `<Preview>` blocks. Before revising an approved output, use `--revise-from <stage> --revision <n>`; preserve unrelated outputs and approvals.\n- **Submit**: synchronize body and assets, then report `--stage <id> --status done --revision <n>`. Re-read after conflicts; obtain output approval at the required stages.\n- **Delivery handoff**: for Studios with separate delivery, finish the review plan with a handoff; implementation and its checks run in delivery.\n- **References**: rewrite mentions of cards no longer on the board.\n- **Decisions**: settle choices supported by evidence and ask only as `akb guide update-questions` allows.\n- **Card**: follow studio rules and `akb guide writing`, fixing all errors from `akb raw validate <id>`.\n- **Ready**: when validated and buildable with prerequisites settled, run `akb raw update <id> --status ready`; otherwise leave blockers as open questions.\n\nFollow the printed closing steps. Wait only for required approvals; completion still requires Studio delivery checks.\n';
62172
62233
  }
62173
62234
  });
62174
62235
 
@@ -62184,7 +62245,7 @@ var init_reflect = __esm({
62184
62245
  var resolve_default;
62185
62246
  var init_resolve2 = __esm({
62186
62247
  "../cli/src/guide/resolve.md"() {
62187
- resolve_default = '# Resolve questions\n\nApply the answers the user supplied to existing open questions. Leave every unanswered\nquestion unchanged. While applying answers, do not research, choose for the user, raise\nanother question, or change project code.\n\n## Apply each answer\n\n1. Match each supplied answer to its open question. If the answer is missing or unclear,\n leave that question open.\n2. Follow `akb guide writing`. Merge the answer into the existing decision, keep only the\n selected choice, remove obsolete or contradictory text, preserve completed work, and add\n newly required work as unchecked todos. When the answer changes an agent\'s section, read\n that agent\'s rules first, as "Preview ownership" there says.\n3. Drop each answered question after its answer is fully applied:\n\n```text\nakb raw update-questions <id> --drop <n[,n...]>\n```\n\nWhen an answer accepts a step the user was asked to review and asks for no changes, tick that\nstep\'s review todo; an answer asking for changes leaves it unticked.\n\nWhen an answer chooses to discard the card, first run `akb raw delivery cancel <delivery>` if a\ndelivery is in flight, then `akb raw reject <id> --reason "<why>"`, and stop. Skip every\nremaining step of this guide.\n\nWhen an answer sends an agent\'s (`agent:`) section back for rework that the user must confirm\nagain, keep or `--update` the question instead of dropping it. Once no question is left for\nthat agent, request each matching agent listed below it whose section is missing or says it\nis waiting.\n\nWhen an answer selects one of several options in a Preview block, remove the rejected\noptions and their spec-tmp files.\n\n## Say what the answers did to a build in flight\n\nA delivery builds the card as it was approved when it started, and applying answers is the\nonly thing that rewrites that card underneath it. You read the question and you wrote the\nanswer, so you are the only one who can tell a confirmation from a change \u2014 the board reads\nyour conclusion and never the card\'s text.\n\n```text\nakb raw delivery answered <delivery> --unchanged "<why>"\nakb raw delivery answered <delivery> --changed "<why>"\n```\n\n- **Record it before you drop the questions**: dropping the last one is what puts the board\n back in motion, and until the conclusion is written the build does not land.\n- **Judge the meaning, not the words**: confirming an option that is already built, writing\n down a decision the card already carries, and tidying prose are all `--unchanged`.\n Adding, dropping or changing a requirement is `--changed`.\n- **A wrong implementation confirmed is still a change**: an answer that blesses work\n contradicting the approved copy is `--changed`, however finished that work is.\n- **One conclusion per round**: it covers every answer you applied in this session. The\n delivery a `--changed` reopens starts on the card as it then reads, with none of its own.\n\n`akb raw card implement <id> --print` prints the delivery\'s id and the copy it is building.\nNothing to record when no delivery is in flight.\n\n## Curate the human half\n\nPut each answer `akb guide writing` places in `Worth noting` in that section; put other\nnecessary lasting decisions below the boundary.\n\nRe-read the whole human half against the same rule. Remove or move down entries that\nfail it, repeat scope, or overlap another entry. Merge entries governed by one decision. One to\nthree independent items is normal; every additional item needs distinct user-facing stakes.\n\n## Refine\n\nOnce no question is left and no delivery is building the card, refine it in this session by\n`akb guide refine`, which decides readiness:\n\n- **Partial**: when the card was refined before, revisit only what the answers changed.\n- **Full**: when the answers reshape the card or its `## Scope` is still the creation scaffold.\n';
62248
+ resolve_default = '# Resolve questions\n\nApply the answers the user supplied to existing open questions. Leave every unanswered\nquestion unchanged. While applying answers, do not research, choose for the user, raise\nanother question, or change project code.\n\n## Apply each answer\n\n1. Match each supplied answer to its open question. If the answer is missing or unclear,\n leave that question open.\n2. Follow `akb guide writing`. Merge the answer into the existing decision, keep only the\n selected choice, remove obsolete or contradictory text, preserve completed work, and add\n newly required work as unchecked todos. When the answer changes an agent\'s section, read\n that agent\'s rules first, as "Preview ownership" there says.\n3. Drop each answered question after its answer is fully applied:\n\n```text\nakb raw update-questions <id> --drop <n[,n...]>\n```\n\nWhen an answer accepts a step the user was asked to review and asks for no changes, tick that\nstep\'s review todo; an answer asking for changes leaves it unticked.\n\nWhen an answer chooses to discard the card, first run `akb raw delivery cancel <delivery>` if a\ndelivery is in flight, then `akb raw reject <id> --reason "<why>"`, and stop. Skip every\nremaining step of this guide.\n\nWhen an answer sends an agent\'s (`agent:`) section back for rework that the user must confirm\nagain, keep or `--update` the question instead of dropping it. Once no question is left for\nthat agent, request each matching agent listed below it whose section is missing or says it\nis waiting.\n\nWhen an answer selects one of several options in a Preview block, remove the rejected\noptions and their spec-tmp files.\n\n## Say what the answers did to a build in flight\n\nA delivery builds the card as it was approved when it started, and applying answers is the\nonly thing that rewrites that card underneath it. You read the question and you wrote the\nanswer, so you are the only one who can tell a confirmation from a change \u2014 the board reads\nyour conclusion and never the card\'s text.\n\n```text\nakb raw delivery answered <delivery> --unchanged "<why>"\nakb raw delivery answered <delivery> --changed "<why>"\n```\n\n- **Record it before you drop the questions**: dropping the last one is what puts the board\n back in motion, and until the conclusion is written the build does not land.\n- **Judge the meaning, not the words**: confirming an option that is already built, writing\n down a decision the card already carries, and tidying prose are all `--unchanged`.\n Adding, dropping or changing a requirement is `--changed`.\n- **A wrong implementation confirmed is still a change**: an answer that blesses work\n contradicting the approved copy is `--changed`, however finished that work is.\n- **One conclusion per round**: it covers every answer you applied in this session. The\n delivery a `--changed` reopens starts on the card as it then reads, with none of its own.\n\n`akb raw card implement <id> --print` prints the delivery\'s id and the copy it is building.\nNothing to record when no delivery is in flight.\n\n## Curate the human half\n\nPut each answer `akb guide writing` places in `Worth noting` in that section; put other\nnecessary lasting decisions below the boundary.\n\nRe-read the whole human half against the same rule. Remove or move down entries that\nfail it, repeat scope, or overlap another entry. Merge entries governed by one decision. One to\nthree independent items is normal; every additional item needs distinct user-facing stakes.\n\n## Refine\n\nIf any question remains open, stop and leave the card waiting. When a delivery is in flight,\nnever refine \u2014 even if `--changed` updated requirements, execution resumes directly from the\nupdated card.\n\nOnce no question is left and no delivery is building the card, refine it in this session by\n`akb guide refine`, which decides readiness:\n\n- **Partial**: when the card was refined before, revisit only what the answers changed.\n- **Full**: when the answers reshape the card or its `## Scope` is still the creation scaffold.\n';
62188
62249
  }
62189
62250
  });
62190
62251
 
@@ -62589,6 +62650,7 @@ function nextDeliveryRun(deliveryId) {
62589
62650
  for (const delivery of store.deliveries) {
62590
62651
  if (deliveryId && delivery.deliveryId !== deliveryId) continue;
62591
62652
  if (delivery.status !== "active" || delivery.cardId === null) continue;
62653
+ if (openQuestions(delivery.cardId) > 0) continue;
62592
62654
  if (store.runs.some((r) => r.deliveryId === delivery.deliveryId && r.status === "running")) continue;
62593
62655
  if (answerOutcome(delivery) === "changed") {
62594
62656
  const superseded = withStore((live) => {
@@ -62622,7 +62684,7 @@ function nextDeliveryRun(deliveryId) {
62622
62684
  };
62623
62685
  }
62624
62686
  }
62625
- const owed = store.deliveries.find((d) => d.cardId !== null && d.steps.some((s) => s.step === "superseded") && !d.steps.some((s) => s.step === "dropped") && !store.deliveries.some((other) => other.cardId === d.cardId && other.deliveryId !== d.deliveryId && other.startedAt >= (d.endedAt ?? 0)) && !store.runs.some((r) => r.cardId === d.cardId && r.status === "running") && approvedRequirements(d.cardId));
62687
+ const owed = store.deliveries.find((d) => d.cardId !== null && d.steps.some((s) => s.step === "superseded") && !d.steps.some((s) => s.step === "dropped") && !store.deliveries.some((other) => other.cardId === d.cardId && other.deliveryId !== d.deliveryId && other.startedAt >= (d.endedAt ?? 0)) && !store.runs.some((r) => r.cardId === d.cardId && r.status === "running") && openQuestions(d.cardId) === 0 && approvedRequirements(d.cardId));
62626
62688
  return owed ? { action: "implement", id: owed.cardId, title: owed.title, session: "new" } : void 0;
62627
62689
  }
62628
62690
  var init_progress = __esm({
@@ -63264,8 +63326,13 @@ function buildFlow(req, program2) {
63264
63326
  if (building) {
63265
63327
  facts.push(...answeringField(building, self));
63266
63328
  facts.push(...notesField(card));
63329
+ close.push(
63330
+ answeredClose(building, self),
63331
+ "do not run `refine` while a delivery is in flight \u2014 even if requirements changed, the build carries on in execution once all questions are dropped"
63332
+ );
63333
+ } else {
63334
+ close.push("once no question is left, refine the card as `akb guide refine` says; if any question remains open, leave it waiting");
63267
63335
  }
63268
- if (building) close.push(answeredClose(building, self));
63269
63336
  close.push(...stageClose(card.meta));
63270
63337
  break;
63271
63338
  }
@@ -63614,6 +63681,7 @@ async function startRefinement(req) {
63614
63681
  function refinementAfter(action, cardId2, flowId) {
63615
63682
  const card = currentCard(cardId2);
63616
63683
  if (!card || card.isGroup || card.openBlockers.length > 0) return null;
63684
+ if (action === "resolve" && activeDelivery(cardId2)) return null;
63617
63685
  if (card.questions.length > 0 || action === "clarify" || card.deliversIn !== "plan") return null;
63618
63686
  if (planDeliveryGap(card) === null) return null;
63619
63687
  if (awaitingApproval(card)) return null;
@@ -63640,6 +63708,7 @@ function stalledLine(cardId2, next) {
63640
63708
  }
63641
63709
  function planStageEnd(run3) {
63642
63710
  if (run3.cardId === null || stageOfAction(run3.action) !== "plan") return null;
63711
+ if (run3.action === "resolve" && (run3.deliveryId || activeDelivery(run3.cardId))) return null;
63643
63712
  const card = currentCard(run3.cardId);
63644
63713
  if (!card || card.isGroup || card.openBlockers.length > 0 || card.questions.length > 0) return null;
63645
63714
  if (refinementStep(card) !== "done") return null;
@@ -63672,6 +63741,7 @@ var init_refine2 = __esm({
63672
63741
  init_read();
63673
63742
  init_rules();
63674
63743
  init_review_plan();
63744
+ init_deliveries();
63675
63745
  init_env();
63676
63746
  init_start();
63677
63747
  init_stage_end();
@@ -63983,11 +64053,11 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
63983
64053
  if (active3.startNote) log.write(`[board] ${active3.startNote}
63984
64054
  `);
63985
64055
  const basePrompt = record2.resumedFrom ? spec.prompt || resumePrompt(record2.deliveryId, record2.action) : spec.prompt;
63986
- const recoveryPrompt = record2.harness === "antigravity" && record2.resumedFrom ? "First verify existing progress and operation results. Preserve user decisions and completed work; do not repeat completed operations. Check actual state before continuing any operation whose result is uncertain." : "";
64056
+ const recoveryPrompt2 = record2.harness === "antigravity" && record2.resumedFrom ? "First verify existing progress and operation results. Preserve user decisions and completed work; do not repeat completed operations. Check actual state before continuing any operation whose result is uncertain." : "";
63987
64057
  const reviewContext = taskReviewContext();
63988
64058
  const boundary = reviewContext ? reviewBoundary(reviewContext.review, reviewContext.assigned) : "";
63989
64059
  const approvedUi = reviewContext && record2.action === "implement" && studioForRun({ id: record2.cardId ?? void 0, deliveryId: record2.deliveryId }) === "coding" ? approvedUiPrompt(reviewContext.review, process.env[APPROVED_UI_DIR_ENV]) : "";
63990
- const prompt = [process.env.AI4KANBAN_SYNC_DIAGNOSTIC ? syncRepairPrompt(process.env.AI4KANBAN_SYNC_DIAGNOSTIC) : "", record2.retry ? `Previous execution failed: ${record2.retry.reason}. Check existing results before continuing; do not repeat completed operations.` : "", conflictPrompt(KANBAN), boundary, basePrompt, approvedUi, recoveryPrompt, discardedCardsPrompt(record2.discardedCards)].filter(Boolean).join("\n\n");
64060
+ const prompt = [process.env.AI4KANBAN_SYNC_DIAGNOSTIC ? syncRepairPrompt(process.env.AI4KANBAN_SYNC_DIAGNOSTIC) : "", record2.retry ? `Previous execution failed: ${record2.retry.reason}. Check existing results before continuing; do not repeat completed operations.` : "", conflictPrompt(KANBAN), boundary, basePrompt, approvedUi, recoveryPrompt2, discardedCardsPrompt(record2.discardedCards)].filter(Boolean).join("\n\n");
63991
64061
  const before = markBoard();
63992
64062
  const takes = active3.images;
63993
64063
  active3.renderer?.setRequiredImages?.(record2.pictures ?? []);
@@ -64015,6 +64085,11 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
64015
64085
  letGo();
64016
64086
  return 1;
64017
64087
  }
64088
+ if (record2.retry?.launching) patch(sessionId, (r) => {
64089
+ if (!r.retry?.launching) return;
64090
+ r.retry.attempt++;
64091
+ delete r.retry.launching;
64092
+ });
64018
64093
  try {
64019
64094
  const start = spawnable(cmd, client || stdinPrompt ? args2 : [...args2, prompt], {
64020
64095
  // Where this run works: the project, or — inside a delivery with a worktree of its
@@ -64045,10 +64120,6 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
64045
64120
  const agentStartedAt = Date.now();
64046
64121
  if (child.pid) {
64047
64122
  patch(sessionId, (r) => {
64048
- if (r.retry?.launching) {
64049
- r.retry.attempt++;
64050
- delete r.retry.launching;
64051
- }
64052
64123
  r.agentPid = child.pid;
64053
64124
  r.agentStartedAt = agentStartedAt;
64054
64125
  r.managedProcess = client?.managedProcess;
@@ -64210,7 +64281,12 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
64210
64281
  const attempt2 = held4.retry?.attempt ?? 1;
64211
64282
  const decision = planRetry(failure2, attempt2, Date.now(), retryBackoff);
64212
64283
  if ("pause" in decision) retryPause = decision.pause;
64213
- else if (blocker || pendingOperations.size || !structured || !resumeSessionId(held4) || spoken?.cleanup?.status === "unconfirmed" || client?.managedProcess && silent && (uncertainAtIdle || !idleStopConfirmed(spoken?.cleanup, resumeSessionId(held4)))) retryPause = "unsafe";
64284
+ else if (blocker || agentRecovery({
64285
+ stopped: true,
64286
+ session: structured && !spawnFailure ? resumeSessionId(held4) : void 0,
64287
+ replayable: !!spawnFailure && !pendingOperations.size,
64288
+ unconfirmedCleanup: spoken?.cleanup?.status === "unconfirmed" || client?.managedProcess && silent && (uncertainAtIdle || !idleStopConfirmed(spoken?.cleanup, resumeSessionId(held4)))
64289
+ }) === "unsafe") retryPause = "unsafe";
64214
64290
  else {
64215
64291
  const mark = runMark(sessionId, agentStartedAt);
64216
64292
  const root2 = child.pid ? { pid: child.pid, since: agentStartedAt, identity: held4.agentIdentity } : void 0;
@@ -64649,7 +64725,9 @@ function readRequest(action, args2, opts) {
64649
64725
  req.notes = words(1);
64650
64726
  if (action === "implement") req.runtime = opts.runtime;
64651
64727
  if (opts.newSession) req.session = "new";
64652
- if (action !== "implement" && (opts.session || opts.transcript)) {
64728
+ if (action === "implement") {
64729
+ if (opts.transcript) req.carry = { transcript: opts.transcript };
64730
+ } else if (opts.session || opts.transcript) {
64653
64731
  const costFrom = Number(process.env[SESSION_COST_ENV]);
64654
64732
  req.carry = {
64655
64733
  resumeId: opts.session,
@@ -65789,10 +65867,10 @@ function declareRuns(program2, cli) {
65789
65867
  withShared(task.command("create")).argument("<request...>", "what the task should do").summary("create a task and prepare its card asynchronously").option("--project <id>", "the project; default: this folder\u2019s linked one").option("--studio <id>", "required: a name `akb studio list` shows").action(async function(request2) {
65790
65868
  await boardless(this, cli, (_, location) => taskCreate(request2.join(" "), this.opts(), location));
65791
65869
  });
65792
- withShared(task.command("approve")).argument("<task>").summary("approve the current review point").option("--stage <id>", "the reviewed node").requiredOption("--revision <n>", "the node or proposed plan version you reviewed").option("--comment <text>", "a note with the approval").action(async function(id2) {
65870
+ withShared(task.command("approve")).argument("<task>").summary("approve the current review point").option("--stage <id>", "the reviewed node").requiredOption("--revision <n>", "the stage version you reviewed").option("--comment <text>", "a note with the approval").action(async function(id2) {
65793
65871
  await boardless(this, cli, (_, location) => taskApprove(id2, this.opts().comment, this.opts(), location));
65794
65872
  });
65795
- withShared(task.command("review")).argument("<task>").summary("read or report the task review plan").option("--file <path>", "propose a JSON review plan").option("--stage <id>", "the node to report").option("--status <status>", "running or done").option("--revise-from <id>", "revise this node and its dependents").option("--revision <n>", "the task review version read before this write").action(async function(id2) {
65873
+ withShared(task.command("review")).argument("<task>").summary("read the task review, set the plan or report a stage").option("--review <flow>", "set a review flow using Studio Preview names").addHelpText("after", REVIEW_FLOW_HELP).option("--file <path>", "set a JSON review plan").option("--stage <id>", "the node to report").option("--status <status>", "running or done").option("--revise-from <id>", "revise this node and its dependents").option("--revision <n>", "the task review version read before this write").action(async function(id2) {
65796
65874
  await boardless(this, cli, (_, location) => taskReview(id2, this.opts(), location));
65797
65875
  });
65798
65876
  const questionOps = [];
@@ -65821,7 +65899,7 @@ function declareRuns(program2, cli) {
65821
65899
  withShared(task.command("comment")).argument("<task>").argument("<text...>").summary("comment on a task").action(async function(id2, text5) {
65822
65900
  await boardless(this, cli, (_, location) => taskComment(id2, text5.join(" "), location));
65823
65901
  });
65824
- const goal = withShared(program2.command("goal")).argument("<move>", "new, save, drop or start").summary("save, drop and start goals of this conversation").description('Write a temporary draft, then goal new --title "\u2026" --body-file <file> [--studio <id>] [--review-file <json>]; update with goal save --id <goal> and any of --title, --body-file, --studio, --review-file. goal drop --id <goal> withdraws one; goal start --id <goal> turns it into a task. A `## Done when` list in the body is what counts as done. Studios are the ones `akb studio list` shows.').option("--id <goal>", "the goal to save, drop or start").option("--title <title>", "what the goal is called").option("--body-file <path>", "the outcome, then a `## Done when` list").option("--studio <id>", "the studio that does the work, from `akb studio list`").option("--review-file <path>", "JSON review nodes with after dependencies; [] needs no extra review");
65902
+ const goal = withShared(program2.command("goal")).argument("<move>", "new, save, drop or start").summary("save, drop and start goals of this conversation").description('Write a temporary draft, then goal new --title "\u2026" --body-file <file> [--studio <id>] [--review <flow>]; update with goal save --id <goal> and any of --title, --body-file, --studio, --review. goal drop --id <goal> withdraws one; goal start --id <goal> turns it into a task. A `## Done when` list in the body is what counts as done. Studios are the ones `akb studio list` shows.').option("--id <goal>", "the goal to save, drop or start").option("--title <title>", "what the goal is called").option("--body-file <path>", "the outcome, then a `## Done when` list").option("--studio <id>", "the studio that does the work, from `akb studio list`").option("--review <flow>", "save a review flow using Studio Preview names").option("--review-file <path>", "JSON review nodes with after dependencies; [] needs no extra review").addHelpText("after", REVIEW_FLOW_HELP);
65825
65903
  goal.action(async function(sub) {
65826
65904
  await boardless(this, cli, () => externalGoalSession() ? cloudGoal([sub], this.opts()) : cmdGoal([sub], this.opts()));
65827
65905
  });
@@ -66090,7 +66168,7 @@ function declareAgent(program2, cli) {
66090
66168
  await onBoard(this, cli, (p) => cmdRunScheduled(studio, name, this.opts(), p));
66091
66169
  });
66092
66170
  }
66093
- var studioList, positional, RUN_ID, DELIVERY, splitArgs, sentence;
66171
+ var REVIEW_FLOW_HELP, studioList, positional, RUN_ID, DELIVERY, splitArgs, sentence;
66094
66172
  var init_agent2 = __esm({
66095
66173
  "../cli/src/lib/cli/agent.ts"() {
66096
66174
  "use strict";
@@ -66122,6 +66200,12 @@ var init_agent2 = __esm({
66122
66200
  init_harnesses();
66123
66201
  init_moved();
66124
66202
  init_shared2();
66203
+ REVIEW_FLOW_HELP = `
66204
+ Review examples
66205
+ --review 'UI design' One Preview approval
66206
+ --review 'UI design -> Prompts' Approve in order
66207
+ --review 'UI design + API docs -> Prompts' Both approvals unlock Prompts
66208
+ --review '' No extra review`;
66125
66209
  studioList = (cmd, cli) => !cmd.optsWithGlobals().board && externalGoalSession() ? boardless(cmd, cli, cloudGoalStudios) : goalsFile() ? boardless(cmd, cli, () => cmdGoalStudios()) : onBoard(cmd, cli, async () => {
66126
66210
  await syncStudios(true);
66127
66211
  return cmdStudioList();
@@ -1 +1 @@
1
- {"name":"wildcrane","version":"0.11.77","akbContract":24,"type":"module","private":true}
1
+ {"name":"wildcrane","version":"0.11.78","akbContract":25,"type":"module","private":true}