wildcrane 0.11.46 → 0.11.48

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