wildcrane-runner 0.6.60-conversations.1 → 0.6.60

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.47 — built by runner/scripts/build.mjs. Do not edit.
2
+ // ai4kanban 0.11.48 — 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;
@@ -866,8 +866,8 @@ function planDeliveryGap(card) {
866
866
  if (card.questions.length > 0) return "questions";
867
867
  if (!planDeliverables(card.body).length) return "deliverable";
868
868
  if (!/^[ \t]*[-*]\s+\[[xX]\].*`[^`]+`/m.test(card.body)) return "command";
869
- const { total, done: done2 } = card.todos;
870
- return total > 0 && done2 === total ? null : "todos";
869
+ const { total, done } = card.todos;
870
+ return total > 0 && done === total ? null : "todos";
871
871
  }
872
872
  function awaitingApproval(card) {
873
873
  const { stages, stage } = card;
@@ -881,8 +881,8 @@ function canRefine(card) {
881
881
  if (awaitingApproval(card)) return false;
882
882
  const unfinished = !card.isGroup && planUnfinished(card);
883
883
  if (card.status !== "todo" && !unfinished) return false;
884
- const { total, done: done2 } = card.todos;
885
- if (total > 0 && done2 === total && !unfinished) return false;
884
+ const { total, done } = card.todos;
885
+ if (total > 0 && done === total && !unfinished) return false;
886
886
  if (card.questions.length > 0 && card.questions.every(hasOptions)) return false;
887
887
  return true;
888
888
  }
@@ -1660,10 +1660,10 @@ async function taskCreate(request2, opts) {
1660
1660
  say(`Created ${task.key}: ${task.title} ${taskUrl(task.key)}`);
1661
1661
  return { ...task };
1662
1662
  }
1663
- async function act(id, route2, body, done2) {
1663
+ async function act(id, route2, body, done) {
1664
1664
  const ref = await taskRef(id);
1665
1665
  const value = await cloud("POST", `/v1/tasks/${enc(ref)}/${route2}`, body);
1666
- say(done2(ref));
1666
+ say(done(ref));
1667
1667
  return value;
1668
1668
  }
1669
1669
  async function taskApprove(id, comment) {
@@ -1684,9 +1684,9 @@ async function taskUpdateQuestions(id, typed) {
1684
1684
  let changes;
1685
1685
  let open3;
1686
1686
  try {
1687
- const done2 = applyQuestionOps(questions, ops);
1688
- changes = done2.changes;
1689
- open3 = done2.questions.length;
1687
+ const done = applyQuestionOps(questions, ops);
1688
+ changes = done.changes;
1689
+ open3 = done.questions.length;
1690
1690
  } catch (e) {
1691
1691
  if (e instanceof QuestionOpError) die(`${ref}: ${e.message}`);
1692
1692
  throw e;
@@ -1797,9 +1797,9 @@ function subtaskLines(body) {
1797
1797
  const m = line.match(/^[ \t]*[-*]\s+\[( |x|X)\]\s*(.*)$/);
1798
1798
  if (!m || !/#\d+/.test(m[2])) continue;
1799
1799
  total++;
1800
- const done2 = /[xX]/.test(m[1]);
1801
- if (done2) ticked++;
1802
- if (done2 || /~~[\s\S]*~~/.test(m[2])) resolved2++;
1800
+ const done = /[xX]/.test(m[1]);
1801
+ if (done) ticked++;
1802
+ if (done || /~~[\s\S]*~~/.test(m[2])) resolved2++;
1803
1803
  }
1804
1804
  return { total, resolved: resolved2, ticked };
1805
1805
  }
@@ -1858,8 +1858,8 @@ var init_leaving = __esm({
1858
1858
  // ../cli/src/lib/board/assemble.ts
1859
1859
  function countTodos(body) {
1860
1860
  const matches = body.match(/^[ \t]*[-*]\s+\[( |x|X)\]/gm) || [];
1861
- const done2 = matches.filter((l) => /\[[xX]\]/.test(l)).length;
1862
- return { total: matches.length, done: done2 };
1861
+ const done = matches.filter((l) => /\[[xX]\]/.test(l)).length;
1862
+ return { total: matches.length, done };
1863
1863
  }
1864
1864
  function attachBlockers(cards) {
1865
1865
  const byId = new Map(cards.map((c) => [c.id, c]));
@@ -2772,8 +2772,8 @@ import fs16 from "node:fs";
2772
2772
  import os4 from "node:os";
2773
2773
  import path17 from "node:path";
2774
2774
  function versionIn(output) {
2775
- const plain2 = output.replace(/\x1b\[[0-9;]*m/g, "");
2776
- return /(?<![\w.-])v?(\d+(?:\.\d+)+(?:-[0-9A-Za-z.-]+)?)/.exec(plain2)?.[1] ?? null;
2775
+ const plain = output.replace(/\x1b\[[0-9;]*m/g, "");
2776
+ return /(?<![\w.-])v?(\d+(?:\.\d+)+(?:-[0-9A-Za-z.-]+)?)/.exec(plain)?.[1] ?? null;
2777
2777
  }
2778
2778
  function compareVersions(a, b) {
2779
2779
  const [numberA = "", ...restA] = a.split("-");
@@ -3562,10 +3562,10 @@ function findRollout(threadId) {
3562
3562
  }
3563
3563
  for (const name of names3) {
3564
3564
  if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
3565
- const path86 = join(dir, name);
3565
+ const path85 = join(dir, name);
3566
3566
  try {
3567
- const at = statSync(path86).mtimeMs;
3568
- if (!newest2 || at > newest2.at) newest2 = { path: path86, at };
3567
+ const at = statSync(path85).mtimeMs;
3568
+ if (!newest2 || at > newest2.at) newest2 = { path: path85, at };
3569
3569
  } catch {
3570
3570
  }
3571
3571
  }
@@ -3573,11 +3573,11 @@ function findRollout(threadId) {
3573
3573
  return newest2?.path;
3574
3574
  }
3575
3575
  function readCodexRunFacts(threadId) {
3576
- const path86 = findRollout(threadId);
3577
- if (!path86) return void 0;
3576
+ const path85 = findRollout(threadId);
3577
+ if (!path85) return void 0;
3578
3578
  let raw;
3579
3579
  try {
3580
- raw = readFileSync(path86, "utf8");
3580
+ raw = readFileSync(path85, "utf8");
3581
3581
  } catch {
3582
3582
  return void 0;
3583
3583
  }
@@ -3705,8 +3705,8 @@ function renderCompleted(item) {
3705
3705
  const changes = Array.isArray(item.changes) ? item.changes : [];
3706
3706
  return changes.map((raw) => {
3707
3707
  const change2 = obj(raw);
3708
- const path86 = str(change2.path);
3709
- return path86 ? `\u23FA ${str(change2.kind) || "change"}(${path86})
3708
+ const path85 = str(change2.path);
3709
+ return path85 ? `\u23FA ${str(change2.kind) || "change"}(${path85})
3710
3710
  ` : "";
3711
3711
  }).join("");
3712
3712
  }
@@ -3753,10 +3753,10 @@ function callResult(item) {
3753
3753
  }
3754
3754
  return "";
3755
3755
  }
3756
- function itemEvents(events, started, item, done2) {
3756
+ function itemEvents(events, started, item, done) {
3757
3757
  const id = str(item.id);
3758
3758
  if (item.type === "agent_message") {
3759
- if (done2) events.message(imageSafeText(str(item.text)));
3759
+ if (done) events.message(imageSafeText(str(item.text)));
3760
3760
  return;
3761
3761
  }
3762
3762
  if (item.type === "todo_list") {
@@ -3765,7 +3765,7 @@ function itemEvents(events, started, item, done2) {
3765
3765
  return;
3766
3766
  }
3767
3767
  if (item.type === "error") {
3768
- if (done2) events.log(`${str(item.message)}
3768
+ if (done) events.log(`${str(item.message)}
3769
3769
  `);
3770
3770
  return;
3771
3771
  }
@@ -3776,7 +3776,7 @@ function itemEvents(events, started, item, done2) {
3776
3776
  const call2 = callOf(item);
3777
3777
  events.toolCall(id, call2.title, kind, call2.target);
3778
3778
  }
3779
- if (done2) {
3779
+ if (done) {
3780
3780
  const failed = item.status === "failed" || typeof item.exit_code === "number" && item.exit_code !== 0;
3781
3781
  events.toolResult(id, failed ? "failed" : "completed", callResult(item));
3782
3782
  }
@@ -3794,9 +3794,9 @@ function createCodexStreamRenderer(carried = false) {
3794
3794
  const background = createBackgroundTasks();
3795
3795
  const subagents = /* @__PURE__ */ new Set();
3796
3796
  const collabItems = /* @__PURE__ */ new Set();
3797
- const collab = (item, done2) => {
3797
+ const collab = (item, done) => {
3798
3798
  if (item.type !== "collab_tool_call") return;
3799
- const key = `${str(item.id)}:${done2}`;
3799
+ const key = `${str(item.id)}:${done}`;
3800
3800
  if (collabItems.has(key)) return;
3801
3801
  collabItems.add(key);
3802
3802
  for (const [id, raw] of Object.entries(obj(item.agents_states))) {
@@ -4013,10 +4013,10 @@ function readKimiRunFacts(sessionId) {
4013
4013
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
4014
4014
  let model;
4015
4015
  let holding = 0;
4016
- for (const { path: path86, main } of wireFiles(entry.sessionDir)) {
4016
+ for (const { path: path85, main } of wireFiles(entry.sessionDir)) {
4017
4017
  let raw;
4018
4018
  try {
4019
- raw = readFileSync2(path86, "utf8");
4019
+ raw = readFileSync2(path85, "utf8");
4020
4020
  } catch {
4021
4021
  continue;
4022
4022
  }
@@ -4355,8 +4355,8 @@ var init_package = __esm({
4355
4355
  "../cli/package.json"() {
4356
4356
  package_default = {
4357
4357
  name: "wildcrane",
4358
- version: "0.11.47",
4359
- akbContract: 12,
4358
+ version: "0.11.48",
4359
+ akbContract: 13,
4360
4360
  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.",
4361
4361
  keywords: [
4362
4362
  "kanban",
@@ -4432,8 +4432,8 @@ var init_version = __esm({
4432
4432
  import fs17 from "node:fs";
4433
4433
  function whereHint(update2, title) {
4434
4434
  const locations = Array.isArray(update2.locations) ? update2.locations : [];
4435
- const path86 = str(obj(locations[0]).path);
4436
- return path86 && !title.includes(path86) ? hint(path86) : "";
4435
+ const path85 = str(obj(locations[0]).path);
4436
+ return path85 && !title.includes(path85) ? hint(path85) : "";
4437
4437
  }
4438
4438
  function saidBy(update2) {
4439
4439
  const content = Array.isArray(update2.content) ? update2.content : [];
@@ -4607,15 +4607,15 @@ async function oneTurn(io, options) {
4607
4607
  currentSession = sessionId;
4608
4608
  live = true;
4609
4609
  phase("submitted");
4610
- const done2 = await rpc.call("session/prompt", {
4610
+ const done = await rpc.call("session/prompt", {
4611
4611
  sessionId,
4612
4612
  prompt: [{ type: "text", text: prompt }]
4613
4613
  });
4614
4614
  const result = tail.end();
4615
4615
  events.end();
4616
- const stopReason2 = str(done2.stopReason);
4617
- const spent = obj(obj(done2._meta).usage);
4618
- const usage3 = usageOf2(done2.usage) ?? usageOf2(spent, true);
4616
+ const stopReason2 = str(done.stopReason);
4617
+ const spent = obj(obj(done._meta).usage);
4618
+ const usage3 = usageOf2(done.usage) ?? usageOf2(spent, true);
4619
4619
  costUsd ??= ticksUsd(spent.costUsdTicks);
4620
4620
  if (stopReason2 && stopReason2 !== "end_turn") {
4621
4621
  const why2 = STOPPED[stopReason2] ?? `the agent stopped: ${stopReason2}`;
@@ -4899,12 +4899,12 @@ async function oneTurn2(io, options) {
4899
4899
  live = true;
4900
4900
  const accepted = await rpc.call("session/send", { sessionId, content: io.prompt });
4901
4901
  if (accepted.accepted === false) throw new Error("the agent would not take the prompt");
4902
- const done2 = await finished;
4903
- const result = tail.end() || done2.response || void 0;
4904
- const usage3 = done2.usage ?? await tokensOf(rpc, sessionId);
4902
+ const done = await finished;
4903
+ const result = tail.end() || done.response || void 0;
4904
+ const usage3 = done.usage ?? await tokensOf(rpc, sessionId);
4905
4905
  const context = await contextOf(rpc, sessionId);
4906
- if (!done2.ok) {
4907
- const why2 = done2.error ?? "the agent stopped without saying why";
4906
+ if (!done.ok) {
4907
+ const why2 = done.error ?? "the agent stopped without saying why";
4908
4908
  stopped(io, why2);
4909
4909
  return { ok: false, result, error: why2, usage: usage3, context };
4910
4910
  }
@@ -5085,7 +5085,7 @@ async function run(io, options, tasks) {
5085
5085
  let model;
5086
5086
  let provider;
5087
5087
  let resolve2;
5088
- const done2 = new Promise((r) => {
5088
+ const done = new Promise((r) => {
5089
5089
  resolve2 = r;
5090
5090
  });
5091
5091
  const deadline = createBackgroundWait(BACKGROUND_WAIT.minutes * 6e4, () => end2(backgroundWaitMessage(BACKGROUND_WAIT.minutes)));
@@ -5182,7 +5182,7 @@ async function run(io, options, tasks) {
5182
5182
  startupTimer = setTimeout(() => {
5183
5183
  if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
5184
5184
  }, CONVERSATION_MS.start);
5185
- await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text4 }, ...images.map((path86) => ({ type: "localImage", path: path86 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error) => {
5185
+ await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text4 }, ...images.map((path85) => ({ type: "localImage", path: path85 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error) => {
5186
5186
  if (!started) throw error;
5187
5187
  });
5188
5188
  };
@@ -5342,7 +5342,7 @@ async function run(io, options, tasks) {
5342
5342
  } catch (e) {
5343
5343
  end2(e instanceof Error ? e.message : String(e));
5344
5344
  }
5345
- return done2;
5345
+ return done;
5346
5346
  }
5347
5347
  var list;
5348
5348
  var init_codex = __esm({
@@ -9741,8 +9741,8 @@ var init_file_limits = __esm({
9741
9741
  });
9742
9742
 
9743
9743
  // ../cli/src/lib/shared/board-files.ts
9744
- function studioRenamed(path86, content) {
9745
- const to = path86.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
9744
+ function studioRenamed(path85, content) {
9745
+ const to = path85.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
9746
9746
  if (!to.endsWith(".md")) return { path: to, content };
9747
9747
  if (to.startsWith("studios/")) return { path: to, content: content.replace(/^(icon:\s*["']?)workflow(-kit)?(["']?\s*)$/gm, "$1studio$2$3") };
9748
9748
  const front = /^(?:todo|triage)\//.test(to) ? /^---\r?\n[\s\S]*?\r?\n---/.exec(content)?.[0] : void 0;
@@ -9751,15 +9751,13 @@ function studioRenamed(path86, content) {
9751
9751
  const renamed = front.replace(/^workflow:[ \t]*(.*)$/m, (_, id) => `studio: ${id === "workflow-builder" ? "studio-builder" : id}`);
9752
9752
  return { path: to, content: renamed + body };
9753
9753
  }
9754
- var cardSlug, studioFolder, studioName, draftFolder;
9754
+ var studioFolder, studioName;
9755
9755
  var init_board_files = __esm({
9756
9756
  "../cli/src/lib/shared/board-files.ts"() {
9757
9757
  "use strict";
9758
9758
  init_file_limits();
9759
- cardSlug = (task) => task.toLowerCase().replace(/_/g, "-");
9760
9759
  studioFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
9761
9760
  studioName = (id) => id.startsWith("wf_builtin_") ? id.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id);
9762
- draftFolder = (task) => cardSlug(task);
9763
9761
  }
9764
9762
  });
9765
9763
 
@@ -10080,15 +10078,6 @@ var init_parse = __esm({
10080
10078
  });
10081
10079
 
10082
10080
  // ../cli/src/lib/agent/studio-def.ts
10083
- function agentLines2(agents, indent2) {
10084
- return agents.flatMap(
10085
- (h) => !h.extra && !h.off ? [`${indent2}- ${scalar(h.agent)}`] : [
10086
- `${indent2}- agent: ${scalar(h.agent)}`,
10087
- ...h.extra ? [`${indent2} extra: ${JSON.stringify(h.extra)}`] : [],
10088
- ...h.off ? [`${indent2} off: true`] : []
10089
- ]
10090
- );
10091
- }
10092
10081
  function readAgent(item) {
10093
10082
  const row = typeof item === "string" ? { agent: item } : box(item);
10094
10083
  const agent = canonicalSpecAgent(text3(row.agent));
@@ -10171,7 +10160,7 @@ function parseStudioFile(id, source, from) {
10171
10160
  }
10172
10161
  };
10173
10162
  }
10174
- var scalar, plain, flowList, groupLines, STUDIO_ID, OLD_KEYS, box, text3, readGroup;
10163
+ var STUDIO_ID, OLD_KEYS, box, text3, readGroup;
10175
10164
  var init_studio_def = __esm({
10176
10165
  "../cli/src/lib/agent/studio-def.ts"() {
10177
10166
  "use strict";
@@ -10180,10 +10169,6 @@ var init_studio_def = __esm({
10180
10169
  init_yaml2();
10181
10170
  init_spec_agent_names();
10182
10171
  init_yaml();
10183
- scalar = (value) => /\s#/.test(value) ? JSON.stringify(value) : yamlScalar(value);
10184
- plain = (agents) => agents.every((h) => !h.extra && !h.off);
10185
- flowList = (agents) => `[${agents.map((h) => scalar(h.agent)).join(", ")}]`;
10186
- groupLines = (key, agents) => !agents.length ? [] : plain(agents) ? [`${key}: ${flowList(agents)}`] : [`${key}:`, ...agentLines2(agents, " ")];
10187
10172
  STUDIO_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
10188
10173
  OLD_KEYS = ["stages", "delivers", "helpers", "every"];
10189
10174
  box = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -10226,6 +10211,15 @@ var init_studio_diagram = __esm({
10226
10211
  });
10227
10212
 
10228
10213
  // ../cli/src/lib/shared/studio-files.ts
10214
+ function diagramFrom(files) {
10215
+ const read3 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
10216
+ if ("problem" in read3) return null;
10217
+ return studioDiagram(read3.def, (name) => {
10218
+ const text4 = files[`agents/${name}/AGENT.md`];
10219
+ const parsed = text4 === void 0 ? null : parseSpecAgent(text4, name, () => null, false);
10220
+ return parsed && "agent" in parsed ? parsed.agent : null;
10221
+ });
10222
+ }
10229
10223
  function folderPath(file, top) {
10230
10224
  const parts = file.split("/");
10231
10225
  if (parts.length < 3 || parts[0] !== top || !AGENT_NAME.test(parts[1])) return null;
@@ -10830,84 +10824,23 @@ var init_catalog = __esm({
10830
10824
  });
10831
10825
 
10832
10826
  // ../cli/src/lib/agent/studio-file.ts
10833
- import fs32 from "node:fs";
10834
- import path36 from "node:path";
10835
- function studioFileText(def) {
10836
- const lines = ["---", `name: ${scalar(def.name)}`];
10837
- const names3 = Object.entries(def.names ?? {});
10838
- if (names3.length) lines.push("names:", ...names3.map(([lang, said2]) => ` ${lang}: ${scalar(said2)}`));
10839
- if (def.description) lines.push(`description: ${scalar(def.description)}`);
10840
- if (def.when) lines.push(`when: ${scalar(def.when)}`);
10841
- lines.push(`needsArtifact: ${def.needsArtifact}`);
10842
- lines.push(...groupLines("previews", def.previews), ...groupLines("land", def.land));
10843
- if (def.memoryFiles?.workspace.length) lines.push("memoryFiles:", ` workspace: [${def.memoryFiles.workspace.map(scalar).join(", ")}]`);
10844
- if (def.scheduled.length) {
10845
- lines.push("scheduled:");
10846
- for (const s of def.scheduled) {
10847
- lines.push(` - agent: ${scalar(s.agent)}`);
10848
- if (s.cadence) lines.push(` cadence: ${scalar(s.cadence)}`);
10849
- }
10850
- }
10851
- lines.push("---");
10852
- return `${lines.join("\n")}
10853
- ${def.rules ? `
10854
- ${def.rules}
10855
- ` : ""}`;
10856
- }
10857
- function draftId() {
10858
- const task = workspaceTask();
10859
- if (!task) return null;
10860
- const id = draftFolder(task);
10861
- return fs32.existsSync(fileOf(id)) ? id : null;
10862
- }
10863
- function readFolder(id, problems) {
10864
- let source;
10865
- try {
10866
- source = fs32.readFileSync(fileOf(id), "utf8");
10867
- } catch {
10868
- problems.push(`${rel(fileOf(id))} is missing`);
10869
- return null;
10870
- }
10871
- const read3 = parseStudioFile(id, source, rel(fileOf(id)));
10872
- if ("problem" in read3) {
10873
- problems.push(read3.problem);
10874
- return null;
10875
- }
10876
- return read3.def;
10877
- }
10878
10827
  function boardStudioDefs() {
10879
- const problems = [];
10880
- const defs = cloudFlows().filter((f) => !f.builtIn).map((f) => f.def);
10881
- const draft = draftId();
10882
- const mine = draft ? readFolder(draft, problems) : null;
10883
- return { defs: mine ? [...defs, mine] : defs, problems };
10884
- }
10885
- function writeStudioDef(def) {
10886
- const file = fileOf(def.id);
10887
- fs32.mkdirSync(path36.dirname(file), { recursive: true });
10888
- fs32.writeFileSync(file, studioFileText(def));
10889
- forgetFileMemos();
10828
+ return { defs: cloudFlows().filter((f) => !f.builtIn).map((f) => f.def), problems: [] };
10890
10829
  }
10891
- var STUDIO_FILE2, builtinDefs, fileOf;
10830
+ var builtinDefs;
10892
10831
  var init_studio_file = __esm({
10893
10832
  "../cli/src/lib/agent/studio-file.ts"() {
10894
10833
  "use strict";
10895
- init_file_memo();
10896
- init_board_files();
10897
- init_tasks();
10898
- init_paths();
10899
10834
  init_cloud_studios();
10900
10835
  init_studio_def();
10901
10836
  init_studio_def();
10902
- STUDIO_FILE2 = "STUDIO.md";
10903
10837
  builtinDefs = () => cloudFlows().filter((f) => f.builtIn).map((f) => f.def);
10904
- fileOf = (id) => path36.join(STUDIOS, id, STUDIO_FILE2);
10905
10838
  }
10906
10839
  });
10907
10840
 
10908
10841
  // ../cli/src/lib/agent/studios.ts
10909
- import fs33 from "node:fs";
10910
- import path37 from "node:path";
10842
+ import fs32 from "node:fs";
10843
+ import path36 from "node:path";
10911
10844
  function studioPurpose(flow) {
10912
10845
  if (flow.builtIn) return builtinDescription(flow.id) || flow.name;
10913
10846
  return boardStudioDefs().defs.find((d) => d.id === flow.id)?.description || flow.name;
@@ -10981,7 +10914,7 @@ function previewStages(flow, chosen) {
10981
10914
  }
10982
10915
  function userStudioRules(flow) {
10983
10916
  try {
10984
- return fs33.readFileSync(studioRuleFile(flow.id), "utf8").trim();
10917
+ return fs32.readFileSync(studioRuleFile(flow.id), "utf8").trim();
10985
10918
  } catch {
10986
10919
  return "";
10987
10920
  }
@@ -11033,25 +10966,6 @@ function landRefused(flow, agent, found2) {
11033
10966
  keys: keys.join(",")
11034
10967
  });
11035
10968
  }
11036
- function writeDraft(def, settings) {
11037
- try {
11038
- writeStudioDef(def);
11039
- } catch (e) {
11040
- const why2 = e instanceof Error ? e.message : String(e);
11041
- return { ok: false, ...refusal("fileWrite", `couldn't write the "${def.name}" studio: ${why2}`, { path: def.id, details: why2 }) };
11042
- }
11043
- return settings ? save2(settings) : { ok: true };
11044
- }
11045
- function renameStudio(id, name) {
11046
- const draft = draftId();
11047
- if (!draft) return readOnly();
11048
- if (id !== draft) return { ok: false, ...refusal("studioReadOnly", `only the draft, \`${draft}\`, is renamed here`, { id }) };
11049
- const wanted = trimmedName(name);
11050
- if (!wanted) return { ok: false, ...refusal("studioUnnamed", "a studio needs a name") };
11051
- if (nameTaken(wanted, id)) return { ok: false, ...refusal("studioTaken", `this workspace already has a studio called "${wanted}"`, { name: wanted }) };
11052
- const def = draftDef(id);
11053
- return def ? writeDraft({ ...def, name: wanted }) : notFound(id);
11054
- }
11055
10969
  function elsewhere(agent, id) {
11056
10970
  const owner = agentStudio(agent);
11057
10971
  if (!owner || owner === id) return null;
@@ -11116,8 +11030,8 @@ function cardMeta(id) {
11116
11030
  try {
11117
11031
  const found2 = locate(id) ?? locateArchived(id);
11118
11032
  if (!found2) return null;
11119
- const file = found2.kind === "group" ? path37.join(found2.target, "root.md") : found2.target;
11120
- return parseFrontmatter(fs33.readFileSync(file, "utf8")).meta;
11033
+ const file = found2.kind === "group" ? path36.join(found2.target, "root.md") : found2.target;
11034
+ return parseFrontmatter(fs32.readFileSync(file, "utf8")).meta;
11121
11035
  } catch {
11122
11036
  return null;
11123
11037
  }
@@ -11134,7 +11048,7 @@ function frozenStudio(id) {
11134
11048
  land: landAgents(flow).map(row)
11135
11049
  };
11136
11050
  }
11137
- var builtinDescription, studiosBlock, storedStages, SCHEDULE, toRow, scheduledRow, studioFileProblems, allListed, resolved, agentAfter, agentKeyProblems, agentStudio, studios, studioById, onBoard, previewMembers, previewAgents, landAgents, archivesOnApproval, studioRuleFile, save2, draftDef, notFound, readOnly, trimmedName, nameTaken, scheduledAgent, cardStudioId, cardStages, cardStage;
11051
+ var builtinDescription, studiosBlock, storedStages, SCHEDULE, toRow, scheduledRow, studioFileProblems, allListed, resolved, agentAfter, agentKeyProblems, agentStudio, studios, studioById, onBoard, previewMembers, previewAgents, landAgents, archivesOnApproval, studioRuleFile, save2, notFound, scheduledAgent, cardStudioId, cardStages, cardStage;
11138
11052
  var init_studios = __esm({
11139
11053
  "../cli/src/lib/agent/studios.ts"() {
11140
11054
  "use strict";
@@ -11207,18 +11121,14 @@ var init_studios = __esm({
11207
11121
  previewAgents = (flow) => previewMembers(flow).filter((h) => !h.off);
11208
11122
  landAgents = (flow) => flow.land.filter((h) => !h.off);
11209
11123
  archivesOnApproval = (flow) => !!flow && !landAgents(flow).length;
11210
- studioRuleFile = (id) => path37.join(RULES, "studios", `${id}.md`);
11124
+ studioRuleFile = (id) => path36.join(RULES, "studios", `${id}.md`);
11211
11125
  save2 = (change2) => writeConfig((cfg) => {
11212
11126
  const block = configBlock(cfg.studios);
11213
11127
  change2(block);
11214
11128
  if (Object.keys(block).length === 0) delete cfg.studios;
11215
11129
  else cfg.studios = block;
11216
11130
  });
11217
- draftDef = (id) => boardStudioDefs().defs.find((d) => d.id === id);
11218
11131
  notFound = (id) => ({ ok: false, ...refusal("studioNotFound", `this board has no \`${id}\` studio`, { id }) });
11219
- readOnly = () => ({ ok: false, ...refusal("studioReadOnly", "Only a Studio builder draft is renamed here; change a studio with `akb studio pull` and `push`.") });
11220
- trimmedName = (name) => name.replace(/\s+/g, " ").trim();
11221
- nameTaken = (name, except = "") => studios().some((w) => w.id !== except && trimmedName(w.name).toLowerCase() === trimmedName(name).toLowerCase());
11222
11132
  scheduledAgent = (id, agent) => {
11223
11133
  const flow = studioById(id);
11224
11134
  return flow ? scheduledMembers(flow).find((h) => h.agent === canonicalSpecAgent(agent.trim())) : void 0;
@@ -11230,11 +11140,11 @@ var init_studios = __esm({
11230
11140
  });
11231
11141
 
11232
11142
  // ../cli/src/commands/goal.ts
11233
- import fs34 from "node:fs";
11143
+ import fs33 from "node:fs";
11234
11144
  function loadGoals() {
11235
11145
  const file = goalsFile();
11236
11146
  if (!file) die("Goals exist only inside a WildCrane goal discussion.");
11237
- const held4 = JSON.parse(fs34.readFileSync(file, "utf8"));
11147
+ const held4 = JSON.parse(fs33.readFileSync(file, "utf8"));
11238
11148
  if (held4.goals !== void 0 && held4.ideas !== void 0 && JSON.stringify(held4.goals) !== JSON.stringify(held4.ideas)) die("goals and ideas do not match.");
11239
11149
  const goals = held4.goals ?? held4.ideas;
11240
11150
  if (!Array.isArray(goals)) die("The goals array is missing or invalid.");
@@ -11264,7 +11174,7 @@ function splitBody2(text4) {
11264
11174
  }
11265
11175
  function readBody(bodyFile) {
11266
11176
  if (!bodyFile) die("--body-file is required; write the goal in a writable temporary file first.");
11267
- const text4 = fs34.readFileSync(bodyFile, "utf8");
11177
+ const text4 = fs33.readFileSync(bodyFile, "utf8");
11268
11178
  if (!text4.trim()) die("The goal must not be empty.");
11269
11179
  return splitBody2(text4);
11270
11180
  }
@@ -11276,7 +11186,7 @@ function named(held4, id) {
11276
11186
  function cmdGoal(args, opts) {
11277
11187
  const sub = args[0] ?? "";
11278
11188
  const { file, held: held4 } = loadGoals();
11279
- const write2 = () => fs34.writeFileSync(file, `${JSON.stringify({ ...held4, goals: void 0, ideas: held4.goals }, null, 2)}
11189
+ const write2 = () => fs33.writeFileSync(file, `${JSON.stringify({ ...held4, goals: void 0, ideas: held4.goals }, null, 2)}
11280
11190
  `);
11281
11191
  if (sub === "new") {
11282
11192
  const title = opts.title?.trim();
@@ -11364,9 +11274,9 @@ var init_goal = __esm({
11364
11274
  });
11365
11275
 
11366
11276
  // ../cli/src/commands/goal-cloud.ts
11367
- import fs35 from "node:fs";
11277
+ import fs34 from "node:fs";
11368
11278
  import os5 from "node:os";
11369
- import path38 from "node:path";
11279
+ import path37 from "node:path";
11370
11280
  import crypto3 from "node:crypto";
11371
11281
  function hostSession() {
11372
11282
  const { CLAUDE_CODE_SESSION_ID: claude, CODEX_THREAD_ID: codex, CURSOR_CONVERSATION_ID: cursor, KIMI_SESSION_ID: kimi, WILDCRANE_DISCUSSION: discussion2 } = process.env;
@@ -11395,24 +11305,24 @@ function goalsOf(d) {
11395
11305
  async function discussion() {
11396
11306
  const session = hostSession();
11397
11307
  if (!session) die("Goals exist only inside a WildCrane goal discussion.");
11398
- const home3 = process.env.WILDCRANE_HOME || path38.join(os5.homedir(), ".wildcrane");
11308
+ const home3 = process.env.WILDCRANE_HOME || path37.join(os5.homedir(), ".wildcrane");
11399
11309
  process.env.AI4KANBAN_HOME ??= home3;
11400
11310
  if (session.host === "discussion") return request("GET", `/v1/discussions/${encodeURIComponent(session.id)}`);
11401
- const machineFile2 = path38.join(home3, "machine.json");
11311
+ const machineFile2 = path37.join(home3, "machine.json");
11402
11312
  let machine;
11403
11313
  try {
11404
- machine = JSON.parse(fs35.readFileSync(machineFile2, "utf8")).id;
11314
+ machine = JSON.parse(fs34.readFileSync(machineFile2, "utf8")).id;
11405
11315
  } catch {
11406
11316
  machine = crypto3.randomUUID();
11407
- fs35.mkdirSync(home3, { recursive: true });
11408
- fs35.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
11317
+ fs34.mkdirSync(home3, { recursive: true });
11318
+ fs34.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
11409
11319
  }
11410
11320
  const held4 = await request("GET", `/v1/runner/folders?machine=${encodeURIComponent(machine)}`);
11411
- const cwd = fs35.realpathSync(process.cwd());
11321
+ const cwd = fs34.realpathSync(process.cwd());
11412
11322
  const folder = held4.folders.filter((f) => {
11413
11323
  try {
11414
- const dir = fs35.realpathSync(f.path);
11415
- return cwd === dir || cwd.startsWith(dir + path38.sep);
11324
+ const dir = fs34.realpathSync(f.path);
11325
+ return cwd === dir || cwd.startsWith(dir + path37.sep);
11416
11326
  } catch {
11417
11327
  return false;
11418
11328
  }
@@ -11421,16 +11331,16 @@ async function discussion() {
11421
11331
  }
11422
11332
  async function withGoalDiscussion(action, save3 = false) {
11423
11333
  const d = await discussion();
11424
- const dir = fs35.mkdtempSync(path38.join(os5.tmpdir(), "akb-goals-"));
11425
- const file = path38.join(dir, "goals.json");
11334
+ const dir = fs34.mkdtempSync(path37.join(os5.tmpdir(), "akb-goals-"));
11335
+ const file = path37.join(dir, "goals.json");
11426
11336
  const before = process.env.KANBAN_GOALS;
11427
11337
  try {
11428
11338
  const previous = goalsOf(d);
11429
- fs35.writeFileSync(file, JSON.stringify({ workspace: d.workspace, studios: await studios2(d.workspace), ideas: previous.map((g) => ({ ...g, task: typeof g.task === "object" && g.task ? g.task.id : g.task })) }));
11339
+ fs34.writeFileSync(file, JSON.stringify({ workspace: d.workspace, studios: await studios2(d.workspace), ideas: previous.map((g) => ({ ...g, task: typeof g.task === "object" && g.task ? g.task.id : g.task })) }));
11430
11340
  process.env.KANBAN_GOALS = file;
11431
11341
  const result = save3 ? await quietlyAsync(async () => action()) : await action();
11432
11342
  if (save3) {
11433
- const goals = JSON.parse(fs35.readFileSync(file, "utf8")).ideas;
11343
+ const goals = JSON.parse(fs34.readFileSync(file, "utf8")).ideas;
11434
11344
  const saved = await request("PUT", `/v1/discussions/${d.id}/draft`, { expectedVersion: d.version, goals: goals.filter((g) => !g.dropped) });
11435
11345
  const savedGoals = goalsOf(saved);
11436
11346
  const fresh = goals.filter((g) => !g.dropped && !previous.some((p) => p.id === g.id));
@@ -11449,7 +11359,7 @@ async function withGoalDiscussion(action, save3 = false) {
11449
11359
  } finally {
11450
11360
  if (before === void 0) delete process.env.KANBAN_GOALS;
11451
11361
  else process.env.KANBAN_GOALS = before;
11452
- fs35.rmSync(dir, { recursive: true, force: true });
11362
+ fs34.rmSync(dir, { recursive: true, force: true });
11453
11363
  }
11454
11364
  }
11455
11365
  async function queryPreviews(studio, workspace2) {
@@ -11481,9 +11391,9 @@ var init_goal_cloud = __esm({
11481
11391
  }
11482
11392
  });
11483
11393
 
11484
- // ../cli/node_modules/commander/lib/error.js
11394
+ // ../../work/cli/node_modules/commander/lib/error.js
11485
11395
  var require_error = __commonJS({
11486
- "../cli/node_modules/commander/lib/error.js"(exports) {
11396
+ "../../work/cli/node_modules/commander/lib/error.js"(exports) {
11487
11397
  var CommanderError2 = class extends Error {
11488
11398
  /**
11489
11399
  * Constructs the CommanderError class
@@ -11516,9 +11426,9 @@ var require_error = __commonJS({
11516
11426
  }
11517
11427
  });
11518
11428
 
11519
- // ../cli/node_modules/commander/lib/argument.js
11429
+ // ../../work/cli/node_modules/commander/lib/argument.js
11520
11430
  var require_argument = __commonJS({
11521
- "../cli/node_modules/commander/lib/argument.js"(exports) {
11431
+ "../../work/cli/node_modules/commander/lib/argument.js"(exports) {
11522
11432
  var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
11523
11433
  var Argument2 = class {
11524
11434
  /**
@@ -11643,9 +11553,9 @@ var require_argument = __commonJS({
11643
11553
  }
11644
11554
  });
11645
11555
 
11646
- // ../cli/node_modules/commander/lib/help.js
11556
+ // ../../work/cli/node_modules/commander/lib/help.js
11647
11557
  var require_help = __commonJS({
11648
- "../cli/node_modules/commander/lib/help.js"(exports) {
11558
+ "../../work/cli/node_modules/commander/lib/help.js"(exports) {
11649
11559
  var { humanReadableArgName } = require_argument();
11650
11560
  var Help2 = class {
11651
11561
  constructor() {
@@ -12212,9 +12122,9 @@ ${itemIndentStr}`);
12212
12122
  }
12213
12123
  });
12214
12124
 
12215
- // ../cli/node_modules/commander/lib/option.js
12125
+ // ../../work/cli/node_modules/commander/lib/option.js
12216
12126
  var require_option = __commonJS({
12217
- "../cli/node_modules/commander/lib/option.js"(exports) {
12127
+ "../../work/cli/node_modules/commander/lib/option.js"(exports) {
12218
12128
  var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
12219
12129
  var Option2 = class {
12220
12130
  /**
@@ -12513,9 +12423,9 @@ var require_option = __commonJS({
12513
12423
  }
12514
12424
  });
12515
12425
 
12516
- // ../cli/node_modules/commander/lib/suggestSimilar.js
12426
+ // ../../work/cli/node_modules/commander/lib/suggestSimilar.js
12517
12427
  var require_suggestSimilar = __commonJS({
12518
- "../cli/node_modules/commander/lib/suggestSimilar.js"(exports) {
12428
+ "../../work/cli/node_modules/commander/lib/suggestSimilar.js"(exports) {
12519
12429
  var maxDistance = 3;
12520
12430
  function editDistance2(a, b) {
12521
12431
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -12593,13 +12503,13 @@ var require_suggestSimilar = __commonJS({
12593
12503
  }
12594
12504
  });
12595
12505
 
12596
- // ../cli/node_modules/commander/lib/command.js
12506
+ // ../../work/cli/node_modules/commander/lib/command.js
12597
12507
  var require_command = __commonJS({
12598
- "../cli/node_modules/commander/lib/command.js"(exports) {
12508
+ "../../work/cli/node_modules/commander/lib/command.js"(exports) {
12599
12509
  var EventEmitter = __require("node:events").EventEmitter;
12600
12510
  var childProcess = __require("node:child_process");
12601
- var path86 = __require("node:path");
12602
- var fs88 = __require("node:fs");
12511
+ var path85 = __require("node:path");
12512
+ var fs87 = __require("node:fs");
12603
12513
  var process2 = __require("node:process");
12604
12514
  var { Argument: Argument2, humanReadableArgName } = require_argument();
12605
12515
  var { CommanderError: CommanderError2 } = require_error();
@@ -13580,7 +13490,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13580
13490
  * @param {string} subcommandName
13581
13491
  */
13582
13492
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
13583
- if (fs88.existsSync(executableFile)) return;
13493
+ if (fs87.existsSync(executableFile)) return;
13584
13494
  const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
13585
13495
  const executableMissing = `'${executableFile}' does not exist
13586
13496
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -13598,11 +13508,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
13598
13508
  let launchWithNode = false;
13599
13509
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
13600
13510
  function findFile(baseDir, baseName) {
13601
- const localBin = path86.resolve(baseDir, baseName);
13602
- if (fs88.existsSync(localBin)) return localBin;
13603
- if (sourceExt.includes(path86.extname(baseName))) return void 0;
13511
+ const localBin = path85.resolve(baseDir, baseName);
13512
+ if (fs87.existsSync(localBin)) return localBin;
13513
+ if (sourceExt.includes(path85.extname(baseName))) return void 0;
13604
13514
  const foundExt = sourceExt.find(
13605
- (ext) => fs88.existsSync(`${localBin}${ext}`)
13515
+ (ext) => fs87.existsSync(`${localBin}${ext}`)
13606
13516
  );
13607
13517
  if (foundExt) return `${localBin}${foundExt}`;
13608
13518
  return void 0;
@@ -13614,21 +13524,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
13614
13524
  if (this._scriptPath) {
13615
13525
  let resolvedScriptPath;
13616
13526
  try {
13617
- resolvedScriptPath = fs88.realpathSync(this._scriptPath);
13527
+ resolvedScriptPath = fs87.realpathSync(this._scriptPath);
13618
13528
  } catch {
13619
13529
  resolvedScriptPath = this._scriptPath;
13620
13530
  }
13621
- executableDir = path86.resolve(
13622
- path86.dirname(resolvedScriptPath),
13531
+ executableDir = path85.resolve(
13532
+ path85.dirname(resolvedScriptPath),
13623
13533
  executableDir
13624
13534
  );
13625
13535
  }
13626
13536
  if (executableDir) {
13627
13537
  let localFile = findFile(executableDir, executableFile);
13628
13538
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
13629
- const legacyName = path86.basename(
13539
+ const legacyName = path85.basename(
13630
13540
  this._scriptPath,
13631
- path86.extname(this._scriptPath)
13541
+ path85.extname(this._scriptPath)
13632
13542
  );
13633
13543
  if (legacyName !== this._name) {
13634
13544
  localFile = findFile(
@@ -13639,7 +13549,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13639
13549
  }
13640
13550
  executableFile = localFile || executableFile;
13641
13551
  }
13642
- launchWithNode = sourceExt.includes(path86.extname(executableFile));
13552
+ launchWithNode = sourceExt.includes(path85.extname(executableFile));
13643
13553
  let proc;
13644
13554
  if (process2.platform !== "win32") {
13645
13555
  if (launchWithNode) {
@@ -14486,7 +14396,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
14486
14396
  * @return {Command}
14487
14397
  */
14488
14398
  nameFromFilename(filename) {
14489
- this._name = path86.basename(filename, path86.extname(filename));
14399
+ this._name = path85.basename(filename, path85.extname(filename));
14490
14400
  return this;
14491
14401
  }
14492
14402
  /**
@@ -14500,9 +14410,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
14500
14410
  * @param {string} [path]
14501
14411
  * @return {(string|null|Command)}
14502
14412
  */
14503
- executableDir(path87) {
14504
- if (path87 === void 0) return this._executableDir;
14505
- this._executableDir = path87;
14413
+ executableDir(path86) {
14414
+ if (path86 === void 0) return this._executableDir;
14415
+ this._executableDir = path86;
14506
14416
  return this;
14507
14417
  }
14508
14418
  /**
@@ -14752,9 +14662,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
14752
14662
  }
14753
14663
  });
14754
14664
 
14755
- // ../cli/node_modules/commander/index.js
14665
+ // ../../work/cli/node_modules/commander/index.js
14756
14666
  var require_commander = __commonJS({
14757
- "../cli/node_modules/commander/index.js"(exports) {
14667
+ "../../work/cli/node_modules/commander/index.js"(exports) {
14758
14668
  var { Argument: Argument2 } = require_argument();
14759
14669
  var { Command: Command2 } = require_command();
14760
14670
  var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
@@ -14774,10 +14684,10 @@ var require_commander = __commonJS({
14774
14684
  }
14775
14685
  });
14776
14686
 
14777
- // ../cli/node_modules/commander/esm.mjs
14687
+ // ../../work/cli/node_modules/commander/esm.mjs
14778
14688
  var import_index, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
14779
14689
  var init_esm = __esm({
14780
- "../cli/node_modules/commander/esm.mjs"() {
14690
+ "../../work/cli/node_modules/commander/esm.mjs"() {
14781
14691
  import_index = __toESM(require_commander(), 1);
14782
14692
  ({
14783
14693
  program,
@@ -14799,11 +14709,11 @@ var init_esm = __esm({
14799
14709
  });
14800
14710
 
14801
14711
  // ../cli/src/lib/cloud/pointer.ts
14802
- import fs36 from "node:fs";
14803
- import path39 from "node:path";
14712
+ import fs35 from "node:fs";
14713
+ import path38 from "node:path";
14804
14714
  function hasRetiredPointer(root2) {
14805
14715
  try {
14806
- const held4 = JSON.parse(fs36.readFileSync(path39.join(root2, POINTER_FILE), "utf8"));
14716
+ const held4 = JSON.parse(fs35.readFileSync(path38.join(root2, POINTER_FILE), "utf8"));
14807
14717
  return typeof held4.workspace === "string" && held4.workspace.trim() !== "";
14808
14718
  } catch {
14809
14719
  return false;
@@ -14818,39 +14728,39 @@ var init_pointer = __esm({
14818
14728
  });
14819
14729
 
14820
14730
  // ../cli/src/lib/card-studio-backfill.ts
14821
- import fs37 from "node:fs";
14822
- import path40 from "node:path";
14731
+ import fs36 from "node:fs";
14732
+ import path39 from "node:path";
14823
14733
  function renameToStudio() {
14824
14734
  if (!KANBAN || !BOARD_STATE) return;
14825
- const mark = path40.join(BOARD_STATE, RENAMED);
14735
+ const mark = path39.join(BOARD_STATE, RENAMED);
14826
14736
  try {
14827
- if (fs37.existsSync(mark)) return;
14828
- for (const [from, to] of [[path40.join(KANBAN, "workflows"), STUDIOS], [path40.join(RULES, "workflows"), path40.join(RULES, "studios")]]) {
14829
- if (fs37.existsSync(from) && !fs37.existsSync(to)) fs37.renameSync(from, to);
14737
+ if (fs36.existsSync(mark)) return;
14738
+ for (const [from, to] of [[path39.join(KANBAN, "workflows"), STUDIOS], [path39.join(RULES, "workflows"), path39.join(RULES, "studios")]]) {
14739
+ if (fs36.existsSync(from) && !fs36.existsSync(to)) fs36.renameSync(from, to);
14830
14740
  }
14831
- for (const file of [STUDIOS, TODO, TRIAGE].flatMap((dir) => fs37.existsSync(dir) ? walkMd(dir) : [])) {
14832
- const at = path40.relative(KANBAN, file).split(path40.sep).join("/");
14833
- const text4 = fs37.readFileSync(file, "utf8");
14741
+ for (const file of [STUDIOS, TODO, TRIAGE].flatMap((dir) => fs36.existsSync(dir) ? walkMd(dir) : [])) {
14742
+ const at = path39.relative(KANBAN, file).split(path39.sep).join("/");
14743
+ const text4 = fs36.readFileSync(file, "utf8");
14834
14744
  const to = studioRenamed(at, text4);
14835
14745
  if (to.path === at && to.content === text4) continue;
14836
- const target = path40.join(KANBAN, to.path);
14837
- if (target !== file && fs37.existsSync(target)) continue;
14838
- fs37.writeFileSync(target, to.content);
14839
- if (target !== file) fs37.rmSync(file);
14746
+ const target = path39.join(KANBAN, to.path);
14747
+ if (target !== file && fs36.existsSync(target)) continue;
14748
+ fs36.writeFileSync(target, to.content);
14749
+ if (target !== file) fs36.rmSync(file);
14840
14750
  }
14841
- fs37.mkdirSync(BOARD_STATE, { recursive: true });
14842
- fs37.writeFileSync(mark, "");
14751
+ fs36.mkdirSync(BOARD_STATE, { recursive: true });
14752
+ fs36.writeFileSync(mark, "");
14843
14753
  } catch {
14844
14754
  }
14845
14755
  }
14846
14756
  function backfillCardStudios() {
14847
14757
  renameToStudio();
14848
14758
  if (!TODO || !BOARD_STATE) return;
14849
- const mark = path40.join(BOARD_STATE, MARK);
14759
+ const mark = path39.join(BOARD_STATE, MARK);
14850
14760
  try {
14851
- if (fs37.existsSync(mark) || !fs37.existsSync(TODO)) return;
14761
+ if (fs36.existsSync(mark) || !fs36.existsSync(TODO)) return;
14852
14762
  for (const file of walkMd(TODO)) {
14853
- const text4 = fs37.readFileSync(file, "utf8");
14763
+ const text4 = fs36.readFileSync(file, "utf8");
14854
14764
  if (!text4.startsWith("---\n")) continue;
14855
14765
  const end2 = text4.indexOf("\n---", 3);
14856
14766
  if (end2 < 0) continue;
@@ -14858,11 +14768,11 @@ function backfillCardStudios() {
14858
14768
  if (!/\ntitle:/.test(head2) || /\nstudio:/.test(head2)) continue;
14859
14769
  const modules = /\nmodules:[^\n]*/.exec(head2);
14860
14770
  const at = modules ? modules.index + modules[0].length : end2;
14861
- fs37.writeFileSync(file, `${text4.slice(0, at)}
14771
+ fs36.writeFileSync(file, `${text4.slice(0, at)}
14862
14772
  studio: coding${text4.slice(at)}`);
14863
14773
  }
14864
- fs37.mkdirSync(BOARD_STATE, { recursive: true });
14865
- fs37.writeFileSync(mark, "");
14774
+ fs36.mkdirSync(BOARD_STATE, { recursive: true });
14775
+ fs36.writeFileSync(mark, "");
14866
14776
  } catch {
14867
14777
  }
14868
14778
  }
@@ -14879,11 +14789,11 @@ var init_card_studio_backfill = __esm({
14879
14789
  });
14880
14790
 
14881
14791
  // ../cli/src/lib/view/stamp.ts
14882
- import fs38 from "node:fs";
14883
- import path41 from "node:path";
14792
+ import fs37 from "node:fs";
14793
+ import path40 from "node:path";
14884
14794
  function boardStamp() {
14885
14795
  const parts = [];
14886
- for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS, path41.join(KANBAN, ".mockups")]) walk(dir, parts, 0);
14796
+ for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS, path40.join(KANBAN, ".mockups")]) walk(dir, parts, 0);
14887
14797
  for (const file of [MODULES_MD, ARCHIVE_MD, CONFIG]) {
14888
14798
  stamp2(file, parts);
14889
14799
  }
@@ -14893,19 +14803,19 @@ function walk(dir, parts, depth3) {
14893
14803
  if (depth3 > MAX_DEPTH) return;
14894
14804
  let entries;
14895
14805
  try {
14896
- entries = fs38.readdirSync(dir, { withFileTypes: true });
14806
+ entries = fs37.readdirSync(dir, { withFileTypes: true });
14897
14807
  } catch {
14898
14808
  return;
14899
14809
  }
14900
14810
  for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
14901
- const full = path41.join(dir, entry.name);
14811
+ const full = path40.join(dir, entry.name);
14902
14812
  if (entry.isDirectory()) walk(full, parts, depth3 + 1);
14903
14813
  else stamp2(full, parts);
14904
14814
  }
14905
14815
  }
14906
14816
  function stamp2(file, parts) {
14907
14817
  try {
14908
- const s = fs38.statSync(file);
14818
+ const s = fs37.statSync(file);
14909
14819
  parts.push(`${file}:${s.size}:${Math.round(s.mtimeMs)}`);
14910
14820
  } catch {
14911
14821
  }
@@ -14937,8 +14847,8 @@ var init_contract = __esm({
14937
14847
  });
14938
14848
 
14939
14849
  // ../cli/src/lib/board/revision.ts
14940
- import fs39 from "node:fs";
14941
- import path42 from "node:path";
14850
+ import fs38 from "node:fs";
14851
+ import path41 from "node:path";
14942
14852
  function revisionOf(text4) {
14943
14853
  let h = 2166136261;
14944
14854
  for (let i = 0; i < text4.length; i++) {
@@ -14950,13 +14860,13 @@ function revisionOf(text4) {
14950
14860
  function cardFile(id) {
14951
14861
  const found2 = locate(id);
14952
14862
  if (!found2) return null;
14953
- return found2.kind === "group" ? path42.join(found2.target, "root.md") : found2.target;
14863
+ return found2.kind === "group" ? path41.join(found2.target, "root.md") : found2.target;
14954
14864
  }
14955
14865
  function cardRevision(id) {
14956
14866
  const file = cardFile(id);
14957
14867
  if (!file) return NO_REVISION;
14958
14868
  try {
14959
- return revisionOf(fs39.readFileSync(file, "utf8"));
14869
+ return revisionOf(fs38.readFileSync(file, "utf8"));
14960
14870
  } catch {
14961
14871
  return NO_REVISION;
14962
14872
  }
@@ -14978,14 +14888,14 @@ var init_revision = __esm({
14978
14888
  });
14979
14889
 
14980
14890
  // ../cli/src/lib/plans.ts
14981
- import fs40 from "node:fs";
14982
- import path43 from "node:path";
14891
+ import fs39 from "node:fs";
14892
+ import path42 from "node:path";
14983
14893
  function planFile(rel2) {
14984
14894
  if (!/^plans\/(archive\/)?[^/\\]+\.md$/.test(rel2)) return null;
14985
14895
  const dir = isArchivedPlan(rel2) ? PLANS_ARCHIVE : PLANS;
14986
14896
  const name = rel2.replace(/^plans\/(archive\/)?/, "");
14987
14897
  if (!name || name.includes("/") || !name.endsWith(".md")) return null;
14988
- return path43.join(dir, name);
14898
+ return path42.join(dir, name);
14989
14899
  }
14990
14900
  function readPlan(rel2) {
14991
14901
  const file = planFile(rel2);
@@ -14993,12 +14903,12 @@ function readPlan(rel2) {
14993
14903
  let text4 = "";
14994
14904
  let found2 = rel2;
14995
14905
  try {
14996
- text4 = fs40.readFileSync(file, "utf8");
14906
+ text4 = fs39.readFileSync(file, "utf8");
14997
14907
  } catch {
14998
14908
  const moved = renamedPlan(rel2);
14999
14909
  if (moved) {
15000
14910
  found2 = moved;
15001
- text4 = fs40.readFileSync(planFile(moved), "utf8");
14911
+ text4 = fs39.readFileSync(planFile(moved), "utf8");
15002
14912
  }
15003
14913
  }
15004
14914
  return { path: found2, text: text4, lines: text4.trim() ? text4.trimEnd().split("\n").length : 0 };
@@ -15013,13 +14923,13 @@ function renamedPlan(rel2) {
15013
14923
  ]) {
15014
14924
  let names3;
15015
14925
  try {
15016
- names3 = fs40.readdirSync(dir);
14926
+ names3 = fs39.readdirSync(dir);
15017
14927
  } catch {
15018
14928
  continue;
15019
14929
  }
15020
14930
  for (const n of names3) {
15021
14931
  if (!n.startsWith(`${id}-`) || !n.endsWith(".md")) continue;
15022
- found2.push({ rel: `${prefix}${n}`, at: fs40.statSync(path43.join(dir, n)).mtimeMs });
14932
+ found2.push({ rel: `${prefix}${n}`, at: fs39.statSync(path42.join(dir, n)).mtimeMs });
15023
14933
  }
15024
14934
  }
15025
14935
  if (!found2.length) return null;
@@ -15028,7 +14938,7 @@ function renamedPlan(rel2) {
15028
14938
  function planFromText(text4) {
15029
14939
  const legacy2 = `${legacyProjectStateDir(KANBAN)}/`;
15030
14940
  if (text4.startsWith(legacy2)) text4 = text4.slice(legacy2.length);
15031
- const local = `${path43.dirname(PLANS)}/`;
14941
+ const local = `${path42.dirname(PLANS)}/`;
15032
14942
  if (text4.startsWith(local)) text4 = text4.slice(local.length);
15033
14943
  if (text4.startsWith(`${KANBAN}/`)) text4 = text4.slice(KANBAN.length + 1);
15034
14944
  const here = `${boardPath()}/`;
@@ -15156,23 +15066,23 @@ var init_telemetry_contract = __esm({
15156
15066
  });
15157
15067
 
15158
15068
  // ../cli/src/lib/agent/catalog.ts
15159
- import fs41 from "node:fs";
15160
- import path44 from "node:path";
15069
+ import fs40 from "node:fs";
15070
+ import path43 from "node:path";
15161
15071
  function cacheFile() {
15162
- return path44.join(machineHome(), "models-dev.json");
15072
+ return path43.join(machineHome(), "models-dev.json");
15163
15073
  }
15164
15074
  function readCache() {
15165
15075
  const file = cacheFile();
15166
15076
  let stamp4;
15167
15077
  try {
15168
- const stat = fs41.statSync(file);
15078
+ const stat = fs40.statSync(file);
15169
15079
  stamp4 = `${stat.mtimeMs}:${stat.size}`;
15170
15080
  } catch {
15171
15081
  return void 0;
15172
15082
  }
15173
15083
  if (held3?.stamp === stamp4) return held3.cached;
15174
15084
  try {
15175
- const data = JSON.parse(fs41.readFileSync(file, "utf8"));
15085
+ const data = JSON.parse(fs40.readFileSync(file, "utf8"));
15176
15086
  if (!data || typeof data.limits !== "object" || !data.limits) return void 0;
15177
15087
  const cached2 = {
15178
15088
  fetchedAt: typeof data.fetchedAt === "number" ? data.fetchedAt : 0,
@@ -15210,8 +15120,8 @@ function refreshCatalog() {
15210
15120
  const limits = limitsIn(await answer2.json());
15211
15121
  if (Object.keys(limits).length === 0) return;
15212
15122
  const file = cacheFile();
15213
- fs41.mkdirSync(path44.dirname(file), { recursive: true });
15214
- fs41.writeFileSync(file, JSON.stringify({ fetchedAt: Date.now(), limits }));
15123
+ fs40.mkdirSync(path43.dirname(file), { recursive: true });
15124
+ fs40.writeFileSync(file, JSON.stringify({ fetchedAt: Date.now(), limits }));
15215
15125
  } catch {
15216
15126
  }
15217
15127
  })();
@@ -15274,8 +15184,8 @@ var init_catalog2 = __esm({
15274
15184
  });
15275
15185
 
15276
15186
  // ../cli/src/lib/machine/telemetry.ts
15277
- import fs42 from "node:fs";
15278
- import path45 from "node:path";
15187
+ import fs41 from "node:fs";
15188
+ import path44 from "node:path";
15279
15189
  import { randomUUID as randomUUID2 } from "node:crypto";
15280
15190
  function readUsageReporting() {
15281
15191
  const { unreadable, values } = heldSettings();
@@ -15309,8 +15219,8 @@ function write(on, disclosed) {
15309
15219
  if (!on) patch2.usageInstallId = void 0;
15310
15220
  const saved = saveSettings(patch2);
15311
15221
  if (saved.ok && !on) {
15312
- fs42.rmSync(usageQueueFile(), { force: true });
15313
- fs42.rmSync(usageStateFile(), { force: true });
15222
+ fs41.rmSync(usageQueueFile(), { force: true });
15223
+ fs41.rmSync(usageStateFile(), { force: true });
15314
15224
  }
15315
15225
  return saved;
15316
15226
  }
@@ -15320,14 +15230,14 @@ var init_telemetry = __esm({
15320
15230
  "use strict";
15321
15231
  init_home();
15322
15232
  init_settings2();
15323
- usageQueueFile = () => path45.join(machineHome(), "usage-queue.jsonl");
15324
- usageStateFile = () => path45.join(machineHome(), "usage-state.json");
15233
+ usageQueueFile = () => path44.join(machineHome(), "usage-queue.jsonl");
15234
+ usageStateFile = () => path44.join(machineHome(), "usage-state.json");
15325
15235
  }
15326
15236
  });
15327
15237
 
15328
15238
  // ../cli/src/lib/machine/usage.ts
15329
- import fs43 from "node:fs";
15330
- import path46 from "node:path";
15239
+ import fs42 from "node:fs";
15240
+ import path45 from "node:path";
15331
15241
  import { randomUUID as randomUUID3 } from "node:crypto";
15332
15242
  function usageSurface() {
15333
15243
  return process.env.KANBAN_DESKTOP === "1" ? "app" : "command";
@@ -15404,15 +15314,15 @@ function endFields({ model, costUsd, ownEndpoint }) {
15404
15314
  }
15405
15315
  function readBoard() {
15406
15316
  try {
15407
- const held4 = JSON.parse(fs43.readFileSync(boardFile(), "utf8"));
15317
+ const held4 = JSON.parse(fs42.readFileSync(boardFile(), "utf8"));
15408
15318
  return held4 && typeof held4 === "object" ? held4 : {};
15409
15319
  } catch {
15410
15320
  return {};
15411
15321
  }
15412
15322
  }
15413
15323
  function writeBoard(state) {
15414
- fs43.mkdirSync(BOARD_STATE, { recursive: true });
15415
- fs43.writeFileSync(boardFile(), `${JSON.stringify(state)}
15324
+ fs42.mkdirSync(BOARD_STATE, { recursive: true });
15325
+ fs42.writeFileSync(boardFile(), `${JSON.stringify(state)}
15416
15326
  `);
15417
15327
  }
15418
15328
  function countBoardEvent(name, n = 1) {
@@ -15456,7 +15366,7 @@ function reportBoardNumbers(customAgentsOn2) {
15456
15366
  function readQueue(day = usageDay()) {
15457
15367
  let text4;
15458
15368
  try {
15459
- text4 = fs43.readFileSync(usageQueueFile(), "utf8");
15369
+ text4 = fs42.readFileSync(usageQueueFile(), "utf8");
15460
15370
  } catch {
15461
15371
  return [];
15462
15372
  }
@@ -15478,8 +15388,8 @@ function readQueue(day = usageDay()) {
15478
15388
  }
15479
15389
  function append(event2) {
15480
15390
  const file = usageQueueFile();
15481
- fs43.mkdirSync(machineHome(), { recursive: true, mode: 448 });
15482
- fs43.appendFileSync(file, `${JSON.stringify(event2)}
15391
+ fs42.mkdirSync(machineHome(), { recursive: true, mode: 448 });
15392
+ fs42.appendFileSync(file, `${JSON.stringify(event2)}
15483
15393
  `);
15484
15394
  const queued = readQueue();
15485
15395
  if (queued.length > QUEUE_MAX) writeQueue(queued.slice(queued.length - QUEUE_MAX));
@@ -15487,14 +15397,14 @@ function append(event2) {
15487
15397
  function writeQueue(events) {
15488
15398
  const file = usageQueueFile();
15489
15399
  if (!events.length) {
15490
- fs43.rmSync(file, { force: true });
15400
+ fs42.rmSync(file, { force: true });
15491
15401
  return;
15492
15402
  }
15493
- fs43.mkdirSync(machineHome(), { recursive: true, mode: 448 });
15403
+ fs42.mkdirSync(machineHome(), { recursive: true, mode: 448 });
15494
15404
  const tmp = `${file}.${process.pid}.tmp`;
15495
- fs43.writeFileSync(tmp, `${events.map((e) => JSON.stringify(e)).join("\n")}
15405
+ fs42.writeFileSync(tmp, `${events.map((e) => JSON.stringify(e)).join("\n")}
15496
15406
  `);
15497
- fs43.renameSync(tmp, file);
15407
+ fs42.renameSync(tmp, file);
15498
15408
  }
15499
15409
  function shiftDay(day, days) {
15500
15410
  const at = Date.parse(`${day}T00:00:00Z`);
@@ -15502,7 +15412,7 @@ function shiftDay(day, days) {
15502
15412
  }
15503
15413
  function readState() {
15504
15414
  try {
15505
- const parsed = JSON.parse(fs43.readFileSync(usageStateFile(), "utf8"));
15415
+ const parsed = JSON.parse(fs42.readFileSync(usageStateFile(), "utf8"));
15506
15416
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
15507
15417
  } catch {
15508
15418
  return {};
@@ -15510,12 +15420,12 @@ function readState() {
15510
15420
  }
15511
15421
  function writeState(state) {
15512
15422
  try {
15513
- fs43.mkdirSync(machineHome(), { recursive: true, mode: 448 });
15423
+ fs42.mkdirSync(machineHome(), { recursive: true, mode: 448 });
15514
15424
  const file = usageStateFile();
15515
15425
  const tmp = `${file}.${process.pid}.tmp`;
15516
- fs43.writeFileSync(tmp, `${JSON.stringify(state, null, 2)}
15426
+ fs42.writeFileSync(tmp, `${JSON.stringify(state, null, 2)}
15517
15427
  `);
15518
- fs43.renameSync(tmp, file);
15428
+ fs42.renameSync(tmp, file);
15519
15429
  } catch {
15520
15430
  return;
15521
15431
  }
@@ -15606,7 +15516,7 @@ var init_usage = __esm({
15606
15516
  "decisions_stood",
15607
15517
  "decisions_overruled"
15608
15518
  ];
15609
- boardFile = () => path46.join(BOARD_STATE, "usage-board.json");
15519
+ boardFile = () => path45.join(BOARD_STATE, "usage-board.json");
15610
15520
  countOf = (counts, name) => {
15611
15521
  const n = counts?.[name];
15612
15522
  return typeof n === "number" && Number.isInteger(n) && n > 0 ? n : 0;
@@ -15653,14 +15563,14 @@ var init_candidate = __esm({
15653
15563
  });
15654
15564
 
15655
15565
  // ../cli/src/lib/agent/outputs.ts
15656
- import fs44 from "node:fs";
15566
+ import fs43 from "node:fs";
15657
15567
  import os6 from "node:os";
15658
- import path47 from "node:path";
15568
+ import path46 from "node:path";
15659
15569
  function cardBody(cardId2) {
15660
15570
  const found2 = locate(cardId2) ?? locateArchived(cardId2);
15661
15571
  if (!found2) return "";
15662
15572
  try {
15663
- return fs44.readFileSync(found2.kind === "group" ? path47.join(found2.target, "root.md") : found2.target, "utf8");
15573
+ return fs43.readFileSync(found2.kind === "group" ? path46.join(found2.target, "root.md") : found2.target, "utf8");
15664
15574
  } catch {
15665
15575
  return "";
15666
15576
  }
@@ -15683,7 +15593,7 @@ function filesStop(delivery) {
15683
15593
  if (!outputs.length) {
15684
15594
  return { reason: "output", why: "the card records no output file", paths: [] };
15685
15595
  }
15686
- const missing = outputs.filter((f) => !fs44.existsSync(resolveOutput(f)));
15596
+ const missing = outputs.filter((f) => !fs43.existsSync(resolveOutput(f)));
15687
15597
  if (missing.length) {
15688
15598
  return { reason: "output", why: `recorded output files are missing: ${missing.join(", ")}`, paths: missing };
15689
15599
  }
@@ -15703,20 +15613,20 @@ var init_outputs = __esm({
15703
15613
  plannedTodos = (cardId2) => todos(cardId2).map((t) => t.text);
15704
15614
  looksLikePath = (token2) => !/\s/.test(token2) && !token2.includes("://") && !token2.startsWith("-") && token2.includes("/");
15705
15615
  resolveOutput = (file) => {
15706
- if (file.startsWith("~/")) return path47.join(os6.homedir(), file.slice(2));
15707
- if (path47.isAbsolute(file)) return file;
15708
- if (file.startsWith(".assets/")) return path47.join(ASSETS, file.slice(".assets/".length));
15709
- return path47.join(REPO_ROOT, file);
15616
+ if (file.startsWith("~/")) return path46.join(os6.homedir(), file.slice(2));
15617
+ if (path46.isAbsolute(file)) return file;
15618
+ if (file.startsWith(".assets/")) return path46.join(ASSETS, file.slice(".assets/".length));
15619
+ return path46.join(REPO_ROOT, file);
15710
15620
  };
15711
15621
  }
15712
15622
  });
15713
15623
 
15714
15624
  // ../cli/src/lib/agent/commit-mode.ts
15715
- import fs45 from "node:fs";
15625
+ import fs44 from "node:fs";
15716
15626
  function recordedIds() {
15717
15627
  try {
15718
15628
  return new Set(
15719
- fs45.readdirSync(DELIVERIES).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length))
15629
+ fs44.readdirSync(DELIVERIES).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length))
15720
15630
  );
15721
15631
  } catch {
15722
15632
  return /* @__PURE__ */ new Set();
@@ -15749,7 +15659,7 @@ var init_commit_mode = __esm({
15749
15659
  init_worktree();
15750
15660
  ID_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
15751
15661
  ID_LENGTH2 = 8;
15752
- deliveryCwd = (delivery) => delivery.worktree && fs45.existsSync(worktreeDir(delivery.worktree)) ? worktreeDir(delivery.worktree) : REPO_ROOT;
15662
+ deliveryCwd = (delivery) => delivery.worktree && fs44.existsSync(worktreeDir(delivery.worktree)) ? worktreeDir(delivery.worktree) : REPO_ROOT;
15753
15663
  }
15754
15664
  });
15755
15665
 
@@ -15930,12 +15840,12 @@ var init_runner = __esm({
15930
15840
  });
15931
15841
 
15932
15842
  // ../cli/src/lib/agent/rules.ts
15933
- import fs46 from "node:fs";
15934
- import path48 from "node:path";
15843
+ import fs45 from "node:fs";
15844
+ import path47 from "node:path";
15935
15845
  function ruleFile(agent) {
15936
15846
  if (!agent || hiddenRole(agent)) return "";
15937
15847
  try {
15938
- return fs46.readFileSync(rulePath(agent), "utf8").trim();
15848
+ return fs45.readFileSync(rulePath(agent), "utf8").trim();
15939
15849
  } catch {
15940
15850
  return "";
15941
15851
  }
@@ -15994,7 +15904,7 @@ function migrateFlowRules() {
15994
15904
  adoptRenamedRules();
15995
15905
  let here;
15996
15906
  try {
15997
- here = new Set(fs46.readdirSync(RULES));
15907
+ here = new Set(fs45.readdirSync(RULES));
15998
15908
  } catch {
15999
15909
  return [];
16000
15910
  }
@@ -16008,9 +15918,9 @@ function migrateFlowRules() {
16008
15918
  if (!from.length) continue;
16009
15919
  const parts = [ruleFile(owner.name), ...from.map(ruleFile)].filter(Boolean);
16010
15920
  try {
16011
- if (parts.length) fs46.writeFileSync(rulePath(owner.name), `${parts.join("\n\n")}
15921
+ if (parts.length) fs45.writeFileSync(rulePath(owner.name), `${parts.join("\n\n")}
16012
15922
  `);
16013
- for (const flow of from) fs46.rmSync(rulePath(flow), { force: true });
15923
+ for (const flow of from) fs45.rmSync(rulePath(flow), { force: true });
16014
15924
  } catch (err) {
16015
15925
  notes.push(`could not move the ${from.join(", ")} rule(s) onto \`${owner.name}\`: ${String(err)}`);
16016
15926
  continue;
@@ -16024,7 +15934,7 @@ function migrateFlowRules() {
16024
15934
  function adoptRenamedRules() {
16025
15935
  let here;
16026
15936
  try {
16027
- here = fs46.readdirSync(RULES);
15937
+ here = fs45.readdirSync(RULES);
16028
15938
  } catch {
16029
15939
  return;
16030
15940
  }
@@ -16034,13 +15944,13 @@ function adoptRenamedRules() {
16034
15944
  const now = RENAMED_ROLES[was] ?? canonicalSpecAgent(was);
16035
15945
  if (now === was) continue;
16036
15946
  try {
16037
- if (!fs46.existsSync(rulePath(now))) fs46.renameSync(rulePath(was), rulePath(now));
15947
+ if (!fs45.existsSync(rulePath(now))) fs45.renameSync(rulePath(was), rulePath(now));
16038
15948
  else if (FOLDED_SPEC_AGENTS.has(was)) {
16039
15949
  const kept2 = ruleFile(now);
16040
15950
  const carried = ruleFile(was);
16041
- if (carried && !kept2.includes(carried)) fs46.writeFileSync(rulePath(now), `${[kept2, carried].filter(Boolean).join("\n\n")}
15951
+ if (carried && !kept2.includes(carried)) fs45.writeFileSync(rulePath(now), `${[kept2, carried].filter(Boolean).join("\n\n")}
16042
15952
  `);
16043
- fs46.rmSync(rulePath(was), { force: true });
15953
+ fs45.rmSync(rulePath(was), { force: true });
16044
15954
  }
16045
15955
  } catch {
16046
15956
  }
@@ -16057,7 +15967,7 @@ var init_rules2 = __esm({
16057
15967
  init_runner();
16058
15968
  init_studios();
16059
15969
  init_types();
16060
- rulePath = (agent) => path48.join(RULES, `${agent}.md`);
15970
+ rulePath = (agent) => path47.join(RULES, `${agent}.md`);
16061
15971
  flowForRequest = (req) => req.refineRound !== void 0 && REFINE_ACTIONS.has(req.action) ? flowByCommand("refine") : flowByAction(req.action);
16062
15972
  ruleOwnerSays = (owner) => `\`${owner.name}\` agent carries one rule of its own${owner.role ? ", on every flow it runs" : ""}`;
16063
15973
  said = (owner, rule) => owner && rule ? [
@@ -16069,8 +15979,8 @@ var init_rules2 = __esm({
16069
15979
  });
16070
15980
 
16071
15981
  // ../cli/src/lib/agent/deliveries.ts
16072
- import fs47 from "node:fs";
16073
- import path49 from "node:path";
15982
+ import fs46 from "node:fs";
15983
+ import path48 from "node:path";
16074
15984
  function writeAudit(delivery, runs) {
16075
15985
  const known2 = new Map(readAudit(delivery.deliveryId)?.sessions.map((s) => [s.sessionId, s]) ?? []);
16076
15986
  const sessions = delivery.sessions.flatMap((id) => {
@@ -16098,10 +16008,10 @@ function writeAudit(delivery, runs) {
16098
16008
  }
16099
16009
  function writeAuditFile(record) {
16100
16010
  try {
16101
- fs47.mkdirSync(DELIVERIES, { recursive: true });
16011
+ fs46.mkdirSync(DELIVERIES, { recursive: true });
16102
16012
  const tmp = `${auditPath(record.deliveryId)}.tmp`;
16103
- fs47.writeFileSync(tmp, JSON.stringify(record, null, 2) + "\n");
16104
- fs47.renameSync(tmp, auditPath(record.deliveryId));
16013
+ fs46.writeFileSync(tmp, JSON.stringify(record, null, 2) + "\n");
16014
+ fs46.renameSync(tmp, auditPath(record.deliveryId));
16105
16015
  return true;
16106
16016
  } catch {
16107
16017
  return false;
@@ -16109,7 +16019,7 @@ function writeAuditFile(record) {
16109
16019
  }
16110
16020
  function readAudit(deliveryId) {
16111
16021
  try {
16112
- const data = JSON.parse(fs47.readFileSync(auditPath(deliveryId), "utf8"));
16022
+ const data = JSON.parse(fs46.readFileSync(auditPath(deliveryId), "utf8"));
16113
16023
  return { sessions: Array.isArray(data?.sessions) ? data.sessions : [] };
16114
16024
  } catch {
16115
16025
  return null;
@@ -16124,7 +16034,7 @@ function syncAudit(deliveryId, just) {
16124
16034
  }
16125
16035
  function wholeAudit(file) {
16126
16036
  try {
16127
- const data = JSON.parse(fs47.readFileSync(file, "utf8"));
16037
+ const data = JSON.parse(fs46.readFileSync(file, "utf8"));
16128
16038
  return typeof data?.deliveryId === "string" && Array.isArray(data.sessions) ? data : null;
16129
16039
  } catch {
16130
16040
  return null;
@@ -16137,14 +16047,14 @@ function activeAudit(file) {
16137
16047
  function allAudits() {
16138
16048
  let names3;
16139
16049
  try {
16140
- names3 = fs47.readdirSync(DELIVERIES);
16050
+ names3 = fs46.readdirSync(DELIVERIES);
16141
16051
  } catch {
16142
16052
  return [];
16143
16053
  }
16144
16054
  const out = [];
16145
16055
  for (const name of names3) {
16146
16056
  if (!name.endsWith(".json")) continue;
16147
- const audit = wholeAudit(path49.join(DELIVERIES, name));
16057
+ const audit = wholeAudit(path48.join(DELIVERIES, name));
16148
16058
  if (audit) out.push(audit);
16149
16059
  }
16150
16060
  return out;
@@ -16317,10 +16227,10 @@ function carryOnFrom(_deliveryId) {
16317
16227
  function approvedRequirements(cardId2) {
16318
16228
  const found2 = locate(cardId2);
16319
16229
  if (!found2) return "";
16320
- const file = found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target;
16230
+ const file = found2.kind === "group" ? path48.join(found2.target, "root.md") : found2.target;
16321
16231
  let text4;
16322
16232
  try {
16323
- text4 = fs47.readFileSync(file, "utf8");
16233
+ text4 = fs46.readFileSync(file, "utf8");
16324
16234
  } catch {
16325
16235
  return "";
16326
16236
  }
@@ -16350,8 +16260,8 @@ function cardMeta2(cardId2) {
16350
16260
  try {
16351
16261
  const found2 = locate(cardId2);
16352
16262
  if (!found2) return null;
16353
- const file = found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target;
16354
- return parseFrontmatter(fs47.readFileSync(file, "utf8")).meta;
16263
+ const file = found2.kind === "group" ? path48.join(found2.target, "root.md") : found2.target;
16264
+ return parseFrontmatter(fs46.readFileSync(file, "utf8")).meta;
16355
16265
  } catch {
16356
16266
  return null;
16357
16267
  }
@@ -16522,11 +16432,11 @@ var init_deliveries = __esm({
16522
16432
  init_types();
16523
16433
  init_worktree();
16524
16434
  init_lock();
16525
- auditPath = (deliveryId) => path49.join(DELIVERIES, `${deliveryId}.json`);
16435
+ auditPath = (deliveryId) => path48.join(DELIVERIES, `${deliveryId}.json`);
16526
16436
  activeAudits = () => allAudits().filter((a) => a.status === "active");
16527
16437
  auditRow = (audit) => readDeliveryRow({ ...audit, sessions: audit.sessions.map((s) => s.sessionId) });
16528
16438
  lastSessionRunning = (audit) => audit.sessions[audit.sessions.length - 1]?.status === "running";
16529
- localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path49.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs47.existsSync(logPathOf(session.sessionId)));
16439
+ localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path48.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs46.existsSync(logPathOf(session.sessionId)));
16530
16440
  unknownDelivery = (id) => refusal("deliveryNotFound", `no delivery here answers to "${id}"`, { id });
16531
16441
  isResumable = (delivery) => !resumeRefusal(delivery);
16532
16442
  APPROVED = [
@@ -16550,35 +16460,35 @@ var init_deliveries = __esm({
16550
16460
  });
16551
16461
 
16552
16462
  // ../cli/src/lib/agent/pictures.ts
16553
- import fs48 from "node:fs";
16554
- import path50 from "node:path";
16463
+ import fs47 from "node:fs";
16464
+ import path49 from "node:path";
16555
16465
  function claimRunPictures(box2, sessionId, names3 = []) {
16556
16466
  if (!box2 || !freeBox(box2) || names3.length === 0) return [];
16557
16467
  const from = pictureBox(box2);
16558
16468
  const to = pictureBox(sessionId);
16559
16469
  try {
16560
- fs48.mkdirSync(SESSIONS_DIR, { recursive: true });
16561
- fs48.renameSync(from, to);
16470
+ fs47.mkdirSync(SESSIONS_DIR, { recursive: true });
16471
+ fs47.renameSync(from, to);
16562
16472
  } catch {
16563
16473
  return [];
16564
16474
  }
16565
- return names3.filter(pictureName).map((name) => path50.join(to, name)).filter((file) => fs48.existsSync(file));
16475
+ return names3.filter(pictureName).map((name) => path49.join(to, name)).filter((file) => fs47.existsSync(file));
16566
16476
  }
16567
16477
  function returnRunPictures(sessionId, box2) {
16568
16478
  if (!box2 || !boxId(box2)) return;
16569
16479
  try {
16570
- fs48.renameSync(pictureBox(sessionId), pictureBox(box2));
16480
+ fs47.renameSync(pictureBox(sessionId), pictureBox(box2));
16571
16481
  } catch {
16572
16482
  }
16573
16483
  }
16574
16484
  function moveRunPictures(from, to, files = []) {
16575
16485
  if (files.length === 0) return [];
16576
16486
  try {
16577
- fs48.renameSync(pictureBox(from), pictureBox(to));
16487
+ fs47.renameSync(pictureBox(from), pictureBox(to));
16578
16488
  } catch {
16579
16489
  return files;
16580
16490
  }
16581
- return files.map((file) => path50.join(pictureBox(to), path50.basename(file)));
16491
+ return files.map((file) => path49.join(pictureBox(to), path49.basename(file)));
16582
16492
  }
16583
16493
  var pictureName, boxId, freeBox, pictureBox;
16584
16494
  var init_pictures = __esm({
@@ -16587,8 +16497,8 @@ var init_pictures = __esm({
16587
16497
  init_paths();
16588
16498
  pictureName = (name) => /^[0-9a-f-]{36}\.[a-z0-9]{2,5}$/.test(name);
16589
16499
  boxId = (box2) => /^[0-9a-f-]{36}$/.test(box2);
16590
- freeBox = (box2) => boxId(box2) && !fs48.existsSync(path50.join(SESSIONS_DIR, `${box2}.log`));
16591
- pictureBox = (box2) => path50.join(SESSIONS_DIR, `${box2}.images`);
16500
+ freeBox = (box2) => boxId(box2) && !fs47.existsSync(path49.join(SESSIONS_DIR, `${box2}.log`));
16501
+ pictureBox = (box2) => path49.join(SESSIONS_DIR, `${box2}.images`);
16592
16502
  }
16593
16503
  });
16594
16504
 
@@ -16686,8 +16596,8 @@ var init_components = __esm({
16686
16596
  });
16687
16597
 
16688
16598
  // ../cli/src/lib/memories.ts
16689
- import fs49 from "node:fs";
16690
- import path51 from "node:path";
16599
+ import fs48 from "node:fs";
16600
+ import path50 from "node:path";
16691
16601
  function readMemory(text4, builtIn, folder) {
16692
16602
  const { meta, body } = splitFrontmatter(text4);
16693
16603
  if (meta === null) return null;
@@ -16707,7 +16617,7 @@ function readMemory(text4, builtIn, folder) {
16707
16617
  rules: body.trim(),
16708
16618
  text: text4,
16709
16619
  builtIn,
16710
- dir: path51.join(MEMORY, folder)
16620
+ dir: path50.join(MEMORY, folder)
16711
16621
  };
16712
16622
  }
16713
16623
  function globalMemories() {
@@ -16718,14 +16628,14 @@ function globalMemories() {
16718
16628
  }
16719
16629
  let folders2 = [];
16720
16630
  try {
16721
- folders2 = fs49.readdirSync(MEMORY, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
16631
+ folders2 = fs48.readdirSync(MEMORY, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
16722
16632
  } catch {
16723
16633
  }
16724
16634
  for (const name of folders2) {
16725
16635
  if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR || name === STUDIO_MEMORY_DIR) continue;
16726
- const file = path51.join(MEMORY, name, GLOBAL_MEMORY_FILE);
16727
- if (!fs49.existsSync(file)) continue;
16728
- const memory = readMemory(fs49.readFileSync(file, "utf8"), false, name);
16636
+ const file = path50.join(MEMORY, name, GLOBAL_MEMORY_FILE);
16637
+ if (!fs48.existsSync(file)) continue;
16638
+ const memory = readMemory(fs48.readFileSync(file, "utf8"), false, name);
16729
16639
  if (memory) out.push(memory);
16730
16640
  }
16731
16641
  return out;
@@ -16781,16 +16691,16 @@ var init_facts = __esm({
16781
16691
  });
16782
16692
 
16783
16693
  // ../cli/src/lib/view/archive.ts
16784
- import fs50 from "node:fs";
16785
- import path52 from "node:path";
16694
+ import fs49 from "node:fs";
16695
+ import path51 from "node:path";
16786
16696
  function archivedId(file) {
16787
- const own = idPrefix(path52.basename(file));
16788
- return own !== null ? own : idPrefix(path52.basename(path52.dirname(file)));
16697
+ const own = idPrefix(path51.basename(file));
16698
+ return own !== null ? own : idPrefix(path51.basename(path51.dirname(file)));
16789
16699
  }
16790
16700
  function readFile(file) {
16791
16701
  const id = archivedId(file);
16792
16702
  if (id === null) return null;
16793
- const { meta, body } = parseFrontmatter(fs50.readFileSync(file, "utf8"));
16703
+ const { meta, body } = parseFrontmatter(fs49.readFileSync(file, "utf8"));
16794
16704
  if (!meta) return null;
16795
16705
  return {
16796
16706
  row: {
@@ -16798,15 +16708,15 @@ function readFile(file) {
16798
16708
  title: meta.title,
16799
16709
  archived: meta.archived,
16800
16710
  rejected: meta.rejected,
16801
- relPath: rel(file).split(path52.sep).join("/")
16711
+ relPath: rel(file).split(path51.sep).join("/")
16802
16712
  },
16803
16713
  body: body.replace(/^\n+/, "").replace(/\s+$/, ""),
16804
16714
  meta
16805
16715
  };
16806
16716
  }
16807
16717
  function readArchive() {
16808
- const relPath = rel(ARCHIVE).split(path52.sep).join("/");
16809
- if (!fs50.existsSync(ARCHIVE)) return { relPath, cards: [] };
16718
+ const relPath = rel(ARCHIVE).split(path51.sep).join("/");
16719
+ if (!fs49.existsSync(ARCHIVE)) return { relPath, cards: [] };
16810
16720
  const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
16811
16721
  cards.sort((a, b) => b.id - a.id);
16812
16722
  return { relPath, cards };
@@ -16821,31 +16731,24 @@ var init_archive = __esm({
16821
16731
  });
16822
16732
 
16823
16733
  // ../cli/src/lib/agent/studio-shared.ts
16824
- import fs51 from "node:fs";
16825
- import path53 from "node:path";
16734
+ import fs50 from "node:fs";
16735
+ import path52 from "node:path";
16826
16736
  function studioFiles(studio) {
16827
16737
  const flow = cloudFlows().find((f) => f.def.id === studio || f.cloudId === studio);
16828
16738
  if (flow) return flow.files;
16829
- if (studio && draftId() === studio) {
16830
- try {
16831
- return readStudioFolder(path53.join(STUDIOS, studio));
16832
- } catch {
16833
- return null;
16834
- }
16835
- }
16836
16739
  return null;
16837
16740
  }
16838
16741
  function readStudioMemory(studio) {
16839
16742
  const dir = studioMemoryDir(studio);
16840
16743
  let names3 = [];
16841
16744
  try {
16842
- names3 = fs51.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => e.name).sort();
16745
+ names3 = fs50.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => e.name).sort();
16843
16746
  } catch {
16844
16747
  return [];
16845
16748
  }
16846
16749
  return names3.flatMap((name) => {
16847
16750
  try {
16848
- return [{ name, text: fs51.readFileSync(path53.join(dir, name), "utf8").trim() }];
16751
+ return [{ name, text: fs50.readFileSync(path52.join(dir, name), "utf8").trim() }];
16849
16752
  } catch {
16850
16753
  return [];
16851
16754
  }
@@ -16885,17 +16788,15 @@ var init_studio_shared = __esm({
16885
16788
  init_studio_files();
16886
16789
  init_command();
16887
16790
  init_cloud_studios();
16888
- init_studio_file();
16889
- init_studio_folder();
16890
16791
  sharedFiles = (files) => Object.keys(files).filter((f) => f.startsWith(SHARED_DIR) && f !== RULES_FILE).sort();
16891
- studioMemoryDir = (studio) => path53.join(MEMORY, STUDIO_MEMORY_DIR, studio);
16792
+ studioMemoryDir = (studio) => path52.join(MEMORY, STUDIO_MEMORY_DIR, studio);
16892
16793
  fileLine = (studio, file) => `- \`${file}\` \u2014 \`${rawMove(`file ${studio} ${file}`)}\``;
16893
16794
  studioHoldsAgent = (studio, agent) => !!studio && Object.keys(studioFiles(studio) ?? {}).some((f) => f.startsWith(`agents/${agent}/`));
16894
16795
  }
16895
16796
  });
16896
16797
 
16897
16798
  // ../cli/src/lib/agent/prompts.ts
16898
- import path54 from "node:path";
16799
+ import path53 from "node:path";
16899
16800
  function stopReason(deliveryId) {
16900
16801
  const delivery = findDelivery(deliveryId);
16901
16802
  if (!delivery) return void 0;
@@ -16956,7 +16857,7 @@ ${text4}` : "";
16956
16857
  }
16957
16858
  function cardFileOf(id) {
16958
16859
  const found2 = id === void 0 ? null : locate(id);
16959
- return found2 ? found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target : "";
16860
+ return found2 ? found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target : "";
16960
16861
  }
16961
16862
  function realPaths(text4, req) {
16962
16863
  if (req.action !== "scheduled" && req.action !== "sub") return text4;
@@ -17054,7 +16955,7 @@ function frozenRules(req) {
17054
16955
  function archivedCardFile(id) {
17055
16956
  const found2 = locateArchived(id);
17056
16957
  if (!found2) return `${rel(ARCHIVE)}/`;
17057
- return rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target);
16958
+ return rel(found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target);
17058
16959
  }
17059
16960
  function shippedLines(cardId2) {
17060
16961
  const delivery = endedDelivery(`${cardId2}`);
@@ -17197,7 +17098,7 @@ function actionPrompt(req, command, notes) {
17197
17098
  case "spec": {
17198
17099
  const agent = findSpecAgent(req.specAgent ?? "");
17199
17100
  const found2 = req.id === void 0 ? null : locate(req.id);
17200
- const cardFile3 = found2 ? rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
17101
+ const cardFile3 = found2 ? rel(found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
17201
17102
  const own = agent ? specAgentInstructions(agent) : null;
17202
17103
  if (own) notes.push(...own.notes);
17203
17104
  const memory = agent ? agentMemoryBlock(agent) : "";
@@ -17373,16 +17274,16 @@ var init_prompts = __esm({
17373
17274
 
17374
17275
  // ../cli/src/lib/agent/stop.ts
17375
17276
  import { spawnSync as spawnSync4 } from "node:child_process";
17376
- import fs52 from "node:fs";
17277
+ import fs51 from "node:fs";
17377
17278
  function markedInProc(entry, strict = false, since) {
17378
17279
  const pids = [];
17379
- for (const name of fs52.readdirSync("/proc")) {
17280
+ for (const name of fs51.readdirSync("/proc")) {
17380
17281
  if (!/^\d+$/.test(name)) continue;
17381
17282
  try {
17382
- if (fs52.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
17283
+ if (fs51.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
17383
17284
  } catch (error) {
17384
17285
  if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
17385
- const stat = fs52.statSync(`/proc/${name}`, { throwIfNoEntry: false });
17286
+ const stat = fs51.statSync(`/proc/${name}`, { throwIfNoEntry: false });
17386
17287
  if (stat?.uid === process.getuid?.() && !startedBefore(Number(name), since)) throw error;
17387
17288
  }
17388
17289
  }
@@ -17547,10 +17448,10 @@ var init_stop = __esm({
17547
17448
  });
17548
17449
 
17549
17450
  // ../cli/src/lib/agent/creation-lock.ts
17550
- import path55 from "node:path";
17451
+ import path54 from "node:path";
17551
17452
  function withCreationLock(fn) {
17552
17453
  if (depth2) return fn();
17553
- return withLock(path55.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
17454
+ return withLock(path54.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
17554
17455
  depth2++;
17555
17456
  try {
17556
17457
  return fn();
@@ -17571,8 +17472,8 @@ var init_creation_lock = __esm({
17571
17472
 
17572
17473
  // ../cli/src/lib/agent/sessions.ts
17573
17474
  import { randomUUID as randomUUID4 } from "node:crypto";
17574
- import fs53 from "node:fs";
17575
- import path56 from "node:path";
17475
+ import fs52 from "node:fs";
17476
+ import path55 from "node:path";
17576
17477
  function reap(runs, reaped = [], restore = []) {
17577
17478
  let changed = false;
17578
17479
  const now = Date.now();
@@ -17592,7 +17493,7 @@ function reap(runs, reaped = [], restore = []) {
17592
17493
  }
17593
17494
  function stampDuration(run3, endedAt) {
17594
17495
  try {
17595
- fs53.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
17496
+ fs52.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
17596
17497
  } catch {
17597
17498
  }
17598
17499
  }
@@ -17606,7 +17507,7 @@ function cardNow(cardId2) {
17606
17507
  try {
17607
17508
  const file = cardFile(cardId2);
17608
17509
  if (!file) return null;
17609
- const { meta } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
17510
+ const { meta } = parseFrontmatter(fs52.readFileSync(file, "utf8"));
17610
17511
  if (!meta) return null;
17611
17512
  return { status: meta.status || "todo", questions: meta.questions.length, title: meta.title };
17612
17513
  } catch {
@@ -17739,9 +17640,9 @@ function leftBoardOnLanding(id) {
17739
17640
  function archivedRejected(id) {
17740
17641
  const filed = locateArchived(id);
17741
17642
  if (!filed) return null;
17742
- const file = filed.kind === "group" ? path56.join(filed.target, "root.md") : filed.target;
17643
+ const file = filed.kind === "group" ? path55.join(filed.target, "root.md") : filed.target;
17743
17644
  try {
17744
- return !!parseFrontmatter(fs53.readFileSync(file, "utf8")).meta?.rejected;
17645
+ return !!parseFrontmatter(fs52.readFileSync(file, "utf8")).meta?.rejected;
17745
17646
  } catch {
17746
17647
  return false;
17747
17648
  }
@@ -17991,7 +17892,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID4(), said2) {
17991
17892
  return { run: record, spec };
17992
17893
  }
17993
17894
  function planningSession(cardId2, cwd = REPO_ROOT) {
17994
- const here = (dir) => !dir || path56.resolve(dir) === cwd;
17895
+ const here = (dir) => !dir || path55.resolve(dir) === cwd;
17995
17896
  const planned = readRuns().filter((r) => r.status === "done" && r.cardId === cardId2 && PLANNING.has(r.action)).sort((a, b) => b.startedAt - a.startedAt)[0];
17996
17897
  if (!planned) return { none: "unrecorded" };
17997
17898
  if (!here(planned.cwd)) return { none: "elsewhere" };
@@ -18211,8 +18112,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
18211
18112
  if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
18212
18113
  clearAsks(prev.sessionId);
18213
18114
  try {
18214
- fs53.unlinkSync(prev.logPath);
18215
- fs53.rmSync(eventsPathOf(prev.sessionId), { force: true });
18115
+ fs52.unlinkSync(prev.logPath);
18116
+ fs52.rmSync(eventsPathOf(prev.sessionId), { force: true });
18216
18117
  } catch {
18217
18118
  }
18218
18119
  if (retry2 && prev.pictures?.length) {
@@ -18235,8 +18136,8 @@ function forgetRun(sessionId) {
18235
18136
  if (!gone) return;
18236
18137
  clearAsks(sessionId);
18237
18138
  try {
18238
- fs53.unlinkSync(gone.logPath);
18239
- fs53.rmSync(eventsPathOf(gone.sessionId), { force: true });
18139
+ fs52.unlinkSync(gone.logPath);
18140
+ fs52.rmSync(eventsPathOf(gone.sessionId), { force: true });
18240
18141
  } catch {
18241
18142
  }
18242
18143
  }
@@ -18265,14 +18166,14 @@ function noteSpecRefusals(sessionId, refused) {
18265
18166
  }
18266
18167
  function clearAsks(sessionId) {
18267
18168
  try {
18268
- fs53.unlinkSync(asksPathOf(sessionId));
18169
+ fs52.unlinkSync(asksPathOf(sessionId));
18269
18170
  } catch {
18270
18171
  }
18271
18172
  }
18272
18173
  function readAsks(sessionId) {
18273
18174
  let data;
18274
18175
  try {
18275
- data = JSON.parse(fs53.readFileSync(asksPathOf(sessionId), "utf8"));
18176
+ data = JSON.parse(fs52.readFileSync(asksPathOf(sessionId), "utf8"));
18276
18177
  } catch {
18277
18178
  return { asks: [], refines: [], refused: [] };
18278
18179
  }
@@ -18299,10 +18200,10 @@ function readAsks(sessionId) {
18299
18200
  return { asks: asks.filter((a) => !discarded.has(a.cardId)), refines: refines.filter((a) => !discarded.has(a.cardId)), refused };
18300
18201
  }
18301
18202
  function writeAsks(sessionId, file) {
18302
- fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
18203
+ fs52.mkdirSync(SESSIONS_DIR, { recursive: true });
18303
18204
  const tmp = `${asksPathOf(sessionId)}.tmp`;
18304
- fs53.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
18305
- fs53.renameSync(tmp, asksPathOf(sessionId));
18205
+ fs52.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
18206
+ fs52.renameSync(tmp, asksPathOf(sessionId));
18306
18207
  }
18307
18208
  function markSpawned(sessionId, pid) {
18308
18209
  patch(sessionId, (r) => {
@@ -18433,12 +18334,12 @@ async function resumeDelivery(id) {
18433
18334
  return { ok: true, deliveryId: delivery.deliveryId, carryOn };
18434
18335
  }
18435
18336
  function writeSpec(spec) {
18436
- fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
18437
- fs53.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
18337
+ fs52.mkdirSync(SESSIONS_DIR, { recursive: true });
18338
+ fs52.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
18438
18339
  }
18439
18340
  function readSpec(sessionId) {
18440
18341
  try {
18441
- const spec = JSON.parse(fs53.readFileSync(specPathOf(sessionId), "utf8"));
18342
+ const spec = JSON.parse(fs52.readFileSync(specPathOf(sessionId), "utf8"));
18442
18343
  return spec && Array.isArray(spec.plan?.argv) ? spec : null;
18443
18344
  } catch {
18444
18345
  return null;
@@ -18446,28 +18347,28 @@ function readSpec(sessionId) {
18446
18347
  }
18447
18348
  function dropSpec(sessionId) {
18448
18349
  try {
18449
- fs53.unlinkSync(specPathOf(sessionId));
18350
+ fs52.unlinkSync(specPathOf(sessionId));
18450
18351
  } catch {
18451
18352
  }
18452
18353
  }
18453
18354
  async function acquireIndexLock(giveUp) {
18454
18355
  const until = Date.now() + INDEX_WAIT_MS;
18455
- const holder = path56.join(INDEX_LOCK2, "holder");
18356
+ const holder = path55.join(INDEX_LOCK2, "holder");
18456
18357
  for (; ; ) {
18457
18358
  if (giveUp()) return null;
18458
18359
  try {
18459
- fs53.mkdirSync(INDEX_LOCK2, { recursive: false });
18460
- fs53.writeFileSync(holder, String(process.pid));
18461
- return () => fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
18360
+ fs52.mkdirSync(INDEX_LOCK2, { recursive: false });
18361
+ fs52.writeFileSync(holder, String(process.pid));
18362
+ return () => fs52.rmSync(INDEX_LOCK2, { recursive: true, force: true });
18462
18363
  } catch (err) {
18463
18364
  const code = err.code;
18464
18365
  if (code === "ENOENT") {
18465
- fs53.mkdirSync(path56.dirname(INDEX_LOCK2), { recursive: true });
18366
+ fs52.mkdirSync(path55.dirname(INDEX_LOCK2), { recursive: true });
18466
18367
  continue;
18467
18368
  }
18468
18369
  if (code !== "EEXIST") throw err;
18469
18370
  if (!pidAlive(Number(readHolder(holder)))) {
18470
- fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
18371
+ fs52.rmSync(INDEX_LOCK2, { recursive: true, force: true });
18471
18372
  continue;
18472
18373
  }
18473
18374
  if (Date.now() > until) return null;
@@ -18477,7 +18378,7 @@ async function acquireIndexLock(giveUp) {
18477
18378
  }
18478
18379
  function readHolder(file) {
18479
18380
  try {
18480
- return fs53.readFileSync(file, "utf8").trim();
18381
+ return fs52.readFileSync(file, "utf8").trim();
18481
18382
  } catch {
18482
18383
  return String(process.pid);
18483
18384
  }
@@ -18562,8 +18463,8 @@ var init_sessions = __esm({
18562
18463
  implement: "implementing",
18563
18464
  hook: "implementing"
18564
18465
  };
18565
- specPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.plan.json`);
18566
- asksPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.asks.json`);
18466
+ specPathOf = (sessionId) => path55.join(SESSIONS_DIR, `${sessionId}.plan.json`);
18467
+ asksPathOf = (sessionId) => path55.join(SESSIONS_DIR, `${sessionId}.asks.json`);
18567
18468
  carriesSession = (r) => !!(r.resumedFrom || r.continues && !r.continues.fork);
18568
18469
  canPickUp = (r) => r.status === "error" || r.status === "interrupted" || r.status === "stopped";
18569
18470
  neverStarted = (r) => r.unspawned === true || !!r.errorWhy?.some((why2) => why2.kind === "notInstalled");
@@ -18616,8 +18517,8 @@ var init_sources = __esm({
18616
18517
  });
18617
18518
 
18618
18519
  // ../cli/src/lib/signals/inbox.ts
18619
- import fs54 from "node:fs";
18620
- import path57 from "node:path";
18520
+ import fs53 from "node:fs";
18521
+ import path56 from "node:path";
18621
18522
  function metaPair(key, value) {
18622
18523
  const name = typeof key === "string" ? key.trim() : "";
18623
18524
  if (!name) return null;
@@ -18648,7 +18549,7 @@ ${signal2.summary.trim()}
18648
18549
  function parse(file, lenient = false) {
18649
18550
  let text4;
18650
18551
  try {
18651
- text4 = fs54.readFileSync(file, "utf8");
18552
+ text4 = fs53.readFileSync(file, "utf8");
18652
18553
  } catch {
18653
18554
  return null;
18654
18555
  }
@@ -18702,28 +18603,28 @@ function parse(file, lenient = false) {
18702
18603
  };
18703
18604
  }
18704
18605
  function freeName(dir, wanted) {
18705
- const ext = path57.extname(wanted);
18606
+ const ext = path56.extname(wanted);
18706
18607
  const stem = wanted.slice(0, wanted.length - ext.length);
18707
18608
  let name = wanted;
18708
- for (let n = 2; fs54.existsSync(path57.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
18609
+ for (let n = 2; fs53.existsSync(path56.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
18709
18610
  return name;
18710
18611
  }
18711
- function readFolder2(dir, lenient = false) {
18612
+ function readFolder(dir, lenient = false) {
18712
18613
  let entries;
18713
18614
  try {
18714
- entries = fs54.readdirSync(dir, { withFileTypes: true });
18615
+ entries = fs53.readdirSync(dir, { withFileTypes: true });
18715
18616
  } catch {
18716
18617
  return [];
18717
18618
  }
18718
- return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path57.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
18619
+ return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path56.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
18719
18620
  }
18720
18621
  function readInbox() {
18721
- const signals = readFolder2(TRIAGE);
18622
+ const signals = readFolder(TRIAGE);
18722
18623
  signals.sort((a, b) => b.collectedAt.localeCompare(a.collectedAt) || a.sourceId.localeCompare(b.sourceId));
18723
18624
  return signals;
18724
18625
  }
18725
18626
  function writeSignal(incoming, importedAt, slug2 = "") {
18726
- fs54.mkdirSync(TRIAGE, { recursive: true });
18627
+ fs53.mkdirSync(TRIAGE, { recursive: true });
18727
18628
  const signal2 = {
18728
18629
  ...incoming,
18729
18630
  importedAt,
@@ -18735,12 +18636,12 @@ function writeSignal(incoming, importedAt, slug2 = "") {
18735
18636
  contentKept: true,
18736
18637
  relPath: ""
18737
18638
  };
18738
- const file = path57.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
18739
- fs54.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
18639
+ const file = path56.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
18640
+ fs53.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
18740
18641
  return { ...signal2, relPath: boardRel(file) };
18741
18642
  }
18742
18643
  function stamp3(file, fields) {
18743
- const text4 = fs54.readFileSync(file, "utf8");
18644
+ const text4 = fs53.readFileSync(file, "utf8");
18744
18645
  const lines = text4.split("\n");
18745
18646
  const close = lines.indexOf("---", 1);
18746
18647
  if (close < 0) return;
@@ -18749,13 +18650,13 @@ function stamp3(file, fields) {
18749
18650
  return !key || fields[key[1]] === void 0;
18750
18651
  });
18751
18652
  const added = Object.entries(fields).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
18752
- fs54.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
18653
+ fs53.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
18753
18654
  }
18754
18655
  function moveSignal(from, into, fields) {
18755
- if (!fs54.existsSync(from)) return "";
18756
- fs54.mkdirSync(into, { recursive: true });
18757
- const at = path57.join(into, freeName(into, path57.basename(from)));
18758
- fs54.renameSync(from, at);
18656
+ if (!fs53.existsSync(from)) return "";
18657
+ fs53.mkdirSync(into, { recursive: true });
18658
+ const at = path56.join(into, freeName(into, path56.basename(from)));
18659
+ fs53.renameSync(from, at);
18759
18660
  stamp3(at, fields);
18760
18661
  return boardRel(at);
18761
18662
  }
@@ -18764,10 +18665,10 @@ function archiveInboxItem(sourceId, cardId2) {
18764
18665
  if (!found2) {
18765
18666
  const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
18766
18667
  if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
18767
- stamp3(path57.join(SIGNALS_DISMISSED, path57.basename(ignored.relPath)), { card_id: String(cardId2) });
18668
+ stamp3(path56.join(SIGNALS_DISMISSED, path56.basename(ignored.relPath)), { card_id: String(cardId2) });
18768
18669
  return { ok: true, relPath: ignored.relPath, where: "dismissed" };
18769
18670
  }
18770
- const at = moveSignal(path57.join(TRIAGE, path57.basename(found2.relPath)), SIGNALS_ARCHIVED, {
18671
+ const at = moveSignal(path56.join(TRIAGE, path56.basename(found2.relPath)), SIGNALS_ARCHIVED, {
18771
18672
  card_id: String(cardId2),
18772
18673
  archived_at: formatStamp(/* @__PURE__ */ new Date())
18773
18674
  });
@@ -18781,13 +18682,13 @@ var init_inbox = __esm({
18781
18682
  init_sources();
18782
18683
  init_paths();
18783
18684
  init_yaml();
18784
- boardRel = (file) => rel(file).split(path57.sep).join("/");
18685
+ boardRel = (file) => rel(file).split(path56.sep).join("/");
18785
18686
  FIELDS = ["source_id", "title", "collected_at", "imported_at"];
18786
18687
  META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
18787
18688
  slugOf = (said2) => said2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
18788
18689
  fileName = (title, slug2 = "") => `${slugOf(slug2) || slugOf(title) || "item"}.md`;
18789
- readArchived = () => readFolder2(SIGNALS_ARCHIVED);
18790
- readAllDismissed = () => readFolder2(SIGNALS_DISMISSED, true);
18690
+ readArchived = () => readFolder(SIGNALS_ARCHIVED);
18691
+ readAllDismissed = () => readFolder(SIGNALS_DISMISSED, true);
18791
18692
  }
18792
18693
  });
18793
18694
 
@@ -18890,12 +18791,12 @@ var init_studio_cards = __esm({
18890
18791
  });
18891
18792
 
18892
18793
  // ../cli/src/lib/readme.ts
18893
- import fs55 from "node:fs";
18894
- import path58 from "node:path";
18794
+ import fs54 from "node:fs";
18795
+ import path57 from "node:path";
18895
18796
  function stripReadmeRefs(target) {
18896
- if (!fs55.existsSync(README)) return [];
18797
+ if (!fs54.existsSync(README)) return [];
18897
18798
  const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
18898
- const lines = fs55.readFileSync(README, "utf8").split("\n");
18799
+ const lines = fs54.readFileSync(README, "utf8").split("\n");
18899
18800
  const out = [];
18900
18801
  const removed = [];
18901
18802
  let i = 0;
@@ -18917,20 +18818,20 @@ function stripReadmeRefs(target) {
18917
18818
  out.push(line);
18918
18819
  i++;
18919
18820
  }
18920
- if (removed.length) fs55.writeFileSync(README, out.join("\n"));
18821
+ if (removed.length) fs54.writeFileSync(README, out.join("\n"));
18921
18822
  return removed;
18922
18823
  }
18923
18824
  function addReadmeRef(id, title, relPath) {
18924
- if (!fs55.existsSync(README)) return false;
18925
- const link2 = relPath.split(path58.sep).join("/");
18825
+ if (!fs54.existsSync(README)) return false;
18826
+ const link2 = relPath.split(path57.sep).join("/");
18926
18827
  const bullet = `- [#${id} ${title}](${link2})`;
18927
18828
  const heading = `## ${TASKS_HEADING}`;
18928
- let lines = fs55.readFileSync(README, "utf8").split("\n");
18829
+ let lines = fs54.readFileSync(README, "utf8").split("\n");
18929
18830
  const hi = lines.findIndex((l) => l.trim().toLowerCase() === heading.toLowerCase());
18930
18831
  if (hi === -1) {
18931
18832
  while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
18932
18833
  lines.push("", heading, "", bullet);
18933
- fs55.writeFileSync(README, lines.join("\n") + "\n");
18834
+ fs54.writeFileSync(README, lines.join("\n") + "\n");
18934
18835
  return true;
18935
18836
  }
18936
18837
  let end2 = hi + 1;
@@ -18944,15 +18845,15 @@ function addReadmeRef(id, title, relPath) {
18944
18845
  const at = lastBullet !== -1 ? lastBullet + 1 : lines[hi + 1] === "" ? hi + 2 : hi + 1;
18945
18846
  lines.splice(at, 0, bullet);
18946
18847
  }
18947
- fs55.writeFileSync(README, lines.join("\n"));
18848
+ fs54.writeFileSync(README, lines.join("\n"));
18948
18849
  return true;
18949
18850
  }
18950
18851
  function repointReadmeLink(id, oldRel, newRel, title) {
18951
- if (!fs55.existsSync(README)) return false;
18952
- const oldLink = oldRel.split(path58.sep).join("/");
18953
- const newLink = newRel.split(path58.sep).join("/");
18852
+ if (!fs54.existsSync(README)) return false;
18853
+ const oldLink = oldRel.split(path57.sep).join("/");
18854
+ const newLink = newRel.split(path57.sep).join("/");
18954
18855
  const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
18955
- const lines = fs55.readFileSync(README, "utf8").split("\n");
18856
+ const lines = fs54.readFileSync(README, "utf8").split("\n");
18956
18857
  let changed = false;
18957
18858
  for (let i = 0; i < lines.length; i++) {
18958
18859
  if (!lines[i].includes(`](${oldLink})`)) continue;
@@ -18962,7 +18863,7 @@ function repointReadmeLink(id, oldRel, newRel, title) {
18962
18863
  changed = true;
18963
18864
  }
18964
18865
  }
18965
- if (changed) fs55.writeFileSync(README, lines.join("\n"));
18866
+ if (changed) fs54.writeFileSync(README, lines.join("\n"));
18966
18867
  return changed;
18967
18868
  }
18968
18869
  var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex;
@@ -19449,14 +19350,14 @@ function collect(body, card, host2) {
19449
19350
  const active2 = /* @__PURE__ */ new Set();
19450
19351
  const out = [];
19451
19352
  const visit = (src, types, owner) => {
19452
- const path86 = src.replace(/[?#].*$/, "");
19353
+ const path85 = src.replace(/[?#].*$/, "");
19453
19354
  let resolved2;
19454
19355
  try {
19455
- resolved2 = host2.resolve(path86, owner);
19356
+ resolved2 = host2.resolve(path85, owner);
19456
19357
  } catch (error) {
19457
19358
  if (owner !== card) return { key: null, error: why(error) };
19458
19359
  if (!nodes.has(src)) {
19459
- const node2 = { key: src, file: null, kind: kindAt(path86, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
19360
+ const node2 = { key: src, file: null, kind: kindAt(path85, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
19460
19361
  nodes.set(src, node2);
19461
19362
  out.push(node2);
19462
19363
  }
@@ -19511,10 +19412,10 @@ function collect(body, card, host2) {
19511
19412
  };
19512
19413
  for (const ref of bodyReferences(body)) visit(ref.src, ref.types, card);
19513
19414
  const sorted = [];
19514
- const done2 = /* @__PURE__ */ new Set();
19415
+ const done = /* @__PURE__ */ new Set();
19515
19416
  const order = (node) => {
19516
- if (done2.has(node.key)) return;
19517
- done2.add(node.key);
19417
+ if (done.has(node.key)) return;
19418
+ done.add(node.key);
19518
19419
  for (const key of node.dependencies.values()) {
19519
19420
  const child = nodes.get(key);
19520
19421
  if (child) order(child);
@@ -19541,16 +19442,16 @@ var init_collect = __esm({
19541
19442
  });
19542
19443
 
19543
19444
  // ../cli/src/lib/dress-page.ts
19544
- import fs56 from "node:fs";
19545
- import path59 from "node:path";
19445
+ import fs55 from "node:fs";
19446
+ import path58 from "node:path";
19546
19447
  function dressPage(file) {
19547
- const folder = path59.dirname(file);
19548
- const html = fs56.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
19448
+ const folder = path58.dirname(file);
19449
+ const html = fs55.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
19549
19450
  const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
19550
19451
  if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
19551
- const at2 = path59.resolve(folder, href);
19552
- if (!at2.startsWith(folder + path59.sep) || !fs56.existsSync(at2)) return tag;
19553
- const css = fs56.readFileSync(at2, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${path59.relative(folder, path59.resolve(path59.dirname(at2), src)).split(path59.sep).join("/")}${quote})`);
19452
+ const at2 = path58.resolve(folder, href);
19453
+ if (!at2.startsWith(folder + path58.sep) || !fs55.existsSync(at2)) return tag;
19454
+ const css = fs55.readFileSync(at2, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${path58.relative(folder, path58.resolve(path58.dirname(at2), src)).split(path58.sep).join("/")}${quote})`);
19554
19455
  return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
19555
19456
  });
19556
19457
  const at = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
@@ -19562,25 +19463,25 @@ var init_dress_page = __esm({
19562
19463
  "use strict";
19563
19464
  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'";
19564
19465
  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>`;
19565
- referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs56.readFileSync(file, "utf8");
19466
+ referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs55.readFileSync(file, "utf8");
19566
19467
  }
19567
19468
  });
19568
19469
 
19569
19470
  // ../cli/src/lib/preview-files.ts
19570
- import fs57 from "node:fs";
19571
- import path60 from "node:path";
19471
+ import fs56 from "node:fs";
19472
+ import path59 from "node:path";
19572
19473
  function resolver(card, id) {
19573
- const roots = [KANBAN, path60.join(ASSETS, String(id)), path60.join(MOCKUPS, String(id))];
19574
- const real2 = (p) => fs57.existsSync(p) ? fs57.realpathSync(p) : p;
19575
- const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) + path60.sep));
19474
+ const roots = [KANBAN, path59.join(ASSETS, String(id)), path59.join(MOCKUPS, String(id))];
19475
+ const real2 = (p) => fs56.existsSync(p) ? fs56.realpathSync(p) : p;
19476
+ const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) + path59.sep));
19576
19477
  return (src, owner) => {
19577
19478
  if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
19578
- if (path60.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
19479
+ if (path59.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
19579
19480
  const held4 = /^\.(assets|mockups)\//.exec(src);
19580
- const file = held4 ? path60.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path60.resolve(path60.dirname(owner), src);
19581
- if (!inside2(path60.resolve(file)) || fs57.existsSync(file) && !inside2(fs57.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
19582
- if (!fs57.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
19583
- return { key: fs57.realpathSync(file), file };
19481
+ const file = held4 ? path59.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path59.resolve(path59.dirname(owner), src);
19482
+ if (!inside2(path59.resolve(file)) || fs56.existsSync(file) && !inside2(fs56.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
19483
+ if (!fs56.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
19484
+ return { key: fs56.realpathSync(file), file };
19584
19485
  };
19585
19486
  }
19586
19487
  function validatePreviewFiles(card, id, text4) {
@@ -19623,8 +19524,8 @@ var init_preview_files = __esm({
19623
19524
  });
19624
19525
 
19625
19526
  // ../cli/src/lib/spec-contract.ts
19626
- import fs58 from "node:fs";
19627
- import path61 from "node:path";
19527
+ import fs57 from "node:fs";
19528
+ import path60 from "node:path";
19628
19529
  function scanCardLines(lines, start = 0) {
19629
19530
  const visible = lines.map(() => "");
19630
19531
  let fence = null;
@@ -19657,18 +19558,18 @@ function scanCardLines(lines, start = 0) {
19657
19558
  }
19658
19559
  function snapshotSpecs() {
19659
19560
  const out = /* @__PURE__ */ new Map();
19660
- if (!fs58.existsSync(TODO)) return out;
19561
+ if (!fs57.existsSync(TODO)) return out;
19661
19562
  for (const file of walkMd(TODO)) {
19662
- if (isLegacyRecurring(path61.relative(TODO, file))) continue;
19663
- const id = idPrefix(path61.basename(file) === "root.md" ? path61.basename(path61.dirname(file)) : path61.basename(file));
19664
- if (id !== null) out.set(file, { id, text: fs58.readFileSync(file, "utf8") });
19563
+ if (isLegacyRecurring(path60.relative(TODO, file))) continue;
19564
+ const id = idPrefix(path60.basename(file) === "root.md" ? path60.basename(path60.dirname(file)) : path60.basename(file));
19565
+ if (id !== null) out.set(file, { id, text: fs57.readFileSync(file, "utf8") });
19665
19566
  }
19666
19567
  return out;
19667
19568
  }
19668
19569
  function enclosingGroups(file) {
19669
19570
  const ids = [];
19670
19571
  for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
19671
- const id = idPrefix(path61.basename(path61.dirname(root2)));
19572
+ const id = idPrefix(path60.basename(path60.dirname(root2)));
19672
19573
  if (id !== null) ids.push(id);
19673
19574
  }
19674
19575
  return ids;
@@ -19753,8 +19654,8 @@ function validateSpec(file, text4, id) {
19753
19654
  markers.push(i + 1);
19754
19655
  continue;
19755
19656
  }
19756
- const done2 = line.match(/^ {0,3}(#{2,3})\s+Done when\s*#*\s*$/);
19757
- if (done2) acceptance.push({ line: i + 1, level: done2[1].length });
19657
+ const done = line.match(/^ {0,3}(#{2,3})\s+Done when\s*#*\s*$/);
19658
+ if (done) acceptance.push({ line: i + 1, level: done[1].length });
19758
19659
  const heading = line.match(/^ {0,3}(#{1,2})\s+(.+?)\s*#*\s*$/);
19759
19660
  if (heading?.[1] === "#") add(i + 1, "heading", "Do not repeat the card title as an H1. Remove this heading or use ### inside your section.");
19760
19661
  if (heading?.[1] === "##") headings.push({ title: heading[2], line: i + 1 });
@@ -19818,10 +19719,10 @@ function validateSpec(file, text4, id) {
19818
19719
  lastOrder = Math.max(lastOrder, rank2);
19819
19720
  }
19820
19721
  }
19821
- for (const [index, done2] of acceptance.entries()) {
19822
- if (index) add(done2.line, "duplicate-section", "Duplicate Done when. Keep one ### Done when under ## Scope.");
19823
- const parent = headings.filter((h) => h.line < done2.line).at(-1);
19824
- if (done2.level !== 3 || parent?.title !== "Scope") add(done2.line, "acceptance-section", "Move the acceptance list to ### Done when under ## Scope.");
19722
+ for (const [index, done] of acceptance.entries()) {
19723
+ if (index) add(done.line, "duplicate-section", "Duplicate Done when. Keep one ### Done when under ## Scope.");
19724
+ const parent = headings.filter((h) => h.line < done.line).at(-1);
19725
+ if (done.level !== 3 || parent?.title !== "Scope") add(done.line, "acceptance-section", "Move the acceptance list to ### Done when under ## Scope.");
19825
19726
  }
19826
19727
  for (const title of required) if (!seen.has(title)) add(end2 + 2, "missing-section", `Missing ## ${title}. Restore that section; keep its title in English.`);
19827
19728
  if (markers.length !== 1) add(markers[1] ?? end2 + 2, "boundary", `Found ${markers.length} <!-- agent --> boundaries; expected exactly one, between the human and agent sections.`);
@@ -19843,9 +19744,9 @@ function setEnd(lines, at) {
19843
19744
  }
19844
19745
  function inside(dir, name) {
19845
19746
  try {
19846
- const root2 = fs58.realpathSync(dir);
19847
- const real2 = fs58.realpathSync(path61.join(dir, name));
19848
- return real2.startsWith(root2 + path61.sep) && fs58.statSync(real2).isFile() ? real2 : null;
19747
+ const root2 = fs57.realpathSync(dir);
19748
+ const real2 = fs57.realpathSync(path60.join(dir, name));
19749
+ return real2.startsWith(root2 + path60.sep) && fs57.statSync(real2).isFile() ? real2 : null;
19849
19750
  } catch {
19850
19751
  return null;
19851
19752
  }
@@ -19863,7 +19764,7 @@ function variantsProblem(raw, src, id) {
19863
19764
  if (files.length < 2 || !files.every((f) => typeof f === "string" && f)) return `variants needs at least two labels, each naming a file. ${shape}`;
19864
19765
  if (!files.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
19865
19766
  if (id === void 0) return null;
19866
- const dir = path61.join(ASSETS, String(id));
19767
+ const dir = path60.join(ASSETS, String(id));
19867
19768
  for (const f of files) {
19868
19769
  const parts = f.split("/");
19869
19770
  if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
@@ -19873,12 +19774,12 @@ function variantsProblem(raw, src, id) {
19873
19774
  return null;
19874
19775
  }
19875
19776
  function compareProblem(attrs, id) {
19876
- const dir = path61.join(ASSETS, String(id));
19777
+ const dir = path60.join(ASSETS, String(id));
19877
19778
  const src = (message) => ({ rule: "compare-src", message });
19878
19779
  const shots = (message) => ({ rule: "compare-shots", message });
19879
19780
  const json = (file) => {
19880
19781
  try {
19881
- return file.endsWith(".json") ? JSON.parse(fs58.readFileSync(file, "utf8")) : null;
19782
+ return file.endsWith(".json") ? JSON.parse(fs57.readFileSync(file, "utf8")) : null;
19882
19783
  } catch {
19883
19784
  return null;
19884
19785
  }
@@ -19903,7 +19804,7 @@ function compareProblem(attrs, id) {
19903
19804
  const file = inside(dir, named2.name);
19904
19805
  if (!file) return { message: `Compare shots ${at} names no file in this card's asset folder. Write the JSON there or fix the path.` };
19905
19806
  try {
19906
- return { data: JSON.parse(fs58.readFileSync(file, "utf8")) };
19807
+ return { data: JSON.parse(fs57.readFileSync(file, "utf8")) };
19907
19808
  } catch {
19908
19809
  return { message: `${at} is not valid JSON.` };
19909
19810
  }
@@ -19921,7 +19822,7 @@ function compareProblem(attrs, id) {
19921
19822
  }
19922
19823
  function validateStoryboards(file, id, text4) {
19923
19824
  const errors = [];
19924
- const dir = path61.join(ASSETS, String(id));
19825
+ const dir = path60.join(ASSETS, String(id));
19925
19826
  for (const [tag, tagOf, rule, fix] of [
19926
19827
  ["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
19927
19828
  ["Studio", studioTag, "studio-src", "Write it with `akb raw studio diagram <studio id> <card id>` or fix the path."]
@@ -19957,14 +19858,14 @@ var init_spec_contract = __esm({
19957
19858
  });
19958
19859
 
19959
19860
  // ../cli/src/lib/reconcile.ts
19960
- import fs59 from "node:fs";
19961
- import path62 from "node:path";
19861
+ import fs58 from "node:fs";
19862
+ import path61 from "node:path";
19962
19863
  function liveIds() {
19963
19864
  const ids = /* @__PURE__ */ new Set();
19964
19865
  for (const file of walkMd(TODO)) {
19965
- const base = path62.basename(file);
19866
+ const base = path61.basename(file);
19966
19867
  if (base === "README.md") continue;
19967
- const id = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
19868
+ const id = base === "root.md" ? idPrefix(path61.basename(path61.dirname(file))) : idPrefix(base);
19968
19869
  if (id != null) ids.add(id);
19969
19870
  }
19970
19871
  return ids;
@@ -19972,16 +19873,16 @@ function liveIds() {
19972
19873
  function indexableCards() {
19973
19874
  const out = [];
19974
19875
  for (const dir of walkDirs(TODO)) {
19975
- const id = idPrefix(path62.basename(dir));
19976
- if (id != null && fs59.existsSync(path62.join(dir, "root.md"))) {
19977
- out.push({ id, rel: path62.join(path62.relative(TODO, dir), "root.md").split(path62.sep).join("/") });
19876
+ const id = idPrefix(path61.basename(dir));
19877
+ if (id != null && fs58.existsSync(path61.join(dir, "root.md"))) {
19878
+ out.push({ id, rel: path61.join(path61.relative(TODO, dir), "root.md").split(path61.sep).join("/") });
19978
19879
  }
19979
19880
  }
19980
19881
  for (const file of walkMd(TODO)) {
19981
- const base = path62.basename(file);
19882
+ const base = path61.basename(file);
19982
19883
  if (base === "README.md" || base === "root.md") continue;
19983
- const relTODO = path62.relative(TODO, file);
19984
- const segs = relTODO.split(path62.sep);
19884
+ const relTODO = path61.relative(TODO, file);
19885
+ const segs = relTODO.split(path61.sep);
19985
19886
  if (segs.length !== 1) continue;
19986
19887
  const id = idPrefix(base);
19987
19888
  if (id != null) out.push({ id, rel: segs.join("/") });
@@ -19990,7 +19891,7 @@ function indexableCards() {
19990
19891
  }
19991
19892
  function readmeComplaints(fix) {
19992
19893
  const said2 = [];
19993
- const lines = fs59.readFileSync(README, "utf8").split("\n");
19894
+ const lines = fs58.readFileSync(README, "utf8").split("\n");
19994
19895
  const indexed = /* @__PURE__ */ new Set();
19995
19896
  let fixed = 0;
19996
19897
  for (let i = 0; i < lines.length; i++) {
@@ -19999,13 +19900,13 @@ function readmeComplaints(fix) {
19999
19900
  const id = Number(m[1]);
20000
19901
  const linkPath = m[2];
20001
19902
  indexed.add(id);
20002
- if (fs59.existsSync(path62.join(TODO, linkPath))) continue;
19903
+ if (fs58.existsSync(path61.join(TODO, linkPath))) continue;
20003
19904
  const found2 = locate(id);
20004
19905
  if (!found2) {
20005
19906
  said2.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
20006
19907
  continue;
20007
19908
  }
20008
- const want = (found2.kind === "group" ? path62.join(found2.rel, "root.md") : found2.rel).split(path62.sep).join("/");
19909
+ const want = (found2.kind === "group" ? path61.join(found2.rel, "root.md") : found2.rel).split(path61.sep).join("/");
20009
19910
  if (want === linkPath) continue;
20010
19911
  if (!fix) {
20011
19912
  said2.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
@@ -20015,7 +19916,7 @@ function readmeComplaints(fix) {
20015
19916
  said2.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
20016
19917
  fixed++;
20017
19918
  }
20018
- if (fixed) fs59.writeFileSync(README, lines.join("\n"));
19919
+ if (fixed) fs58.writeFileSync(README, lines.join("\n"));
20019
19920
  for (const c of indexableCards()) {
20020
19921
  if (!indexed.has(c.id)) {
20021
19922
  said2.push(`card ${c.rel} (#${c.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
@@ -20027,11 +19928,11 @@ function crossRefComplaints() {
20027
19928
  const said2 = [];
20028
19929
  const live = liveIds();
20029
19930
  for (const file of walkMd(TODO)) {
20030
- const base = path62.basename(file);
19931
+ const base = path61.basename(file);
20031
19932
  if (base === "README.md") continue;
20032
- const ownerId = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
19933
+ const ownerId = base === "root.md" ? idPrefix(path61.basename(path61.dirname(file))) : idPrefix(base);
20033
19934
  if (ownerId == null) continue;
20034
- const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19935
+ const { meta } = parseFrontmatter(fs58.readFileSync(file, "utf8"));
20035
19936
  if (!meta) continue;
20036
19937
  for (const field2 of ["blocked_by", "related"]) {
20037
19938
  for (const ref of meta[field2] || []) {
@@ -20044,11 +19945,11 @@ function crossRefComplaints() {
20044
19945
  return said2;
20045
19946
  }
20046
19947
  function reconcileBoard() {
20047
- if (!fs59.existsSync(README)) return;
19948
+ if (!fs58.existsSync(README)) return;
20048
19949
  for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
20049
19950
  }
20050
19951
  function boardComplaints() {
20051
- if (!fs59.existsSync(README)) return [];
19952
+ if (!fs58.existsSync(README)) return [];
20052
19953
  try {
20053
19954
  return [...readmeComplaints(false), ...crossRefComplaints()];
20054
19955
  } catch {
@@ -20068,8 +19969,8 @@ var init_reconcile = __esm({
20068
19969
  });
20069
19970
 
20070
19971
  // ../cli/src/commands/card.ts
20071
- import fs60 from "node:fs";
20072
- import path63 from "node:path";
19972
+ import fs59 from "node:fs";
19973
+ import path62 from "node:path";
20073
19974
  function defaultBody(summary = "<\u7528\u4E00\u5C0F\u6BB5\u8BDD\u5148\u8BB2\u53D1\u751F\u4E86\u4EC0\u4E48\u3001\u7528\u6237\u9047\u5230\u4EC0\u4E48\uFF0C\u518D\u8BB2\u8FD9\u5F20\u5361\u8981\u8FBE\u5230\u7684\u7ED3\u679C\u3002>") {
20074
19975
  return [
20075
19976
  summary,
@@ -20095,7 +19996,7 @@ function bodyFromFile(opts) {
20095
19996
  if (opts.body === false) die("pass --body-file or --no-body, not both");
20096
19997
  let text4;
20097
19998
  try {
20098
- text4 = fs60.readFileSync(opts.bodyFile, "utf8");
19999
+ text4 = fs59.readFileSync(opts.bodyFile, "utf8");
20099
20000
  } catch {
20100
20001
  die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
20101
20002
  }
@@ -20119,11 +20020,11 @@ function normalizeBody(text4) {
20119
20020
  const boundary = (line) => /^\s*<!--\s*agent\s*-->\s*$/.test(line);
20120
20021
  const sectionEnd = (line) => /^ {0,3}#{1,2}\s/.test(line) || boundary(line);
20121
20022
  const formal = sections2.some((h) => h.level <= 2 && h.title !== "Done when") || visible.some(boundary);
20122
- const done2 = acceptance.find((h) => h.level === 2);
20023
+ const done = acceptance.find((h) => h.level === 2);
20123
20024
  let checklist = [];
20124
- if (done2) {
20125
- const end2 = visible.findIndex((line, i) => i > done2.index && sectionEnd(line));
20126
- checklist = trim(rows.splice(done2.index, (end2 < 0 ? rows.length : end2) - done2.index));
20025
+ if (done) {
20026
+ const end2 = visible.findIndex((line, i) => i > done.index && sectionEnd(line));
20027
+ checklist = trim(rows.splice(done.index, (end2 < 0 ? rows.length : end2) - done.index));
20127
20028
  checklist[0] = "### Done when";
20128
20029
  }
20129
20030
  if (!formal) rows = [...trim(rows), ...defaultBody("").split("\n").slice(1)];
@@ -20160,20 +20061,20 @@ function cmdCreate(opts) {
20160
20061
  const start = opts.id;
20161
20062
  const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
20162
20063
  const fileRel = `${start}-${slug2}.md`;
20163
- const file = path63.join(TODO, fileRel);
20064
+ const file = path62.join(TODO, fileRel);
20164
20065
  const held4 = locate(start) ?? locateArchived(start);
20165
- if (held4 && path63.basename(held4.target) === `${start}-${slug2}.md`) {
20066
+ if (held4 && path62.basename(held4.target) === `${start}-${slug2}.md`) {
20166
20067
  say(start);
20167
20068
  say(` ${rel(held4.target)} was already written`);
20168
20069
  return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
20169
20070
  }
20170
20071
  if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
20171
- if (fs60.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
20072
+ if (fs59.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
20172
20073
  countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
20173
20074
  const meta = { title, priority, status: "todo", blocked_by, related, modules, studio, previews, stages, triage, source, questions };
20174
20075
  const scaffolded = !written && opts.body !== false;
20175
20076
  const body = written ?? (scaffolded ? defaultBody() : "");
20176
- fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
20077
+ fs59.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
20177
20078
  const indexed = addReadmeRef(start, title, fileRel);
20178
20079
  say(start);
20179
20080
  say(
@@ -20225,8 +20126,8 @@ function cmdUpdate(id, flags) {
20225
20126
  if (creating) die(creating, { kind: "card-being-created", id });
20226
20127
  const found2 = locate(id);
20227
20128
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
20228
- const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
20229
- const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
20129
+ const file = found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target;
20130
+ const { meta, body } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
20230
20131
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
20231
20132
  if (flags.blockedBy !== void 0 && flags.addBlockedBy !== void 0) die("--blocked-by replaces the list and --add-blocked-by appends to it \u2014 pass one");
20232
20133
  if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
@@ -20300,26 +20201,26 @@ function cmdUpdate(id, flags) {
20300
20201
  meta.status = "todo";
20301
20202
  changes.push("status\u2192todo (open questions)");
20302
20203
  }
20303
- const curRel = path63.relative(TODO, file);
20204
+ const curRel = path62.relative(TODO, file);
20304
20205
  const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
20305
- let base = path63.basename(file);
20206
+ let base = path62.basename(file);
20306
20207
  if (flags.slug !== void 0) {
20307
20208
  if (found2.kind === "group") die("renaming a group root by script is not supported");
20308
20209
  base = `${id}-${slugify(flags.slug)}.md`;
20309
20210
  }
20310
- const destRel = path63.join(path63.dirname(curRel), base);
20311
- const dest = path63.join(TODO, destRel);
20211
+ const destRel = path62.join(path62.dirname(curRel), base);
20212
+ const dest = path62.join(TODO, destRel);
20312
20213
  const moving = dest !== file;
20313
- if (moving && fs60.existsSync(dest)) die(`${rel(dest)} already exists`);
20314
- fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
20315
- if (moving) fs60.renameSync(file, dest);
20214
+ if (moving && fs59.existsSync(dest)) die(`${rel(dest)} already exists`);
20215
+ fs59.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
20216
+ if (moving) fs59.renameSync(file, dest);
20316
20217
  if (isSubtask) {
20317
20218
  if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
20318
- if (moving) changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
20219
+ if (moving) changes.push(`renamed \u2192 ${destRel.split(path62.sep).join("/")}`);
20319
20220
  } else if (moving) {
20320
20221
  stripReadmeRefs({ kind: "file", rel: curRel });
20321
20222
  addReadmeRef(id, meta.title, destRel);
20322
- changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
20223
+ changes.push(`renamed \u2192 ${destRel.split(path62.sep).join("/")}`);
20323
20224
  } else if (changes.includes("title")) {
20324
20225
  stripReadmeRefs({ kind: "file", rel: curRel });
20325
20226
  addReadmeRef(id, meta.title, curRel);
@@ -20331,8 +20232,8 @@ function cmdUpdateQuestions(id, input) {
20331
20232
  const ops = readQuestionOps(input.ops ?? []);
20332
20233
  const found2 = locate(id);
20333
20234
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
20334
- const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
20335
- const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
20235
+ const file = found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target;
20236
+ const { meta, body } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
20336
20237
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
20337
20238
  for (const op of ops) {
20338
20239
  if (!op.question?.agent) continue;
@@ -20340,23 +20241,23 @@ function cmdUpdateQuestions(id, input) {
20340
20241
  if (!agent) die(`--agent "${op.question.agent}" is not an agent on this board`, { kind: "no-such-spec-agent", specAgent: op.question.agent });
20341
20242
  op.question.agent = agent.name;
20342
20243
  }
20343
- let done2;
20244
+ let done;
20344
20245
  try {
20345
- done2 = applyQuestionOps(meta.questions, ops, specRunAgent());
20246
+ done = applyQuestionOps(meta.questions, ops, specRunAgent());
20346
20247
  } catch (e) {
20347
20248
  if (e instanceof QuestionOpError) die(`#${id}: ${e.message}`);
20348
20249
  throw e;
20349
20250
  }
20350
- const { changes } = done2;
20351
- meta.questions = done2.questions;
20251
+ const { changes } = done;
20252
+ meta.questions = done.questions;
20352
20253
  const open3 = meta.questions.length;
20353
20254
  if (open3 > 0 && meta.status === "ready") {
20354
20255
  meta.status = "todo";
20355
20256
  changes.push("status\u2192todo (open questions)");
20356
20257
  }
20357
- fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
20258
+ fs59.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
20358
20259
  const closed2 = activeDelivery(id) ? "questions_closed_verify" : "questions_closed_user";
20359
- for (const _ of done2.closed) countBoardEvent(closed2);
20260
+ for (const _ of done.closed) countBoardEvent(closed2);
20360
20261
  say(`updated #${id} questions: ${changes.join(", ")} (${open3} open)`);
20361
20262
  return { id, changes, open: open3, file: rel(file) };
20362
20263
  }
@@ -20421,13 +20322,13 @@ var init_config_template = __esm({
20421
20322
  });
20422
20323
 
20423
20324
  // ../cli/src/lib/agent/local.ts
20424
- import fs61 from "node:fs";
20425
- import path64 from "node:path";
20325
+ import fs60 from "node:fs";
20326
+ import path63 from "node:path";
20426
20327
  function takeLocalModels(board2) {
20427
- const file = path64.join(board2, ".local.json");
20328
+ const file = path63.join(board2, ".local.json");
20428
20329
  let held4;
20429
20330
  try {
20430
- held4 = configBlock(JSON.parse(fs61.readFileSync(file, "utf8")));
20331
+ held4 = configBlock(JSON.parse(fs60.readFileSync(file, "utf8")));
20431
20332
  } catch {
20432
20333
  return {};
20433
20334
  }
@@ -20445,7 +20346,7 @@ function takeLocalModels(board2) {
20445
20346
  }
20446
20347
  if (!Object.keys(agents).length) return out;
20447
20348
  delete held4.agents;
20448
- fs61.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
20349
+ fs60.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
20449
20350
  return out;
20450
20351
  }
20451
20352
  var LOCAL_IGNORE_LINE;
@@ -20506,12 +20407,12 @@ var init_identity2 = __esm({
20506
20407
  });
20507
20408
 
20508
20409
  // ../cli/src/lib/signals/migrate.ts
20509
- import fs62 from "node:fs";
20510
- import path65 from "node:path";
20410
+ import fs61 from "node:fs";
20411
+ import path64 from "node:path";
20511
20412
  function readHandled() {
20512
20413
  let text4;
20513
20414
  try {
20514
- text4 = fs62.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
20415
+ text4 = fs61.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
20515
20416
  } catch {
20516
20417
  return [];
20517
20418
  }
@@ -20528,67 +20429,67 @@ function readHandled() {
20528
20429
  return held4;
20529
20430
  }
20530
20431
  function lift(from, into) {
20531
- fs62.mkdirSync(into, { recursive: true });
20532
- fs62.renameSync(from, path65.join(into, freeName(into, path65.basename(from))));
20432
+ fs61.mkdirSync(into, { recursive: true });
20433
+ fs61.renameSync(from, path64.join(into, freeName(into, path64.basename(from))));
20533
20434
  }
20534
20435
  function repoint(dir, from, into) {
20535
20436
  let entries;
20536
20437
  try {
20537
- entries = fs62.readdirSync(dir, { withFileTypes: true });
20438
+ entries = fs61.readdirSync(dir, { withFileTypes: true });
20538
20439
  } catch {
20539
20440
  return;
20540
20441
  }
20541
20442
  for (const entry of entries) {
20542
20443
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
20543
- const file = path65.join(dir, entry.name);
20544
- const text4 = fs62.readFileSync(file, "utf8");
20545
- if (text4.includes(from)) fs62.writeFileSync(file, text4.split(from).join(into));
20444
+ const file = path64.join(dir, entry.name);
20445
+ const text4 = fs61.readFileSync(file, "utf8");
20446
+ if (text4.includes(from)) fs61.writeFileSync(file, text4.split(from).join(into));
20546
20447
  }
20547
20448
  }
20548
20449
  function dropIfEmpty2(dir) {
20549
20450
  try {
20550
- fs62.rmdirSync(dir);
20451
+ fs61.rmdirSync(dir);
20551
20452
  } catch {
20552
20453
  }
20553
20454
  }
20554
20455
  function liftInbox() {
20555
- if (!fs62.existsSync(SIGNALS_OLD_INBOX)) return;
20556
- const oldFiles = path65.join(SIGNALS_OLD_INBOX, "files");
20557
- if (fs62.existsSync(oldFiles)) {
20558
- for (const entry of fs62.readdirSync(oldFiles, { withFileTypes: true })) {
20559
- if (entry.isFile()) lift(path65.join(oldFiles, entry.name), SIGNALS_FILES);
20456
+ if (!fs61.existsSync(SIGNALS_OLD_INBOX)) return;
20457
+ const oldFiles = path64.join(SIGNALS_OLD_INBOX, "files");
20458
+ if (fs61.existsSync(oldFiles)) {
20459
+ for (const entry of fs61.readdirSync(oldFiles, { withFileTypes: true })) {
20460
+ if (entry.isFile()) lift(path64.join(oldFiles, entry.name), SIGNALS_FILES);
20560
20461
  }
20561
20462
  dropIfEmpty2(oldFiles);
20562
20463
  }
20563
- const held4 = new Set(readFolder2(TRIAGE).map((signal2) => signal2.sourceId));
20564
- for (const entry of fs62.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
20464
+ const held4 = new Set(readFolder(TRIAGE).map((signal2) => signal2.sourceId));
20465
+ for (const entry of fs61.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
20565
20466
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
20566
- const from = path65.join(SIGNALS_OLD_INBOX, entry.name);
20467
+ const from = path64.join(SIGNALS_OLD_INBOX, entry.name);
20567
20468
  const item = parse(from);
20568
20469
  if (item && held4.has(item.sourceId)) {
20569
- fs62.rmSync(from, { force: true });
20470
+ fs61.rmSync(from, { force: true });
20570
20471
  continue;
20571
20472
  }
20572
20473
  if (item) held4.add(item.sourceId);
20573
20474
  lift(from, TRIAGE);
20574
20475
  }
20575
- const wasAt = asWritten(path65.join(SIGNALS_OLD_INBOX, "files"));
20476
+ const wasAt = asWritten(path64.join(SIGNALS_OLD_INBOX, "files"));
20576
20477
  const nowAt = asWritten(SIGNALS_FILES);
20577
20478
  for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
20578
20479
  dropIfEmpty2(SIGNALS_OLD_INBOX);
20579
20480
  }
20580
20481
  function liftHandled() {
20581
- if (!fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
20482
+ if (!fs61.existsSync(SIGNALS_OLD_HANDLED)) return;
20582
20483
  const lines = readHandled();
20583
20484
  const held4 = /* @__PURE__ */ new Set([
20584
- ...readFolder2(TRIAGE).map((signal2) => signal2.sourceId),
20585
- ...readFolder2(SIGNALS_ARCHIVED).map((signal2) => signal2.sourceId),
20485
+ ...readFolder(TRIAGE).map((signal2) => signal2.sourceId),
20486
+ ...readFolder(SIGNALS_ARCHIVED).map((signal2) => signal2.sourceId),
20586
20487
  ...readAllDismissed().map((signal2) => signal2.sourceId)
20587
20488
  ]);
20588
20489
  for (const { sourceId, when } of lines) {
20589
20490
  if (held4.has(sourceId)) continue;
20590
20491
  held4.add(sourceId);
20591
- fs62.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
20492
+ fs61.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
20592
20493
  const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
20593
20494
  const front = [
20594
20495
  "---",
@@ -20598,13 +20499,13 @@ function liftHandled() {
20598
20499
  "---",
20599
20500
  ""
20600
20501
  ];
20601
- fs62.writeFileSync(path65.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
20502
+ fs61.writeFileSync(path64.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
20602
20503
  `);
20603
20504
  }
20604
- fs62.rmSync(SIGNALS_OLD_HANDLED, { force: true });
20505
+ fs61.rmSync(SIGNALS_OLD_HANDLED, { force: true });
20605
20506
  }
20606
20507
  function migrateTriage() {
20607
- if (!fs62.existsSync(SIGNALS_OLD_INBOX) && !fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
20508
+ if (!fs61.existsSync(SIGNALS_OLD_INBOX) && !fs61.existsSync(SIGNALS_OLD_HANDLED)) return;
20608
20509
  try {
20609
20510
  liftInbox();
20610
20511
  liftHandled();
@@ -20619,13 +20520,13 @@ var init_migrate = __esm({
20619
20520
  init_yaml();
20620
20521
  init_inbox();
20621
20522
  HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
20622
- asWritten = (dir) => `${rel(dir).split(path65.sep).join("/")}/`;
20523
+ asWritten = (dir) => `${rel(dir).split(path64.sep).join("/")}/`;
20623
20524
  }
20624
20525
  });
20625
20526
 
20626
20527
  // ../cli/src/lib/signals/add.ts
20627
- import fs63 from "node:fs";
20628
- import path66 from "node:path";
20528
+ import fs62 from "node:fs";
20529
+ import path65 from "node:path";
20629
20530
  import { createHash as createHash4 } from "node:crypto";
20630
20531
  function linkTitle(url) {
20631
20532
  let at;
@@ -20638,7 +20539,7 @@ function linkTitle(url) {
20638
20539
  return oneLine(where) || url.slice(0, TITLE_MAX);
20639
20540
  }
20640
20541
  function asText(file) {
20641
- const ext = path66.extname(file.name).toLowerCase();
20542
+ const ext = path65.extname(file.name).toLowerCase();
20642
20543
  if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
20643
20544
  try {
20644
20545
  const text4 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
@@ -20648,9 +20549,9 @@ function asText(file) {
20648
20549
  }
20649
20550
  }
20650
20551
  function fileName2(name, data) {
20651
- const base = path66.basename(name);
20652
- const ext = path66.extname(base).toLowerCase().slice(0, 12);
20653
- const word = path66.basename(base, path66.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
20552
+ const base = path65.basename(name);
20553
+ const ext = path65.extname(base).toLowerCase().slice(0, 12);
20554
+ const word = path65.basename(base, path65.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
20654
20555
  const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
20655
20556
  return `${word}-${hash2}${ext}`;
20656
20557
  }
@@ -20659,9 +20560,9 @@ function addToInbox(drop) {
20659
20560
  const typed = (drop.text ?? "").trim();
20660
20561
  const file = drop.file;
20661
20562
  if (!typed && !file) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
20662
- if (file && file.data.length === 0) return { ok: false, error: `${path66.basename(file.name)} is empty.` };
20563
+ if (file && file.data.length === 0) return { ok: false, error: `${path65.basename(file.name)} is empty.` };
20663
20564
  if (file && file.data.length > MAX_BYTES2) {
20664
- return { ok: false, error: `${path66.basename(file.name)} is over ${MAX_BYTES2 / 1024 / 1024} MB \u2014 too big for the board.` };
20565
+ return { ok: false, error: `${path65.basename(file.name)} is over ${MAX_BYTES2 / 1024 / 1024} MB \u2014 too big for the board.` };
20665
20566
  }
20666
20567
  const read3 = describe(typed, file);
20667
20568
  const keep2 = read3.keep;
@@ -20683,8 +20584,8 @@ ${incoming.summary}`);
20683
20584
  if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
20684
20585
  try {
20685
20586
  if (keep2) {
20686
- fs63.mkdirSync(SIGNALS_FILES, { recursive: true });
20687
- fs63.writeFileSync(keep2.at, keep2.data);
20587
+ fs62.mkdirSync(SIGNALS_FILES, { recursive: true });
20588
+ fs62.writeFileSync(keep2.at, keep2.data);
20688
20589
  }
20689
20590
  return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
20690
20591
  } catch (e) {
@@ -20698,7 +20599,7 @@ function describe(typed, file) {
20698
20599
  return only ? [only] : [];
20699
20600
  };
20700
20601
  if (file) {
20701
- const name = path66.basename(file.name);
20602
+ const name = path65.basename(file.name);
20702
20603
  const text4 = asText(file);
20703
20604
  const note = typed ? `
20704
20605
 
@@ -20710,7 +20611,7 @@ ${typed}` : "";
20710
20611
  const at = keepAt(file);
20711
20612
  return {
20712
20613
  incoming: {
20713
- title: path66.basename(name, path66.extname(name)) || name,
20614
+ title: path65.basename(name, path65.extname(name)) || name,
20714
20615
  summary: `${name} \u2014 ${boardRel2(at)}${note}`,
20715
20616
  ...named2
20716
20617
  },
@@ -20748,73 +20649,73 @@ var init_add = __esm({
20748
20649
  MAX_BYTES2 = 25 * 1024 * 1024;
20749
20650
  TITLE_MAX = 120;
20750
20651
  TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
20751
- boardRel2 = (file) => rel(file).split(path66.sep).join("/");
20652
+ boardRel2 = (file) => rel(file).split(path65.sep).join("/");
20752
20653
  oneLine = (text4) => {
20753
20654
  const first = text4.split("\n").find((line) => line.trim()) ?? "";
20754
20655
  const clean = first.replace(/^#+\s*/, "").trim();
20755
20656
  return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
20756
20657
  };
20757
- keepAt = (file) => path66.join(SIGNALS_FILES, fileName2(file.name, file.data));
20658
+ keepAt = (file) => path65.join(SIGNALS_FILES, fileName2(file.name, file.data));
20758
20659
  }
20759
20660
  });
20760
20661
 
20761
20662
  // ../cli/src/lib/recurring.ts
20762
- import fs64 from "node:fs";
20763
- import path67 from "node:path";
20663
+ import fs63 from "node:fs";
20664
+ import path66 from "node:path";
20764
20665
  function migratePruneMemoryCard() {
20765
20666
  const dir = recurringDir();
20766
20667
  let names3;
20767
20668
  try {
20768
- names3 = fs64.readdirSync(dir);
20669
+ names3 = fs63.readdirSync(dir);
20769
20670
  } catch {
20770
20671
  return null;
20771
20672
  }
20772
20673
  const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
20773
20674
  if (!name) return null;
20774
- const file = path67.join(dir, name);
20675
+ const file = path66.join(dir, name);
20775
20676
  try {
20776
- const { meta } = parseFrontmatter(fs64.readFileSync(file, "utf8"));
20677
+ const { meta } = parseFrontmatter(fs63.readFileSync(file, "utf8"));
20777
20678
  const cadence = meta?.cadence;
20778
20679
  if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
20779
20680
  } catch {
20780
20681
  }
20781
- fs64.rmSync(file, { force: true });
20682
+ fs63.rmSync(file, { force: true });
20782
20683
  return rel(file);
20783
20684
  }
20784
20685
  function legacyCards() {
20785
20686
  const dir = recurringDir();
20786
- if (!fs64.existsSync(dir)) return [];
20687
+ if (!fs63.existsSync(dir)) return [];
20787
20688
  const cards = [];
20788
- for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20689
+ for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
20789
20690
  const id = idPrefix(entry.name);
20790
20691
  if (id === null) continue;
20791
- const full = path67.join(dir, entry.name);
20692
+ const full = path66.join(dir, entry.name);
20792
20693
  const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
20793
20694
  if (entry.isFile() && entry.name.endsWith(".md")) cards.push({ id, slug: slug2, file: full });
20794
- else if (entry.isDirectory() && fs64.existsSync(path67.join(full, "root.md"))) {
20795
- cards.push({ id, slug: slug2, file: path67.join(full, "root.md"), folder: full });
20695
+ else if (entry.isDirectory() && fs63.existsSync(path66.join(full, "root.md"))) {
20696
+ cards.push({ id, slug: slug2, file: path66.join(full, "root.md"), folder: full });
20796
20697
  }
20797
20698
  }
20798
20699
  return cards.sort((a, b) => a.id - b.id);
20799
20700
  }
20800
20701
  function mergeInto2(from, to, skip = []) {
20801
- fs64.mkdirSync(to, { recursive: true });
20802
- for (const entry of fs64.readdirSync(from, { withFileTypes: true })) {
20702
+ fs63.mkdirSync(to, { recursive: true });
20703
+ for (const entry of fs63.readdirSync(from, { withFileTypes: true })) {
20803
20704
  if (skip.includes(entry.name)) continue;
20804
- const source = path67.join(from, entry.name);
20805
- const target = path67.join(to, entry.name);
20806
- if (!fs64.existsSync(target)) fs64.renameSync(source, target);
20807
- else if (entry.isDirectory() && fs64.statSync(target).isDirectory()) mergeInto2(source, target);
20705
+ const source = path66.join(from, entry.name);
20706
+ const target = path66.join(to, entry.name);
20707
+ if (!fs63.existsSync(target)) fs63.renameSync(source, target);
20708
+ else if (entry.isDirectory() && fs63.statSync(target).isDirectory()) mergeInto2(source, target);
20808
20709
  }
20809
- if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
20710
+ if (isEmpty(from)) fs63.rmSync(from, { recursive: true, force: true });
20810
20711
  }
20811
20712
  function moveSideFolders() {
20812
20713
  const dir = recurringDir();
20813
- for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20714
+ for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
20814
20715
  if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
20815
- const from = path67.join(dir, entry.name);
20816
- if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
20817
- else mergeInto2(from, path67.join(AGENTS, entry.name));
20716
+ const from = path66.join(dir, entry.name);
20717
+ if (isEmpty(from)) fs63.rmSync(from, { recursive: true, force: true });
20718
+ else mergeInto2(from, path66.join(AGENTS, entry.name));
20818
20719
  }
20819
20720
  }
20820
20721
  function sections(body) {
@@ -20864,8 +20765,8 @@ function agentName(card, text4) {
20864
20765
  const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a) => a.name), ...ROLE_NAMES]);
20865
20766
  for (const name of [slug2, `${slug2}-${card.id}`]) {
20866
20767
  if (!AGENT_NAME.test(name)) continue;
20867
- const file = path67.join(AGENTS, name, AGENT_FILE2);
20868
- const written = fs64.existsSync(file) ? fs64.readFileSync(file, "utf8") : null;
20768
+ const file = path66.join(AGENTS, name, AGENT_FILE2);
20769
+ const written = fs63.existsSync(file) ? fs63.readFileSync(file, "utf8") : null;
20869
20770
  if (written === text4(name)) return name;
20870
20771
  if (written === null && !known2.has(name)) return name;
20871
20772
  }
@@ -20882,11 +20783,11 @@ ${q.options.map((o) => `- ${o}`).join("\n")}` : "";
20882
20783
  function removeCard(card) {
20883
20784
  dropCrossRefs(card.id);
20884
20785
  const target = card.folder ?? card.file;
20885
- stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path67.relative(TODO, target).split(path67.sep).join("/") });
20886
- fs64.rmSync(target, { recursive: true, force: true });
20786
+ stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path66.relative(TODO, target).split(path66.sep).join("/") });
20787
+ fs63.rmSync(target, { recursive: true, force: true });
20887
20788
  }
20888
20789
  function migrateCard(card) {
20889
- const { meta, body } = parseFrontmatter(fs64.readFileSync(card.file, "utf8"));
20790
+ const { meta, body } = parseFrontmatter(fs63.readFileSync(card.file, "utf8"));
20890
20791
  if (!meta) throw new Error("its frontmatter cannot be read");
20891
20792
  const raw = meta;
20892
20793
  const said2 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
@@ -20896,19 +20797,19 @@ function migrateCard(card) {
20896
20797
  if (!flow) throw new Error(noStudioMessage(""));
20897
20798
  const text4 = (name2) => agentText(name2, meta.title || card.slug, body);
20898
20799
  const name = agentName(card, text4);
20899
- const dir = path67.join(AGENTS, name);
20900
- const file = path67.join(dir, AGENT_FILE2);
20901
- const madeDir = !fs64.existsSync(dir);
20902
- const wrote = !fs64.existsSync(file);
20800
+ const dir = path66.join(AGENTS, name);
20801
+ const file = path66.join(dir, AGENT_FILE2);
20802
+ const madeDir = !fs63.existsSync(dir);
20803
+ const wrote = !fs63.existsSync(file);
20903
20804
  try {
20904
- fs64.mkdirSync(dir, { recursive: true });
20905
- if (wrote) fs64.writeFileSync(file, text4(name));
20805
+ fs63.mkdirSync(dir, { recursive: true });
20806
+ if (wrote) fs63.writeFileSync(file, text4(name));
20906
20807
  const adopted = adoptStudioScheduled(flow.id, name, { cadence, lastRun });
20907
20808
  if (!adopted.ok) throw new Error(adopted.error);
20908
20809
  questionsToTriage(meta, name);
20909
20810
  } catch (e) {
20910
- if (madeDir) fs64.rmSync(dir, { recursive: true, force: true });
20911
- else if (wrote) fs64.rmSync(file, { force: true });
20811
+ if (madeDir) fs63.rmSync(dir, { recursive: true, force: true });
20812
+ else if (wrote) fs63.rmSync(file, { force: true });
20912
20813
  throw e;
20913
20814
  }
20914
20815
  if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
@@ -20916,31 +20817,31 @@ function migrateCard(card) {
20916
20817
  return { card: rel(card.file), agent: name, studio: flow.name, on: !!cadence, cadence };
20917
20818
  }
20918
20819
  function migrateRecurringCards() {
20919
- const done2 = { agents: [], removed: [], failed: [] };
20820
+ const done = { agents: [], removed: [], failed: [] };
20920
20821
  const dir = recurringDir();
20921
- if (!fs64.existsSync(dir)) return done2;
20822
+ if (!fs63.existsSync(dir)) return done;
20922
20823
  migratePruneMemoryCard();
20923
20824
  moveSideFolders();
20924
20825
  for (const card of legacyCards()) {
20925
20826
  try {
20926
20827
  if (card.slug === FETCH_SLUG) {
20927
20828
  removeCard(card);
20928
- done2.removed.push(rel(card.file));
20929
- } else done2.agents.push(migrateCard(card));
20829
+ done.removed.push(rel(card.file));
20830
+ } else done.agents.push(migrateCard(card));
20930
20831
  } catch (e) {
20931
- done2.failed.push({ card: rel(card.file), why: e instanceof Error ? e.message : String(e) });
20832
+ done.failed.push({ card: rel(card.file), why: e instanceof Error ? e.message : String(e) });
20932
20833
  }
20933
20834
  }
20934
- if (isEmpty(dir)) fs64.rmSync(dir, { recursive: true, force: true });
20935
- return done2;
20835
+ if (isEmpty(dir)) fs63.rmSync(dir, { recursive: true, force: true });
20836
+ return done;
20936
20837
  }
20937
- function recurringMigrationLines(done2) {
20838
+ function recurringMigrationLines(done) {
20938
20839
  return [
20939
- ...done2.agents.map(
20840
+ ...done.agents.map(
20940
20841
  (one) => `${one.card} is now the scheduled agent \`${one.agent}\` in the ${one.studio} studio \u2014 ` + (one.on ? `on, cadence ${one.cadence}` : "off: it had no cadence, so it runs only when you run it")
20941
20842
  ),
20942
- ...done2.removed.map((card) => `removed ${card} \u2014 write a scheduled agent to pull triage items on a cadence (\`akb guide write-agent\`)`),
20943
- ...done2.failed.map((one) => `could not turn ${one.card} into a scheduled agent: ${one.why}. It is left as it was and tried again next time`)
20843
+ ...done.removed.map((card) => `removed ${card} \u2014 write a scheduled agent to pull triage items on a cadence (\`akb guide write-agent\`)`),
20844
+ ...done.failed.map((one) => `could not turn ${one.card} into a scheduled agent: ${one.why}. It is left as it was and tried again next time`)
20944
20845
  ];
20945
20846
  }
20946
20847
  var PRUNE_SLUG, FETCH_SLUG, AGENT_FILE2, recurringDir, isEmpty, SECTION;
@@ -20964,14 +20865,14 @@ var init_recurring = __esm({
20964
20865
  PRUNE_SLUG = "prune-the-memory";
20965
20866
  FETCH_SLUG = "fetch-triage-items";
20966
20867
  AGENT_FILE2 = "AGENT.md";
20967
- recurringDir = () => path67.join(TODO, LEGACY_RECURRING);
20968
- isEmpty = (dir) => fs64.readdirSync(dir).every((name) => name === ".DS_Store");
20868
+ recurringDir = () => path66.join(TODO, LEGACY_RECURRING);
20869
+ isEmpty = (dir) => fs63.readdirSync(dir).every((name) => name === ".DS_Store");
20969
20870
  SECTION = /^##\s+(.+?)\s*$/;
20970
20871
  }
20971
20872
  });
20972
20873
 
20973
20874
  // ../cli/src/commands/init.ts
20974
- import fs65 from "node:fs";
20875
+ import fs64 from "node:fs";
20975
20876
  function boardReadme() {
20976
20877
  return `# Board
20977
20878
 
@@ -20984,20 +20885,20 @@ _(none)_
20984
20885
  `;
20985
20886
  }
20986
20887
  function writeConfigIfMissing() {
20987
- if (fs65.existsSync(CONFIG)) return false;
20988
- fs65.mkdirSync(KANBAN, { recursive: true });
20989
- fs65.writeFileSync(CONFIG, CONFIG_TEMPLATE);
20888
+ if (fs64.existsSync(CONFIG)) return false;
20889
+ fs64.mkdirSync(KANBAN, { recursive: true });
20890
+ fs64.writeFileSync(CONFIG, CONFIG_TEMPLATE);
20990
20891
  return true;
20991
20892
  }
20992
20893
  function writeModulesIfMissing() {
20993
- if (fs65.existsSync(MODULES_MD)) return false;
20994
- fs65.mkdirSync(KANBAN, { recursive: true });
20995
- fs65.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
20894
+ if (fs64.existsSync(MODULES_MD)) return false;
20895
+ fs64.mkdirSync(KANBAN, { recursive: true });
20896
+ fs64.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
20996
20897
  return true;
20997
20898
  }
20998
20899
  function writeGitignoreIfMissing() {
20999
- fs65.mkdirSync(KANBAN, { recursive: true });
21000
- const text4 = fs65.existsSync(KANBAN_GITIGNORE) ? fs65.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
20900
+ fs64.mkdirSync(KANBAN, { recursive: true });
20901
+ const text4 = fs64.existsSync(KANBAN_GITIGNORE) ? fs64.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
21001
20902
  const has = (rule) => text4.split("\n").some((line) => line.trim() === rule.line);
21002
20903
  const missing = IGNORE_RULES.filter((rule) => !has(rule));
21003
20904
  if (!missing.length) return false;
@@ -21005,45 +20906,45 @@ function writeGitignoreIfMissing() {
21005
20906
  ${rule.line}
21006
20907
  `).join("");
21007
20908
  const separator = !text4 || text4.endsWith("\n") ? "" : "\n";
21008
- fs65.writeFileSync(KANBAN_GITIGNORE, `${text4}${separator}${block}`);
20909
+ fs64.writeFileSync(KANBAN_GITIGNORE, `${text4}${separator}${block}`);
21009
20910
  return true;
21010
20911
  }
21011
20912
  function writeSkeletonIfMissing() {
21012
20913
  const added = [];
21013
- if (!fs65.existsSync(TODO)) {
21014
- fs65.mkdirSync(TODO, { recursive: true });
20914
+ if (!fs64.existsSync(TODO)) {
20915
+ fs64.mkdirSync(TODO, { recursive: true });
21015
20916
  added.push(`${rel(TODO)}/`);
21016
20917
  }
21017
- if (!fs65.existsSync(README)) {
21018
- fs65.writeFileSync(README, boardReadme());
20918
+ if (!fs64.existsSync(README)) {
20919
+ fs64.writeFileSync(README, boardReadme());
21019
20920
  added.push(rel(README));
21020
20921
  }
21021
20922
  return added;
21022
20923
  }
21023
20924
  function retireReleases() {
21024
- const done2 = [];
21025
- if (fs65.existsSync(RELEASES)) {
21026
- fs65.rmSync(RELEASES);
21027
- done2.push(`deleted ${rel(RELEASES)}`);
20925
+ const done = [];
20926
+ if (fs64.existsSync(RELEASES)) {
20927
+ fs64.rmSync(RELEASES);
20928
+ done.push(`deleted ${rel(RELEASES)}`);
21028
20929
  }
21029
20930
  let cards = 0;
21030
20931
  for (const dir of [TODO, ARCHIVE]) {
21031
- if (!fs65.existsSync(dir)) continue;
20932
+ if (!fs64.existsSync(dir)) continue;
21032
20933
  for (const file of walkMd(dir)) {
21033
- const text4 = fs65.readFileSync(file, "utf8");
20934
+ const text4 = fs64.readFileSync(file, "utf8");
21034
20935
  const end2 = text4.startsWith("---\n") ? text4.indexOf("\n---", 3) : -1;
21035
20936
  if (end2 < 0) continue;
21036
20937
  const head2 = text4.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
21037
20938
  if (head2.length === end2) continue;
21038
- fs65.writeFileSync(file, head2 + text4.slice(end2));
20939
+ fs64.writeFileSync(file, head2 + text4.slice(end2));
21039
20940
  cards++;
21040
20941
  }
21041
20942
  }
21042
- if (cards) done2.push(`cleared the release on ${cards} card${cards === 1 ? "" : "s"}`);
21043
- return done2.join(", ");
20943
+ if (cards) done.push(`cleared the release on ${cards} card${cards === 1 ? "" : "s"}`);
20944
+ return done.join(", ");
21044
20945
  }
21045
20946
  function cmdInit() {
21046
- if (fs65.existsSync(KANBAN)) {
20947
+ if (fs64.existsSync(KANBAN)) {
21047
20948
  const added = [
21048
20949
  ...writeSkeletonIfMissing(),
21049
20950
  writeConfigIfMissing() && rel(CONFIG),
@@ -21078,8 +20979,8 @@ function cmdInit() {
21078
20979
  }
21079
20980
  return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
21080
20981
  }
21081
- fs65.mkdirSync(TODO, { recursive: true });
21082
- fs65.writeFileSync(README, boardReadme());
20982
+ fs64.mkdirSync(TODO, { recursive: true });
20983
+ fs64.writeFileSync(README, boardReadme());
21083
20984
  writeConfigIfMissing();
21084
20985
  scaffoldProjectMemory();
21085
20986
  writeModulesIfMissing();
@@ -21168,25 +21069,25 @@ var init_scheduled = __esm({
21168
21069
  });
21169
21070
 
21170
21071
  // ../cli/src/lib/card-age.ts
21171
- import fs66 from "node:fs";
21172
- import path68 from "node:path";
21072
+ import fs65 from "node:fs";
21073
+ import path67 from "node:path";
21173
21074
  function staleAfterIn(config) {
21174
21075
  const days = Number(LINE.exec(config)?.[1]);
21175
21076
  return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
21176
21077
  }
21177
21078
  function staleAfter() {
21178
- if (!fs66.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
21179
- return staleAfterIn(fs66.readFileSync(CONFIG, "utf8"));
21079
+ if (!fs65.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
21080
+ return staleAfterIn(fs65.readFileSync(CONFIG, "utf8"));
21180
21081
  }
21181
21082
  function todoPathspec(top) {
21182
- const from = path68.relative(real(top), real(TODO));
21183
- if (!from || from.startsWith("..") || path68.isAbsolute(from)) return null;
21184
- return from.split(path68.sep).join("/");
21083
+ const from = path67.relative(real(top), real(TODO));
21084
+ if (!from || from.startsWith("..") || path67.isAbsolute(from)) return null;
21085
+ return from.split(path67.sep).join("/");
21185
21086
  }
21186
21087
  function cardFile2(spec, printed) {
21187
21088
  const p = unquotePath(printed);
21188
21089
  if (!p.startsWith(`${spec}/`)) return null;
21189
- return path68.join(TODO, ...p.slice(spec.length + 1).split("/"));
21090
+ return path67.join(TODO, ...p.slice(spec.length + 1).split("/"));
21190
21091
  }
21191
21092
  function dirtyCards(top, spec) {
21192
21093
  const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
@@ -21233,9 +21134,9 @@ var init_card_age = __esm({
21233
21134
  gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
21234
21135
  real = (p) => {
21235
21136
  try {
21236
- return fs66.realpathSync(p);
21137
+ return fs65.realpathSync(p);
21237
21138
  } catch {
21238
- return path68.resolve(p);
21139
+ return path67.resolve(p);
21239
21140
  }
21240
21141
  };
21241
21142
  unquotePath = (line) => {
@@ -21269,8 +21170,8 @@ var init_card_holds = __esm({
21269
21170
  });
21270
21171
 
21271
21172
  // ../cli/src/commands/list.ts
21272
- import fs67 from "node:fs";
21273
- import path69 from "node:path";
21173
+ import fs66 from "node:fs";
21174
+ import path68 from "node:path";
21274
21175
  function summaryLine(body) {
21275
21176
  const lines = body.split("\n");
21276
21177
  let i = 0;
@@ -21286,13 +21187,13 @@ function summaryLine(body) {
21286
21187
  function openRows() {
21287
21188
  const rows = [];
21288
21189
  for (const file of walkMd(TODO)) {
21289
- const base = path69.basename(file);
21190
+ const base = path68.basename(file);
21290
21191
  if (base === "README.md") continue;
21291
21192
  const isRoot = base === "root.md";
21292
- const id = isRoot ? idPrefix(path69.basename(path69.dirname(file))) : idPrefix(base);
21193
+ const id = isRoot ? idPrefix(path68.basename(path68.dirname(file))) : idPrefix(base);
21293
21194
  if (id == null) continue;
21294
- if (isLegacyRecurring(path69.relative(TODO, file))) continue;
21295
- const { meta, body } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
21195
+ if (isLegacyRecurring(path68.relative(TODO, file))) continue;
21196
+ const { meta, body } = parseFrontmatter(fs66.readFileSync(file, "utf8"));
21296
21197
  rows.push({
21297
21198
  id,
21298
21199
  file,
@@ -21334,15 +21235,15 @@ function cmdStale(rows, all2, scope, mod) {
21334
21235
  }
21335
21236
  function archivedFiles() {
21336
21237
  const files = /* @__PURE__ */ new Map();
21337
- if (!fs67.existsSync(ARCHIVE)) return files;
21238
+ if (!fs66.existsSync(ARCHIVE)) return files;
21338
21239
  for (const file of walkMd(ARCHIVE)) {
21339
- const id = idPrefix(path69.basename(file));
21240
+ const id = idPrefix(path68.basename(file));
21340
21241
  if (id !== null) files.set(id, file);
21341
21242
  }
21342
21243
  for (const dir of walkDirs(ARCHIVE)) {
21343
- const id = idPrefix(path69.basename(dir));
21344
- const root2 = path69.join(dir, "root.md");
21345
- if (id !== null && fs67.existsSync(root2)) files.set(id, root2);
21244
+ const id = idPrefix(path68.basename(dir));
21245
+ const root2 = path68.join(dir, "root.md");
21246
+ if (id !== null && fs66.existsSync(root2)) files.set(id, root2);
21346
21247
  }
21347
21248
  return files;
21348
21249
  }
@@ -21452,8 +21353,8 @@ var init_list = __esm({
21452
21353
  });
21453
21354
 
21454
21355
  // ../cli/src/lib/card-sources.ts
21455
- import fs68 from "node:fs";
21456
- import path70 from "node:path";
21356
+ import fs67 from "node:fs";
21357
+ import path69 from "node:path";
21457
21358
  function planById(id) {
21458
21359
  const found2 = readPlan(`plans/${id}-.md`);
21459
21360
  return found2?.text.trim() ? found2 : null;
@@ -21463,8 +21364,8 @@ function cardLink(id) {
21463
21364
  const found2 = open3 ?? locateArchived(id);
21464
21365
  if (!found2) return null;
21465
21366
  try {
21466
- const file = found2.kind === "group" ? path70.join(found2.target, "root.md") : found2.target;
21467
- const title = parseFrontmatter(fs68.readFileSync(file, "utf8")).meta?.title ?? "";
21367
+ const file = found2.kind === "group" ? path69.join(found2.target, "root.md") : found2.target;
21368
+ const title = parseFrontmatter(fs67.readFileSync(file, "utf8")).meta?.title ?? "";
21468
21369
  return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
21469
21370
  } catch {
21470
21371
  return null;
@@ -21489,7 +21390,7 @@ function link(ref, items) {
21489
21390
  if (ref.kind === "plan") return planLink(ref.id);
21490
21391
  if (ref.kind === "card") return cardLink(ref.id);
21491
21392
  if (ref.kind === "url") return urlLink(ref.url);
21492
- const item = items().find((signal2) => path70.basename(signal2.relPath) === ref.file);
21393
+ const item = items().find((signal2) => path69.basename(signal2.relPath) === ref.file);
21493
21394
  return item ? itemLink(item) : null;
21494
21395
  }
21495
21396
  function cardSources(meta, body) {
@@ -21530,12 +21431,12 @@ var init_card_sources = __esm({
21530
21431
  });
21531
21432
 
21532
21433
  // ../cli/src/lib/view/read.ts
21533
- import fs69 from "node:fs";
21534
- import path71 from "node:path";
21434
+ import fs68 from "node:fs";
21435
+ import path70 from "node:path";
21535
21436
  function readCard(file, relFromTodo) {
21536
- const id = idPrefix(path71.basename(relFromTodo));
21437
+ const id = idPrefix(path70.basename(relFromTodo));
21537
21438
  if (id === null) {
21538
- const parts = relFromTodo.split(path71.sep);
21439
+ const parts = relFromTodo.split(path70.sep);
21539
21440
  const folderId = idPrefix(parts[parts.length - 2] || "");
21540
21441
  if (folderId === null) return null;
21541
21442
  return buildCard(folderId, file, relFromTodo);
@@ -21543,10 +21444,10 @@ function readCard(file, relFromTodo) {
21543
21444
  return buildCard(id, file, relFromTodo);
21544
21445
  }
21545
21446
  function buildCard(id, file, relFromTodo) {
21546
- const text4 = fs69.readFileSync(file, "utf8");
21447
+ const text4 = fs68.readFileSync(file, "utf8");
21547
21448
  const { meta, body } = parseFrontmatter(text4);
21548
21449
  if (!meta) return null;
21549
- const relPath = relFromTodo.split(path71.sep).join("/");
21450
+ const relPath = relFromTodo.split(path70.sep).join("/");
21550
21451
  const flow = studioFor(meta.studio);
21551
21452
  const plan = !!meta.studio && archivesOnApproval(flow);
21552
21453
  const stages = cardStages(meta, flow).length;
@@ -21555,7 +21456,7 @@ function buildCard(id, file, relFromTodo) {
21555
21456
  // Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
21556
21457
  // read here and a card read by the contract agree on what version this is.
21557
21458
  revision: revisionOf(text4),
21558
- updatedAt: fs69.statSync(file).mtime.toISOString(),
21459
+ updatedAt: fs68.statSync(file).mtime.toISOString(),
21559
21460
  relPath,
21560
21461
  title: meta.title,
21561
21462
  priority: meta.priority,
@@ -21576,22 +21477,22 @@ function buildCard(id, file, relFromTodo) {
21576
21477
  };
21577
21478
  }
21578
21479
  function readGroup2(folderName) {
21579
- const groupDir = path71.join(TODO, folderName);
21580
- const rootFile = path71.join(groupDir, "root.md");
21581
- if (!fs69.existsSync(rootFile)) return null;
21582
- const root2 = readCard(rootFile, path71.join(folderName, "root.md"));
21480
+ const groupDir = path70.join(TODO, folderName);
21481
+ const rootFile = path70.join(groupDir, "root.md");
21482
+ if (!fs68.existsSync(rootFile)) return null;
21483
+ const root2 = readCard(rootFile, path70.join(folderName, "root.md"));
21583
21484
  if (!root2) return null;
21584
21485
  root2.isGroup = true;
21585
21486
  const { total, resolved: resolved2 } = subtaskLines(root2.body);
21586
21487
  root2.subtaskLines = { total, resolved: resolved2 };
21587
21488
  const subCards = [];
21588
21489
  const recurse = (dir, relDir) => {
21589
- for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
21590
- const childRel = path71.join(relDir, entry.name);
21490
+ for (const entry of fs68.readdirSync(dir, { withFileTypes: true })) {
21491
+ const childRel = path70.join(relDir, entry.name);
21591
21492
  if (entry.isDirectory()) {
21592
- recurse(path71.join(dir, entry.name), childRel);
21493
+ recurse(path70.join(dir, entry.name), childRel);
21593
21494
  } else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
21594
- const c = readCard(path71.join(dir, entry.name), childRel);
21495
+ const c = readCard(path70.join(dir, entry.name), childRel);
21595
21496
  if (c) {
21596
21497
  c.parent = { id: root2.id, title: root2.title };
21597
21498
  subCards.push(c);
@@ -21612,12 +21513,12 @@ function readGroup2(folderName) {
21612
21513
  return { root: root2, subCards };
21613
21514
  }
21614
21515
  function standaloneCards(dirRel) {
21615
- const dir = dirRel ? path71.join(TODO, dirRel) : TODO;
21616
- if (!fs69.existsSync(dir)) return [];
21516
+ const dir = dirRel ? path70.join(TODO, dirRel) : TODO;
21517
+ if (!fs68.existsSync(dir)) return [];
21617
21518
  const cards = [];
21618
- for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
21519
+ for (const entry of fs68.readdirSync(dir, { withFileTypes: true })) {
21619
21520
  if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
21620
- const c = readCard(path71.join(dir, entry.name), path71.join(dirRel, entry.name));
21521
+ const c = readCard(path70.join(dir, entry.name), path70.join(dirRel, entry.name));
21621
21522
  if (c) cards.push(c);
21622
21523
  }
21623
21524
  }
@@ -21629,7 +21530,7 @@ function collectCards() {
21629
21530
  const top = standaloneCards("");
21630
21531
  board2.push(...top);
21631
21532
  every.push(...top);
21632
- for (const entry of fs69.readdirSync(TODO, { withFileTypes: true })) {
21533
+ for (const entry of fs68.readdirSync(TODO, { withFileTypes: true })) {
21633
21534
  if (!entry.isDirectory()) continue;
21634
21535
  if (isGroupFolder(entry.name)) {
21635
21536
  const g = readGroup2(entry.name);
@@ -21661,7 +21562,7 @@ function findCard(id) {
21661
21562
  }
21662
21563
  function attachSources(card) {
21663
21564
  try {
21664
- const { meta, body } = parseFrontmatter(fs69.readFileSync(path71.join(TODO, card.relPath), "utf8"));
21565
+ const { meta, body } = parseFrontmatter(fs68.readFileSync(path70.join(TODO, card.relPath), "utf8"));
21665
21566
  const sources2 = meta ? cardSources(meta, body) : [];
21666
21567
  if (sources2.length) card.sources = sources2;
21667
21568
  } catch {
@@ -21765,10 +21666,10 @@ var init_read = __esm({
21765
21666
  });
21766
21667
 
21767
21668
  // ../cli/src/lib/group-close.ts
21768
- import fs70 from "node:fs";
21669
+ import fs69 from "node:fs";
21769
21670
  function groupCloses(rootFile) {
21770
21671
  try {
21771
- return groupCloseOf(fs70.readFileSync(rootFile, "utf8"));
21672
+ return groupCloseOf(fs69.readFileSync(rootFile, "utf8"));
21772
21673
  } catch {
21773
21674
  return false;
21774
21675
  }
@@ -21781,12 +21682,12 @@ var init_group_close = __esm({
21781
21682
  });
21782
21683
 
21783
21684
  // ../cli/src/commands/remove.ts
21784
- import fs71 from "node:fs";
21785
- import path72 from "node:path";
21685
+ import fs70 from "node:fs";
21686
+ import path71 from "node:path";
21786
21687
  function leavingIds(id, found2) {
21787
21688
  const ids = /* @__PURE__ */ new Set([id]);
21788
21689
  if (found2.kind === "group") {
21789
- const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) => path72.basename(f));
21690
+ const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) => path71.basename(f));
21790
21691
  for (const name of names3) {
21791
21692
  const n = idPrefix(name);
21792
21693
  if (n !== null) ids.add(n);
@@ -21798,10 +21699,10 @@ function findMentions(ids) {
21798
21699
  const hits = [];
21799
21700
  const re = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
21800
21701
  for (const dir of [TODO, MEMORY]) {
21801
- if (!fs71.existsSync(dir)) continue;
21702
+ if (!fs70.existsSync(dir)) continue;
21802
21703
  for (const file of walkMd(dir)) {
21803
- if (path72.basename(file) === "README.md") continue;
21804
- const lines = fs71.readFileSync(file, "utf8").split("\n");
21704
+ if (path71.basename(file) === "README.md") continue;
21705
+ const lines = fs70.readFileSync(file, "utf8").split("\n");
21805
21706
  const fmEnd = frontmatterEnd(lines);
21806
21707
  lines.forEach((line, i) => {
21807
21708
  if (!re.test(line)) return;
@@ -21817,12 +21718,12 @@ function findMentions(ids) {
21817
21718
  return hits;
21818
21719
  }
21819
21720
  function leavingCards(id, found2) {
21820
- const own = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
21721
+ const own = found2.kind === "group" ? path71.join(found2.target, "root.md") : found2.target;
21821
21722
  const cards = [{ id, file: own }];
21822
21723
  if (found2.kind !== "group") return cards;
21823
21724
  for (const file of walkMd(found2.target)) {
21824
21725
  if (file === own) continue;
21825
- const n = idPrefix(path72.basename(file));
21726
+ const n = idPrefix(path71.basename(file));
21826
21727
  if (n !== null) cards.push({ id: n, file });
21827
21728
  }
21828
21729
  return cards;
@@ -21831,10 +21732,10 @@ function stampLeaving(cards, rejection) {
21831
21732
  const day = formatDay();
21832
21733
  const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
21833
21734
  for (const card of cards) {
21834
- if (!fs71.existsSync(card.file)) continue;
21835
- const text4 = fs71.readFileSync(card.file, "utf8");
21735
+ if (!fs70.existsSync(card.file)) continue;
21736
+ const text4 = fs70.readFileSync(card.file, "utf8");
21836
21737
  const stamped = stampLeavingIn(text4, day, stamp4);
21837
- if (stamped !== text4) fs71.writeFileSync(card.file, stamped);
21738
+ if (stamped !== text4) fs70.writeFileSync(card.file, stamped);
21838
21739
  }
21839
21740
  }
21840
21741
  function unfinishedDelivery(id) {
@@ -21850,7 +21751,7 @@ function unfinishedDelivery(id) {
21850
21751
  }[gap];
21851
21752
  return `#${id} is not finished: ${what}.`;
21852
21753
  }
21853
- const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs71.existsSync(path72.join(ASSETS, src.slice(".assets/".length))));
21754
+ const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs70.existsSync(path71.join(ASSETS, src.slice(".assets/".length))));
21854
21755
  return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
21855
21756
  }
21856
21757
  function agentDecisions(text4) {
@@ -21881,8 +21782,8 @@ function removeCard2(id, metric, options) {
21881
21782
  const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
21882
21783
  if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
21883
21784
  const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
21884
- const cardFile3 = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
21885
- const cardText = fs71.existsSync(cardFile3) ? fs71.readFileSync(cardFile3, "utf8") : "";
21785
+ const cardFile3 = found2.kind === "group" ? path71.join(found2.target, "root.md") : found2.target;
21786
+ const cardText = fs70.existsSync(cardFile3) ? fs70.readFileSync(cardFile3, "utf8") : "";
21886
21787
  const { meta: cardMeta3 } = parseFrontmatter(cardText);
21887
21788
  const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f) => f !== cardFile3).map((f) => rel(f)).sort() : [];
21888
21789
  const leftIds = leavingIds(id, found2);
@@ -21913,10 +21814,10 @@ function removeCard2(id, metric, options) {
21913
21814
  const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
21914
21815
  if (dest) {
21915
21816
  stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
21916
- fs71.mkdirSync(ARCHIVE, { recursive: true });
21917
- fs71.renameSync(found2.target, dest);
21817
+ fs70.mkdirSync(ARCHIVE, { recursive: true });
21818
+ fs70.renameSync(found2.target, dest);
21918
21819
  } else {
21919
- fs71.rmSync(found2.target, { recursive: true, force: true });
21820
+ fs70.rmSync(found2.target, { recursive: true, force: true });
21920
21821
  }
21921
21822
  const removedRefs = stripReadmeRefs(found2);
21922
21823
  let marked2 = null;
@@ -21965,14 +21866,14 @@ function removeCard2(id, metric, options) {
21965
21866
  };
21966
21867
  }
21967
21868
  function closeGroup(rootFile) {
21968
- const rootId = idPrefix(path72.basename(path72.dirname(rootFile)));
21869
+ const rootId = idPrefix(path71.basename(path71.dirname(rootFile)));
21969
21870
  if (rootId === null) return null;
21970
21871
  if (runnerProject(KANBAN)) return null;
21971
21872
  if (!groupCloses(rootFile)) return null;
21972
21873
  say(`
21973
21874
  every subtask line on #${rootId} is resolved \u2014 closing the group:`);
21974
21875
  try {
21975
- const { meta, body } = parseFrontmatter(fs71.readFileSync(rootFile, "utf8"));
21876
+ const { meta, body } = parseFrontmatter(fs70.readFileSync(rootFile, "utf8"));
21976
21877
  const res = cmdRemove(rootId, "completed", { closing: true });
21977
21878
  return {
21978
21879
  id: rootId,
@@ -22029,7 +21930,7 @@ function cleanupDiscardedCards(sessionId) {
22029
21930
  if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
22030
21931
  while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
22031
21932
  dropCrossRefs(card.id);
22032
- stripReadmeRefs({ kind: "file", rel: path72.relative(TODO, path72.resolve(REPO_ROOT, card.path)).split(path72.sep).join("/") });
21933
+ stripReadmeRefs({ kind: "file", rel: path71.relative(TODO, path71.resolve(REPO_ROOT, card.path)).split(path71.sep).join("/") });
22033
21934
  }
22034
21935
  return discarded.map((c) => c.id);
22035
21936
  });
@@ -22037,8 +21938,8 @@ function cleanupDiscardedCards(sessionId) {
22037
21938
  function recoveredArchiveHandoff(id, source) {
22038
21939
  const found2 = locateArchived(id);
22039
21940
  if (!found2) throw new Error(`No archived card #${id} was found.`);
22040
- const file = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
22041
- const { meta } = parseFrontmatter(fs71.readFileSync(file, "utf8"));
21941
+ const file = found2.kind === "group" ? path71.join(found2.target, "root.md") : found2.target;
21942
+ const { meta } = parseFrontmatter(fs70.readFileSync(file, "utf8"));
22042
21943
  stripReadmeRefs(source ?? found2);
22043
21944
  const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
22044
21945
  if (root2) markSubtask(root2, id, "tick");
@@ -22425,8 +22326,8 @@ var init_created_cards = __esm({
22425
22326
 
22426
22327
  // ../cli/src/lib/agent/creation.ts
22427
22328
  import crypto4 from "node:crypto";
22428
- import fs72 from "node:fs";
22429
- import path73 from "node:path";
22329
+ import fs71 from "node:fs";
22330
+ import path72 from "node:path";
22430
22331
  function creationError(error, triage) {
22431
22332
  const zh = readLanguage() === "zh";
22432
22333
  const messages = {
@@ -22452,12 +22353,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
22452
22353
  function creationReceipt(request2, slot) {
22453
22354
  const hash2 = crypto4.createHash("sha256").update(`${request2}
22454
22355
  ${slot}`).digest("hex");
22455
- return path73.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
22356
+ return path72.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
22456
22357
  }
22457
22358
  function readCreation(file, said2) {
22458
22359
  return withCreationLock(() => {
22459
22360
  try {
22460
- const held4 = JSON.parse(fs72.readFileSync(file, "utf8"));
22361
+ const held4 = JSON.parse(fs71.readFileSync(file, "utf8"));
22461
22362
  if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
22462
22363
  return held4;
22463
22364
  } catch (error) {
@@ -22469,10 +22370,10 @@ function readCreation(file, said2) {
22469
22370
  });
22470
22371
  }
22471
22372
  function saveCreation(file, journal) {
22472
- fs72.mkdirSync(path73.dirname(file), { recursive: true });
22373
+ fs71.mkdirSync(path72.dirname(file), { recursive: true });
22473
22374
  const temp = `${file}.${crypto4.randomUUID()}.tmp`;
22474
- fs72.writeFileSync(temp, JSON.stringify(journal));
22475
- fs72.renameSync(temp, file);
22375
+ fs71.writeFileSync(temp, JSON.stringify(journal));
22376
+ fs71.renameSync(temp, file);
22476
22377
  }
22477
22378
  function archiveCreation(source, id) {
22478
22379
  if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
@@ -22486,7 +22387,7 @@ function archiveCreation(source, id) {
22486
22387
  function triageFile(sourceId) {
22487
22388
  const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
22488
22389
  if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
22489
- return path73.basename(found2.relPath, ".md");
22390
+ return path72.basename(found2.relPath, ".md");
22490
22391
  }
22491
22392
  var init_creation = __esm({
22492
22393
  "../cli/src/lib/agent/creation.ts"() {
@@ -22654,8 +22555,8 @@ __export(board_exports, {
22654
22555
  buildBoardProgram: () => buildBoardProgram
22655
22556
  });
22656
22557
  import crypto5 from "node:crypto";
22657
- import fs73 from "node:fs";
22658
- import path74 from "node:path";
22558
+ import fs72 from "node:fs";
22559
+ import path73 from "node:path";
22659
22560
  async function dispatch(move, cmd, args, opts, cli) {
22660
22561
  const ctx = ctxOf(cmd, cli.program);
22661
22562
  const data = await runAction(ctx, {}, async () => {
@@ -22695,7 +22596,7 @@ async function cloudCard(task, opts) {
22695
22596
  let request2;
22696
22597
  if (typeof opts.bodyFile === "string") {
22697
22598
  try {
22698
- request2 = fs73.readFileSync(opts.bodyFile, "utf8");
22599
+ request2 = fs72.readFileSync(opts.bodyFile, "utf8");
22699
22600
  } catch {
22700
22601
  }
22701
22602
  }
@@ -22725,7 +22626,7 @@ async function cloudCard(task, opts) {
22725
22626
  const file = creationReceipt(`${checked.value}:${requestId}`, slot);
22726
22627
  const journal = readCreation(file, said2);
22727
22628
  if (!journal.made) {
22728
- const key = `akb-${path74.basename(file, ".json").slice(0, 40)}`;
22629
+ const key = `akb-${path73.basename(file, ".json").slice(0, 40)}`;
22729
22630
  const made = await createProjectTask(checked.value, journal.said, key);
22730
22631
  if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
22731
22632
  journal.made = made.value;
@@ -22854,17 +22755,17 @@ var init_board2 = __esm({
22854
22755
  });
22855
22756
 
22856
22757
  // ../cli/src/lib/board-cli.ts
22857
- import fs74 from "node:fs";
22858
- import path75 from "node:path";
22758
+ import fs73 from "node:fs";
22759
+ import path74 from "node:path";
22859
22760
  function useBoard(found2, dirNamed) {
22860
- if (!found2.named && found2.board === path75.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
22761
+ if (!found2.named && found2.board === path74.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
22861
22762
  else setBoardDir(found2.board, found2.root);
22862
22763
  useProjectState();
22863
22764
  backfillCardStudios();
22864
22765
  }
22865
22766
  function whole(found2, move) {
22866
22767
  if (move === MAKES_A_BOARD) return found2;
22867
- if (!fs74.existsSync(path75.join(found2.board, "todo"))) {
22768
+ if (!fs73.existsSync(path74.join(found2.board, "todo"))) {
22868
22769
  die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
22869
22770
  kind: "board-incomplete",
22870
22771
  dir: found2.root
@@ -22873,13 +22774,13 @@ function whole(found2, move) {
22873
22774
  return found2;
22874
22775
  }
22875
22776
  function findBoardUpward(from, move) {
22876
- let dir = path75.resolve(from);
22777
+ let dir = path74.resolve(from);
22877
22778
  for (; ; ) {
22878
- if (hasBoard(dir)) return { root: dir, board: path75.join(dir, "docs", "kanban") };
22779
+ if (hasBoard(dir)) return { root: dir, board: path74.join(dir, "docs", "kanban") };
22879
22780
  if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
22880
- const kept2 = path75.join(dir, ".akb", "kanban");
22881
- if (move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return { root: dir, board: kept2 };
22882
- const up = path75.dirname(dir);
22781
+ const kept2 = path74.join(dir, ".akb", "kanban");
22782
+ if (move !== MAKES_A_BOARD && fs73.existsSync(path74.join(kept2, "todo"))) return { root: dir, board: kept2 };
22783
+ const up = path74.dirname(dir);
22883
22784
  if (up === dir) return null;
22884
22785
  dir = up;
22885
22786
  }
@@ -22887,11 +22788,11 @@ function findBoardUpward(from, move) {
22887
22788
  function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
22888
22789
  const named2 = board2 ?? boardFromEnv();
22889
22790
  if (named2) {
22890
- const folder = path75.resolve(cwd, named2);
22891
- if (!fs74.existsSync(folder) && move !== MAKES_A_BOARD) {
22791
+ const folder = path74.resolve(cwd, named2);
22792
+ if (!fs73.existsSync(folder) && move !== MAKES_A_BOARD) {
22892
22793
  die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
22893
22794
  }
22894
- if (fs74.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
22795
+ if (fs73.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
22895
22796
  die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
22896
22797
  kind: "no-board",
22897
22798
  dir: folder
@@ -22900,24 +22801,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
22900
22801
  return { root: projectRootOf(folder), board: folder, named: true };
22901
22802
  }
22902
22803
  if (dir !== null) {
22903
- const root2 = path75.resolve(dir);
22904
- if (!fs74.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
22905
- const kept2 = path75.join(root2, ".akb", "kanban");
22906
- if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
22804
+ const root2 = path74.resolve(dir);
22805
+ if (!fs73.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
22806
+ const kept2 = path74.join(root2, ".akb", "kanban");
22807
+ if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs73.existsSync(path74.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
22907
22808
  if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
22908
22809
  die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
22909
22810
  kind: "no-board",
22910
22811
  dir: root2
22911
22812
  });
22912
22813
  }
22913
- return whole({ root: root2, board: path75.join(root2, "docs", "kanban") }, move);
22814
+ return whole({ root: root2, board: path74.join(root2, "docs", "kanban") }, move);
22914
22815
  }
22915
22816
  const found2 = findBoardUpward(cwd, move);
22916
22817
  if (found2) return whole(found2, move);
22917
- if (move === MAKES_A_BOARD) return { root: path75.resolve(cwd), board: path75.join(path75.resolve(cwd), "docs", "kanban") };
22818
+ if (move === MAKES_A_BOARD) return { root: path74.resolve(cwd), board: path74.join(path74.resolve(cwd), "docs", "kanban") };
22918
22819
  die(
22919
- `no board here. Looked in ${path75.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
22920
- { kind: "no-board", dir: path75.resolve(cwd) }
22820
+ `no board here. Looked in ${path74.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
22821
+ { kind: "no-board", dir: path74.resolve(cwd) }
22921
22822
  );
22922
22823
  }
22923
22824
  function editDistance(a, b) {
@@ -23000,8 +22901,8 @@ var init_board_cli = __esm({
23000
22901
  init_pointer();
23001
22902
  init_card_studio_backfill();
23002
22903
  MAKES_A_BOARD = "init";
23003
- hasBoard = (dir) => fs74.existsSync(path75.join(dir, "docs", "kanban"));
23004
- isBoardDir = (dir) => fs74.existsSync(path75.join(dir, "todo")) && fs74.existsSync(path75.join(dir, "config.md"));
22904
+ hasBoard = (dir) => fs73.existsSync(path74.join(dir, "docs", "kanban"));
22905
+ isBoardDir = (dir) => fs73.existsSync(path74.join(dir, "todo")) && fs73.existsSync(path74.join(dir, "config.md"));
23005
22906
  boardFromEnv = () => {
23006
22907
  const named2 = process.env.AI4KANBAN_BOARD?.trim();
23007
22908
  return named2 ? named2 : null;
@@ -23261,8 +23162,8 @@ var init_agent = __esm({
23261
23162
 
23262
23163
  // ../cli/src/commands/cloud-template.ts
23263
23164
  import { createHash as createHash5 } from "node:crypto";
23264
- import fs75 from "node:fs";
23265
- import path76 from "node:path";
23165
+ import fs74 from "node:fs";
23166
+ import path75 from "node:path";
23266
23167
  function usage2(problem, line) {
23267
23168
  die(`${problem}
23268
23169
  usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
@@ -23339,10 +23240,10 @@ This template has no preview.`);
23339
23240
  const written = [];
23340
23241
  for (const p of previews) {
23341
23242
  const bytes2 = Buffer.from(await (await ask(`/${at}/previews/${route(p.path)}`, {}, WITHOUT)).arrayBuffer());
23342
- const file = path76.basename(p.path);
23343
- const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
23344
- fs75.mkdirSync(opts.to, { recursive: true });
23345
- fs75.writeFileSync(out, bytes2);
23243
+ const file = path75.basename(p.path);
23244
+ const out = path75.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
23245
+ fs74.mkdirSync(opts.to, { recursive: true });
23246
+ fs74.writeFileSync(out, bytes2);
23346
23247
  written.push(out);
23347
23248
  say(out);
23348
23249
  }
@@ -23355,15 +23256,15 @@ async function templateGet(name, opts, program2) {
23355
23256
  const { template } = await asJson(await ask(`/${at}`, {}, WITHOUT));
23356
23257
  const fetched = [];
23357
23258
  for (const f of template.files) {
23358
- const out = path76.resolve(to, f.path);
23359
- if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse3(T.corrupt, WITHOUT);
23259
+ const out = path75.resolve(to, f.path);
23260
+ if (!out.startsWith(path75.resolve(to) + path75.sep)) refuse3(T.corrupt, WITHOUT);
23360
23261
  const bytes2 = Buffer.from(await (await ask(`/${at}/files/${route(f.path)}`, {}, WITHOUT)).arrayBuffer());
23361
23262
  if (bytes2.byteLength !== f.size || createHash5("sha256").update(bytes2).digest("hex") !== f.sha256) {
23362
23263
  refuse3(T.corrupt, WITHOUT);
23363
23264
  }
23364
23265
  fetched.push({ out, bytes: bytes2 });
23365
23266
  }
23366
- const taken = fetched.filter((f) => fs75.existsSync(f.out)).map((f) => path76.relative(to, f.out));
23267
+ const taken = fetched.filter((f) => fs74.existsSync(f.out)).map((f) => path75.relative(to, f.out));
23367
23268
  if (taken.length > 0) {
23368
23269
  refuse3({
23369
23270
  zh: `\u76EE\u6807\u6587\u4EF6\u5939\u5DF2\u6709\u540C\u540D\u6587\u4EF6\uFF1A${taken.join("\u3001")}\u3002\u8BF7\u6362\u4E00\u4E2A\u6587\u4EF6\u5939\uFF0C\u6216\u5148\u79FB\u8D70\u8FD9\u4E9B\u6587\u4EF6\u3002`,
@@ -23371,8 +23272,8 @@ async function templateGet(name, opts, program2) {
23371
23272
  });
23372
23273
  }
23373
23274
  for (const f of fetched) {
23374
- fs75.mkdirSync(path76.dirname(f.out), { recursive: true });
23375
- fs75.writeFileSync(f.out, f.bytes);
23275
+ fs74.mkdirSync(path75.dirname(f.out), { recursive: true });
23276
+ fs74.writeFileSync(f.out, f.bytes);
23376
23277
  }
23377
23278
  say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
23378
23279
  Fetched ${name}: ${fetched.length} files into ${to}`);
@@ -23389,25 +23290,25 @@ async function templateSource(name, opts) {
23389
23290
  say(`evidence: ${e.path}`);
23390
23291
  continue;
23391
23292
  }
23392
- const out = path76.join(opts.to, `${name}-${path76.basename(e.path)}`);
23393
- fs75.mkdirSync(opts.to, { recursive: true });
23394
- fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
23293
+ const out = path75.join(opts.to, `${name}-${path75.basename(e.path)}`);
23294
+ fs74.mkdirSync(opts.to, { recursive: true });
23295
+ fs74.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
23395
23296
  written.push(out);
23396
23297
  say(out);
23397
23298
  }
23398
23299
  return { name, source, evidence: written.length > 0 ? written : evidence.map((e) => e.path) };
23399
23300
  }
23400
23301
  async function templatePublish(dir, opts) {
23401
- const root2 = path76.resolve(dir);
23402
- const manifest = path76.join(root2, "template.md");
23403
- if (!fs75.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
23404
- const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
23302
+ const root2 = path75.resolve(dir);
23303
+ const manifest = path75.join(root2, "template.md");
23304
+ if (!fs74.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
23305
+ const meta = readTemplateMeta(fs74.readFileSync(manifest, "utf8"));
23405
23306
  const files = walk2(root2);
23406
- const total = files.reduce((sum, f) => sum + fs75.statSync(path76.join(root2, f)).size, 0);
23307
+ const total = files.reduce((sum, f) => sum + fs74.statSync(path75.join(root2, f)).size, 0);
23407
23308
  if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
23408
23309
  for (const extra of [...opts.preview, ...opts.evidence]) {
23409
- if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
23410
- if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
23310
+ if (!fs74.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
23311
+ if (path75.resolve(extra).startsWith(root2 + path75.sep)) {
23411
23312
  invalid(
23412
23313
  `${extra} \u5728\u6A21\u677F\u6587\u4EF6\u5939\u5185\uFF1B\u9884\u89C8\u56FE\u4E0E\u6765\u6E90\u51ED\u8BC1\u9700\u653E\u5728\u6A21\u677F\u6587\u4EF6\u5939\u4E4B\u5916\u3002`,
23413
23314
  `${extra} is inside the template folder; keep previews and evidence outside it.`
@@ -23419,17 +23320,17 @@ async function templatePublish(dir, opts) {
23419
23320
  }
23420
23321
  const form = new FormData();
23421
23322
  form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
23422
- const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
23423
- for (const f of files) add("files", f, path76.join(root2, f));
23424
- for (const f of opts.preview) add("previews", path76.basename(f), f);
23425
- for (const f of opts.evidence) add("evidence", path76.basename(f), f);
23426
- const done2 = await asJson(await ask("", { method: "POST", body: form }));
23323
+ const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs74.readFileSync(file)]), path75.basename(name));
23324
+ for (const f of files) add("files", f, path75.join(root2, f));
23325
+ for (const f of opts.preview) add("previews", path75.basename(f), f);
23326
+ for (const f of opts.evidence) add("evidence", path75.basename(f), f);
23327
+ const done = await asJson(await ask("", { method: "POST", body: form }));
23427
23328
  say(
23428
- done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
23429
- Replaced ${done2.name}: ${files.length} files.` : `\u5DF2\u53D1\u5E03 ${done2.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
23430
- Published ${done2.name}: ${files.length} files.`
23329
+ done.replaced ? `\u5DF2\u66FF\u6362 ${done.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
23330
+ Replaced ${done.name}: ${files.length} files.` : `\u5DF2\u53D1\u5E03 ${done.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
23331
+ Published ${done.name}: ${files.length} files.`
23431
23332
  );
23432
- return { name: done2.name, replaced: done2.replaced, files };
23333
+ return { name: done.name, replaced: done.replaced, files };
23433
23334
  }
23434
23335
  async function templateDelete(name) {
23435
23336
  await ask(`/${encodeURIComponent(name)}`, { method: "DELETE" });
@@ -23438,11 +23339,11 @@ Deleted ${name} from the catalog.`);
23438
23339
  return { name, deleted: true };
23439
23340
  }
23440
23341
  async function templateShowcase(name, dir) {
23441
- const file = path76.join(dir, "showcase.json");
23442
- if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
23342
+ const file = path75.join(dir, "showcase.json");
23343
+ if (!fs74.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
23443
23344
  let meta;
23444
23345
  try {
23445
- meta = JSON.parse(fs75.readFileSync(file, "utf8"));
23346
+ meta = JSON.parse(fs74.readFileSync(file, "utf8"));
23446
23347
  } catch {
23447
23348
  return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
23448
23349
  }
@@ -23454,18 +23355,18 @@ async function templateShowcase(name, dir) {
23454
23355
  const form = new FormData();
23455
23356
  form.set("meta", JSON.stringify(meta));
23456
23357
  for (const p of new Set(named2)) {
23457
- const at = path76.join(dir, p);
23458
- if (!fs75.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
23459
- form.append(`media:${p}`, new Blob([fs75.readFileSync(at)]), p);
23358
+ const at = path75.join(dir, p);
23359
+ if (!fs74.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
23360
+ form.append(`media:${p}`, new Blob([fs74.readFileSync(at)]), p);
23460
23361
  }
23461
- const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
23462
- say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
23463
- Updated ${name}'s showcase: ${done2.files} files.`);
23464
- return { name, files: done2.files };
23362
+ const done = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
23363
+ say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done.files} \u4E2A\u6587\u4EF6\u3002
23364
+ Updated ${name}'s showcase: ${done.files} files.`);
23365
+ return { name, files: done.files };
23465
23366
  }
23466
23367
  function walk2(root2, sub = "") {
23467
23368
  const out = [];
23468
- for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
23369
+ for (const entry of fs74.readdirSync(path75.join(root2, sub), { withFileTypes: true })) {
23469
23370
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
23470
23371
  const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
23471
23372
  if (entry.isDirectory()) out.push(...walk2(root2, rel2));
@@ -23658,7 +23559,7 @@ var init_board3 = __esm({
23658
23559
  var card_chat_default;
23659
23560
  var init_card_chat = __esm({
23660
23561
  "../cli/src/guide/card-chat.md"() {
23661
- card_chat_default = '# Answer a card\'s conversation\n\nWork on the current card and its assets by default. Project implementation requires approval on the review page.\n\n- **Where the task stands**: read it with `akb task show <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- **Choose a preview agent**: when a preview is needed and the agent is unclear, use `akb raw previews --triggers` to match the work to an agent.\n- **Create or revise a preview**: when the user asks to see or change a preview for the current card, use `akb raw previews <agent> <id> --print`; never write embed tags by hand.\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**: when the user asks to change a studio or one of its agents, follow `akb guide update-studio`.\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- **Start this task**: when the user explicitly asks to start, implement or approve it, use `akb task approve` or `akb raw card approve/implement`. In a task reply these register one approval for after the reply finishes and syncs. Pending means accepted, not started; finish the reply and do not wait or edit the card again. Preview approvals still apply.\n';
23562
+ card_chat_default = '# Answer a card\'s conversation\n\nWork on the current card and its assets by default. Project implementation requires approval on the review page.\n\n- **Where the task stands**: read it with `akb task show <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- **Choose a preview agent**: when a preview is needed and the agent is unclear, use `akb raw previews --triggers` to match the work to an agent.\n- **Create or revise a preview**: when the user asks to see or change a preview for the current card, use `akb raw previews <agent> <id> --print`; never write embed tags by hand.\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 or agent changes; 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- **Start this task**: when the user explicitly asks to start, implement or approve it, use `akb task approve` or `akb raw card approve/implement`. In a task reply these register one approval for after the reply finishes and syncs. Pending means accepted, not started; finish the reply and do not wait or edit the card again. Preview approvals still apply.\n';
23662
23563
  }
23663
23564
  });
23664
23565
 
@@ -23666,7 +23567,7 @@ var init_card_chat = __esm({
23666
23567
  var update_studio_default;
23667
23568
  var init_update_studio = __esm({
23668
23569
  "../cli/src/guide/update-studio.md"() {
23669
- update_studio_default = "# Update a studio\n\nChange one of this workspace's studios so new tasks run the new version.\n\n## How a studio works\n\nA studio is steerable: agents do the work, and a person reviews and fine-tunes only the parts where precision matters most, so the result stays reliable.\n\n- **Previews**: usually one preview agent shows the work, finished or a draft, where the person can fine-tune it; add another only when a part needs precision and a mistake there is costly, such as a developer tool's screens. Each shows only what the person decides on, without overlapping another. With none, the card the `STUDIO.md` body writes is the only review.\n- **Unreviewable previews**: when the user finds a preview unneeded or cannot judge it, remove it; a land agent checks that part instead, or nobody does.\n- **Stages**: one stage by default. Add `after` only when a draft is too costly to make before another is approved, such as a video's storyboard, which waits for its script.\n- **Minimal**: when the user outlines the studio, keep it that simple or simpler; add no review point or constraint they did not ask for, and let the trial show what else needs review.\n- **Judgment**: leave to an agent what it can judge; never add a hard rule for one case, and keep a rule only once real runs show it holds widely.\n- **Memory**: give an agent memory only where it has wide latitude and tends to err or be corrected to taste, naming those error-prone points as what it records; give a narrow agent none.\n- **Shared**: what several of the studio's agents follow, run or remember belongs to the studio, never to one agent that the others point to.\n- **Card template**: put what every card of the studio starts from, such as its shared Todo steps, in `CARD.md`, not in the `STUDIO.md` body.\n- **Land**: everything else runs unattended after the last approval and follows the approved previews, such as building and merging a change; leave `land` empty when the last approved preview is the deliverable.\n- **Scheduled**: repeating work runs as a scheduled agent without previews; a studio may hold only scheduled agents.\n- **Agents**: write each as `akb guide write-agent` says.\n\n## The folder\n\n`akb studio pull` writes a studio as this folder:\n\n```text\n<folder>/\n\u251C\u2500\u2500 STUDIO.md frontmatter: `description`, what it does in one sentence; `when`, which requests\n\u2502 it is for, exceptions included; its agents under `previews`, `land`, `scheduled`;\n\u2502 `memoryFiles.workspace`, the studio memory shared by every project\n\u2502 body: how a card of this kind is written; every planning run on its cards reads it\n\u251C\u2500\u2500 CARD.md optional: the card template; the planner fits it to each card, such as its `## Todo`\n\u251C\u2500\u2500 shared/\n\u2502 \u251C\u2500\u2500 RULES.md terms and formats every agent follows; every run of the studio reads it\n\u2502 \u2514\u2500\u2500 \u2026 files any of its agents may read with `akb raw file <studio> shared/<path>`\n\u251C\u2500\u2500 agents/<name>/\n\u2502 \u251C\u2500\u2500 AGENT.md one agent: what its preview shows, or what its land or scheduled run does\n\u2502 \u2514\u2500\u2500 \u2026 files its AGENT.md points to\n\u2514\u2500\u2500 version.json the version pulled; push reads it, never edit it\n```\n\n## Versions\n\n- **Pinned**: a studio and the agents it holds live in Cloud as numbered versions; a task\n keeps the version it started with, and only tasks started after a push take the new one.\n- **Project agents**: agents under the board's `agents/` folder are the project's own; a\n studio may name them, but they are not part of its versions and an edit there applies to\n every card at once.\n- **Own studios only**: only the workspace's own studios take a new version; ask the user to\n copy a built-in or marketplace one on the web first.\n\n## Change it\n\n- **Standing preference**: when the user only wants a lasting rule for a studio or one of its\n agents and the flow itself stays, set it with `akb studio rule <studio>` or\n `akb studio instructions <agent>` instead of pushing; it reaches every task's later runs and\n works on built-in studios too. Either replaces all of them, so run it bare first to read the\n current ones, and keep each unless the user asks to change or drop it.\n- **Direct or task**: push directly a change the user spelled out; start a Studio builder task\n instead when the change adds, removes or restages agents, or when the user wants to review\n it before it applies.\n- **Steps**: `akb studio pull <id> <folder>`, edit the files there and keep what the request\n leaves alone, fix every problem `akb raw studio validate <folder>` reports, then\n `akb studio push <folder>`.\n- **Moved on**: when push says Cloud has a newer version, pull again and redo the change.\n- **Borrowed parts**: when an agent points to another agent's sections, files or memory\n folder, move them into `shared/`, `memoryFiles` and the studio memory folder, then push.\n";
23570
+ update_studio_default = "# Update a studio\n\n- **Studio files**: follow `akb guide add-task` to create a card with `--studio studio-builder`\n for a new studio or a change to an existing studio.\n- **Current draft**: a correction to the current card\u2019s deliverable follows `akb guide card-chat`.\n- **User rules**: for an explicit request to read or change attached rules, use\n `akb studio rule <studio>` or `akb studio instructions <agent>`; bare reads,\n `--text` or `--file` replaces all, and empty text clears. Read before changing and keep\n what the request leaves alone. These commands change attached rules, not `AGENT.md`.\n";
23670
23571
  }
23671
23572
  });
23672
23573
 
@@ -23738,7 +23639,7 @@ var init_review_rejections = __esm({
23738
23639
  var refine_default;
23739
23640
  var init_refine = __esm({
23740
23641
  "../cli/src/guide/refine.md"() {
23741
- refine_default = '# Refine a card\n\nPlan one card in this session until it can be built.\n\n- **\u91CD\u590D\u5361\u7247**: \u82E5\u53D1\u73B0\u53E6\u4E00\u5F20\u4EFB\u52A1\u5B8C\u6574\u8986\u76D6\u672C\u5361\uFF0C\u5373\u4F7F\u5BF9\u65B9\u5C1A\u672A\u5B9E\u65BD\uFF0C\u4E5F\u5148\u5C06\u5176\u7F3A\u5C11\u7684\u6709\u7528\u4FE1\u606F\u8865\u5165\u5E76\u786E\u8BA4\u4FDD\u5B58\u6210\u529F\uFF1B\n \u4FDD\u5B58\u5931\u8D25\u5219\u4FDD\u7559\u672C\u5361\u5E76\u505C\u6B62\u3002\u6CA1\u6709\u4FE1\u606F\u9700\u8981\u8865\u5145\u6216\u5DF2\u4FDD\u5B58\u6210\u529F\u540E\uFF0C\u8FD0\u884C\n `akb raw reject <id> --reason "<\u627F\u63A5\u4EFB\u52A1\u7F16\u53F7\u53CA\u5B8C\u6574\u8986\u76D6\u539F\u56E0>"` \u5E76\u505C\u6B62\u3002\n \u4E0D\u8BF7\u6C42\u786E\u8BA4\uFF0C\u4E0D\u8FD0\u884C\u9884\u89C8\uFF1B\u4EC5\u90E8\u5206\u91CD\u53E0\u4E0D\u4E22\u5F03\u3002\n- **Unchecked card**: a card with `triage:` set and an empty `## Scope` was never checked\n against the project. Check it first; when the project already does\n the work, or what it concerns no longer exists, run\n `akb raw reject <id> --reason "<what shows it>"` and stop.\n- **Gone or already done**: for any other card, append a question asking the user whether to\n discard it, run no preview agent, and stop.\n- **Existing group**: read its subtasks and check that they cover the parent\u2019s outcome;\n keep a complete split, or fill gaps by updating subtasks and dependencies without\n duplicating work or resetting progress. Finish the pass without marking the parent\n ready merely because its split is complete; its completion still follows its subtasks.\n- **Studio rules**: write the card as the studio rules at the end of this prompt say.\n- **Preview agents**: an agent\'s `After` names the previews it waits for; the board approves\n previews in stages, one stage per Approve, and the card\'s `previews` were chosen when its\n goal was written. A card without `previews` has not chosen: choose and save them first, as\n the list says, then run only its first stage. Run each agent the list above names whose\n section is missing or outdated with `akb raw previews <agent> <id> --print`, one at a time in this\n session; leave out `--print` only for an agent the list says runs in a session of its own.\n- **Stale mentions**: rewrite any sentence that relies on a card no longer on the board.\n- **Questions**: settle every decision you can and record the answers as `akb guide writing`\n says; ask only what `akb guide update-questions` says to ask.\n- **Write**: shape the card as `akb guide writing` says, then run `akb raw validate <id>` and\n fix every reported line.\n- **Ready**: settle every fact from the project and authoritative sources. Once the card\n validates, judge whether it can be built as written, or before its last Approve: if so, run\n `akb raw update <id> --status ready`; otherwise leave what blocks it as an open question.\n\nFollow any closing steps the flow printed, then stop: the user approves the previews or starts\nthe build.\n';
23642
+ refine_default = "# Refine a card\n\nPlan one card in this session until it can be built.\n\n- **Unchecked card**: a card with `triage:` set and an empty `## Scope` was never checked\n against the project. Check it first; when the project already does\n the work, or what it concerns no longer exists, run\n `akb raw reject <id> --reason \"<what shows it>\"` and stop.\n- **Gone or already done**: for any other card, append a question asking the user whether to\n discard it, run no preview agent, and stop.\n- **Existing group**: read its subtasks and check that they cover the parent\u2019s outcome;\n keep a complete split, or fill gaps by updating subtasks and dependencies without\n duplicating work or resetting progress. Finish the pass without marking the parent\n ready merely because its split is complete; its completion still follows its subtasks.\n- **Studio rules**: write the card as the studio rules at the end of this prompt say.\n- **Preview agents**: an agent's `After` names the previews it waits for; the board approves\n previews in stages, one stage per Approve, and the card's `previews` were chosen when its\n goal was written. A card without `previews` has not chosen: choose and save them first, as\n the list says, then run only its first stage. Run each agent the list above names whose\n section is missing or outdated with `akb raw previews <agent> <id> --print`, one at a time in this\n session; leave out `--print` only for an agent the list says runs in a session of its own.\n- **Stale mentions**: rewrite any sentence that relies on a card no longer on the board.\n- **Questions**: settle every decision you can and record the answers as `akb guide writing`\n says; ask only what `akb guide update-questions` says to ask.\n- **Write**: shape the card as `akb guide writing` says, then run `akb raw validate <id>` and\n fix every reported line.\n- **Ready**: settle every fact from the project and authoritative sources. Once the card\n validates, judge whether it can be built as written, or before its last Approve: if so, run\n `akb raw update <id> --status ready`; otherwise leave what blocks it as an open question.\n\nFollow any closing steps the flow printed, then stop: the user approves the previews or starts\nthe build.\n";
23742
23643
  }
23743
23644
  });
23744
23645
 
@@ -23927,8 +23828,9 @@ var init_guide2 = __esm({
23927
23828
  });
23928
23829
 
23929
23830
  // ../cli/src/commands/studio.ts
23930
- import fs76 from "node:fs";
23931
- import path77 from "node:path";
23831
+ import crypto6 from "node:crypto";
23832
+ import fs75 from "node:fs";
23833
+ import path76 from "node:path";
23932
23834
  function cmdStudioList() {
23933
23835
  if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
23934
23836
  const offline2 = studiosOffline();
@@ -23956,30 +23858,28 @@ function cmdStudioList() {
23956
23858
  ...offline2 ? { offline: offline2 } : {}
23957
23859
  };
23958
23860
  }
23959
- function cmdStudioRename(id, name) {
23960
- done(renameStudio(id, name));
23961
- say(`renamed ${id} to "${name.trim()}"`);
23962
- return { id, name: name.trim() };
23963
- }
23964
- function cmdStudioDiagram(id, card) {
23965
- const flow = found(id);
23861
+ function cmdStudioDiagram(id, card, folder) {
23862
+ const files = folder ? readStudioFolder(path76.resolve(folder)) : null;
23863
+ const local = files ? parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE) : null;
23864
+ if (local && "problem" in local) die(local.problem, "bad-studio");
23865
+ const flow = local && "def" in local ? local.def : found(id);
23966
23866
  const cardId2 = Number(card);
23967
23867
  if (!Number.isInteger(cardId2) || !locate(cardId2)) die(`no card #${card} on this board`, "no-such-card");
23968
- const diagram = studioDiagram({ previews: previewMembers(flow), land: flow.land, scheduled: scheduledMembers(flow) }, (name) => {
23868
+ const diagram = files ? diagramFrom(files) : studioDiagram({ previews: previewMembers(found(id)), land: flow.land, scheduled: scheduledMembers(found(id)) }, (name) => {
23969
23869
  const agent = findSpecAgent(name);
23970
23870
  return agent ? { ...agent, after: agentAfter(name) } : null;
23971
23871
  });
23972
- const file = path77.join(ASSETS, String(cardId2), "studio.json");
23973
- fs76.mkdirSync(path77.dirname(file), { recursive: true });
23974
- fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
23872
+ const file = path76.join(ASSETS, String(cardId2), "studio.json");
23873
+ fs75.mkdirSync(path76.dirname(file), { recursive: true });
23874
+ fs75.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
23975
23875
  `);
23976
23876
  const tag = `<Studio src=".assets/${cardId2}/studio.json" label="${flow.name.replace(/"/g, "")}" />`;
23977
23877
  say(tag);
23978
23878
  return { file, tag, diagram };
23979
23879
  }
23980
23880
  function cmdStudioValidate(folder) {
23981
- const dir = path77.resolve(folder);
23982
- if (!fs76.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
23881
+ const dir = path76.resolve(folder);
23882
+ if (!fs75.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
23983
23883
  const files = readStudioFolder(dir);
23984
23884
  const read3 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
23985
23885
  const def = "def" in read3 ? read3.def : null;
@@ -23995,69 +23895,92 @@ function cmdStudioValidate(folder) {
23995
23895
  const problems = studioFilesProblems(files).map((p) => `${p.file} ${p.reason}`);
23996
23896
  if (problems.length) die(problems.map((p) => `! ${p}`).join("\n"), { kind: "studio-problems", bare: true, problems });
23997
23897
  say(`${folder}: no problems`);
23998
- return { folder: dir, problems };
23898
+ const checked = checkStudioFiles(files);
23899
+ const fingerprint = checked.ok ? crypto6.createHash("sha256").update(hashInput({ ...checked.files, ...files[VERSION_FILE] ? { [VERSION_FILE]: files[VERSION_FILE] } : {} })).digest("hex") : null;
23900
+ return { folder: dir, problems, fingerprint };
23999
23901
  }
24000
23902
  async function cmdStudioPull(id, folder) {
24001
23903
  const cloudId = cloudIdOf(id);
24002
23904
  if (!cloudId) found(id);
24003
- const dir = path77.resolve(folder ?? id);
24004
- if (fs76.existsSync(dir) && fs76.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
23905
+ const dir = path76.resolve(folder ?? id);
23906
+ if (fs75.existsSync(dir) && fs75.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
24005
23907
  const read3 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
24006
23908
  if (!read3.ok) die(read3.error, read3.code === "not_found" ? "no-such-studio" : "cloud-refused");
24007
23909
  const { version, files } = read3.value;
24008
23910
  for (const [file, text4] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version) })) {
24009
- const full = path77.join(dir, ...file.split("/"));
24010
- fs76.mkdirSync(path77.dirname(full), { recursive: true });
23911
+ const full = path76.join(dir, ...file.split("/"));
23912
+ fs75.mkdirSync(path76.dirname(full), { recursive: true });
24011
23913
  const data = isAboutFile(file) && !file.endsWith(".md") && /^data:[^;]+;base64,/.exec(text4);
24012
- fs76.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
23914
+ fs75.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
24013
23915
  }
24014
23916
  const shown = folder ?? `./${id}`;
24015
23917
  say(`Pulled ${id} v${version} into ${shown}.`);
24016
23918
  return { id, version, folder: dir };
24017
23919
  }
23920
+ function publicationFiles(dir) {
23921
+ const checked = checkStudioFiles(readStudioFolder(dir));
23922
+ if (!checked.ok) die(`${checked.file} ${checked.reason}`, "bad-studio");
23923
+ return checked.files;
23924
+ }
23925
+ async function publishFolder(dir, route2, body, requestId) {
23926
+ const pendingFile = path76.join(dir, ".publication.json");
23927
+ const hash2 = crypto6.createHash("sha256").update(JSON.stringify({ route: route2, files: body.files, workspace: body.workspace })).digest("hex");
23928
+ let held4;
23929
+ try {
23930
+ held4 = JSON.parse(fs75.readFileSync(pendingFile, "utf8"));
23931
+ } catch {
23932
+ }
23933
+ if (requestId && held4?.requestId === requestId && held4.hash !== hash2) die("This request ID already names different files; use a new request ID.", "bad-args");
23934
+ const replay = held4?.hash === hash2 && held4.route === route2 && (!requestId || held4.requestId === requestId) && (body.expectedVersion === held4.body.expectedVersion || body.expectedVersion === held4.resultVersion);
23935
+ const pending = replay ? held4 : { requestId: requestId ?? crypto6.randomUUID(), hash: hash2, body, route: route2 };
23936
+ fs75.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
23937
+ const res = await call(route2 === "/v1/studios" ? "POST" : "PATCH", route2, pending.body, pending.requestId);
23938
+ if (!res.ok) die(res.error, res.code === "version_conflict" || res.code === "conflict" ? "studio-moved" : "cloud-refused");
23939
+ const { id, version } = res.value;
23940
+ pending.resultVersion = version;
23941
+ fs75.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
23942
+ fs75.writeFileSync(path76.join(dir, VERSION_FILE), versionText(id, version));
23943
+ say(`Saved ${studioName(id)} v${version}. New tasks take it.`);
23944
+ return { id, version, changed: true, requestId: pending.requestId };
23945
+ }
23946
+ async function cmdStudioCreate(folder, opts) {
23947
+ if (!opts.requestId) die("--request-id is required", "bad-args");
23948
+ const dir = path76.resolve(folder);
23949
+ const files = publicationFiles(dir);
23950
+ const workspace2 = opts.workspace ?? (await cloudScope()).workspace;
23951
+ return publishFolder(dir, "/v1/studios", { files, workspace: workspace2 }, opts.requestId);
23952
+ }
24018
23953
  async function cmdStudioPush(folder, opts) {
24019
- const dir = path77.resolve(folder);
23954
+ const dir = path76.resolve(folder);
24020
23955
  let pulled = null;
24021
23956
  try {
24022
- pulled = JSON.parse(fs76.readFileSync(path77.join(dir, VERSION_FILE), "utf8"));
23957
+ pulled = JSON.parse(fs75.readFileSync(path76.join(dir, VERSION_FILE), "utf8"));
24023
23958
  } catch {
24024
23959
  }
24025
- if (!pulled?.id || !Number.isInteger(pulled.version)) die(`${folder} was not written by \`akb studio pull\``, "bad-args");
24026
- const { id: cloudId, version } = pulled;
24027
- const id = studioName(cloudId);
24028
- const readOnly2 = () => die(`${id} is not this workspace's own; copy it on the web first.`, "studio-read-only");
24029
- if (cloudId.startsWith("wf_builtin_")) readOnly2();
24030
- const read3 = readStudioFolder(dir);
24031
- const problems = studioFilesProblems(read3).map((p) => `${p.file} ${p.reason}`);
24032
- if (problems.length) die(problems.map((p) => `! ${p}`).join("\n"), { kind: "bad-studio", bare: true, problems });
24033
- const checked = checkStudioFiles(read3);
24034
- const { files } = checked;
24035
- const now = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
24036
- if (!now.ok) die(now.error, now.code === "not_found" ? "no-such-studio" : "cloud-refused");
24037
- if (now.value.version !== version) die(`${id} is at v${now.value.version} now; pull again and redo the change.`, "studio-moved");
24038
- if (JSON.stringify(files) === JSON.stringify(Object.fromEntries(Object.entries(now.value.files).filter(([f]) => f !== VERSION_FILE).sort()))) {
24039
- say(`${id} is unchanged (v${version}).`);
24040
- return { id, version, changed: false, ...opts.dryRun ? { dryRun: true } : {} };
23960
+ if (!pulled?.id || !Number.isInteger(pulled.version) || pulled.version < 1) die(`${folder} has no valid version.json; pull again.`, "bad-args");
23961
+ const { id, version } = pulled;
23962
+ if (id.startsWith("wf_builtin_")) die("Copy this studio before editing it.", "studio-read-only");
23963
+ const files = publicationFiles(dir);
23964
+ if (!fs75.existsSync(path76.join(dir, ".publication.json")) && !opts.requestId) {
23965
+ const now = await call("GET", `/v1/studios/${encodeURIComponent(id)}`);
23966
+ if (now.ok && now.value.version === version && JSON.stringify(files) === JSON.stringify(Object.fromEntries(Object.entries(now.value.files).filter(([f]) => f !== VERSION_FILE).sort()))) {
23967
+ say(`${studioName(id)} is unchanged (v${version}).`);
23968
+ return { id: studioName(id), version, changed: false, ...opts.dryRun ? { dryRun: true } : {} };
23969
+ }
24041
23970
  }
24042
23971
  if (opts.dryRun) {
24043
- say(`${id} would push v${version + 1}.`);
24044
- return { id, version: version + 1, changed: true, dryRun: true };
24045
- }
24046
- const res = await call("PATCH", `/v1/studios/${encodeURIComponent(cloudId)}`, { files });
24047
- if (!res.ok) {
24048
- if (res.code === "read_only" || res.code === "not_found") readOnly2();
24049
- die(res.error, res.code === "bad_request" || res.code === "payload_too_large" ? "bad-studio" : "cloud-refused");
23972
+ const now = cloudOk(await call("GET", `/v1/studios/${encodeURIComponent(id)}`));
23973
+ if (now.version !== version) die(`The studio is at v${now.version}; pull again.`, "studio-moved");
23974
+ say(`${studioName(id)} would push v${version + 1}.`);
23975
+ return { id: studioName(id), version: version + 1, changed: true, dryRun: true };
24050
23976
  }
24051
- const next = res.value.version;
24052
- fs76.writeFileSync(path77.join(dir, VERSION_FILE), versionText(cloudId, next));
24053
- say(`Pushed ${id} v${next}. New tasks take it.`);
24054
- return { id, version: next, changed: true };
23977
+ return publishFolder(dir, `/v1/studios/${encodeURIComponent(id)}`, { files, expectedVersion: version }, opts.requestId);
24055
23978
  }
24056
23979
  function noteText({ file, text: text4 }) {
24057
23980
  if (file !== void 0 && text4 !== void 0) die("pass --file or --text, not both", "bad-args");
24058
23981
  if (file !== void 0) {
24059
23982
  try {
24060
- return fs76.readFileSync(file, "utf8").trim();
23983
+ return fs75.readFileSync(file, "utf8").trim();
24061
23984
  } catch {
24062
23985
  die(`can't read ${file}`, "bad-args");
24063
23986
  }
@@ -24122,7 +24045,7 @@ async function cmdStudioInstructions(agent, opts) {
24122
24045
  say(rule ? `saved ${agent}'s instructions (${scope === "project" ? "this project" : "every project"})` : `cleared ${agent}'s instructions`);
24123
24046
  return { agent, rule, scope };
24124
24047
  }
24125
- var found, done, names2, previewNames, cloudIdOf, enc2;
24048
+ var found, names2, previewNames, cloudIdOf, enc2;
24126
24049
  var init_studio2 = __esm({
24127
24050
  "../cli/src/commands/studio.ts"() {
24128
24051
  "use strict";
@@ -24148,9 +24071,6 @@ var init_studio2 = __esm({
24148
24071
  }
24149
24072
  return flow;
24150
24073
  };
24151
- done = (res) => {
24152
- if (!res.ok) die(res.error ?? "the board refused that change", res.reason === "studioReadOnly" ? "studio-read-only" : void 0);
24153
- };
24154
24074
  names2 = (rows) => rows.map((h) => `${h.agent}${h.off ? " (off)" : ""}`).join(", ");
24155
24075
  previewNames = (rows) => rows.map((h) => `${names2([h])}${agentAfter(h.agent).length ? ` (after ${agentAfter(h.agent).join(", ")})` : ""}`).join(", ");
24156
24076
  cloudIdOf = (id) => cloudFlows().find((f) => studioName(f.cloudId) === id)?.cloudId;
@@ -24282,8 +24202,8 @@ var init_complete = __esm({
24282
24202
  });
24283
24203
 
24284
24204
  // ../cli/src/lib/agent/approve.ts
24285
- import fs77 from "node:fs";
24286
- import path78 from "node:path";
24205
+ import fs76 from "node:fs";
24206
+ import path77 from "node:path";
24287
24207
  function approvalRequest(req) {
24288
24208
  const id = req.id;
24289
24209
  const card = id === void 0 ? null : findCard(id);
@@ -24301,12 +24221,12 @@ function advancePhase(id) {
24301
24221
  const card = findCard(id);
24302
24222
  const found2 = locate(id);
24303
24223
  if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
24304
- const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
24305
- const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
24224
+ const file = found2.kind === "group" ? path77.join(found2.target, "root.md") : found2.target;
24225
+ const { meta, body } = parseFrontmatter(fs76.readFileSync(file, "utf8"));
24306
24226
  if (!meta) return { error: `#${id} has no frontmatter` };
24307
24227
  meta.phase = card.stage + 1;
24308
24228
  meta.status = "todo";
24309
- fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
24229
+ fs76.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
24310
24230
  return null;
24311
24231
  }
24312
24232
  var init_approve = __esm({
@@ -24429,16 +24349,16 @@ var init_start = __esm({
24429
24349
  });
24430
24350
 
24431
24351
  // ../cli/src/lib/agent/task-chats.ts
24432
- import fs78 from "node:fs";
24433
- import path79 from "node:path";
24352
+ import fs77 from "node:fs";
24353
+ import path78 from "node:path";
24434
24354
  function taskChatFile(task, home3) {
24435
24355
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
24436
- return path79.join(taskChatsDir(home3), `${task}.jsonl`);
24356
+ return path78.join(taskChatsDir(home3), `${task}.jsonl`);
24437
24357
  }
24438
24358
  function readTaskChat(task, home3) {
24439
24359
  let text4;
24440
24360
  try {
24441
- text4 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
24361
+ text4 = fs77.readFileSync(taskChatFile(task, home3), "utf8");
24442
24362
  } catch {
24443
24363
  return [];
24444
24364
  }
@@ -24459,13 +24379,13 @@ var init_task_chats = __esm({
24459
24379
  "use strict";
24460
24380
  init_home();
24461
24381
  TASK = /^[\w-]{1,100}$/;
24462
- taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
24382
+ taskChatsDir = (home3 = machineHome()) => path78.join(home3, "chats");
24463
24383
  }
24464
24384
  });
24465
24385
 
24466
24386
  // ../cli/src/lib/agent/memory-review.ts
24467
- import fs79 from "node:fs";
24468
- import path80 from "node:path";
24387
+ import fs78 from "node:fs";
24388
+ import path79 from "node:path";
24469
24389
  function taskChatsToReview(tasks) {
24470
24390
  const out = [];
24471
24391
  for (const ref of [...new Set(tasks)]) {
@@ -24487,8 +24407,8 @@ function readArchived2(id) {
24487
24407
  const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
24488
24408
  if (!found2) return null;
24489
24409
  try {
24490
- const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
24491
- const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
24410
+ const file = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
24411
+ const { meta, body } = parseFrontmatter(fs78.readFileSync(file, "utf8"));
24492
24412
  if (!meta) return null;
24493
24413
  return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
24494
24414
  } catch {
@@ -24557,17 +24477,17 @@ var init_memory_review = __esm({
24557
24477
  });
24558
24478
 
24559
24479
  // ../cli/src/lib/agent/dismissal-review.ts
24560
- import fs80 from "node:fs";
24561
- import path81 from "node:path";
24480
+ import fs79 from "node:fs";
24481
+ import path80 from "node:path";
24562
24482
  function rejectionsToReview() {
24563
- const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
24564
- if (!fs80.existsSync(dir)) return [];
24483
+ const dir = path80.join(ARCHIVE, REJECTIONS_TO_REVIEW);
24484
+ if (!fs79.existsSync(dir)) return [];
24565
24485
  const found2 = [];
24566
24486
  for (const file of walkMd(dir)) {
24567
24487
  const id = archivedId(file);
24568
24488
  if (id === null) continue;
24569
24489
  try {
24570
- const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
24490
+ const { meta } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
24571
24491
  if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
24572
24492
  found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
24573
24493
  } catch {
@@ -24597,7 +24517,7 @@ function citedSources(text4) {
24597
24517
  function withdrawnSources() {
24598
24518
  const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
24599
24519
  try {
24600
- return citedSources(fs80.readFileSync(file, "utf8"));
24520
+ return citedSources(fs79.readFileSync(file, "utf8"));
24601
24521
  } catch {
24602
24522
  return [];
24603
24523
  }
@@ -24622,8 +24542,8 @@ var init_dismissal_review = __esm({
24622
24542
  });
24623
24543
 
24624
24544
  // ../cli/src/lib/agent/flow.ts
24625
- import fs81 from "node:fs";
24626
- import path82 from "node:path";
24545
+ import fs80 from "node:fs";
24546
+ import path81 from "node:path";
24627
24547
  function readCard2(id, home3 = "board") {
24628
24548
  const pending = activeDelivery(id)?.completions?.some((c) => !c.finished);
24629
24549
  const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
@@ -24633,10 +24553,10 @@ function readCard2(id, home3 = "board") {
24633
24553
  { kind: "card-not-found", id }
24634
24554
  );
24635
24555
  }
24636
- const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
24556
+ const file = found2.kind === "group" ? path81.join(found2.target, "root.md") : found2.target;
24637
24557
  let text4;
24638
24558
  try {
24639
- text4 = fs81.readFileSync(file, "utf8");
24559
+ text4 = fs80.readFileSync(file, "utf8");
24640
24560
  } catch {
24641
24561
  die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
24642
24562
  }
@@ -25379,15 +25299,15 @@ var init_follow = __esm({
25379
25299
  function queueCompleted(openBefore) {
25380
25300
  const before = new Set(openBefore);
25381
25301
  if (!before.size) return false;
25382
- let done2;
25302
+ let done;
25383
25303
  try {
25384
- done2 = readArchive().cards.filter((card) => before.has(card.id) && !card.rejected).map((card) => card.id);
25304
+ done = readArchive().cards.filter((card) => before.has(card.id) && !card.rejected).map((card) => card.id);
25385
25305
  } catch {
25386
25306
  return false;
25387
25307
  }
25388
25308
  const queue = reflectQueue();
25389
25309
  const covered = reflectedOn();
25390
- const fresh = done2.filter((id) => !queue.includes(id) && !covered.has(id)).reverse();
25310
+ const fresh = done.filter((id) => !queue.includes(id) && !covered.has(id)).reverse();
25391
25311
  if (!fresh.length) return false;
25392
25312
  queueReflect(fresh);
25393
25313
  return true;
@@ -25452,7 +25372,7 @@ __export(watch_exports, {
25452
25372
  watchRun: () => watchRun
25453
25373
  });
25454
25374
  import { spawn as spawn3 } from "node:child_process";
25455
- import fs82 from "node:fs";
25375
+ import fs81 from "node:fs";
25456
25376
  async function watchRun(sessionId, resume = startResume) {
25457
25377
  const spec = readSpec(sessionId);
25458
25378
  const run3 = peekRun(sessionId);
@@ -25488,11 +25408,11 @@ async function watchRun(sessionId, resume = startResume) {
25488
25408
  const record = claimed ?? run3;
25489
25409
  const sub = record.action === "sub";
25490
25410
  if (claim) await setCardStatus(claim.cardId, claim.status);
25491
- fs82.mkdirSync(SESSIONS_DIR, { recursive: true });
25492
- const logFile = fs82.createWriteStream(record.logPath, { flags: "a" });
25411
+ fs81.mkdirSync(SESSIONS_DIR, { recursive: true });
25412
+ const logFile = fs81.createWriteStream(record.logPath, { flags: "a" });
25493
25413
  logFile.on("error", () => {
25494
25414
  });
25495
- const eventsFile = fs82.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
25415
+ const eventsFile = fs81.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
25496
25416
  eventsFile.on("error", () => {
25497
25417
  });
25498
25418
  const event2 = (e) => eventsFile.write(`${JSON.stringify(e)}
@@ -25647,7 +25567,7 @@ async function watchRun(sessionId, resume = startResume) {
25647
25567
  [error] ${spawnError}`);
25648
25568
  });
25649
25569
  return await new Promise((resolve2) => {
25650
- let done2 = false;
25570
+ let done = false;
25651
25571
  let spoken;
25652
25572
  let silent = false;
25653
25573
  let waited = false;
@@ -25665,8 +25585,8 @@ async function watchRun(sessionId, resume = startResume) {
25665
25585
  };
25666
25586
  });
25667
25587
  const finish = async (code, wanted) => {
25668
- if (done2) return;
25669
- done2 = true;
25588
+ if (done) return;
25589
+ done = true;
25670
25590
  let asked = wanted;
25671
25591
  if (idle) clearTimeout(idle);
25672
25592
  await stopSubRuns(sessionId);
@@ -25894,17 +25814,17 @@ Cannot resume board repair: ${next.error}`;
25894
25814
  wakeUp();
25895
25815
  return;
25896
25816
  }
25897
- if (done2) return;
25817
+ if (done) return;
25898
25818
  giveUp(true);
25899
25819
  };
25900
25820
  process.on("SIGTERM", askToStop);
25901
25821
  process.on("SIGINT", askToStop);
25902
25822
  touch = () => {
25903
- if (done2 || !silenceMs) return;
25823
+ if (done || !silenceMs) return;
25904
25824
  if (idle) clearTimeout(idle);
25905
25825
  const background = client?.background?.() ?? renderer?.background?.() ?? 0;
25906
25826
  idle = setTimeout(() => {
25907
- if (done2 || stopped2 || silent) return;
25827
+ if (done || stopped2 || silent) return;
25908
25828
  if (liveSubRuns(sessionId).length) {
25909
25829
  touch();
25910
25830
  return;
@@ -26063,8 +25983,8 @@ var init_watch = __esm({
26063
25983
  });
26064
25984
 
26065
25985
  // ../cli/src/commands/run.ts
26066
- import fs83 from "node:fs";
26067
- import path83 from "node:path";
25986
+ import fs82 from "node:fs";
25987
+ import path82 from "node:path";
26068
25988
  async function cmdStartRun(action, args, opts, program2 = "akb") {
26069
25989
  const { req, follow: follow2, print } = readRequest(action, args, opts);
26070
25990
  if (!print && (action === "approve" || action === "implement")) {
@@ -26284,7 +26204,7 @@ async function cmdSubStart(words, opts) {
26284
26204
  let prompt = words.join(" ");
26285
26205
  if (opts.file) {
26286
26206
  try {
26287
- prompt = fs83.readFileSync(path83.resolve(opts.file), "utf8");
26207
+ prompt = fs82.readFileSync(path82.resolve(opts.file), "utf8");
26288
26208
  } catch {
26289
26209
  die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
26290
26210
  }
@@ -26594,7 +26514,7 @@ var init_run = __esm({
26594
26514
  WAIT_MS2 = 9e4;
26595
26515
  WAIT_POLL_MS = 1e3;
26596
26516
  follow = { pollMs: 2e3, idleMs: 10 * 6e4 };
26597
- pause = (ms) => new Promise((done2) => setTimeout(done2, ms));
26517
+ pause = (ms) => new Promise((done) => setTimeout(done, ms));
26598
26518
  MARK2 = {
26599
26519
  running: "\xB7",
26600
26520
  done: "\u2713",
@@ -26652,7 +26572,7 @@ var init_signals = __esm({
26652
26572
  });
26653
26573
 
26654
26574
  // ../cli/src/commands/triage.ts
26655
- import fs84 from "node:fs";
26575
+ import fs83 from "node:fs";
26656
26576
  async function cmdTriageAdd(opts) {
26657
26577
  const title = (opts.title ?? "").trim();
26658
26578
  if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
@@ -26662,7 +26582,7 @@ async function cmdTriageAdd(opts) {
26662
26582
  let body = opts.text;
26663
26583
  if (opts.file !== void 0) {
26664
26584
  try {
26665
- body = fs84.readFileSync(opts.file, "utf8");
26585
+ body = fs83.readFileSync(opts.file, "utf8");
26666
26586
  } catch {
26667
26587
  die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
26668
26588
  }
@@ -26671,10 +26591,10 @@ async function cmdTriageAdd(opts) {
26671
26591
  die('the item has to say something: --text ".." , or --file <path> for a longer one', { kind: "needs-input" });
26672
26592
  }
26673
26593
  const agent = runAgent();
26674
- const done2 = addToInbox({ title, text: body, source: opts.source, slug: opts.slug, studio, ...agent ? { agent } : {} });
26675
- if (!done2.ok) die(done2.error, { kind: "triage-item-refused" });
26676
- say(`added to triage: ${done2.signal.relPath}`);
26677
- return { title: done2.signal.title, source_id: done2.signal.sourceId, file: done2.signal.relPath };
26594
+ const done = addToInbox({ title, text: body, source: opts.source, slug: opts.slug, studio, ...agent ? { agent } : {} });
26595
+ if (!done.ok) die(done.error, { kind: "triage-item-refused" });
26596
+ say(`added to triage: ${done.signal.relPath}`);
26597
+ return { title: done.signal.title, source_id: done.signal.sourceId, file: done.signal.relPath };
26678
26598
  }
26679
26599
  function cmdTriageCheck(sourceId) {
26680
26600
  const said2 = sourceId.trim();
@@ -26975,15 +26895,12 @@ List trigger conditions: ${raw} previews --triggers --json`).action(async functi
26975
26895
  useBoard(resolveBoard("components", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint }), ctx.dir !== null);
26976
26896
  await boardless(this, cli, () => cmdComponents(this.opts()));
26977
26897
  });
26978
- const studio = noun("studio", "check a studio folder, or rename a draft or draw a diagram inside a run");
26898
+ const studio = noun("studio", "check a studio folder or draw its diagram");
26979
26899
  withShared(studio.command("validate")).argument("<folder>", "a studio folder: STUDIO.md and agents/").summary("report every problem in a studio folder; agents it names but lacks are read from the board").action(async function(folder) {
26980
26900
  await onBoard2(this, cli, () => cmdStudioValidate(folder));
26981
26901
  });
26982
- withShared(studio.command("rename")).argument("<id>", "the draft, from `studio list`").argument("<name...>", "what to call it now").summary("rename the Studio builder draft. Only inside that task's run.").action(async function(id, name) {
26983
- await onBoard2(this, cli, () => cmdStudioRename(id, name.join(" ")));
26984
- });
26985
- withShared(studio.command("diagram")).argument("<id>", "the studio, from `studio list`").argument("<card>", "the card whose asset folder gets studio.json").summary("write the studio's diagram to .assets/<card>/studio.json and print the <Studio> tag that shows it").action(async function(id, card) {
26986
- await onBoard2(this, cli, () => cmdStudioDiagram(id, card));
26902
+ withShared(studio.command("diagram")).argument("<id-or-card>", "studio id, or card number with --folder").argument("[card]", "the card whose asset folder gets studio.json").option("--folder <folder>", "read a local studio folder").summary("write the studio's diagram to .assets/<card>/studio.json and print the <Studio> tag that shows it").action(async function(id, card) {
26903
+ await onBoard2(this, cli, () => cmdStudioDiagram(id, this.opts().folder ? id : card, this.opts().folder));
26987
26904
  });
26988
26905
  }
26989
26906
  function declareRuns(program2, cli) {
@@ -27118,7 +27035,7 @@ function declareRuns(program2, cli) {
27118
27035
  "Every card runs through one studio, kept in Cloud: the built-ins and the studios this workspace installed or made. To change one of this workspace's own: `pull` it into a folder, edit, `push`. New tasks take the new version; a task already started keeps its own. `akb guide update-studio` has the whole flow."
27119
27036
  ).allowExcessArguments().allowUnknownOption().action(async function() {
27120
27037
  const word = this.args[0];
27121
- if (word === "rename" || word === "diagram") {
27038
+ if (word === "diagram") {
27122
27039
  this.error(`\`${cli.program} studio ${word}\` is now \`${cli.program} raw studio ${word}\`.`, { code: "commander.unknownCommand" });
27123
27040
  }
27124
27041
  if (word) this.error(`unknown command '${word}'`, { code: "commander.unknownCommand" });
@@ -27131,7 +27048,10 @@ function declareRuns(program2, cli) {
27131
27048
  flowWord("pull").argument("<id>", "the studio, from `studio list`").argument("[folder]", "where to write it, empty or new; default ./<id>").summary("write the studio's current version into a folder to edit").action(async function(id, folder) {
27132
27049
  await onBoard2(this, cli, () => cmdStudioPull(id, folder));
27133
27050
  });
27134
- flowWord("push").argument("<folder>", "a folder `studio pull` wrote").option("--dry-run", "check the folder and print what would happen, saving nothing").summary("save the edited folder as the studio's next version, which new tasks take").action(async function(folder) {
27051
+ flowWord("create").argument("<folder>", "the studio files to create").requiredOption("--request-id <id>", "the publication request, reused on retry").option("--workspace <id>", "the target workspace; otherwise use the linked project").summary("create a workspace studio from a local folder").action(async function(folder) {
27052
+ await boardless(this, cli, () => cmdStudioCreate(folder, this.opts()));
27053
+ });
27054
+ flowWord("push").argument("<folder>", "a folder `studio pull` wrote").option("--request-id <id>", "reuse this publication request after a timeout").option("--dry-run", "check the folder and print what would happen, saving nothing").summary("save the edited folder as the studio's next version, which new tasks take").action(async function(folder) {
27135
27055
  await boardless(this, cli, () => cmdStudioPush(folder, this.opts()));
27136
27056
  });
27137
27057
  flowWord("rule").argument("<studio>", "a studio id from `akb studio list`").option("--text <text>", "the rules, for a one-liner; empty clears them").option("--file <path>", "the rules, as markdown written to a file first").summary("set a studio's rules \u2014 what every card on it follows \u2014 in the user's own words").description(
@@ -27333,15 +27253,15 @@ var init_agent2 = __esm({
27333
27253
  });
27334
27254
 
27335
27255
  // ../cli/src/kanban.ts
27336
- import fs87 from "node:fs";
27256
+ import fs86 from "node:fs";
27337
27257
  import { fileURLToPath as fileURLToPath4 } from "node:url";
27338
27258
 
27339
27259
  // ../cli/src/lib/cli/akb.ts
27340
27260
  init_agent2();
27341
27261
 
27342
27262
  // ../cli/src/lib/cli/setup.ts
27343
- import fs86 from "node:fs";
27344
- import path85 from "node:path";
27263
+ import fs85 from "node:fs";
27264
+ import path84 from "node:path";
27345
27265
  import { fileURLToPath as fileURLToPath3 } from "node:url";
27346
27266
 
27347
27267
  // ../cli/src/commands/update.ts
@@ -27355,8 +27275,8 @@ init_paths();
27355
27275
  init_memory();
27356
27276
  init_yaml2();
27357
27277
  init_version();
27358
- import fs85 from "node:fs";
27359
- import path84 from "node:path";
27278
+ import fs84 from "node:fs";
27279
+ import path83 from "node:path";
27360
27280
  import { spawnSync as spawnSync6 } from "node:child_process";
27361
27281
  var NAME = "wildcrane";
27362
27282
  var REPO = "https://github.com/wildcrane-ai/wildcrane";
@@ -27378,10 +27298,10 @@ var Report = class {
27378
27298
  for (const line of this.notes) say(` ! ${line}`);
27379
27299
  }
27380
27300
  };
27381
- var read2 = (file) => fs85.existsSync(file) ? fs85.readFileSync(file, "utf8") : null;
27301
+ var read2 = (file) => fs84.existsSync(file) ? fs84.readFileSync(file, "utf8") : null;
27382
27302
  function statOf(p) {
27383
27303
  try {
27384
- return fs85.lstatSync(p);
27304
+ return fs84.lstatSync(p);
27385
27305
  } catch {
27386
27306
  return null;
27387
27307
  }
@@ -27406,10 +27326,10 @@ async function cmdUpdate2(ctx) {
27406
27326
  return { updated: ctx.dir, from, to: SKILL_VERSION };
27407
27327
  }
27408
27328
  async function repairBoard(root2, report3, named2) {
27409
- const legacy2 = path84.join(root2, "docs", "kanban");
27410
- const kept2 = path84.join(root2, ".akb", "kanban");
27411
- const board2 = named2 ?? (fs85.existsSync(legacy2) ? legacy2 : kept2);
27412
- if (!fs85.existsSync(board2)) {
27329
+ const legacy2 = path83.join(root2, "docs", "kanban");
27330
+ const kept2 = path83.join(root2, ".akb", "kanban");
27331
+ const board2 = named2 ?? (fs84.existsSync(legacy2) ? legacy2 : kept2);
27332
+ if (!fs84.existsSync(board2)) {
27413
27333
  report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
27414
27334
  return false;
27415
27335
  }
@@ -27440,20 +27360,20 @@ function moveRuntimes(root2, board2, report3) {
27440
27360
  }
27441
27361
  }
27442
27362
  function moveLegacyMemory(board2, report3) {
27443
- const memory = path84.join(board2, "memory");
27363
+ const memory = path83.join(board2, "memory");
27444
27364
  const moved = [];
27445
27365
  for (const name of MEMORY_FILES) {
27446
- const from = path84.join(board2, name);
27366
+ const from = path83.join(board2, name);
27447
27367
  const st = statOf(from);
27448
27368
  if (!st || !st.isFile()) continue;
27449
- fs85.mkdirSync(memory, { recursive: true });
27450
- const to = path84.join(memory, name);
27369
+ fs84.mkdirSync(memory, { recursive: true });
27370
+ const to = path83.join(memory, name);
27451
27371
  const there = read2(to);
27452
27372
  if (there === null) {
27453
- fs85.renameSync(from, to);
27373
+ fs84.renameSync(from, to);
27454
27374
  moved.push(name);
27455
27375
  } else if (there === read2(from)) {
27456
- fs85.rmSync(from);
27376
+ fs84.rmSync(from);
27457
27377
  moved.push(name);
27458
27378
  } else {
27459
27379
  report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
@@ -27462,23 +27382,23 @@ function moveLegacyMemory(board2, report3) {
27462
27382
  if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
27463
27383
  }
27464
27384
  function dropRecordFile(board2) {
27465
- const file = path84.join(board2, "record.csv");
27466
- if (!fs85.existsSync(file)) return null;
27467
- fs85.rmSync(file);
27385
+ const file = path83.join(board2, "record.csv");
27386
+ if (!fs84.existsSync(file)) return null;
27387
+ fs84.rmSync(file);
27468
27388
  return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
27469
27389
  }
27470
27390
  function dropModuleGoals(board2, report3) {
27471
- const memory = path84.join(board2, "memory");
27472
- if (!fs85.existsSync(memory)) return;
27473
- const root2 = read2(path84.join(memory, "goal.md"));
27391
+ const memory = path83.join(board2, "memory");
27392
+ if (!fs84.existsSync(memory)) return;
27393
+ const root2 = read2(path83.join(memory, "goal.md"));
27474
27394
  let dropped = 0;
27475
- for (const entry of fs85.readdirSync(memory, { withFileTypes: true })) {
27395
+ for (const entry of fs84.readdirSync(memory, { withFileTypes: true })) {
27476
27396
  if (!entry.isDirectory()) continue;
27477
- const file = path84.join(memory, entry.name, "goal.md");
27397
+ const file = path83.join(memory, entry.name, "goal.md");
27478
27398
  const text4 = read2(file);
27479
27399
  if (text4 === null) continue;
27480
27400
  if (text4 === root2 || text4.includes(UNFILLED) || !goalWords(text4)) {
27481
- fs85.rmSync(file);
27401
+ fs84.rmSync(file);
27482
27402
  dropped++;
27483
27403
  } else {
27484
27404
  report3.notes.push(
@@ -27500,10 +27420,10 @@ var PLAN_LEADS = {
27500
27420
  var GONE_LEADS = ["software-planner", "planner"];
27501
27421
  function planLeads(board2) {
27502
27422
  const leads = { ...PLAN_LEADS };
27503
- const root2 = path84.join(board2, "studios");
27504
- for (const entry of fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []) {
27423
+ const root2 = path83.join(board2, "studios");
27424
+ for (const entry of fs84.existsSync(root2) ? fs84.readdirSync(root2, { withFileTypes: true }) : []) {
27505
27425
  if (!entry.isDirectory()) continue;
27506
- const meta = splitFrontmatter(read2(path84.join(root2, entry.name, "STUDIO.md")) ?? "").meta;
27426
+ const meta = splitFrontmatter(read2(path83.join(root2, entry.name, "STUDIO.md")) ?? "").meta;
27507
27427
  const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
27508
27428
  const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
27509
27429
  const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
@@ -27512,30 +27432,30 @@ function planLeads(board2) {
27512
27432
  return leads;
27513
27433
  }
27514
27434
  function movePlanRules(board2, report3) {
27515
- const rules = path84.join(board2, "rules");
27435
+ const rules = path83.join(board2, "rules");
27516
27436
  const moved = [];
27517
27437
  for (const [id, leads] of Object.entries(planLeads(board2))) {
27518
27438
  for (const lead of leads) {
27519
- const from = path84.join(rules, `${lead}.md`);
27439
+ const from = path83.join(rules, `${lead}.md`);
27520
27440
  const rule = read2(from)?.trim();
27521
27441
  if (!rule) continue;
27522
- const to = path84.join(rules, "studios", `${id}.md`);
27442
+ const to = path83.join(rules, "studios", `${id}.md`);
27523
27443
  const there = read2(to)?.trim() ?? "";
27524
27444
  if (!there.includes(rule)) {
27525
- fs85.mkdirSync(path84.dirname(to), { recursive: true });
27526
- fs85.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
27445
+ fs84.mkdirSync(path83.dirname(to), { recursive: true });
27446
+ fs84.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
27527
27447
  `);
27528
27448
  moved.push(`${lead} \u2192 ${id}`);
27529
27449
  }
27530
27450
  }
27531
27451
  }
27532
- for (const lead of GONE_LEADS) fs85.rmSync(path84.join(rules, `${lead}.md`), { force: true });
27452
+ for (const lead of GONE_LEADS) fs84.rmSync(path83.join(rules, `${lead}.md`), { force: true });
27533
27453
  if (moved.length) report3.did.push(`made each plan agent's rule its studio's card rule (docs/kanban/rules/studios/): ${moved.join(", ")}`);
27534
27454
  }
27535
27455
  function noteOldStudios(board2, report3) {
27536
27456
  const old = (dir, file, keys) => {
27537
- const root2 = path84.join(board2, dir);
27538
- return (fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []).filter((e) => e.isDirectory() && keys.test(splitFrontmatter(read2(path84.join(root2, e.name, file)) ?? "").meta ?? "")).map((e) => `docs/kanban/${dir}/${e.name}/${file}`);
27457
+ const root2 = path83.join(board2, dir);
27458
+ return (fs84.existsSync(root2) ? fs84.readdirSync(root2, { withFileTypes: true }) : []).filter((e) => e.isDirectory() && keys.test(splitFrontmatter(read2(path83.join(root2, e.name, file)) ?? "").meta ?? "")).map((e) => `docs/kanban/${dir}/${e.name}/${file}`);
27539
27459
  };
27540
27460
  const files = [...old("studios", "STUDIO.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
27541
27461
  if (files.length) {
@@ -27545,7 +27465,7 @@ function noteOldStudios(board2, report3) {
27545
27465
  }
27546
27466
  }
27547
27467
  function checkConfig(board2, report3) {
27548
- const current = read2(path84.join(board2, "config.md"));
27468
+ const current = read2(path83.join(board2, "config.md"));
27549
27469
  if (!current) return;
27550
27470
  const added = missingConfigKeys(current);
27551
27471
  if (added.length) {
@@ -27555,7 +27475,7 @@ function checkConfig(board2, report3) {
27555
27475
  }
27556
27476
  }
27557
27477
  function checkModules(board2, report3) {
27558
- const map2 = read2(path84.join(board2, "modules.md"));
27478
+ const map2 = read2(path83.join(board2, "modules.md"));
27559
27479
  if (map2 && map2.includes(UNFILLED)) {
27560
27480
  report3.notes.push(
27561
27481
  "docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
@@ -27609,14 +27529,14 @@ function declareSetup(program2, cli) {
27609
27529
  program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
27610
27530
  const dirOption = (cmd) => cmd.option("--dir <path>", "the project to work on (default: the current folder)").option("--json", "answer as one JSON object instead of prose");
27611
27531
  const where = (cmd) => {
27612
- const dir = path85.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
27613
- if (!fs86.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
27532
+ const dir = path84.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
27533
+ if (!fs85.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
27614
27534
  return dir;
27615
27535
  };
27616
27536
  dirOption(program2.command("update")).summary("\u4FEE\u590D\u5DF2\u6709\u770B\u677F\u5E76\u68C0\u67E5 CLI \u65B0\u7248\u672C").description("\u4FEE\u590D\u5DF2\u6709\u770B\u677F\u5E76\u63D0\u793A CLI \u5347\u7EA7\u547D\u4EE4\u3002\u6CA1\u6709\u770B\u677F\u65F6\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002").action(async function() {
27617
27537
  const dir = where(this);
27618
27538
  const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
27619
- const board2 = named2 ? path85.resolve(cli.cwd, named2) : null;
27539
+ const board2 = named2 ? path84.resolve(cli.cwd, named2) : null;
27620
27540
  await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
27621
27541
  });
27622
27542
  program2.command("__rules", { hidden: true }).action(function() {
@@ -27661,7 +27581,7 @@ function invokedDirectly() {
27661
27581
  const entry = process.argv[1];
27662
27582
  if (!entry) return false;
27663
27583
  try {
27664
- return fs87.realpathSync(entry) === fs87.realpathSync(SELF2);
27584
+ return fs86.realpathSync(entry) === fs86.realpathSync(SELF2);
27665
27585
  } catch {
27666
27586
  return false;
27667
27587
  }