wildcrane-runner 0.6.45 → 0.6.47

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.41 — 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.41",
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
  }
@@ -9191,9 +9193,19 @@ var init_roles = __esm({
9191
9193
  }
9192
9194
  });
9193
9195
 
9196
+ // ../cli/src/lib/shared/file-limits.ts
9197
+ var BOARD_FILE_LIMIT, ASSET_FILE_LIMIT;
9198
+ var init_file_limits = __esm({
9199
+ "../cli/src/lib/shared/file-limits.ts"() {
9200
+ "use strict";
9201
+ BOARD_FILE_LIMIT = 10 * 1024 * 1024;
9202
+ ASSET_FILE_LIMIT = 100 * 1024 * 1024;
9203
+ }
9204
+ });
9205
+
9194
9206
  // ../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");
9207
+ function studioRenamed(path86, content) {
9208
+ const to = path86.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
9197
9209
  if (!to.endsWith(".md")) return { path: to, content };
9198
9210
  if (to.startsWith("studios/")) return { path: to, content: content.replace(/^(icon:\s*["']?)workflow(-kit)?(["']?\s*)$/gm, "$1studio$2$3") };
9199
9211
  const front = /^(?:todo|triage)\//.test(to) ? /^---\r?\n[\s\S]*?\r?\n---/.exec(content)?.[0] : void 0;
@@ -9202,11 +9214,11 @@ function studioRenamed(path85, content) {
9202
9214
  const renamed = front.replace(/^workflow:[ \t]*(.*)$/m, (_, id) => `studio: ${id === "workflow-builder" ? "studio-builder" : id}`);
9203
9215
  return { path: to, content: renamed + body };
9204
9216
  }
9205
- var BOARD_FILE_LIMIT, cardSlug, studioFolder, studioName, draftFolder;
9217
+ var cardSlug, studioFolder, studioName, draftFolder;
9206
9218
  var init_board_files = __esm({
9207
9219
  "../cli/src/lib/shared/board-files.ts"() {
9208
9220
  "use strict";
9209
- BOARD_FILE_LIMIT = 256 * 1024;
9221
+ init_file_limits();
9210
9222
  cardSlug = (task) => task.toLowerCase().replace(/_/g, "-");
9211
9223
  studioFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
9212
9224
  studioName = (id) => id.startsWith("wf_builtin_") ? id.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id);
@@ -9499,7 +9511,7 @@ function readTranslations(raw) {
9499
9511
  }
9500
9512
  return out;
9501
9513
  }
9502
- function memoryPaths(raw) {
9514
+ function memoryPaths(raw, folder = "memory/agents/<name>/") {
9503
9515
  if (raw === void 0) return [];
9504
9516
  const block = map(raw);
9505
9517
  const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
@@ -9511,7 +9523,7 @@ function memoryPaths(raw) {
9511
9523
  }
9512
9524
  const paths = [...new Set(list.map((v) => v.trim()))];
9513
9525
  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>/\``;
9526
+ if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
9515
9527
  return paths;
9516
9528
  }
9517
9529
  var OLD_ROLE_KEYS, AGENT_NAME, SCHEDULE_READS, isScheduleReads, names, str3, map;
@@ -9602,6 +9614,8 @@ function parseStudioFile(id, source, from) {
9602
9614
  if (!agent || scheduled.some((s) => s.agent === agent)) continue;
9603
9615
  scheduled.push({ agent, ...text3(row.cadence) ? { cadence: text3(row.cadence) } : {} });
9604
9616
  }
9617
+ const workspace2 = memoryPaths(raw.memoryFiles, `memory/studios/${id}/`);
9618
+ if (typeof workspace2 === "string") return { problem: `${from}: declares ${workspace2}` };
9605
9619
  const names3 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said2]) => [lang, text3(said2)]).filter(([, said2]) => said2));
9606
9620
  return {
9607
9621
  def: {
@@ -9615,6 +9629,7 @@ function parseStudioFile(id, source, from) {
9615
9629
  previews,
9616
9630
  land,
9617
9631
  scheduled,
9632
+ ...workspace2.length ? { memoryFiles: { workspace: workspace2 } } : {},
9618
9633
  rules: body.trim()
9619
9634
  }
9620
9635
  };
@@ -9624,6 +9639,7 @@ var init_studio_def = __esm({
9624
9639
  "../cli/src/lib/agent/studio-def.ts"() {
9625
9640
  "use strict";
9626
9641
  init_icon();
9642
+ init_parse();
9627
9643
  init_yaml2();
9628
9644
  init_spec_agent_names();
9629
9645
  init_yaml();
@@ -9655,7 +9671,12 @@ function studioDiagram(def, agentOf2) {
9655
9671
  const after2 = (name) => (agentOf2(name)?.after ?? []).filter((other) => previews.includes(other));
9656
9672
  return {
9657
9673
  version: 1,
9658
- rounds: stagesOf(previews, after2).map((round) => round.map(step)),
9674
+ rounds: stagesOf(previews, after2).map(
9675
+ (round) => round.map((name) => {
9676
+ const waits = after2(name);
9677
+ return waits.length ? { ...step(name), after: waits } : step(name);
9678
+ })
9679
+ ),
9659
9680
  land: def.land.filter((h) => !h.off).map((h) => step(h.agent)),
9660
9681
  scheduled: def.scheduled.map((s) => ({ ...step(s.agent), ...s.cadence ? { cadence: s.cadence } : {} }))
9661
9682
  };
@@ -9723,7 +9744,7 @@ function inspect(value, official) {
9723
9744
  if (size > FILE_LIMITS.file) return fail(file, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
9724
9745
  total += size;
9725
9746
  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;
9747
+ if (file === STUDIO_FILE || file === CARD_TEMPLATE_FILE) continue;
9727
9748
  if (official && file === MCP_FILE) {
9728
9749
  const problem = mcpProblem(text4);
9729
9750
  if (problem) fail(file, problem);
@@ -9735,9 +9756,10 @@ function inspect(value, official) {
9735
9756
  else skills.add(file.split("/")[1]);
9736
9757
  continue;
9737
9758
  }
9759
+ if (isSharedFile(file)) continue;
9738
9760
  const at = folderPath(file, "agents");
9739
9761
  if (!at) {
9740
- fail(file, `is neither ${STUDIO_FILE} nor inside agents/<name>/`);
9762
+ fail(file, `is neither ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, shared/ nor inside agents/<name>/`);
9741
9763
  continue;
9742
9764
  }
9743
9765
  if (!folders2.has(at[0])) folders2.set(at[0], /* @__PURE__ */ new Map());
@@ -9775,7 +9797,7 @@ function inspect(value, official) {
9775
9797
  }
9776
9798
  return { problems, def, files };
9777
9799
  }
9778
- var STUDIO_FILE, MCP_FILE, VERSION_FILE, versionText, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes, studioFilesProblems;
9800
+ 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
9801
  var init_studio_files = __esm({
9780
9802
  "../cli/src/lib/shared/studio-files.ts"() {
9781
9803
  "use strict";
@@ -9784,6 +9806,9 @@ var init_studio_files = __esm({
9784
9806
  init_studio_diagram();
9785
9807
  STUDIO_FILE = "STUDIO.md";
9786
9808
  MCP_FILE = "mcp.json";
9809
+ CARD_TEMPLATE_FILE = "CARD.md";
9810
+ SHARED_DIR = "shared/";
9811
+ RULES_FILE = "shared/RULES.md";
9787
9812
  VERSION_FILE = "version.json";
9788
9813
  versionText = (id, version) => `${JSON.stringify({ id, version })}
9789
9814
  `;
@@ -9795,6 +9820,10 @@ var init_studio_files = __esm({
9795
9820
  SEGMENT = /^[\w.-]+$/;
9796
9821
  isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
9797
9822
  bytes = (text4) => new TextEncoder().encode(text4).length;
9823
+ isSharedFile = (file) => {
9824
+ const parts = file.split("/");
9825
+ return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p) => SEGMENT.test(p) && p !== "." && p !== "..");
9826
+ };
9798
9827
  studioFilesProblems = (value, official = false) => inspect(value, official).problems;
9799
9828
  }
9800
9829
  });
@@ -9842,7 +9871,7 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
9842
9871
  const dir = path33.join(studiosDir, folder);
9843
9872
  const files = {};
9844
9873
  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);
9874
+ 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
9875
  }
9847
9876
  const read3 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
9848
9877
  Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f, t]) => [`agents/${name}/${f}`, t]))
@@ -10274,6 +10303,7 @@ function studioFileText(def) {
10274
10303
  if (def.when) lines.push(`when: ${scalar(def.when)}`);
10275
10304
  lines.push(`needsArtifact: ${def.needsArtifact}`);
10276
10305
  lines.push(...groupLines("previews", def.previews), ...groupLines("land", def.land));
10306
+ if (def.memoryFiles?.workspace.length) lines.push("memoryFiles:", ` workspace: [${def.memoryFiles.workspace.map(scalar).join(", ")}]`);
10277
10307
  if (def.scheduled.length) {
10278
10308
  lines.push("scheduled:");
10279
10309
  for (const s of def.scheduled) {
@@ -12031,8 +12061,8 @@ var require_command = __commonJS({
12031
12061
  "../cli/node_modules/commander/lib/command.js"(exports) {
12032
12062
  var EventEmitter = __require("node:events").EventEmitter;
12033
12063
  var childProcess = __require("node:child_process");
12034
- var path85 = __require("node:path");
12035
- var fs87 = __require("node:fs");
12064
+ var path86 = __require("node:path");
12065
+ var fs88 = __require("node:fs");
12036
12066
  var process2 = __require("node:process");
12037
12067
  var { Argument: Argument2, humanReadableArgName } = require_argument();
12038
12068
  var { CommanderError: CommanderError2 } = require_error();
@@ -13013,7 +13043,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13013
13043
  * @param {string} subcommandName
13014
13044
  */
13015
13045
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
13016
- if (fs87.existsSync(executableFile)) return;
13046
+ if (fs88.existsSync(executableFile)) return;
13017
13047
  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
13048
  const executableMissing = `'${executableFile}' does not exist
13019
13049
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -13031,11 +13061,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
13031
13061
  let launchWithNode = false;
13032
13062
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
13033
13063
  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;
13064
+ const localBin = path86.resolve(baseDir, baseName);
13065
+ if (fs88.existsSync(localBin)) return localBin;
13066
+ if (sourceExt.includes(path86.extname(baseName))) return void 0;
13037
13067
  const foundExt = sourceExt.find(
13038
- (ext) => fs87.existsSync(`${localBin}${ext}`)
13068
+ (ext) => fs88.existsSync(`${localBin}${ext}`)
13039
13069
  );
13040
13070
  if (foundExt) return `${localBin}${foundExt}`;
13041
13071
  return void 0;
@@ -13047,21 +13077,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
13047
13077
  if (this._scriptPath) {
13048
13078
  let resolvedScriptPath;
13049
13079
  try {
13050
- resolvedScriptPath = fs87.realpathSync(this._scriptPath);
13080
+ resolvedScriptPath = fs88.realpathSync(this._scriptPath);
13051
13081
  } catch {
13052
13082
  resolvedScriptPath = this._scriptPath;
13053
13083
  }
13054
- executableDir = path85.resolve(
13055
- path85.dirname(resolvedScriptPath),
13084
+ executableDir = path86.resolve(
13085
+ path86.dirname(resolvedScriptPath),
13056
13086
  executableDir
13057
13087
  );
13058
13088
  }
13059
13089
  if (executableDir) {
13060
13090
  let localFile = findFile(executableDir, executableFile);
13061
13091
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
13062
- const legacyName = path85.basename(
13092
+ const legacyName = path86.basename(
13063
13093
  this._scriptPath,
13064
- path85.extname(this._scriptPath)
13094
+ path86.extname(this._scriptPath)
13065
13095
  );
13066
13096
  if (legacyName !== this._name) {
13067
13097
  localFile = findFile(
@@ -13072,7 +13102,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13072
13102
  }
13073
13103
  executableFile = localFile || executableFile;
13074
13104
  }
13075
- launchWithNode = sourceExt.includes(path85.extname(executableFile));
13105
+ launchWithNode = sourceExt.includes(path86.extname(executableFile));
13076
13106
  let proc;
13077
13107
  if (process2.platform !== "win32") {
13078
13108
  if (launchWithNode) {
@@ -13919,7 +13949,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13919
13949
  * @return {Command}
13920
13950
  */
13921
13951
  nameFromFilename(filename) {
13922
- this._name = path85.basename(filename, path85.extname(filename));
13952
+ this._name = path86.basename(filename, path86.extname(filename));
13923
13953
  return this;
13924
13954
  }
13925
13955
  /**
@@ -13933,9 +13963,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
13933
13963
  * @param {string} [path]
13934
13964
  * @return {(string|null|Command)}
13935
13965
  */
13936
- executableDir(path86) {
13937
- if (path86 === void 0) return this._executableDir;
13938
- this._executableDir = path86;
13966
+ executableDir(path87) {
13967
+ if (path87 === void 0) return this._executableDir;
13968
+ this._executableDir = path87;
13939
13969
  return this;
13940
13970
  }
13941
13971
  /**
@@ -16155,7 +16185,7 @@ function globalMemories() {
16155
16185
  } catch {
16156
16186
  }
16157
16187
  for (const name of folders2) {
16158
- if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR) continue;
16188
+ if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR || name === STUDIO_MEMORY_DIR) continue;
16159
16189
  const file = path51.join(MEMORY, name, GLOBAL_MEMORY_FILE);
16160
16190
  if (!fs49.existsSync(file)) continue;
16161
16191
  const memory = readMemory(fs49.readFileSync(file, "utf8"), false, name);
@@ -16253,8 +16283,82 @@ var init_archive = __esm({
16253
16283
  }
16254
16284
  });
16255
16285
 
16256
- // ../cli/src/lib/agent/prompts.ts
16286
+ // ../cli/src/lib/agent/studio-shared.ts
16287
+ import fs51 from "node:fs";
16257
16288
  import path53 from "node:path";
16289
+ function studioFiles(studio) {
16290
+ const flow = cloudFlows().find((f) => f.def.id === studio || f.cloudId === studio);
16291
+ if (flow) return flow.files;
16292
+ if (studio && draftId() === studio) {
16293
+ try {
16294
+ return readStudioFolder(path53.join(STUDIOS, studio));
16295
+ } catch {
16296
+ return null;
16297
+ }
16298
+ }
16299
+ return null;
16300
+ }
16301
+ function readStudioMemory(studio) {
16302
+ const dir = studioMemoryDir(studio);
16303
+ let names3 = [];
16304
+ try {
16305
+ names3 = fs51.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => e.name).sort();
16306
+ } catch {
16307
+ return [];
16308
+ }
16309
+ return names3.flatMap((name) => {
16310
+ try {
16311
+ return [{ name, text: fs51.readFileSync(path53.join(dir, name), "utf8").trim() }];
16312
+ } catch {
16313
+ return [];
16314
+ }
16315
+ });
16316
+ }
16317
+ function studioSections(studio, opts = {}) {
16318
+ const files = studio ? studioFiles(studio) : null;
16319
+ if (!studio || !files) return [];
16320
+ const rules = files[RULES_FILE]?.trim();
16321
+ const own = opts.agent ? Object.keys(files).filter((f) => f.startsWith(`agents/${opts.agent}/`) && f !== `agents/${opts.agent}/AGENT.md`).sort() : [];
16322
+ const listed = [...sharedFiles(files), ...own];
16323
+ const remembered = opts.memory ? readStudioMemory(studio) : [];
16324
+ return [
16325
+ rules ? `\u2014\u2014\u2014 your studio's rules \u2014\u2014\u2014
16326
+
16327
+ ${rules}` : "",
16328
+ listed.length ? `\u2014\u2014\u2014 your studio's files \u2014\u2014\u2014
16329
+
16330
+ Read one only when the work calls for it:
16331
+
16332
+ ${listed.map((f) => fileLine(studio, f)).join("\n")}` : "",
16333
+ remembered.length ? `\u2014\u2014\u2014 what your studio remembers \u2014\u2014\u2014
16334
+
16335
+ From \`${rel(studioMemoryDir(studio))}/\`:
16336
+
16337
+ ${remembered.map((m) => `### \`${m.name}\`
16338
+
16339
+ ${m.text || "_(empty)_"}`).join("\n\n")}` : ""
16340
+ ].filter(Boolean);
16341
+ }
16342
+ var sharedFiles, studioMemoryDir, fileLine, studioHoldsAgent;
16343
+ var init_studio_shared = __esm({
16344
+ "../cli/src/lib/agent/studio-shared.ts"() {
16345
+ "use strict";
16346
+ init_memory();
16347
+ init_paths();
16348
+ init_studio_files();
16349
+ init_command();
16350
+ init_cloud_studios();
16351
+ init_studio_file();
16352
+ init_studio_folder();
16353
+ sharedFiles = (files) => Object.keys(files).filter((f) => f.startsWith(SHARED_DIR) && f !== RULES_FILE).sort();
16354
+ studioMemoryDir = (studio) => path53.join(MEMORY, STUDIO_MEMORY_DIR, studio);
16355
+ fileLine = (studio, file) => `- \`${file}\` \u2014 \`${rawMove(`file ${studio} ${file}`)}\``;
16356
+ studioHoldsAgent = (studio, agent) => !!studio && Object.keys(studioFiles(studio) ?? {}).some((f) => f.startsWith(`agents/${agent}/`));
16357
+ }
16358
+ });
16359
+
16360
+ // ../cli/src/lib/agent/prompts.ts
16361
+ import path54 from "node:path";
16258
16362
  function stopReason(deliveryId) {
16259
16363
  const delivery = findDelivery(deliveryId);
16260
16364
  if (!delivery) return void 0;
@@ -16315,7 +16419,7 @@ ${text4}` : "";
16315
16419
  }
16316
16420
  function cardFileOf(id) {
16317
16421
  const found2 = id === void 0 ? null : locate(id);
16318
- return found2 ? found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target : "";
16422
+ return found2 ? found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target : "";
16319
16423
  }
16320
16424
  function realPaths(text4, req) {
16321
16425
  if (req.action !== "scheduled" && req.action !== "sub") return text4;
@@ -16342,14 +16446,26 @@ function studioRulesBlock(req) {
16342
16446
  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
16447
  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
16448
  const own = userStudioRules(flow);
16449
+ const template = studioFiles(flow.id)?.[CARD_TEMPLATE_FILE]?.trim();
16345
16450
  const body = [where, end2, flow.rules.trim()].filter(Boolean).join("\n\n");
16346
16451
  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");
16452
+ [
16453
+ `<studio name="${flow.name}">`,
16454
+ "How a card on this studio is written.",
16455
+ body,
16456
+ "</studio>",
16457
+ ...template ? ["", "<card-template>", "Write the card from this template: keep only the parts that fit this card, and fill them in.", template, "</card-template>"] : [],
16458
+ ...own ? ["", "<rules>", "The user's own rules for cards on this studio; they win over the studio above.", own, "</rules>"] : []
16459
+ ].join("\n"),
16460
+ ...studioSections(flow.id)
16461
+ ].join("\n\n");
16462
+ }
16463
+ function ownFiles2(studio, agent, files) {
16464
+ const sections2 = studioSections(studio, { agent, memory: true });
16465
+ const listed = !!agent && studioHoldsAgent(studio, agent);
16466
+ return [...sections2, ...files && !listed ? [`\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16467
+
16468
+ ${files}`] : []];
16353
16469
  }
16354
16470
  function landBlock(req) {
16355
16471
  if (req.action !== "implement") return "";
@@ -16357,6 +16473,7 @@ function landBlock(req) {
16357
16473
  const flow = frozen ? void 0 : studioFor(studioForRun(req));
16358
16474
  const rows = frozen ? frozen.land ?? [] : flow ? landAgents(flow) : [];
16359
16475
  const delivery = deliveryFor(req);
16476
+ const studio = frozen?.id ?? flow?.id;
16360
16477
  const step = delivery ? deliveryStep(delivery) : 0;
16361
16478
  const agents = rows.slice(step, step + 1).flatMap((h) => {
16362
16479
  const agent = findSpecAgent(h.agent);
@@ -16368,9 +16485,7 @@ function landBlock(req) {
16368
16485
  `\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
16486
 
16370
16487
  ${agent.body}`,
16371
- agentFilesBlock(agent) ? `\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16372
-
16373
- ${agentFilesBlock(agent)}` : "",
16488
+ ...ownFiles2(studio, agent.name, agentFilesBlock(agent)),
16374
16489
  globalMemoryBlock(agent) ? `\u2014\u2014\u2014 global memories \u2014\u2014\u2014
16375
16490
 
16376
16491
  ${globalMemoryBlock(agent)}` : "",
@@ -16402,7 +16517,7 @@ function frozenRules(req) {
16402
16517
  function archivedCardFile(id) {
16403
16518
  const found2 = locateArchived(id);
16404
16519
  if (!found2) return `${rel(ARCHIVE)}/`;
16405
- return rel(found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target);
16520
+ return rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target);
16406
16521
  }
16407
16522
  function shippedLines(cardId2) {
16408
16523
  const delivery = endedDelivery(`${cardId2}`);
@@ -16501,7 +16616,7 @@ function actionPrompt(req, command, notes) {
16501
16616
  case "prune-memory":
16502
16617
  return [
16503
16618
  `${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.`,
16619
+ `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
16620
  `Change nothing but those files: no card, no question for anyone.`
16506
16621
  ].join(" ");
16507
16622
  // Reading back over the conversations (#748). It names nothing either: which ones have
@@ -16545,7 +16660,7 @@ function actionPrompt(req, command, notes) {
16545
16660
  case "spec": {
16546
16661
  const agent = findSpecAgent(req.specAgent ?? "");
16547
16662
  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}`;
16663
+ const cardFile3 = found2 ? rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
16549
16664
  const own = agent ? specAgentInstructions(agent) : null;
16550
16665
  if (own) notes.push(...own.notes);
16551
16666
  const memory = agent ? agentMemoryBlock(agent) : "";
@@ -16563,9 +16678,7 @@ function actionPrompt(req, command, notes) {
16563
16678
  agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
16564
16679
 
16565
16680
  ${own.instructions}` : "",
16566
- own?.files ? `\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16567
-
16568
- ${own.files}` : "",
16681
+ ...ownFiles2(studioForRun(req), agent?.name, own?.files),
16569
16682
  memory ? `\u2014\u2014\u2014 what you remember \u2014\u2014\u2014
16570
16683
 
16571
16684
  ${memory}` : "",
@@ -16598,9 +16711,7 @@ ${shared}` : "",
16598
16711
  agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
16599
16712
 
16600
16713
  ${own.instructions}` : "",
16601
- own?.files ? `\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16602
-
16603
- ${own.files}` : "",
16714
+ ...ownFiles2(flow?.id, agent?.name, own?.files),
16604
16715
  extra ? `\u2014\u2014\u2014 what this studio asks of you here \u2014\u2014\u2014
16605
16716
 
16606
16717
  ${extra}` : "",
@@ -16634,9 +16745,7 @@ ${req.description ?? ""}`,
16634
16745
  agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
16635
16746
 
16636
16747
  ${own.instructions}` : "",
16637
- own?.files ? `\u2014\u2014\u2014 your own files \u2014\u2014\u2014
16638
-
16639
- ${own.files}` : "",
16748
+ ...ownFiles2(studioForRun(req), agent?.name, own?.files),
16640
16749
  memory ? `\u2014\u2014\u2014 what you remember \u2014\u2014\u2014
16641
16750
 
16642
16751
  ${memory}` : "",
@@ -16685,6 +16794,8 @@ var init_prompts = __esm({
16685
16794
  init_flows();
16686
16795
  init_resolve();
16687
16796
  init_runner();
16797
+ init_studio_shared();
16798
+ init_studio_files();
16688
16799
  init_studios();
16689
16800
  init_catalog();
16690
16801
  init_roles();
@@ -16725,16 +16836,16 @@ var init_prompts = __esm({
16725
16836
 
16726
16837
  // ../cli/src/lib/agent/stop.ts
16727
16838
  import { spawnSync as spawnSync4 } from "node:child_process";
16728
- import fs51 from "node:fs";
16839
+ import fs52 from "node:fs";
16729
16840
  function markedInProc(entry, strict = false) {
16730
16841
  const pids = [];
16731
- for (const name of fs51.readdirSync("/proc")) {
16842
+ for (const name of fs52.readdirSync("/proc")) {
16732
16843
  if (!/^\d+$/.test(name)) continue;
16733
16844
  try {
16734
- if (fs51.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
16845
+ if (fs52.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
16735
16846
  } catch (error) {
16736
16847
  if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
16737
- const stat = fs51.statSync(`/proc/${name}`, { throwIfNoEntry: false });
16848
+ const stat = fs52.statSync(`/proc/${name}`, { throwIfNoEntry: false });
16738
16849
  if (stat?.uid === process.getuid?.()) throw error;
16739
16850
  }
16740
16851
  }
@@ -16889,10 +17000,10 @@ var init_stop = __esm({
16889
17000
  });
16890
17001
 
16891
17002
  // ../cli/src/lib/agent/creation-lock.ts
16892
- import path54 from "node:path";
17003
+ import path55 from "node:path";
16893
17004
  function withCreationLock(fn) {
16894
17005
  if (depth2) return fn();
16895
- return withLock(path54.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
17006
+ return withLock(path55.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
16896
17007
  depth2++;
16897
17008
  try {
16898
17009
  return fn();
@@ -16913,8 +17024,8 @@ var init_creation_lock = __esm({
16913
17024
 
16914
17025
  // ../cli/src/lib/agent/sessions.ts
16915
17026
  import { randomUUID as randomUUID4 } from "node:crypto";
16916
- import fs52 from "node:fs";
16917
- import path55 from "node:path";
17027
+ import fs53 from "node:fs";
17028
+ import path56 from "node:path";
16918
17029
  function reap(runs, reaped = [], restore = []) {
16919
17030
  let changed = false;
16920
17031
  const now = Date.now();
@@ -16934,7 +17045,7 @@ function reap(runs, reaped = [], restore = []) {
16934
17045
  }
16935
17046
  function stampDuration(run2, endedAt) {
16936
17047
  try {
16937
- fs52.appendFileSync(run2.logPath, durationLine(endedAt - run2.startedAt));
17048
+ fs53.appendFileSync(run2.logPath, durationLine(endedAt - run2.startedAt));
16938
17049
  } catch {
16939
17050
  }
16940
17051
  }
@@ -16948,7 +17059,7 @@ function cardNow(cardId2) {
16948
17059
  try {
16949
17060
  const file = cardFile(cardId2);
16950
17061
  if (!file) return null;
16951
- const { meta } = parseFrontmatter(fs52.readFileSync(file, "utf8"));
17062
+ const { meta } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
16952
17063
  if (!meta) return null;
16953
17064
  return { status: meta.status || "todo", questions: meta.questions.length, title: meta.title };
16954
17065
  } catch {
@@ -17081,9 +17192,9 @@ function leftBoardOnLanding(id) {
17081
17192
  function archivedRejected(id) {
17082
17193
  const filed = locateArchived(id);
17083
17194
  if (!filed) return null;
17084
- const file = filed.kind === "group" ? path55.join(filed.target, "root.md") : filed.target;
17195
+ const file = filed.kind === "group" ? path56.join(filed.target, "root.md") : filed.target;
17085
17196
  try {
17086
- return !!parseFrontmatter(fs52.readFileSync(file, "utf8")).meta?.rejected;
17197
+ return !!parseFrontmatter(fs53.readFileSync(file, "utf8")).meta?.rejected;
17087
17198
  } catch {
17088
17199
  return false;
17089
17200
  }
@@ -17333,7 +17444,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID4(), said2) {
17333
17444
  return { run: record, spec };
17334
17445
  }
17335
17446
  function planningSession(cardId2, cwd = REPO_ROOT) {
17336
- const here = (dir) => !dir || path55.resolve(dir) === cwd;
17447
+ const here = (dir) => !dir || path56.resolve(dir) === cwd;
17337
17448
  const planned = readRuns().filter((r) => r.status === "done" && r.cardId === cardId2 && PLANNING.has(r.action)).sort((a, b) => b.startedAt - a.startedAt)[0];
17338
17449
  if (!planned) return { none: "unrecorded" };
17339
17450
  if (!here(planned.cwd)) return { none: "elsewhere" };
@@ -17553,8 +17664,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
17553
17664
  if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
17554
17665
  clearAsks(prev.sessionId);
17555
17666
  try {
17556
- fs52.unlinkSync(prev.logPath);
17557
- fs52.rmSync(eventsPathOf(prev.sessionId), { force: true });
17667
+ fs53.unlinkSync(prev.logPath);
17668
+ fs53.rmSync(eventsPathOf(prev.sessionId), { force: true });
17558
17669
  } catch {
17559
17670
  }
17560
17671
  if (retry2 && prev.pictures?.length) {
@@ -17577,8 +17688,8 @@ function forgetRun(sessionId) {
17577
17688
  if (!gone) return;
17578
17689
  clearAsks(sessionId);
17579
17690
  try {
17580
- fs52.unlinkSync(gone.logPath);
17581
- fs52.rmSync(eventsPathOf(gone.sessionId), { force: true });
17691
+ fs53.unlinkSync(gone.logPath);
17692
+ fs53.rmSync(eventsPathOf(gone.sessionId), { force: true });
17582
17693
  } catch {
17583
17694
  }
17584
17695
  }
@@ -17607,14 +17718,14 @@ function noteSpecRefusals(sessionId, refused) {
17607
17718
  }
17608
17719
  function clearAsks(sessionId) {
17609
17720
  try {
17610
- fs52.unlinkSync(asksPathOf(sessionId));
17721
+ fs53.unlinkSync(asksPathOf(sessionId));
17611
17722
  } catch {
17612
17723
  }
17613
17724
  }
17614
17725
  function readAsks(sessionId) {
17615
17726
  let data;
17616
17727
  try {
17617
- data = JSON.parse(fs52.readFileSync(asksPathOf(sessionId), "utf8"));
17728
+ data = JSON.parse(fs53.readFileSync(asksPathOf(sessionId), "utf8"));
17618
17729
  } catch {
17619
17730
  return { asks: [], refines: [], refused: [] };
17620
17731
  }
@@ -17641,10 +17752,10 @@ function readAsks(sessionId) {
17641
17752
  return { asks: asks.filter((a) => !discarded.has(a.cardId)), refines: refines.filter((a) => !discarded.has(a.cardId)), refused };
17642
17753
  }
17643
17754
  function writeAsks(sessionId, file) {
17644
- fs52.mkdirSync(SESSIONS_DIR, { recursive: true });
17755
+ fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
17645
17756
  const tmp = `${asksPathOf(sessionId)}.tmp`;
17646
- fs52.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
17647
- fs52.renameSync(tmp, asksPathOf(sessionId));
17757
+ fs53.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
17758
+ fs53.renameSync(tmp, asksPathOf(sessionId));
17648
17759
  }
17649
17760
  function markSpawned(sessionId, pid) {
17650
17761
  patch(sessionId, (r) => {
@@ -17775,12 +17886,12 @@ async function resumeDelivery(id) {
17775
17886
  return { ok: true, deliveryId: delivery.deliveryId, carryOn };
17776
17887
  }
17777
17888
  function writeSpec(spec) {
17778
- fs52.mkdirSync(SESSIONS_DIR, { recursive: true });
17779
- fs52.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
17889
+ fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
17890
+ fs53.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
17780
17891
  }
17781
17892
  function readSpec(sessionId) {
17782
17893
  try {
17783
- const spec = JSON.parse(fs52.readFileSync(specPathOf(sessionId), "utf8"));
17894
+ const spec = JSON.parse(fs53.readFileSync(specPathOf(sessionId), "utf8"));
17784
17895
  return spec && Array.isArray(spec.plan?.argv) ? spec : null;
17785
17896
  } catch {
17786
17897
  return null;
@@ -17788,28 +17899,28 @@ function readSpec(sessionId) {
17788
17899
  }
17789
17900
  function dropSpec(sessionId) {
17790
17901
  try {
17791
- fs52.unlinkSync(specPathOf(sessionId));
17902
+ fs53.unlinkSync(specPathOf(sessionId));
17792
17903
  } catch {
17793
17904
  }
17794
17905
  }
17795
17906
  async function acquireIndexLock(giveUp) {
17796
17907
  const until = Date.now() + INDEX_WAIT_MS;
17797
- const holder = path55.join(INDEX_LOCK2, "holder");
17908
+ const holder = path56.join(INDEX_LOCK2, "holder");
17798
17909
  for (; ; ) {
17799
17910
  if (giveUp()) return null;
17800
17911
  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 });
17912
+ fs53.mkdirSync(INDEX_LOCK2, { recursive: false });
17913
+ fs53.writeFileSync(holder, String(process.pid));
17914
+ return () => fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17804
17915
  } catch (err) {
17805
17916
  const code = err.code;
17806
17917
  if (code === "ENOENT") {
17807
- fs52.mkdirSync(path55.dirname(INDEX_LOCK2), { recursive: true });
17918
+ fs53.mkdirSync(path56.dirname(INDEX_LOCK2), { recursive: true });
17808
17919
  continue;
17809
17920
  }
17810
17921
  if (code !== "EEXIST") throw err;
17811
17922
  if (!pidAlive(Number(readHolder(holder)))) {
17812
- fs52.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17923
+ fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17813
17924
  continue;
17814
17925
  }
17815
17926
  if (Date.now() > until) return null;
@@ -17819,7 +17930,7 @@ async function acquireIndexLock(giveUp) {
17819
17930
  }
17820
17931
  function readHolder(file) {
17821
17932
  try {
17822
- return fs52.readFileSync(file, "utf8").trim();
17933
+ return fs53.readFileSync(file, "utf8").trim();
17823
17934
  } catch {
17824
17935
  return String(process.pid);
17825
17936
  }
@@ -17904,8 +18015,8 @@ var init_sessions = __esm({
17904
18015
  implement: "implementing",
17905
18016
  hook: "implementing"
17906
18017
  };
17907
- specPathOf = (sessionId) => path55.join(SESSIONS_DIR, `${sessionId}.plan.json`);
17908
- asksPathOf = (sessionId) => path55.join(SESSIONS_DIR, `${sessionId}.asks.json`);
18018
+ specPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.plan.json`);
18019
+ asksPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.asks.json`);
17909
18020
  carriesSession = (r) => !!(r.resumedFrom || r.continues && !r.continues.fork);
17910
18021
  canPickUp = (r) => r.status === "error" || r.status === "interrupted" || r.status === "stopped";
17911
18022
  neverStarted = (r) => r.unspawned === true || !!r.errorWhy?.some((why2) => why2.kind === "notInstalled");
@@ -17958,8 +18069,8 @@ var init_sources = __esm({
17958
18069
  });
17959
18070
 
17960
18071
  // ../cli/src/lib/signals/inbox.ts
17961
- import fs53 from "node:fs";
17962
- import path56 from "node:path";
18072
+ import fs54 from "node:fs";
18073
+ import path57 from "node:path";
17963
18074
  function metaPair(key, value) {
17964
18075
  const name = typeof key === "string" ? key.trim() : "";
17965
18076
  if (!name) return null;
@@ -17990,7 +18101,7 @@ ${signal2.summary.trim()}
17990
18101
  function parse(file, lenient = false) {
17991
18102
  let text4;
17992
18103
  try {
17993
- text4 = fs53.readFileSync(file, "utf8");
18104
+ text4 = fs54.readFileSync(file, "utf8");
17994
18105
  } catch {
17995
18106
  return null;
17996
18107
  }
@@ -18044,20 +18155,20 @@ function parse(file, lenient = false) {
18044
18155
  };
18045
18156
  }
18046
18157
  function freeName(dir, wanted) {
18047
- const ext = path56.extname(wanted);
18158
+ const ext = path57.extname(wanted);
18048
18159
  const stem = wanted.slice(0, wanted.length - ext.length);
18049
18160
  let name = wanted;
18050
- for (let n = 2; fs53.existsSync(path56.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
18161
+ for (let n = 2; fs54.existsSync(path57.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
18051
18162
  return name;
18052
18163
  }
18053
18164
  function readFolder2(dir, lenient = false) {
18054
18165
  let entries;
18055
18166
  try {
18056
- entries = fs53.readdirSync(dir, { withFileTypes: true });
18167
+ entries = fs54.readdirSync(dir, { withFileTypes: true });
18057
18168
  } catch {
18058
18169
  return [];
18059
18170
  }
18060
- return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path56.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
18171
+ return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path57.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
18061
18172
  }
18062
18173
  function readInbox() {
18063
18174
  const signals = readFolder2(TRIAGE);
@@ -18065,7 +18176,7 @@ function readInbox() {
18065
18176
  return signals;
18066
18177
  }
18067
18178
  function writeSignal(incoming, importedAt, slug2 = "") {
18068
- fs53.mkdirSync(TRIAGE, { recursive: true });
18179
+ fs54.mkdirSync(TRIAGE, { recursive: true });
18069
18180
  const signal2 = {
18070
18181
  ...incoming,
18071
18182
  importedAt,
@@ -18077,12 +18188,12 @@ function writeSignal(incoming, importedAt, slug2 = "") {
18077
18188
  contentKept: true,
18078
18189
  relPath: ""
18079
18190
  };
18080
- const file = path56.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
18081
- fs53.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
18191
+ const file = path57.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
18192
+ fs54.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
18082
18193
  return { ...signal2, relPath: boardRel(file) };
18083
18194
  }
18084
18195
  function stamp3(file, fields) {
18085
- const text4 = fs53.readFileSync(file, "utf8");
18196
+ const text4 = fs54.readFileSync(file, "utf8");
18086
18197
  const lines = text4.split("\n");
18087
18198
  const close = lines.indexOf("---", 1);
18088
18199
  if (close < 0) return;
@@ -18091,13 +18202,13 @@ function stamp3(file, fields) {
18091
18202
  return !key || fields[key[1]] === void 0;
18092
18203
  });
18093
18204
  const added = Object.entries(fields).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
18094
- fs53.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
18205
+ fs54.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
18095
18206
  }
18096
18207
  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);
18208
+ if (!fs54.existsSync(from)) return "";
18209
+ fs54.mkdirSync(into, { recursive: true });
18210
+ const at = path57.join(into, freeName(into, path57.basename(from)));
18211
+ fs54.renameSync(from, at);
18101
18212
  stamp3(at, fields);
18102
18213
  return boardRel(at);
18103
18214
  }
@@ -18106,10 +18217,10 @@ function archiveInboxItem(sourceId, cardId2) {
18106
18217
  if (!found2) {
18107
18218
  const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
18108
18219
  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) });
18220
+ stamp3(path57.join(SIGNALS_DISMISSED, path57.basename(ignored.relPath)), { card_id: String(cardId2) });
18110
18221
  return { ok: true, relPath: ignored.relPath, where: "dismissed" };
18111
18222
  }
18112
- const at = moveSignal(path56.join(TRIAGE, path56.basename(found2.relPath)), SIGNALS_ARCHIVED, {
18223
+ const at = moveSignal(path57.join(TRIAGE, path57.basename(found2.relPath)), SIGNALS_ARCHIVED, {
18113
18224
  card_id: String(cardId2),
18114
18225
  archived_at: formatStamp(/* @__PURE__ */ new Date())
18115
18226
  });
@@ -18123,7 +18234,7 @@ var init_inbox = __esm({
18123
18234
  init_sources();
18124
18235
  init_paths();
18125
18236
  init_yaml();
18126
- boardRel = (file) => rel(file).split(path56.sep).join("/");
18237
+ boardRel = (file) => rel(file).split(path57.sep).join("/");
18127
18238
  FIELDS = ["source_id", "title", "collected_at", "imported_at"];
18128
18239
  META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
18129
18240
  slugOf = (said2) => said2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
@@ -18232,12 +18343,12 @@ var init_studio_cards = __esm({
18232
18343
  });
18233
18344
 
18234
18345
  // ../cli/src/lib/readme.ts
18235
- import fs54 from "node:fs";
18236
- import path57 from "node:path";
18346
+ import fs55 from "node:fs";
18347
+ import path58 from "node:path";
18237
18348
  function stripReadmeRefs(target) {
18238
- if (!fs54.existsSync(README)) return [];
18349
+ if (!fs55.existsSync(README)) return [];
18239
18350
  const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
18240
- const lines = fs54.readFileSync(README, "utf8").split("\n");
18351
+ const lines = fs55.readFileSync(README, "utf8").split("\n");
18241
18352
  const out = [];
18242
18353
  const removed = [];
18243
18354
  let i = 0;
@@ -18259,20 +18370,20 @@ function stripReadmeRefs(target) {
18259
18370
  out.push(line);
18260
18371
  i++;
18261
18372
  }
18262
- if (removed.length) fs54.writeFileSync(README, out.join("\n"));
18373
+ if (removed.length) fs55.writeFileSync(README, out.join("\n"));
18263
18374
  return removed;
18264
18375
  }
18265
18376
  function addReadmeRef(id, title, relPath) {
18266
- if (!fs54.existsSync(README)) return false;
18267
- const link2 = relPath.split(path57.sep).join("/");
18377
+ if (!fs55.existsSync(README)) return false;
18378
+ const link2 = relPath.split(path58.sep).join("/");
18268
18379
  const bullet = `- [#${id} ${title}](${link2})`;
18269
18380
  const heading = `## ${TASKS_HEADING}`;
18270
- let lines = fs54.readFileSync(README, "utf8").split("\n");
18381
+ let lines = fs55.readFileSync(README, "utf8").split("\n");
18271
18382
  const hi = lines.findIndex((l) => l.trim().toLowerCase() === heading.toLowerCase());
18272
18383
  if (hi === -1) {
18273
18384
  while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
18274
18385
  lines.push("", heading, "", bullet);
18275
- fs54.writeFileSync(README, lines.join("\n") + "\n");
18386
+ fs55.writeFileSync(README, lines.join("\n") + "\n");
18276
18387
  return true;
18277
18388
  }
18278
18389
  let end2 = hi + 1;
@@ -18286,15 +18397,15 @@ function addReadmeRef(id, title, relPath) {
18286
18397
  const at = lastBullet !== -1 ? lastBullet + 1 : lines[hi + 1] === "" ? hi + 2 : hi + 1;
18287
18398
  lines.splice(at, 0, bullet);
18288
18399
  }
18289
- fs54.writeFileSync(README, lines.join("\n"));
18400
+ fs55.writeFileSync(README, lines.join("\n"));
18290
18401
  return true;
18291
18402
  }
18292
18403
  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("/");
18404
+ if (!fs55.existsSync(README)) return false;
18405
+ const oldLink = oldRel.split(path58.sep).join("/");
18406
+ const newLink = newRel.split(path58.sep).join("/");
18296
18407
  const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
18297
- const lines = fs54.readFileSync(README, "utf8").split("\n");
18408
+ const lines = fs55.readFileSync(README, "utf8").split("\n");
18298
18409
  let changed = false;
18299
18410
  for (let i = 0; i < lines.length; i++) {
18300
18411
  if (!lines[i].includes(`](${oldLink})`)) continue;
@@ -18304,7 +18415,7 @@ function repointReadmeLink(id, oldRel, newRel, title) {
18304
18415
  changed = true;
18305
18416
  }
18306
18417
  }
18307
- if (changed) fs54.writeFileSync(README, lines.join("\n"));
18418
+ if (changed) fs55.writeFileSync(README, lines.join("\n"));
18308
18419
  return changed;
18309
18420
  }
18310
18421
  var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex;
@@ -18791,14 +18902,14 @@ function collect(body, card, host2) {
18791
18902
  const active2 = /* @__PURE__ */ new Set();
18792
18903
  const out = [];
18793
18904
  const visit = (src, types, owner) => {
18794
- const path85 = src.replace(/[?#].*$/, "");
18905
+ const path86 = src.replace(/[?#].*$/, "");
18795
18906
  let resolved2;
18796
18907
  try {
18797
- resolved2 = host2.resolve(path85, owner);
18908
+ resolved2 = host2.resolve(path86, owner);
18798
18909
  } catch (error) {
18799
18910
  if (owner !== card) return { key: null, error: why(error) };
18800
18911
  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]) };
18912
+ const node2 = { key: src, file: null, kind: kindAt(path86, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18802
18913
  nodes.set(src, node2);
18803
18914
  out.push(node2);
18804
18915
  }
@@ -18883,16 +18994,16 @@ var init_collect = __esm({
18883
18994
  });
18884
18995
 
18885
18996
  // ../cli/src/lib/dress-page.ts
18886
- import fs55 from "node:fs";
18887
- import path58 from "node:path";
18997
+ import fs56 from "node:fs";
18998
+ import path59 from "node:path";
18888
18999
  function dressPage(file) {
18889
- const folder = path58.dirname(file);
18890
- const html = fs55.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
19000
+ const folder = path59.dirname(file);
19001
+ const html = fs56.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
18891
19002
  const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
18892
19003
  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})`);
19004
+ const at2 = path59.resolve(folder, href);
19005
+ if (!at2.startsWith(folder + path59.sep) || !fs56.existsSync(at2)) return tag;
19006
+ 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
19007
  return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
18897
19008
  });
18898
19009
  const at = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
@@ -18904,25 +19015,25 @@ var init_dress_page = __esm({
18904
19015
  "use strict";
18905
19016
  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
19017
  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");
19018
+ referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs56.readFileSync(file, "utf8");
18908
19019
  }
18909
19020
  });
18910
19021
 
18911
19022
  // ../cli/src/lib/preview-files.ts
18912
- import fs56 from "node:fs";
18913
- import path59 from "node:path";
19023
+ import fs57 from "node:fs";
19024
+ import path60 from "node:path";
18914
19025
  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));
19026
+ const roots = [KANBAN, path60.join(ASSETS, String(id)), path60.join(MOCKUPS, String(id))];
19027
+ const real2 = (p) => fs57.existsSync(p) ? fs57.realpathSync(p) : p;
19028
+ const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) + path60.sep));
18918
19029
  return (src, owner) => {
18919
19030
  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");
19031
+ if (path60.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
18921
19032
  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 };
19033
+ const file = held4 ? path60.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path60.resolve(path60.dirname(owner), src);
19034
+ if (!inside2(path60.resolve(file)) || fs57.existsSync(file) && !inside2(fs57.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
19035
+ if (!fs57.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
19036
+ return { key: fs57.realpathSync(file), file };
18926
19037
  };
18927
19038
  }
18928
19039
  function validatePreviewFiles(card, id, text4) {
@@ -18965,8 +19076,8 @@ var init_preview_files = __esm({
18965
19076
  });
18966
19077
 
18967
19078
  // ../cli/src/lib/spec-contract.ts
18968
- import fs57 from "node:fs";
18969
- import path60 from "node:path";
19079
+ import fs58 from "node:fs";
19080
+ import path61 from "node:path";
18970
19081
  function scanCardLines(lines, start = 0) {
18971
19082
  const visible = lines.map(() => "");
18972
19083
  let fence = null;
@@ -18999,18 +19110,18 @@ function scanCardLines(lines, start = 0) {
18999
19110
  }
19000
19111
  function snapshotSpecs() {
19001
19112
  const out = /* @__PURE__ */ new Map();
19002
- if (!fs57.existsSync(TODO)) return out;
19113
+ if (!fs58.existsSync(TODO)) return out;
19003
19114
  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") });
19115
+ if (isLegacyRecurring(path61.relative(TODO, file))) continue;
19116
+ const id = idPrefix(path61.basename(file) === "root.md" ? path61.basename(path61.dirname(file)) : path61.basename(file));
19117
+ if (id !== null) out.set(file, { id, text: fs58.readFileSync(file, "utf8") });
19007
19118
  }
19008
19119
  return out;
19009
19120
  }
19010
19121
  function enclosingGroups(file) {
19011
19122
  const ids = [];
19012
19123
  for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
19013
- const id = idPrefix(path60.basename(path60.dirname(root2)));
19124
+ const id = idPrefix(path61.basename(path61.dirname(root2)));
19014
19125
  if (id !== null) ids.push(id);
19015
19126
  }
19016
19127
  return ids;
@@ -19185,9 +19296,9 @@ function setEnd(lines, at) {
19185
19296
  }
19186
19297
  function inside(dir, name) {
19187
19298
  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;
19299
+ const root2 = fs58.realpathSync(dir);
19300
+ const real2 = fs58.realpathSync(path61.join(dir, name));
19301
+ return real2.startsWith(root2 + path61.sep) && fs58.statSync(real2).isFile() ? real2 : null;
19191
19302
  } catch {
19192
19303
  return null;
19193
19304
  }
@@ -19205,7 +19316,7 @@ function variantsProblem(raw, src, id) {
19205
19316
  if (files.length < 2 || !files.every((f) => typeof f === "string" && f)) return `variants needs at least two labels, each naming a file. ${shape}`;
19206
19317
  if (!files.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
19207
19318
  if (id === void 0) return null;
19208
- const dir = path60.join(ASSETS, String(id));
19319
+ const dir = path61.join(ASSETS, String(id));
19209
19320
  for (const f of files) {
19210
19321
  const parts = f.split("/");
19211
19322
  if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
@@ -19215,12 +19326,12 @@ function variantsProblem(raw, src, id) {
19215
19326
  return null;
19216
19327
  }
19217
19328
  function compareProblem(attrs, id) {
19218
- const dir = path60.join(ASSETS, String(id));
19329
+ const dir = path61.join(ASSETS, String(id));
19219
19330
  const src = (message) => ({ rule: "compare-src", message });
19220
19331
  const shots = (message) => ({ rule: "compare-shots", message });
19221
19332
  const json = (file) => {
19222
19333
  try {
19223
- return file.endsWith(".json") ? JSON.parse(fs57.readFileSync(file, "utf8")) : null;
19334
+ return file.endsWith(".json") ? JSON.parse(fs58.readFileSync(file, "utf8")) : null;
19224
19335
  } catch {
19225
19336
  return null;
19226
19337
  }
@@ -19245,7 +19356,7 @@ function compareProblem(attrs, id) {
19245
19356
  const file = inside(dir, named2.name);
19246
19357
  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
19358
  try {
19248
- return { data: JSON.parse(fs57.readFileSync(file, "utf8")) };
19359
+ return { data: JSON.parse(fs58.readFileSync(file, "utf8")) };
19249
19360
  } catch {
19250
19361
  return { message: `${at} is not valid JSON.` };
19251
19362
  }
@@ -19263,7 +19374,7 @@ function compareProblem(attrs, id) {
19263
19374
  }
19264
19375
  function validateStoryboards(file, id, text4) {
19265
19376
  const errors = [];
19266
- const dir = path60.join(ASSETS, String(id));
19377
+ const dir = path61.join(ASSETS, String(id));
19267
19378
  for (const [tag, tagOf, rule, fix] of [
19268
19379
  ["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
19269
19380
  ["Studio", studioTag, "studio-src", "Write it with `akb raw studio diagram <studio id> <card id>` or fix the path."]
@@ -19299,14 +19410,14 @@ var init_spec_contract = __esm({
19299
19410
  });
19300
19411
 
19301
19412
  // ../cli/src/lib/reconcile.ts
19302
- import fs58 from "node:fs";
19303
- import path61 from "node:path";
19413
+ import fs59 from "node:fs";
19414
+ import path62 from "node:path";
19304
19415
  function liveIds() {
19305
19416
  const ids = /* @__PURE__ */ new Set();
19306
19417
  for (const file of walkMd(TODO)) {
19307
- const base = path61.basename(file);
19418
+ const base = path62.basename(file);
19308
19419
  if (base === "README.md") continue;
19309
- const id = base === "root.md" ? idPrefix(path61.basename(path61.dirname(file))) : idPrefix(base);
19420
+ const id = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
19310
19421
  if (id != null) ids.add(id);
19311
19422
  }
19312
19423
  return ids;
@@ -19314,16 +19425,16 @@ function liveIds() {
19314
19425
  function indexableCards() {
19315
19426
  const out = [];
19316
19427
  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("/") });
19428
+ const id = idPrefix(path62.basename(dir));
19429
+ if (id != null && fs59.existsSync(path62.join(dir, "root.md"))) {
19430
+ out.push({ id, rel: path62.join(path62.relative(TODO, dir), "root.md").split(path62.sep).join("/") });
19320
19431
  }
19321
19432
  }
19322
19433
  for (const file of walkMd(TODO)) {
19323
- const base = path61.basename(file);
19434
+ const base = path62.basename(file);
19324
19435
  if (base === "README.md" || base === "root.md") continue;
19325
- const relTODO = path61.relative(TODO, file);
19326
- const segs = relTODO.split(path61.sep);
19436
+ const relTODO = path62.relative(TODO, file);
19437
+ const segs = relTODO.split(path62.sep);
19327
19438
  if (segs.length !== 1) continue;
19328
19439
  const id = idPrefix(base);
19329
19440
  if (id != null) out.push({ id, rel: segs.join("/") });
@@ -19332,7 +19443,7 @@ function indexableCards() {
19332
19443
  }
19333
19444
  function readmeComplaints(fix) {
19334
19445
  const said2 = [];
19335
- const lines = fs58.readFileSync(README, "utf8").split("\n");
19446
+ const lines = fs59.readFileSync(README, "utf8").split("\n");
19336
19447
  const indexed = /* @__PURE__ */ new Set();
19337
19448
  let fixed = 0;
19338
19449
  for (let i = 0; i < lines.length; i++) {
@@ -19341,13 +19452,13 @@ function readmeComplaints(fix) {
19341
19452
  const id = Number(m[1]);
19342
19453
  const linkPath = m[2];
19343
19454
  indexed.add(id);
19344
- if (fs58.existsSync(path61.join(TODO, linkPath))) continue;
19455
+ if (fs59.existsSync(path62.join(TODO, linkPath))) continue;
19345
19456
  const found2 = locate(id);
19346
19457
  if (!found2) {
19347
19458
  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
19459
  continue;
19349
19460
  }
19350
- const want = (found2.kind === "group" ? path61.join(found2.rel, "root.md") : found2.rel).split(path61.sep).join("/");
19461
+ const want = (found2.kind === "group" ? path62.join(found2.rel, "root.md") : found2.rel).split(path62.sep).join("/");
19351
19462
  if (want === linkPath) continue;
19352
19463
  if (!fix) {
19353
19464
  said2.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
@@ -19357,7 +19468,7 @@ function readmeComplaints(fix) {
19357
19468
  said2.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
19358
19469
  fixed++;
19359
19470
  }
19360
- if (fixed) fs58.writeFileSync(README, lines.join("\n"));
19471
+ if (fixed) fs59.writeFileSync(README, lines.join("\n"));
19361
19472
  for (const c of indexableCards()) {
19362
19473
  if (!indexed.has(c.id)) {
19363
19474
  said2.push(`card ${c.rel} (#${c.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
@@ -19369,11 +19480,11 @@ function crossRefComplaints() {
19369
19480
  const said2 = [];
19370
19481
  const live = liveIds();
19371
19482
  for (const file of walkMd(TODO)) {
19372
- const base = path61.basename(file);
19483
+ const base = path62.basename(file);
19373
19484
  if (base === "README.md") continue;
19374
- const ownerId = base === "root.md" ? idPrefix(path61.basename(path61.dirname(file))) : idPrefix(base);
19485
+ const ownerId = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
19375
19486
  if (ownerId == null) continue;
19376
- const { meta } = parseFrontmatter(fs58.readFileSync(file, "utf8"));
19487
+ const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19377
19488
  if (!meta) continue;
19378
19489
  for (const field2 of ["blocked_by", "related"]) {
19379
19490
  for (const ref of meta[field2] || []) {
@@ -19386,11 +19497,11 @@ function crossRefComplaints() {
19386
19497
  return said2;
19387
19498
  }
19388
19499
  function reconcileBoard() {
19389
- if (!fs58.existsSync(README)) return;
19500
+ if (!fs59.existsSync(README)) return;
19390
19501
  for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
19391
19502
  }
19392
19503
  function boardComplaints() {
19393
- if (!fs58.existsSync(README)) return [];
19504
+ if (!fs59.existsSync(README)) return [];
19394
19505
  try {
19395
19506
  return [...readmeComplaints(false), ...crossRefComplaints()];
19396
19507
  } catch {
@@ -19410,8 +19521,8 @@ var init_reconcile = __esm({
19410
19521
  });
19411
19522
 
19412
19523
  // ../cli/src/commands/card.ts
19413
- import fs59 from "node:fs";
19414
- import path62 from "node:path";
19524
+ import fs60 from "node:fs";
19525
+ import path63 from "node:path";
19415
19526
  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
19527
  return [
19417
19528
  summary,
@@ -19437,7 +19548,7 @@ function bodyFromFile(opts) {
19437
19548
  if (opts.body === false) die("pass --body-file or --no-body, not both");
19438
19549
  let text4;
19439
19550
  try {
19440
- text4 = fs59.readFileSync(opts.bodyFile, "utf8");
19551
+ text4 = fs60.readFileSync(opts.bodyFile, "utf8");
19441
19552
  } catch {
19442
19553
  die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
19443
19554
  }
@@ -19502,20 +19613,20 @@ function cmdCreate(opts) {
19502
19613
  const start = opts.id;
19503
19614
  const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
19504
19615
  const fileRel = `${start}-${slug2}.md`;
19505
- const file = path62.join(TODO, fileRel);
19616
+ const file = path63.join(TODO, fileRel);
19506
19617
  const held4 = locate(start) ?? locateArchived(start);
19507
- if (held4 && path62.basename(held4.target) === `${start}-${slug2}.md`) {
19618
+ if (held4 && path63.basename(held4.target) === `${start}-${slug2}.md`) {
19508
19619
  say(start);
19509
19620
  say(` ${rel(held4.target)} was already written`);
19510
19621
  return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
19511
19622
  }
19512
19623
  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`);
19624
+ if (fs60.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
19514
19625
  countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
19515
19626
  const meta = { title, priority, status: "todo", blocked_by, related, modules, studio, previews, stages, triage, source, questions };
19516
19627
  const scaffolded = !written && opts.body !== false;
19517
19628
  const body = written ?? (scaffolded ? defaultBody() : "");
19518
- fs59.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
19629
+ fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
19519
19630
  const indexed = addReadmeRef(start, title, fileRel);
19520
19631
  say(start);
19521
19632
  say(
@@ -19567,8 +19678,8 @@ function cmdUpdate(id, flags) {
19567
19678
  if (creating) die(creating, { kind: "card-being-created", id });
19568
19679
  const found2 = locate(id);
19569
19680
  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"));
19681
+ const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
19682
+ const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
19572
19683
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
19573
19684
  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
19685
  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 +19753,26 @@ function cmdUpdate(id, flags) {
19642
19753
  meta.status = "todo";
19643
19754
  changes.push("status\u2192todo (open questions)");
19644
19755
  }
19645
- const curRel = path62.relative(TODO, file);
19756
+ const curRel = path63.relative(TODO, file);
19646
19757
  const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
19647
- let base = path62.basename(file);
19758
+ let base = path63.basename(file);
19648
19759
  if (flags.slug !== void 0) {
19649
19760
  if (found2.kind === "group") die("renaming a group root by script is not supported");
19650
19761
  base = `${id}-${slugify(flags.slug)}.md`;
19651
19762
  }
19652
- const destRel = path62.join(path62.dirname(curRel), base);
19653
- const dest = path62.join(TODO, destRel);
19763
+ const destRel = path63.join(path63.dirname(curRel), base);
19764
+ const dest = path63.join(TODO, destRel);
19654
19765
  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);
19766
+ if (moving && fs60.existsSync(dest)) die(`${rel(dest)} already exists`);
19767
+ fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19768
+ if (moving) fs60.renameSync(file, dest);
19658
19769
  if (isSubtask) {
19659
19770
  if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
19660
- if (moving) changes.push(`renamed \u2192 ${destRel.split(path62.sep).join("/")}`);
19771
+ if (moving) changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
19661
19772
  } else if (moving) {
19662
19773
  stripReadmeRefs({ kind: "file", rel: curRel });
19663
19774
  addReadmeRef(id, meta.title, destRel);
19664
- changes.push(`renamed \u2192 ${destRel.split(path62.sep).join("/")}`);
19775
+ changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
19665
19776
  } else if (changes.includes("title")) {
19666
19777
  stripReadmeRefs({ kind: "file", rel: curRel });
19667
19778
  addReadmeRef(id, meta.title, curRel);
@@ -19673,8 +19784,8 @@ function cmdUpdateQuestions(id, input) {
19673
19784
  const ops = readQuestionOps(input.ops ?? []);
19674
19785
  const found2 = locate(id);
19675
19786
  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"));
19787
+ const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
19788
+ const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
19678
19789
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
19679
19790
  for (const op of ops) {
19680
19791
  if (!op.question?.agent) continue;
@@ -19696,7 +19807,7 @@ function cmdUpdateQuestions(id, input) {
19696
19807
  meta.status = "todo";
19697
19808
  changes.push("status\u2192todo (open questions)");
19698
19809
  }
19699
- fs59.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19810
+ fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19700
19811
  const closed2 = activeDelivery(id) ? "questions_closed_verify" : "questions_closed_user";
19701
19812
  for (const _ of done2.closed) countBoardEvent(closed2);
19702
19813
  say(`updated #${id} questions: ${changes.join(", ")} (${open3} open)`);
@@ -19763,13 +19874,13 @@ var init_config_template = __esm({
19763
19874
  });
19764
19875
 
19765
19876
  // ../cli/src/lib/agent/local.ts
19766
- import fs60 from "node:fs";
19767
- import path63 from "node:path";
19877
+ import fs61 from "node:fs";
19878
+ import path64 from "node:path";
19768
19879
  function takeLocalModels(board2) {
19769
- const file = path63.join(board2, ".local.json");
19880
+ const file = path64.join(board2, ".local.json");
19770
19881
  let held4;
19771
19882
  try {
19772
- held4 = configBlock(JSON.parse(fs60.readFileSync(file, "utf8")));
19883
+ held4 = configBlock(JSON.parse(fs61.readFileSync(file, "utf8")));
19773
19884
  } catch {
19774
19885
  return {};
19775
19886
  }
@@ -19787,7 +19898,7 @@ function takeLocalModels(board2) {
19787
19898
  }
19788
19899
  if (!Object.keys(agents).length) return out;
19789
19900
  delete held4.agents;
19790
- fs60.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19901
+ fs61.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19791
19902
  return out;
19792
19903
  }
19793
19904
  var LOCAL_IGNORE_LINE;
@@ -19848,12 +19959,12 @@ var init_identity2 = __esm({
19848
19959
  });
19849
19960
 
19850
19961
  // ../cli/src/lib/signals/migrate.ts
19851
- import fs61 from "node:fs";
19852
- import path64 from "node:path";
19962
+ import fs62 from "node:fs";
19963
+ import path65 from "node:path";
19853
19964
  function readHandled() {
19854
19965
  let text4;
19855
19966
  try {
19856
- text4 = fs61.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19967
+ text4 = fs62.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19857
19968
  } catch {
19858
19969
  return [];
19859
19970
  }
@@ -19870,57 +19981,57 @@ function readHandled() {
19870
19981
  return held4;
19871
19982
  }
19872
19983
  function lift(from, into) {
19873
- fs61.mkdirSync(into, { recursive: true });
19874
- fs61.renameSync(from, path64.join(into, freeName(into, path64.basename(from))));
19984
+ fs62.mkdirSync(into, { recursive: true });
19985
+ fs62.renameSync(from, path65.join(into, freeName(into, path65.basename(from))));
19875
19986
  }
19876
19987
  function repoint(dir, from, into) {
19877
19988
  let entries;
19878
19989
  try {
19879
- entries = fs61.readdirSync(dir, { withFileTypes: true });
19990
+ entries = fs62.readdirSync(dir, { withFileTypes: true });
19880
19991
  } catch {
19881
19992
  return;
19882
19993
  }
19883
19994
  for (const entry of entries) {
19884
19995
  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));
19996
+ const file = path65.join(dir, entry.name);
19997
+ const text4 = fs62.readFileSync(file, "utf8");
19998
+ if (text4.includes(from)) fs62.writeFileSync(file, text4.split(from).join(into));
19888
19999
  }
19889
20000
  }
19890
20001
  function dropIfEmpty2(dir) {
19891
20002
  try {
19892
- fs61.rmdirSync(dir);
20003
+ fs62.rmdirSync(dir);
19893
20004
  } catch {
19894
20005
  }
19895
20006
  }
19896
20007
  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);
20008
+ if (!fs62.existsSync(SIGNALS_OLD_INBOX)) return;
20009
+ const oldFiles = path65.join(SIGNALS_OLD_INBOX, "files");
20010
+ if (fs62.existsSync(oldFiles)) {
20011
+ for (const entry of fs62.readdirSync(oldFiles, { withFileTypes: true })) {
20012
+ if (entry.isFile()) lift(path65.join(oldFiles, entry.name), SIGNALS_FILES);
19902
20013
  }
19903
20014
  dropIfEmpty2(oldFiles);
19904
20015
  }
19905
20016
  const held4 = new Set(readFolder2(TRIAGE).map((signal2) => signal2.sourceId));
19906
- for (const entry of fs61.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
20017
+ for (const entry of fs62.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19907
20018
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
19908
- const from = path64.join(SIGNALS_OLD_INBOX, entry.name);
20019
+ const from = path65.join(SIGNALS_OLD_INBOX, entry.name);
19909
20020
  const item = parse(from);
19910
20021
  if (item && held4.has(item.sourceId)) {
19911
- fs61.rmSync(from, { force: true });
20022
+ fs62.rmSync(from, { force: true });
19912
20023
  continue;
19913
20024
  }
19914
20025
  if (item) held4.add(item.sourceId);
19915
20026
  lift(from, TRIAGE);
19916
20027
  }
19917
- const wasAt = asWritten(path64.join(SIGNALS_OLD_INBOX, "files"));
20028
+ const wasAt = asWritten(path65.join(SIGNALS_OLD_INBOX, "files"));
19918
20029
  const nowAt = asWritten(SIGNALS_FILES);
19919
20030
  for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
19920
20031
  dropIfEmpty2(SIGNALS_OLD_INBOX);
19921
20032
  }
19922
20033
  function liftHandled() {
19923
- if (!fs61.existsSync(SIGNALS_OLD_HANDLED)) return;
20034
+ if (!fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
19924
20035
  const lines = readHandled();
19925
20036
  const held4 = /* @__PURE__ */ new Set([
19926
20037
  ...readFolder2(TRIAGE).map((signal2) => signal2.sourceId),
@@ -19930,7 +20041,7 @@ function liftHandled() {
19930
20041
  for (const { sourceId, when } of lines) {
19931
20042
  if (held4.has(sourceId)) continue;
19932
20043
  held4.add(sourceId);
19933
- fs61.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
20044
+ fs62.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19934
20045
  const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
19935
20046
  const front = [
19936
20047
  "---",
@@ -19940,13 +20051,13 @@ function liftHandled() {
19940
20051
  "---",
19941
20052
  ""
19942
20053
  ];
19943
- fs61.writeFileSync(path64.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
20054
+ fs62.writeFileSync(path65.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19944
20055
  `);
19945
20056
  }
19946
- fs61.rmSync(SIGNALS_OLD_HANDLED, { force: true });
20057
+ fs62.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19947
20058
  }
19948
20059
  function migrateTriage() {
19949
- if (!fs61.existsSync(SIGNALS_OLD_INBOX) && !fs61.existsSync(SIGNALS_OLD_HANDLED)) return;
20060
+ if (!fs62.existsSync(SIGNALS_OLD_INBOX) && !fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
19950
20061
  try {
19951
20062
  liftInbox();
19952
20063
  liftHandled();
@@ -19961,13 +20072,13 @@ var init_migrate = __esm({
19961
20072
  init_yaml();
19962
20073
  init_inbox();
19963
20074
  HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
19964
- asWritten = (dir) => `${rel(dir).split(path64.sep).join("/")}/`;
20075
+ asWritten = (dir) => `${rel(dir).split(path65.sep).join("/")}/`;
19965
20076
  }
19966
20077
  });
19967
20078
 
19968
20079
  // ../cli/src/lib/signals/add.ts
19969
- import fs62 from "node:fs";
19970
- import path65 from "node:path";
20080
+ import fs63 from "node:fs";
20081
+ import path66 from "node:path";
19971
20082
  import { createHash as createHash4 } from "node:crypto";
19972
20083
  function linkTitle(url) {
19973
20084
  let at;
@@ -19980,7 +20091,7 @@ function linkTitle(url) {
19980
20091
  return oneLine(where) || url.slice(0, TITLE_MAX);
19981
20092
  }
19982
20093
  function asText(file) {
19983
- const ext = path65.extname(file.name).toLowerCase();
20094
+ const ext = path66.extname(file.name).toLowerCase();
19984
20095
  if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
19985
20096
  try {
19986
20097
  const text4 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
@@ -19990,9 +20101,9 @@ function asText(file) {
19990
20101
  }
19991
20102
  }
19992
20103
  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";
20104
+ const base = path66.basename(name);
20105
+ const ext = path66.extname(base).toLowerCase().slice(0, 12);
20106
+ const word = path66.basename(base, path66.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
19996
20107
  const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
19997
20108
  return `${word}-${hash2}${ext}`;
19998
20109
  }
@@ -20001,9 +20112,9 @@ function addToInbox(drop) {
20001
20112
  const typed = (drop.text ?? "").trim();
20002
20113
  const file = drop.file;
20003
20114
  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.` };
20115
+ if (file && file.data.length === 0) return { ok: false, error: `${path66.basename(file.name)} is empty.` };
20005
20116
  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.` };
20117
+ return { ok: false, error: `${path66.basename(file.name)} is over ${MAX_BYTES2 / 1024 / 1024} MB \u2014 too big for the board.` };
20007
20118
  }
20008
20119
  const read3 = describe(typed, file);
20009
20120
  const keep2 = read3.keep;
@@ -20025,8 +20136,8 @@ ${incoming.summary}`);
20025
20136
  if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
20026
20137
  try {
20027
20138
  if (keep2) {
20028
- fs62.mkdirSync(SIGNALS_FILES, { recursive: true });
20029
- fs62.writeFileSync(keep2.at, keep2.data);
20139
+ fs63.mkdirSync(SIGNALS_FILES, { recursive: true });
20140
+ fs63.writeFileSync(keep2.at, keep2.data);
20030
20141
  }
20031
20142
  return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
20032
20143
  } catch (e) {
@@ -20040,7 +20151,7 @@ function describe(typed, file) {
20040
20151
  return only ? [only] : [];
20041
20152
  };
20042
20153
  if (file) {
20043
- const name = path65.basename(file.name);
20154
+ const name = path66.basename(file.name);
20044
20155
  const text4 = asText(file);
20045
20156
  const note = typed ? `
20046
20157
 
@@ -20052,7 +20163,7 @@ ${typed}` : "";
20052
20163
  const at = keepAt(file);
20053
20164
  return {
20054
20165
  incoming: {
20055
- title: path65.basename(name, path65.extname(name)) || name,
20166
+ title: path66.basename(name, path66.extname(name)) || name,
20056
20167
  summary: `${name} \u2014 ${boardRel2(at)}${note}`,
20057
20168
  ...named2
20058
20169
  },
@@ -20090,73 +20201,73 @@ var init_add = __esm({
20090
20201
  MAX_BYTES2 = 25 * 1024 * 1024;
20091
20202
  TITLE_MAX = 120;
20092
20203
  TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
20093
- boardRel2 = (file) => rel(file).split(path65.sep).join("/");
20204
+ boardRel2 = (file) => rel(file).split(path66.sep).join("/");
20094
20205
  oneLine = (text4) => {
20095
20206
  const first = text4.split("\n").find((line) => line.trim()) ?? "";
20096
20207
  const clean = first.replace(/^#+\s*/, "").trim();
20097
20208
  return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
20098
20209
  };
20099
- keepAt = (file) => path65.join(SIGNALS_FILES, fileName2(file.name, file.data));
20210
+ keepAt = (file) => path66.join(SIGNALS_FILES, fileName2(file.name, file.data));
20100
20211
  }
20101
20212
  });
20102
20213
 
20103
20214
  // ../cli/src/lib/recurring.ts
20104
- import fs63 from "node:fs";
20105
- import path66 from "node:path";
20215
+ import fs64 from "node:fs";
20216
+ import path67 from "node:path";
20106
20217
  function migratePruneMemoryCard() {
20107
20218
  const dir = recurringDir();
20108
20219
  let names3;
20109
20220
  try {
20110
- names3 = fs63.readdirSync(dir);
20221
+ names3 = fs64.readdirSync(dir);
20111
20222
  } catch {
20112
20223
  return null;
20113
20224
  }
20114
20225
  const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
20115
20226
  if (!name) return null;
20116
- const file = path66.join(dir, name);
20227
+ const file = path67.join(dir, name);
20117
20228
  try {
20118
- const { meta } = parseFrontmatter(fs63.readFileSync(file, "utf8"));
20229
+ const { meta } = parseFrontmatter(fs64.readFileSync(file, "utf8"));
20119
20230
  const cadence = meta?.cadence;
20120
20231
  if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
20121
20232
  } catch {
20122
20233
  }
20123
- fs63.rmSync(file, { force: true });
20234
+ fs64.rmSync(file, { force: true });
20124
20235
  return rel(file);
20125
20236
  }
20126
20237
  function legacyCards() {
20127
20238
  const dir = recurringDir();
20128
- if (!fs63.existsSync(dir)) return [];
20239
+ if (!fs64.existsSync(dir)) return [];
20129
20240
  const cards = [];
20130
- for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
20241
+ for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20131
20242
  const id = idPrefix(entry.name);
20132
20243
  if (id === null) continue;
20133
- const full = path66.join(dir, entry.name);
20244
+ const full = path67.join(dir, entry.name);
20134
20245
  const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
20135
20246
  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 });
20247
+ else if (entry.isDirectory() && fs64.existsSync(path67.join(full, "root.md"))) {
20248
+ cards.push({ id, slug: slug2, file: path67.join(full, "root.md"), folder: full });
20138
20249
  }
20139
20250
  }
20140
20251
  return cards.sort((a, b) => a.id - b.id);
20141
20252
  }
20142
20253
  function mergeInto2(from, to, skip = []) {
20143
- fs63.mkdirSync(to, { recursive: true });
20144
- for (const entry of fs63.readdirSync(from, { withFileTypes: true })) {
20254
+ fs64.mkdirSync(to, { recursive: true });
20255
+ for (const entry of fs64.readdirSync(from, { withFileTypes: true })) {
20145
20256
  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);
20257
+ const source = path67.join(from, entry.name);
20258
+ const target = path67.join(to, entry.name);
20259
+ if (!fs64.existsSync(target)) fs64.renameSync(source, target);
20260
+ else if (entry.isDirectory() && fs64.statSync(target).isDirectory()) mergeInto2(source, target);
20150
20261
  }
20151
- if (isEmpty(from)) fs63.rmSync(from, { recursive: true, force: true });
20262
+ if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
20152
20263
  }
20153
20264
  function moveSideFolders() {
20154
20265
  const dir = recurringDir();
20155
- for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
20266
+ for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20156
20267
  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));
20268
+ const from = path67.join(dir, entry.name);
20269
+ if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
20270
+ else mergeInto2(from, path67.join(AGENTS, entry.name));
20160
20271
  }
20161
20272
  }
20162
20273
  function sections(body) {
@@ -20206,8 +20317,8 @@ function agentName(card, text4) {
20206
20317
  const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a) => a.name), ...ROLE_NAMES]);
20207
20318
  for (const name of [slug2, `${slug2}-${card.id}`]) {
20208
20319
  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;
20320
+ const file = path67.join(AGENTS, name, AGENT_FILE2);
20321
+ const written = fs64.existsSync(file) ? fs64.readFileSync(file, "utf8") : null;
20211
20322
  if (written === text4(name)) return name;
20212
20323
  if (written === null && !known2.has(name)) return name;
20213
20324
  }
@@ -20224,11 +20335,11 @@ ${q.options.map((o) => `- ${o}`).join("\n")}` : "";
20224
20335
  function removeCard(card) {
20225
20336
  dropCrossRefs(card.id);
20226
20337
  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 });
20338
+ stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path67.relative(TODO, target).split(path67.sep).join("/") });
20339
+ fs64.rmSync(target, { recursive: true, force: true });
20229
20340
  }
20230
20341
  function migrateCard(card) {
20231
- const { meta, body } = parseFrontmatter(fs63.readFileSync(card.file, "utf8"));
20342
+ const { meta, body } = parseFrontmatter(fs64.readFileSync(card.file, "utf8"));
20232
20343
  if (!meta) throw new Error("its frontmatter cannot be read");
20233
20344
  const raw = meta;
20234
20345
  const said2 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
@@ -20238,19 +20349,19 @@ function migrateCard(card) {
20238
20349
  if (!flow) throw new Error(noStudioMessage(""));
20239
20350
  const text4 = (name2) => agentText(name2, meta.title || card.slug, body);
20240
20351
  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);
20352
+ const dir = path67.join(AGENTS, name);
20353
+ const file = path67.join(dir, AGENT_FILE2);
20354
+ const madeDir = !fs64.existsSync(dir);
20355
+ const wrote = !fs64.existsSync(file);
20245
20356
  try {
20246
- fs63.mkdirSync(dir, { recursive: true });
20247
- if (wrote) fs63.writeFileSync(file, text4(name));
20357
+ fs64.mkdirSync(dir, { recursive: true });
20358
+ if (wrote) fs64.writeFileSync(file, text4(name));
20248
20359
  const adopted = adoptStudioScheduled(flow.id, name, { cadence, lastRun });
20249
20360
  if (!adopted.ok) throw new Error(adopted.error);
20250
20361
  questionsToTriage(meta, name);
20251
20362
  } catch (e) {
20252
- if (madeDir) fs63.rmSync(dir, { recursive: true, force: true });
20253
- else if (wrote) fs63.rmSync(file, { force: true });
20363
+ if (madeDir) fs64.rmSync(dir, { recursive: true, force: true });
20364
+ else if (wrote) fs64.rmSync(file, { force: true });
20254
20365
  throw e;
20255
20366
  }
20256
20367
  if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
@@ -20260,7 +20371,7 @@ function migrateCard(card) {
20260
20371
  function migrateRecurringCards() {
20261
20372
  const done2 = { agents: [], removed: [], failed: [] };
20262
20373
  const dir = recurringDir();
20263
- if (!fs63.existsSync(dir)) return done2;
20374
+ if (!fs64.existsSync(dir)) return done2;
20264
20375
  migratePruneMemoryCard();
20265
20376
  moveSideFolders();
20266
20377
  for (const card of legacyCards()) {
@@ -20273,7 +20384,7 @@ function migrateRecurringCards() {
20273
20384
  done2.failed.push({ card: rel(card.file), why: e instanceof Error ? e.message : String(e) });
20274
20385
  }
20275
20386
  }
20276
- if (isEmpty(dir)) fs63.rmSync(dir, { recursive: true, force: true });
20387
+ if (isEmpty(dir)) fs64.rmSync(dir, { recursive: true, force: true });
20277
20388
  return done2;
20278
20389
  }
20279
20390
  function recurringMigrationLines(done2) {
@@ -20306,14 +20417,14 @@ var init_recurring = __esm({
20306
20417
  PRUNE_SLUG = "prune-the-memory";
20307
20418
  FETCH_SLUG = "fetch-triage-items";
20308
20419
  AGENT_FILE2 = "AGENT.md";
20309
- recurringDir = () => path66.join(TODO, LEGACY_RECURRING);
20310
- isEmpty = (dir) => fs63.readdirSync(dir).every((name) => name === ".DS_Store");
20420
+ recurringDir = () => path67.join(TODO, LEGACY_RECURRING);
20421
+ isEmpty = (dir) => fs64.readdirSync(dir).every((name) => name === ".DS_Store");
20311
20422
  SECTION = /^##\s+(.+?)\s*$/;
20312
20423
  }
20313
20424
  });
20314
20425
 
20315
20426
  // ../cli/src/commands/init.ts
20316
- import fs64 from "node:fs";
20427
+ import fs65 from "node:fs";
20317
20428
  function boardReadme() {
20318
20429
  return `# Board
20319
20430
 
@@ -20326,20 +20437,20 @@ _(none)_
20326
20437
  `;
20327
20438
  }
20328
20439
  function writeConfigIfMissing() {
20329
- if (fs64.existsSync(CONFIG)) return false;
20330
- fs64.mkdirSync(KANBAN, { recursive: true });
20331
- fs64.writeFileSync(CONFIG, CONFIG_TEMPLATE);
20440
+ if (fs65.existsSync(CONFIG)) return false;
20441
+ fs65.mkdirSync(KANBAN, { recursive: true });
20442
+ fs65.writeFileSync(CONFIG, CONFIG_TEMPLATE);
20332
20443
  return true;
20333
20444
  }
20334
20445
  function writeModulesIfMissing() {
20335
- if (fs64.existsSync(MODULES_MD)) return false;
20336
- fs64.mkdirSync(KANBAN, { recursive: true });
20337
- fs64.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
20446
+ if (fs65.existsSync(MODULES_MD)) return false;
20447
+ fs65.mkdirSync(KANBAN, { recursive: true });
20448
+ fs65.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
20338
20449
  return true;
20339
20450
  }
20340
20451
  function writeGitignoreIfMissing() {
20341
- fs64.mkdirSync(KANBAN, { recursive: true });
20342
- const text4 = fs64.existsSync(KANBAN_GITIGNORE) ? fs64.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
20452
+ fs65.mkdirSync(KANBAN, { recursive: true });
20453
+ const text4 = fs65.existsSync(KANBAN_GITIGNORE) ? fs65.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
20343
20454
  const has = (rule) => text4.split("\n").some((line) => line.trim() === rule.line);
20344
20455
  const missing = IGNORE_RULES.filter((rule) => !has(rule));
20345
20456
  if (!missing.length) return false;
@@ -20347,37 +20458,37 @@ function writeGitignoreIfMissing() {
20347
20458
  ${rule.line}
20348
20459
  `).join("");
20349
20460
  const separator = !text4 || text4.endsWith("\n") ? "" : "\n";
20350
- fs64.writeFileSync(KANBAN_GITIGNORE, `${text4}${separator}${block}`);
20461
+ fs65.writeFileSync(KANBAN_GITIGNORE, `${text4}${separator}${block}`);
20351
20462
  return true;
20352
20463
  }
20353
20464
  function writeSkeletonIfMissing() {
20354
20465
  const added = [];
20355
- if (!fs64.existsSync(TODO)) {
20356
- fs64.mkdirSync(TODO, { recursive: true });
20466
+ if (!fs65.existsSync(TODO)) {
20467
+ fs65.mkdirSync(TODO, { recursive: true });
20357
20468
  added.push(`${rel(TODO)}/`);
20358
20469
  }
20359
- if (!fs64.existsSync(README)) {
20360
- fs64.writeFileSync(README, boardReadme());
20470
+ if (!fs65.existsSync(README)) {
20471
+ fs65.writeFileSync(README, boardReadme());
20361
20472
  added.push(rel(README));
20362
20473
  }
20363
20474
  return added;
20364
20475
  }
20365
20476
  function retireReleases() {
20366
20477
  const done2 = [];
20367
- if (fs64.existsSync(RELEASES)) {
20368
- fs64.rmSync(RELEASES);
20478
+ if (fs65.existsSync(RELEASES)) {
20479
+ fs65.rmSync(RELEASES);
20369
20480
  done2.push(`deleted ${rel(RELEASES)}`);
20370
20481
  }
20371
20482
  let cards = 0;
20372
20483
  for (const dir of [TODO, ARCHIVE]) {
20373
- if (!fs64.existsSync(dir)) continue;
20484
+ if (!fs65.existsSync(dir)) continue;
20374
20485
  for (const file of walkMd(dir)) {
20375
- const text4 = fs64.readFileSync(file, "utf8");
20486
+ const text4 = fs65.readFileSync(file, "utf8");
20376
20487
  const end2 = text4.startsWith("---\n") ? text4.indexOf("\n---", 3) : -1;
20377
20488
  if (end2 < 0) continue;
20378
20489
  const head2 = text4.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
20379
20490
  if (head2.length === end2) continue;
20380
- fs64.writeFileSync(file, head2 + text4.slice(end2));
20491
+ fs65.writeFileSync(file, head2 + text4.slice(end2));
20381
20492
  cards++;
20382
20493
  }
20383
20494
  }
@@ -20385,7 +20496,7 @@ function retireReleases() {
20385
20496
  return done2.join(", ");
20386
20497
  }
20387
20498
  function cmdInit() {
20388
- if (fs64.existsSync(KANBAN)) {
20499
+ if (fs65.existsSync(KANBAN)) {
20389
20500
  const added = [
20390
20501
  ...writeSkeletonIfMissing(),
20391
20502
  writeConfigIfMissing() && rel(CONFIG),
@@ -20420,8 +20531,8 @@ function cmdInit() {
20420
20531
  }
20421
20532
  return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
20422
20533
  }
20423
- fs64.mkdirSync(TODO, { recursive: true });
20424
- fs64.writeFileSync(README, boardReadme());
20534
+ fs65.mkdirSync(TODO, { recursive: true });
20535
+ fs65.writeFileSync(README, boardReadme());
20425
20536
  writeConfigIfMissing();
20426
20537
  scaffoldProjectMemory();
20427
20538
  writeModulesIfMissing();
@@ -20510,25 +20621,25 @@ var init_scheduled = __esm({
20510
20621
  });
20511
20622
 
20512
20623
  // ../cli/src/lib/card-age.ts
20513
- import fs65 from "node:fs";
20514
- import path67 from "node:path";
20624
+ import fs66 from "node:fs";
20625
+ import path68 from "node:path";
20515
20626
  function staleAfterIn(config) {
20516
20627
  const days = Number(LINE.exec(config)?.[1]);
20517
20628
  return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
20518
20629
  }
20519
20630
  function staleAfter() {
20520
- if (!fs65.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
20521
- return staleAfterIn(fs65.readFileSync(CONFIG, "utf8"));
20631
+ if (!fs66.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
20632
+ return staleAfterIn(fs66.readFileSync(CONFIG, "utf8"));
20522
20633
  }
20523
20634
  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("/");
20635
+ const from = path68.relative(real(top), real(TODO));
20636
+ if (!from || from.startsWith("..") || path68.isAbsolute(from)) return null;
20637
+ return from.split(path68.sep).join("/");
20527
20638
  }
20528
20639
  function cardFile2(spec, printed) {
20529
20640
  const p = unquotePath(printed);
20530
20641
  if (!p.startsWith(`${spec}/`)) return null;
20531
- return path67.join(TODO, ...p.slice(spec.length + 1).split("/"));
20642
+ return path68.join(TODO, ...p.slice(spec.length + 1).split("/"));
20532
20643
  }
20533
20644
  function dirtyCards(top, spec) {
20534
20645
  const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
@@ -20575,9 +20686,9 @@ var init_card_age = __esm({
20575
20686
  gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
20576
20687
  real = (p) => {
20577
20688
  try {
20578
- return fs65.realpathSync(p);
20689
+ return fs66.realpathSync(p);
20579
20690
  } catch {
20580
- return path67.resolve(p);
20691
+ return path68.resolve(p);
20581
20692
  }
20582
20693
  };
20583
20694
  unquotePath = (line) => {
@@ -20611,8 +20722,8 @@ var init_card_holds = __esm({
20611
20722
  });
20612
20723
 
20613
20724
  // ../cli/src/commands/list.ts
20614
- import fs66 from "node:fs";
20615
- import path68 from "node:path";
20725
+ import fs67 from "node:fs";
20726
+ import path69 from "node:path";
20616
20727
  function summaryLine(body) {
20617
20728
  const lines = body.split("\n");
20618
20729
  let i = 0;
@@ -20628,13 +20739,13 @@ function summaryLine(body) {
20628
20739
  function openRows() {
20629
20740
  const rows = [];
20630
20741
  for (const file of walkMd(TODO)) {
20631
- const base = path68.basename(file);
20742
+ const base = path69.basename(file);
20632
20743
  if (base === "README.md") continue;
20633
20744
  const isRoot = base === "root.md";
20634
- const id = isRoot ? idPrefix(path68.basename(path68.dirname(file))) : idPrefix(base);
20745
+ const id = isRoot ? idPrefix(path69.basename(path69.dirname(file))) : idPrefix(base);
20635
20746
  if (id == null) continue;
20636
- if (isLegacyRecurring(path68.relative(TODO, file))) continue;
20637
- const { meta, body } = parseFrontmatter(fs66.readFileSync(file, "utf8"));
20747
+ if (isLegacyRecurring(path69.relative(TODO, file))) continue;
20748
+ const { meta, body } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
20638
20749
  rows.push({
20639
20750
  id,
20640
20751
  file,
@@ -20676,15 +20787,15 @@ function cmdStale(rows, all2, scope, mod) {
20676
20787
  }
20677
20788
  function archivedFiles() {
20678
20789
  const files = /* @__PURE__ */ new Map();
20679
- if (!fs66.existsSync(ARCHIVE)) return files;
20790
+ if (!fs67.existsSync(ARCHIVE)) return files;
20680
20791
  for (const file of walkMd(ARCHIVE)) {
20681
- const id = idPrefix(path68.basename(file));
20792
+ const id = idPrefix(path69.basename(file));
20682
20793
  if (id !== null) files.set(id, file);
20683
20794
  }
20684
20795
  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);
20796
+ const id = idPrefix(path69.basename(dir));
20797
+ const root2 = path69.join(dir, "root.md");
20798
+ if (id !== null && fs67.existsSync(root2)) files.set(id, root2);
20688
20799
  }
20689
20800
  return files;
20690
20801
  }
@@ -20794,8 +20905,8 @@ var init_list = __esm({
20794
20905
  });
20795
20906
 
20796
20907
  // ../cli/src/lib/card-sources.ts
20797
- import fs67 from "node:fs";
20798
- import path69 from "node:path";
20908
+ import fs68 from "node:fs";
20909
+ import path70 from "node:path";
20799
20910
  function planById(id) {
20800
20911
  const found2 = readPlan(`plans/${id}-.md`);
20801
20912
  return found2?.text.trim() ? found2 : null;
@@ -20805,8 +20916,8 @@ function cardLink(id) {
20805
20916
  const found2 = open3 ?? locateArchived(id);
20806
20917
  if (!found2) return null;
20807
20918
  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 ?? "";
20919
+ const file = found2.kind === "group" ? path70.join(found2.target, "root.md") : found2.target;
20920
+ const title = parseFrontmatter(fs68.readFileSync(file, "utf8")).meta?.title ?? "";
20810
20921
  return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
20811
20922
  } catch {
20812
20923
  return null;
@@ -20831,7 +20942,7 @@ function link(ref, items) {
20831
20942
  if (ref.kind === "plan") return planLink(ref.id);
20832
20943
  if (ref.kind === "card") return cardLink(ref.id);
20833
20944
  if (ref.kind === "url") return urlLink(ref.url);
20834
- const item = items().find((signal2) => path69.basename(signal2.relPath) === ref.file);
20945
+ const item = items().find((signal2) => path70.basename(signal2.relPath) === ref.file);
20835
20946
  return item ? itemLink(item) : null;
20836
20947
  }
20837
20948
  function cardSources(meta, body) {
@@ -20872,12 +20983,12 @@ var init_card_sources = __esm({
20872
20983
  });
20873
20984
 
20874
20985
  // ../cli/src/lib/view/read.ts
20875
- import fs68 from "node:fs";
20876
- import path70 from "node:path";
20986
+ import fs69 from "node:fs";
20987
+ import path71 from "node:path";
20877
20988
  function readCard(file, relFromTodo) {
20878
- const id = idPrefix(path70.basename(relFromTodo));
20989
+ const id = idPrefix(path71.basename(relFromTodo));
20879
20990
  if (id === null) {
20880
- const parts = relFromTodo.split(path70.sep);
20991
+ const parts = relFromTodo.split(path71.sep);
20881
20992
  const folderId = idPrefix(parts[parts.length - 2] || "");
20882
20993
  if (folderId === null) return null;
20883
20994
  return buildCard(folderId, file, relFromTodo);
@@ -20885,10 +20996,10 @@ function readCard(file, relFromTodo) {
20885
20996
  return buildCard(id, file, relFromTodo);
20886
20997
  }
20887
20998
  function buildCard(id, file, relFromTodo) {
20888
- const text4 = fs68.readFileSync(file, "utf8");
20999
+ const text4 = fs69.readFileSync(file, "utf8");
20889
21000
  const { meta, body } = parseFrontmatter(text4);
20890
21001
  if (!meta) return null;
20891
- const relPath = relFromTodo.split(path70.sep).join("/");
21002
+ const relPath = relFromTodo.split(path71.sep).join("/");
20892
21003
  const flow = studioFor(meta.studio);
20893
21004
  const plan = !!meta.studio && archivesOnApproval(flow);
20894
21005
  const stages = cardStages(meta, flow).length;
@@ -20897,7 +21008,7 @@ function buildCard(id, file, relFromTodo) {
20897
21008
  // Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
20898
21009
  // read here and a card read by the contract agree on what version this is.
20899
21010
  revision: revisionOf(text4),
20900
- updatedAt: fs68.statSync(file).mtime.toISOString(),
21011
+ updatedAt: fs69.statSync(file).mtime.toISOString(),
20901
21012
  relPath,
20902
21013
  title: meta.title,
20903
21014
  priority: meta.priority,
@@ -20918,22 +21029,22 @@ function buildCard(id, file, relFromTodo) {
20918
21029
  };
20919
21030
  }
20920
21031
  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"));
21032
+ const groupDir = path71.join(TODO, folderName);
21033
+ const rootFile = path71.join(groupDir, "root.md");
21034
+ if (!fs69.existsSync(rootFile)) return null;
21035
+ const root2 = readCard(rootFile, path71.join(folderName, "root.md"));
20925
21036
  if (!root2) return null;
20926
21037
  root2.isGroup = true;
20927
21038
  const { total, resolved: resolved2 } = subtaskLines(root2.body);
20928
21039
  root2.subtaskLines = { total, resolved: resolved2 };
20929
21040
  const subCards = [];
20930
21041
  const recurse = (dir, relDir) => {
20931
- for (const entry of fs68.readdirSync(dir, { withFileTypes: true })) {
20932
- const childRel = path70.join(relDir, entry.name);
21042
+ for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
21043
+ const childRel = path71.join(relDir, entry.name);
20933
21044
  if (entry.isDirectory()) {
20934
- recurse(path70.join(dir, entry.name), childRel);
21045
+ recurse(path71.join(dir, entry.name), childRel);
20935
21046
  } else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
20936
- const c = readCard(path70.join(dir, entry.name), childRel);
21047
+ const c = readCard(path71.join(dir, entry.name), childRel);
20937
21048
  if (c) {
20938
21049
  c.parent = { id: root2.id, title: root2.title };
20939
21050
  subCards.push(c);
@@ -20954,12 +21065,12 @@ function readGroup2(folderName) {
20954
21065
  return { root: root2, subCards };
20955
21066
  }
20956
21067
  function standaloneCards(dirRel) {
20957
- const dir = dirRel ? path70.join(TODO, dirRel) : TODO;
20958
- if (!fs68.existsSync(dir)) return [];
21068
+ const dir = dirRel ? path71.join(TODO, dirRel) : TODO;
21069
+ if (!fs69.existsSync(dir)) return [];
20959
21070
  const cards = [];
20960
- for (const entry of fs68.readdirSync(dir, { withFileTypes: true })) {
21071
+ for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
20961
21072
  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));
21073
+ const c = readCard(path71.join(dir, entry.name), path71.join(dirRel, entry.name));
20963
21074
  if (c) cards.push(c);
20964
21075
  }
20965
21076
  }
@@ -20971,7 +21082,7 @@ function collectCards() {
20971
21082
  const top = standaloneCards("");
20972
21083
  board2.push(...top);
20973
21084
  every.push(...top);
20974
- for (const entry of fs68.readdirSync(TODO, { withFileTypes: true })) {
21085
+ for (const entry of fs69.readdirSync(TODO, { withFileTypes: true })) {
20975
21086
  if (!entry.isDirectory()) continue;
20976
21087
  if (isGroupFolder(entry.name)) {
20977
21088
  const g = readGroup2(entry.name);
@@ -21003,7 +21114,7 @@ function findCard(id) {
21003
21114
  }
21004
21115
  function attachSources(card) {
21005
21116
  try {
21006
- const { meta, body } = parseFrontmatter(fs68.readFileSync(path70.join(TODO, card.relPath), "utf8"));
21117
+ const { meta, body } = parseFrontmatter(fs69.readFileSync(path71.join(TODO, card.relPath), "utf8"));
21007
21118
  const sources2 = meta ? cardSources(meta, body) : [];
21008
21119
  if (sources2.length) card.sources = sources2;
21009
21120
  } catch {
@@ -21107,10 +21218,10 @@ var init_read = __esm({
21107
21218
  });
21108
21219
 
21109
21220
  // ../cli/src/lib/group-close.ts
21110
- import fs69 from "node:fs";
21221
+ import fs70 from "node:fs";
21111
21222
  function groupCloses(rootFile) {
21112
21223
  try {
21113
- return groupCloseOf(fs69.readFileSync(rootFile, "utf8"));
21224
+ return groupCloseOf(fs70.readFileSync(rootFile, "utf8"));
21114
21225
  } catch {
21115
21226
  return false;
21116
21227
  }
@@ -21123,12 +21234,12 @@ var init_group_close = __esm({
21123
21234
  });
21124
21235
 
21125
21236
  // ../cli/src/commands/remove.ts
21126
- import fs70 from "node:fs";
21127
- import path71 from "node:path";
21237
+ import fs71 from "node:fs";
21238
+ import path72 from "node:path";
21128
21239
  function leavingIds(id, found2) {
21129
21240
  const ids = /* @__PURE__ */ new Set([id]);
21130
21241
  if (found2.kind === "group") {
21131
- const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) => path71.basename(f));
21242
+ const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) => path72.basename(f));
21132
21243
  for (const name of names3) {
21133
21244
  const n = idPrefix(name);
21134
21245
  if (n !== null) ids.add(n);
@@ -21140,10 +21251,10 @@ function findMentions(ids) {
21140
21251
  const hits = [];
21141
21252
  const re = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
21142
21253
  for (const dir of [TODO, MEMORY]) {
21143
- if (!fs70.existsSync(dir)) continue;
21254
+ if (!fs71.existsSync(dir)) continue;
21144
21255
  for (const file of walkMd(dir)) {
21145
- if (path71.basename(file) === "README.md") continue;
21146
- const lines = fs70.readFileSync(file, "utf8").split("\n");
21256
+ if (path72.basename(file) === "README.md") continue;
21257
+ const lines = fs71.readFileSync(file, "utf8").split("\n");
21147
21258
  const fmEnd = frontmatterEnd(lines);
21148
21259
  lines.forEach((line, i) => {
21149
21260
  if (!re.test(line)) return;
@@ -21159,12 +21270,12 @@ function findMentions(ids) {
21159
21270
  return hits;
21160
21271
  }
21161
21272
  function leavingCards(id, found2) {
21162
- const own = found2.kind === "group" ? path71.join(found2.target, "root.md") : found2.target;
21273
+ const own = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
21163
21274
  const cards = [{ id, file: own }];
21164
21275
  if (found2.kind !== "group") return cards;
21165
21276
  for (const file of walkMd(found2.target)) {
21166
21277
  if (file === own) continue;
21167
- const n = idPrefix(path71.basename(file));
21278
+ const n = idPrefix(path72.basename(file));
21168
21279
  if (n !== null) cards.push({ id: n, file });
21169
21280
  }
21170
21281
  return cards;
@@ -21173,10 +21284,10 @@ function stampLeaving(cards, rejection) {
21173
21284
  const day = formatDay();
21174
21285
  const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
21175
21286
  for (const card of cards) {
21176
- if (!fs70.existsSync(card.file)) continue;
21177
- const text4 = fs70.readFileSync(card.file, "utf8");
21287
+ if (!fs71.existsSync(card.file)) continue;
21288
+ const text4 = fs71.readFileSync(card.file, "utf8");
21178
21289
  const stamped = stampLeavingIn(text4, day, stamp4);
21179
- if (stamped !== text4) fs70.writeFileSync(card.file, stamped);
21290
+ if (stamped !== text4) fs71.writeFileSync(card.file, stamped);
21180
21291
  }
21181
21292
  }
21182
21293
  function unfinishedDelivery(id) {
@@ -21192,7 +21303,7 @@ function unfinishedDelivery(id) {
21192
21303
  }[gap];
21193
21304
  return `#${id} is not finished: ${what}.`;
21194
21305
  }
21195
- const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs70.existsSync(path71.join(ASSETS, src.slice(".assets/".length))));
21306
+ const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs71.existsSync(path72.join(ASSETS, src.slice(".assets/".length))));
21196
21307
  return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
21197
21308
  }
21198
21309
  function agentDecisions(text4) {
@@ -21223,8 +21334,8 @@ function removeCard2(id, metric, options) {
21223
21334
  const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
21224
21335
  if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
21225
21336
  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") : "";
21337
+ const cardFile3 = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
21338
+ const cardText = fs71.existsSync(cardFile3) ? fs71.readFileSync(cardFile3, "utf8") : "";
21228
21339
  const { meta: cardMeta3 } = parseFrontmatter(cardText);
21229
21340
  const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f) => f !== cardFile3).map((f) => rel(f)).sort() : [];
21230
21341
  const leftIds = leavingIds(id, found2);
@@ -21255,10 +21366,10 @@ function removeCard2(id, metric, options) {
21255
21366
  const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
21256
21367
  if (dest) {
21257
21368
  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);
21369
+ fs71.mkdirSync(ARCHIVE, { recursive: true });
21370
+ fs71.renameSync(found2.target, dest);
21260
21371
  } else {
21261
- fs70.rmSync(found2.target, { recursive: true, force: true });
21372
+ fs71.rmSync(found2.target, { recursive: true, force: true });
21262
21373
  }
21263
21374
  const removedRefs = stripReadmeRefs(found2);
21264
21375
  let marked2 = null;
@@ -21307,14 +21418,14 @@ function removeCard2(id, metric, options) {
21307
21418
  };
21308
21419
  }
21309
21420
  function closeGroup(rootFile) {
21310
- const rootId = idPrefix(path71.basename(path71.dirname(rootFile)));
21421
+ const rootId = idPrefix(path72.basename(path72.dirname(rootFile)));
21311
21422
  if (rootId === null) return null;
21312
21423
  if (runnerProject(KANBAN)) return null;
21313
21424
  if (!groupCloses(rootFile)) return null;
21314
21425
  say(`
21315
21426
  every subtask line on #${rootId} is resolved \u2014 closing the group:`);
21316
21427
  try {
21317
- const { meta, body } = parseFrontmatter(fs70.readFileSync(rootFile, "utf8"));
21428
+ const { meta, body } = parseFrontmatter(fs71.readFileSync(rootFile, "utf8"));
21318
21429
  const res = cmdRemove(rootId, "completed", { closing: true });
21319
21430
  return {
21320
21431
  id: rootId,
@@ -21371,7 +21482,7 @@ function cleanupDiscardedCards(sessionId) {
21371
21482
  if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
21372
21483
  while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
21373
21484
  dropCrossRefs(card.id);
21374
- stripReadmeRefs({ kind: "file", rel: path71.relative(TODO, path71.resolve(REPO_ROOT, card.path)).split(path71.sep).join("/") });
21485
+ stripReadmeRefs({ kind: "file", rel: path72.relative(TODO, path72.resolve(REPO_ROOT, card.path)).split(path72.sep).join("/") });
21375
21486
  }
21376
21487
  return discarded.map((c) => c.id);
21377
21488
  });
@@ -21379,8 +21490,8 @@ function cleanupDiscardedCards(sessionId) {
21379
21490
  function recoveredArchiveHandoff(id, source) {
21380
21491
  const found2 = locateArchived(id);
21381
21492
  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"));
21493
+ const file = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
21494
+ const { meta } = parseFrontmatter(fs71.readFileSync(file, "utf8"));
21384
21495
  stripReadmeRefs(source ?? found2);
21385
21496
  const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
21386
21497
  if (root2) markSubtask(root2, id, "tick");
@@ -21456,6 +21567,30 @@ var init_agent_file = __esm({
21456
21567
  }
21457
21568
  });
21458
21569
 
21570
+ // ../cli/src/commands/studio-file.ts
21571
+ function cmdStudioFile(askedStudio, askedFile) {
21572
+ const studio = askedStudio.trim();
21573
+ const files = studioFiles(studio);
21574
+ if (!files) die(`no studio ${studio}`, { kind: "no-such-studio", studio });
21575
+ const file = askedFile.trim().replace(/^\.\//, "");
21576
+ const readable = Object.keys(files).filter((f) => f === STUDIO_FILE || f.startsWith("shared/") || f.startsWith("agents/")).sort();
21577
+ if (!readable.includes(file) || isAboutFile(file)) {
21578
+ die(`${studio} has no ${file}. It has: ${readable.join(", ")}.`, { kind: "no-such-studio-file", studio, file });
21579
+ }
21580
+ const text4 = files[file];
21581
+ say(text4);
21582
+ return { studio, file, text: text4 };
21583
+ }
21584
+ var init_studio_file2 = __esm({
21585
+ "../cli/src/commands/studio-file.ts"() {
21586
+ "use strict";
21587
+ init_io();
21588
+ init_paths();
21589
+ init_studio_shared();
21590
+ init_studio_files();
21591
+ }
21592
+ });
21593
+
21459
21594
  // ../cli/src/commands/memory-file.ts
21460
21595
  function cmdMemoryFile(askedName) {
21461
21596
  const name = askedName.trim();
@@ -21669,6 +21804,7 @@ var init_local2 = __esm({
21669
21804
  init_list();
21670
21805
  init_remove();
21671
21806
  init_agent_file();
21807
+ init_studio_file2();
21672
21808
  init_memory_file();
21673
21809
  init_validate2();
21674
21810
  init_io();
@@ -21687,10 +21823,11 @@ var init_local2 = __esm({
21687
21823
  archive: ({ args }) => cmdRemove(Number(args[0]), "completed"),
21688
21824
  reject: ({ args, opts }) => cmdRemove(Number(args[0]), "rejected", as(opts)),
21689
21825
  "agent-file": ({ args }) => cmdAgentFile(args[0] ?? "", args[1] ?? ""),
21826
+ file: ({ args }) => cmdStudioFile(args[0] ?? "", args[1] ?? ""),
21690
21827
  "memory-file": ({ args }) => cmdMemoryFile(args[0] ?? "")
21691
21828
  };
21692
21829
  BOARD_MOVES = new Set(Object.keys(MOVES));
21693
- READ_ONLY_MOVES = /* @__PURE__ */ new Set(["list", "validate", "agent-file", "memory-file"]);
21830
+ READ_ONLY_MOVES = /* @__PURE__ */ new Set(["list", "validate", "file", "agent-file", "memory-file"]);
21694
21831
  leases = /* @__PURE__ */ new Map();
21695
21832
  leaseCounter = 0;
21696
21833
  }
@@ -21741,8 +21878,8 @@ var init_created_cards = __esm({
21741
21878
 
21742
21879
  // ../cli/src/lib/agent/creation.ts
21743
21880
  import crypto4 from "node:crypto";
21744
- import fs71 from "node:fs";
21745
- import path72 from "node:path";
21881
+ import fs72 from "node:fs";
21882
+ import path73 from "node:path";
21746
21883
  function creationError(error, triage) {
21747
21884
  const zh = readLanguage() === "zh";
21748
21885
  const messages = {
@@ -21768,12 +21905,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
21768
21905
  function creationReceipt(request2, slot) {
21769
21906
  const hash2 = crypto4.createHash("sha256").update(`${request2}
21770
21907
  ${slot}`).digest("hex");
21771
- return path72.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21908
+ return path73.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21772
21909
  }
21773
21910
  function readCreation(file, said2) {
21774
21911
  return withCreationLock(() => {
21775
21912
  try {
21776
- const held4 = JSON.parse(fs71.readFileSync(file, "utf8"));
21913
+ const held4 = JSON.parse(fs72.readFileSync(file, "utf8"));
21777
21914
  if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
21778
21915
  return held4;
21779
21916
  } catch (error) {
@@ -21785,10 +21922,10 @@ function readCreation(file, said2) {
21785
21922
  });
21786
21923
  }
21787
21924
  function saveCreation(file, journal) {
21788
- fs71.mkdirSync(path72.dirname(file), { recursive: true });
21925
+ fs72.mkdirSync(path73.dirname(file), { recursive: true });
21789
21926
  const temp = `${file}.${crypto4.randomUUID()}.tmp`;
21790
- fs71.writeFileSync(temp, JSON.stringify(journal));
21791
- fs71.renameSync(temp, file);
21927
+ fs72.writeFileSync(temp, JSON.stringify(journal));
21928
+ fs72.renameSync(temp, file);
21792
21929
  }
21793
21930
  function archiveCreation(source, id) {
21794
21931
  if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
@@ -21802,7 +21939,7 @@ function archiveCreation(source, id) {
21802
21939
  function triageFile(sourceId) {
21803
21940
  const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
21804
21941
  if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
21805
- return path72.basename(found2.relPath, ".md");
21942
+ return path73.basename(found2.relPath, ".md");
21806
21943
  }
21807
21944
  var init_creation = __esm({
21808
21945
  "../cli/src/lib/agent/creation.ts"() {
@@ -21970,8 +22107,8 @@ __export(board_exports, {
21970
22107
  buildBoardProgram: () => buildBoardProgram
21971
22108
  });
21972
22109
  import crypto5 from "node:crypto";
21973
- import fs72 from "node:fs";
21974
- import path73 from "node:path";
22110
+ import fs73 from "node:fs";
22111
+ import path74 from "node:path";
21975
22112
  async function dispatch(move, cmd, args, opts, cli) {
21976
22113
  const ctx = ctxOf(cmd, cli.program);
21977
22114
  const data = await runAction(ctx, {}, async () => {
@@ -22011,7 +22148,7 @@ async function cloudCard(task, opts) {
22011
22148
  let request2;
22012
22149
  if (typeof opts.bodyFile === "string") {
22013
22150
  try {
22014
- request2 = fs72.readFileSync(opts.bodyFile, "utf8");
22151
+ request2 = fs73.readFileSync(opts.bodyFile, "utf8");
22015
22152
  } catch {
22016
22153
  }
22017
22154
  }
@@ -22041,7 +22178,7 @@ async function cloudCard(task, opts) {
22041
22178
  const file = creationReceipt(`${checked.value}:${requestId}`, slot);
22042
22179
  const journal = readCreation(file, said2);
22043
22180
  if (!journal.made) {
22044
- const key = `akb-${path73.basename(file, ".json").slice(0, 40)}`;
22181
+ const key = `akb-${path74.basename(file, ".json").slice(0, 40)}`;
22045
22182
  const made = await createProjectTask(checked.value, journal.said, key);
22046
22183
  if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
22047
22184
  journal.made = made.value;
@@ -22091,9 +22228,10 @@ function buildBoardProgram(cli) {
22091
22228
  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
22229
  await dispatch("validate", this, id === void 0 ? [] : [String(id)], this.opts(), cli);
22093
22230
  });
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) {
22231
+ 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) {
22232
+ await dispatch("file", this, [studio, file], this.opts(), cli);
22233
+ });
22234
+ withShared(program2.command("agent-file", { hidden: true })).argument("<agent>").argument("<path>").action(async function(agent, file) {
22097
22235
  await dispatch("agent-file", this, [agent, file], this.opts(), cli);
22098
22236
  });
22099
22237
  move("memory-file").argument("<name>", "the global memory").summary("print one global memory's rules, its MEMORY.md").description(
@@ -22169,17 +22307,17 @@ var init_board2 = __esm({
22169
22307
  });
22170
22308
 
22171
22309
  // ../cli/src/lib/board-cli.ts
22172
- import fs73 from "node:fs";
22173
- import path74 from "node:path";
22310
+ import fs74 from "node:fs";
22311
+ import path75 from "node:path";
22174
22312
  function useBoard(found2, dirNamed) {
22175
- if (!found2.named && found2.board === path74.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
22313
+ if (!found2.named && found2.board === path75.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
22176
22314
  else setBoardDir(found2.board, found2.root);
22177
22315
  useProjectState();
22178
22316
  backfillCardStudios();
22179
22317
  }
22180
22318
  function whole(found2, move) {
22181
22319
  if (move === MAKES_A_BOARD) return found2;
22182
- if (!fs73.existsSync(path74.join(found2.board, "todo"))) {
22320
+ if (!fs74.existsSync(path75.join(found2.board, "todo"))) {
22183
22321
  die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
22184
22322
  kind: "board-incomplete",
22185
22323
  dir: found2.root
@@ -22188,13 +22326,13 @@ function whole(found2, move) {
22188
22326
  return found2;
22189
22327
  }
22190
22328
  function findBoardUpward(from, move) {
22191
- let dir = path74.resolve(from);
22329
+ let dir = path75.resolve(from);
22192
22330
  for (; ; ) {
22193
- if (hasBoard(dir)) return { root: dir, board: path74.join(dir, "docs", "kanban") };
22331
+ if (hasBoard(dir)) return { root: dir, board: path75.join(dir, "docs", "kanban") };
22194
22332
  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);
22333
+ const kept2 = path75.join(dir, ".akb", "kanban");
22334
+ if (move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return { root: dir, board: kept2 };
22335
+ const up = path75.dirname(dir);
22198
22336
  if (up === dir) return null;
22199
22337
  dir = up;
22200
22338
  }
@@ -22202,11 +22340,11 @@ function findBoardUpward(from, move) {
22202
22340
  function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
22203
22341
  const named2 = board2 ?? boardFromEnv();
22204
22342
  if (named2) {
22205
- const folder = path74.resolve(cwd, named2);
22206
- if (!fs73.existsSync(folder) && move !== MAKES_A_BOARD) {
22343
+ const folder = path75.resolve(cwd, named2);
22344
+ if (!fs74.existsSync(folder) && move !== MAKES_A_BOARD) {
22207
22345
  die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
22208
22346
  }
22209
- if (fs73.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
22347
+ if (fs74.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
22210
22348
  die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
22211
22349
  kind: "no-board",
22212
22350
  dir: folder
@@ -22215,24 +22353,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
22215
22353
  return { root: projectRootOf(folder), board: folder, named: true };
22216
22354
  }
22217
22355
  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);
22356
+ const root2 = path75.resolve(dir);
22357
+ if (!fs74.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
22358
+ const kept2 = path75.join(root2, ".akb", "kanban");
22359
+ if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
22222
22360
  if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
22223
22361
  die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
22224
22362
  kind: "no-board",
22225
22363
  dir: root2
22226
22364
  });
22227
22365
  }
22228
- return whole({ root: root2, board: path74.join(root2, "docs", "kanban") }, move);
22366
+ return whole({ root: root2, board: path75.join(root2, "docs", "kanban") }, move);
22229
22367
  }
22230
22368
  const found2 = findBoardUpward(cwd, move);
22231
22369
  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") };
22370
+ if (move === MAKES_A_BOARD) return { root: path75.resolve(cwd), board: path75.join(path75.resolve(cwd), "docs", "kanban") };
22233
22371
  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) }
22372
+ `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`,
22373
+ { kind: "no-board", dir: path75.resolve(cwd) }
22236
22374
  );
22237
22375
  }
22238
22376
  function editDistance(a, b) {
@@ -22315,8 +22453,8 @@ var init_board_cli = __esm({
22315
22453
  init_pointer();
22316
22454
  init_card_studio_backfill();
22317
22455
  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"));
22456
+ hasBoard = (dir) => fs74.existsSync(path75.join(dir, "docs", "kanban"));
22457
+ isBoardDir = (dir) => fs74.existsSync(path75.join(dir, "todo")) && fs74.existsSync(path75.join(dir, "config.md"));
22320
22458
  boardFromEnv = () => {
22321
22459
  const named2 = process.env.AI4KANBAN_BOARD?.trim();
22322
22460
  return named2 ? named2 : null;
@@ -22576,8 +22714,8 @@ var init_agent = __esm({
22576
22714
 
22577
22715
  // ../cli/src/commands/cloud-template.ts
22578
22716
  import { createHash as createHash5 } from "node:crypto";
22579
- import fs74 from "node:fs";
22580
- import path75 from "node:path";
22717
+ import fs75 from "node:fs";
22718
+ import path76 from "node:path";
22581
22719
  function usage2(problem, line) {
22582
22720
  die(`${problem}
22583
22721
  usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
@@ -22654,10 +22792,10 @@ This template has no preview.`);
22654
22792
  const written = [];
22655
22793
  for (const p of previews) {
22656
22794
  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);
22795
+ const file = path76.basename(p.path);
22796
+ const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
22797
+ fs75.mkdirSync(opts.to, { recursive: true });
22798
+ fs75.writeFileSync(out, bytes2);
22661
22799
  written.push(out);
22662
22800
  say(out);
22663
22801
  }
@@ -22670,15 +22808,15 @@ async function templateGet(name, opts, program2) {
22670
22808
  const { template } = await asJson(await ask(`/${at}`, {}, WITHOUT));
22671
22809
  const fetched = [];
22672
22810
  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);
22811
+ const out = path76.resolve(to, f.path);
22812
+ if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse3(T.corrupt, WITHOUT);
22675
22813
  const bytes2 = Buffer.from(await (await ask(`/${at}/files/${route(f.path)}`, {}, WITHOUT)).arrayBuffer());
22676
22814
  if (bytes2.byteLength !== f.size || createHash5("sha256").update(bytes2).digest("hex") !== f.sha256) {
22677
22815
  refuse3(T.corrupt, WITHOUT);
22678
22816
  }
22679
22817
  fetched.push({ out, bytes: bytes2 });
22680
22818
  }
22681
- const taken = fetched.filter((f) => fs74.existsSync(f.out)).map((f) => path75.relative(to, f.out));
22819
+ const taken = fetched.filter((f) => fs75.existsSync(f.out)).map((f) => path76.relative(to, f.out));
22682
22820
  if (taken.length > 0) {
22683
22821
  refuse3({
22684
22822
  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 +22824,8 @@ async function templateGet(name, opts, program2) {
22686
22824
  });
22687
22825
  }
22688
22826
  for (const f of fetched) {
22689
- fs74.mkdirSync(path75.dirname(f.out), { recursive: true });
22690
- fs74.writeFileSync(f.out, f.bytes);
22827
+ fs75.mkdirSync(path76.dirname(f.out), { recursive: true });
22828
+ fs75.writeFileSync(f.out, f.bytes);
22691
22829
  }
22692
22830
  say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
22693
22831
  Fetched ${name}: ${fetched.length} files into ${to}`);
@@ -22704,25 +22842,25 @@ async function templateSource(name, opts) {
22704
22842
  say(`evidence: ${e.path}`);
22705
22843
  continue;
22706
22844
  }
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()));
22845
+ const out = path76.join(opts.to, `${name}-${path76.basename(e.path)}`);
22846
+ fs75.mkdirSync(opts.to, { recursive: true });
22847
+ fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
22710
22848
  written.push(out);
22711
22849
  say(out);
22712
22850
  }
22713
22851
  return { name, source, evidence: written.length > 0 ? written : evidence.map((e) => e.path) };
22714
22852
  }
22715
22853
  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"));
22854
+ const root2 = path76.resolve(dir);
22855
+ const manifest = path76.join(root2, "template.md");
22856
+ 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.");
22857
+ const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
22720
22858
  const files = walk2(root2);
22721
- const total = files.reduce((sum, f) => sum + fs74.statSync(path75.join(root2, f)).size, 0);
22859
+ const total = files.reduce((sum, f) => sum + fs75.statSync(path76.join(root2, f)).size, 0);
22722
22860
  if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
22723
22861
  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)) {
22862
+ if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
22863
+ if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
22726
22864
  invalid(
22727
22865
  `${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
22866
  `${extra} is inside the template folder; keep previews and evidence outside it.`
@@ -22734,10 +22872,10 @@ async function templatePublish(dir, opts) {
22734
22872
  }
22735
22873
  const form = new FormData();
22736
22874
  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);
22875
+ const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
22876
+ for (const f of files) add("files", f, path76.join(root2, f));
22877
+ for (const f of opts.preview) add("previews", path76.basename(f), f);
22878
+ for (const f of opts.evidence) add("evidence", path76.basename(f), f);
22741
22879
  const done2 = await asJson(await ask("", { method: "POST", body: form }));
22742
22880
  say(
22743
22881
  done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
@@ -22753,11 +22891,11 @@ Deleted ${name} from the catalog.`);
22753
22891
  return { name, deleted: true };
22754
22892
  }
22755
22893
  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}.`);
22894
+ const file = path76.join(dir, "showcase.json");
22895
+ if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
22758
22896
  let meta;
22759
22897
  try {
22760
- meta = JSON.parse(fs74.readFileSync(file, "utf8"));
22898
+ meta = JSON.parse(fs75.readFileSync(file, "utf8"));
22761
22899
  } catch {
22762
22900
  return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
22763
22901
  }
@@ -22769,9 +22907,9 @@ async function templateShowcase(name, dir) {
22769
22907
  const form = new FormData();
22770
22908
  form.set("meta", JSON.stringify(meta));
22771
22909
  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);
22910
+ const at = path76.join(dir, p);
22911
+ if (!fs75.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
22912
+ form.append(`media:${p}`, new Blob([fs75.readFileSync(at)]), p);
22775
22913
  }
22776
22914
  const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
22777
22915
  say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
@@ -22780,7 +22918,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
22780
22918
  }
22781
22919
  function walk2(root2, sub = "") {
22782
22920
  const out = [];
22783
- for (const entry of fs74.readdirSync(path75.join(root2, sub), { withFileTypes: true })) {
22921
+ for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
22784
22922
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
22785
22923
  const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
22786
22924
  if (entry.isDirectory()) out.push(...walk2(root2, rel2));
@@ -22981,7 +23119,7 @@ var init_card_chat = __esm({
22981
23119
  var update_studio_default;
22982
23120
  var init_update_studio = __esm({
22983
23121
  "../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";
23122
+ 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
23123
  }
22986
23124
  });
22987
23125
 
@@ -23037,7 +23175,7 @@ var init_prune_memory = __esm({
23037
23175
  var review_memory_default;
23038
23176
  var init_review_memory = __esm({
23039
23177
  "../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";
23178
+ 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
23179
  }
23042
23180
  });
23043
23181
 
@@ -23085,7 +23223,7 @@ var init_revise = __esm({
23085
23223
  var preview_agent_default;
23086
23224
  var init_preview_agent = __esm({
23087
23225
  "../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';
23226
+ 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
23227
  }
23090
23228
  });
23091
23229
 
@@ -23109,7 +23247,7 @@ var init_troubleshoot = __esm({
23109
23247
  var write_agent_default;
23110
23248
  var init_write_agent = __esm({
23111
23249
  "../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";
23250
+ 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
23251
  }
23114
23252
  });
23115
23253
 
@@ -23125,7 +23263,7 @@ var init_write_prompt = __esm({
23125
23263
  var writing_default;
23126
23264
  var init_writing = __esm({
23127
23265
  "../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";
23266
+ 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
23267
  }
23130
23268
  });
23131
23269
 
@@ -23242,8 +23380,8 @@ var init_guide2 = __esm({
23242
23380
  });
23243
23381
 
23244
23382
  // ../cli/src/commands/studio.ts
23245
- import fs75 from "node:fs";
23246
- import path76 from "node:path";
23383
+ import fs76 from "node:fs";
23384
+ import path77 from "node:path";
23247
23385
  function cmdStudioList() {
23248
23386
  if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
23249
23387
  const offline2 = studiosOffline();
@@ -23284,17 +23422,17 @@ function cmdStudioDiagram(id, card) {
23284
23422
  const agent = findSpecAgent(name);
23285
23423
  return agent ? { ...agent, after: agentAfter(name) } : null;
23286
23424
  });
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)}
23425
+ const file = path77.join(ASSETS, String(cardId2), "studio.json");
23426
+ fs76.mkdirSync(path77.dirname(file), { recursive: true });
23427
+ fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
23290
23428
  `);
23291
23429
  const tag = `<Studio src=".assets/${cardId2}/studio.json" label="${flow.name.replace(/"/g, "")}" />`;
23292
23430
  say(tag);
23293
23431
  return { file, tag, diagram };
23294
23432
  }
23295
23433
  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");
23434
+ const dir = path77.resolve(folder);
23435
+ if (!fs76.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
23298
23436
  const files = readStudioFolder(dir);
23299
23437
  const read3 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
23300
23438
  const def = "def" in read3 ? read3.def : null;
@@ -23315,26 +23453,26 @@ function cmdStudioValidate(folder) {
23315
23453
  async function cmdStudioPull(id, folder) {
23316
23454
  const cloudId = cloudIdOf(id);
23317
23455
  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");
23456
+ const dir = path77.resolve(folder ?? id);
23457
+ if (fs76.existsSync(dir) && fs76.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
23320
23458
  const read3 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
23321
23459
  if (!read3.ok) die(read3.error, read3.code === "not_found" ? "no-such-studio" : "cloud-refused");
23322
23460
  const { version, files } = read3.value;
23323
23461
  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 });
23462
+ const full = path77.join(dir, ...file.split("/"));
23463
+ fs76.mkdirSync(path77.dirname(full), { recursive: true });
23326
23464
  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);
23465
+ fs76.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
23328
23466
  }
23329
23467
  const shown = folder ?? `./${id}`;
23330
23468
  say(`Pulled ${id} v${version} into ${shown}.`);
23331
23469
  return { id, version, folder: dir };
23332
23470
  }
23333
23471
  async function cmdStudioPush(folder, opts) {
23334
- const dir = path76.resolve(folder);
23472
+ const dir = path77.resolve(folder);
23335
23473
  let pulled = null;
23336
23474
  try {
23337
- pulled = JSON.parse(fs75.readFileSync(path76.join(dir, VERSION_FILE), "utf8"));
23475
+ pulled = JSON.parse(fs76.readFileSync(path77.join(dir, VERSION_FILE), "utf8"));
23338
23476
  } catch {
23339
23477
  }
23340
23478
  if (!pulled?.id || !Number.isInteger(pulled.version)) die(`${folder} was not written by \`akb studio pull\``, "bad-args");
@@ -23364,7 +23502,7 @@ async function cmdStudioPush(folder, opts) {
23364
23502
  die(res.error, res.code === "bad_request" || res.code === "payload_too_large" ? "bad-studio" : "cloud-refused");
23365
23503
  }
23366
23504
  const next = res.value.version;
23367
- fs75.writeFileSync(path76.join(dir, VERSION_FILE), versionText(cloudId, next));
23505
+ fs76.writeFileSync(path77.join(dir, VERSION_FILE), versionText(cloudId, next));
23368
23506
  say(`Pushed ${id} v${next}. New tasks take it.`);
23369
23507
  return { id, version: next, changed: true };
23370
23508
  }
@@ -23372,7 +23510,7 @@ function noteText({ file, text: text4 }) {
23372
23510
  if (file !== void 0 && text4 !== void 0) die("pass --file or --text, not both", "bad-args");
23373
23511
  if (file !== void 0) {
23374
23512
  try {
23375
- return fs75.readFileSync(file, "utf8").trim();
23513
+ return fs76.readFileSync(file, "utf8").trim();
23376
23514
  } catch {
23377
23515
  die(`can't read ${file}`, "bad-args");
23378
23516
  }
@@ -23597,8 +23735,8 @@ var init_complete = __esm({
23597
23735
  });
23598
23736
 
23599
23737
  // ../cli/src/lib/agent/approve.ts
23600
- import fs76 from "node:fs";
23601
- import path77 from "node:path";
23738
+ import fs77 from "node:fs";
23739
+ import path78 from "node:path";
23602
23740
  function approvalRequest(req) {
23603
23741
  const id = req.id;
23604
23742
  const card = id === void 0 ? null : findCard(id);
@@ -23616,12 +23754,12 @@ function advancePhase(id) {
23616
23754
  const card = findCard(id);
23617
23755
  const found2 = locate(id);
23618
23756
  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"));
23757
+ const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
23758
+ const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
23621
23759
  if (!meta) return { error: `#${id} has no frontmatter` };
23622
23760
  meta.phase = card.stage + 1;
23623
23761
  meta.status = "todo";
23624
- fs76.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
23762
+ fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
23625
23763
  return null;
23626
23764
  }
23627
23765
  var init_approve = __esm({
@@ -23744,16 +23882,16 @@ var init_start = __esm({
23744
23882
  });
23745
23883
 
23746
23884
  // ../cli/src/lib/agent/task-chats.ts
23747
- import fs77 from "node:fs";
23748
- import path78 from "node:path";
23885
+ import fs78 from "node:fs";
23886
+ import path79 from "node:path";
23749
23887
  function taskChatFile(task, home3) {
23750
23888
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
23751
- return path78.join(taskChatsDir(home3), `${task}.jsonl`);
23889
+ return path79.join(taskChatsDir(home3), `${task}.jsonl`);
23752
23890
  }
23753
23891
  function readTaskChat(task, home3) {
23754
23892
  let text4;
23755
23893
  try {
23756
- text4 = fs77.readFileSync(taskChatFile(task, home3), "utf8");
23894
+ text4 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
23757
23895
  } catch {
23758
23896
  return [];
23759
23897
  }
@@ -23774,13 +23912,13 @@ var init_task_chats = __esm({
23774
23912
  "use strict";
23775
23913
  init_home();
23776
23914
  TASK = /^[\w-]{1,100}$/;
23777
- taskChatsDir = (home3 = machineHome()) => path78.join(home3, "chats");
23915
+ taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
23778
23916
  }
23779
23917
  });
23780
23918
 
23781
23919
  // ../cli/src/lib/agent/memory-review.ts
23782
- import fs78 from "node:fs";
23783
- import path79 from "node:path";
23920
+ import fs79 from "node:fs";
23921
+ import path80 from "node:path";
23784
23922
  function taskChatsToReview(tasks) {
23785
23923
  const out = [];
23786
23924
  for (const ref of [...new Set(tasks)]) {
@@ -23802,8 +23940,8 @@ function readArchived2(id) {
23802
23940
  const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
23803
23941
  if (!found2) return null;
23804
23942
  try {
23805
- const file = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
23806
- const { meta, body } = parseFrontmatter(fs78.readFileSync(file, "utf8"));
23943
+ const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
23944
+ const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
23807
23945
  if (!meta) return null;
23808
23946
  return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
23809
23947
  } catch {
@@ -23872,17 +24010,17 @@ var init_memory_review = __esm({
23872
24010
  });
23873
24011
 
23874
24012
  // ../cli/src/lib/agent/dismissal-review.ts
23875
- import fs79 from "node:fs";
23876
- import path80 from "node:path";
24013
+ import fs80 from "node:fs";
24014
+ import path81 from "node:path";
23877
24015
  function rejectionsToReview() {
23878
- const dir = path80.join(ARCHIVE, REJECTIONS_TO_REVIEW);
23879
- if (!fs79.existsSync(dir)) return [];
24016
+ const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
24017
+ if (!fs80.existsSync(dir)) return [];
23880
24018
  const found2 = [];
23881
24019
  for (const file of walkMd(dir)) {
23882
24020
  const id = archivedId(file);
23883
24021
  if (id === null) continue;
23884
24022
  try {
23885
- const { meta } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
24023
+ const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
23886
24024
  if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
23887
24025
  found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
23888
24026
  } catch {
@@ -23912,7 +24050,7 @@ function citedSources(text4) {
23912
24050
  function withdrawnSources() {
23913
24051
  const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
23914
24052
  try {
23915
- return citedSources(fs79.readFileSync(file, "utf8"));
24053
+ return citedSources(fs80.readFileSync(file, "utf8"));
23916
24054
  } catch {
23917
24055
  return [];
23918
24056
  }
@@ -23937,8 +24075,8 @@ var init_dismissal_review = __esm({
23937
24075
  });
23938
24076
 
23939
24077
  // ../cli/src/lib/agent/flow.ts
23940
- import fs80 from "node:fs";
23941
- import path81 from "node:path";
24078
+ import fs81 from "node:fs";
24079
+ import path82 from "node:path";
23942
24080
  function readCard2(id, home3 = "board") {
23943
24081
  const pending = activeDelivery(id)?.completions?.some((c) => !c.finished);
23944
24082
  const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
@@ -23948,10 +24086,10 @@ function readCard2(id, home3 = "board") {
23948
24086
  { kind: "card-not-found", id }
23949
24087
  );
23950
24088
  }
23951
- const file = found2.kind === "group" ? path81.join(found2.target, "root.md") : found2.target;
24089
+ const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
23952
24090
  let text4;
23953
24091
  try {
23954
- text4 = fs80.readFileSync(file, "utf8");
24092
+ text4 = fs81.readFileSync(file, "utf8");
23955
24093
  } catch {
23956
24094
  die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
23957
24095
  }
@@ -24767,7 +24905,7 @@ __export(watch_exports, {
24767
24905
  watchRun: () => watchRun
24768
24906
  });
24769
24907
  import { spawn as spawn3 } from "node:child_process";
24770
- import fs81 from "node:fs";
24908
+ import fs82 from "node:fs";
24771
24909
  async function watchRun(sessionId, resume = startResume) {
24772
24910
  const spec = readSpec(sessionId);
24773
24911
  const run2 = peekRun(sessionId);
@@ -24803,11 +24941,11 @@ async function watchRun(sessionId, resume = startResume) {
24803
24941
  const record = claimed ?? run2;
24804
24942
  const sub = record.action === "sub";
24805
24943
  if (claim) await setCardStatus(claim.cardId, claim.status);
24806
- fs81.mkdirSync(SESSIONS_DIR, { recursive: true });
24807
- const logFile = fs81.createWriteStream(record.logPath, { flags: "a" });
24944
+ fs82.mkdirSync(SESSIONS_DIR, { recursive: true });
24945
+ const logFile = fs82.createWriteStream(record.logPath, { flags: "a" });
24808
24946
  logFile.on("error", () => {
24809
24947
  });
24810
- const eventsFile = fs81.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
24948
+ const eventsFile = fs82.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
24811
24949
  eventsFile.on("error", () => {
24812
24950
  });
24813
24951
  const event2 = (e) => eventsFile.write(`${JSON.stringify(e)}
@@ -25377,8 +25515,8 @@ var init_watch = __esm({
25377
25515
  });
25378
25516
 
25379
25517
  // ../cli/src/commands/run.ts
25380
- import fs82 from "node:fs";
25381
- import path82 from "node:path";
25518
+ import fs83 from "node:fs";
25519
+ import path83 from "node:path";
25382
25520
  async function cmdStartRun(action, args, opts, program2 = "akb") {
25383
25521
  const { req, follow: follow2, print } = readRequest(action, args, opts);
25384
25522
  if (Number.isInteger(req.id)) {
@@ -25594,7 +25732,7 @@ async function cmdSubStart(words, opts) {
25594
25732
  let prompt = words.join(" ");
25595
25733
  if (opts.file) {
25596
25734
  try {
25597
- prompt = fs82.readFileSync(path82.resolve(opts.file), "utf8");
25735
+ prompt = fs83.readFileSync(path83.resolve(opts.file), "utf8");
25598
25736
  } catch {
25599
25737
  die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
25600
25738
  }
@@ -25961,7 +26099,7 @@ var init_signals = __esm({
25961
26099
  });
25962
26100
 
25963
26101
  // ../cli/src/commands/triage.ts
25964
- import fs83 from "node:fs";
26102
+ import fs84 from "node:fs";
25965
26103
  async function cmdTriageAdd(opts) {
25966
26104
  const title = (opts.title ?? "").trim();
25967
26105
  if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
@@ -25971,7 +26109,7 @@ async function cmdTriageAdd(opts) {
25971
26109
  let body = opts.text;
25972
26110
  if (opts.file !== void 0) {
25973
26111
  try {
25974
- body = fs83.readFileSync(opts.file, "utf8");
26112
+ body = fs84.readFileSync(opts.file, "utf8");
25975
26113
  } catch {
25976
26114
  die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
25977
26115
  }
@@ -26642,15 +26780,15 @@ var init_agent2 = __esm({
26642
26780
  });
26643
26781
 
26644
26782
  // ../cli/src/kanban.ts
26645
- import fs86 from "node:fs";
26783
+ import fs87 from "node:fs";
26646
26784
  import { fileURLToPath as fileURLToPath4 } from "node:url";
26647
26785
 
26648
26786
  // ../cli/src/lib/cli/akb.ts
26649
26787
  init_agent2();
26650
26788
 
26651
26789
  // ../cli/src/lib/cli/setup.ts
26652
- import fs85 from "node:fs";
26653
- import path84 from "node:path";
26790
+ import fs86 from "node:fs";
26791
+ import path85 from "node:path";
26654
26792
  import { fileURLToPath as fileURLToPath3 } from "node:url";
26655
26793
 
26656
26794
  // ../cli/src/commands/update.ts
@@ -26664,8 +26802,8 @@ init_paths();
26664
26802
  init_memory();
26665
26803
  init_yaml2();
26666
26804
  init_version();
26667
- import fs84 from "node:fs";
26668
- import path83 from "node:path";
26805
+ import fs85 from "node:fs";
26806
+ import path84 from "node:path";
26669
26807
  import { spawnSync as spawnSync6 } from "node:child_process";
26670
26808
  var NAME = "wildcrane";
26671
26809
  var REPO = "https://github.com/wildcrane-ai/wildcrane";
@@ -26687,10 +26825,10 @@ var Report = class {
26687
26825
  for (const line of this.notes) say(` ! ${line}`);
26688
26826
  }
26689
26827
  };
26690
- var read2 = (file) => fs84.existsSync(file) ? fs84.readFileSync(file, "utf8") : null;
26828
+ var read2 = (file) => fs85.existsSync(file) ? fs85.readFileSync(file, "utf8") : null;
26691
26829
  function statOf(p) {
26692
26830
  try {
26693
- return fs84.lstatSync(p);
26831
+ return fs85.lstatSync(p);
26694
26832
  } catch {
26695
26833
  return null;
26696
26834
  }
@@ -26715,10 +26853,10 @@ async function cmdUpdate2(ctx) {
26715
26853
  return { updated: ctx.dir, from, to: SKILL_VERSION };
26716
26854
  }
26717
26855
  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)) {
26856
+ const legacy2 = path84.join(root2, "docs", "kanban");
26857
+ const kept2 = path84.join(root2, ".akb", "kanban");
26858
+ const board2 = named2 ?? (fs85.existsSync(legacy2) ? legacy2 : kept2);
26859
+ if (!fs85.existsSync(board2)) {
26722
26860
  report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
26723
26861
  return false;
26724
26862
  }
@@ -26749,20 +26887,20 @@ function moveRuntimes(root2, board2, report3) {
26749
26887
  }
26750
26888
  }
26751
26889
  function moveLegacyMemory(board2, report3) {
26752
- const memory = path83.join(board2, "memory");
26890
+ const memory = path84.join(board2, "memory");
26753
26891
  const moved = [];
26754
26892
  for (const name of MEMORY_FILES) {
26755
- const from = path83.join(board2, name);
26893
+ const from = path84.join(board2, name);
26756
26894
  const st = statOf(from);
26757
26895
  if (!st || !st.isFile()) continue;
26758
- fs84.mkdirSync(memory, { recursive: true });
26759
- const to = path83.join(memory, name);
26896
+ fs85.mkdirSync(memory, { recursive: true });
26897
+ const to = path84.join(memory, name);
26760
26898
  const there = read2(to);
26761
26899
  if (there === null) {
26762
- fs84.renameSync(from, to);
26900
+ fs85.renameSync(from, to);
26763
26901
  moved.push(name);
26764
26902
  } else if (there === read2(from)) {
26765
- fs84.rmSync(from);
26903
+ fs85.rmSync(from);
26766
26904
  moved.push(name);
26767
26905
  } else {
26768
26906
  report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
@@ -26771,23 +26909,23 @@ function moveLegacyMemory(board2, report3) {
26771
26909
  if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
26772
26910
  }
26773
26911
  function dropRecordFile(board2) {
26774
- const file = path83.join(board2, "record.csv");
26775
- if (!fs84.existsSync(file)) return null;
26776
- fs84.rmSync(file);
26912
+ const file = path84.join(board2, "record.csv");
26913
+ if (!fs85.existsSync(file)) return null;
26914
+ fs85.rmSync(file);
26777
26915
  return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
26778
26916
  }
26779
26917
  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"));
26918
+ const memory = path84.join(board2, "memory");
26919
+ if (!fs85.existsSync(memory)) return;
26920
+ const root2 = read2(path84.join(memory, "goal.md"));
26783
26921
  let dropped = 0;
26784
- for (const entry of fs84.readdirSync(memory, { withFileTypes: true })) {
26922
+ for (const entry of fs85.readdirSync(memory, { withFileTypes: true })) {
26785
26923
  if (!entry.isDirectory()) continue;
26786
- const file = path83.join(memory, entry.name, "goal.md");
26924
+ const file = path84.join(memory, entry.name, "goal.md");
26787
26925
  const text4 = read2(file);
26788
26926
  if (text4 === null) continue;
26789
26927
  if (text4 === root2 || text4.includes(UNFILLED) || !goalWords(text4)) {
26790
- fs84.rmSync(file);
26928
+ fs85.rmSync(file);
26791
26929
  dropped++;
26792
26930
  } else {
26793
26931
  report3.notes.push(
@@ -26809,10 +26947,10 @@ var PLAN_LEADS = {
26809
26947
  var GONE_LEADS = ["software-planner", "planner"];
26810
26948
  function planLeads(board2) {
26811
26949
  const leads = { ...PLAN_LEADS };
26812
- const root2 = path83.join(board2, "studios");
26813
- for (const entry of fs84.existsSync(root2) ? fs84.readdirSync(root2, { withFileTypes: true }) : []) {
26950
+ const root2 = path84.join(board2, "studios");
26951
+ for (const entry of fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []) {
26814
26952
  if (!entry.isDirectory()) continue;
26815
- const meta = splitFrontmatter(read2(path83.join(root2, entry.name, "STUDIO.md")) ?? "").meta;
26953
+ const meta = splitFrontmatter(read2(path84.join(root2, entry.name, "STUDIO.md")) ?? "").meta;
26816
26954
  const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
26817
26955
  const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
26818
26956
  const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
@@ -26821,30 +26959,30 @@ function planLeads(board2) {
26821
26959
  return leads;
26822
26960
  }
26823
26961
  function movePlanRules(board2, report3) {
26824
- const rules = path83.join(board2, "rules");
26962
+ const rules = path84.join(board2, "rules");
26825
26963
  const moved = [];
26826
26964
  for (const [id, leads] of Object.entries(planLeads(board2))) {
26827
26965
  for (const lead of leads) {
26828
- const from = path83.join(rules, `${lead}.md`);
26966
+ const from = path84.join(rules, `${lead}.md`);
26829
26967
  const rule = read2(from)?.trim();
26830
26968
  if (!rule) continue;
26831
- const to = path83.join(rules, "studios", `${id}.md`);
26969
+ const to = path84.join(rules, "studios", `${id}.md`);
26832
26970
  const there = read2(to)?.trim() ?? "";
26833
26971
  if (!there.includes(rule)) {
26834
- fs84.mkdirSync(path83.dirname(to), { recursive: true });
26835
- fs84.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
26972
+ fs85.mkdirSync(path84.dirname(to), { recursive: true });
26973
+ fs85.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
26836
26974
  `);
26837
26975
  moved.push(`${lead} \u2192 ${id}`);
26838
26976
  }
26839
26977
  }
26840
26978
  }
26841
- for (const lead of GONE_LEADS) fs84.rmSync(path83.join(rules, `${lead}.md`), { force: true });
26979
+ for (const lead of GONE_LEADS) fs85.rmSync(path84.join(rules, `${lead}.md`), { force: true });
26842
26980
  if (moved.length) report3.did.push(`made each plan agent's rule its studio's card rule (docs/kanban/rules/studios/): ${moved.join(", ")}`);
26843
26981
  }
26844
26982
  function noteOldStudios(board2, report3) {
26845
26983
  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}`);
26984
+ const root2 = path84.join(board2, dir);
26985
+ 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
26986
  };
26849
26987
  const files = [...old("studios", "STUDIO.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
26850
26988
  if (files.length) {
@@ -26854,7 +26992,7 @@ function noteOldStudios(board2, report3) {
26854
26992
  }
26855
26993
  }
26856
26994
  function checkConfig(board2, report3) {
26857
- const current = read2(path83.join(board2, "config.md"));
26995
+ const current = read2(path84.join(board2, "config.md"));
26858
26996
  if (!current) return;
26859
26997
  const added = missingConfigKeys(current);
26860
26998
  if (added.length) {
@@ -26864,7 +27002,7 @@ function checkConfig(board2, report3) {
26864
27002
  }
26865
27003
  }
26866
27004
  function checkModules(board2, report3) {
26867
- const map2 = read2(path83.join(board2, "modules.md"));
27005
+ const map2 = read2(path84.join(board2, "modules.md"));
26868
27006
  if (map2 && map2.includes(UNFILLED)) {
26869
27007
  report3.notes.push(
26870
27008
  "docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
@@ -26918,14 +27056,14 @@ function declareSetup(program2, cli) {
26918
27056
  program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
26919
27057
  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
27058
  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 });
27059
+ const dir = path85.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
27060
+ if (!fs86.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
26923
27061
  return dir;
26924
27062
  };
26925
27063
  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
27064
  const dir = where(this);
26927
27065
  const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
26928
- const board2 = named2 ? path84.resolve(cli.cwd, named2) : null;
27066
+ const board2 = named2 ? path85.resolve(cli.cwd, named2) : null;
26929
27067
  await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
26930
27068
  });
26931
27069
  program2.command("__rules", { hidden: true }).action(function() {
@@ -26970,7 +27108,7 @@ function invokedDirectly() {
26970
27108
  const entry = process.argv[1];
26971
27109
  if (!entry) return false;
26972
27110
  try {
26973
- return fs86.realpathSync(entry) === fs86.realpathSync(SELF2);
27111
+ return fs87.realpathSync(entry) === fs87.realpathSync(SELF2);
26974
27112
  } catch {
26975
27113
  return false;
26976
27114
  }