wildcrane-runner 0.6.45 → 0.6.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // ai4kanban 0.11.39 — built by runner/scripts/build.mjs. Do not edit.
2
+ // ai4kanban 0.11.40 — built by runner/scripts/build.mjs. Do not edit.
3
3
  import { createRequire as __ai4kanbanRequire } from 'node:module'
4
4
  const require = __ai4kanbanRequire(import.meta.url)
5
5
  var __create = Object.create;
@@ -3484,10 +3484,10 @@ function findRollout(threadId) {
3484
3484
  }
3485
3485
  for (const name of names3) {
3486
3486
  if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
3487
- const path85 = join(dir, name);
3487
+ const path86 = join(dir, name);
3488
3488
  try {
3489
- const at = statSync(path85).mtimeMs;
3490
- if (!newest2 || at > newest2.at) newest2 = { path: path85, at };
3489
+ const at = statSync(path86).mtimeMs;
3490
+ if (!newest2 || at > newest2.at) newest2 = { path: path86, at };
3491
3491
  } catch {
3492
3492
  }
3493
3493
  }
@@ -3495,11 +3495,11 @@ function findRollout(threadId) {
3495
3495
  return newest2?.path;
3496
3496
  }
3497
3497
  function readCodexRunFacts(threadId) {
3498
- const path85 = findRollout(threadId);
3499
- if (!path85) return void 0;
3498
+ const path86 = findRollout(threadId);
3499
+ if (!path86) return void 0;
3500
3500
  let raw;
3501
3501
  try {
3502
- raw = readFileSync(path85, "utf8");
3502
+ raw = readFileSync(path86, "utf8");
3503
3503
  } catch {
3504
3504
  return void 0;
3505
3505
  }
@@ -3627,8 +3627,8 @@ function renderCompleted(item) {
3627
3627
  const changes = Array.isArray(item.changes) ? item.changes : [];
3628
3628
  return changes.map((raw) => {
3629
3629
  const change2 = obj(raw);
3630
- const path85 = str(change2.path);
3631
- return path85 ? `\u23FA ${str(change2.kind) || "change"}(${path85})
3630
+ const path86 = str(change2.path);
3631
+ return path86 ? `\u23FA ${str(change2.kind) || "change"}(${path86})
3632
3632
  ` : "";
3633
3633
  }).join("");
3634
3634
  }
@@ -3890,10 +3890,10 @@ function readKimiRunFacts(sessionId) {
3890
3890
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
3891
3891
  let model;
3892
3892
  let holding = 0;
3893
- for (const { path: path85, main } of wireFiles(entry.sessionDir)) {
3893
+ for (const { path: path86, main } of wireFiles(entry.sessionDir)) {
3894
3894
  let raw;
3895
3895
  try {
3896
- raw = readFileSync2(path85, "utf8");
3896
+ raw = readFileSync2(path86, "utf8");
3897
3897
  } catch {
3898
3898
  continue;
3899
3899
  }
@@ -4207,8 +4207,8 @@ var init_package = __esm({
4207
4207
  "../cli/package.json"() {
4208
4208
  package_default = {
4209
4209
  name: "wildcrane",
4210
- version: "0.11.39",
4211
- akbContract: 10,
4210
+ version: "0.11.40",
4211
+ akbContract: 11,
4212
4212
  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.",
4213
4213
  keywords: [
4214
4214
  "kanban",
@@ -4284,8 +4284,8 @@ var init_version = __esm({
4284
4284
  import fs17 from "node:fs";
4285
4285
  function whereHint(update2, title) {
4286
4286
  const locations = Array.isArray(update2.locations) ? update2.locations : [];
4287
- const path85 = str(obj(locations[0]).path);
4288
- return path85 && !title.includes(path85) ? hint(path85) : "";
4287
+ const path86 = str(obj(locations[0]).path);
4288
+ return path86 && !title.includes(path86) ? hint(path86) : "";
4289
4289
  }
4290
4290
  function saidBy(update2) {
4291
4291
  const content = Array.isArray(update2.content) ? update2.content : [];
@@ -8563,7 +8563,7 @@ ${rest}`);
8563
8563
  }
8564
8564
  function legacyModuleDirs() {
8565
8565
  try {
8566
- return fs27.readdirSync(MEMORY, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== RESERVED_MEMORY_DIR && !isGlobalMemory(e.name)).map((e) => e.name);
8566
+ return fs27.readdirSync(MEMORY, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== RESERVED_MEMORY_DIR && e.name !== STUDIO_MEMORY_DIR && !isGlobalMemory(e.name)).map((e) => e.name);
8567
8567
  } catch {
8568
8568
  return [];
8569
8569
  }
@@ -8660,7 +8660,7 @@ ${rest}`);
8660
8660
  fs27.rmSync(goal, { force: true });
8661
8661
  return words ? `moved the goal to the top of ${rel(agentMemoryFile(PLANNER, "decisions.md"))}` : "removed the empty goal";
8662
8662
  }
8663
- var isGlobalMemory, PLANNER, PLANNER_MEMORY_FILES, BOARD_MEMORY_FILES, STARTERS, onlyStarter, unraw, setOf, RESERVED_MEMORY_DIR, KEPT_MEMORY_FOLDERS, agentMemoryDir, agentMemoryFile, writtenMemoryNames, memoryNamesOf, agentMemoryFiles, legacyAgentMemoryFile, HEADINGS, HEADING_RE, stripHeading, FOLDED_UNDER, moveMemory, RESERVED_MODULE_NAMES, isModule, moduleMemoryFile, plannerCopies, memoryFile, ENTRY_RE, entriesOf2, demote, promote, PRODUCT_STARTER, SEEDED_GOAL_PARAGRAPHS;
8663
+ var isGlobalMemory, PLANNER, PLANNER_MEMORY_FILES, BOARD_MEMORY_FILES, STARTERS, onlyStarter, unraw, setOf, RESERVED_MEMORY_DIR, STUDIO_MEMORY_DIR, KEPT_MEMORY_FOLDERS, agentMemoryDir, agentMemoryFile, writtenMemoryNames, memoryNamesOf, agentMemoryFiles, legacyAgentMemoryFile, HEADINGS, HEADING_RE, stripHeading, FOLDED_UNDER, moveMemory, RESERVED_MODULE_NAMES, isModule, moduleMemoryFile, plannerCopies, memoryFile, ENTRY_RE, entriesOf2, demote, promote, PRODUCT_STARTER, SEEDED_GOAL_PARAGRAPHS;
8664
8664
  var init_memory = __esm({
8665
8665
  "../cli/src/lib/memory.ts"() {
8666
8666
  "use strict";
@@ -8707,6 +8707,7 @@ edits here do not last.
8707
8707
  unraw = (text4) => text4.trim().replace("`akb raw ", "`akb ");
8708
8708
  setOf = (names3) => Object.fromEntries(names3.map((name) => [name, STARTERS[name]]));
8709
8709
  RESERVED_MEMORY_DIR = "agents";
8710
+ STUDIO_MEMORY_DIR = "studios";
8710
8711
  KEPT_MEMORY_FOLDERS = { "hyperframes-editor": "video-assets" };
8711
8712
  agentMemoryDir = (agent) => path29.join(AGENT_MEMORY, KEPT_MEMORY_FOLDERS[agent] ?? agent);
8712
8713
  agentMemoryFile = (agent, name) => path29.join(agentMemoryDir(agent), name);
@@ -8812,11 +8813,12 @@ function specAgentInstructions(agent, entries = specAgentEntries()) {
8812
8813
  function agentFilesBlock(agent) {
8813
8814
  if (!agent.files.length) return "";
8814
8815
  const dir = agent.dir;
8816
+ const studio = dir ? "" : agentStudio(agent.name);
8815
8817
  return [
8816
8818
  "Read one only when the work calls for it:",
8817
8819
  "",
8818
8820
  ...agent.files.map(
8819
- (f) => dir ? `- \`${rel(path30.join(dir, f))}\`` : `- \`${f}\` \u2014 \`${rawMove(`agent-file ${agent.name} ${f}`)}\``
8821
+ (f) => dir ? `- \`${rel(path30.join(dir, f))}\`` : `- \`${f}\` \u2014 \`${rawMove(studio ? `file ${studio} agents/${agent.name}/${f}` : `agent-file ${agent.name} ${f}`)}\``
8820
8822
  )
8821
8823
  ].join("\n");
8822
8824
  }
@@ -9192,8 +9194,8 @@ var init_roles = __esm({
9192
9194
  });
9193
9195
 
9194
9196
  // ../cli/src/lib/shared/board-files.ts
9195
- function studioRenamed(path85, content) {
9196
- const to = path85.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
9197
+ function studioRenamed(path86, content) {
9198
+ const to = path86.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
9197
9199
  if (!to.endsWith(".md")) return { path: to, content };
9198
9200
  if (to.startsWith("studios/")) return { path: to, content: content.replace(/^(icon:\s*["']?)workflow(-kit)?(["']?\s*)$/gm, "$1studio$2$3") };
9199
9201
  const front = /^(?:todo|triage)\//.test(to) ? /^---\r?\n[\s\S]*?\r?\n---/.exec(content)?.[0] : void 0;
@@ -9499,7 +9501,7 @@ function readTranslations(raw) {
9499
9501
  }
9500
9502
  return out;
9501
9503
  }
9502
- function memoryPaths(raw) {
9504
+ function memoryPaths(raw, folder = "memory/agents/<name>/") {
9503
9505
  if (raw === void 0) return [];
9504
9506
  const block = map(raw);
9505
9507
  const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
@@ -9511,7 +9513,7 @@ function memoryPaths(raw) {
9511
9513
  }
9512
9514
  const paths = [...new Set(list.map((v) => v.trim()))];
9513
9515
  const outside = paths.find((p) => p.startsWith("/") || p.includes("\\") || p.split("/").some((part) => part === ".." || part === "."));
9514
- if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`memory/agents/<name>/\``;
9516
+ if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
9515
9517
  return paths;
9516
9518
  }
9517
9519
  var OLD_ROLE_KEYS, AGENT_NAME, SCHEDULE_READS, isScheduleReads, names, str3, map;
@@ -9602,6 +9604,8 @@ function parseStudioFile(id, source, from) {
9602
9604
  if (!agent || scheduled.some((s) => s.agent === agent)) continue;
9603
9605
  scheduled.push({ agent, ...text3(row.cadence) ? { cadence: text3(row.cadence) } : {} });
9604
9606
  }
9607
+ const workspace2 = memoryPaths(raw.memoryFiles, `memory/studios/${id}/`);
9608
+ if (typeof workspace2 === "string") return { problem: `${from}: declares ${workspace2}` };
9605
9609
  const names3 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said2]) => [lang, text3(said2)]).filter(([, said2]) => said2));
9606
9610
  return {
9607
9611
  def: {
@@ -9615,6 +9619,7 @@ function parseStudioFile(id, source, from) {
9615
9619
  previews,
9616
9620
  land,
9617
9621
  scheduled,
9622
+ ...workspace2.length ? { memoryFiles: { workspace: workspace2 } } : {},
9618
9623
  rules: body.trim()
9619
9624
  }
9620
9625
  };
@@ -9624,6 +9629,7 @@ var init_studio_def = __esm({
9624
9629
  "../cli/src/lib/agent/studio-def.ts"() {
9625
9630
  "use strict";
9626
9631
  init_icon();
9632
+ init_parse();
9627
9633
  init_yaml2();
9628
9634
  init_spec_agent_names();
9629
9635
  init_yaml();
@@ -9655,7 +9661,12 @@ function studioDiagram(def, agentOf2) {
9655
9661
  const after2 = (name) => (agentOf2(name)?.after ?? []).filter((other) => previews.includes(other));
9656
9662
  return {
9657
9663
  version: 1,
9658
- rounds: stagesOf(previews, after2).map((round) => round.map(step)),
9664
+ rounds: stagesOf(previews, after2).map(
9665
+ (round) => round.map((name) => {
9666
+ const waits = after2(name);
9667
+ return waits.length ? { ...step(name), after: waits } : step(name);
9668
+ })
9669
+ ),
9659
9670
  land: def.land.filter((h) => !h.off).map((h) => step(h.agent)),
9660
9671
  scheduled: def.scheduled.map((s) => ({ ...step(s.agent), ...s.cadence ? { cadence: s.cadence } : {} }))
9661
9672
  };
@@ -9723,7 +9734,7 @@ function inspect(value, official) {
9723
9734
  if (size > FILE_LIMITS.file) return fail(file, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
9724
9735
  total += size;
9725
9736
  if (total > FILE_LIMITS.total) return fail("files", `are larger than ${FILE_LIMITS.total / KB / KB} MB together`, true);
9726
- if (file === STUDIO_FILE) continue;
9737
+ if (file === STUDIO_FILE || file === CARD_TEMPLATE_FILE) continue;
9727
9738
  if (official && file === MCP_FILE) {
9728
9739
  const problem = mcpProblem(text4);
9729
9740
  if (problem) fail(file, problem);
@@ -9735,9 +9746,10 @@ function inspect(value, official) {
9735
9746
  else skills.add(file.split("/")[1]);
9736
9747
  continue;
9737
9748
  }
9749
+ if (isSharedFile(file)) continue;
9738
9750
  const at = folderPath(file, "agents");
9739
9751
  if (!at) {
9740
- fail(file, `is neither ${STUDIO_FILE} nor inside agents/<name>/`);
9752
+ fail(file, `is neither ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, shared/ nor inside agents/<name>/`);
9741
9753
  continue;
9742
9754
  }
9743
9755
  if (!folders2.has(at[0])) folders2.set(at[0], /* @__PURE__ */ new Map());
@@ -9775,7 +9787,7 @@ function inspect(value, official) {
9775
9787
  }
9776
9788
  return { problems, def, files };
9777
9789
  }
9778
- var STUDIO_FILE, MCP_FILE, VERSION_FILE, versionText, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes, studioFilesProblems;
9790
+ var STUDIO_FILE, MCP_FILE, CARD_TEMPLATE_FILE, SHARED_DIR, RULES_FILE, VERSION_FILE, versionText, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes, isSharedFile, studioFilesProblems;
9779
9791
  var init_studio_files = __esm({
9780
9792
  "../cli/src/lib/shared/studio-files.ts"() {
9781
9793
  "use strict";
@@ -9784,6 +9796,9 @@ var init_studio_files = __esm({
9784
9796
  init_studio_diagram();
9785
9797
  STUDIO_FILE = "STUDIO.md";
9786
9798
  MCP_FILE = "mcp.json";
9799
+ CARD_TEMPLATE_FILE = "CARD.md";
9800
+ SHARED_DIR = "shared/";
9801
+ RULES_FILE = "shared/RULES.md";
9787
9802
  VERSION_FILE = "version.json";
9788
9803
  versionText = (id, version) => `${JSON.stringify({ id, version })}
9789
9804
  `;
@@ -9795,6 +9810,10 @@ var init_studio_files = __esm({
9795
9810
  SEGMENT = /^[\w.-]+$/;
9796
9811
  isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
9797
9812
  bytes = (text4) => new TextEncoder().encode(text4).length;
9813
+ isSharedFile = (file) => {
9814
+ const parts = file.split("/");
9815
+ return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p) => SEGMENT.test(p) && p !== "." && p !== "..");
9816
+ };
9798
9817
  studioFilesProblems = (value, official = false) => inspect(value, official).problems;
9799
9818
  }
9800
9819
  });
@@ -9842,7 +9861,7 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
9842
9861
  const dir = path33.join(studiosDir, folder);
9843
9862
  const files = {};
9844
9863
  for (const f of filesOf(dir).sort()) {
9845
- if (f === STUDIO_FILE || f === MCP_FILE || f.startsWith("skills/") || isAboutFile(f)) files[f] = readStudioFile(dir, f);
9864
+ if (f === STUDIO_FILE || f === CARD_TEMPLATE_FILE || f === MCP_FILE || f.startsWith("skills/") || f.startsWith(SHARED_DIR) || isAboutFile(f)) files[f] = readStudioFile(dir, f);
9846
9865
  }
9847
9866
  const read3 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
9848
9867
  Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f, t]) => [`agents/${name}/${f}`, t]))
@@ -10274,6 +10293,7 @@ function studioFileText(def) {
10274
10293
  if (def.when) lines.push(`when: ${scalar(def.when)}`);
10275
10294
  lines.push(`needsArtifact: ${def.needsArtifact}`);
10276
10295
  lines.push(...groupLines("previews", def.previews), ...groupLines("land", def.land));
10296
+ if (def.memoryFiles?.workspace.length) lines.push("memoryFiles:", ` workspace: [${def.memoryFiles.workspace.map(scalar).join(", ")}]`);
10277
10297
  if (def.scheduled.length) {
10278
10298
  lines.push("scheduled:");
10279
10299
  for (const s of def.scheduled) {
@@ -12031,8 +12051,8 @@ var require_command = __commonJS({
12031
12051
  "../cli/node_modules/commander/lib/command.js"(exports) {
12032
12052
  var EventEmitter = __require("node:events").EventEmitter;
12033
12053
  var childProcess = __require("node:child_process");
12034
- var path85 = __require("node:path");
12035
- var fs87 = __require("node:fs");
12054
+ var path86 = __require("node:path");
12055
+ var fs88 = __require("node:fs");
12036
12056
  var process2 = __require("node:process");
12037
12057
  var { Argument: Argument2, humanReadableArgName } = require_argument();
12038
12058
  var { CommanderError: CommanderError2 } = require_error();
@@ -13013,7 +13033,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13013
13033
  * @param {string} subcommandName
13014
13034
  */
13015
13035
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
13016
- if (fs87.existsSync(executableFile)) return;
13036
+ if (fs88.existsSync(executableFile)) return;
13017
13037
  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";
13018
13038
  const executableMissing = `'${executableFile}' does not exist
13019
13039
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -13031,11 +13051,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
13031
13051
  let launchWithNode = false;
13032
13052
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
13033
13053
  function findFile(baseDir, baseName) {
13034
- const localBin = path85.resolve(baseDir, baseName);
13035
- if (fs87.existsSync(localBin)) return localBin;
13036
- if (sourceExt.includes(path85.extname(baseName))) return void 0;
13054
+ const localBin = path86.resolve(baseDir, baseName);
13055
+ if (fs88.existsSync(localBin)) return localBin;
13056
+ if (sourceExt.includes(path86.extname(baseName))) return void 0;
13037
13057
  const foundExt = sourceExt.find(
13038
- (ext) => fs87.existsSync(`${localBin}${ext}`)
13058
+ (ext) => fs88.existsSync(`${localBin}${ext}`)
13039
13059
  );
13040
13060
  if (foundExt) return `${localBin}${foundExt}`;
13041
13061
  return void 0;
@@ -13047,21 +13067,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
13047
13067
  if (this._scriptPath) {
13048
13068
  let resolvedScriptPath;
13049
13069
  try {
13050
- resolvedScriptPath = fs87.realpathSync(this._scriptPath);
13070
+ resolvedScriptPath = fs88.realpathSync(this._scriptPath);
13051
13071
  } catch {
13052
13072
  resolvedScriptPath = this._scriptPath;
13053
13073
  }
13054
- executableDir = path85.resolve(
13055
- path85.dirname(resolvedScriptPath),
13074
+ executableDir = path86.resolve(
13075
+ path86.dirname(resolvedScriptPath),
13056
13076
  executableDir
13057
13077
  );
13058
13078
  }
13059
13079
  if (executableDir) {
13060
13080
  let localFile = findFile(executableDir, executableFile);
13061
13081
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
13062
- const legacyName = path85.basename(
13082
+ const legacyName = path86.basename(
13063
13083
  this._scriptPath,
13064
- path85.extname(this._scriptPath)
13084
+ path86.extname(this._scriptPath)
13065
13085
  );
13066
13086
  if (legacyName !== this._name) {
13067
13087
  localFile = findFile(
@@ -13072,7 +13092,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13072
13092
  }
13073
13093
  executableFile = localFile || executableFile;
13074
13094
  }
13075
- launchWithNode = sourceExt.includes(path85.extname(executableFile));
13095
+ launchWithNode = sourceExt.includes(path86.extname(executableFile));
13076
13096
  let proc;
13077
13097
  if (process2.platform !== "win32") {
13078
13098
  if (launchWithNode) {
@@ -13919,7 +13939,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13919
13939
  * @return {Command}
13920
13940
  */
13921
13941
  nameFromFilename(filename) {
13922
- this._name = path85.basename(filename, path85.extname(filename));
13942
+ this._name = path86.basename(filename, path86.extname(filename));
13923
13943
  return this;
13924
13944
  }
13925
13945
  /**
@@ -13933,9 +13953,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
13933
13953
  * @param {string} [path]
13934
13954
  * @return {(string|null|Command)}
13935
13955
  */
13936
- executableDir(path86) {
13937
- if (path86 === void 0) return this._executableDir;
13938
- this._executableDir = path86;
13956
+ executableDir(path87) {
13957
+ if (path87 === void 0) return this._executableDir;
13958
+ this._executableDir = path87;
13939
13959
  return this;
13940
13960
  }
13941
13961
  /**
@@ -16155,7 +16175,7 @@ function globalMemories() {
16155
16175
  } catch {
16156
16176
  }
16157
16177
  for (const name of folders2) {
16158
- if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR) continue;
16178
+ if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR || name === STUDIO_MEMORY_DIR) continue;
16159
16179
  const file = path51.join(MEMORY, name, GLOBAL_MEMORY_FILE);
16160
16180
  if (!fs49.existsSync(file)) continue;
16161
16181
  const memory = readMemory(fs49.readFileSync(file, "utf8"), false, name);
@@ -16253,8 +16273,82 @@ var init_archive = __esm({
16253
16273
  }
16254
16274
  });
16255
16275
 
16256
- // ../cli/src/lib/agent/prompts.ts
16276
+ // ../cli/src/lib/agent/studio-shared.ts
16277
+ import fs51 from "node:fs";
16257
16278
  import path53 from "node:path";
16279
+ function studioFiles(studio) {
16280
+ const flow = cloudFlows().find((f) => f.def.id === studio || f.cloudId === studio);
16281
+ if (flow) return flow.files;
16282
+ if (studio && draftId() === studio) {
16283
+ try {
16284
+ return readStudioFolder(path53.join(STUDIOS, studio));
16285
+ } catch {
16286
+ return null;
16287
+ }
16288
+ }
16289
+ return null;
16290
+ }
16291
+ function readStudioMemory(studio) {
16292
+ const dir = studioMemoryDir(studio);
16293
+ let names3 = [];
16294
+ try {
16295
+ names3 = fs51.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => e.name).sort();
16296
+ } catch {
16297
+ return [];
16298
+ }
16299
+ return names3.flatMap((name) => {
16300
+ try {
16301
+ return [{ name, text: fs51.readFileSync(path53.join(dir, name), "utf8").trim() }];
16302
+ } catch {
16303
+ return [];
16304
+ }
16305
+ });
16306
+ }
16307
+ function studioSections(studio, opts = {}) {
16308
+ const files = studio ? studioFiles(studio) : null;
16309
+ if (!studio || !files) return [];
16310
+ const rules = files[RULES_FILE]?.trim();
16311
+ const own = opts.agent ? Object.keys(files).filter((f) => f.startsWith(`agents/${opts.agent}/`) && f !== `agents/${opts.agent}/AGENT.md`).sort() : [];
16312
+ const listed = [...sharedFiles(files), ...own];
16313
+ const remembered = opts.memory ? readStudioMemory(studio) : [];
16314
+ return [
16315
+ rules ? `\u2014\u2014\u2014 your studio's rules \u2014\u2014\u2014
16316
+
16317
+ ${rules}` : "",
16318
+ listed.length ? `\u2014\u2014\u2014 your studio's files \u2014\u2014\u2014
16319
+
16320
+ Read one only when the work calls for it:
16321
+
16322
+ ${listed.map((f) => fileLine(studio, f)).join("\n")}` : "",
16323
+ remembered.length ? `\u2014\u2014\u2014 what your studio remembers \u2014\u2014\u2014
16324
+
16325
+ From \`${rel(studioMemoryDir(studio))}/\`:
16326
+
16327
+ ${remembered.map((m) => `### \`${m.name}\`
16328
+
16329
+ ${m.text || "_(empty)_"}`).join("\n\n")}` : ""
16330
+ ].filter(Boolean);
16331
+ }
16332
+ var sharedFiles, studioMemoryDir, fileLine, studioHoldsAgent;
16333
+ var init_studio_shared = __esm({
16334
+ "../cli/src/lib/agent/studio-shared.ts"() {
16335
+ "use strict";
16336
+ init_memory();
16337
+ init_paths();
16338
+ init_studio_files();
16339
+ init_command();
16340
+ init_cloud_studios();
16341
+ init_studio_file();
16342
+ init_studio_folder();
16343
+ sharedFiles = (files) => Object.keys(files).filter((f) => f.startsWith(SHARED_DIR) && f !== RULES_FILE).sort();
16344
+ studioMemoryDir = (studio) => path53.join(MEMORY, STUDIO_MEMORY_DIR, studio);
16345
+ fileLine = (studio, file) => `- \`${file}\` \u2014 \`${rawMove(`file ${studio} ${file}`)}\``;
16346
+ studioHoldsAgent = (studio, agent) => !!studio && Object.keys(studioFiles(studio) ?? {}).some((f) => f.startsWith(`agents/${agent}/`));
16347
+ }
16348
+ });
16349
+
16350
+ // ../cli/src/lib/agent/prompts.ts
16351
+ import path54 from "node:path";
16258
16352
  function stopReason(deliveryId) {
16259
16353
  const delivery = findDelivery(deliveryId);
16260
16354
  if (!delivery) return void 0;
@@ -16315,7 +16409,7 @@ ${text4}` : "";
16315
16409
  }
16316
16410
  function cardFileOf(id) {
16317
16411
  const found2 = id === void 0 ? null : locate(id);
16318
- return found2 ? found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target : "";
16412
+ return found2 ? found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target : "";
16319
16413
  }
16320
16414
  function realPaths(text4, req) {
16321
16415
  if (req.action !== "scheduled" && req.action !== "sub") return text4;
@@ -16342,14 +16436,26 @@ function studioRulesBlock(req) {
16342
16436
  const where = req.id !== void 0 && stages > 1 ? `#${req.id} awaits Approve ${stage} of ${stages}: write only the previews this Approve covers${stage < stages ? "; the next previews start once the user approves" : ""}.` : "";
16343
16437
  const end2 = landAgents(flow).length ? "After the last approval, the studio agents complete the approved outcome and archive the card." : "The last Approve archives the card: nothing is built, so leave no todo for a build.";
16344
16438
  const own = userStudioRules(flow);
16439
+ const template = studioFiles(flow.id)?.[CARD_TEMPLATE_FILE]?.trim();
16345
16440
  const body = [where, end2, flow.rules.trim()].filter(Boolean).join("\n\n");
16346
16441
  return [
16347
- `<studio name="${flow.name}">`,
16348
- "How a card on this studio is written.",
16349
- body,
16350
- "</studio>",
16351
- ...own ? ["", "<rules>", "The user's own rules for cards on this studio; they win over the studio above.", own, "</rules>"] : []
16352
- ].join("\n");
16442
+ [
16443
+ `<studio name="${flow.name}">`,
16444
+ "How a card on this studio is written.",
16445
+ body,
16446
+ "</studio>",
16447
+ ...template ? ["", "<card-template>", "Write the card from this template: keep only the parts that fit this card, and fill them in.", template, "</card-template>"] : [],
16448
+ ...own ? ["", "<rules>", "The user's own rules for cards on this studio; they win over the studio above.", own, "</rules>"] : []
16449
+ ].join("\n"),
16450
+ ...studioSections(flow.id)
16451
+ ].join("\n\n");
16452
+ }
16453
+ function ownFiles2(studio, agent, files) {
16454
+ const sections2 = studioSections(studio, { agent, memory: true });
16455
+ const listed = !!agent && studioHoldsAgent(studio, agent);
16456
+ return [...sections2, ...files && !listed ? [`\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16457
+
16458
+ ${files}`] : []];
16353
16459
  }
16354
16460
  function landBlock(req) {
16355
16461
  if (req.action !== "implement") return "";
@@ -16357,6 +16463,7 @@ function landBlock(req) {
16357
16463
  const flow = frozen ? void 0 : studioFor(studioForRun(req));
16358
16464
  const rows = frozen ? frozen.land ?? [] : flow ? landAgents(flow) : [];
16359
16465
  const delivery = deliveryFor(req);
16466
+ const studio = frozen?.id ?? flow?.id;
16360
16467
  const step = delivery ? deliveryStep(delivery) : 0;
16361
16468
  const agents = rows.slice(step, step + 1).flatMap((h) => {
16362
16469
  const agent = findSpecAgent(h.agent);
@@ -16368,9 +16475,7 @@ function landBlock(req) {
16368
16475
  `\u2014\u2014\u2014 ${agents.length > 1 ? `step ${i + 1}: ` : ""}you, the \`${agent.name}\` agent \u2014 where this differs from the shared flow, follow this \u2014\u2014\u2014
16369
16476
 
16370
16477
  ${agent.body}`,
16371
- agentFilesBlock(agent) ? `\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16372
-
16373
- ${agentFilesBlock(agent)}` : "",
16478
+ ...ownFiles2(studio, agent.name, agentFilesBlock(agent)),
16374
16479
  globalMemoryBlock(agent) ? `\u2014\u2014\u2014 global memories \u2014\u2014\u2014
16375
16480
 
16376
16481
  ${globalMemoryBlock(agent)}` : "",
@@ -16402,7 +16507,7 @@ function frozenRules(req) {
16402
16507
  function archivedCardFile(id) {
16403
16508
  const found2 = locateArchived(id);
16404
16509
  if (!found2) return `${rel(ARCHIVE)}/`;
16405
- return rel(found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target);
16510
+ return rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target);
16406
16511
  }
16407
16512
  function shippedLines(cardId2) {
16408
16513
  const delivery = endedDelivery(`${cardId2}`);
@@ -16501,7 +16606,7 @@ function actionPrompt(req, command, notes) {
16501
16606
  case "prune-memory":
16502
16607
  return [
16503
16608
  `${kb}. Prune this board's memory following \`akb guide prune-memory\`.`,
16504
- `Cover the board's own record at \`${rel(MEMORY)}/\` and every agent's memory at \`${rel(MEMORY)}/agents/<agent>/\`, the ${PLANNER}'s among them.`,
16609
+ `Cover the board's own record at \`${rel(MEMORY)}/\` and every agent's memory at \`${rel(MEMORY)}/agents/<agent>/\`, the ${PLANNER}'s among them, and each studio's at \`${rel(MEMORY)}/studios/<studio>/\`.`,
16505
16610
  `Change nothing but those files: no card, no question for anyone.`
16506
16611
  ].join(" ");
16507
16612
  // Reading back over the conversations (#748). It names nothing either: which ones have
@@ -16545,7 +16650,7 @@ function actionPrompt(req, command, notes) {
16545
16650
  case "spec": {
16546
16651
  const agent = findSpecAgent(req.specAgent ?? "");
16547
16652
  const found2 = req.id === void 0 ? null : locate(req.id);
16548
- const cardFile3 = found2 ? rel(found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
16653
+ const cardFile3 = found2 ? rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
16549
16654
  const own = agent ? specAgentInstructions(agent) : null;
16550
16655
  if (own) notes.push(...own.notes);
16551
16656
  const memory = agent ? agentMemoryBlock(agent) : "";
@@ -16563,9 +16668,7 @@ function actionPrompt(req, command, notes) {
16563
16668
  agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
16564
16669
 
16565
16670
  ${own.instructions}` : "",
16566
- own?.files ? `\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16567
-
16568
- ${own.files}` : "",
16671
+ ...ownFiles2(studioForRun(req), agent?.name, own?.files),
16569
16672
  memory ? `\u2014\u2014\u2014 what you remember \u2014\u2014\u2014
16570
16673
 
16571
16674
  ${memory}` : "",
@@ -16598,9 +16701,7 @@ ${shared}` : "",
16598
16701
  agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
16599
16702
 
16600
16703
  ${own.instructions}` : "",
16601
- own?.files ? `\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16602
-
16603
- ${own.files}` : "",
16704
+ ...ownFiles2(flow?.id, agent?.name, own?.files),
16604
16705
  extra ? `\u2014\u2014\u2014 what this studio asks of you here \u2014\u2014\u2014
16605
16706
 
16606
16707
  ${extra}` : "",
@@ -16634,9 +16735,7 @@ ${req.description ?? ""}`,
16634
16735
  agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
16635
16736
 
16636
16737
  ${own.instructions}` : "",
16637
- own?.files ? `\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16638
-
16639
- ${own.files}` : "",
16738
+ ...ownFiles2(studioForRun(req), agent?.name, own?.files),
16640
16739
  memory ? `\u2014\u2014\u2014 what you remember \u2014\u2014\u2014
16641
16740
 
16642
16741
  ${memory}` : "",
@@ -16685,6 +16784,8 @@ var init_prompts = __esm({
16685
16784
  init_flows();
16686
16785
  init_resolve();
16687
16786
  init_runner();
16787
+ init_studio_shared();
16788
+ init_studio_files();
16688
16789
  init_studios();
16689
16790
  init_catalog();
16690
16791
  init_roles();
@@ -16725,16 +16826,16 @@ var init_prompts = __esm({
16725
16826
 
16726
16827
  // ../cli/src/lib/agent/stop.ts
16727
16828
  import { spawnSync as spawnSync4 } from "node:child_process";
16728
- import fs51 from "node:fs";
16829
+ import fs52 from "node:fs";
16729
16830
  function markedInProc(entry, strict = false) {
16730
16831
  const pids = [];
16731
- for (const name of fs51.readdirSync("/proc")) {
16832
+ for (const name of fs52.readdirSync("/proc")) {
16732
16833
  if (!/^\d+$/.test(name)) continue;
16733
16834
  try {
16734
- if (fs51.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
16835
+ if (fs52.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
16735
16836
  } catch (error) {
16736
16837
  if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
16737
- const stat = fs51.statSync(`/proc/${name}`, { throwIfNoEntry: false });
16838
+ const stat = fs52.statSync(`/proc/${name}`, { throwIfNoEntry: false });
16738
16839
  if (stat?.uid === process.getuid?.()) throw error;
16739
16840
  }
16740
16841
  }
@@ -16889,10 +16990,10 @@ var init_stop = __esm({
16889
16990
  });
16890
16991
 
16891
16992
  // ../cli/src/lib/agent/creation-lock.ts
16892
- import path54 from "node:path";
16993
+ import path55 from "node:path";
16893
16994
  function withCreationLock(fn) {
16894
16995
  if (depth2) return fn();
16895
- return withLock(path54.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
16996
+ return withLock(path55.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
16896
16997
  depth2++;
16897
16998
  try {
16898
16999
  return fn();
@@ -16913,8 +17014,8 @@ var init_creation_lock = __esm({
16913
17014
 
16914
17015
  // ../cli/src/lib/agent/sessions.ts
16915
17016
  import { randomUUID as randomUUID4 } from "node:crypto";
16916
- import fs52 from "node:fs";
16917
- import path55 from "node:path";
17017
+ import fs53 from "node:fs";
17018
+ import path56 from "node:path";
16918
17019
  function reap(runs, reaped = [], restore = []) {
16919
17020
  let changed = false;
16920
17021
  const now = Date.now();
@@ -16934,7 +17035,7 @@ function reap(runs, reaped = [], restore = []) {
16934
17035
  }
16935
17036
  function stampDuration(run2, endedAt) {
16936
17037
  try {
16937
- fs52.appendFileSync(run2.logPath, durationLine(endedAt - run2.startedAt));
17038
+ fs53.appendFileSync(run2.logPath, durationLine(endedAt - run2.startedAt));
16938
17039
  } catch {
16939
17040
  }
16940
17041
  }
@@ -16948,7 +17049,7 @@ function cardNow(cardId2) {
16948
17049
  try {
16949
17050
  const file = cardFile(cardId2);
16950
17051
  if (!file) return null;
16951
- const { meta } = parseFrontmatter(fs52.readFileSync(file, "utf8"));
17052
+ const { meta } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
16952
17053
  if (!meta) return null;
16953
17054
  return { status: meta.status || "todo", questions: meta.questions.length, title: meta.title };
16954
17055
  } catch {
@@ -17081,9 +17182,9 @@ function leftBoardOnLanding(id) {
17081
17182
  function archivedRejected(id) {
17082
17183
  const filed = locateArchived(id);
17083
17184
  if (!filed) return null;
17084
- const file = filed.kind === "group" ? path55.join(filed.target, "root.md") : filed.target;
17185
+ const file = filed.kind === "group" ? path56.join(filed.target, "root.md") : filed.target;
17085
17186
  try {
17086
- return !!parseFrontmatter(fs52.readFileSync(file, "utf8")).meta?.rejected;
17187
+ return !!parseFrontmatter(fs53.readFileSync(file, "utf8")).meta?.rejected;
17087
17188
  } catch {
17088
17189
  return false;
17089
17190
  }
@@ -17333,7 +17434,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID4(), said2) {
17333
17434
  return { run: record, spec };
17334
17435
  }
17335
17436
  function planningSession(cardId2, cwd = REPO_ROOT) {
17336
- const here = (dir) => !dir || path55.resolve(dir) === cwd;
17437
+ const here = (dir) => !dir || path56.resolve(dir) === cwd;
17337
17438
  const planned = readRuns().filter((r) => r.status === "done" && r.cardId === cardId2 && PLANNING.has(r.action)).sort((a, b) => b.startedAt - a.startedAt)[0];
17338
17439
  if (!planned) return { none: "unrecorded" };
17339
17440
  if (!here(planned.cwd)) return { none: "elsewhere" };
@@ -17553,8 +17654,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
17553
17654
  if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
17554
17655
  clearAsks(prev.sessionId);
17555
17656
  try {
17556
- fs52.unlinkSync(prev.logPath);
17557
- fs52.rmSync(eventsPathOf(prev.sessionId), { force: true });
17657
+ fs53.unlinkSync(prev.logPath);
17658
+ fs53.rmSync(eventsPathOf(prev.sessionId), { force: true });
17558
17659
  } catch {
17559
17660
  }
17560
17661
  if (retry2 && prev.pictures?.length) {
@@ -17577,8 +17678,8 @@ function forgetRun(sessionId) {
17577
17678
  if (!gone) return;
17578
17679
  clearAsks(sessionId);
17579
17680
  try {
17580
- fs52.unlinkSync(gone.logPath);
17581
- fs52.rmSync(eventsPathOf(gone.sessionId), { force: true });
17681
+ fs53.unlinkSync(gone.logPath);
17682
+ fs53.rmSync(eventsPathOf(gone.sessionId), { force: true });
17582
17683
  } catch {
17583
17684
  }
17584
17685
  }
@@ -17607,14 +17708,14 @@ function noteSpecRefusals(sessionId, refused) {
17607
17708
  }
17608
17709
  function clearAsks(sessionId) {
17609
17710
  try {
17610
- fs52.unlinkSync(asksPathOf(sessionId));
17711
+ fs53.unlinkSync(asksPathOf(sessionId));
17611
17712
  } catch {
17612
17713
  }
17613
17714
  }
17614
17715
  function readAsks(sessionId) {
17615
17716
  let data;
17616
17717
  try {
17617
- data = JSON.parse(fs52.readFileSync(asksPathOf(sessionId), "utf8"));
17718
+ data = JSON.parse(fs53.readFileSync(asksPathOf(sessionId), "utf8"));
17618
17719
  } catch {
17619
17720
  return { asks: [], refines: [], refused: [] };
17620
17721
  }
@@ -17641,10 +17742,10 @@ function readAsks(sessionId) {
17641
17742
  return { asks: asks.filter((a) => !discarded.has(a.cardId)), refines: refines.filter((a) => !discarded.has(a.cardId)), refused };
17642
17743
  }
17643
17744
  function writeAsks(sessionId, file) {
17644
- fs52.mkdirSync(SESSIONS_DIR, { recursive: true });
17745
+ fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
17645
17746
  const tmp = `${asksPathOf(sessionId)}.tmp`;
17646
- fs52.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
17647
- fs52.renameSync(tmp, asksPathOf(sessionId));
17747
+ fs53.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
17748
+ fs53.renameSync(tmp, asksPathOf(sessionId));
17648
17749
  }
17649
17750
  function markSpawned(sessionId, pid) {
17650
17751
  patch(sessionId, (r) => {
@@ -17775,12 +17876,12 @@ async function resumeDelivery(id) {
17775
17876
  return { ok: true, deliveryId: delivery.deliveryId, carryOn };
17776
17877
  }
17777
17878
  function writeSpec(spec) {
17778
- fs52.mkdirSync(SESSIONS_DIR, { recursive: true });
17779
- fs52.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
17879
+ fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
17880
+ fs53.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
17780
17881
  }
17781
17882
  function readSpec(sessionId) {
17782
17883
  try {
17783
- const spec = JSON.parse(fs52.readFileSync(specPathOf(sessionId), "utf8"));
17884
+ const spec = JSON.parse(fs53.readFileSync(specPathOf(sessionId), "utf8"));
17784
17885
  return spec && Array.isArray(spec.plan?.argv) ? spec : null;
17785
17886
  } catch {
17786
17887
  return null;
@@ -17788,28 +17889,28 @@ function readSpec(sessionId) {
17788
17889
  }
17789
17890
  function dropSpec(sessionId) {
17790
17891
  try {
17791
- fs52.unlinkSync(specPathOf(sessionId));
17892
+ fs53.unlinkSync(specPathOf(sessionId));
17792
17893
  } catch {
17793
17894
  }
17794
17895
  }
17795
17896
  async function acquireIndexLock(giveUp) {
17796
17897
  const until = Date.now() + INDEX_WAIT_MS;
17797
- const holder = path55.join(INDEX_LOCK2, "holder");
17898
+ const holder = path56.join(INDEX_LOCK2, "holder");
17798
17899
  for (; ; ) {
17799
17900
  if (giveUp()) return null;
17800
17901
  try {
17801
- fs52.mkdirSync(INDEX_LOCK2, { recursive: false });
17802
- fs52.writeFileSync(holder, String(process.pid));
17803
- return () => fs52.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17902
+ fs53.mkdirSync(INDEX_LOCK2, { recursive: false });
17903
+ fs53.writeFileSync(holder, String(process.pid));
17904
+ return () => fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17804
17905
  } catch (err) {
17805
17906
  const code = err.code;
17806
17907
  if (code === "ENOENT") {
17807
- fs52.mkdirSync(path55.dirname(INDEX_LOCK2), { recursive: true });
17908
+ fs53.mkdirSync(path56.dirname(INDEX_LOCK2), { recursive: true });
17808
17909
  continue;
17809
17910
  }
17810
17911
  if (code !== "EEXIST") throw err;
17811
17912
  if (!pidAlive(Number(readHolder(holder)))) {
17812
- fs52.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17913
+ fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17813
17914
  continue;
17814
17915
  }
17815
17916
  if (Date.now() > until) return null;
@@ -17819,7 +17920,7 @@ async function acquireIndexLock(giveUp) {
17819
17920
  }
17820
17921
  function readHolder(file) {
17821
17922
  try {
17822
- return fs52.readFileSync(file, "utf8").trim();
17923
+ return fs53.readFileSync(file, "utf8").trim();
17823
17924
  } catch {
17824
17925
  return String(process.pid);
17825
17926
  }
@@ -17904,8 +18005,8 @@ var init_sessions = __esm({
17904
18005
  implement: "implementing",
17905
18006
  hook: "implementing"
17906
18007
  };
17907
- specPathOf = (sessionId) => path55.join(SESSIONS_DIR, `${sessionId}.plan.json`);
17908
- asksPathOf = (sessionId) => path55.join(SESSIONS_DIR, `${sessionId}.asks.json`);
18008
+ specPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.plan.json`);
18009
+ asksPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.asks.json`);
17909
18010
  carriesSession = (r) => !!(r.resumedFrom || r.continues && !r.continues.fork);
17910
18011
  canPickUp = (r) => r.status === "error" || r.status === "interrupted" || r.status === "stopped";
17911
18012
  neverStarted = (r) => r.unspawned === true || !!r.errorWhy?.some((why2) => why2.kind === "notInstalled");
@@ -17958,8 +18059,8 @@ var init_sources = __esm({
17958
18059
  });
17959
18060
 
17960
18061
  // ../cli/src/lib/signals/inbox.ts
17961
- import fs53 from "node:fs";
17962
- import path56 from "node:path";
18062
+ import fs54 from "node:fs";
18063
+ import path57 from "node:path";
17963
18064
  function metaPair(key, value) {
17964
18065
  const name = typeof key === "string" ? key.trim() : "";
17965
18066
  if (!name) return null;
@@ -17990,7 +18091,7 @@ ${signal2.summary.trim()}
17990
18091
  function parse(file, lenient = false) {
17991
18092
  let text4;
17992
18093
  try {
17993
- text4 = fs53.readFileSync(file, "utf8");
18094
+ text4 = fs54.readFileSync(file, "utf8");
17994
18095
  } catch {
17995
18096
  return null;
17996
18097
  }
@@ -18044,20 +18145,20 @@ function parse(file, lenient = false) {
18044
18145
  };
18045
18146
  }
18046
18147
  function freeName(dir, wanted) {
18047
- const ext = path56.extname(wanted);
18148
+ const ext = path57.extname(wanted);
18048
18149
  const stem = wanted.slice(0, wanted.length - ext.length);
18049
18150
  let name = wanted;
18050
- for (let n = 2; fs53.existsSync(path56.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
18151
+ for (let n = 2; fs54.existsSync(path57.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
18051
18152
  return name;
18052
18153
  }
18053
18154
  function readFolder2(dir, lenient = false) {
18054
18155
  let entries;
18055
18156
  try {
18056
- entries = fs53.readdirSync(dir, { withFileTypes: true });
18157
+ entries = fs54.readdirSync(dir, { withFileTypes: true });
18057
18158
  } catch {
18058
18159
  return [];
18059
18160
  }
18060
- return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path56.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
18161
+ return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path57.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
18061
18162
  }
18062
18163
  function readInbox() {
18063
18164
  const signals = readFolder2(TRIAGE);
@@ -18065,7 +18166,7 @@ function readInbox() {
18065
18166
  return signals;
18066
18167
  }
18067
18168
  function writeSignal(incoming, importedAt, slug2 = "") {
18068
- fs53.mkdirSync(TRIAGE, { recursive: true });
18169
+ fs54.mkdirSync(TRIAGE, { recursive: true });
18069
18170
  const signal2 = {
18070
18171
  ...incoming,
18071
18172
  importedAt,
@@ -18077,12 +18178,12 @@ function writeSignal(incoming, importedAt, slug2 = "") {
18077
18178
  contentKept: true,
18078
18179
  relPath: ""
18079
18180
  };
18080
- const file = path56.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
18081
- fs53.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
18181
+ const file = path57.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
18182
+ fs54.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
18082
18183
  return { ...signal2, relPath: boardRel(file) };
18083
18184
  }
18084
18185
  function stamp3(file, fields) {
18085
- const text4 = fs53.readFileSync(file, "utf8");
18186
+ const text4 = fs54.readFileSync(file, "utf8");
18086
18187
  const lines = text4.split("\n");
18087
18188
  const close = lines.indexOf("---", 1);
18088
18189
  if (close < 0) return;
@@ -18091,13 +18192,13 @@ function stamp3(file, fields) {
18091
18192
  return !key || fields[key[1]] === void 0;
18092
18193
  });
18093
18194
  const added = Object.entries(fields).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
18094
- fs53.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
18195
+ fs54.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
18095
18196
  }
18096
18197
  function moveSignal(from, into, fields) {
18097
- if (!fs53.existsSync(from)) return "";
18098
- fs53.mkdirSync(into, { recursive: true });
18099
- const at = path56.join(into, freeName(into, path56.basename(from)));
18100
- fs53.renameSync(from, at);
18198
+ if (!fs54.existsSync(from)) return "";
18199
+ fs54.mkdirSync(into, { recursive: true });
18200
+ const at = path57.join(into, freeName(into, path57.basename(from)));
18201
+ fs54.renameSync(from, at);
18101
18202
  stamp3(at, fields);
18102
18203
  return boardRel(at);
18103
18204
  }
@@ -18106,10 +18207,10 @@ function archiveInboxItem(sourceId, cardId2) {
18106
18207
  if (!found2) {
18107
18208
  const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
18108
18209
  if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
18109
- stamp3(path56.join(SIGNALS_DISMISSED, path56.basename(ignored.relPath)), { card_id: String(cardId2) });
18210
+ stamp3(path57.join(SIGNALS_DISMISSED, path57.basename(ignored.relPath)), { card_id: String(cardId2) });
18110
18211
  return { ok: true, relPath: ignored.relPath, where: "dismissed" };
18111
18212
  }
18112
- const at = moveSignal(path56.join(TRIAGE, path56.basename(found2.relPath)), SIGNALS_ARCHIVED, {
18213
+ const at = moveSignal(path57.join(TRIAGE, path57.basename(found2.relPath)), SIGNALS_ARCHIVED, {
18113
18214
  card_id: String(cardId2),
18114
18215
  archived_at: formatStamp(/* @__PURE__ */ new Date())
18115
18216
  });
@@ -18123,7 +18224,7 @@ var init_inbox = __esm({
18123
18224
  init_sources();
18124
18225
  init_paths();
18125
18226
  init_yaml();
18126
- boardRel = (file) => rel(file).split(path56.sep).join("/");
18227
+ boardRel = (file) => rel(file).split(path57.sep).join("/");
18127
18228
  FIELDS = ["source_id", "title", "collected_at", "imported_at"];
18128
18229
  META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
18129
18230
  slugOf = (said2) => said2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
@@ -18232,12 +18333,12 @@ var init_studio_cards = __esm({
18232
18333
  });
18233
18334
 
18234
18335
  // ../cli/src/lib/readme.ts
18235
- import fs54 from "node:fs";
18236
- import path57 from "node:path";
18336
+ import fs55 from "node:fs";
18337
+ import path58 from "node:path";
18237
18338
  function stripReadmeRefs(target) {
18238
- if (!fs54.existsSync(README)) return [];
18339
+ if (!fs55.existsSync(README)) return [];
18239
18340
  const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
18240
- const lines = fs54.readFileSync(README, "utf8").split("\n");
18341
+ const lines = fs55.readFileSync(README, "utf8").split("\n");
18241
18342
  const out = [];
18242
18343
  const removed = [];
18243
18344
  let i = 0;
@@ -18259,20 +18360,20 @@ function stripReadmeRefs(target) {
18259
18360
  out.push(line);
18260
18361
  i++;
18261
18362
  }
18262
- if (removed.length) fs54.writeFileSync(README, out.join("\n"));
18363
+ if (removed.length) fs55.writeFileSync(README, out.join("\n"));
18263
18364
  return removed;
18264
18365
  }
18265
18366
  function addReadmeRef(id, title, relPath) {
18266
- if (!fs54.existsSync(README)) return false;
18267
- const link2 = relPath.split(path57.sep).join("/");
18367
+ if (!fs55.existsSync(README)) return false;
18368
+ const link2 = relPath.split(path58.sep).join("/");
18268
18369
  const bullet = `- [#${id} ${title}](${link2})`;
18269
18370
  const heading = `## ${TASKS_HEADING}`;
18270
- let lines = fs54.readFileSync(README, "utf8").split("\n");
18371
+ let lines = fs55.readFileSync(README, "utf8").split("\n");
18271
18372
  const hi = lines.findIndex((l) => l.trim().toLowerCase() === heading.toLowerCase());
18272
18373
  if (hi === -1) {
18273
18374
  while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
18274
18375
  lines.push("", heading, "", bullet);
18275
- fs54.writeFileSync(README, lines.join("\n") + "\n");
18376
+ fs55.writeFileSync(README, lines.join("\n") + "\n");
18276
18377
  return true;
18277
18378
  }
18278
18379
  let end2 = hi + 1;
@@ -18286,15 +18387,15 @@ function addReadmeRef(id, title, relPath) {
18286
18387
  const at = lastBullet !== -1 ? lastBullet + 1 : lines[hi + 1] === "" ? hi + 2 : hi + 1;
18287
18388
  lines.splice(at, 0, bullet);
18288
18389
  }
18289
- fs54.writeFileSync(README, lines.join("\n"));
18390
+ fs55.writeFileSync(README, lines.join("\n"));
18290
18391
  return true;
18291
18392
  }
18292
18393
  function repointReadmeLink(id, oldRel, newRel, title) {
18293
- if (!fs54.existsSync(README)) return false;
18294
- const oldLink = oldRel.split(path57.sep).join("/");
18295
- const newLink = newRel.split(path57.sep).join("/");
18394
+ if (!fs55.existsSync(README)) return false;
18395
+ const oldLink = oldRel.split(path58.sep).join("/");
18396
+ const newLink = newRel.split(path58.sep).join("/");
18296
18397
  const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
18297
- const lines = fs54.readFileSync(README, "utf8").split("\n");
18398
+ const lines = fs55.readFileSync(README, "utf8").split("\n");
18298
18399
  let changed = false;
18299
18400
  for (let i = 0; i < lines.length; i++) {
18300
18401
  if (!lines[i].includes(`](${oldLink})`)) continue;
@@ -18304,7 +18405,7 @@ function repointReadmeLink(id, oldRel, newRel, title) {
18304
18405
  changed = true;
18305
18406
  }
18306
18407
  }
18307
- if (changed) fs54.writeFileSync(README, lines.join("\n"));
18408
+ if (changed) fs55.writeFileSync(README, lines.join("\n"));
18308
18409
  return changed;
18309
18410
  }
18310
18411
  var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex;
@@ -18791,14 +18892,14 @@ function collect(body, card, host2) {
18791
18892
  const active2 = /* @__PURE__ */ new Set();
18792
18893
  const out = [];
18793
18894
  const visit = (src, types, owner) => {
18794
- const path85 = src.replace(/[?#].*$/, "");
18895
+ const path86 = src.replace(/[?#].*$/, "");
18795
18896
  let resolved2;
18796
18897
  try {
18797
- resolved2 = host2.resolve(path85, owner);
18898
+ resolved2 = host2.resolve(path86, owner);
18798
18899
  } catch (error) {
18799
18900
  if (owner !== card) return { key: null, error: why(error) };
18800
18901
  if (!nodes.has(src)) {
18801
- const node2 = { key: src, file: null, kind: kindAt(path85, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18902
+ const node2 = { key: src, file: null, kind: kindAt(path86, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18802
18903
  nodes.set(src, node2);
18803
18904
  out.push(node2);
18804
18905
  }
@@ -18883,16 +18984,16 @@ var init_collect = __esm({
18883
18984
  });
18884
18985
 
18885
18986
  // ../cli/src/lib/dress-page.ts
18886
- import fs55 from "node:fs";
18887
- import path58 from "node:path";
18987
+ import fs56 from "node:fs";
18988
+ import path59 from "node:path";
18888
18989
  function dressPage(file) {
18889
- const folder = path58.dirname(file);
18890
- const html = fs55.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
18990
+ const folder = path59.dirname(file);
18991
+ const html = fs56.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
18891
18992
  const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
18892
18993
  if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
18893
- const at2 = path58.resolve(folder, href);
18894
- if (!at2.startsWith(folder + path58.sep) || !fs55.existsSync(at2)) return tag;
18895
- 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})`);
18994
+ const at2 = path59.resolve(folder, href);
18995
+ if (!at2.startsWith(folder + path59.sep) || !fs56.existsSync(at2)) return tag;
18996
+ 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})`);
18896
18997
  return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
18897
18998
  });
18898
18999
  const at = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
@@ -18904,25 +19005,25 @@ var init_dress_page = __esm({
18904
19005
  "use strict";
18905
19006
  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'";
18906
19007
  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>`;
18907
- referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs55.readFileSync(file, "utf8");
19008
+ referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs56.readFileSync(file, "utf8");
18908
19009
  }
18909
19010
  });
18910
19011
 
18911
19012
  // ../cli/src/lib/preview-files.ts
18912
- import fs56 from "node:fs";
18913
- import path59 from "node:path";
19013
+ import fs57 from "node:fs";
19014
+ import path60 from "node:path";
18914
19015
  function resolver(card, id) {
18915
- const roots = [KANBAN, path59.join(ASSETS, String(id)), path59.join(MOCKUPS, String(id))];
18916
- const real2 = (p) => fs56.existsSync(p) ? fs56.realpathSync(p) : p;
18917
- const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) + path59.sep));
19016
+ const roots = [KANBAN, path60.join(ASSETS, String(id)), path60.join(MOCKUPS, String(id))];
19017
+ const real2 = (p) => fs57.existsSync(p) ? fs57.realpathSync(p) : p;
19018
+ const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) + path60.sep));
18918
19019
  return (src, owner) => {
18919
19020
  if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
18920
- if (path59.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
19021
+ if (path60.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
18921
19022
  const held4 = /^\.(assets|mockups)\//.exec(src);
18922
- const file = held4 ? path59.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path59.resolve(path59.dirname(owner), src);
18923
- if (!inside2(path59.resolve(file)) || fs56.existsSync(file) && !inside2(fs56.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
18924
- if (!fs56.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
18925
- return { key: fs56.realpathSync(file), file };
19023
+ const file = held4 ? path60.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path60.resolve(path60.dirname(owner), src);
19024
+ if (!inside2(path60.resolve(file)) || fs57.existsSync(file) && !inside2(fs57.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
19025
+ if (!fs57.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
19026
+ return { key: fs57.realpathSync(file), file };
18926
19027
  };
18927
19028
  }
18928
19029
  function validatePreviewFiles(card, id, text4) {
@@ -18965,8 +19066,8 @@ var init_preview_files = __esm({
18965
19066
  });
18966
19067
 
18967
19068
  // ../cli/src/lib/spec-contract.ts
18968
- import fs57 from "node:fs";
18969
- import path60 from "node:path";
19069
+ import fs58 from "node:fs";
19070
+ import path61 from "node:path";
18970
19071
  function scanCardLines(lines, start = 0) {
18971
19072
  const visible = lines.map(() => "");
18972
19073
  let fence = null;
@@ -18999,18 +19100,18 @@ function scanCardLines(lines, start = 0) {
18999
19100
  }
19000
19101
  function snapshotSpecs() {
19001
19102
  const out = /* @__PURE__ */ new Map();
19002
- if (!fs57.existsSync(TODO)) return out;
19103
+ if (!fs58.existsSync(TODO)) return out;
19003
19104
  for (const file of walkMd(TODO)) {
19004
- if (isLegacyRecurring(path60.relative(TODO, file))) continue;
19005
- const id = idPrefix(path60.basename(file) === "root.md" ? path60.basename(path60.dirname(file)) : path60.basename(file));
19006
- if (id !== null) out.set(file, { id, text: fs57.readFileSync(file, "utf8") });
19105
+ if (isLegacyRecurring(path61.relative(TODO, file))) continue;
19106
+ const id = idPrefix(path61.basename(file) === "root.md" ? path61.basename(path61.dirname(file)) : path61.basename(file));
19107
+ if (id !== null) out.set(file, { id, text: fs58.readFileSync(file, "utf8") });
19007
19108
  }
19008
19109
  return out;
19009
19110
  }
19010
19111
  function enclosingGroups(file) {
19011
19112
  const ids = [];
19012
19113
  for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
19013
- const id = idPrefix(path60.basename(path60.dirname(root2)));
19114
+ const id = idPrefix(path61.basename(path61.dirname(root2)));
19014
19115
  if (id !== null) ids.push(id);
19015
19116
  }
19016
19117
  return ids;
@@ -19185,9 +19286,9 @@ function setEnd(lines, at) {
19185
19286
  }
19186
19287
  function inside(dir, name) {
19187
19288
  try {
19188
- const root2 = fs57.realpathSync(dir);
19189
- const real2 = fs57.realpathSync(path60.join(dir, name));
19190
- return real2.startsWith(root2 + path60.sep) && fs57.statSync(real2).isFile() ? real2 : null;
19289
+ const root2 = fs58.realpathSync(dir);
19290
+ const real2 = fs58.realpathSync(path61.join(dir, name));
19291
+ return real2.startsWith(root2 + path61.sep) && fs58.statSync(real2).isFile() ? real2 : null;
19191
19292
  } catch {
19192
19293
  return null;
19193
19294
  }
@@ -19205,7 +19306,7 @@ function variantsProblem(raw, src, id) {
19205
19306
  if (files.length < 2 || !files.every((f) => typeof f === "string" && f)) return `variants needs at least two labels, each naming a file. ${shape}`;
19206
19307
  if (!files.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
19207
19308
  if (id === void 0) return null;
19208
- const dir = path60.join(ASSETS, String(id));
19309
+ const dir = path61.join(ASSETS, String(id));
19209
19310
  for (const f of files) {
19210
19311
  const parts = f.split("/");
19211
19312
  if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
@@ -19215,12 +19316,12 @@ function variantsProblem(raw, src, id) {
19215
19316
  return null;
19216
19317
  }
19217
19318
  function compareProblem(attrs, id) {
19218
- const dir = path60.join(ASSETS, String(id));
19319
+ const dir = path61.join(ASSETS, String(id));
19219
19320
  const src = (message) => ({ rule: "compare-src", message });
19220
19321
  const shots = (message) => ({ rule: "compare-shots", message });
19221
19322
  const json = (file) => {
19222
19323
  try {
19223
- return file.endsWith(".json") ? JSON.parse(fs57.readFileSync(file, "utf8")) : null;
19324
+ return file.endsWith(".json") ? JSON.parse(fs58.readFileSync(file, "utf8")) : null;
19224
19325
  } catch {
19225
19326
  return null;
19226
19327
  }
@@ -19245,7 +19346,7 @@ function compareProblem(attrs, id) {
19245
19346
  const file = inside(dir, named2.name);
19246
19347
  if (!file) return { message: `Compare shots ${at} names no file in this card's asset folder. Write the JSON there or fix the path.` };
19247
19348
  try {
19248
- return { data: JSON.parse(fs57.readFileSync(file, "utf8")) };
19349
+ return { data: JSON.parse(fs58.readFileSync(file, "utf8")) };
19249
19350
  } catch {
19250
19351
  return { message: `${at} is not valid JSON.` };
19251
19352
  }
@@ -19263,7 +19364,7 @@ function compareProblem(attrs, id) {
19263
19364
  }
19264
19365
  function validateStoryboards(file, id, text4) {
19265
19366
  const errors = [];
19266
- const dir = path60.join(ASSETS, String(id));
19367
+ const dir = path61.join(ASSETS, String(id));
19267
19368
  for (const [tag, tagOf, rule, fix] of [
19268
19369
  ["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
19269
19370
  ["Studio", studioTag, "studio-src", "Write it with `akb raw studio diagram <studio id> <card id>` or fix the path."]
@@ -19299,14 +19400,14 @@ var init_spec_contract = __esm({
19299
19400
  });
19300
19401
 
19301
19402
  // ../cli/src/lib/reconcile.ts
19302
- import fs58 from "node:fs";
19303
- import path61 from "node:path";
19403
+ import fs59 from "node:fs";
19404
+ import path62 from "node:path";
19304
19405
  function liveIds() {
19305
19406
  const ids = /* @__PURE__ */ new Set();
19306
19407
  for (const file of walkMd(TODO)) {
19307
- const base = path61.basename(file);
19408
+ const base = path62.basename(file);
19308
19409
  if (base === "README.md") continue;
19309
- const id = base === "root.md" ? idPrefix(path61.basename(path61.dirname(file))) : idPrefix(base);
19410
+ const id = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
19310
19411
  if (id != null) ids.add(id);
19311
19412
  }
19312
19413
  return ids;
@@ -19314,16 +19415,16 @@ function liveIds() {
19314
19415
  function indexableCards() {
19315
19416
  const out = [];
19316
19417
  for (const dir of walkDirs(TODO)) {
19317
- const id = idPrefix(path61.basename(dir));
19318
- if (id != null && fs58.existsSync(path61.join(dir, "root.md"))) {
19319
- out.push({ id, rel: path61.join(path61.relative(TODO, dir), "root.md").split(path61.sep).join("/") });
19418
+ const id = idPrefix(path62.basename(dir));
19419
+ if (id != null && fs59.existsSync(path62.join(dir, "root.md"))) {
19420
+ out.push({ id, rel: path62.join(path62.relative(TODO, dir), "root.md").split(path62.sep).join("/") });
19320
19421
  }
19321
19422
  }
19322
19423
  for (const file of walkMd(TODO)) {
19323
- const base = path61.basename(file);
19424
+ const base = path62.basename(file);
19324
19425
  if (base === "README.md" || base === "root.md") continue;
19325
- const relTODO = path61.relative(TODO, file);
19326
- const segs = relTODO.split(path61.sep);
19426
+ const relTODO = path62.relative(TODO, file);
19427
+ const segs = relTODO.split(path62.sep);
19327
19428
  if (segs.length !== 1) continue;
19328
19429
  const id = idPrefix(base);
19329
19430
  if (id != null) out.push({ id, rel: segs.join("/") });
@@ -19332,7 +19433,7 @@ function indexableCards() {
19332
19433
  }
19333
19434
  function readmeComplaints(fix) {
19334
19435
  const said2 = [];
19335
- const lines = fs58.readFileSync(README, "utf8").split("\n");
19436
+ const lines = fs59.readFileSync(README, "utf8").split("\n");
19336
19437
  const indexed = /* @__PURE__ */ new Set();
19337
19438
  let fixed = 0;
19338
19439
  for (let i = 0; i < lines.length; i++) {
@@ -19341,13 +19442,13 @@ function readmeComplaints(fix) {
19341
19442
  const id = Number(m[1]);
19342
19443
  const linkPath = m[2];
19343
19444
  indexed.add(id);
19344
- if (fs58.existsSync(path61.join(TODO, linkPath))) continue;
19445
+ if (fs59.existsSync(path62.join(TODO, linkPath))) continue;
19345
19446
  const found2 = locate(id);
19346
19447
  if (!found2) {
19347
19448
  said2.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
19348
19449
  continue;
19349
19450
  }
19350
- const want = (found2.kind === "group" ? path61.join(found2.rel, "root.md") : found2.rel).split(path61.sep).join("/");
19451
+ const want = (found2.kind === "group" ? path62.join(found2.rel, "root.md") : found2.rel).split(path62.sep).join("/");
19351
19452
  if (want === linkPath) continue;
19352
19453
  if (!fix) {
19353
19454
  said2.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
@@ -19357,7 +19458,7 @@ function readmeComplaints(fix) {
19357
19458
  said2.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
19358
19459
  fixed++;
19359
19460
  }
19360
- if (fixed) fs58.writeFileSync(README, lines.join("\n"));
19461
+ if (fixed) fs59.writeFileSync(README, lines.join("\n"));
19361
19462
  for (const c of indexableCards()) {
19362
19463
  if (!indexed.has(c.id)) {
19363
19464
  said2.push(`card ${c.rel} (#${c.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
@@ -19369,11 +19470,11 @@ function crossRefComplaints() {
19369
19470
  const said2 = [];
19370
19471
  const live = liveIds();
19371
19472
  for (const file of walkMd(TODO)) {
19372
- const base = path61.basename(file);
19473
+ const base = path62.basename(file);
19373
19474
  if (base === "README.md") continue;
19374
- const ownerId = base === "root.md" ? idPrefix(path61.basename(path61.dirname(file))) : idPrefix(base);
19475
+ const ownerId = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
19375
19476
  if (ownerId == null) continue;
19376
- const { meta } = parseFrontmatter(fs58.readFileSync(file, "utf8"));
19477
+ const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19377
19478
  if (!meta) continue;
19378
19479
  for (const field2 of ["blocked_by", "related"]) {
19379
19480
  for (const ref of meta[field2] || []) {
@@ -19386,11 +19487,11 @@ function crossRefComplaints() {
19386
19487
  return said2;
19387
19488
  }
19388
19489
  function reconcileBoard() {
19389
- if (!fs58.existsSync(README)) return;
19490
+ if (!fs59.existsSync(README)) return;
19390
19491
  for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
19391
19492
  }
19392
19493
  function boardComplaints() {
19393
- if (!fs58.existsSync(README)) return [];
19494
+ if (!fs59.existsSync(README)) return [];
19394
19495
  try {
19395
19496
  return [...readmeComplaints(false), ...crossRefComplaints()];
19396
19497
  } catch {
@@ -19410,8 +19511,8 @@ var init_reconcile = __esm({
19410
19511
  });
19411
19512
 
19412
19513
  // ../cli/src/commands/card.ts
19413
- import fs59 from "node:fs";
19414
- import path62 from "node:path";
19514
+ import fs60 from "node:fs";
19515
+ import path63 from "node:path";
19415
19516
  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>") {
19416
19517
  return [
19417
19518
  summary,
@@ -19437,7 +19538,7 @@ function bodyFromFile(opts) {
19437
19538
  if (opts.body === false) die("pass --body-file or --no-body, not both");
19438
19539
  let text4;
19439
19540
  try {
19440
- text4 = fs59.readFileSync(opts.bodyFile, "utf8");
19541
+ text4 = fs60.readFileSync(opts.bodyFile, "utf8");
19441
19542
  } catch {
19442
19543
  die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
19443
19544
  }
@@ -19502,20 +19603,20 @@ function cmdCreate(opts) {
19502
19603
  const start = opts.id;
19503
19604
  const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
19504
19605
  const fileRel = `${start}-${slug2}.md`;
19505
- const file = path62.join(TODO, fileRel);
19606
+ const file = path63.join(TODO, fileRel);
19506
19607
  const held4 = locate(start) ?? locateArchived(start);
19507
- if (held4 && path62.basename(held4.target) === `${start}-${slug2}.md`) {
19608
+ if (held4 && path63.basename(held4.target) === `${start}-${slug2}.md`) {
19508
19609
  say(start);
19509
19610
  say(` ${rel(held4.target)} was already written`);
19510
19611
  return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
19511
19612
  }
19512
19613
  if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
19513
- if (fs59.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
19614
+ if (fs60.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
19514
19615
  countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
19515
19616
  const meta = { title, priority, status: "todo", blocked_by, related, modules, studio, previews, stages, triage, source, questions };
19516
19617
  const scaffolded = !written && opts.body !== false;
19517
19618
  const body = written ?? (scaffolded ? defaultBody() : "");
19518
- fs59.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
19619
+ fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
19519
19620
  const indexed = addReadmeRef(start, title, fileRel);
19520
19621
  say(start);
19521
19622
  say(
@@ -19567,8 +19668,8 @@ function cmdUpdate(id, flags) {
19567
19668
  if (creating) die(creating, { kind: "card-being-created", id });
19568
19669
  const found2 = locate(id);
19569
19670
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
19570
- const file = found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target;
19571
- const { meta, body } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19671
+ const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
19672
+ const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
19572
19673
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
19573
19674
  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");
19574
19675
  if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
@@ -19642,26 +19743,26 @@ function cmdUpdate(id, flags) {
19642
19743
  meta.status = "todo";
19643
19744
  changes.push("status\u2192todo (open questions)");
19644
19745
  }
19645
- const curRel = path62.relative(TODO, file);
19746
+ const curRel = path63.relative(TODO, file);
19646
19747
  const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
19647
- let base = path62.basename(file);
19748
+ let base = path63.basename(file);
19648
19749
  if (flags.slug !== void 0) {
19649
19750
  if (found2.kind === "group") die("renaming a group root by script is not supported");
19650
19751
  base = `${id}-${slugify(flags.slug)}.md`;
19651
19752
  }
19652
- const destRel = path62.join(path62.dirname(curRel), base);
19653
- const dest = path62.join(TODO, destRel);
19753
+ const destRel = path63.join(path63.dirname(curRel), base);
19754
+ const dest = path63.join(TODO, destRel);
19654
19755
  const moving = dest !== file;
19655
- if (moving && fs59.existsSync(dest)) die(`${rel(dest)} already exists`);
19656
- fs59.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19657
- if (moving) fs59.renameSync(file, dest);
19756
+ if (moving && fs60.existsSync(dest)) die(`${rel(dest)} already exists`);
19757
+ fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19758
+ if (moving) fs60.renameSync(file, dest);
19658
19759
  if (isSubtask) {
19659
19760
  if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
19660
- if (moving) changes.push(`renamed \u2192 ${destRel.split(path62.sep).join("/")}`);
19761
+ if (moving) changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
19661
19762
  } else if (moving) {
19662
19763
  stripReadmeRefs({ kind: "file", rel: curRel });
19663
19764
  addReadmeRef(id, meta.title, destRel);
19664
- changes.push(`renamed \u2192 ${destRel.split(path62.sep).join("/")}`);
19765
+ changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
19665
19766
  } else if (changes.includes("title")) {
19666
19767
  stripReadmeRefs({ kind: "file", rel: curRel });
19667
19768
  addReadmeRef(id, meta.title, curRel);
@@ -19673,8 +19774,8 @@ function cmdUpdateQuestions(id, input) {
19673
19774
  const ops = readQuestionOps(input.ops ?? []);
19674
19775
  const found2 = locate(id);
19675
19776
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
19676
- const file = found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target;
19677
- const { meta, body } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19777
+ const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
19778
+ const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
19678
19779
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
19679
19780
  for (const op of ops) {
19680
19781
  if (!op.question?.agent) continue;
@@ -19696,7 +19797,7 @@ function cmdUpdateQuestions(id, input) {
19696
19797
  meta.status = "todo";
19697
19798
  changes.push("status\u2192todo (open questions)");
19698
19799
  }
19699
- fs59.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19800
+ fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19700
19801
  const closed2 = activeDelivery(id) ? "questions_closed_verify" : "questions_closed_user";
19701
19802
  for (const _ of done2.closed) countBoardEvent(closed2);
19702
19803
  say(`updated #${id} questions: ${changes.join(", ")} (${open3} open)`);
@@ -19763,13 +19864,13 @@ var init_config_template = __esm({
19763
19864
  });
19764
19865
 
19765
19866
  // ../cli/src/lib/agent/local.ts
19766
- import fs60 from "node:fs";
19767
- import path63 from "node:path";
19867
+ import fs61 from "node:fs";
19868
+ import path64 from "node:path";
19768
19869
  function takeLocalModels(board2) {
19769
- const file = path63.join(board2, ".local.json");
19870
+ const file = path64.join(board2, ".local.json");
19770
19871
  let held4;
19771
19872
  try {
19772
- held4 = configBlock(JSON.parse(fs60.readFileSync(file, "utf8")));
19873
+ held4 = configBlock(JSON.parse(fs61.readFileSync(file, "utf8")));
19773
19874
  } catch {
19774
19875
  return {};
19775
19876
  }
@@ -19787,7 +19888,7 @@ function takeLocalModels(board2) {
19787
19888
  }
19788
19889
  if (!Object.keys(agents).length) return out;
19789
19890
  delete held4.agents;
19790
- fs60.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19891
+ fs61.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19791
19892
  return out;
19792
19893
  }
19793
19894
  var LOCAL_IGNORE_LINE;
@@ -19848,12 +19949,12 @@ var init_identity2 = __esm({
19848
19949
  });
19849
19950
 
19850
19951
  // ../cli/src/lib/signals/migrate.ts
19851
- import fs61 from "node:fs";
19852
- import path64 from "node:path";
19952
+ import fs62 from "node:fs";
19953
+ import path65 from "node:path";
19853
19954
  function readHandled() {
19854
19955
  let text4;
19855
19956
  try {
19856
- text4 = fs61.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19957
+ text4 = fs62.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19857
19958
  } catch {
19858
19959
  return [];
19859
19960
  }
@@ -19870,57 +19971,57 @@ function readHandled() {
19870
19971
  return held4;
19871
19972
  }
19872
19973
  function lift(from, into) {
19873
- fs61.mkdirSync(into, { recursive: true });
19874
- fs61.renameSync(from, path64.join(into, freeName(into, path64.basename(from))));
19974
+ fs62.mkdirSync(into, { recursive: true });
19975
+ fs62.renameSync(from, path65.join(into, freeName(into, path65.basename(from))));
19875
19976
  }
19876
19977
  function repoint(dir, from, into) {
19877
19978
  let entries;
19878
19979
  try {
19879
- entries = fs61.readdirSync(dir, { withFileTypes: true });
19980
+ entries = fs62.readdirSync(dir, { withFileTypes: true });
19880
19981
  } catch {
19881
19982
  return;
19882
19983
  }
19883
19984
  for (const entry of entries) {
19884
19985
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
19885
- const file = path64.join(dir, entry.name);
19886
- const text4 = fs61.readFileSync(file, "utf8");
19887
- if (text4.includes(from)) fs61.writeFileSync(file, text4.split(from).join(into));
19986
+ const file = path65.join(dir, entry.name);
19987
+ const text4 = fs62.readFileSync(file, "utf8");
19988
+ if (text4.includes(from)) fs62.writeFileSync(file, text4.split(from).join(into));
19888
19989
  }
19889
19990
  }
19890
19991
  function dropIfEmpty2(dir) {
19891
19992
  try {
19892
- fs61.rmdirSync(dir);
19993
+ fs62.rmdirSync(dir);
19893
19994
  } catch {
19894
19995
  }
19895
19996
  }
19896
19997
  function liftInbox() {
19897
- if (!fs61.existsSync(SIGNALS_OLD_INBOX)) return;
19898
- const oldFiles = path64.join(SIGNALS_OLD_INBOX, "files");
19899
- if (fs61.existsSync(oldFiles)) {
19900
- for (const entry of fs61.readdirSync(oldFiles, { withFileTypes: true })) {
19901
- if (entry.isFile()) lift(path64.join(oldFiles, entry.name), SIGNALS_FILES);
19998
+ if (!fs62.existsSync(SIGNALS_OLD_INBOX)) return;
19999
+ const oldFiles = path65.join(SIGNALS_OLD_INBOX, "files");
20000
+ if (fs62.existsSync(oldFiles)) {
20001
+ for (const entry of fs62.readdirSync(oldFiles, { withFileTypes: true })) {
20002
+ if (entry.isFile()) lift(path65.join(oldFiles, entry.name), SIGNALS_FILES);
19902
20003
  }
19903
20004
  dropIfEmpty2(oldFiles);
19904
20005
  }
19905
20006
  const held4 = new Set(readFolder2(TRIAGE).map((signal2) => signal2.sourceId));
19906
- for (const entry of fs61.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
20007
+ for (const entry of fs62.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19907
20008
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
19908
- const from = path64.join(SIGNALS_OLD_INBOX, entry.name);
20009
+ const from = path65.join(SIGNALS_OLD_INBOX, entry.name);
19909
20010
  const item = parse(from);
19910
20011
  if (item && held4.has(item.sourceId)) {
19911
- fs61.rmSync(from, { force: true });
20012
+ fs62.rmSync(from, { force: true });
19912
20013
  continue;
19913
20014
  }
19914
20015
  if (item) held4.add(item.sourceId);
19915
20016
  lift(from, TRIAGE);
19916
20017
  }
19917
- const wasAt = asWritten(path64.join(SIGNALS_OLD_INBOX, "files"));
20018
+ const wasAt = asWritten(path65.join(SIGNALS_OLD_INBOX, "files"));
19918
20019
  const nowAt = asWritten(SIGNALS_FILES);
19919
20020
  for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
19920
20021
  dropIfEmpty2(SIGNALS_OLD_INBOX);
19921
20022
  }
19922
20023
  function liftHandled() {
19923
- if (!fs61.existsSync(SIGNALS_OLD_HANDLED)) return;
20024
+ if (!fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
19924
20025
  const lines = readHandled();
19925
20026
  const held4 = /* @__PURE__ */ new Set([
19926
20027
  ...readFolder2(TRIAGE).map((signal2) => signal2.sourceId),
@@ -19930,7 +20031,7 @@ function liftHandled() {
19930
20031
  for (const { sourceId, when } of lines) {
19931
20032
  if (held4.has(sourceId)) continue;
19932
20033
  held4.add(sourceId);
19933
- fs61.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
20034
+ fs62.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19934
20035
  const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
19935
20036
  const front = [
19936
20037
  "---",
@@ -19940,13 +20041,13 @@ function liftHandled() {
19940
20041
  "---",
19941
20042
  ""
19942
20043
  ];
19943
- fs61.writeFileSync(path64.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
20044
+ fs62.writeFileSync(path65.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19944
20045
  `);
19945
20046
  }
19946
- fs61.rmSync(SIGNALS_OLD_HANDLED, { force: true });
20047
+ fs62.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19947
20048
  }
19948
20049
  function migrateTriage() {
19949
- if (!fs61.existsSync(SIGNALS_OLD_INBOX) && !fs61.existsSync(SIGNALS_OLD_HANDLED)) return;
20050
+ if (!fs62.existsSync(SIGNALS_OLD_INBOX) && !fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
19950
20051
  try {
19951
20052
  liftInbox();
19952
20053
  liftHandled();
@@ -19961,13 +20062,13 @@ var init_migrate = __esm({
19961
20062
  init_yaml();
19962
20063
  init_inbox();
19963
20064
  HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
19964
- asWritten = (dir) => `${rel(dir).split(path64.sep).join("/")}/`;
20065
+ asWritten = (dir) => `${rel(dir).split(path65.sep).join("/")}/`;
19965
20066
  }
19966
20067
  });
19967
20068
 
19968
20069
  // ../cli/src/lib/signals/add.ts
19969
- import fs62 from "node:fs";
19970
- import path65 from "node:path";
20070
+ import fs63 from "node:fs";
20071
+ import path66 from "node:path";
19971
20072
  import { createHash as createHash4 } from "node:crypto";
19972
20073
  function linkTitle(url) {
19973
20074
  let at;
@@ -19980,7 +20081,7 @@ function linkTitle(url) {
19980
20081
  return oneLine(where) || url.slice(0, TITLE_MAX);
19981
20082
  }
19982
20083
  function asText(file) {
19983
- const ext = path65.extname(file.name).toLowerCase();
20084
+ const ext = path66.extname(file.name).toLowerCase();
19984
20085
  if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
19985
20086
  try {
19986
20087
  const text4 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
@@ -19990,9 +20091,9 @@ function asText(file) {
19990
20091
  }
19991
20092
  }
19992
20093
  function fileName2(name, data) {
19993
- const base = path65.basename(name);
19994
- const ext = path65.extname(base).toLowerCase().slice(0, 12);
19995
- const word = path65.basename(base, path65.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
20094
+ const base = path66.basename(name);
20095
+ const ext = path66.extname(base).toLowerCase().slice(0, 12);
20096
+ const word = path66.basename(base, path66.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
19996
20097
  const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
19997
20098
  return `${word}-${hash2}${ext}`;
19998
20099
  }
@@ -20001,9 +20102,9 @@ function addToInbox(drop) {
20001
20102
  const typed = (drop.text ?? "").trim();
20002
20103
  const file = drop.file;
20003
20104
  if (!typed && !file) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
20004
- if (file && file.data.length === 0) return { ok: false, error: `${path65.basename(file.name)} is empty.` };
20105
+ if (file && file.data.length === 0) return { ok: false, error: `${path66.basename(file.name)} is empty.` };
20005
20106
  if (file && file.data.length > MAX_BYTES2) {
20006
- return { ok: false, error: `${path65.basename(file.name)} is over ${MAX_BYTES2 / 1024 / 1024} MB \u2014 too big for the board.` };
20107
+ return { ok: false, error: `${path66.basename(file.name)} is over ${MAX_BYTES2 / 1024 / 1024} MB \u2014 too big for the board.` };
20007
20108
  }
20008
20109
  const read3 = describe(typed, file);
20009
20110
  const keep2 = read3.keep;
@@ -20025,8 +20126,8 @@ ${incoming.summary}`);
20025
20126
  if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
20026
20127
  try {
20027
20128
  if (keep2) {
20028
- fs62.mkdirSync(SIGNALS_FILES, { recursive: true });
20029
- fs62.writeFileSync(keep2.at, keep2.data);
20129
+ fs63.mkdirSync(SIGNALS_FILES, { recursive: true });
20130
+ fs63.writeFileSync(keep2.at, keep2.data);
20030
20131
  }
20031
20132
  return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
20032
20133
  } catch (e) {
@@ -20040,7 +20141,7 @@ function describe(typed, file) {
20040
20141
  return only ? [only] : [];
20041
20142
  };
20042
20143
  if (file) {
20043
- const name = path65.basename(file.name);
20144
+ const name = path66.basename(file.name);
20044
20145
  const text4 = asText(file);
20045
20146
  const note = typed ? `
20046
20147
 
@@ -20052,7 +20153,7 @@ ${typed}` : "";
20052
20153
  const at = keepAt(file);
20053
20154
  return {
20054
20155
  incoming: {
20055
- title: path65.basename(name, path65.extname(name)) || name,
20156
+ title: path66.basename(name, path66.extname(name)) || name,
20056
20157
  summary: `${name} \u2014 ${boardRel2(at)}${note}`,
20057
20158
  ...named2
20058
20159
  },
@@ -20090,73 +20191,73 @@ var init_add = __esm({
20090
20191
  MAX_BYTES2 = 25 * 1024 * 1024;
20091
20192
  TITLE_MAX = 120;
20092
20193
  TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
20093
- boardRel2 = (file) => rel(file).split(path65.sep).join("/");
20194
+ boardRel2 = (file) => rel(file).split(path66.sep).join("/");
20094
20195
  oneLine = (text4) => {
20095
20196
  const first = text4.split("\n").find((line) => line.trim()) ?? "";
20096
20197
  const clean = first.replace(/^#+\s*/, "").trim();
20097
20198
  return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
20098
20199
  };
20099
- keepAt = (file) => path65.join(SIGNALS_FILES, fileName2(file.name, file.data));
20200
+ keepAt = (file) => path66.join(SIGNALS_FILES, fileName2(file.name, file.data));
20100
20201
  }
20101
20202
  });
20102
20203
 
20103
20204
  // ../cli/src/lib/recurring.ts
20104
- import fs63 from "node:fs";
20105
- import path66 from "node:path";
20205
+ import fs64 from "node:fs";
20206
+ import path67 from "node:path";
20106
20207
  function migratePruneMemoryCard() {
20107
20208
  const dir = recurringDir();
20108
20209
  let names3;
20109
20210
  try {
20110
- names3 = fs63.readdirSync(dir);
20211
+ names3 = fs64.readdirSync(dir);
20111
20212
  } catch {
20112
20213
  return null;
20113
20214
  }
20114
20215
  const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
20115
20216
  if (!name) return null;
20116
- const file = path66.join(dir, name);
20217
+ const file = path67.join(dir, name);
20117
20218
  try {
20118
- const { meta } = parseFrontmatter(fs63.readFileSync(file, "utf8"));
20219
+ const { meta } = parseFrontmatter(fs64.readFileSync(file, "utf8"));
20119
20220
  const cadence = meta?.cadence;
20120
20221
  if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
20121
20222
  } catch {
20122
20223
  }
20123
- fs63.rmSync(file, { force: true });
20224
+ fs64.rmSync(file, { force: true });
20124
20225
  return rel(file);
20125
20226
  }
20126
20227
  function legacyCards() {
20127
20228
  const dir = recurringDir();
20128
- if (!fs63.existsSync(dir)) return [];
20229
+ if (!fs64.existsSync(dir)) return [];
20129
20230
  const cards = [];
20130
- for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
20231
+ for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20131
20232
  const id = idPrefix(entry.name);
20132
20233
  if (id === null) continue;
20133
- const full = path66.join(dir, entry.name);
20234
+ const full = path67.join(dir, entry.name);
20134
20235
  const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
20135
20236
  if (entry.isFile() && entry.name.endsWith(".md")) cards.push({ id, slug: slug2, file: full });
20136
- else if (entry.isDirectory() && fs63.existsSync(path66.join(full, "root.md"))) {
20137
- cards.push({ id, slug: slug2, file: path66.join(full, "root.md"), folder: full });
20237
+ else if (entry.isDirectory() && fs64.existsSync(path67.join(full, "root.md"))) {
20238
+ cards.push({ id, slug: slug2, file: path67.join(full, "root.md"), folder: full });
20138
20239
  }
20139
20240
  }
20140
20241
  return cards.sort((a, b) => a.id - b.id);
20141
20242
  }
20142
20243
  function mergeInto2(from, to, skip = []) {
20143
- fs63.mkdirSync(to, { recursive: true });
20144
- for (const entry of fs63.readdirSync(from, { withFileTypes: true })) {
20244
+ fs64.mkdirSync(to, { recursive: true });
20245
+ for (const entry of fs64.readdirSync(from, { withFileTypes: true })) {
20145
20246
  if (skip.includes(entry.name)) continue;
20146
- const source = path66.join(from, entry.name);
20147
- const target = path66.join(to, entry.name);
20148
- if (!fs63.existsSync(target)) fs63.renameSync(source, target);
20149
- else if (entry.isDirectory() && fs63.statSync(target).isDirectory()) mergeInto2(source, target);
20247
+ const source = path67.join(from, entry.name);
20248
+ const target = path67.join(to, entry.name);
20249
+ if (!fs64.existsSync(target)) fs64.renameSync(source, target);
20250
+ else if (entry.isDirectory() && fs64.statSync(target).isDirectory()) mergeInto2(source, target);
20150
20251
  }
20151
- if (isEmpty(from)) fs63.rmSync(from, { recursive: true, force: true });
20252
+ if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
20152
20253
  }
20153
20254
  function moveSideFolders() {
20154
20255
  const dir = recurringDir();
20155
- for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
20256
+ for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20156
20257
  if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
20157
- const from = path66.join(dir, entry.name);
20158
- if (isEmpty(from)) fs63.rmSync(from, { recursive: true, force: true });
20159
- else mergeInto2(from, path66.join(AGENTS, entry.name));
20258
+ const from = path67.join(dir, entry.name);
20259
+ if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
20260
+ else mergeInto2(from, path67.join(AGENTS, entry.name));
20160
20261
  }
20161
20262
  }
20162
20263
  function sections(body) {
@@ -20206,8 +20307,8 @@ function agentName(card, text4) {
20206
20307
  const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a) => a.name), ...ROLE_NAMES]);
20207
20308
  for (const name of [slug2, `${slug2}-${card.id}`]) {
20208
20309
  if (!AGENT_NAME.test(name)) continue;
20209
- const file = path66.join(AGENTS, name, AGENT_FILE2);
20210
- const written = fs63.existsSync(file) ? fs63.readFileSync(file, "utf8") : null;
20310
+ const file = path67.join(AGENTS, name, AGENT_FILE2);
20311
+ const written = fs64.existsSync(file) ? fs64.readFileSync(file, "utf8") : null;
20211
20312
  if (written === text4(name)) return name;
20212
20313
  if (written === null && !known2.has(name)) return name;
20213
20314
  }
@@ -20224,11 +20325,11 @@ ${q.options.map((o) => `- ${o}`).join("\n")}` : "";
20224
20325
  function removeCard(card) {
20225
20326
  dropCrossRefs(card.id);
20226
20327
  const target = card.folder ?? card.file;
20227
- stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path66.relative(TODO, target).split(path66.sep).join("/") });
20228
- fs63.rmSync(target, { recursive: true, force: true });
20328
+ stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path67.relative(TODO, target).split(path67.sep).join("/") });
20329
+ fs64.rmSync(target, { recursive: true, force: true });
20229
20330
  }
20230
20331
  function migrateCard(card) {
20231
- const { meta, body } = parseFrontmatter(fs63.readFileSync(card.file, "utf8"));
20332
+ const { meta, body } = parseFrontmatter(fs64.readFileSync(card.file, "utf8"));
20232
20333
  if (!meta) throw new Error("its frontmatter cannot be read");
20233
20334
  const raw = meta;
20234
20335
  const said2 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
@@ -20238,19 +20339,19 @@ function migrateCard(card) {
20238
20339
  if (!flow) throw new Error(noStudioMessage(""));
20239
20340
  const text4 = (name2) => agentText(name2, meta.title || card.slug, body);
20240
20341
  const name = agentName(card, text4);
20241
- const dir = path66.join(AGENTS, name);
20242
- const file = path66.join(dir, AGENT_FILE2);
20243
- const madeDir = !fs63.existsSync(dir);
20244
- const wrote = !fs63.existsSync(file);
20342
+ const dir = path67.join(AGENTS, name);
20343
+ const file = path67.join(dir, AGENT_FILE2);
20344
+ const madeDir = !fs64.existsSync(dir);
20345
+ const wrote = !fs64.existsSync(file);
20245
20346
  try {
20246
- fs63.mkdirSync(dir, { recursive: true });
20247
- if (wrote) fs63.writeFileSync(file, text4(name));
20347
+ fs64.mkdirSync(dir, { recursive: true });
20348
+ if (wrote) fs64.writeFileSync(file, text4(name));
20248
20349
  const adopted = adoptStudioScheduled(flow.id, name, { cadence, lastRun });
20249
20350
  if (!adopted.ok) throw new Error(adopted.error);
20250
20351
  questionsToTriage(meta, name);
20251
20352
  } catch (e) {
20252
- if (madeDir) fs63.rmSync(dir, { recursive: true, force: true });
20253
- else if (wrote) fs63.rmSync(file, { force: true });
20353
+ if (madeDir) fs64.rmSync(dir, { recursive: true, force: true });
20354
+ else if (wrote) fs64.rmSync(file, { force: true });
20254
20355
  throw e;
20255
20356
  }
20256
20357
  if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
@@ -20260,7 +20361,7 @@ function migrateCard(card) {
20260
20361
  function migrateRecurringCards() {
20261
20362
  const done2 = { agents: [], removed: [], failed: [] };
20262
20363
  const dir = recurringDir();
20263
- if (!fs63.existsSync(dir)) return done2;
20364
+ if (!fs64.existsSync(dir)) return done2;
20264
20365
  migratePruneMemoryCard();
20265
20366
  moveSideFolders();
20266
20367
  for (const card of legacyCards()) {
@@ -20273,7 +20374,7 @@ function migrateRecurringCards() {
20273
20374
  done2.failed.push({ card: rel(card.file), why: e instanceof Error ? e.message : String(e) });
20274
20375
  }
20275
20376
  }
20276
- if (isEmpty(dir)) fs63.rmSync(dir, { recursive: true, force: true });
20377
+ if (isEmpty(dir)) fs64.rmSync(dir, { recursive: true, force: true });
20277
20378
  return done2;
20278
20379
  }
20279
20380
  function recurringMigrationLines(done2) {
@@ -20306,14 +20407,14 @@ var init_recurring = __esm({
20306
20407
  PRUNE_SLUG = "prune-the-memory";
20307
20408
  FETCH_SLUG = "fetch-triage-items";
20308
20409
  AGENT_FILE2 = "AGENT.md";
20309
- recurringDir = () => path66.join(TODO, LEGACY_RECURRING);
20310
- isEmpty = (dir) => fs63.readdirSync(dir).every((name) => name === ".DS_Store");
20410
+ recurringDir = () => path67.join(TODO, LEGACY_RECURRING);
20411
+ isEmpty = (dir) => fs64.readdirSync(dir).every((name) => name === ".DS_Store");
20311
20412
  SECTION = /^##\s+(.+?)\s*$/;
20312
20413
  }
20313
20414
  });
20314
20415
 
20315
20416
  // ../cli/src/commands/init.ts
20316
- import fs64 from "node:fs";
20417
+ import fs65 from "node:fs";
20317
20418
  function boardReadme() {
20318
20419
  return `# Board
20319
20420
 
@@ -20326,20 +20427,20 @@ _(none)_
20326
20427
  `;
20327
20428
  }
20328
20429
  function writeConfigIfMissing() {
20329
- if (fs64.existsSync(CONFIG)) return false;
20330
- fs64.mkdirSync(KANBAN, { recursive: true });
20331
- fs64.writeFileSync(CONFIG, CONFIG_TEMPLATE);
20430
+ if (fs65.existsSync(CONFIG)) return false;
20431
+ fs65.mkdirSync(KANBAN, { recursive: true });
20432
+ fs65.writeFileSync(CONFIG, CONFIG_TEMPLATE);
20332
20433
  return true;
20333
20434
  }
20334
20435
  function writeModulesIfMissing() {
20335
- if (fs64.existsSync(MODULES_MD)) return false;
20336
- fs64.mkdirSync(KANBAN, { recursive: true });
20337
- fs64.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
20436
+ if (fs65.existsSync(MODULES_MD)) return false;
20437
+ fs65.mkdirSync(KANBAN, { recursive: true });
20438
+ fs65.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
20338
20439
  return true;
20339
20440
  }
20340
20441
  function writeGitignoreIfMissing() {
20341
- fs64.mkdirSync(KANBAN, { recursive: true });
20342
- const text4 = fs64.existsSync(KANBAN_GITIGNORE) ? fs64.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
20442
+ fs65.mkdirSync(KANBAN, { recursive: true });
20443
+ const text4 = fs65.existsSync(KANBAN_GITIGNORE) ? fs65.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
20343
20444
  const has = (rule) => text4.split("\n").some((line) => line.trim() === rule.line);
20344
20445
  const missing = IGNORE_RULES.filter((rule) => !has(rule));
20345
20446
  if (!missing.length) return false;
@@ -20347,37 +20448,37 @@ function writeGitignoreIfMissing() {
20347
20448
  ${rule.line}
20348
20449
  `).join("");
20349
20450
  const separator = !text4 || text4.endsWith("\n") ? "" : "\n";
20350
- fs64.writeFileSync(KANBAN_GITIGNORE, `${text4}${separator}${block}`);
20451
+ fs65.writeFileSync(KANBAN_GITIGNORE, `${text4}${separator}${block}`);
20351
20452
  return true;
20352
20453
  }
20353
20454
  function writeSkeletonIfMissing() {
20354
20455
  const added = [];
20355
- if (!fs64.existsSync(TODO)) {
20356
- fs64.mkdirSync(TODO, { recursive: true });
20456
+ if (!fs65.existsSync(TODO)) {
20457
+ fs65.mkdirSync(TODO, { recursive: true });
20357
20458
  added.push(`${rel(TODO)}/`);
20358
20459
  }
20359
- if (!fs64.existsSync(README)) {
20360
- fs64.writeFileSync(README, boardReadme());
20460
+ if (!fs65.existsSync(README)) {
20461
+ fs65.writeFileSync(README, boardReadme());
20361
20462
  added.push(rel(README));
20362
20463
  }
20363
20464
  return added;
20364
20465
  }
20365
20466
  function retireReleases() {
20366
20467
  const done2 = [];
20367
- if (fs64.existsSync(RELEASES)) {
20368
- fs64.rmSync(RELEASES);
20468
+ if (fs65.existsSync(RELEASES)) {
20469
+ fs65.rmSync(RELEASES);
20369
20470
  done2.push(`deleted ${rel(RELEASES)}`);
20370
20471
  }
20371
20472
  let cards = 0;
20372
20473
  for (const dir of [TODO, ARCHIVE]) {
20373
- if (!fs64.existsSync(dir)) continue;
20474
+ if (!fs65.existsSync(dir)) continue;
20374
20475
  for (const file of walkMd(dir)) {
20375
- const text4 = fs64.readFileSync(file, "utf8");
20476
+ const text4 = fs65.readFileSync(file, "utf8");
20376
20477
  const end2 = text4.startsWith("---\n") ? text4.indexOf("\n---", 3) : -1;
20377
20478
  if (end2 < 0) continue;
20378
20479
  const head2 = text4.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
20379
20480
  if (head2.length === end2) continue;
20380
- fs64.writeFileSync(file, head2 + text4.slice(end2));
20481
+ fs65.writeFileSync(file, head2 + text4.slice(end2));
20381
20482
  cards++;
20382
20483
  }
20383
20484
  }
@@ -20385,7 +20486,7 @@ function retireReleases() {
20385
20486
  return done2.join(", ");
20386
20487
  }
20387
20488
  function cmdInit() {
20388
- if (fs64.existsSync(KANBAN)) {
20489
+ if (fs65.existsSync(KANBAN)) {
20389
20490
  const added = [
20390
20491
  ...writeSkeletonIfMissing(),
20391
20492
  writeConfigIfMissing() && rel(CONFIG),
@@ -20420,8 +20521,8 @@ function cmdInit() {
20420
20521
  }
20421
20522
  return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
20422
20523
  }
20423
- fs64.mkdirSync(TODO, { recursive: true });
20424
- fs64.writeFileSync(README, boardReadme());
20524
+ fs65.mkdirSync(TODO, { recursive: true });
20525
+ fs65.writeFileSync(README, boardReadme());
20425
20526
  writeConfigIfMissing();
20426
20527
  scaffoldProjectMemory();
20427
20528
  writeModulesIfMissing();
@@ -20510,25 +20611,25 @@ var init_scheduled = __esm({
20510
20611
  });
20511
20612
 
20512
20613
  // ../cli/src/lib/card-age.ts
20513
- import fs65 from "node:fs";
20514
- import path67 from "node:path";
20614
+ import fs66 from "node:fs";
20615
+ import path68 from "node:path";
20515
20616
  function staleAfterIn(config) {
20516
20617
  const days = Number(LINE.exec(config)?.[1]);
20517
20618
  return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
20518
20619
  }
20519
20620
  function staleAfter() {
20520
- if (!fs65.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
20521
- return staleAfterIn(fs65.readFileSync(CONFIG, "utf8"));
20621
+ if (!fs66.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
20622
+ return staleAfterIn(fs66.readFileSync(CONFIG, "utf8"));
20522
20623
  }
20523
20624
  function todoPathspec(top) {
20524
- const from = path67.relative(real(top), real(TODO));
20525
- if (!from || from.startsWith("..") || path67.isAbsolute(from)) return null;
20526
- return from.split(path67.sep).join("/");
20625
+ const from = path68.relative(real(top), real(TODO));
20626
+ if (!from || from.startsWith("..") || path68.isAbsolute(from)) return null;
20627
+ return from.split(path68.sep).join("/");
20527
20628
  }
20528
20629
  function cardFile2(spec, printed) {
20529
20630
  const p = unquotePath(printed);
20530
20631
  if (!p.startsWith(`${spec}/`)) return null;
20531
- return path67.join(TODO, ...p.slice(spec.length + 1).split("/"));
20632
+ return path68.join(TODO, ...p.slice(spec.length + 1).split("/"));
20532
20633
  }
20533
20634
  function dirtyCards(top, spec) {
20534
20635
  const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
@@ -20575,9 +20676,9 @@ var init_card_age = __esm({
20575
20676
  gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
20576
20677
  real = (p) => {
20577
20678
  try {
20578
- return fs65.realpathSync(p);
20679
+ return fs66.realpathSync(p);
20579
20680
  } catch {
20580
- return path67.resolve(p);
20681
+ return path68.resolve(p);
20581
20682
  }
20582
20683
  };
20583
20684
  unquotePath = (line) => {
@@ -20611,8 +20712,8 @@ var init_card_holds = __esm({
20611
20712
  });
20612
20713
 
20613
20714
  // ../cli/src/commands/list.ts
20614
- import fs66 from "node:fs";
20615
- import path68 from "node:path";
20715
+ import fs67 from "node:fs";
20716
+ import path69 from "node:path";
20616
20717
  function summaryLine(body) {
20617
20718
  const lines = body.split("\n");
20618
20719
  let i = 0;
@@ -20628,13 +20729,13 @@ function summaryLine(body) {
20628
20729
  function openRows() {
20629
20730
  const rows = [];
20630
20731
  for (const file of walkMd(TODO)) {
20631
- const base = path68.basename(file);
20732
+ const base = path69.basename(file);
20632
20733
  if (base === "README.md") continue;
20633
20734
  const isRoot = base === "root.md";
20634
- const id = isRoot ? idPrefix(path68.basename(path68.dirname(file))) : idPrefix(base);
20735
+ const id = isRoot ? idPrefix(path69.basename(path69.dirname(file))) : idPrefix(base);
20635
20736
  if (id == null) continue;
20636
- if (isLegacyRecurring(path68.relative(TODO, file))) continue;
20637
- const { meta, body } = parseFrontmatter(fs66.readFileSync(file, "utf8"));
20737
+ if (isLegacyRecurring(path69.relative(TODO, file))) continue;
20738
+ const { meta, body } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
20638
20739
  rows.push({
20639
20740
  id,
20640
20741
  file,
@@ -20676,15 +20777,15 @@ function cmdStale(rows, all2, scope, mod) {
20676
20777
  }
20677
20778
  function archivedFiles() {
20678
20779
  const files = /* @__PURE__ */ new Map();
20679
- if (!fs66.existsSync(ARCHIVE)) return files;
20780
+ if (!fs67.existsSync(ARCHIVE)) return files;
20680
20781
  for (const file of walkMd(ARCHIVE)) {
20681
- const id = idPrefix(path68.basename(file));
20782
+ const id = idPrefix(path69.basename(file));
20682
20783
  if (id !== null) files.set(id, file);
20683
20784
  }
20684
20785
  for (const dir of walkDirs(ARCHIVE)) {
20685
- const id = idPrefix(path68.basename(dir));
20686
- const root2 = path68.join(dir, "root.md");
20687
- if (id !== null && fs66.existsSync(root2)) files.set(id, root2);
20786
+ const id = idPrefix(path69.basename(dir));
20787
+ const root2 = path69.join(dir, "root.md");
20788
+ if (id !== null && fs67.existsSync(root2)) files.set(id, root2);
20688
20789
  }
20689
20790
  return files;
20690
20791
  }
@@ -20794,8 +20895,8 @@ var init_list = __esm({
20794
20895
  });
20795
20896
 
20796
20897
  // ../cli/src/lib/card-sources.ts
20797
- import fs67 from "node:fs";
20798
- import path69 from "node:path";
20898
+ import fs68 from "node:fs";
20899
+ import path70 from "node:path";
20799
20900
  function planById(id) {
20800
20901
  const found2 = readPlan(`plans/${id}-.md`);
20801
20902
  return found2?.text.trim() ? found2 : null;
@@ -20805,8 +20906,8 @@ function cardLink(id) {
20805
20906
  const found2 = open3 ?? locateArchived(id);
20806
20907
  if (!found2) return null;
20807
20908
  try {
20808
- const file = found2.kind === "group" ? path69.join(found2.target, "root.md") : found2.target;
20809
- const title = parseFrontmatter(fs67.readFileSync(file, "utf8")).meta?.title ?? "";
20909
+ const file = found2.kind === "group" ? path70.join(found2.target, "root.md") : found2.target;
20910
+ const title = parseFrontmatter(fs68.readFileSync(file, "utf8")).meta?.title ?? "";
20810
20911
  return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
20811
20912
  } catch {
20812
20913
  return null;
@@ -20831,7 +20932,7 @@ function link(ref, items) {
20831
20932
  if (ref.kind === "plan") return planLink(ref.id);
20832
20933
  if (ref.kind === "card") return cardLink(ref.id);
20833
20934
  if (ref.kind === "url") return urlLink(ref.url);
20834
- const item = items().find((signal2) => path69.basename(signal2.relPath) === ref.file);
20935
+ const item = items().find((signal2) => path70.basename(signal2.relPath) === ref.file);
20835
20936
  return item ? itemLink(item) : null;
20836
20937
  }
20837
20938
  function cardSources(meta, body) {
@@ -20872,12 +20973,12 @@ var init_card_sources = __esm({
20872
20973
  });
20873
20974
 
20874
20975
  // ../cli/src/lib/view/read.ts
20875
- import fs68 from "node:fs";
20876
- import path70 from "node:path";
20976
+ import fs69 from "node:fs";
20977
+ import path71 from "node:path";
20877
20978
  function readCard(file, relFromTodo) {
20878
- const id = idPrefix(path70.basename(relFromTodo));
20979
+ const id = idPrefix(path71.basename(relFromTodo));
20879
20980
  if (id === null) {
20880
- const parts = relFromTodo.split(path70.sep);
20981
+ const parts = relFromTodo.split(path71.sep);
20881
20982
  const folderId = idPrefix(parts[parts.length - 2] || "");
20882
20983
  if (folderId === null) return null;
20883
20984
  return buildCard(folderId, file, relFromTodo);
@@ -20885,10 +20986,10 @@ function readCard(file, relFromTodo) {
20885
20986
  return buildCard(id, file, relFromTodo);
20886
20987
  }
20887
20988
  function buildCard(id, file, relFromTodo) {
20888
- const text4 = fs68.readFileSync(file, "utf8");
20989
+ const text4 = fs69.readFileSync(file, "utf8");
20889
20990
  const { meta, body } = parseFrontmatter(text4);
20890
20991
  if (!meta) return null;
20891
- const relPath = relFromTodo.split(path70.sep).join("/");
20992
+ const relPath = relFromTodo.split(path71.sep).join("/");
20892
20993
  const flow = studioFor(meta.studio);
20893
20994
  const plan = !!meta.studio && archivesOnApproval(flow);
20894
20995
  const stages = cardStages(meta, flow).length;
@@ -20897,7 +20998,7 @@ function buildCard(id, file, relFromTodo) {
20897
20998
  // Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
20898
20999
  // read here and a card read by the contract agree on what version this is.
20899
21000
  revision: revisionOf(text4),
20900
- updatedAt: fs68.statSync(file).mtime.toISOString(),
21001
+ updatedAt: fs69.statSync(file).mtime.toISOString(),
20901
21002
  relPath,
20902
21003
  title: meta.title,
20903
21004
  priority: meta.priority,
@@ -20918,22 +21019,22 @@ function buildCard(id, file, relFromTodo) {
20918
21019
  };
20919
21020
  }
20920
21021
  function readGroup2(folderName) {
20921
- const groupDir = path70.join(TODO, folderName);
20922
- const rootFile = path70.join(groupDir, "root.md");
20923
- if (!fs68.existsSync(rootFile)) return null;
20924
- const root2 = readCard(rootFile, path70.join(folderName, "root.md"));
21022
+ const groupDir = path71.join(TODO, folderName);
21023
+ const rootFile = path71.join(groupDir, "root.md");
21024
+ if (!fs69.existsSync(rootFile)) return null;
21025
+ const root2 = readCard(rootFile, path71.join(folderName, "root.md"));
20925
21026
  if (!root2) return null;
20926
21027
  root2.isGroup = true;
20927
21028
  const { total, resolved: resolved2 } = subtaskLines(root2.body);
20928
21029
  root2.subtaskLines = { total, resolved: resolved2 };
20929
21030
  const subCards = [];
20930
21031
  const recurse = (dir, relDir) => {
20931
- for (const entry of fs68.readdirSync(dir, { withFileTypes: true })) {
20932
- const childRel = path70.join(relDir, entry.name);
21032
+ for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
21033
+ const childRel = path71.join(relDir, entry.name);
20933
21034
  if (entry.isDirectory()) {
20934
- recurse(path70.join(dir, entry.name), childRel);
21035
+ recurse(path71.join(dir, entry.name), childRel);
20935
21036
  } else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
20936
- const c = readCard(path70.join(dir, entry.name), childRel);
21037
+ const c = readCard(path71.join(dir, entry.name), childRel);
20937
21038
  if (c) {
20938
21039
  c.parent = { id: root2.id, title: root2.title };
20939
21040
  subCards.push(c);
@@ -20954,12 +21055,12 @@ function readGroup2(folderName) {
20954
21055
  return { root: root2, subCards };
20955
21056
  }
20956
21057
  function standaloneCards(dirRel) {
20957
- const dir = dirRel ? path70.join(TODO, dirRel) : TODO;
20958
- if (!fs68.existsSync(dir)) return [];
21058
+ const dir = dirRel ? path71.join(TODO, dirRel) : TODO;
21059
+ if (!fs69.existsSync(dir)) return [];
20959
21060
  const cards = [];
20960
- for (const entry of fs68.readdirSync(dir, { withFileTypes: true })) {
21061
+ for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
20961
21062
  if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
20962
- const c = readCard(path70.join(dir, entry.name), path70.join(dirRel, entry.name));
21063
+ const c = readCard(path71.join(dir, entry.name), path71.join(dirRel, entry.name));
20963
21064
  if (c) cards.push(c);
20964
21065
  }
20965
21066
  }
@@ -20971,7 +21072,7 @@ function collectCards() {
20971
21072
  const top = standaloneCards("");
20972
21073
  board2.push(...top);
20973
21074
  every.push(...top);
20974
- for (const entry of fs68.readdirSync(TODO, { withFileTypes: true })) {
21075
+ for (const entry of fs69.readdirSync(TODO, { withFileTypes: true })) {
20975
21076
  if (!entry.isDirectory()) continue;
20976
21077
  if (isGroupFolder(entry.name)) {
20977
21078
  const g = readGroup2(entry.name);
@@ -21003,7 +21104,7 @@ function findCard(id) {
21003
21104
  }
21004
21105
  function attachSources(card) {
21005
21106
  try {
21006
- const { meta, body } = parseFrontmatter(fs68.readFileSync(path70.join(TODO, card.relPath), "utf8"));
21107
+ const { meta, body } = parseFrontmatter(fs69.readFileSync(path71.join(TODO, card.relPath), "utf8"));
21007
21108
  const sources2 = meta ? cardSources(meta, body) : [];
21008
21109
  if (sources2.length) card.sources = sources2;
21009
21110
  } catch {
@@ -21107,10 +21208,10 @@ var init_read = __esm({
21107
21208
  });
21108
21209
 
21109
21210
  // ../cli/src/lib/group-close.ts
21110
- import fs69 from "node:fs";
21211
+ import fs70 from "node:fs";
21111
21212
  function groupCloses(rootFile) {
21112
21213
  try {
21113
- return groupCloseOf(fs69.readFileSync(rootFile, "utf8"));
21214
+ return groupCloseOf(fs70.readFileSync(rootFile, "utf8"));
21114
21215
  } catch {
21115
21216
  return false;
21116
21217
  }
@@ -21123,12 +21224,12 @@ var init_group_close = __esm({
21123
21224
  });
21124
21225
 
21125
21226
  // ../cli/src/commands/remove.ts
21126
- import fs70 from "node:fs";
21127
- import path71 from "node:path";
21227
+ import fs71 from "node:fs";
21228
+ import path72 from "node:path";
21128
21229
  function leavingIds(id, found2) {
21129
21230
  const ids = /* @__PURE__ */ new Set([id]);
21130
21231
  if (found2.kind === "group") {
21131
- const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) => path71.basename(f));
21232
+ const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) => path72.basename(f));
21132
21233
  for (const name of names3) {
21133
21234
  const n = idPrefix(name);
21134
21235
  if (n !== null) ids.add(n);
@@ -21140,10 +21241,10 @@ function findMentions(ids) {
21140
21241
  const hits = [];
21141
21242
  const re = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
21142
21243
  for (const dir of [TODO, MEMORY]) {
21143
- if (!fs70.existsSync(dir)) continue;
21244
+ if (!fs71.existsSync(dir)) continue;
21144
21245
  for (const file of walkMd(dir)) {
21145
- if (path71.basename(file) === "README.md") continue;
21146
- const lines = fs70.readFileSync(file, "utf8").split("\n");
21246
+ if (path72.basename(file) === "README.md") continue;
21247
+ const lines = fs71.readFileSync(file, "utf8").split("\n");
21147
21248
  const fmEnd = frontmatterEnd(lines);
21148
21249
  lines.forEach((line, i) => {
21149
21250
  if (!re.test(line)) return;
@@ -21159,12 +21260,12 @@ function findMentions(ids) {
21159
21260
  return hits;
21160
21261
  }
21161
21262
  function leavingCards(id, found2) {
21162
- const own = found2.kind === "group" ? path71.join(found2.target, "root.md") : found2.target;
21263
+ const own = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
21163
21264
  const cards = [{ id, file: own }];
21164
21265
  if (found2.kind !== "group") return cards;
21165
21266
  for (const file of walkMd(found2.target)) {
21166
21267
  if (file === own) continue;
21167
- const n = idPrefix(path71.basename(file));
21268
+ const n = idPrefix(path72.basename(file));
21168
21269
  if (n !== null) cards.push({ id: n, file });
21169
21270
  }
21170
21271
  return cards;
@@ -21173,10 +21274,10 @@ function stampLeaving(cards, rejection) {
21173
21274
  const day = formatDay();
21174
21275
  const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
21175
21276
  for (const card of cards) {
21176
- if (!fs70.existsSync(card.file)) continue;
21177
- const text4 = fs70.readFileSync(card.file, "utf8");
21277
+ if (!fs71.existsSync(card.file)) continue;
21278
+ const text4 = fs71.readFileSync(card.file, "utf8");
21178
21279
  const stamped = stampLeavingIn(text4, day, stamp4);
21179
- if (stamped !== text4) fs70.writeFileSync(card.file, stamped);
21280
+ if (stamped !== text4) fs71.writeFileSync(card.file, stamped);
21180
21281
  }
21181
21282
  }
21182
21283
  function unfinishedDelivery(id) {
@@ -21192,7 +21293,7 @@ function unfinishedDelivery(id) {
21192
21293
  }[gap];
21193
21294
  return `#${id} is not finished: ${what}.`;
21194
21295
  }
21195
- const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs70.existsSync(path71.join(ASSETS, src.slice(".assets/".length))));
21296
+ const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs71.existsSync(path72.join(ASSETS, src.slice(".assets/".length))));
21196
21297
  return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
21197
21298
  }
21198
21299
  function agentDecisions(text4) {
@@ -21223,8 +21324,8 @@ function removeCard2(id, metric, options) {
21223
21324
  const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
21224
21325
  if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
21225
21326
  const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
21226
- const cardFile3 = found2.kind === "group" ? path71.join(found2.target, "root.md") : found2.target;
21227
- const cardText = fs70.existsSync(cardFile3) ? fs70.readFileSync(cardFile3, "utf8") : "";
21327
+ const cardFile3 = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
21328
+ const cardText = fs71.existsSync(cardFile3) ? fs71.readFileSync(cardFile3, "utf8") : "";
21228
21329
  const { meta: cardMeta3 } = parseFrontmatter(cardText);
21229
21330
  const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f) => f !== cardFile3).map((f) => rel(f)).sort() : [];
21230
21331
  const leftIds = leavingIds(id, found2);
@@ -21255,10 +21356,10 @@ function removeCard2(id, metric, options) {
21255
21356
  const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
21256
21357
  if (dest) {
21257
21358
  stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
21258
- fs70.mkdirSync(ARCHIVE, { recursive: true });
21259
- fs70.renameSync(found2.target, dest);
21359
+ fs71.mkdirSync(ARCHIVE, { recursive: true });
21360
+ fs71.renameSync(found2.target, dest);
21260
21361
  } else {
21261
- fs70.rmSync(found2.target, { recursive: true, force: true });
21362
+ fs71.rmSync(found2.target, { recursive: true, force: true });
21262
21363
  }
21263
21364
  const removedRefs = stripReadmeRefs(found2);
21264
21365
  let marked2 = null;
@@ -21307,14 +21408,14 @@ function removeCard2(id, metric, options) {
21307
21408
  };
21308
21409
  }
21309
21410
  function closeGroup(rootFile) {
21310
- const rootId = idPrefix(path71.basename(path71.dirname(rootFile)));
21411
+ const rootId = idPrefix(path72.basename(path72.dirname(rootFile)));
21311
21412
  if (rootId === null) return null;
21312
21413
  if (runnerProject(KANBAN)) return null;
21313
21414
  if (!groupCloses(rootFile)) return null;
21314
21415
  say(`
21315
21416
  every subtask line on #${rootId} is resolved \u2014 closing the group:`);
21316
21417
  try {
21317
- const { meta, body } = parseFrontmatter(fs70.readFileSync(rootFile, "utf8"));
21418
+ const { meta, body } = parseFrontmatter(fs71.readFileSync(rootFile, "utf8"));
21318
21419
  const res = cmdRemove(rootId, "completed", { closing: true });
21319
21420
  return {
21320
21421
  id: rootId,
@@ -21371,7 +21472,7 @@ function cleanupDiscardedCards(sessionId) {
21371
21472
  if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
21372
21473
  while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
21373
21474
  dropCrossRefs(card.id);
21374
- stripReadmeRefs({ kind: "file", rel: path71.relative(TODO, path71.resolve(REPO_ROOT, card.path)).split(path71.sep).join("/") });
21475
+ stripReadmeRefs({ kind: "file", rel: path72.relative(TODO, path72.resolve(REPO_ROOT, card.path)).split(path72.sep).join("/") });
21375
21476
  }
21376
21477
  return discarded.map((c) => c.id);
21377
21478
  });
@@ -21379,8 +21480,8 @@ function cleanupDiscardedCards(sessionId) {
21379
21480
  function recoveredArchiveHandoff(id, source) {
21380
21481
  const found2 = locateArchived(id);
21381
21482
  if (!found2) throw new Error(`No archived card #${id} was found.`);
21382
- const file = found2.kind === "group" ? path71.join(found2.target, "root.md") : found2.target;
21383
- const { meta } = parseFrontmatter(fs70.readFileSync(file, "utf8"));
21483
+ const file = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
21484
+ const { meta } = parseFrontmatter(fs71.readFileSync(file, "utf8"));
21384
21485
  stripReadmeRefs(source ?? found2);
21385
21486
  const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
21386
21487
  if (root2) markSubtask(root2, id, "tick");
@@ -21456,6 +21557,30 @@ var init_agent_file = __esm({
21456
21557
  }
21457
21558
  });
21458
21559
 
21560
+ // ../cli/src/commands/studio-file.ts
21561
+ function cmdStudioFile(askedStudio, askedFile) {
21562
+ const studio = askedStudio.trim();
21563
+ const files = studioFiles(studio);
21564
+ if (!files) die(`no studio ${studio}`, { kind: "no-such-studio", studio });
21565
+ const file = askedFile.trim().replace(/^\.\//, "");
21566
+ const readable = Object.keys(files).filter((f) => f === STUDIO_FILE || f.startsWith("shared/") || f.startsWith("agents/")).sort();
21567
+ if (!readable.includes(file) || isAboutFile(file)) {
21568
+ die(`${studio} has no ${file}. It has: ${readable.join(", ")}.`, { kind: "no-such-studio-file", studio, file });
21569
+ }
21570
+ const text4 = files[file];
21571
+ say(text4);
21572
+ return { studio, file, text: text4 };
21573
+ }
21574
+ var init_studio_file2 = __esm({
21575
+ "../cli/src/commands/studio-file.ts"() {
21576
+ "use strict";
21577
+ init_io();
21578
+ init_paths();
21579
+ init_studio_shared();
21580
+ init_studio_files();
21581
+ }
21582
+ });
21583
+
21459
21584
  // ../cli/src/commands/memory-file.ts
21460
21585
  function cmdMemoryFile(askedName) {
21461
21586
  const name = askedName.trim();
@@ -21669,6 +21794,7 @@ var init_local2 = __esm({
21669
21794
  init_list();
21670
21795
  init_remove();
21671
21796
  init_agent_file();
21797
+ init_studio_file2();
21672
21798
  init_memory_file();
21673
21799
  init_validate2();
21674
21800
  init_io();
@@ -21687,10 +21813,11 @@ var init_local2 = __esm({
21687
21813
  archive: ({ args }) => cmdRemove(Number(args[0]), "completed"),
21688
21814
  reject: ({ args, opts }) => cmdRemove(Number(args[0]), "rejected", as(opts)),
21689
21815
  "agent-file": ({ args }) => cmdAgentFile(args[0] ?? "", args[1] ?? ""),
21816
+ file: ({ args }) => cmdStudioFile(args[0] ?? "", args[1] ?? ""),
21690
21817
  "memory-file": ({ args }) => cmdMemoryFile(args[0] ?? "")
21691
21818
  };
21692
21819
  BOARD_MOVES = new Set(Object.keys(MOVES));
21693
- READ_ONLY_MOVES = /* @__PURE__ */ new Set(["list", "validate", "agent-file", "memory-file"]);
21820
+ READ_ONLY_MOVES = /* @__PURE__ */ new Set(["list", "validate", "file", "agent-file", "memory-file"]);
21694
21821
  leases = /* @__PURE__ */ new Map();
21695
21822
  leaseCounter = 0;
21696
21823
  }
@@ -21741,8 +21868,8 @@ var init_created_cards = __esm({
21741
21868
 
21742
21869
  // ../cli/src/lib/agent/creation.ts
21743
21870
  import crypto4 from "node:crypto";
21744
- import fs71 from "node:fs";
21745
- import path72 from "node:path";
21871
+ import fs72 from "node:fs";
21872
+ import path73 from "node:path";
21746
21873
  function creationError(error, triage) {
21747
21874
  const zh = readLanguage() === "zh";
21748
21875
  const messages = {
@@ -21768,12 +21895,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
21768
21895
  function creationReceipt(request2, slot) {
21769
21896
  const hash2 = crypto4.createHash("sha256").update(`${request2}
21770
21897
  ${slot}`).digest("hex");
21771
- return path72.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21898
+ return path73.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21772
21899
  }
21773
21900
  function readCreation(file, said2) {
21774
21901
  return withCreationLock(() => {
21775
21902
  try {
21776
- const held4 = JSON.parse(fs71.readFileSync(file, "utf8"));
21903
+ const held4 = JSON.parse(fs72.readFileSync(file, "utf8"));
21777
21904
  if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
21778
21905
  return held4;
21779
21906
  } catch (error) {
@@ -21785,10 +21912,10 @@ function readCreation(file, said2) {
21785
21912
  });
21786
21913
  }
21787
21914
  function saveCreation(file, journal) {
21788
- fs71.mkdirSync(path72.dirname(file), { recursive: true });
21915
+ fs72.mkdirSync(path73.dirname(file), { recursive: true });
21789
21916
  const temp = `${file}.${crypto4.randomUUID()}.tmp`;
21790
- fs71.writeFileSync(temp, JSON.stringify(journal));
21791
- fs71.renameSync(temp, file);
21917
+ fs72.writeFileSync(temp, JSON.stringify(journal));
21918
+ fs72.renameSync(temp, file);
21792
21919
  }
21793
21920
  function archiveCreation(source, id) {
21794
21921
  if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
@@ -21802,7 +21929,7 @@ function archiveCreation(source, id) {
21802
21929
  function triageFile(sourceId) {
21803
21930
  const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
21804
21931
  if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
21805
- return path72.basename(found2.relPath, ".md");
21932
+ return path73.basename(found2.relPath, ".md");
21806
21933
  }
21807
21934
  var init_creation = __esm({
21808
21935
  "../cli/src/lib/agent/creation.ts"() {
@@ -21970,8 +22097,8 @@ __export(board_exports, {
21970
22097
  buildBoardProgram: () => buildBoardProgram
21971
22098
  });
21972
22099
  import crypto5 from "node:crypto";
21973
- import fs72 from "node:fs";
21974
- import path73 from "node:path";
22100
+ import fs73 from "node:fs";
22101
+ import path74 from "node:path";
21975
22102
  async function dispatch(move, cmd, args, opts, cli) {
21976
22103
  const ctx = ctxOf(cmd, cli.program);
21977
22104
  const data = await runAction(ctx, {}, async () => {
@@ -22011,7 +22138,7 @@ async function cloudCard(task, opts) {
22011
22138
  let request2;
22012
22139
  if (typeof opts.bodyFile === "string") {
22013
22140
  try {
22014
- request2 = fs72.readFileSync(opts.bodyFile, "utf8");
22141
+ request2 = fs73.readFileSync(opts.bodyFile, "utf8");
22015
22142
  } catch {
22016
22143
  }
22017
22144
  }
@@ -22041,7 +22168,7 @@ async function cloudCard(task, opts) {
22041
22168
  const file = creationReceipt(`${checked.value}:${requestId}`, slot);
22042
22169
  const journal = readCreation(file, said2);
22043
22170
  if (!journal.made) {
22044
- const key = `akb-${path73.basename(file, ".json").slice(0, 40)}`;
22171
+ const key = `akb-${path74.basename(file, ".json").slice(0, 40)}`;
22045
22172
  const made = await createProjectTask(checked.value, journal.said, key);
22046
22173
  if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
22047
22174
  journal.made = made.value;
@@ -22091,9 +22218,10 @@ function buildBoardProgram(cli) {
22091
22218
  move("validate").argument("[id]", ID, cardId).summary("validate card format and report file, line, and repair instructions").description("Check one card, or every open card when no id is given. Reads only; exits non-zero with detailed errors until the format is valid.").action(async function(id) {
22092
22219
  await dispatch("validate", this, id === void 0 ? [] : [String(id)], this.opts(), cli);
22093
22220
  });
22094
- move("agent-file").argument("<agent>", "the agent whose folder the file is in").argument("<path>", "the file, as the run's own list spells it").summary("print one file from an agent's own folder").description(
22095
- "Every run is told which files its agent's folder holds, and reads one when the work calls for it. `AGENT.md` prints the agent's own rules. A built-in agent ships its files inside the command, so this is the only way to open one; a path the agent does not offer is refused."
22096
- ).action(async function(agent, file) {
22221
+ move("file").argument("<studio>", "the studio, e.g. blog-post").argument("<path>", "the file as `akb studio pull` lays it out: shared/\u2026 or agents/<name>/\u2026").summary("print one file of a studio").description("In a task's run, reads the version the task is pinned to; otherwise the current one.").action(async function(studio, file) {
22222
+ await dispatch("file", this, [studio, file], this.opts(), cli);
22223
+ });
22224
+ withShared(program2.command("agent-file", { hidden: true })).argument("<agent>").argument("<path>").action(async function(agent, file) {
22097
22225
  await dispatch("agent-file", this, [agent, file], this.opts(), cli);
22098
22226
  });
22099
22227
  move("memory-file").argument("<name>", "the global memory").summary("print one global memory's rules, its MEMORY.md").description(
@@ -22169,17 +22297,17 @@ var init_board2 = __esm({
22169
22297
  });
22170
22298
 
22171
22299
  // ../cli/src/lib/board-cli.ts
22172
- import fs73 from "node:fs";
22173
- import path74 from "node:path";
22300
+ import fs74 from "node:fs";
22301
+ import path75 from "node:path";
22174
22302
  function useBoard(found2, dirNamed) {
22175
- if (!found2.named && found2.board === path74.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
22303
+ if (!found2.named && found2.board === path75.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
22176
22304
  else setBoardDir(found2.board, found2.root);
22177
22305
  useProjectState();
22178
22306
  backfillCardStudios();
22179
22307
  }
22180
22308
  function whole(found2, move) {
22181
22309
  if (move === MAKES_A_BOARD) return found2;
22182
- if (!fs73.existsSync(path74.join(found2.board, "todo"))) {
22310
+ if (!fs74.existsSync(path75.join(found2.board, "todo"))) {
22183
22311
  die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
22184
22312
  kind: "board-incomplete",
22185
22313
  dir: found2.root
@@ -22188,13 +22316,13 @@ function whole(found2, move) {
22188
22316
  return found2;
22189
22317
  }
22190
22318
  function findBoardUpward(from, move) {
22191
- let dir = path74.resolve(from);
22319
+ let dir = path75.resolve(from);
22192
22320
  for (; ; ) {
22193
- if (hasBoard(dir)) return { root: dir, board: path74.join(dir, "docs", "kanban") };
22321
+ if (hasBoard(dir)) return { root: dir, board: path75.join(dir, "docs", "kanban") };
22194
22322
  if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
22195
- const kept2 = path74.join(dir, ".akb", "kanban");
22196
- if (move !== MAKES_A_BOARD && fs73.existsSync(path74.join(kept2, "todo"))) return { root: dir, board: kept2 };
22197
- const up = path74.dirname(dir);
22323
+ const kept2 = path75.join(dir, ".akb", "kanban");
22324
+ if (move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return { root: dir, board: kept2 };
22325
+ const up = path75.dirname(dir);
22198
22326
  if (up === dir) return null;
22199
22327
  dir = up;
22200
22328
  }
@@ -22202,11 +22330,11 @@ function findBoardUpward(from, move) {
22202
22330
  function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
22203
22331
  const named2 = board2 ?? boardFromEnv();
22204
22332
  if (named2) {
22205
- const folder = path74.resolve(cwd, named2);
22206
- if (!fs73.existsSync(folder) && move !== MAKES_A_BOARD) {
22333
+ const folder = path75.resolve(cwd, named2);
22334
+ if (!fs74.existsSync(folder) && move !== MAKES_A_BOARD) {
22207
22335
  die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
22208
22336
  }
22209
- if (fs73.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
22337
+ if (fs74.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
22210
22338
  die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
22211
22339
  kind: "no-board",
22212
22340
  dir: folder
@@ -22215,24 +22343,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
22215
22343
  return { root: projectRootOf(folder), board: folder, named: true };
22216
22344
  }
22217
22345
  if (dir !== null) {
22218
- const root2 = path74.resolve(dir);
22219
- if (!fs73.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
22220
- const kept2 = path74.join(root2, ".akb", "kanban");
22221
- if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs73.existsSync(path74.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
22346
+ const root2 = path75.resolve(dir);
22347
+ if (!fs74.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
22348
+ const kept2 = path75.join(root2, ".akb", "kanban");
22349
+ if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
22222
22350
  if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
22223
22351
  die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
22224
22352
  kind: "no-board",
22225
22353
  dir: root2
22226
22354
  });
22227
22355
  }
22228
- return whole({ root: root2, board: path74.join(root2, "docs", "kanban") }, move);
22356
+ return whole({ root: root2, board: path75.join(root2, "docs", "kanban") }, move);
22229
22357
  }
22230
22358
  const found2 = findBoardUpward(cwd, move);
22231
22359
  if (found2) return whole(found2, move);
22232
- if (move === MAKES_A_BOARD) return { root: path74.resolve(cwd), board: path74.join(path74.resolve(cwd), "docs", "kanban") };
22360
+ if (move === MAKES_A_BOARD) return { root: path75.resolve(cwd), board: path75.join(path75.resolve(cwd), "docs", "kanban") };
22233
22361
  die(
22234
- `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`,
22235
- { kind: "no-board", dir: path74.resolve(cwd) }
22362
+ `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`,
22363
+ { kind: "no-board", dir: path75.resolve(cwd) }
22236
22364
  );
22237
22365
  }
22238
22366
  function editDistance(a, b) {
@@ -22315,8 +22443,8 @@ var init_board_cli = __esm({
22315
22443
  init_pointer();
22316
22444
  init_card_studio_backfill();
22317
22445
  MAKES_A_BOARD = "init";
22318
- hasBoard = (dir) => fs73.existsSync(path74.join(dir, "docs", "kanban"));
22319
- isBoardDir = (dir) => fs73.existsSync(path74.join(dir, "todo")) && fs73.existsSync(path74.join(dir, "config.md"));
22446
+ hasBoard = (dir) => fs74.existsSync(path75.join(dir, "docs", "kanban"));
22447
+ isBoardDir = (dir) => fs74.existsSync(path75.join(dir, "todo")) && fs74.existsSync(path75.join(dir, "config.md"));
22320
22448
  boardFromEnv = () => {
22321
22449
  const named2 = process.env.AI4KANBAN_BOARD?.trim();
22322
22450
  return named2 ? named2 : null;
@@ -22576,8 +22704,8 @@ var init_agent = __esm({
22576
22704
 
22577
22705
  // ../cli/src/commands/cloud-template.ts
22578
22706
  import { createHash as createHash5 } from "node:crypto";
22579
- import fs74 from "node:fs";
22580
- import path75 from "node:path";
22707
+ import fs75 from "node:fs";
22708
+ import path76 from "node:path";
22581
22709
  function usage2(problem, line) {
22582
22710
  die(`${problem}
22583
22711
  usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
@@ -22654,10 +22782,10 @@ This template has no preview.`);
22654
22782
  const written = [];
22655
22783
  for (const p of previews) {
22656
22784
  const bytes2 = Buffer.from(await (await ask(`/${at}/previews/${route(p.path)}`, {}, WITHOUT)).arrayBuffer());
22657
- const file = path75.basename(p.path);
22658
- const out = path75.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
22659
- fs74.mkdirSync(opts.to, { recursive: true });
22660
- fs74.writeFileSync(out, bytes2);
22785
+ const file = path76.basename(p.path);
22786
+ const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
22787
+ fs75.mkdirSync(opts.to, { recursive: true });
22788
+ fs75.writeFileSync(out, bytes2);
22661
22789
  written.push(out);
22662
22790
  say(out);
22663
22791
  }
@@ -22670,15 +22798,15 @@ async function templateGet(name, opts, program2) {
22670
22798
  const { template } = await asJson(await ask(`/${at}`, {}, WITHOUT));
22671
22799
  const fetched = [];
22672
22800
  for (const f of template.files) {
22673
- const out = path75.resolve(to, f.path);
22674
- if (!out.startsWith(path75.resolve(to) + path75.sep)) refuse3(T.corrupt, WITHOUT);
22801
+ const out = path76.resolve(to, f.path);
22802
+ if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse3(T.corrupt, WITHOUT);
22675
22803
  const bytes2 = Buffer.from(await (await ask(`/${at}/files/${route(f.path)}`, {}, WITHOUT)).arrayBuffer());
22676
22804
  if (bytes2.byteLength !== f.size || createHash5("sha256").update(bytes2).digest("hex") !== f.sha256) {
22677
22805
  refuse3(T.corrupt, WITHOUT);
22678
22806
  }
22679
22807
  fetched.push({ out, bytes: bytes2 });
22680
22808
  }
22681
- const taken = fetched.filter((f) => fs74.existsSync(f.out)).map((f) => path75.relative(to, f.out));
22809
+ const taken = fetched.filter((f) => fs75.existsSync(f.out)).map((f) => path76.relative(to, f.out));
22682
22810
  if (taken.length > 0) {
22683
22811
  refuse3({
22684
22812
  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`,
@@ -22686,8 +22814,8 @@ async function templateGet(name, opts, program2) {
22686
22814
  });
22687
22815
  }
22688
22816
  for (const f of fetched) {
22689
- fs74.mkdirSync(path75.dirname(f.out), { recursive: true });
22690
- fs74.writeFileSync(f.out, f.bytes);
22817
+ fs75.mkdirSync(path76.dirname(f.out), { recursive: true });
22818
+ fs75.writeFileSync(f.out, f.bytes);
22691
22819
  }
22692
22820
  say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
22693
22821
  Fetched ${name}: ${fetched.length} files into ${to}`);
@@ -22704,25 +22832,25 @@ async function templateSource(name, opts) {
22704
22832
  say(`evidence: ${e.path}`);
22705
22833
  continue;
22706
22834
  }
22707
- const out = path75.join(opts.to, `${name}-${path75.basename(e.path)}`);
22708
- fs74.mkdirSync(opts.to, { recursive: true });
22709
- fs74.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
22835
+ const out = path76.join(opts.to, `${name}-${path76.basename(e.path)}`);
22836
+ fs75.mkdirSync(opts.to, { recursive: true });
22837
+ fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
22710
22838
  written.push(out);
22711
22839
  say(out);
22712
22840
  }
22713
22841
  return { name, source, evidence: written.length > 0 ? written : evidence.map((e) => e.path) };
22714
22842
  }
22715
22843
  async function templatePublish(dir, opts) {
22716
- const root2 = path75.resolve(dir);
22717
- const manifest = path75.join(root2, "template.md");
22718
- 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.");
22719
- const meta = readTemplateMeta(fs74.readFileSync(manifest, "utf8"));
22844
+ const root2 = path76.resolve(dir);
22845
+ const manifest = path76.join(root2, "template.md");
22846
+ 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.");
22847
+ const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
22720
22848
  const files = walk2(root2);
22721
- const total = files.reduce((sum, f) => sum + fs74.statSync(path75.join(root2, f)).size, 0);
22849
+ const total = files.reduce((sum, f) => sum + fs75.statSync(path76.join(root2, f)).size, 0);
22722
22850
  if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
22723
22851
  for (const extra of [...opts.preview, ...opts.evidence]) {
22724
- if (!fs74.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
22725
- if (path75.resolve(extra).startsWith(root2 + path75.sep)) {
22852
+ if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
22853
+ if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
22726
22854
  invalid(
22727
22855
  `${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`,
22728
22856
  `${extra} is inside the template folder; keep previews and evidence outside it.`
@@ -22734,10 +22862,10 @@ async function templatePublish(dir, opts) {
22734
22862
  }
22735
22863
  const form = new FormData();
22736
22864
  form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
22737
- const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs74.readFileSync(file)]), path75.basename(name));
22738
- for (const f of files) add("files", f, path75.join(root2, f));
22739
- for (const f of opts.preview) add("previews", path75.basename(f), f);
22740
- for (const f of opts.evidence) add("evidence", path75.basename(f), f);
22865
+ const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
22866
+ for (const f of files) add("files", f, path76.join(root2, f));
22867
+ for (const f of opts.preview) add("previews", path76.basename(f), f);
22868
+ for (const f of opts.evidence) add("evidence", path76.basename(f), f);
22741
22869
  const done2 = await asJson(await ask("", { method: "POST", body: form }));
22742
22870
  say(
22743
22871
  done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
@@ -22753,11 +22881,11 @@ Deleted ${name} from the catalog.`);
22753
22881
  return { name, deleted: true };
22754
22882
  }
22755
22883
  async function templateShowcase(name, dir) {
22756
- const file = path75.join(dir, "showcase.json");
22757
- if (!fs74.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
22884
+ const file = path76.join(dir, "showcase.json");
22885
+ if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
22758
22886
  let meta;
22759
22887
  try {
22760
- meta = JSON.parse(fs74.readFileSync(file, "utf8"));
22888
+ meta = JSON.parse(fs75.readFileSync(file, "utf8"));
22761
22889
  } catch {
22762
22890
  return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
22763
22891
  }
@@ -22769,9 +22897,9 @@ async function templateShowcase(name, dir) {
22769
22897
  const form = new FormData();
22770
22898
  form.set("meta", JSON.stringify(meta));
22771
22899
  for (const p of new Set(named2)) {
22772
- const at = path75.join(dir, p);
22773
- if (!fs74.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
22774
- form.append(`media:${p}`, new Blob([fs74.readFileSync(at)]), p);
22900
+ const at = path76.join(dir, p);
22901
+ if (!fs75.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
22902
+ form.append(`media:${p}`, new Blob([fs75.readFileSync(at)]), p);
22775
22903
  }
22776
22904
  const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
22777
22905
  say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
@@ -22780,7 +22908,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
22780
22908
  }
22781
22909
  function walk2(root2, sub = "") {
22782
22910
  const out = [];
22783
- for (const entry of fs74.readdirSync(path75.join(root2, sub), { withFileTypes: true })) {
22911
+ for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
22784
22912
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
22785
22913
  const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
22786
22914
  if (entry.isDirectory()) out.push(...walk2(root2, rel2));
@@ -22981,7 +23109,7 @@ var init_card_chat = __esm({
22981
23109
  var update_studio_default;
22982
23110
  var init_update_studio = __esm({
22983
23111
  "../cli/src/guide/update-studio.md"() {
22984
- 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- **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 body: how a card of this kind is written; every planning run on its cards reads it\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";
23112
+ 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";
22985
23113
  }
22986
23114
  });
22987
23115
 
@@ -23037,7 +23165,7 @@ var init_prune_memory = __esm({
23037
23165
  var review_memory_default;
23038
23166
  var init_review_memory = __esm({
23039
23167
  "../cli/src/guide/review-memory.md"() {
23040
- review_memory_default = "# Review what the conversations settled\n\nRead each conversation given to you right through, then write what it settled into memory.\n\nChats and planning flows write no memory themselves. One turn cannot see where an exchange\nis going, so a \"what if\" thrown out and taken back three turns later used to land as a\ndecision. You read the whole exchange, so you can tell a decision from a passing thought \u2014\nand that judgement is the whole job.\n\n- **Read what you are given**: each card comes in its own `<conversation>` block: its summary,\n its `Worth noting` and `Overruled by the user` lines, then its chat and the comments the user\n left reviewing it, when it had any, the user's words as written and the agent's replies,\n oldest first. The card is archived, so it is complete and reviewed this once; open no card or\n transcript file.\n- **Keep them apart**: judge each block by itself; what one conversation settled never\n becomes a note for another's card or agents.\n- **Hold to the same bar**: \"What earns a note\" in `akb guide board` governs what you write,\n exactly as it governs a flow that writes one. A conversation that settled nothing earns no\n note, and most do not \u2014 writing nothing is a complete result.\n- **Only what the user settled**: a durable preference, constraint, decision or correction\n they stated. Your own proposal is not their decision, and neither is a question, a \"what\n if\", or a direction the conversation then moved off.\n- **Take the last word**: where they said one thing and then another, the later one stands.\n Where a note already in the file says what they have since overturned, rewrite that note in\n place \u2014 never leave both and never add a second.\n- **Honour \"don't record this\"**: told in the conversation not to record something, write no\n note for it. If one is already there from an earlier review, delete it now.\n- **Where it goes**: a durable choice goes in the planner's `decisions.md` as one\n `**<key>**: <call>` line under the topic that fits, without its rationale; a design lesson\n goes in its `redesign.md` under the relevant topic as\n `- \u274C **<mistake>** \u2192 \u2705 <what the design should be instead, one line>.`, written as guidance\n for future tasks, not a history of the fix. Both go in the folder of the module each\n conversation is listed with (`akb guide board`). Each conversation also lists the agents\n whose sections its card holds and the memory files each keeps: where what was settled lands\n on one agent's own work, it goes in that agent's memory instead. Read that agent's AGENT.md\n (`akb raw agent-file <agent> AGENT.md`) only then, and keep its memory the way it says.\n Distill settled feedback into reusable preferences (dos) and corrections (don'ts), retaining\n their scope; never copy raw reviews. An agent whose instructions name no memory gets no new file.\n- **What the card settled**: the summary says what the card was about and earns no note. A\n `Worth noting` line is a decision the user approved, by answering it or letting it stand, so\n it can be a choice but never a correction, and it earns a planner note only where the user's\n own words in the conversation back it; a line under\n `Overruled by the user` is a call the user reversed, so it goes in `redesign.md`: that of\n the agent whose section it came from, created there even if its instructions name other\n files, or the planner's when none did or its instructions name no memory.\n- **Change nothing else**: no card, no open question, no code. The memory\n files are the whole of what this run writes.\n- **Say what you wrote**: finish by reporting each conversation you read, and for each the\n notes you added, rewrote, deleted, or that you wrote none.\n";
23168
+ review_memory_default = "# Review what the conversations settled\n\nRead each conversation given to you right through, then write what it settled into memory.\n\nChats and planning flows write no memory themselves. One turn cannot see where an exchange\nis going, so a \"what if\" thrown out and taken back three turns later used to land as a\ndecision. You read the whole exchange, so you can tell a decision from a passing thought \u2014\nand that judgement is the whole job.\n\n- **Read what you are given**: each card comes in its own `<conversation>` block: its summary,\n its `Worth noting` and `Overruled by the user` lines, then its chat and the comments the user\n left reviewing it, when it had any, the user's words as written and the agent's replies,\n oldest first. The card is archived, so it is complete and reviewed this once; open no card or\n transcript file.\n- **Keep them apart**: judge each block by itself; what one conversation settled never\n becomes a note for another's card or agents.\n- **Hold to the same bar**: \"What earns a note\" in `akb guide board` governs what you write,\n exactly as it governs a flow that writes one. A conversation that settled nothing earns no\n note, and most do not \u2014 writing nothing is a complete result.\n- **Only what the user settled**: a durable preference, constraint, decision or correction\n they stated. Your own proposal is not their decision, and neither is a question, a \"what\n if\", or a direction the conversation then moved off.\n- **Take the last word**: where they said one thing and then another, the later one stands.\n Where a note already in the file says what they have since overturned, rewrite that note in\n place \u2014 never leave both and never add a second.\n- **Honour \"don't record this\"**: told in the conversation not to record something, write no\n note for it. If one is already there from an earlier review, delete it now.\n- **Where it goes**: a durable choice goes in the planner's `decisions.md` as one\n `**<key>**: <call>` line under the topic that fits, without its rationale; a design lesson\n goes in its `redesign.md` under the relevant topic as\n `- \u274C **<mistake>** \u2192 \u2705 <what the design should be instead, one line>.`, written as guidance\n for future tasks, not a history of the fix. Both go in the folder of the module each\n conversation is listed with (`akb guide board`). Each conversation also lists the agents\n whose sections its card holds and the memory files each keeps: where what was settled lands\n on one agent's own work, it goes in that agent's memory, or the studio's when its `shared/RULES.md`\n keeps it. Read those rules (`akb raw file <studio> agents/<agent>/AGENT.md`, `shared/RULES.md`)\n only then, and keep the memory the way they say.\n Distill settled feedback into reusable preferences (dos) and corrections (don'ts), retaining\n their scope; never copy raw reviews. An agent whose instructions name no memory gets no new file.\n- **What the card settled**: the summary says what the card was about and earns no note. A\n `Worth noting` line is a decision the user approved, by answering it or letting it stand, so\n it can be a choice but never a correction, and it earns a planner note only where the user's\n own words in the conversation back it; a line under\n `Overruled by the user` is a call the user reversed, so it goes in `redesign.md`: that of\n the agent whose section it came from, created there even if its instructions name other\n files, or the planner's when none did or its instructions name no memory.\n- **Change nothing else**: no card, no open question, no code. The memory\n files are the whole of what this run writes.\n- **Say what you wrote**: finish by reporting each conversation you read, and for each the\n notes you added, rewrote, deleted, or that you wrote none.\n";
23041
23169
  }
23042
23170
  });
23043
23171
 
@@ -23085,7 +23213,7 @@ var init_revise = __esm({
23085
23213
  var preview_agent_default;
23086
23214
  var init_preview_agent = __esm({
23087
23215
  "../cli/src/guide/preview-agent.md"() {
23088
- preview_agent_default = '# Be a preview agent\n\nYou are one preview agent on a card. Change only your own part: the ``## By `<agent-name>`\nagent`` section your instructions cover, its assets, your memory, and any file your\ninstructions tell you to write.\n\n- **Write**: edit your section in place above `<!-- agent -->`; do not duplicate it. Use\n `###` for subheadings.\n- **Finish your part**: write your planning content on the card now; never defer it to\n implementation.\n- **Components**: use the component documentation supplied with your run for embeds.\n- **Long drafts**: put a draft over about 20 lines in `<board-state>/assets/<card id>/<name>.md`\n and embed it as `<Asset src=".assets/<card id>/<name>.md">`; a shorter one goes in a code block.\n- **Memory**: `docs/kanban/memory/agents/<agent-name>/` is yours; keep only the files your\n instructions name, and edit one directly when you learn something lasting.\n- **User decisions**: follow `akb guide update-questions`; leave at most one open question,\n pointing to your section, appended with `--agent <agent-name>`.\n- **Validate**: run `akb raw validate <task-id>` and fix what it reports.\n';
23216
+ preview_agent_default = '# Be a preview agent\n\nYou are one preview agent on a card. Change only your own part: the ``## By `<agent-name>`\nagent`` section your instructions cover, its assets, your memory, and any file your\ninstructions tell you to write.\n\n- **Write**: edit your section in place above `<!-- agent -->`; do not duplicate it. Use\n `###` for subheadings.\n- **Finish your part**: write your planning content on the card now; never defer it to\n implementation.\n- **Rework**: when your section exists, redo only what the user names or an upstream change\n affects, and keep the rest, including its IDs, as it is.\n- **Components**: use the component documentation supplied with your run for embeds.\n- **Long drafts**: put a draft over about 20 lines in `<board-state>/assets/<card id>/<name>.md`\n and embed it as `<Asset src=".assets/<card id>/<name>.md">`; a shorter one goes in a code block.\n- **Memory**: `docs/kanban/memory/agents/<agent-name>/` is yours; keep only the files your\n instructions name, and edit one directly when you learn something lasting. Edit your\n studio\'s memory only as its rules say.\n- **User decisions**: follow `akb guide update-questions`; leave at most one open question,\n pointing to your section, appended with `--agent <agent-name>`.\n- **Validate**: run `akb raw validate <task-id>` and fix what it reports.\n';
23089
23217
  }
23090
23218
  });
23091
23219
 
@@ -23109,7 +23237,7 @@ var init_troubleshoot = __esm({
23109
23237
  var write_agent_default;
23110
23238
  var init_write_agent = __esm({
23111
23239
  "../cli/src/guide/write-agent.md"() {
23112
- write_agent_default = "# Write an agent\n\nAn agent is one folder: `docs/kanban/agents/<name>/AGENT.md`. The folder name is the agent's\nname and the word every flow asks for it by \u2014 lower-case words joined by `-`, matching the\n`name` in its frontmatter. It cannot be a name the board already answers to: one of the\nboard's roles, an agent the command ships, or a folder already in `docs/kanban/agents/`.\n\n## The file\n\n```yaml\n---\n# Required; matches the folder name.\nname: ux-writer\n# Required: one sentence saying what it does.\ndescription: Writes the words a screen shows.\n# Optional.\nakb:\n # Optional, for a preview agent: when to request it, exceptions included. Without it, it\n # always runs.\n when: A card changes what the product says to the user; not a typo.\n # Optional, for a preview agent: it runs only after these agents' previews are approved,\n # when the card requests them too; it never makes them run.\n after: [ui-designer]\n # Optional, for a preview agent: `new` runs it in a session of its own.\n session: new\n # Preview components this agent uses; an empty list loads no component documentation.\n components: [Asset]\n # Optional: a sticker of its deliverable, by glyph name (the Studio builder lists them),\n # or 1 to 12 parts `{ d, f?, o?: true, s?, w? }`. Without it, a generic file is drawn.\n icon: text\n---\n\nYou write the words a screen shows.\n```\n\nIts studio, not the agent, sets its role: `STUDIO.md` lists it under `previews`, `land`\nor `scheduled`.\n\nA scheduled agent can also name the new input it works on; it then runs only when there is some:\n\n```yaml\nakb:\n # archived-cards | chats | dismissals; omit to run on its cadence alone.\n reads: archived-cards\n```\n\nA land agent that merges code into the target branch declares it; completing its step then\nrequires the merged commit and branch:\n\n```yaml\nakb:\n merges: true\n```\n\nAn agent that shares material with others names the global memories it keeps:\n\n```yaml\nakb:\n # Optional; global memories under `docs/kanban/memory/<name>/`, by name.\n memory: [competitors]\n # Optional; its own memory files, or folders ending in `/`, that hold in any of the user's\n # projects. Everything else is this project's.\n memoryFiles:\n workspace: [style.md]\n```\n\nEverything under the frontmatter is the agent's instructions, read fresh on every run \u2014\na file with none is refused.\n\nAn agent declares no options of its own. Two ways of working is two agents, each with its own\n`AGENT.md` \u2014 a switch that changes how one agent works costs more than it buys.\n\n## Translations\n\n```yaml\nakb:\n # Optional; UI text only. Runs use English; omitted text falls back to English.\n i18n:\n # Language tag; every field below is optional.\n en:\n # Display name, shown as the stage name: name the output, not the role; at most\n # 3 English words or 4 Chinese characters. Does not change the agent's name.\n title: UI copy\n zh:\n title: \u754C\u9762\u6587\u6848\n description: \u64B0\u5199\u754C\u9762\u4E0A\u7684\u6587\u5B57\u3002\n when: \u5361\u7247\u65B0\u589E\u6216\u4FEE\u6539\u754C\u9762\u6587\u5B57\u65F6\u3002\n```\n\n## Files\n\nEvery file beside `AGENT.md`, in any subfolder, is named to the run by its path and opened only\nwhen the work calls for it. Put long material there and keep `AGENT.md` short.\n\n- **Scripts**: every agent owns its task scripts in its own folder, including built-in agents.\n Keep business validation there, outside the CLI's board logic. Document the runtime, inputs\n and invocation beside the script; consumers use the owner's script. Built-in files can be\n saved through `akb raw agent-file <agent> <path>` and run locally with their relative layout\n intact; custom agents use their existing folders.\n\n## Imported skills\n\nAn agent may carry several skills, each whole in its own `skills/<skill>/` folder.\n\n- **Keep the capability**: copy the skill's instructions, scripts, resources and license\n unchanged; never reduce it to rewritten instructions. Leave out installed packages and caches,\n and name any file it refers to that you could not get.\n- **Record the source**: list each in a `## Skills` section of `AGENT.md` as\n `- **<skill>**: <when to use it>. Source: <URL or pasted> @ <commit, tag or snapshot date>`.\n- **Adapt outside it**: say in `AGENT.md` when to use each skill and how its result becomes\n this agent's output; paths inside a skill resolve from its folder. Keep the skill folder\n untouched so an update can replace it whole.\n- **Runtime needs**: check every command, package and credential the skill needs on this\n machine. Name what is missing under its bullet and tell the user; never call the agent usable\n while anything is missing, and never copy a key into the folder.\n- **Update and remove**: update only when the user asks \u2014 replace the folder, show the diff and\n change the version. Remove a skill with its folder and bullet. Each agent owns its copies, so\n no change reaches another agent.\n\n## Memory\n\n`docs/kanban/memory/agents/<name>/` is read into every run. Keep none unless the agent has wide\nlatitude and its mistakes or the user's corrections should change its next output. Otherwise say\nin `AGENT.md`:\n\n- **Files**: each file and what it holds; `## General` for what always holds, and a heading per\n situation (a format, a recipe, a channel) for what holds only there.\n- **When**: which file to apply before which step, and which error-prone points, answers or\n corrections to record.\n- **What goes in**: lasting preferences, decisions and corrections only \u2014 never raw feedback,\n run history, or what the instructions already say.\n- **Shared material**: what other agents also use goes in a global memory under `akb.memory`;\n its rules arrive with every run, so `AGENT.md` never restates them.\n\n## Output\n\nDeclare the preview components the agent uses in `akb.components` (Asset, Compare, Storyboard, Set).\nTheir usage documentation is supplied with the run; omitted declarations default to Asset.\nUse `akb raw components --agent <name> --docs` or `--studio <id> --docs` to read it.\n\nChoose the form the reader takes in fastest and say it in `AGENT.md`: an image for a look, a\nstoryboard for a sequence over time, readable Markdown for everything else.\n\n## Dependencies\n\n- **In `after`**: name the agents whose approved previews this one needs; it waits for those\n approvals and never requests the agents.\n- **In the instructions**: say what to do when the section it needs is missing or still\n carries an open question \u2014 normally draw nothing and write one line naming what is missing.\n A preview agent never asks for another.\n\n## Instructions\n\nSay what the agent owns, what it produces, and what it leaves alone. Don't repeat the contract\nevery run is pointed to (`akb guide preview-agent`): where the section goes, how to validate,\nhow to keep memory, and how to defer to the user. A scheduled agent says what one run does,\nnever when it runs. Write the text as `akb guide write-prompt` says.\n\n## Work with the user\n\n- **Ask little**: settle what the request, the skill and the board already answer; ask the rest\n as `akb guide update-questions` does, and never ask again what is answered.\n- **State between runs**: ask how a scheduled agent should keep what its next run needs, and\n write the answer into `AGENT.md`; assume no file or format.\n- **Important choices**: give a recommendation and its tradeoff, and accept a free answer.\n- **Show each edit**: when changing an existing agent, show every changed file as a unified\n diff with context, followed by one sentence of reason.\n\n## Check it\n\n- **Validate before finishing**: after creating or editing an agent, run `akb raw previews`. Read all trigger conditions with `akb raw previews --triggers`.\n Fix every problem reported for its file under \"Problems on this board\", then run it again.\n Do not finish until the agent is accepted with no problems reported for it.\n- **`akb raw previews <name> <id> --print`** on a real card prints the whole prompt the agent will get:\n its instructions, the reference for each chosen setting, its files and its memory. Read it, and cut whatever the run does not need.\n- **Studio**: a new agent belongs to the studio it was created in and starts switched on;\n a preview agent joins the end of that studio's `previews`. `akb raw previews` refuses it while it is off.\n Switch it in that studio's `STUDIO.md`.\n- **Schedule**: set `reads` from what the agent works on; it runs automatically by default.\n For a fixed cadence, add `cadence: 1d` to its entry in the studio's `scheduled`.\n";
23240
+ write_agent_default = "# Write an agent\n\nAn agent is one folder: `docs/kanban/agents/<name>/AGENT.md`. The folder name is the agent's\nname and the word every flow asks for it by \u2014 lower-case words joined by `-`, matching the\n`name` in its frontmatter. It cannot be a name the board already answers to: one of the\nboard's roles, an agent the command ships, or a folder already in `docs/kanban/agents/`.\n\n## The file\n\n```yaml\n---\n# Required; matches the folder name.\nname: ux-writer\n# Required: one sentence saying what it does.\ndescription: Writes the words a screen shows.\n# Optional.\nakb:\n # Optional, for a preview agent: when to request it, exceptions included. Without it, it\n # always runs.\n when: A card changes what the product says to the user; not a typo.\n # Optional, for a preview agent: it runs only after these agents' previews are approved,\n # when the card requests them too; it never makes them run.\n after: [ui-designer]\n # Optional, for a preview agent: `new` runs it in a session of its own.\n session: new\n # Preview components this agent uses; an empty list loads no component documentation.\n components: [Asset]\n # Optional: a sticker of its deliverable, by glyph name (the Studio builder lists them),\n # or 1 to 12 parts `{ d, f?, o?: true, s?, w? }`. Without it, a generic file is drawn.\n icon: text\n---\n\nYou write the words a screen shows.\n```\n\nIts studio, not the agent, sets its role: `STUDIO.md` lists it under `previews`, `land`\nor `scheduled`.\n\nA scheduled agent can also name the new input it works on; it then runs only when there is some:\n\n```yaml\nakb:\n # archived-cards | chats | dismissals; omit to run on its cadence alone.\n reads: archived-cards\n```\n\nA land agent that merges code into the target branch declares it; completing its step then\nrequires the merged commit and branch:\n\n```yaml\nakb:\n merges: true\n```\n\nAn agent that shares material with others names the global memories it keeps:\n\n```yaml\nakb:\n # Optional; global memories under `docs/kanban/memory/<name>/`, by name.\n memory: [competitors]\n # Optional; its own memory files, or folders ending in `/`, that hold in any of the user's\n # projects. Everything else is this project's.\n memoryFiles:\n workspace: [style.md]\n```\n\nEverything under the frontmatter is the agent's instructions, read fresh on every run \u2014\na file with none is refused. A preview agent already redoes only what the user names or an\nupstream change affects; state only how its own rework differs, such as what to re-render.\n\nAn agent declares no options of its own. Two ways of working is two agents, each with its own\n`AGENT.md` \u2014 a switch that changes how one agent works costs more than it buys.\n\n## Translations\n\n```yaml\nakb:\n # Optional; UI text only. Runs use English; omitted text falls back to English.\n i18n:\n # Language tag; every field below is optional.\n en:\n # Display name, shown as the stage name: name the output, not the role; at most\n # 3 English words or 4 Chinese characters. Does not change the agent's name.\n title: UI copy\n zh:\n title: \u754C\u9762\u6587\u6848\n description: \u64B0\u5199\u754C\u9762\u4E0A\u7684\u6587\u5B57\u3002\n when: \u5361\u7247\u65B0\u589E\u6216\u4FEE\u6539\u754C\u9762\u6587\u5B57\u65F6\u3002\n```\n\n## Files\n\nEvery file beside `AGENT.md`, in any subfolder, is named to the run by its path and opened only\nwhen the work calls for it. Put long material there and keep `AGENT.md` short.\n\n- **Shared files**: a file several agents of one studio use goes in the studio's `shared/`, never\n in one agent's folder for the others to borrow.\n- **Scripts**: every agent owns its task scripts in its own folder, including built-in agents.\n Keep business validation there, outside the CLI's board logic. Document the runtime, inputs\n and invocation beside the script; consumers use the owner's script. Built-in files can be\n saved through `akb raw file <studio> <path>` and run locally with their relative layout\n intact; custom agents use their existing folders.\n\n## Imported skills\n\nAn agent may carry several skills, each whole in its own `skills/<skill>/` folder.\n\n- **Keep the capability**: copy the skill's instructions, scripts, resources and license\n unchanged; never reduce it to rewritten instructions. Leave out installed packages and caches,\n and name any file it refers to that you could not get.\n- **Record the source**: list each in a `## Skills` section of `AGENT.md` as\n `- **<skill>**: <when to use it>. Source: <URL or pasted> @ <commit, tag or snapshot date>`.\n- **Adapt outside it**: say in `AGENT.md` when to use each skill and how its result becomes\n this agent's output; paths inside a skill resolve from its folder. Keep the skill folder\n untouched so an update can replace it whole.\n- **Runtime needs**: check every command, package and credential the skill needs on this\n machine. Name what is missing under its bullet and tell the user; never call the agent usable\n while anything is missing, and never copy a key into the folder.\n- **Update and remove**: update only when the user asks \u2014 replace the folder, show the diff and\n change the version. Remove a skill with its folder and bullet. Each agent owns its copies, so\n no change reaches another agent.\n\n## Memory\n\n`docs/kanban/memory/agents/<name>/` is read into every run; what several agents of one studio\nremember goes in the studio's `docs/kanban/memory/studios/<studio>/`, described in its\n`shared/RULES.md`. Keep none unless the agent has wide\nlatitude and its mistakes or the user's corrections should change its next output. Otherwise say\nin `AGENT.md`:\n\n- **Files**: each file and what it holds; `## General` for what always holds, and a heading per\n situation (a format, a recipe, a channel) for what holds only there.\n- **When**: which file to apply before which step, and which error-prone points, answers or\n corrections to record.\n- **What goes in**: lasting preferences, decisions and corrections only \u2014 never raw feedback,\n run history, or what the instructions already say.\n- **Shared material**: what other agents also use goes in a global memory under `akb.memory`;\n its rules arrive with every run, so `AGENT.md` never restates them.\n\n## Output\n\nDeclare the preview components the agent uses in `akb.components` (Asset, Compare, Storyboard, Set).\nTheir usage documentation is supplied with the run; omitted declarations default to Asset.\nUse `akb raw components --agent <name> --docs` or `--studio <id> --docs` to read it.\n\nChoose the form the reader takes in fastest and say it in `AGENT.md`: an image for a look, a\nstoryboard for a sequence over time, readable Markdown for everything else.\n\n## Dependencies\n\n- **In `after`**: name the agents whose approved previews this one needs; it waits for those\n approvals and never requests the agents.\n- **In the instructions**: say what to do when the section it needs is missing or still\n carries an open question \u2014 normally draw nothing and write one line naming what is missing.\n A preview agent never asks for another.\n\n## Instructions\n\nSay what the agent owns, what it produces, and what it leaves alone. Don't repeat the contract\nevery run is pointed to (`akb guide preview-agent`): where the section goes, how to validate,\nhow to keep memory, and how to defer to the user. A scheduled agent says what one run does,\nnever when it runs. Write the text as `akb guide write-prompt` says.\n\n## Work with the user\n\n- **Ask little**: settle what the request, the skill and the board already answer; ask the rest\n as `akb guide update-questions` does, and never ask again what is answered.\n- **State between runs**: ask how a scheduled agent should keep what its next run needs, and\n write the answer into `AGENT.md`; assume no file or format.\n- **Important choices**: give a recommendation and its tradeoff, and accept a free answer.\n- **Show each edit**: when changing an existing agent, show every changed file as a unified\n diff with context, followed by one sentence of reason.\n\n## Check it\n\n- **Validate before finishing**: after creating or editing an agent, run `akb raw previews`. Read all trigger conditions with `akb raw previews --triggers`.\n Fix every problem reported for its file under \"Problems on this board\", then run it again.\n Do not finish until the agent is accepted with no problems reported for it.\n- **`akb raw previews <name> <id> --print`** on a real card prints the whole prompt the agent will get:\n its instructions, the reference for each chosen setting, its files and its memory. Read it, and cut whatever the run does not need.\n- **Studio**: a new agent belongs to the studio it was created in and starts switched on;\n a preview agent joins the end of that studio's `previews`. `akb raw previews` refuses it while it is off.\n Switch it in that studio's `STUDIO.md`.\n- **Schedule**: set `reads` from what the agent works on; it runs automatically by default.\n For a fixed cadence, add `cadence: 1d` to its entry in the studio's `scheduled`.\n";
23113
23241
  }
23114
23242
  });
23115
23243
 
@@ -23125,7 +23253,7 @@ var init_write_prompt = __esm({
23125
23253
  var writing_default;
23126
23254
  var init_writing = __esm({
23127
23255
  "../cli/src/guide/writing.md"() {
23128
- writing_default = "# Write a card\n\nA card has a **human half** for review and a folded **agent half** for implementation.\nUse this order and keep the English section titles and empty scaffold sections:\n\n```text\n<One short paragraph: the problem and the intended result.>\n\n## Worth noting <- user's answers first, then material decisions; empty if none\n- **<decision>**: <chosen behavior and main cost in one sentence>\n\n## Worth noting after implementation\n- **<decision>**: <chosen behavior and main cost in one sentence>\n <- settled by the build; omit when empty; no logs or open questions\n\n## By `<name>` agent <- preview owned by that agent\n\n<!-- agent --> <- folded content starts here\n\n## Scope <- requirements, not rationale\n### Done when <- acceptance checklist, when supplied\n- [ ] <observable result>\n\n## Todo <- implementation only; finish planning before writing steps\n- [ ] <one build step>\n\n## Decided by the agent <- other decisions and non-obvious findings the build needs\n- **<decision>**: <answer and required action>\n### Overruled by the user <- superseded decisions, always last\n```\n\n- **Decisions**: use the material-decision test in `akb guide update-questions` for Worth noting;\n merge entries governed by one policy and keep only the decision and its main cost.\n- **Delivery boundary**: Worth noting after implementation never changes approved scope or\n blocks an ongoing delivery; the build must fix deviations or refer them to the user.\n- **Preview ownership**: produce preview sections only by running their agent; before changing\n owned content, read `akb raw agent-file <agent> AGENT.md`, then only the references needed\n for that change with `akb raw agent-file <agent> <path>`; paths are relative to the named\n agent's folder, and cross-agent references use their named owner; report unreadable rules\n before proceeding.\n- **Preserve work**: leave checked todos and supplied Done when checklists unchanged; append a\n todo to reverse completed work, and move user-overruled decisions to Overruled by the user\n until the card leaves no room to repeat them.\n- **Writing**: write clear behavior and necessary tradeoffs for a fresh reader, keep the human\n half self-contained, and state each fact once.\n- **Frontmatter**: never edit frontmatter by hand; use `akb raw create`, `update`, or\n `update-questions`.\n- **Validate**: run `akb raw validate <id>` after edits and fix every reported file and line.\n";
23256
+ writing_default = "# Write a card\n\nA card has a **human half** for review and a folded **agent half** for implementation.\nUse this order and keep the English section titles and empty scaffold sections:\n\n```text\n<One short paragraph: the problem and the intended result.>\n\n## Worth noting <- user's answers first, then material decisions; empty if none\n- **<decision>**: <chosen behavior and main cost in one sentence>\n\n## Worth noting after implementation\n- **<decision>**: <chosen behavior and main cost in one sentence>\n <- settled by the build; omit when empty; no logs or open questions\n\n## By `<name>` agent <- preview owned by that agent\n\n<!-- agent --> <- folded content starts here\n\n## Scope <- requirements, not rationale\n### Done when <- acceptance checklist, when supplied\n- [ ] <observable result>\n\n## Todo <- implementation only; finish planning before writing steps\n- [ ] <one build step>\n\n## Decided by the agent <- other decisions and non-obvious findings the build needs\n- **<decision>**: <answer and required action>\n### Overruled by the user <- superseded decisions, always last\n```\n\n- **Decisions**: use the material-decision test in `akb guide update-questions` for Worth noting;\n merge entries governed by one policy and keep only the decision and its main cost.\n- **Delivery boundary**: Worth noting after implementation never changes approved scope or\n blocks an ongoing delivery; the build must fix deviations or refer them to the user.\n- **Preview ownership**: produce preview sections only by running their agent; before changing\n owned content, read `akb raw file <studio> agents/<agent>/AGENT.md` and the studio's\n `shared/RULES.md`, then only the files needed for that change with `akb raw file <studio> <path>`;\n report unreadable rules before proceeding.\n- **Preserve work**: leave checked todos and supplied Done when checklists unchanged; append a\n todo to reverse completed work, and move user-overruled decisions to Overruled by the user\n until the card leaves no room to repeat them.\n- **Writing**: write clear behavior and necessary tradeoffs for a fresh reader, keep the human\n half self-contained, and state each fact once.\n- **Frontmatter**: never edit frontmatter by hand; use `akb raw create`, `update`, or\n `update-questions`.\n- **Validate**: run `akb raw validate <id>` after edits and fix every reported file and line.\n";
23129
23257
  }
23130
23258
  });
23131
23259
 
@@ -23242,8 +23370,8 @@ var init_guide2 = __esm({
23242
23370
  });
23243
23371
 
23244
23372
  // ../cli/src/commands/studio.ts
23245
- import fs75 from "node:fs";
23246
- import path76 from "node:path";
23373
+ import fs76 from "node:fs";
23374
+ import path77 from "node:path";
23247
23375
  function cmdStudioList() {
23248
23376
  if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
23249
23377
  const offline2 = studiosOffline();
@@ -23284,17 +23412,17 @@ function cmdStudioDiagram(id, card) {
23284
23412
  const agent = findSpecAgent(name);
23285
23413
  return agent ? { ...agent, after: agentAfter(name) } : null;
23286
23414
  });
23287
- const file = path76.join(ASSETS, String(cardId2), "studio.json");
23288
- fs75.mkdirSync(path76.dirname(file), { recursive: true });
23289
- fs75.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
23415
+ const file = path77.join(ASSETS, String(cardId2), "studio.json");
23416
+ fs76.mkdirSync(path77.dirname(file), { recursive: true });
23417
+ fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
23290
23418
  `);
23291
23419
  const tag = `<Studio src=".assets/${cardId2}/studio.json" label="${flow.name.replace(/"/g, "")}" />`;
23292
23420
  say(tag);
23293
23421
  return { file, tag, diagram };
23294
23422
  }
23295
23423
  function cmdStudioValidate(folder) {
23296
- const dir = path76.resolve(folder);
23297
- if (!fs75.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
23424
+ const dir = path77.resolve(folder);
23425
+ if (!fs76.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
23298
23426
  const files = readStudioFolder(dir);
23299
23427
  const read3 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
23300
23428
  const def = "def" in read3 ? read3.def : null;
@@ -23315,26 +23443,26 @@ function cmdStudioValidate(folder) {
23315
23443
  async function cmdStudioPull(id, folder) {
23316
23444
  const cloudId = cloudIdOf(id);
23317
23445
  if (!cloudId) found(id);
23318
- const dir = path76.resolve(folder ?? id);
23319
- if (fs75.existsSync(dir) && fs75.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
23446
+ const dir = path77.resolve(folder ?? id);
23447
+ if (fs76.existsSync(dir) && fs76.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
23320
23448
  const read3 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
23321
23449
  if (!read3.ok) die(read3.error, read3.code === "not_found" ? "no-such-studio" : "cloud-refused");
23322
23450
  const { version, files } = read3.value;
23323
23451
  for (const [file, text4] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version) })) {
23324
- const full = path76.join(dir, ...file.split("/"));
23325
- fs75.mkdirSync(path76.dirname(full), { recursive: true });
23452
+ const full = path77.join(dir, ...file.split("/"));
23453
+ fs76.mkdirSync(path77.dirname(full), { recursive: true });
23326
23454
  const data = isAboutFile(file) && !file.endsWith(".md") && /^data:[^;]+;base64,/.exec(text4);
23327
- fs75.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
23455
+ fs76.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
23328
23456
  }
23329
23457
  const shown = folder ?? `./${id}`;
23330
23458
  say(`Pulled ${id} v${version} into ${shown}.`);
23331
23459
  return { id, version, folder: dir };
23332
23460
  }
23333
23461
  async function cmdStudioPush(folder, opts) {
23334
- const dir = path76.resolve(folder);
23462
+ const dir = path77.resolve(folder);
23335
23463
  let pulled = null;
23336
23464
  try {
23337
- pulled = JSON.parse(fs75.readFileSync(path76.join(dir, VERSION_FILE), "utf8"));
23465
+ pulled = JSON.parse(fs76.readFileSync(path77.join(dir, VERSION_FILE), "utf8"));
23338
23466
  } catch {
23339
23467
  }
23340
23468
  if (!pulled?.id || !Number.isInteger(pulled.version)) die(`${folder} was not written by \`akb studio pull\``, "bad-args");
@@ -23364,7 +23492,7 @@ async function cmdStudioPush(folder, opts) {
23364
23492
  die(res.error, res.code === "bad_request" || res.code === "payload_too_large" ? "bad-studio" : "cloud-refused");
23365
23493
  }
23366
23494
  const next = res.value.version;
23367
- fs75.writeFileSync(path76.join(dir, VERSION_FILE), versionText(cloudId, next));
23495
+ fs76.writeFileSync(path77.join(dir, VERSION_FILE), versionText(cloudId, next));
23368
23496
  say(`Pushed ${id} v${next}. New tasks take it.`);
23369
23497
  return { id, version: next, changed: true };
23370
23498
  }
@@ -23372,7 +23500,7 @@ function noteText({ file, text: text4 }) {
23372
23500
  if (file !== void 0 && text4 !== void 0) die("pass --file or --text, not both", "bad-args");
23373
23501
  if (file !== void 0) {
23374
23502
  try {
23375
- return fs75.readFileSync(file, "utf8").trim();
23503
+ return fs76.readFileSync(file, "utf8").trim();
23376
23504
  } catch {
23377
23505
  die(`can't read ${file}`, "bad-args");
23378
23506
  }
@@ -23597,8 +23725,8 @@ var init_complete = __esm({
23597
23725
  });
23598
23726
 
23599
23727
  // ../cli/src/lib/agent/approve.ts
23600
- import fs76 from "node:fs";
23601
- import path77 from "node:path";
23728
+ import fs77 from "node:fs";
23729
+ import path78 from "node:path";
23602
23730
  function approvalRequest(req) {
23603
23731
  const id = req.id;
23604
23732
  const card = id === void 0 ? null : findCard(id);
@@ -23616,12 +23744,12 @@ function advancePhase(id) {
23616
23744
  const card = findCard(id);
23617
23745
  const found2 = locate(id);
23618
23746
  if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
23619
- const file = found2.kind === "group" ? path77.join(found2.target, "root.md") : found2.target;
23620
- const { meta, body } = parseFrontmatter(fs76.readFileSync(file, "utf8"));
23747
+ const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
23748
+ const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
23621
23749
  if (!meta) return { error: `#${id} has no frontmatter` };
23622
23750
  meta.phase = card.stage + 1;
23623
23751
  meta.status = "todo";
23624
- fs76.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
23752
+ fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
23625
23753
  return null;
23626
23754
  }
23627
23755
  var init_approve = __esm({
@@ -23744,16 +23872,16 @@ var init_start = __esm({
23744
23872
  });
23745
23873
 
23746
23874
  // ../cli/src/lib/agent/task-chats.ts
23747
- import fs77 from "node:fs";
23748
- import path78 from "node:path";
23875
+ import fs78 from "node:fs";
23876
+ import path79 from "node:path";
23749
23877
  function taskChatFile(task, home3) {
23750
23878
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
23751
- return path78.join(taskChatsDir(home3), `${task}.jsonl`);
23879
+ return path79.join(taskChatsDir(home3), `${task}.jsonl`);
23752
23880
  }
23753
23881
  function readTaskChat(task, home3) {
23754
23882
  let text4;
23755
23883
  try {
23756
- text4 = fs77.readFileSync(taskChatFile(task, home3), "utf8");
23884
+ text4 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
23757
23885
  } catch {
23758
23886
  return [];
23759
23887
  }
@@ -23774,13 +23902,13 @@ var init_task_chats = __esm({
23774
23902
  "use strict";
23775
23903
  init_home();
23776
23904
  TASK = /^[\w-]{1,100}$/;
23777
- taskChatsDir = (home3 = machineHome()) => path78.join(home3, "chats");
23905
+ taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
23778
23906
  }
23779
23907
  });
23780
23908
 
23781
23909
  // ../cli/src/lib/agent/memory-review.ts
23782
- import fs78 from "node:fs";
23783
- import path79 from "node:path";
23910
+ import fs79 from "node:fs";
23911
+ import path80 from "node:path";
23784
23912
  function taskChatsToReview(tasks) {
23785
23913
  const out = [];
23786
23914
  for (const ref of [...new Set(tasks)]) {
@@ -23802,8 +23930,8 @@ function readArchived2(id) {
23802
23930
  const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
23803
23931
  if (!found2) return null;
23804
23932
  try {
23805
- const file = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
23806
- const { meta, body } = parseFrontmatter(fs78.readFileSync(file, "utf8"));
23933
+ const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
23934
+ const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
23807
23935
  if (!meta) return null;
23808
23936
  return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
23809
23937
  } catch {
@@ -23872,17 +24000,17 @@ var init_memory_review = __esm({
23872
24000
  });
23873
24001
 
23874
24002
  // ../cli/src/lib/agent/dismissal-review.ts
23875
- import fs79 from "node:fs";
23876
- import path80 from "node:path";
24003
+ import fs80 from "node:fs";
24004
+ import path81 from "node:path";
23877
24005
  function rejectionsToReview() {
23878
- const dir = path80.join(ARCHIVE, REJECTIONS_TO_REVIEW);
23879
- if (!fs79.existsSync(dir)) return [];
24006
+ const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
24007
+ if (!fs80.existsSync(dir)) return [];
23880
24008
  const found2 = [];
23881
24009
  for (const file of walkMd(dir)) {
23882
24010
  const id = archivedId(file);
23883
24011
  if (id === null) continue;
23884
24012
  try {
23885
- const { meta } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
24013
+ const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
23886
24014
  if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
23887
24015
  found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
23888
24016
  } catch {
@@ -23912,7 +24040,7 @@ function citedSources(text4) {
23912
24040
  function withdrawnSources() {
23913
24041
  const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
23914
24042
  try {
23915
- return citedSources(fs79.readFileSync(file, "utf8"));
24043
+ return citedSources(fs80.readFileSync(file, "utf8"));
23916
24044
  } catch {
23917
24045
  return [];
23918
24046
  }
@@ -23937,8 +24065,8 @@ var init_dismissal_review = __esm({
23937
24065
  });
23938
24066
 
23939
24067
  // ../cli/src/lib/agent/flow.ts
23940
- import fs80 from "node:fs";
23941
- import path81 from "node:path";
24068
+ import fs81 from "node:fs";
24069
+ import path82 from "node:path";
23942
24070
  function readCard2(id, home3 = "board") {
23943
24071
  const pending = activeDelivery(id)?.completions?.some((c) => !c.finished);
23944
24072
  const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
@@ -23948,10 +24076,10 @@ function readCard2(id, home3 = "board") {
23948
24076
  { kind: "card-not-found", id }
23949
24077
  );
23950
24078
  }
23951
- const file = found2.kind === "group" ? path81.join(found2.target, "root.md") : found2.target;
24079
+ const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
23952
24080
  let text4;
23953
24081
  try {
23954
- text4 = fs80.readFileSync(file, "utf8");
24082
+ text4 = fs81.readFileSync(file, "utf8");
23955
24083
  } catch {
23956
24084
  die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
23957
24085
  }
@@ -24767,7 +24895,7 @@ __export(watch_exports, {
24767
24895
  watchRun: () => watchRun
24768
24896
  });
24769
24897
  import { spawn as spawn3 } from "node:child_process";
24770
- import fs81 from "node:fs";
24898
+ import fs82 from "node:fs";
24771
24899
  async function watchRun(sessionId, resume = startResume) {
24772
24900
  const spec = readSpec(sessionId);
24773
24901
  const run2 = peekRun(sessionId);
@@ -24803,11 +24931,11 @@ async function watchRun(sessionId, resume = startResume) {
24803
24931
  const record = claimed ?? run2;
24804
24932
  const sub = record.action === "sub";
24805
24933
  if (claim) await setCardStatus(claim.cardId, claim.status);
24806
- fs81.mkdirSync(SESSIONS_DIR, { recursive: true });
24807
- const logFile = fs81.createWriteStream(record.logPath, { flags: "a" });
24934
+ fs82.mkdirSync(SESSIONS_DIR, { recursive: true });
24935
+ const logFile = fs82.createWriteStream(record.logPath, { flags: "a" });
24808
24936
  logFile.on("error", () => {
24809
24937
  });
24810
- const eventsFile = fs81.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
24938
+ const eventsFile = fs82.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
24811
24939
  eventsFile.on("error", () => {
24812
24940
  });
24813
24941
  const event2 = (e) => eventsFile.write(`${JSON.stringify(e)}
@@ -25377,8 +25505,8 @@ var init_watch = __esm({
25377
25505
  });
25378
25506
 
25379
25507
  // ../cli/src/commands/run.ts
25380
- import fs82 from "node:fs";
25381
- import path82 from "node:path";
25508
+ import fs83 from "node:fs";
25509
+ import path83 from "node:path";
25382
25510
  async function cmdStartRun(action, args, opts, program2 = "akb") {
25383
25511
  const { req, follow: follow2, print } = readRequest(action, args, opts);
25384
25512
  if (Number.isInteger(req.id)) {
@@ -25594,7 +25722,7 @@ async function cmdSubStart(words, opts) {
25594
25722
  let prompt = words.join(" ");
25595
25723
  if (opts.file) {
25596
25724
  try {
25597
- prompt = fs82.readFileSync(path82.resolve(opts.file), "utf8");
25725
+ prompt = fs83.readFileSync(path83.resolve(opts.file), "utf8");
25598
25726
  } catch {
25599
25727
  die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
25600
25728
  }
@@ -25961,7 +26089,7 @@ var init_signals = __esm({
25961
26089
  });
25962
26090
 
25963
26091
  // ../cli/src/commands/triage.ts
25964
- import fs83 from "node:fs";
26092
+ import fs84 from "node:fs";
25965
26093
  async function cmdTriageAdd(opts) {
25966
26094
  const title = (opts.title ?? "").trim();
25967
26095
  if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
@@ -25971,7 +26099,7 @@ async function cmdTriageAdd(opts) {
25971
26099
  let body = opts.text;
25972
26100
  if (opts.file !== void 0) {
25973
26101
  try {
25974
- body = fs83.readFileSync(opts.file, "utf8");
26102
+ body = fs84.readFileSync(opts.file, "utf8");
25975
26103
  } catch {
25976
26104
  die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
25977
26105
  }
@@ -26642,15 +26770,15 @@ var init_agent2 = __esm({
26642
26770
  });
26643
26771
 
26644
26772
  // ../cli/src/kanban.ts
26645
- import fs86 from "node:fs";
26773
+ import fs87 from "node:fs";
26646
26774
  import { fileURLToPath as fileURLToPath4 } from "node:url";
26647
26775
 
26648
26776
  // ../cli/src/lib/cli/akb.ts
26649
26777
  init_agent2();
26650
26778
 
26651
26779
  // ../cli/src/lib/cli/setup.ts
26652
- import fs85 from "node:fs";
26653
- import path84 from "node:path";
26780
+ import fs86 from "node:fs";
26781
+ import path85 from "node:path";
26654
26782
  import { fileURLToPath as fileURLToPath3 } from "node:url";
26655
26783
 
26656
26784
  // ../cli/src/commands/update.ts
@@ -26664,8 +26792,8 @@ init_paths();
26664
26792
  init_memory();
26665
26793
  init_yaml2();
26666
26794
  init_version();
26667
- import fs84 from "node:fs";
26668
- import path83 from "node:path";
26795
+ import fs85 from "node:fs";
26796
+ import path84 from "node:path";
26669
26797
  import { spawnSync as spawnSync6 } from "node:child_process";
26670
26798
  var NAME = "wildcrane";
26671
26799
  var REPO = "https://github.com/wildcrane-ai/wildcrane";
@@ -26687,10 +26815,10 @@ var Report = class {
26687
26815
  for (const line of this.notes) say(` ! ${line}`);
26688
26816
  }
26689
26817
  };
26690
- var read2 = (file) => fs84.existsSync(file) ? fs84.readFileSync(file, "utf8") : null;
26818
+ var read2 = (file) => fs85.existsSync(file) ? fs85.readFileSync(file, "utf8") : null;
26691
26819
  function statOf(p) {
26692
26820
  try {
26693
- return fs84.lstatSync(p);
26821
+ return fs85.lstatSync(p);
26694
26822
  } catch {
26695
26823
  return null;
26696
26824
  }
@@ -26715,10 +26843,10 @@ async function cmdUpdate2(ctx) {
26715
26843
  return { updated: ctx.dir, from, to: SKILL_VERSION };
26716
26844
  }
26717
26845
  async function repairBoard(root2, report3, named2) {
26718
- const legacy2 = path83.join(root2, "docs", "kanban");
26719
- const kept2 = path83.join(root2, ".akb", "kanban");
26720
- const board2 = named2 ?? (fs84.existsSync(legacy2) ? legacy2 : kept2);
26721
- if (!fs84.existsSync(board2)) {
26846
+ const legacy2 = path84.join(root2, "docs", "kanban");
26847
+ const kept2 = path84.join(root2, ".akb", "kanban");
26848
+ const board2 = named2 ?? (fs85.existsSync(legacy2) ? legacy2 : kept2);
26849
+ if (!fs85.existsSync(board2)) {
26722
26850
  report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
26723
26851
  return false;
26724
26852
  }
@@ -26749,20 +26877,20 @@ function moveRuntimes(root2, board2, report3) {
26749
26877
  }
26750
26878
  }
26751
26879
  function moveLegacyMemory(board2, report3) {
26752
- const memory = path83.join(board2, "memory");
26880
+ const memory = path84.join(board2, "memory");
26753
26881
  const moved = [];
26754
26882
  for (const name of MEMORY_FILES) {
26755
- const from = path83.join(board2, name);
26883
+ const from = path84.join(board2, name);
26756
26884
  const st = statOf(from);
26757
26885
  if (!st || !st.isFile()) continue;
26758
- fs84.mkdirSync(memory, { recursive: true });
26759
- const to = path83.join(memory, name);
26886
+ fs85.mkdirSync(memory, { recursive: true });
26887
+ const to = path84.join(memory, name);
26760
26888
  const there = read2(to);
26761
26889
  if (there === null) {
26762
- fs84.renameSync(from, to);
26890
+ fs85.renameSync(from, to);
26763
26891
  moved.push(name);
26764
26892
  } else if (there === read2(from)) {
26765
- fs84.rmSync(from);
26893
+ fs85.rmSync(from);
26766
26894
  moved.push(name);
26767
26895
  } else {
26768
26896
  report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
@@ -26771,23 +26899,23 @@ function moveLegacyMemory(board2, report3) {
26771
26899
  if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
26772
26900
  }
26773
26901
  function dropRecordFile(board2) {
26774
- const file = path83.join(board2, "record.csv");
26775
- if (!fs84.existsSync(file)) return null;
26776
- fs84.rmSync(file);
26902
+ const file = path84.join(board2, "record.csv");
26903
+ if (!fs85.existsSync(file)) return null;
26904
+ fs85.rmSync(file);
26777
26905
  return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
26778
26906
  }
26779
26907
  function dropModuleGoals(board2, report3) {
26780
- const memory = path83.join(board2, "memory");
26781
- if (!fs84.existsSync(memory)) return;
26782
- const root2 = read2(path83.join(memory, "goal.md"));
26908
+ const memory = path84.join(board2, "memory");
26909
+ if (!fs85.existsSync(memory)) return;
26910
+ const root2 = read2(path84.join(memory, "goal.md"));
26783
26911
  let dropped = 0;
26784
- for (const entry of fs84.readdirSync(memory, { withFileTypes: true })) {
26912
+ for (const entry of fs85.readdirSync(memory, { withFileTypes: true })) {
26785
26913
  if (!entry.isDirectory()) continue;
26786
- const file = path83.join(memory, entry.name, "goal.md");
26914
+ const file = path84.join(memory, entry.name, "goal.md");
26787
26915
  const text4 = read2(file);
26788
26916
  if (text4 === null) continue;
26789
26917
  if (text4 === root2 || text4.includes(UNFILLED) || !goalWords(text4)) {
26790
- fs84.rmSync(file);
26918
+ fs85.rmSync(file);
26791
26919
  dropped++;
26792
26920
  } else {
26793
26921
  report3.notes.push(
@@ -26809,10 +26937,10 @@ var PLAN_LEADS = {
26809
26937
  var GONE_LEADS = ["software-planner", "planner"];
26810
26938
  function planLeads(board2) {
26811
26939
  const leads = { ...PLAN_LEADS };
26812
- const root2 = path83.join(board2, "studios");
26813
- for (const entry of fs84.existsSync(root2) ? fs84.readdirSync(root2, { withFileTypes: true }) : []) {
26940
+ const root2 = path84.join(board2, "studios");
26941
+ for (const entry of fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []) {
26814
26942
  if (!entry.isDirectory()) continue;
26815
- const meta = splitFrontmatter(read2(path83.join(root2, entry.name, "STUDIO.md")) ?? "").meta;
26943
+ const meta = splitFrontmatter(read2(path84.join(root2, entry.name, "STUDIO.md")) ?? "").meta;
26816
26944
  const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
26817
26945
  const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
26818
26946
  const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
@@ -26821,30 +26949,30 @@ function planLeads(board2) {
26821
26949
  return leads;
26822
26950
  }
26823
26951
  function movePlanRules(board2, report3) {
26824
- const rules = path83.join(board2, "rules");
26952
+ const rules = path84.join(board2, "rules");
26825
26953
  const moved = [];
26826
26954
  for (const [id, leads] of Object.entries(planLeads(board2))) {
26827
26955
  for (const lead of leads) {
26828
- const from = path83.join(rules, `${lead}.md`);
26956
+ const from = path84.join(rules, `${lead}.md`);
26829
26957
  const rule = read2(from)?.trim();
26830
26958
  if (!rule) continue;
26831
- const to = path83.join(rules, "studios", `${id}.md`);
26959
+ const to = path84.join(rules, "studios", `${id}.md`);
26832
26960
  const there = read2(to)?.trim() ?? "";
26833
26961
  if (!there.includes(rule)) {
26834
- fs84.mkdirSync(path83.dirname(to), { recursive: true });
26835
- fs84.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
26962
+ fs85.mkdirSync(path84.dirname(to), { recursive: true });
26963
+ fs85.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
26836
26964
  `);
26837
26965
  moved.push(`${lead} \u2192 ${id}`);
26838
26966
  }
26839
26967
  }
26840
26968
  }
26841
- for (const lead of GONE_LEADS) fs84.rmSync(path83.join(rules, `${lead}.md`), { force: true });
26969
+ for (const lead of GONE_LEADS) fs85.rmSync(path84.join(rules, `${lead}.md`), { force: true });
26842
26970
  if (moved.length) report3.did.push(`made each plan agent's rule its studio's card rule (docs/kanban/rules/studios/): ${moved.join(", ")}`);
26843
26971
  }
26844
26972
  function noteOldStudios(board2, report3) {
26845
26973
  const old = (dir, file, keys) => {
26846
- const root2 = path83.join(board2, dir);
26847
- 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}`);
26974
+ const root2 = path84.join(board2, dir);
26975
+ 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}`);
26848
26976
  };
26849
26977
  const files = [...old("studios", "STUDIO.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
26850
26978
  if (files.length) {
@@ -26854,7 +26982,7 @@ function noteOldStudios(board2, report3) {
26854
26982
  }
26855
26983
  }
26856
26984
  function checkConfig(board2, report3) {
26857
- const current = read2(path83.join(board2, "config.md"));
26985
+ const current = read2(path84.join(board2, "config.md"));
26858
26986
  if (!current) return;
26859
26987
  const added = missingConfigKeys(current);
26860
26988
  if (added.length) {
@@ -26864,7 +26992,7 @@ function checkConfig(board2, report3) {
26864
26992
  }
26865
26993
  }
26866
26994
  function checkModules(board2, report3) {
26867
- const map2 = read2(path83.join(board2, "modules.md"));
26995
+ const map2 = read2(path84.join(board2, "modules.md"));
26868
26996
  if (map2 && map2.includes(UNFILLED)) {
26869
26997
  report3.notes.push(
26870
26998
  "docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
@@ -26918,14 +27046,14 @@ function declareSetup(program2, cli) {
26918
27046
  program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
26919
27047
  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");
26920
27048
  const where = (cmd) => {
26921
- const dir = path84.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
26922
- if (!fs85.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
27049
+ const dir = path85.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
27050
+ if (!fs86.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
26923
27051
  return dir;
26924
27052
  };
26925
27053
  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() {
26926
27054
  const dir = where(this);
26927
27055
  const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
26928
- const board2 = named2 ? path84.resolve(cli.cwd, named2) : null;
27056
+ const board2 = named2 ? path85.resolve(cli.cwd, named2) : null;
26929
27057
  await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
26930
27058
  });
26931
27059
  program2.command("__rules", { hidden: true }).action(function() {
@@ -26970,7 +27098,7 @@ function invokedDirectly() {
26970
27098
  const entry = process.argv[1];
26971
27099
  if (!entry) return false;
26972
27100
  try {
26973
- return fs86.realpathSync(entry) === fs86.realpathSync(SELF2);
27101
+ return fs87.realpathSync(entry) === fs87.realpathSync(SELF2);
26974
27102
  } catch {
26975
27103
  return false;
26976
27104
  }