wildcrane-runner 0.6.26 → 0.6.27

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.23 — built by runner/scripts/build.mjs. Do not edit.
2
+ // ai4kanban 0.11.24 — 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;
@@ -1993,8 +1993,8 @@ var require_command = __commonJS({
1993
1993
  "../cli/node_modules/commander/lib/command.js"(exports) {
1994
1994
  var EventEmitter = __require("node:events").EventEmitter;
1995
1995
  var childProcess = __require("node:child_process");
1996
- var path87 = __require("node:path");
1997
- var fs88 = __require("node:fs");
1996
+ var path90 = __require("node:path");
1997
+ var fs91 = __require("node:fs");
1998
1998
  var process2 = __require("node:process");
1999
1999
  var { Argument: Argument2, humanReadableArgName } = require_argument();
2000
2000
  var { CommanderError: CommanderError2 } = require_error();
@@ -2975,7 +2975,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2975
2975
  * @param {string} subcommandName
2976
2976
  */
2977
2977
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
2978
- if (fs88.existsSync(executableFile)) return;
2978
+ if (fs91.existsSync(executableFile)) return;
2979
2979
  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";
2980
2980
  const executableMissing = `'${executableFile}' does not exist
2981
2981
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -2993,11 +2993,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2993
2993
  let launchWithNode = false;
2994
2994
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2995
2995
  function findFile(baseDir, baseName) {
2996
- const localBin = path87.resolve(baseDir, baseName);
2997
- if (fs88.existsSync(localBin)) return localBin;
2998
- if (sourceExt.includes(path87.extname(baseName))) return void 0;
2996
+ const localBin = path90.resolve(baseDir, baseName);
2997
+ if (fs91.existsSync(localBin)) return localBin;
2998
+ if (sourceExt.includes(path90.extname(baseName))) return void 0;
2999
2999
  const foundExt = sourceExt.find(
3000
- (ext) => fs88.existsSync(`${localBin}${ext}`)
3000
+ (ext) => fs91.existsSync(`${localBin}${ext}`)
3001
3001
  );
3002
3002
  if (foundExt) return `${localBin}${foundExt}`;
3003
3003
  return void 0;
@@ -3009,21 +3009,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
3009
3009
  if (this._scriptPath) {
3010
3010
  let resolvedScriptPath;
3011
3011
  try {
3012
- resolvedScriptPath = fs88.realpathSync(this._scriptPath);
3012
+ resolvedScriptPath = fs91.realpathSync(this._scriptPath);
3013
3013
  } catch {
3014
3014
  resolvedScriptPath = this._scriptPath;
3015
3015
  }
3016
- executableDir = path87.resolve(
3017
- path87.dirname(resolvedScriptPath),
3016
+ executableDir = path90.resolve(
3017
+ path90.dirname(resolvedScriptPath),
3018
3018
  executableDir
3019
3019
  );
3020
3020
  }
3021
3021
  if (executableDir) {
3022
3022
  let localFile = findFile(executableDir, executableFile);
3023
3023
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
3024
- const legacyName = path87.basename(
3024
+ const legacyName = path90.basename(
3025
3025
  this._scriptPath,
3026
- path87.extname(this._scriptPath)
3026
+ path90.extname(this._scriptPath)
3027
3027
  );
3028
3028
  if (legacyName !== this._name) {
3029
3029
  localFile = findFile(
@@ -3034,7 +3034,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3034
3034
  }
3035
3035
  executableFile = localFile || executableFile;
3036
3036
  }
3037
- launchWithNode = sourceExt.includes(path87.extname(executableFile));
3037
+ launchWithNode = sourceExt.includes(path90.extname(executableFile));
3038
3038
  let proc;
3039
3039
  if (process2.platform !== "win32") {
3040
3040
  if (launchWithNode) {
@@ -3881,7 +3881,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3881
3881
  * @return {Command}
3882
3882
  */
3883
3883
  nameFromFilename(filename) {
3884
- this._name = path87.basename(filename, path87.extname(filename));
3884
+ this._name = path90.basename(filename, path90.extname(filename));
3885
3885
  return this;
3886
3886
  }
3887
3887
  /**
@@ -3895,9 +3895,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3895
3895
  * @param {string} [path]
3896
3896
  * @return {(string|null|Command)}
3897
3897
  */
3898
- executableDir(path88) {
3899
- if (path88 === void 0) return this._executableDir;
3900
- this._executableDir = path88;
3898
+ executableDir(path91) {
3899
+ if (path91 === void 0) return this._executableDir;
3900
+ this._executableDir = path91;
3901
3901
  return this;
3902
3902
  }
3903
3903
  /**
@@ -4842,7 +4842,7 @@ function moveSignal(from, into, fields) {
4842
4842
  function dismissInboxItems(sourceIds, by, reason = "") {
4843
4843
  const waiting = bySource(readInbox());
4844
4844
  const ignored = bySource(readAllDismissed());
4845
- const why = reason.trim();
4845
+ const why2 = reason.trim();
4846
4846
  return [...new Set(sourceIds)].map((sourceId) => {
4847
4847
  const missing = { sourceId, ok: false, error: `nothing waiting in triage is ${sourceId}` };
4848
4848
  const found2 = waiting.get(sourceId);
@@ -4852,7 +4852,7 @@ function dismissInboxItems(sourceIds, by, reason = "") {
4852
4852
  const at2 = moveSignal(path11.join(TRIAGE, path11.basename(found2.relPath)), SIGNALS_DISMISSED, {
4853
4853
  dismissed_at: formatStamp(/* @__PURE__ */ new Date()),
4854
4854
  dismissed_by: by,
4855
- ...why ? { dismissed_reason: why } : {}
4855
+ ...why2 ? { dismissed_reason: why2 } : {}
4856
4856
  });
4857
4857
  return at2 ? { sourceId, ok: true, relPath: at2 } : missing;
4858
4858
  });
@@ -5758,7 +5758,7 @@ var init_package = __esm({
5758
5758
  "../cli/package.json"() {
5759
5759
  package_default = {
5760
5760
  name: "wildcrane",
5761
- version: "0.11.23",
5761
+ version: "0.11.24",
5762
5762
  akbContract: 7,
5763
5763
  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.",
5764
5764
  keywords: [
@@ -6343,14 +6343,14 @@ function currentTurn() {
6343
6343
  function forgetFileMemos() {
6344
6344
  turn++;
6345
6345
  }
6346
- function memoByFiles(paths, read4) {
6346
+ function memoByFiles(paths, read5) {
6347
6347
  let last = null;
6348
6348
  return () => {
6349
6349
  const now = currentTurn();
6350
6350
  if (last?.turn !== now) {
6351
6351
  const seen = stamp3(paths());
6352
6352
  if (last?.stamp === seen) last.turn = now;
6353
- else last = { stamp: seen, turn: now, value: read4() };
6353
+ else last = { stamp: seen, turn: now, value: read5() };
6354
6354
  }
6355
6355
  return copy(last.value);
6356
6356
  };
@@ -6366,15 +6366,15 @@ var init_file_memo = __esm({
6366
6366
  });
6367
6367
 
6368
6368
  // ../cloud/src/board-files.ts
6369
- function isBoardPath(path87) {
6370
- if (!path87 || path87.length > 500 || path87.startsWith("/") || path87.includes("\\") || path87.includes("\0")) return false;
6371
- if (path87.split("/").some((part) => !part || part === "." || part === "..")) return false;
6372
- if (path87 === "todo/README.md" || path87.split("/").includes(".sync")) return false;
6373
- if (path87.startsWith("workflows/")) return true;
6374
- if (SETTINGS.includes(path87)) return true;
6375
- if (path87.startsWith("rules/")) return isSettingsPath(path87);
6376
- if (path87.startsWith("assets/")) return path87.endsWith(".json");
6377
- return ROOTS.some((root2) => path87.startsWith(root2)) && path87.endsWith(".md");
6369
+ function isBoardPath(path90) {
6370
+ if (!path90 || path90.length > 500 || path90.startsWith("/") || path90.includes("\\") || path90.includes("\0")) return false;
6371
+ if (path90.split("/").some((part) => !part || part === "." || part === "..")) return false;
6372
+ if (path90 === "todo/README.md" || path90.split("/").includes(".sync")) return false;
6373
+ if (path90.startsWith("workflows/")) return true;
6374
+ if (SETTINGS.includes(path90)) return true;
6375
+ if (path90.startsWith("rules/")) return isSettingsPath(path90);
6376
+ if (path90.startsWith("assets/")) return path90.endsWith(".json");
6377
+ return ROOTS.some((root2) => path90.startsWith(root2)) && path90.endsWith(".md");
6378
6378
  }
6379
6379
  var ROOTS, SETTINGS, isSettingsPath, BOARD_FILE_LIMIT, cardSlug, workflowFolder, workflowName, draftFolder;
6380
6380
  var init_board_files = __esm({
@@ -6382,7 +6382,7 @@ var init_board_files = __esm({
6382
6382
  "use strict";
6383
6383
  ROOTS = ["todo/", ".archive/", "memory/", "workflows/", "triage/", "assets/", "rules/"];
6384
6384
  SETTINGS = ["modules.md", "config.md"];
6385
- isSettingsPath = (path87) => SETTINGS.includes(path87) || /^rules\/(?:workflows\/)?[^/]+\.md$/.test(path87);
6385
+ isSettingsPath = (path90) => SETTINGS.includes(path90) || /^rules\/(?:workflows\/)?[^/]+\.md$/.test(path90);
6386
6386
  BOARD_FILE_LIMIT = 256 * 1024;
6387
6387
  cardSlug = (task) => task.toLowerCase().replace(/_/g, "-");
6388
6388
  workflowFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
@@ -6391,6 +6391,93 @@ var init_board_files = __esm({
6391
6391
  }
6392
6392
  });
6393
6393
 
6394
+ // ../cli/src/lib/agents/icon.ts
6395
+ function readIcon(raw) {
6396
+ if (raw === void 0 || raw === "") return void 0;
6397
+ if (typeof raw === "string") return ICON_NAMES.includes(raw.trim()) ? raw.trim() : { problem: `"${raw}" is not a glyph name` };
6398
+ if (!Array.isArray(raw) || !raw.length || raw.length > 12) return { problem: "the value is neither a glyph name nor a list of 1 to 12 parts" };
6399
+ const parts = [];
6400
+ for (const [i, item] of raw.entries()) {
6401
+ const at2 = `part ${i + 1}`;
6402
+ if (!item || typeof item !== "object" || Array.isArray(item)) return { problem: `${at2} is not a map of \`d\`, \`f\`, \`o\`, \`s\`, \`w\`` };
6403
+ const { d: d2, f: f2, o: o3, s, w: w2, ...extra } = item;
6404
+ if (Object.keys(extra).length) return { problem: `${at2} has \`${Object.keys(extra).join("`, `")}\`` };
6405
+ if (typeof d2 !== "string" || !PATH.test(d2)) return { problem: `${at2} has no \`d\` of SVG path commands and numbers` };
6406
+ const part = { d: d2.trim() };
6407
+ for (const [key, value] of [["f", f2], ["s", s]]) {
6408
+ if (value === void 0) continue;
6409
+ if (typeof value !== "string" || !isColor(value)) return { problem: `${at2} colours \`${key}\` with "${String(value)}"` };
6410
+ part[key] = value;
6411
+ }
6412
+ if (o3 !== void 0) {
6413
+ if (o3 !== "true") return { problem: `${at2} has \`o: ${String(o3)}\`, not \`true\`` };
6414
+ part.o = true;
6415
+ }
6416
+ if (w2 !== void 0) {
6417
+ const width = typeof w2 === "string" ? Number(w2) : NaN;
6418
+ if (!(width > 0 && width <= 3)) return { problem: `${at2} has \`w: ${String(w2)}\`, not above 0 and up to 3` };
6419
+ part.w = width;
6420
+ }
6421
+ parts.push(part);
6422
+ }
6423
+ return parts;
6424
+ }
6425
+ var ICON_NAMES, ICON_COLORS, PATH, isColor;
6426
+ var init_icon = __esm({
6427
+ "../cli/src/lib/agents/icon.ts"() {
6428
+ "use strict";
6429
+ ICON_NAMES = [
6430
+ "file",
6431
+ "text",
6432
+ "article",
6433
+ "outline",
6434
+ "script",
6435
+ "prompt",
6436
+ "email",
6437
+ "image",
6438
+ "post-image",
6439
+ "social-image",
6440
+ "cover",
6441
+ "carousel",
6442
+ "carousel-outline",
6443
+ "slides",
6444
+ "wireframe",
6445
+ "screen",
6446
+ "video",
6447
+ "storyboard",
6448
+ "template",
6449
+ "shots",
6450
+ "api",
6451
+ "schema",
6452
+ "compare",
6453
+ "stack",
6454
+ "workflow",
6455
+ "code",
6456
+ "checklist",
6457
+ "card",
6458
+ "plan",
6459
+ "proposal",
6460
+ "dismissed",
6461
+ "inbox",
6462
+ "notebook",
6463
+ "squeeze",
6464
+ "folder",
6465
+ "reply",
6466
+ "feedback",
6467
+ "software",
6468
+ "product-video",
6469
+ "social-post",
6470
+ "blog",
6471
+ "deck",
6472
+ "video-clone",
6473
+ "workflow-kit"
6474
+ ];
6475
+ ICON_COLORS = ["k", "w", "c", "g", "o", "p", "s", "m", "l", "r", "y"];
6476
+ PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/;
6477
+ isColor = (v) => ICON_COLORS.includes(v);
6478
+ }
6479
+ });
6480
+
6394
6481
  // ../cli/src/lib/agents/yaml.ts
6395
6482
  function stripComment(value) {
6396
6483
  let from = 0;
@@ -6505,8 +6592,8 @@ var init_yaml2 = __esm({
6505
6592
  // ../cli/src/lib/agents/parse.ts
6506
6593
  function parseSpecAgent(text5, from, file, builtIn = false, list = () => []) {
6507
6594
  let named2 = "";
6508
- const bad = (why, old2) => ({
6509
- problem: `${from}: ${why}`,
6595
+ const bad = (why2, old2) => ({
6596
+ problem: `${from}: ${why2}`,
6510
6597
  ...named2 ? { name: named2 } : {},
6511
6598
  ...old2 ? { old: old2 } : {}
6512
6599
  });
@@ -6541,6 +6628,12 @@ function parseSpecAgent(text5, from, file, builtIn = false, list = () => []) {
6541
6628
  if (!Array.isArray(components) || components.some((value) => typeof value !== "string" || !value.trim())) {
6542
6629
  return bad(`\`${name}\` declares \`akb.components\` that is not a list of component IDs`);
6543
6630
  }
6631
+ const icon = readIcon(akb.icon);
6632
+ if (icon && typeof icon === "object" && "problem" in icon) {
6633
+ return bad(
6634
+ `\`${name}\` declares an \`akb.icon\` where ${icon.problem} \u2014 use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
6635
+ );
6636
+ }
6544
6637
  const workspace = memoryPaths(akb.memoryFiles);
6545
6638
  if (typeof workspace === "string") return bad(`\`${name}\` declares ${workspace}`);
6546
6639
  const instructions = body.trim();
@@ -6552,6 +6645,7 @@ function parseSpecAgent(text5, from, file, builtIn = false, list = () => []) {
6552
6645
  ...when ? { when } : {},
6553
6646
  after: after2,
6554
6647
  components: [...new Set(components.map((value) => value.trim()))],
6648
+ ...icon ? { icon } : {},
6555
6649
  i18n: readTranslations(akb.i18n),
6556
6650
  ...declaredReads ? { reads: declaredReads } : {},
6557
6651
  ...declaredSession ? { session: "new" } : {},
@@ -6600,6 +6694,7 @@ var OLD_ROLE_KEYS, AGENT_NAME, SCHEDULE_READS, isScheduleReads, names, str, map;
6600
6694
  var init_parse = __esm({
6601
6695
  "../cli/src/lib/agents/parse.ts"() {
6602
6696
  "use strict";
6697
+ init_icon();
6603
6698
  init_yaml2();
6604
6699
  OLD_ROLE_KEYS = ["lead", "hook", "stage", "kind"];
6605
6700
  AGENT_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
@@ -6653,6 +6748,12 @@ function parseWorkflowFile(id, source, from) {
6653
6748
  problem: `${from}: \`${old.join("`, `")}\` ${old.length > 1 ? "are" : "is"} no longer read \u2014 list the agents under \`previews\`, \`land\` and \`scheduled\` instead (\`akb guide write-agent\`), or ask the Workflow builder to rewrite it`
6654
6749
  };
6655
6750
  }
6751
+ const icon = readIcon(raw.icon);
6752
+ if (icon && typeof icon === "object" && "problem" in icon) {
6753
+ return {
6754
+ problem: `${from}: its \`icon\` is wrong \u2014 ${icon.problem}; use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
6755
+ };
6756
+ }
6656
6757
  const previews = readPreviews(raw.previews);
6657
6758
  if (typeof previews === "string") return { problem: `${from}: ${previews}` };
6658
6759
  const land = readGroup(raw.land);
@@ -6677,6 +6778,7 @@ function parseWorkflowFile(id, source, from) {
6677
6778
  description: text(raw.description),
6678
6779
  when: text(raw.when),
6679
6780
  needsArtifact: text(raw.needsArtifact) === "true",
6781
+ ...icon ? { icon } : {},
6680
6782
  previews,
6681
6783
  land,
6682
6784
  scheduled,
@@ -6688,6 +6790,7 @@ var WORKFLOW_ID, OLD_KEYS, box, text, readGroup;
6688
6790
  var init_workflow_def = __esm({
6689
6791
  "../cli/src/lib/agent/workflow-def.ts"() {
6690
6792
  "use strict";
6793
+ init_icon();
6691
6794
  init_yaml2();
6692
6795
  init_spec_agent_names();
6693
6796
  WORKFLOW_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
@@ -6698,6 +6801,36 @@ var init_workflow_def = __esm({
6698
6801
  }
6699
6802
  });
6700
6803
 
6804
+ // ../cli/src/lib/agent/workflow-diagram.ts
6805
+ function workflowDiagram(def, agentOf3) {
6806
+ const step = (name) => {
6807
+ const agent = ROLES[name] ? null : agentOf3(name);
6808
+ const en2 = agent?.i18n.en?.title || name;
6809
+ return {
6810
+ agent: name,
6811
+ title: ROLES[name] ?? { en: en2, zh: agent?.i18n.zh?.title || en2 },
6812
+ ...agent?.icon ? { icon: agent.icon } : {},
6813
+ ...agent?.when ? { optional: true } : {}
6814
+ };
6815
+ };
6816
+ const previews = def.previews.filter((h3) => !h3.off).map((h3) => h3.agent);
6817
+ const after2 = (name) => (agentOf3(name)?.after ?? []).filter((other) => previews.includes(other));
6818
+ return {
6819
+ version: 1,
6820
+ rounds: stagesOf(previews, after2).map((round) => round.map(step)),
6821
+ land: def.land.filter((h3) => !h3.off).map((h3) => step(h3.agent)),
6822
+ scheduled: def.scheduled.map((s) => ({ ...step(s.agent), ...s.cadence ? { cadence: s.cadence } : {} }))
6823
+ };
6824
+ }
6825
+ var ROLES;
6826
+ var init_workflow_diagram = __esm({
6827
+ "../cli/src/lib/agent/workflow-diagram.ts"() {
6828
+ "use strict";
6829
+ init_workflow_def();
6830
+ ROLES = { builder: { en: "Build and merge", zh: "\u5B9E\u73B0\u5E76\u5408\u5165" } };
6831
+ }
6832
+ });
6833
+
6701
6834
  // ../cloud/src/v1/workflow-files.ts
6702
6835
  function folderPath(file, top) {
6703
6836
  const parts = file.split("/");
@@ -6706,13 +6839,13 @@ function folderPath(file, top) {
6706
6839
  return [parts[1], parts.slice(2).join("/")];
6707
6840
  }
6708
6841
  function mcpProblem(text5) {
6709
- let read4;
6842
+ let read5;
6710
6843
  try {
6711
- read4 = JSON.parse(text5);
6844
+ read5 = JSON.parse(text5);
6712
6845
  } catch {
6713
6846
  return "is not JSON";
6714
6847
  }
6715
- const servers = read4?.mcpServers;
6848
+ const servers = read5?.mcpServers;
6716
6849
  if (!servers || typeof servers !== "object" || Array.isArray(servers)) return "must hold `mcpServers`, an object of name \u2192 server";
6717
6850
  for (const [name, server] of Object.entries(servers)) {
6718
6851
  const { command, args, ...rest } = server ?? {};
@@ -6759,9 +6892,9 @@ function checkWorkflowFiles(value, official = false) {
6759
6892
  }
6760
6893
  const source = value[WORKFLOW_FILE];
6761
6894
  if (source === void 0) return fail(WORKFLOW_FILE, "is missing");
6762
- const read4 = parseWorkflowFile("workflow", source, WORKFLOW_FILE);
6763
- if ("problem" in read4) return fail(WORKFLOW_FILE, read4.problem.replace(`${WORKFLOW_FILE}: `, ""));
6764
- const def = read4.def;
6895
+ const read5 = parseWorkflowFile("workflow", source, WORKFLOW_FILE);
6896
+ if ("problem" in read5) return fail(WORKFLOW_FILE, read5.problem.replace(`${WORKFLOW_FILE}: `, ""));
6897
+ const def = read5.def;
6765
6898
  const agents = /* @__PURE__ */ new Map();
6766
6899
  for (const [name, own] of folders2) {
6767
6900
  const from = `agents/${name}/AGENT.md`;
@@ -6777,8 +6910,8 @@ function checkWorkflowFiles(value, official = false) {
6777
6910
  ...def.land.filter((h3) => !LAND_ROLES.includes(h3.agent)).map((h3) => [h3.agent, "it lands with"]),
6778
6911
  ...def.scheduled.map((s) => [s.agent, "it schedules"])
6779
6912
  ];
6780
- for (const [name, why] of named2) {
6781
- if (!agents.has(name)) return fail(WORKFLOW_FILE, `${why} \`${name}\`, which has no agents/${name}/AGENT.md`);
6913
+ for (const [name, why2] of named2) {
6914
+ if (!agents.has(name)) return fail(WORKFLOW_FILE, `${why2} \`${name}\`, which has no agents/${name}/AGENT.md`);
6782
6915
  }
6783
6916
  return { ok: true, def, files: value };
6784
6917
  }
@@ -6788,6 +6921,7 @@ var init_workflow_files = __esm({
6788
6921
  "use strict";
6789
6922
  init_workflow_def();
6790
6923
  init_parse();
6924
+ init_workflow_diagram();
6791
6925
  WORKFLOW_FILE = "WORKFLOW.md";
6792
6926
  MCP_FILE = "mcp.json";
6793
6927
  KB = 1024;
@@ -6817,8 +6951,8 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
6817
6951
  return [name, Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, fs20.readFileSync(path21.join(dir, f2), "utf8")]))];
6818
6952
  }));
6819
6953
  for (const [name, own] of Object.entries(loose ? {} : agentFiles)) {
6820
- const read4 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
6821
- if ("problem" in read4) throw new Error(read4.problem);
6954
+ const read5 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
6955
+ if ("problem" in read5) throw new Error(read5.problem);
6822
6956
  }
6823
6957
  const workflowsDir = path21.join(root2, "workflows");
6824
6958
  return dirs(workflowsDir).map((folder) => {
@@ -6827,10 +6961,10 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
6827
6961
  for (const f2 of filesOf(dir).sort()) {
6828
6962
  if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/")) files2[f2] = fs20.readFileSync(path21.join(dir, f2), "utf8");
6829
6963
  }
6830
- const read4 = checkWorkflowFiles({ [WORKFLOW_FILE]: files2[WORKFLOW_FILE], ...Object.fromEntries(
6964
+ const read5 = checkWorkflowFiles({ [WORKFLOW_FILE]: files2[WORKFLOW_FILE], ...Object.fromEntries(
6831
6965
  Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f2, t]) => [`agents/${name}/${f2}`, t]))
6832
6966
  ) });
6833
- if (!read4.ok && !loose) throw new Error(`official/workflows/${folder}: ${read4.file}: ${read4.reason}`);
6967
+ if (!read5.ok && !loose) throw new Error(`official/workflows/${folder}: ${read5.file}: ${read5.reason}`);
6834
6968
  const parsed = parseWorkflowFile(folder, files2[WORKFLOW_FILE] ?? "", WORKFLOW_FILE);
6835
6969
  if ("problem" in parsed) throw new Error(parsed.problem);
6836
6970
  const def = parsed.def;
@@ -6903,18 +7037,18 @@ function pinMissing() {
6903
7037
  async function versionOf(id, version) {
6904
7038
  const held4 = readVersion(id, version);
6905
7039
  if (held4) return { ok: true, value: held4 };
6906
- const read4 = await call("GET", `/v1/workflows/${encodeURIComponent(id)}`);
6907
- if (!read4.ok) return read4;
6908
- saveVersion(read4.value);
6909
- return read4;
7040
+ const read5 = await call("GET", `/v1/workflows/${encodeURIComponent(id)}`);
7041
+ if (!read5.ok) return read5;
7042
+ saveVersion(read5.value);
7043
+ return read5;
6910
7044
  }
6911
7045
  async function pinTask(task) {
6912
7046
  const pin = readPin(task);
6913
7047
  const held4 = pin && readVersion(pin.workflow, pin.version);
6914
7048
  if (held4) return { ok: true, value: held4 };
6915
- const read4 = await call("GET", `/v1/tasks/${encodeURIComponent(task)}/workflow`);
6916
- if (!read4.ok) return read4;
6917
- const value = { id: read4.value.workflow, version: read4.value.version, name: read4.value.name, files: read4.value.files };
7049
+ const read5 = await call("GET", `/v1/tasks/${encodeURIComponent(task)}/workflow`);
7050
+ if (!read5.ok) return read5;
7051
+ const value = { id: read5.value.workflow, version: read5.value.version, name: read5.value.name, files: read5.value.files };
6918
7052
  savePin(task, value);
6919
7053
  return { ok: true, value };
6920
7054
  }
@@ -6933,12 +7067,12 @@ async function syncWorkflows(force = false) {
6933
7067
  if (fresh && !force) return;
6934
7068
  let workspace = held4?.workspace;
6935
7069
  if (!workspace) {
6936
- const read4 = await call("GET", `/v1/projects/${encodeURIComponent(project)}`);
6937
- if (!read4.ok) {
6938
- offline = !read4.code;
7070
+ const read5 = await call("GET", `/v1/projects/${encodeURIComponent(project)}`);
7071
+ if (!read5.ok) {
7072
+ offline = !read5.code;
6939
7073
  return;
6940
7074
  }
6941
- workspace = read4.value.workspace;
7075
+ workspace = read5.value.workspace;
6942
7076
  }
6943
7077
  const listed = [];
6944
7078
  let after2 = null;
@@ -6956,9 +7090,9 @@ async function syncWorkflows(force = false) {
6956
7090
  } while (after2);
6957
7091
  const kept2 = [];
6958
7092
  for (const w2 of listed) {
6959
- const read4 = await versionOf(w2.id, w2.version);
6960
- if (read4.ok) kept2.push({ id: read4.value.id, version: read4.value.version });
6961
- else if (!read4.code) offline = true;
7093
+ const read5 = await versionOf(w2.id, w2.version);
7094
+ if (read5.ok) kept2.push({ id: read5.value.id, version: read5.value.version });
7095
+ else if (!read5.code) offline = true;
6962
7096
  }
6963
7097
  writeJson(listFile(project), { at: (/* @__PURE__ */ new Date()).toISOString(), workspace, workflows: kept2 });
6964
7098
  } catch {
@@ -7031,9 +7165,9 @@ var init_cloud_workflows = __esm({
7031
7165
  workflowsOffline = () => offline;
7032
7166
  flowOf = (held4) => {
7033
7167
  const id = workflowName(held4.id);
7034
- const read4 = parseWorkflowFile(id, held4.files["WORKFLOW.md"] ?? "", `the \`${id}\` workflow`);
7035
- if ("problem" in read4) return null;
7036
- return { def: read4.def, cloudId: held4.id, version: held4.version, builtIn: held4.id.startsWith("wf_builtin_"), files: held4.files };
7168
+ const read5 = parseWorkflowFile(id, held4.files["WORKFLOW.md"] ?? "", `the \`${id}\` workflow`);
7169
+ if ("problem" in read5) return null;
7170
+ return { def: read5.def, cloudId: held4.id, version: held4.version, builtIn: held4.id.startsWith("wf_builtin_"), files: held4.files };
7037
7171
  };
7038
7172
  sources = () => {
7039
7173
  if (devFolder()) return [devFolder()];
@@ -7065,16 +7199,16 @@ function readCatalog() {
7065
7199
  const agents = [];
7066
7200
  const problems = [];
7067
7201
  const refused = [];
7068
- const take = (read4, folder) => {
7069
- if ("problem" in read4) {
7070
- if (!read4.missing) problems.push(read4.problem);
7071
- if (!read4.file) return;
7072
- const { file, name: name2, old } = read4;
7073
- const cause = read4.missing ? "noFile" : old ? "oldKeys" : "file";
7202
+ const take = (read5, folder) => {
7203
+ if ("problem" in read5) {
7204
+ if (!read5.missing) problems.push(read5.problem);
7205
+ if (!read5.file) return;
7206
+ const { file, name: name2, old } = read5;
7207
+ const cause = read5.missing ? "noFile" : old ? "oldKeys" : "file";
7074
7208
  refused.push({ folder, file, cause, ...name2 ? { name: name2 } : {}, ...old ? { keys: old.keys } : {} });
7075
7209
  return;
7076
7210
  }
7077
- const { name, from, builtIn } = read4.agent;
7211
+ const { name, from, builtIn } = read5.agent;
7078
7212
  const refuse3 = (cause, problem) => {
7079
7213
  problems.push(problem);
7080
7214
  if (!builtIn) refused.push({ folder, name, file: from, cause });
@@ -7098,14 +7232,14 @@ function readCatalog() {
7098
7232
  `${from}: its folder is \`${folder}\` but it calls itself \`${name}\`. An agent is asked for by its folder name \u2014 make the two match.`
7099
7233
  );
7100
7234
  }
7101
- agents.push(read4.agent);
7235
+ agents.push(read5.agent);
7102
7236
  };
7103
7237
  for (const folder of bundledFolders()) take(readBundled(folder), folder);
7104
7238
  for (const folder of projectFolders(AGENTS)) {
7105
- const read4 = readProject(AGENTS, folder);
7106
- take(read4, folder);
7107
- if ("agent" in read4 && read4.agent.from.endsWith(LEGACY_AGENT_FILE)) {
7108
- problems.push(`${read4.agent.from}: rename it to ${AGENT_FILE}`);
7239
+ const read5 = readProject(AGENTS, folder);
7240
+ take(read5, folder);
7241
+ if ("agent" in read5 && read5.agent.from.endsWith(LEGACY_AGENT_FILE)) {
7242
+ problems.push(`${read5.agent.from}: rename it to ${AGENT_FILE}`);
7109
7243
  }
7110
7244
  }
7111
7245
  for (const folder of projectFolders(LEGACY_AGENTS)) {
@@ -7210,10 +7344,10 @@ function readProject(root2, folder) {
7210
7344
  const missing = rel(path23.join(dir, AGENT_FILE));
7211
7345
  if (!found2) return { problem: `${missing} is missing`, file: missing, missing: true };
7212
7346
  const from = rel(path23.join(dir, found2.name));
7213
- const read4 = parseSpecAgent(found2.text, from, file, false, () => ownFiles(walkFolder(dir, "")));
7214
- if ("problem" in read4) return { ...read4, file: from };
7215
- if ("agent" in read4) Object.assign(read4.agent, { dir, text: found2.text });
7216
- return read4;
7347
+ const read5 = parseSpecAgent(found2.text, from, file, false, () => ownFiles(walkFolder(dir, "")));
7348
+ if ("problem" in read5) return { ...read5, file: from };
7349
+ if ("agent" in read5) Object.assign(read5.agent, { dir, text: found2.text });
7350
+ return read5;
7217
7351
  }
7218
7352
  var specAgentCatalog, bundledFolders, AGENT_FILE, LEGACY_AGENT_FILE, AGENT_FILES, ownFiles;
7219
7353
  var init_catalog2 = __esm({
@@ -8255,10 +8389,10 @@ function findRollout(threadId) {
8255
8389
  }
8256
8390
  for (const name of names3) {
8257
8391
  if (!name.startsWith("rollout-") || !name.endsWith(tail2)) continue;
8258
- const path87 = join(dir, name);
8392
+ const path90 = join(dir, name);
8259
8393
  try {
8260
- const at2 = statSync(path87).mtimeMs;
8261
- if (!newest2 || at2 > newest2.at) newest2 = { path: path87, at: at2 };
8394
+ const at2 = statSync(path90).mtimeMs;
8395
+ if (!newest2 || at2 > newest2.at) newest2 = { path: path90, at: at2 };
8262
8396
  } catch {
8263
8397
  }
8264
8398
  }
@@ -8266,11 +8400,11 @@ function findRollout(threadId) {
8266
8400
  return newest2?.path;
8267
8401
  }
8268
8402
  function readCodexRunFacts(threadId) {
8269
- const path87 = findRollout(threadId);
8270
- if (!path87) return void 0;
8403
+ const path90 = findRollout(threadId);
8404
+ if (!path90) return void 0;
8271
8405
  let raw;
8272
8406
  try {
8273
- raw = readFileSync(path87, "utf8");
8407
+ raw = readFileSync(path90, "utf8");
8274
8408
  } catch {
8275
8409
  return void 0;
8276
8410
  }
@@ -8398,8 +8532,8 @@ function renderCompleted(item) {
8398
8532
  const changes = Array.isArray(item.changes) ? item.changes : [];
8399
8533
  return changes.map((raw) => {
8400
8534
  const change2 = obj(raw);
8401
- const path87 = str2(change2.path);
8402
- return path87 ? `\u23FA ${str2(change2.kind) || "change"}(${path87})
8535
+ const path90 = str2(change2.path);
8536
+ return path90 ? `\u23FA ${str2(change2.kind) || "change"}(${path90})
8403
8537
  ` : "";
8404
8538
  }).join("");
8405
8539
  }
@@ -8661,10 +8795,10 @@ function readKimiRunFacts(sessionId) {
8661
8795
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
8662
8796
  let model;
8663
8797
  let holding = 0;
8664
- for (const { path: path87, main } of wireFiles(entry.sessionDir)) {
8798
+ for (const { path: path90, main } of wireFiles(entry.sessionDir)) {
8665
8799
  let raw;
8666
8800
  try {
8667
- raw = readFileSync2(path87, "utf8");
8801
+ raw = readFileSync2(path90, "utf8");
8668
8802
  } catch {
8669
8803
  continue;
8670
8804
  }
@@ -8727,9 +8861,9 @@ function toolCalls(row) {
8727
8861
  }).join("");
8728
8862
  }
8729
8863
  function retry(row) {
8730
- const why = str2(row.error_message) || str2(row.error_name) || "the provider failed";
8864
+ const why2 = str2(row.error_message) || str2(row.error_name) || "the provider failed";
8731
8865
  const attempt2 = `${num(row.next_attempt)}/${num(row.max_attempts)}`;
8732
- return `[retry ${attempt2}] ${why}
8866
+ return `[retry ${attempt2}] ${why2}
8733
8867
  `;
8734
8868
  }
8735
8869
  function createKimiStreamRenderer(cwd) {
@@ -8818,10 +8952,10 @@ function connect(stdout, stdin, onCall, dialect = {}) {
8818
8952
  } catch {
8819
8953
  }
8820
8954
  };
8821
- const closed2 = (why) => {
8955
+ const closed2 = (why2) => {
8822
8956
  if (gone) return;
8823
- gone = why;
8824
- for (const { fail } of waiting.values()) fail(new Error(why));
8957
+ gone = why2;
8958
+ for (const { fail } of waiting.values()) fail(new Error(why2));
8825
8959
  waiting.clear();
8826
8960
  };
8827
8961
  stdout.on("data", (chunk) => {
@@ -8945,8 +9079,8 @@ var init_tail = __esm({
8945
9079
  import fs28 from "node:fs";
8946
9080
  function whereHint(update2, title) {
8947
9081
  const locations = Array.isArray(update2.locations) ? update2.locations : [];
8948
- const path87 = str2(obj(locations[0]).path);
8949
- return path87 && !title.includes(path87) ? hint(path87) : "";
9082
+ const path90 = str2(obj(locations[0]).path);
9083
+ return path90 && !title.includes(path90) ? hint(path90) : "";
8950
9084
  }
8951
9085
  function saidBy(update2) {
8952
9086
  const content = Array.isArray(update2.content) ? update2.content : [];
@@ -9111,12 +9245,12 @@ async function oneTurn(io, options) {
9111
9245
  const usage3 = usageOf2(done2.usage) ?? usageOf2(spent, true);
9112
9246
  costUsd ??= ticksUsd(spent.costUsdTicks);
9113
9247
  if (stopReason2 && stopReason2 !== "end_turn") {
9114
- const why = STOPPED[stopReason2] ?? `the agent stopped: ${stopReason2}`;
9115
- io.log(`[error] ${why}
9248
+ const why2 = STOPPED[stopReason2] ?? `the agent stopped: ${stopReason2}`;
9249
+ io.log(`[error] ${why2}
9116
9250
  `);
9117
- events.error(why);
9251
+ events.error(why2);
9118
9252
  emit();
9119
- return { ok: false, result, error: why, usage: usage3, context, costUsd };
9253
+ return { ok: false, result, error: why2, usage: usage3, context, costUsd };
9120
9254
  }
9121
9255
  emit();
9122
9256
  return { ok: true, result, usage: usage3, context, costUsd };
@@ -9146,8 +9280,8 @@ function update(raw, tail2, gotCost, gotContext) {
9146
9280
  }
9147
9281
  case "tool_call_update": {
9148
9282
  if (change2.status !== "failed") return;
9149
- const why = saidBy(change2);
9150
- tail2.line(`[error] ${str2(change2.title) || "that tool call"} failed${why ? `: ${why}` : ""}`);
9283
+ const why2 = saidBy(change2);
9284
+ tail2.line(`[error] ${str2(change2.title) || "that tool call"} failed${why2 ? `: ${why2}` : ""}`);
9151
9285
  return;
9152
9286
  }
9153
9287
  case "usage_update": {
@@ -9261,8 +9395,8 @@ function createParts(tail2) {
9261
9395
  tail2.line(`\u23FA ${title}${whereHint2(state.input, title)}`);
9262
9396
  }
9263
9397
  if (str2(state.status) === "error") {
9264
- const why = str2(state.error).trim();
9265
- tail2.line(`[error] ${title} failed${why ? `: ${why}` : ""}`);
9398
+ const why2 = str2(state.error).trim();
9399
+ tail2.line(`[error] ${title} failed${why2 ? `: ${why2}` : ""}`);
9266
9400
  }
9267
9401
  },
9268
9402
  /** A piece of one part, as `part.delta` sends it. */
@@ -9295,18 +9429,18 @@ function createParts(tail2) {
9295
9429
  toolUpdate(payload) {
9296
9430
  if (str2(payload.kind) !== "error") return;
9297
9431
  const name = named2.get(str2(payload.toolCallId)) ?? "tool";
9298
- const why = str2(obj(payload.error).message).split("\n")[0].trim();
9299
- tail2.line(`[error] ${name} failed${why ? `: ${why.slice(0, 200)}` : ""}`);
9432
+ const why2 = str2(obj(payload.error).message).split("\n")[0].trim();
9433
+ tail2.line(`[error] ${name} failed${why2 ? `: ${why2.slice(0, 200)}` : ""}`);
9300
9434
  }
9301
9435
  };
9302
9436
  }
9303
9437
  function createZcodeClient(options = {}) {
9304
9438
  return { turn: (io) => oneTurn2(io, options) };
9305
9439
  }
9306
- function stopped(io, why) {
9307
- io.log(`[error] ${why}
9440
+ function stopped(io, why2) {
9441
+ io.log(`[error] ${why2}
9308
9442
  `);
9309
- if (MISSING_KEY.test(why)) {
9443
+ if (MISSING_KEY.test(why2)) {
9310
9444
  io.log("[board] paste a Z.AI or BigModel Coding Plan key into ZCode's key box in Configuration.\n");
9311
9445
  }
9312
9446
  }
@@ -9396,9 +9530,9 @@ async function oneTurn2(io, options) {
9396
9530
  const usage3 = done2.usage ?? await tokensOf(rpc, sessionId);
9397
9531
  const context = await contextOf(rpc, sessionId);
9398
9532
  if (!done2.ok) {
9399
- const why = done2.error ?? "the agent stopped without saying why";
9400
- stopped(io, why);
9401
- return { ok: false, result, error: why, usage: usage3, context };
9533
+ const why2 = done2.error ?? "the agent stopped without saying why";
9534
+ stopped(io, why2);
9535
+ return { ok: false, result, error: why2, usage: usage3, context };
9402
9536
  }
9403
9537
  return { ok: true, result, usage: usage3, context };
9404
9538
  } catch (e2) {
@@ -9417,8 +9551,8 @@ async function tokensOf(rpc, sessionId) {
9417
9551
  }
9418
9552
  async function contextOf(rpc, sessionId) {
9419
9553
  try {
9420
- const read4 = await rpc.call("session/read", { sessionId, messageLimit: 1 });
9421
- const state = obj(read4.projection);
9554
+ const read5 = await rpc.call("session/read", { sessionId, messageLimit: 1 });
9555
+ const state = obj(read5.projection);
9422
9556
  const used = num(state.contextUsed);
9423
9557
  const limit = num(state.contextWindow);
9424
9558
  return used > 0 ? { used, limit: limit > 0 ? limit : void 0 } : void 0;
@@ -11134,12 +11268,12 @@ var init_language = __esm({
11134
11268
 
11135
11269
  // ../cli/src/lib/agent/proxy.ts
11136
11270
  import { execFileSync } from "node:child_process";
11137
- function withSystemProxy(env2 = process.env, platform = process.platform, read4 = () => execFileSync("/usr/sbin/scutil", ["--proxy"], { encoding: "utf8", timeout: 1e3, stdio: ["ignore", "pipe", "ignore"] })) {
11271
+ function withSystemProxy(env2 = process.env, platform = process.platform, read5 = () => execFileSync("/usr/sbin/scutil", ["--proxy"], { encoding: "utf8", timeout: 1e3, stdio: ["ignore", "pipe", "ignore"] })) {
11138
11272
  const out = { ...env2 };
11139
11273
  if (platform !== "darwin" || PROXY_KEYS.some((key) => env2[key] !== void 0)) return out;
11140
11274
  let raw;
11141
11275
  try {
11142
- raw = read4();
11276
+ raw = read5();
11143
11277
  } catch {
11144
11278
  return out;
11145
11279
  }
@@ -11779,12 +11913,12 @@ function readAnswers(raw) {
11779
11913
  if (!Array.isArray(raw)) return void 0;
11780
11914
  const answers2 = raw.flatMap((entry) => {
11781
11915
  if (!entry || entry.outcome !== "changed" && entry.outcome !== "unchanged") return [];
11782
- const why = text3(entry.why);
11783
- if (!why) return [];
11916
+ const why2 = text3(entry.why);
11917
+ if (!why2) return [];
11784
11918
  return [
11785
11919
  {
11786
11920
  outcome: entry.outcome,
11787
- why,
11921
+ why: why2,
11788
11922
  at: typeof entry.at === "number" ? entry.at : 0,
11789
11923
  actedAt: typeof entry.actedAt === "number" ? entry.actedAt : void 0
11790
11924
  }
@@ -12211,12 +12345,12 @@ function writeConfig(change2) {
12211
12345
  try {
12212
12346
  cfg = readConfigRaw();
12213
12347
  } catch (e2) {
12214
- const why = e2 instanceof Error ? e2.message : String(e2);
12348
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12215
12349
  return {
12216
12350
  ok: false,
12217
- ...refusal("fileParse", `couldn't save: ${UI_CONFIG} won't parse (${why}). Fix the file, then try again.`, {
12351
+ ...refusal("fileParse", `couldn't save: ${UI_CONFIG} won't parse (${why2}). Fix the file, then try again.`, {
12218
12352
  path: UI_CONFIG,
12219
- details: why
12353
+ details: why2
12220
12354
  })
12221
12355
  };
12222
12356
  }
@@ -12227,8 +12361,8 @@ function writeConfig(change2) {
12227
12361
  forgetFileMemos();
12228
12362
  return { ok: true };
12229
12363
  } catch (e2) {
12230
- const why = e2 instanceof Error ? e2.message : String(e2);
12231
- return { ok: false, ...refusal("fileWrite", `couldn't write ${UI_CONFIG}: ${why}`, { path: UI_CONFIG, details: why }) };
12364
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12365
+ return { ok: false, ...refusal("fileWrite", `couldn't write ${UI_CONFIG}: ${why2}`, { path: UI_CONFIG, details: why2 }) };
12232
12366
  }
12233
12367
  }
12234
12368
  function parseLine(line) {
@@ -12274,12 +12408,12 @@ function ensureIgnored() {
12274
12408
  fs34.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${IGNORE_BLOCK}`);
12275
12409
  return { ok: true };
12276
12410
  } catch (e2) {
12277
- const why = e2 instanceof Error ? e2.message : String(e2);
12411
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12278
12412
  return {
12279
12413
  ok: false,
12280
- ...refusal("gitignoreWrite", `couldn't write ${KANBAN_GITIGNORE} to keep the key out of git: ${why}`, {
12414
+ ...refusal("gitignoreWrite", `couldn't write ${KANBAN_GITIGNORE} to keep the key out of git: ${why2}`, {
12281
12415
  path: KANBAN_GITIGNORE,
12282
- details: why
12416
+ details: why2
12283
12417
  })
12284
12418
  };
12285
12419
  }
@@ -12291,8 +12425,8 @@ function setSecret(name, value) {
12291
12425
  try {
12292
12426
  lines = fs34.existsSync(ENV_FILE) ? fs34.readFileSync(ENV_FILE, "utf8").split("\n") : [];
12293
12427
  } catch (e2) {
12294
- const why = e2 instanceof Error ? e2.message : String(e2);
12295
- return { ok: false, ...refusal("fileRead", `couldn't read ${ENV_FILE}: ${why}`, { path: ENV_FILE, details: why }) };
12428
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12429
+ return { ok: false, ...refusal("fileRead", `couldn't read ${ENV_FILE}: ${why2}`, { path: ENV_FILE, details: why2 }) };
12296
12430
  }
12297
12431
  const next = value.trim();
12298
12432
  const kept2 = [];
@@ -12315,8 +12449,8 @@ function setSecret(name, value) {
12315
12449
  fs34.writeFileSync(ENV_FILE, text5, { mode: 384 });
12316
12450
  return { ok: true };
12317
12451
  } catch (e2) {
12318
- const why = e2 instanceof Error ? e2.message : String(e2);
12319
- return { ok: false, ...refusal("fileWrite", `couldn't write ${ENV_FILE}: ${why}`, { path: ENV_FILE, details: why }) };
12452
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12453
+ return { ok: false, ...refusal("fileWrite", `couldn't write ${ENV_FILE}: ${why2}`, { path: ENV_FILE, details: why2 }) };
12320
12454
  }
12321
12455
  }
12322
12456
  function stampSchedule(key, when) {
@@ -13594,12 +13728,12 @@ function readFolder2(id, problems) {
13594
13728
  problems.push(`${rel(fileOf(id))} is missing`);
13595
13729
  return null;
13596
13730
  }
13597
- const read4 = parseWorkflowFile(id, source, rel(fileOf(id)));
13598
- if ("problem" in read4) {
13599
- problems.push(read4.problem);
13731
+ const read5 = parseWorkflowFile(id, source, rel(fileOf(id)));
13732
+ if ("problem" in read5) {
13733
+ problems.push(read5.problem);
13600
13734
  return null;
13601
13735
  }
13602
- return read4.def;
13736
+ return read5.def;
13603
13737
  }
13604
13738
  function boardWorkflowDefs() {
13605
13739
  const problems = [];
@@ -13760,8 +13894,8 @@ function writeDraft(def, settings) {
13760
13894
  try {
13761
13895
  writeWorkflowDef(def);
13762
13896
  } catch (e2) {
13763
- const why = e2 instanceof Error ? e2.message : String(e2);
13764
- return { ok: false, ...refusal("fileWrite", `couldn't write the "${def.name}" workflow: ${why}`, { path: def.id, details: why }) };
13897
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
13898
+ return { ok: false, ...refusal("fileWrite", `couldn't write the "${def.name}" workflow: ${why2}`, { path: def.id, details: why2 }) };
13765
13899
  }
13766
13900
  return settings ? save2(settings) : { ok: true };
13767
13901
  }
@@ -14717,8 +14851,8 @@ function takeUnchanged(delivery) {
14717
14851
  for (const answer2 of live.answers ?? []) if (!answer2.actedAt && answer2.outcome === "unchanged") answer2.actedAt = now;
14718
14852
  });
14719
14853
  }
14720
- function recordAnswer(deliveryId, outcome, why) {
14721
- const line = why.trim();
14854
+ function recordAnswer(deliveryId, outcome, why2) {
14855
+ const line = why2.trim();
14722
14856
  if (!line) return { ok: false, error: "say in one sentence what the answers did \u2014 an unexplained conclusion is not one." };
14723
14857
  return withStore((store) => {
14724
14858
  const delivery = store.deliveries.find((d2) => d2.deliveryId === deliveryId);
@@ -15533,6 +15667,14 @@ var init_Storyboard = __esm({
15533
15667
  }
15534
15668
  });
15535
15669
 
15670
+ // ../cli/src/components/Workflow.md
15671
+ var Workflow_default;
15672
+ var init_Workflow = __esm({
15673
+ "../cli/src/components/Workflow.md"() {
15674
+ Workflow_default = '# Workflow\n\nShow how a workflow runs with `<Workflow src=".assets/<card id>/workflow.json" label="..." />` alone in a paragraph. Inline and fenced examples remain text.\n\n- **Data**: `akb workflow diagram <workflow id> <card id>` writes the file from the workflow and prints the tag; never write or edit the JSON by hand. Rerun it after changing the workflow.\n';
15675
+ }
15676
+ });
15677
+
15536
15678
  // ../cli/src/lib/components.ts
15537
15679
  function agentComponents(names3, documents = DOCUMENTS) {
15538
15680
  const docs = /* @__PURE__ */ new Map();
@@ -15565,11 +15707,12 @@ var init_components = __esm({
15565
15707
  init_Asset();
15566
15708
  init_Compare();
15567
15709
  init_Storyboard();
15710
+ init_Workflow();
15568
15711
  init_agents();
15569
15712
  init_io();
15570
15713
  init_paths();
15571
15714
  init_workflows();
15572
- DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default };
15715
+ DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default, Workflow: Workflow_default };
15573
15716
  componentDocsText = (docs) => docs.map((doc) => doc.text.trim()).join("\n\n");
15574
15717
  }
15575
15718
  });
@@ -15714,8 +15857,8 @@ import path51 from "node:path";
15714
15857
  function stopReason(deliveryId) {
15715
15858
  const delivery = findDelivery(deliveryId);
15716
15859
  if (!delivery) return void 0;
15717
- const why = firstLine(delivery.review?.stopped?.why);
15718
- if (why) return why;
15860
+ const why2 = firstLine(delivery.review?.stopped?.why);
15861
+ if (why2) return why2;
15719
15862
  const ids = new Set(delivery.sessions);
15720
15863
  const last = readRuns().filter((r2) => ids.has(r2.sessionId) && r2.action === "implement" && r2.status !== "running").at(-1);
15721
15864
  if (!last) return void 0;
@@ -16529,9 +16672,9 @@ function endedDeliveryRefusal(r2, refusals) {
16529
16672
  if (refusals?.has(r2.deliveryId)) return refusals.get(r2.deliveryId);
16530
16673
  const delivery = findDelivery(r2.deliveryId);
16531
16674
  const ended = delivery && delivery.status !== "active" && (delivery.status !== "failed" || delivery.worktree);
16532
- const why = ended ? resumeRefusal(delivery) : void 0;
16533
- refusals?.set(r2.deliveryId, why);
16534
- return why;
16675
+ const why2 = ended ? resumeRefusal(delivery) : void 0;
16676
+ refusals?.set(r2.deliveryId, why2);
16677
+ return why2;
16535
16678
  }
16536
16679
  function retryAsk(r2) {
16537
16680
  if (r2.resumedFrom && r2.action !== "create" || isRetired(r2.action)) return void 0;
@@ -16862,7 +17005,7 @@ function planningSession(cardId2, cwd = REPO_ROOT) {
16862
17005
  function carriedSession(req) {
16863
17006
  const carries = PLANNING.has(req.action) || req.action === "implement" && !!req.carry?.resumeId;
16864
17007
  if (!Number.isInteger(req.id) || !carries) return void 0;
16865
- const fresh = (why) => ({ note: `new session \u2014 ${why}` });
17008
+ const fresh = (why2) => ({ note: `new session \u2014 ${why2}` });
16866
17009
  if (req.session === "new") return fresh("the earlier one is gone, so this step was started again");
16867
17010
  const agent = agentForRun(req);
16868
17011
  const own = planRun(randomUUID5(), REPO_ROOT, agent, req.runtime ? { pin: req.runtime } : {});
@@ -17446,7 +17589,7 @@ var init_sessions = __esm({
17446
17589
  asksPathOf = (sessionId) => path52.join(SESSIONS_DIR, `${sessionId}.asks.json`);
17447
17590
  carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
17448
17591
  canPickUp = (r2) => (r2.status === "error" || r2.status === "interrupted" || r2.status === "stopped") && !(r2.action === "create" && readRuns().some((next) => next.resumedFrom === r2.sessionId));
17449
- neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why) => why.kind === "notInstalled");
17592
+ neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
17450
17593
  lacksSession = (r2) => neverStarted(r2) || !resumeIdOf(r2);
17451
17594
  carriesOn = (r2) => resumesUnder(r2.harness) || restartable(r2);
17452
17595
  CARDLESS = /* @__PURE__ */ new Set(["prune-memory", "review-memory", "review-dismissals", "describe-project"]);
@@ -17827,7 +17970,7 @@ function storyboardAttrs(raw) {
17827
17970
  const text5 = label ? (label[1] ?? label[2]).trim() : "";
17828
17971
  return { src: src[1] ?? src[2], ...text5 ? { label: text5 } : {} };
17829
17972
  }
17830
- function storyboardMarkers(body) {
17973
+ function storyboardMarkers(body, tagOf = storyboardTag) {
17831
17974
  const lines = body.replace(/\r\n/g, "\n").split("\n");
17832
17975
  const found2 = [];
17833
17976
  let fence = null;
@@ -17841,7 +17984,7 @@ function storyboardMarkers(body) {
17841
17984
  fence = delimiter[1];
17842
17985
  return;
17843
17986
  }
17844
- const src = storyboardTag(line);
17987
+ const src = tagOf(line);
17845
17988
  if (src !== null && !lines[i - 1]?.trim() && !lines[i + 1]?.trim()) found2.push({ src, line: i + 1 });
17846
17989
  });
17847
17990
  return found2;
@@ -17858,7 +18001,7 @@ function assetName(src, cardId2, exts, nested = false) {
17858
18001
  if (!name.includes(".") || !exts.includes(ext)) return { expected, actual: `file type ${JSON.stringify(name.includes(".") ? ext : "")}` };
17859
18002
  return { name };
17860
18003
  }
17861
- var TAG2, attr, SRC_ATTR, LABEL_ATTR, SEGMENT2, storyboardTag;
18004
+ var TAG2, attr, SRC_ATTR, LABEL_ATTR, SEGMENT2, storyboardTag, workflowTag;
17862
18005
  var init_storyboard = __esm({
17863
18006
  "../cli/src/lib/storyboard.ts"() {
17864
18007
  "use strict";
@@ -17868,12 +18011,492 @@ var init_storyboard = __esm({
17868
18011
  LABEL_ATTR = attr("label");
17869
18012
  SEGMENT2 = /^(?!\.)[^/\\]+$/;
17870
18013
  storyboardTag = (raw) => storyboardAttrs(raw)?.src ?? null;
18014
+ workflowTag = (raw) => {
18015
+ const m = /^<Workflow\b([^<>]*?)\/>$/.exec(raw.trim());
18016
+ const src = m ? SRC_ATTR.exec(m[1]) : null;
18017
+ return src ? src[1] ?? src[2] : null;
18018
+ };
17871
18019
  }
17872
18020
  });
17873
18021
 
17874
- // ../cli/src/lib/spec-contract.ts
18022
+ // ../artifact-sdk/src/builtin/compare.json
18023
+ var compare_default;
18024
+ var init_compare2 = __esm({
18025
+ "../artifact-sdk/src/builtin/compare.json"() {
18026
+ compare_default = '{\n "name": "compare",\n "title": { "en": "Compare", "zh": "\u5BF9\u6BD4" },\n "types": ["compare"],\n "schema": {\n "type": "object",\n "required": ["a", "b"],\n "properties": { "a": { "type": "string" }, "b": { "type": "string" } }\n },\n "references": [\n { "json": "/a", "types": ["storyboard", "compare"] },\n { "json": "/b", "types": ["storyboard", "compare"] },\n { "json": "/shots", "types": ["storyboard", "compare"] }\n ]\n}\n';
18027
+ }
18028
+ });
18029
+
18030
+ // ../artifact-sdk/src/builtin/html.json
18031
+ var html_default;
18032
+ var init_html = __esm({
18033
+ "../artifact-sdk/src/builtin/html.json"() {
18034
+ html_default = `{
18035
+ "name": "html",
18036
+ "title": { "en": "Page", "zh": "\u9875\u9762" },
18037
+ "types": ["html"],
18038
+ "references": [
18039
+ { "text": "<[a-z][^<>]*?\\\\ssrc\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
18040
+ { "text": "<[a-z][^<>]*?\\\\sposter\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
18041
+ { "text": "<[a-z][^<>]*?\\\\ssrcset\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']", "list": "," },
18042
+ { "text": "<link\\\\b[^<>]*?\\\\shref\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
18043
+ { "text": "url\\\\(\\\\s*[\\"']?([^\\"')]+?)[\\"']?\\\\s*\\\\)" }
18044
+ ]
18045
+ }
18046
+ `;
18047
+ }
18048
+ });
18049
+
18050
+ // ../artifact-sdk/src/builtin/image.json
18051
+ var image_default;
18052
+ var init_image = __esm({
18053
+ "../artifact-sdk/src/builtin/image.json"() {
18054
+ image_default = '{ "name": "image", "title": { "en": "Image", "zh": "\u56FE\u7247" }, "types": ["image"] }\n';
18055
+ }
18056
+ });
18057
+
18058
+ // ../artifact-sdk/src/builtin/markdown.json
18059
+ var markdown_default;
18060
+ var init_markdown = __esm({
18061
+ "../artifact-sdk/src/builtin/markdown.json"() {
18062
+ markdown_default = '{ "name": "markdown", "title": { "en": "Document", "zh": "\u6587\u6863" }, "types": ["markdown"] }\n';
18063
+ }
18064
+ });
18065
+
18066
+ // ../artifact-sdk/src/builtin/storyboard.json
18067
+ var storyboard_default;
18068
+ var init_storyboard2 = __esm({
18069
+ "../artifact-sdk/src/builtin/storyboard.json"() {
18070
+ storyboard_default = '{\n "name": "storyboard",\n "title": { "en": "Storyboard", "zh": "\u5206\u955C" },\n "types": ["storyboard"],\n "schema": {\n "type": "object",\n "anyOf": [{ "required": ["shots"] }, { "required": ["slides"] }],\n "properties": {\n "shots": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": { "frames": { "type": "array", "items": { "type": "object", "properties": { "src": { "type": "string" } } } } }\n }\n },\n "slides": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "preview": { "type": "object", "properties": { "src": { "type": "string" } } },\n "assets": { "type": "array", "items": { "type": "string" } }\n }\n }\n }\n }\n },\n "references": [\n { "json": "/shots/*/frames/*/src" },\n { "json": "/slides/*/preview/src" },\n { "json": "/slides/*/assets/*" }\n ]\n}\n';
18071
+ }
18072
+ });
18073
+
18074
+ // ../artifact-sdk/src/builtin/video.json
18075
+ var video_default;
18076
+ var init_video = __esm({
18077
+ "../artifact-sdk/src/builtin/video.json"() {
18078
+ video_default = '{ "name": "video", "title": { "en": "Video", "zh": "\u89C6\u9891" }, "types": ["video"] }\n';
18079
+ }
18080
+ });
18081
+
18082
+ // ../artifact-sdk/src/builtin/workflow.json
18083
+ var workflow_default;
18084
+ var init_workflow = __esm({
18085
+ "../artifact-sdk/src/builtin/workflow.json"() {
18086
+ workflow_default = '{\n "name": "workflow",\n "title": { "en": "Workflow", "zh": "\u5DE5\u4F5C\u6D41" },\n "types": ["workflow"],\n "schema": {\n "type": "object",\n "required": ["rounds", "land", "scheduled"],\n "properties": {\n "rounds": {\n "type": "array",\n "items": {\n "type": "array",\n "minItems": 1,\n "items": { "type": "object", "required": ["agent", "title"], "properties": { "agent": { "type": "string" }, "title": { "type": "object", "required": ["en"] } } }\n }\n },\n "land": { "type": "array", "items": { "type": "object", "required": ["agent", "title"] } },\n "scheduled": { "type": "array", "items": { "type": "object", "required": ["agent", "title"] } }\n }\n }\n}\n';
18087
+ }
18088
+ });
18089
+
18090
+ // ../artifact-sdk/src/builtin/index.ts
18091
+ var read, builtin_default;
18092
+ var init_builtin = __esm({
18093
+ "../artifact-sdk/src/builtin/index.ts"() {
18094
+ "use strict";
18095
+ init_compare2();
18096
+ init_html();
18097
+ init_image();
18098
+ init_markdown();
18099
+ init_storyboard2();
18100
+ init_video();
18101
+ init_workflow();
18102
+ read = (m) => typeof m === "string" ? JSON.parse(m) : m;
18103
+ builtin_default = [html_default, image_default, video_default, markdown_default, storyboard_default, compare_default, workflow_default].map(read);
18104
+ }
18105
+ });
18106
+
18107
+ // ../artifact-sdk/src/internal/schema.ts
18108
+ function typeOk(type, v) {
18109
+ const types = Array.isArray(type) ? type : [type];
18110
+ return types.some(
18111
+ (t) => t === "null" ? v === null : t === "array" ? Array.isArray(v) : t === "object" ? isObj(v) : t === "integer" ? Number.isInteger(v) : t === "number" ? typeof v === "number" && Number.isFinite(v) : typeof v === t
18112
+ );
18113
+ }
18114
+ function schemaProblem(schema, value, at2 = "") {
18115
+ if (!isObj(schema)) return null;
18116
+ const s = schema;
18117
+ const here = at2 || "/";
18118
+ if (s.type !== void 0 && !typeOk(s.type, value)) return here;
18119
+ if (Array.isArray(s.enum) && !s.enum.some((e2) => JSON.stringify(e2) === JSON.stringify(value))) return here;
18120
+ if (s.const !== void 0 && JSON.stringify(s.const) !== JSON.stringify(value)) return here;
18121
+ if (Array.isArray(s.anyOf) && !s.anyOf.some((x2) => !schemaProblem(x2, value, at2))) return here;
18122
+ if (typeof value === "string") {
18123
+ if (typeof s.minLength === "number" && value.length < s.minLength) return here;
18124
+ if (typeof s.maxLength === "number" && value.length > s.maxLength) return here;
18125
+ if (typeof s.pattern === "string") {
18126
+ try {
18127
+ if (!new RegExp(s.pattern, "u").test(value)) return here;
18128
+ } catch {
18129
+ }
18130
+ }
18131
+ }
18132
+ if (typeof value === "number") {
18133
+ if (typeof s.minimum === "number" && value < s.minimum) return here;
18134
+ if (typeof s.maximum === "number" && value > s.maximum) return here;
18135
+ }
18136
+ if (Array.isArray(value)) {
18137
+ if (typeof s.minItems === "number" && value.length < s.minItems) return here;
18138
+ if (typeof s.maxItems === "number" && value.length > s.maxItems) return here;
18139
+ if (isObj(s.items)) {
18140
+ for (let i = 0; i < value.length; i++) {
18141
+ const bad = schemaProblem(s.items, value[i], `${at2}/${i}`);
18142
+ if (bad) return bad;
18143
+ }
18144
+ }
18145
+ }
18146
+ if (isObj(value)) {
18147
+ const props = isObj(s.properties) ? s.properties : {};
18148
+ if (Array.isArray(s.required)) {
18149
+ for (const k2 of s.required) if (typeof k2 === "string" && !(k2 in value)) return `${at2}/${k2}`;
18150
+ }
18151
+ for (const [k2, v] of Object.entries(value)) {
18152
+ if (k2 in props) {
18153
+ const bad = schemaProblem(props[k2], v, `${at2}/${k2}`);
18154
+ if (bad) return bad;
18155
+ } else if (s.additionalProperties === false) return `${at2}/${k2}`;
18156
+ else if (isObj(s.additionalProperties)) {
18157
+ const bad = schemaProblem(s.additionalProperties, v, `${at2}/${k2}`);
18158
+ if (bad) return bad;
18159
+ }
18160
+ }
18161
+ }
18162
+ return null;
18163
+ }
18164
+ var isObj;
18165
+ var init_schema = __esm({
18166
+ "../artifact-sdk/src/internal/schema.ts"() {
18167
+ "use strict";
18168
+ isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
18169
+ }
18170
+ });
18171
+
18172
+ // ../artifact-sdk/src/internal/manifest.ts
18173
+ function typeOf(data, types) {
18174
+ for (const type of types) if (!schemaProblem(manifestOf(type)?.schema, data)) return { type };
18175
+ if (types.length !== 1) return { type: null };
18176
+ return { type: types[0], problem: `does not match ${types[0]} at ${schemaProblem(manifestOf(types[0])?.schema, data)}` };
18177
+ }
18178
+ function mapJson(node, keys, at2, visit) {
18179
+ if (!keys.length) return typeof node === "string" && node ? visit(node, at2) : node;
18180
+ const [key, ...rest] = keys;
18181
+ if (Array.isArray(node)) {
18182
+ if (key === "*") return node.map((x2, i2) => mapJson(x2, rest, `${at2}/${i2}`, visit));
18183
+ const i = Number(key);
18184
+ return Number.isInteger(i) && i in node ? node.map((x2, j2) => j2 === i ? mapJson(x2, rest, `${at2}/${j2}`, visit) : x2) : node;
18185
+ }
18186
+ if (!isObject(node)) return node;
18187
+ const out = { ...node };
18188
+ for (const k2 of key === "*" ? Object.keys(node) : key in node ? [key] : []) out[k2] = mapJson(node[k2], rest, `${at2}/${k2}`, visit);
18189
+ return out;
18190
+ }
18191
+ function mapText(text5, rule, visit) {
18192
+ let out = "";
18193
+ let last = 0;
18194
+ for (const m of text5.matchAll(new RegExp(rule.text, "gid"))) {
18195
+ const span = m.indices?.[1];
18196
+ if (!span || m[1] === void 0) continue;
18197
+ const line = text5.slice(0, span[0]).split("\n").length;
18198
+ const one = (src) => remote(src) ? src : visit(src, line);
18199
+ const value = rule.list ? m[1].split(rule.list).map((part) => part.replace(/^(\s*)(\S+)/, (_2, space, src) => space + one(src))).join(rule.list) : one(m[1]);
18200
+ out += text5.slice(last, span[0]) + value;
18201
+ last = span[1];
18202
+ }
18203
+ return out + text5.slice(last);
18204
+ }
18205
+ function mapReferences(manifest, content, map2) {
18206
+ for (const rule of manifest?.references ?? []) {
18207
+ const types = rule.types ?? [];
18208
+ if ("json" in rule) {
18209
+ if (typeof content !== "string") content = mapJson(content, rule.json.split("/").filter(Boolean), "", (src, at2) => map2(src, { src, types, text: false, at: at2 || "/" }));
18210
+ } else if (typeof content === "string") {
18211
+ content = mapText(content, rule, (src, line) => map2(src, { src, types, text: true, line }));
18212
+ }
18213
+ }
18214
+ return content;
18215
+ }
18216
+ function referencesOf(manifest, content) {
18217
+ const found2 = [];
18218
+ mapReferences(manifest, content, (src, ref) => (found2.push(ref), src));
18219
+ return found2;
18220
+ }
18221
+ var BUILTINS, manifestOf, isObject, remote;
18222
+ var init_manifest = __esm({
18223
+ "../artifact-sdk/src/internal/manifest.ts"() {
18224
+ "use strict";
18225
+ init_builtin();
18226
+ init_schema();
18227
+ BUILTINS = builtin_default;
18228
+ manifestOf = (type) => BUILTINS.find((m) => m.types.includes(type));
18229
+ isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
18230
+ remote = (src) => !src || /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src);
18231
+ }
18232
+ });
18233
+
18234
+ // ../artifact-sdk/src/internal/references.ts
18235
+ function bodyReferences(body) {
18236
+ const lines = body.replace(/<!--[^]*?-->/g, "").split(/\r?\n/);
18237
+ let fence = "";
18238
+ let inTag = false;
18239
+ const out = [];
18240
+ const visible = [];
18241
+ for (const line of lines) {
18242
+ const delimiter = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
18243
+ if (fence) {
18244
+ if (delimiter && delimiter[0] === fence[0] && delimiter.length >= fence.length) fence = "";
18245
+ visible.push("");
18246
+ continue;
18247
+ }
18248
+ if (delimiter) {
18249
+ fence = delimiter;
18250
+ visible.push("");
18251
+ continue;
18252
+ }
18253
+ const kept2 = inTag || !/^(?: {4}|\t)/.test(line);
18254
+ visible.push(kept2 ? line : "");
18255
+ if (kept2 && /^ {0,3}<(?:Asset|Mockup|Compare|Storyboard|Workflow)\b/.test(line)) inTag = true;
18256
+ if (line.includes("/>")) inTag = false;
18257
+ }
18258
+ const text5 = visible.join("\n").replace(/(`+)[^]*?\1/g, "");
18259
+ const tag = /<(Asset|Mockup|Compare|Storyboard|Workflow)\b([^<>]*?)\/>/g;
18260
+ const blocks = text5.matchAll(/^ {0,3}(?:<(?:Asset|Mockup|Compare|Storyboard|Workflow)\b[^<>]*?\/>[ \t]*(?:\n[ \t]*)?)+$/gm);
18261
+ for (const block of blocks) {
18262
+ const tags = [...block[0].matchAll(tag)];
18263
+ for (const m of tags) {
18264
+ const a2 = {};
18265
+ for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
18266
+ if (m[1] === "Compare") {
18267
+ if (!a2.a || !a2.b) continue;
18268
+ for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types: COMPARE });
18269
+ } else if (a2.src) {
18270
+ out.push({ src: a2.src, types: m[1] === "Storyboard" ? STORYBOARD : m[1] === "Workflow" ? WORKFLOW : [] });
18271
+ if (a2.variants) {
18272
+ try {
18273
+ const v = JSON.parse(a2.variants);
18274
+ if (isObject2(v)) {
18275
+ for (const src of Object.values(v)) if (typeof src === "string" && src) out.push({ src, types: [] });
18276
+ }
18277
+ } catch {
18278
+ }
18279
+ }
18280
+ }
18281
+ }
18282
+ }
18283
+ for (const m of text5.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1], types: [] });
18284
+ return out;
18285
+ }
18286
+ function kindOf(ext) {
18287
+ if (ext === ".tsx" || ext === ".html") return "html";
18288
+ if (ext === ".md" || ext === ".mdx") return "markdown";
18289
+ const type = TYPES[ext] ?? "";
18290
+ if (type.startsWith("image/")) return "image";
18291
+ return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
18292
+ }
18293
+ var STORYBOARD, WORKFLOW, COMPARE, isObject2, bodySources, TYPES;
18294
+ var init_references = __esm({
18295
+ "../artifact-sdk/src/internal/references.ts"() {
18296
+ "use strict";
18297
+ STORYBOARD = ["storyboard"];
18298
+ WORKFLOW = ["workflow"];
18299
+ COMPARE = ["storyboard", "compare"];
18300
+ isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
18301
+ bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
18302
+ TYPES = {
18303
+ ".png": "image/png",
18304
+ ".jpg": "image/jpeg",
18305
+ ".jpeg": "image/jpeg",
18306
+ ".gif": "image/gif",
18307
+ ".webp": "image/webp",
18308
+ ".svg": "image/svg+xml",
18309
+ ".mp4": "video/mp4",
18310
+ ".webm": "video/webm",
18311
+ ".mp3": "audio/mpeg",
18312
+ ".pdf": "application/pdf",
18313
+ ".html": "text/html",
18314
+ ".md": "text/markdown",
18315
+ ".mdx": "text/markdown",
18316
+ ".mov": "video/quicktime",
18317
+ ".wav": "audio/wav",
18318
+ ".m4a": "audio/mp4",
18319
+ ".json": "application/json",
18320
+ ".txt": "text/plain",
18321
+ ".otf": "font/otf",
18322
+ ".ttf": "font/ttf",
18323
+ ".woff": "font/woff",
18324
+ ".woff2": "font/woff2",
18325
+ ".css": "text/css"
18326
+ };
18327
+ }
18328
+ });
18329
+
18330
+ // ../artifact-sdk/src/internal/collect.ts
18331
+ function collect(body, card, host2) {
18332
+ const nodes = /* @__PURE__ */ new Map();
18333
+ const active2 = /* @__PURE__ */ new Set();
18334
+ const out = [];
18335
+ const visit = (src, types, owner) => {
18336
+ const path90 = src.replace(/[?#].*$/, "");
18337
+ let resolved2;
18338
+ try {
18339
+ resolved2 = host2.resolve(path90, owner);
18340
+ } catch (error) {
18341
+ if (owner !== card) return { key: null, error: why(error) };
18342
+ if (!nodes.has(src)) {
18343
+ const node2 = { key: src, file: null, kind: kindAt(path90, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18344
+ nodes.set(src, node2);
18345
+ out.push(node2);
18346
+ }
18347
+ return { key: src, error: nodes.get(src).error };
18348
+ }
18349
+ if (!resolved2) return { key: null };
18350
+ const { key, file } = resolved2;
18351
+ if (active2.has(key)) throw new Error(`${owner}: ${src}: \u8D44\u6E90\u4F9D\u8D56\u5FAA\u73AF`);
18352
+ const json = !!file && extOf(file) === ".json";
18353
+ const held4 = nodes.get(key);
18354
+ if (held4) {
18355
+ if (owner === card) held4.aliases.add(src);
18356
+ if (held4.error || !json || !types.length || held4.kind !== "asset") return { key, error: held4.error };
18357
+ out.splice(out.indexOf(held4), 1);
18358
+ }
18359
+ const node = { key, file, kind: "asset", problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: held4?.aliases ?? /* @__PURE__ */ new Set([key]) };
18360
+ if (owner === card) node.aliases.add(src);
18361
+ nodes.set(key, node);
18362
+ active2.add(key);
18363
+ const child = (ref, from) => {
18364
+ const found2 = visit(ref.src, ref.types, from);
18365
+ if (found2.key) node.dependencies.set(ref.src, found2.key);
18366
+ else if (found2.error) node.problems.push({ src: ref.src, ..."line" in ref ? { line: ref.line } : {}, ..."at" in ref ? { at: ref.at } : {}, message: found2.error });
18367
+ node.error ??= found2.error;
18368
+ };
18369
+ if (file) {
18370
+ if (json) {
18371
+ try {
18372
+ node.data = JSON.parse(host2.read(file));
18373
+ const typed = typeOf(node.data, types);
18374
+ node.kind = typed.type ?? "asset";
18375
+ if (typed.problem) node.problems.push({ src: file, message: `${typed.problem}: ${file}` });
18376
+ } catch {
18377
+ node.problems.push({ src: file, message: `not valid JSON: ${file}` });
18378
+ }
18379
+ } else {
18380
+ node.kind = kindOf(extOf(file));
18381
+ try {
18382
+ if (manifestOf(node.kind)?.references) node.data = host2.read(file);
18383
+ } catch (error) {
18384
+ node.problems.push({ src: file, message: why(error) });
18385
+ }
18386
+ }
18387
+ node.error = node.problems[0]?.message;
18388
+ if (!node.error) for (const ref of referencesOf(manifestOf(node.kind), node.data)) child(ref, file);
18389
+ } else {
18390
+ for (const ref of host2.retained(key)) child(ref, card);
18391
+ }
18392
+ active2.delete(key);
18393
+ out.push(node);
18394
+ return { key, error: node.error };
18395
+ };
18396
+ for (const ref of bodyReferences(body)) visit(ref.src, ref.types, card);
18397
+ const sorted = [];
18398
+ const done2 = /* @__PURE__ */ new Set();
18399
+ const order = (node) => {
18400
+ if (done2.has(node.key)) return;
18401
+ done2.add(node.key);
18402
+ for (const key of node.dependencies.values()) {
18403
+ const child = nodes.get(key);
18404
+ if (child) order(child);
18405
+ }
18406
+ sorted.push(node);
18407
+ };
18408
+ for (const node of out) order(node);
18409
+ return sorted;
18410
+ }
18411
+ var extOf, why, kindAt;
18412
+ var init_collect = __esm({
18413
+ "../artifact-sdk/src/internal/collect.ts"() {
18414
+ "use strict";
18415
+ init_manifest();
18416
+ init_references();
18417
+ extOf = (file) => /\.[^./\\]+$/.exec(file)?.[0].toLowerCase() ?? "";
18418
+ why = (error) => error instanceof Error ? error.message : String(error);
18419
+ kindAt = (src, types) => extOf(src) === ".json" ? types[0] ?? "asset" : kindOf(extOf(src));
18420
+ }
18421
+ });
18422
+
18423
+ // ../cli/src/lib/dress-page.ts
17875
18424
  import fs51 from "node:fs";
17876
18425
  import path54 from "node:path";
18426
+ function dressPage(file) {
18427
+ const folder = path54.dirname(file);
18428
+ const html = fs51.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
18429
+ const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
18430
+ if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
18431
+ const at3 = path54.resolve(folder, href);
18432
+ if (!at3.startsWith(folder + path54.sep) || !fs51.existsSync(at3)) return tag;
18433
+ const css = fs51.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${path54.relative(folder, path54.resolve(path54.dirname(at3), src)).split(path54.sep).join("/")}${quote})`);
18434
+ return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
18435
+ });
18436
+ const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
18437
+ return /<!doctype\b|<html[\s>]|<head[\s>]/i.test(html) ? html.slice(0, at2) + head + html.slice(at2) : `<!doctype html><html><head>${head}</head><body>${html}</body></html>`;
18438
+ }
18439
+ var CSP, head, referenceText;
18440
+ var init_dress_page = __esm({
18441
+ "../cli/src/lib/dress-page.ts"() {
18442
+ "use strict";
18443
+ 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'";
18444
+ 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>`;
18445
+ referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs51.readFileSync(file, "utf8");
18446
+ }
18447
+ });
18448
+
18449
+ // ../cli/src/lib/preview-files.ts
18450
+ import fs52 from "node:fs";
18451
+ import path55 from "node:path";
18452
+ function resolver(card, id) {
18453
+ const roots = [KANBAN, path55.join(ASSETS, String(id)), path55.join(MOCKUPS, String(id))];
18454
+ const real2 = (p2) => fs52.existsSync(p2) ? fs52.realpathSync(p2) : p2;
18455
+ const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path55.sep));
18456
+ return (src, owner) => {
18457
+ if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
18458
+ if (path55.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
18459
+ const held4 = /^\.(assets|mockups)\//.exec(src);
18460
+ const file = held4 ? path55.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path55.resolve(path55.dirname(owner), src);
18461
+ if (!inside2(path55.resolve(file)) || fs52.existsSync(file) && !inside2(fs52.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
18462
+ if (!fs52.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
18463
+ return { key: fs52.realpathSync(file), file };
18464
+ };
18465
+ }
18466
+ function validatePreviewFiles(card, id, text5) {
18467
+ const resolve2 = resolver(card, id);
18468
+ const errors = [];
18469
+ const graph = collect(text5, card, {
18470
+ resolve: (src, owner) => {
18471
+ if (owner !== card) return resolve2(src, owner);
18472
+ try {
18473
+ return resolve2(src, owner);
18474
+ } catch {
18475
+ return null;
18476
+ }
18477
+ },
18478
+ read: referenceText,
18479
+ retained: () => []
18480
+ });
18481
+ for (const node of graph) {
18482
+ for (const p2 of node.problems) {
18483
+ errors.push({ file: rel(node.file ?? card), line: p2.line ?? 1, rule: "preview-file", message: `${p2.at ? `${p2.at}: ` : ""}${p2.src}: ${p2.message}. Fix the reference or add the file.` });
18484
+ }
18485
+ }
18486
+ return errors;
18487
+ }
18488
+ var init_preview_files = __esm({
18489
+ "../cli/src/lib/preview-files.ts"() {
18490
+ "use strict";
18491
+ init_collect();
18492
+ init_dress_page();
18493
+ init_paths();
18494
+ }
18495
+ });
18496
+
18497
+ // ../cli/src/lib/spec-contract.ts
18498
+ import fs53 from "node:fs";
18499
+ import path56 from "node:path";
17877
18500
  function scanCardLines(lines, start = 0) {
17878
18501
  const visible = lines.map(() => "");
17879
18502
  let fence = null;
@@ -17906,18 +18529,18 @@ function scanCardLines(lines, start = 0) {
17906
18529
  }
17907
18530
  function snapshotSpecs() {
17908
18531
  const out = /* @__PURE__ */ new Map();
17909
- if (!fs51.existsSync(TODO)) return out;
18532
+ if (!fs53.existsSync(TODO)) return out;
17910
18533
  for (const file of walkMd(TODO)) {
17911
- if (isLegacyRecurring(path54.relative(TODO, file))) continue;
17912
- const id = idPrefix(path54.basename(file) === "root.md" ? path54.basename(path54.dirname(file)) : path54.basename(file));
17913
- if (id !== null) out.set(file, { id, text: fs51.readFileSync(file, "utf8") });
18534
+ if (isLegacyRecurring(path56.relative(TODO, file))) continue;
18535
+ const id = idPrefix(path56.basename(file) === "root.md" ? path56.basename(path56.dirname(file)) : path56.basename(file));
18536
+ if (id !== null) out.set(file, { id, text: fs53.readFileSync(file, "utf8") });
17914
18537
  }
17915
18538
  return out;
17916
18539
  }
17917
18540
  function enclosingGroups(file) {
17918
18541
  const ids = [];
17919
18542
  for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
17920
- const id = idPrefix(path54.basename(path54.dirname(root2)));
18543
+ const id = idPrefix(path56.basename(path56.dirname(root2)));
17921
18544
  if (id !== null) ids.push(id);
17922
18545
  }
17923
18546
  return ids;
@@ -18015,8 +18638,8 @@ function validateSpec(file, text5, id) {
18015
18638
  if (device !== void 0 && device !== "mobile" && device !== "desktop") add(i + 1, "mockup-device", `device="${device}" is not a device. Use device="mobile" or device="desktop".`);
18016
18639
  const src = line.match(/\bsrc="([^"]*)"/)?.[1] ?? "";
18017
18640
  const variants = line.match(/\bvariants='([^']*)'/)?.[1];
18018
- const why = variants === void 0 ? null : variantsProblem(variants, src, id);
18019
- if (why) add(i + 1, "mockup-variants", why);
18641
+ const why2 = variants === void 0 ? null : variantsProblem(variants, src, id);
18642
+ if (why2) add(i + 1, "mockup-variants", why2);
18020
18643
  else if (id !== void 0 && src.startsWith(".assets/") && !inside(ASSETS, src.slice(".assets/".length))) {
18021
18644
  add(i + 1, "asset-src", `src="${src}" names no file. Write it as ${rel(ASSETS)}/${src.slice(".assets/".length)}, or fix the path.`);
18022
18645
  }
@@ -18024,13 +18647,16 @@ function validateSpec(file, text5, id) {
18024
18647
  if (/^\s*<Storyboard\b/.test(line) && (storyboardTag(line) === null || lines[i - 1]?.trim() || lines[i + 1]?.trim())) {
18025
18648
  add(i + 1, "storyboard-block", 'Put one self-closing <Storyboard src=".assets/<card id>/storyboard.json" /> tag on its own line, with blank lines around it.');
18026
18649
  }
18650
+ if (/^\s*<Workflow\b/.test(line) && (workflowTag(line) === null || !/\blabel="[^"]+"/.test(line) || lines[i - 1]?.trim() || lines[i + 1]?.trim())) {
18651
+ add(i + 1, "workflow-block", 'Put one self-closing <Workflow src=".assets/<card id>/workflow.json" label="..." /> tag on its own line, with blank lines around it.');
18652
+ }
18027
18653
  if (/^\s*<Compare\b/.test(line)) {
18028
18654
  const attrs = compareAttrs(line);
18029
18655
  if (!attrs || lines[i - 1]?.trim() || lines[i + 1]?.trim()) add(i + 1, "compare-block", 'Put one self-closing <Compare a="..." b="..." label="..." /> tag on its own line, with blank lines around it.');
18030
18656
  else if (!attrs.a || !attrs.b || !attrs.label) add(i + 1, "compare-attributes", 'Add non-empty a="...", b="..." and label="..." attributes to the Compare tag.');
18031
18657
  else if (id !== void 0) {
18032
- const why = compareProblem(attrs, id);
18033
- if (why) add(i + 1, why.rule, why.message);
18658
+ const why2 = compareProblem(attrs, id);
18659
+ if (why2) add(i + 1, why2.rule, why2.message);
18034
18660
  }
18035
18661
  }
18036
18662
  }
@@ -18067,14 +18693,14 @@ function validateSpec(file, text5, id) {
18067
18693
  const next = headings.find((h3) => h3.line > todo.line)?.line ?? lines.length + 1;
18068
18694
  if (!visible.slice(todo.line, next - 1).some((line) => /^\s*[-*+]\s*\[[ xX]?\]/.test(line))) add(todo.line, "todos", "## Todo needs at least one checkbox step, for example - [ ] Implement the requested behavior.");
18069
18695
  }
18070
- if (id !== void 0) errors.push(...validateStoryboards(file, id, text5));
18696
+ if (id !== void 0) errors.push(...validateStoryboards(file, id, text5), ...validatePreviewFiles(file, id, text5));
18071
18697
  return errors;
18072
18698
  }
18073
18699
  function inside(dir, name) {
18074
18700
  try {
18075
- const root2 = fs51.realpathSync(dir);
18076
- const real2 = fs51.realpathSync(path54.join(dir, name));
18077
- return real2.startsWith(root2 + path54.sep) && fs51.statSync(real2).isFile() ? real2 : null;
18701
+ const root2 = fs53.realpathSync(dir);
18702
+ const real2 = fs53.realpathSync(path56.join(dir, name));
18703
+ return real2.startsWith(root2 + path56.sep) && fs53.statSync(real2).isFile() ? real2 : null;
18078
18704
  } catch {
18079
18705
  return null;
18080
18706
  }
@@ -18092,7 +18718,7 @@ function variantsProblem(raw, src, id) {
18092
18718
  if (files2.length < 2 || !files2.every((f2) => typeof f2 === "string" && f2)) return `variants needs at least two labels, each naming a file. ${shape}`;
18093
18719
  if (!files2.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
18094
18720
  if (id === void 0) return null;
18095
- const dir = path54.join(ASSETS, String(id));
18721
+ const dir = path56.join(ASSETS, String(id));
18096
18722
  for (const f2 of files2) {
18097
18723
  const parts = f2.split("/");
18098
18724
  if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
@@ -18102,7 +18728,7 @@ function variantsProblem(raw, src, id) {
18102
18728
  return null;
18103
18729
  }
18104
18730
  function compareProblem(attrs, id) {
18105
- const dir = path54.join(ASSETS, String(id));
18731
+ const dir = path56.join(ASSETS, String(id));
18106
18732
  const src = (message) => ({ rule: "compare-src", message });
18107
18733
  const shots = (message) => ({ rule: "compare-shots", message });
18108
18734
  for (const side of ["a", "b"]) {
@@ -18116,23 +18742,23 @@ function compareProblem(attrs, id) {
18116
18742
  if (!script && kind !== compareKind(attrs.b)) return src("Compare a and b must both be images or both be videos.");
18117
18743
  if (attrs.shots === void 0) return script ? shots('shots is required when b is a storyboard. Add shots="..." naming a storyboard or shots list of video a.') : null;
18118
18744
  if (kind !== "video") return shots("shots is for videos only. Remove it from this Compare tag.");
18119
- const read4 = (at2) => {
18745
+ const read5 = (at2) => {
18120
18746
  const named2 = assetName(at2, id, ["json"]);
18121
18747
  if (!("name" in named2)) return { message: `Compare shots is ${named2.actual}; expected ${named2.expected}.` };
18122
18748
  const file = inside(dir, named2.name);
18123
18749
  if (!file) return { message: `Compare shots ${at2} names no file in this card's asset folder. Write the JSON there or fix the path.` };
18124
18750
  try {
18125
- return { data: JSON.parse(fs51.readFileSync(file, "utf8")) };
18751
+ return { data: JSON.parse(fs53.readFileSync(file, "utf8")) };
18126
18752
  } catch {
18127
18753
  return { message: `${at2} is not valid JSON.` };
18128
18754
  }
18129
18755
  };
18130
- const list = read4(attrs.shots);
18756
+ const list = read5(attrs.shots);
18131
18757
  if ("message" in list) return shots(list.message);
18132
- const why = Array.isArray(list.data) ? shotsProblem(list.data) : storyboardProblem(list.data);
18133
- if (why) return shots(`${attrs.shots}: ${why}`);
18758
+ const why2 = Array.isArray(list.data) ? shotsProblem(list.data) : storyboardProblem(list.data);
18759
+ if (why2) return shots(`${attrs.shots}: ${why2}`);
18134
18760
  if (!script) return null;
18135
- const b2 = read4(attrs.b);
18761
+ const b2 = read5(attrs.b);
18136
18762
  if ("message" in b2) return src(b2.message);
18137
18763
  const bad = storyboardProblem(b2.data);
18138
18764
  if (bad) return src(`${attrs.b}: ${bad}`);
@@ -18142,12 +18768,17 @@ function compareProblem(attrs, id) {
18142
18768
  }
18143
18769
  function validateStoryboards(file, id, text5) {
18144
18770
  const errors = [];
18145
- const dir = path54.join(ASSETS, String(id));
18146
- for (const marker of storyboardMarkers(text5)) {
18147
- const named2 = assetName(marker.src, id, ["json"]);
18148
- const add = (message) => errors.push({ file: rel(file), line: marker.line, rule: "storyboard-src", message });
18149
- if (!("name" in named2)) add(`Storyboard src is ${named2.actual}; expected ${named2.expected}.`);
18150
- else if (!inside(dir, named2.name)) add(`Storyboard src ${marker.src} names no file in this card's asset folder. Write the JSON there or fix the path.`);
18771
+ const dir = path56.join(ASSETS, String(id));
18772
+ for (const [tag, tagOf, rule, fix] of [
18773
+ ["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
18774
+ ["Workflow", workflowTag, "workflow-src", "Write it with `akb workflow diagram <workflow id> <card id>` or fix the path."]
18775
+ ]) {
18776
+ for (const marker of storyboardMarkers(text5, tagOf)) {
18777
+ const named2 = assetName(marker.src, id, ["json"]);
18778
+ const add = (message) => errors.push({ file: rel(file), line: marker.line, rule, message });
18779
+ if (!("name" in named2)) add(`${tag} src is ${named2.actual}; expected ${named2.expected}.`);
18780
+ else if (!inside(dir, named2.name)) add(`${tag} src ${marker.src} names no file in this card's asset folder. ${fix}`);
18781
+ }
18151
18782
  }
18152
18783
  return errors;
18153
18784
  }
@@ -18208,19 +18839,20 @@ var init_spec_contract = __esm({
18208
18839
  init_paths();
18209
18840
  init_compare();
18210
18841
  init_storyboard();
18842
+ init_preview_files();
18211
18843
  init_validate();
18212
18844
  }
18213
18845
  });
18214
18846
 
18215
18847
  // ../cli/src/lib/reconcile.ts
18216
- import fs52 from "node:fs";
18217
- import path55 from "node:path";
18848
+ import fs54 from "node:fs";
18849
+ import path57 from "node:path";
18218
18850
  function liveIds() {
18219
18851
  const ids = /* @__PURE__ */ new Set();
18220
18852
  for (const file of walkMd(TODO)) {
18221
- const base = path55.basename(file);
18853
+ const base = path57.basename(file);
18222
18854
  if (base === "README.md") continue;
18223
- const id = base === "root.md" ? idPrefix(path55.basename(path55.dirname(file))) : idPrefix(base);
18855
+ const id = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
18224
18856
  if (id != null) ids.add(id);
18225
18857
  }
18226
18858
  return ids;
@@ -18228,16 +18860,16 @@ function liveIds() {
18228
18860
  function indexableCards() {
18229
18861
  const out = [];
18230
18862
  for (const dir of walkDirs(TODO)) {
18231
- const id = idPrefix(path55.basename(dir));
18232
- if (id != null && fs52.existsSync(path55.join(dir, "root.md"))) {
18233
- out.push({ id, rel: path55.join(path55.relative(TODO, dir), "root.md").split(path55.sep).join("/") });
18863
+ const id = idPrefix(path57.basename(dir));
18864
+ if (id != null && fs54.existsSync(path57.join(dir, "root.md"))) {
18865
+ out.push({ id, rel: path57.join(path57.relative(TODO, dir), "root.md").split(path57.sep).join("/") });
18234
18866
  }
18235
18867
  }
18236
18868
  for (const file of walkMd(TODO)) {
18237
- const base = path55.basename(file);
18869
+ const base = path57.basename(file);
18238
18870
  if (base === "README.md" || base === "root.md") continue;
18239
- const relTODO = path55.relative(TODO, file);
18240
- const segs = relTODO.split(path55.sep);
18871
+ const relTODO = path57.relative(TODO, file);
18872
+ const segs = relTODO.split(path57.sep);
18241
18873
  if (segs.length !== 1) continue;
18242
18874
  const id = idPrefix(base);
18243
18875
  if (id != null) out.push({ id, rel: segs.join("/") });
@@ -18246,7 +18878,7 @@ function indexableCards() {
18246
18878
  }
18247
18879
  function readmeComplaints(fix) {
18248
18880
  const said3 = [];
18249
- const lines = fs52.readFileSync(README, "utf8").split("\n");
18881
+ const lines = fs54.readFileSync(README, "utf8").split("\n");
18250
18882
  const indexed = /* @__PURE__ */ new Set();
18251
18883
  let fixed = 0;
18252
18884
  for (let i = 0; i < lines.length; i++) {
@@ -18255,13 +18887,13 @@ function readmeComplaints(fix) {
18255
18887
  const id = Number(m[1]);
18256
18888
  const linkPath = m[2];
18257
18889
  indexed.add(id);
18258
- if (fs52.existsSync(path55.join(TODO, linkPath))) continue;
18890
+ if (fs54.existsSync(path57.join(TODO, linkPath))) continue;
18259
18891
  const found2 = locate(id);
18260
18892
  if (!found2) {
18261
18893
  said3.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
18262
18894
  continue;
18263
18895
  }
18264
- const want = (found2.kind === "group" ? path55.join(found2.rel, "root.md") : found2.rel).split(path55.sep).join("/");
18896
+ const want = (found2.kind === "group" ? path57.join(found2.rel, "root.md") : found2.rel).split(path57.sep).join("/");
18265
18897
  if (want === linkPath) continue;
18266
18898
  if (!fix) {
18267
18899
  said3.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
@@ -18271,7 +18903,7 @@ function readmeComplaints(fix) {
18271
18903
  said3.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
18272
18904
  fixed++;
18273
18905
  }
18274
- if (fixed) fs52.writeFileSync(README, lines.join("\n"));
18906
+ if (fixed) fs54.writeFileSync(README, lines.join("\n"));
18275
18907
  for (const c2 of indexableCards()) {
18276
18908
  if (!indexed.has(c2.id)) {
18277
18909
  said3.push(`card ${c2.rel} (#${c2.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
@@ -18283,11 +18915,11 @@ function crossRefComplaints() {
18283
18915
  const said3 = [];
18284
18916
  const live = liveIds();
18285
18917
  for (const file of walkMd(TODO)) {
18286
- const base = path55.basename(file);
18918
+ const base = path57.basename(file);
18287
18919
  if (base === "README.md") continue;
18288
- const ownerId = base === "root.md" ? idPrefix(path55.basename(path55.dirname(file))) : idPrefix(base);
18920
+ const ownerId = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
18289
18921
  if (ownerId == null) continue;
18290
- const { meta } = parseFrontmatter(fs52.readFileSync(file, "utf8"));
18922
+ const { meta } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
18291
18923
  if (!meta) continue;
18292
18924
  for (const field2 of ["blocked_by", "related"]) {
18293
18925
  for (const ref of meta[field2] || []) {
@@ -18300,11 +18932,11 @@ function crossRefComplaints() {
18300
18932
  return said3;
18301
18933
  }
18302
18934
  function reconcileBoard() {
18303
- if (!fs52.existsSync(README)) return;
18935
+ if (!fs54.existsSync(README)) return;
18304
18936
  for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
18305
18937
  }
18306
18938
  function boardComplaints() {
18307
- if (!fs52.existsSync(README)) return [];
18939
+ if (!fs54.existsSync(README)) return [];
18308
18940
  try {
18309
18941
  return [...readmeComplaints(false), ...crossRefComplaints()];
18310
18942
  } catch {
@@ -18324,8 +18956,8 @@ var init_reconcile = __esm({
18324
18956
  });
18325
18957
 
18326
18958
  // ../cli/src/commands/card.ts
18327
- import fs53 from "node:fs";
18328
- import path56 from "node:path";
18959
+ import fs55 from "node:fs";
18960
+ import path58 from "node:path";
18329
18961
  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>") {
18330
18962
  return [
18331
18963
  summary,
@@ -18351,7 +18983,7 @@ function bodyFromFile(opts) {
18351
18983
  if (opts.body === false) die("pass --body-file or --no-body, not both");
18352
18984
  let text5;
18353
18985
  try {
18354
- text5 = fs53.readFileSync(opts.bodyFile, "utf8");
18986
+ text5 = fs55.readFileSync(opts.bodyFile, "utf8");
18355
18987
  } catch {
18356
18988
  die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
18357
18989
  }
@@ -18431,20 +19063,20 @@ function cmdCreate(opts) {
18431
19063
  const start = opts.id;
18432
19064
  const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
18433
19065
  const fileRel = `${start}-${slug2}.md`;
18434
- const file = path56.join(TODO, fileRel);
19066
+ const file = path58.join(TODO, fileRel);
18435
19067
  const held4 = locate(start) ?? locateArchived(start);
18436
- if (held4 && path56.basename(held4.target) === `${start}-${slug2}.md`) {
19068
+ if (held4 && path58.basename(held4.target) === `${start}-${slug2}.md`) {
18437
19069
  say(start);
18438
19070
  say(` ${rel(held4.target)} was already written`);
18439
19071
  return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
18440
19072
  }
18441
19073
  if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
18442
- if (fs53.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
19074
+ if (fs55.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
18443
19075
  countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
18444
19076
  const meta = { title, priority, status: "todo", blocked_by, related, modules, workflow, previews, stages, triage, source, questions };
18445
19077
  const scaffolded = !written && opts.body !== false;
18446
19078
  const body = written ?? (scaffolded ? defaultBody() : "");
18447
- fs53.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
19079
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
18448
19080
  const indexed = addReadmeRef(start, title, fileRel);
18449
19081
  say(start);
18450
19082
  say(
@@ -18491,8 +19123,8 @@ function cmdUpdate(id, flags) {
18491
19123
  if (creating) die(creating, { kind: "card-being-created", id });
18492
19124
  const found2 = locate(id);
18493
19125
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
18494
- const file = found2.kind === "group" ? path56.join(found2.target, "root.md") : found2.target;
18495
- const { meta, body } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
19126
+ const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
19127
+ const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
18496
19128
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
18497
19129
  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");
18498
19130
  if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
@@ -18566,26 +19198,26 @@ function cmdUpdate(id, flags) {
18566
19198
  meta.status = "todo";
18567
19199
  changes.push("status\u2192todo (open questions)");
18568
19200
  }
18569
- const curRel = path56.relative(TODO, file);
19201
+ const curRel = path58.relative(TODO, file);
18570
19202
  const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
18571
- let base = path56.basename(file);
19203
+ let base = path58.basename(file);
18572
19204
  if (flags.slug !== void 0) {
18573
19205
  if (found2.kind === "group") die("renaming a group root by script is not supported");
18574
19206
  base = `${id}-${slugify(flags.slug)}.md`;
18575
19207
  }
18576
- const destRel = path56.join(path56.dirname(curRel), base);
18577
- const dest = path56.join(TODO, destRel);
19208
+ const destRel = path58.join(path58.dirname(curRel), base);
19209
+ const dest = path58.join(TODO, destRel);
18578
19210
  const moving = dest !== file;
18579
- if (moving && fs53.existsSync(dest)) die(`${rel(dest)} already exists`);
18580
- fs53.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
18581
- if (moving) fs53.renameSync(file, dest);
19211
+ if (moving && fs55.existsSync(dest)) die(`${rel(dest)} already exists`);
19212
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19213
+ if (moving) fs55.renameSync(file, dest);
18582
19214
  if (isSubtask) {
18583
19215
  if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
18584
- if (moving) changes.push(`renamed \u2192 ${destRel.split(path56.sep).join("/")}`);
19216
+ if (moving) changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
18585
19217
  } else if (moving) {
18586
19218
  stripReadmeRefs({ kind: "file", rel: curRel });
18587
19219
  addReadmeRef(id, meta.title, destRel);
18588
- changes.push(`renamed \u2192 ${destRel.split(path56.sep).join("/")}`);
19220
+ changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
18589
19221
  } else if (changes.includes("title")) {
18590
19222
  stripReadmeRefs({ kind: "file", rel: curRel });
18591
19223
  addReadmeRef(id, meta.title, curRel);
@@ -18597,8 +19229,8 @@ function cmdUpdateQuestions(id, input) {
18597
19229
  const ops = readQuestionOps(input.ops ?? []);
18598
19230
  const found2 = locate(id);
18599
19231
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
18600
- const file = found2.kind === "group" ? path56.join(found2.target, "root.md") : found2.target;
18601
- const { meta, body } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
19232
+ const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
19233
+ const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
18602
19234
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
18603
19235
  if (insideRun() && ops.some((op) => op.kind === "skip" || op.kind === "unskip")) {
18604
19236
  die("only the user skips or reopens a question \u2014 a run leaves questions for them to answer");
@@ -18671,7 +19303,7 @@ function cmdUpdateQuestions(id, input) {
18671
19303
  meta.status = "todo";
18672
19304
  changes.push("status\u2192todo (open questions)");
18673
19305
  }
18674
- fs53.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19306
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
18675
19307
  for (const kind of closed2) countBoardEvent(kind);
18676
19308
  settleDelivery2(id, skipped, unskipped);
18677
19309
  say(
@@ -18746,13 +19378,13 @@ var init_config_template = __esm({
18746
19378
  });
18747
19379
 
18748
19380
  // ../cli/src/lib/agent/local.ts
18749
- import fs54 from "node:fs";
18750
- import path57 from "node:path";
19381
+ import fs56 from "node:fs";
19382
+ import path59 from "node:path";
18751
19383
  function takeLocalModels(board2) {
18752
- const file = path57.join(board2, ".local.json");
19384
+ const file = path59.join(board2, ".local.json");
18753
19385
  let held4;
18754
19386
  try {
18755
- held4 = configBlock(JSON.parse(fs54.readFileSync(file, "utf8")));
19387
+ held4 = configBlock(JSON.parse(fs56.readFileSync(file, "utf8")));
18756
19388
  } catch {
18757
19389
  return {};
18758
19390
  }
@@ -18770,7 +19402,7 @@ function takeLocalModels(board2) {
18770
19402
  }
18771
19403
  if (!Object.keys(agents).length) return out;
18772
19404
  delete held4.agents;
18773
- fs54.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19405
+ fs56.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
18774
19406
  return out;
18775
19407
  }
18776
19408
  var LOCAL_IGNORE_LINE;
@@ -18831,12 +19463,12 @@ var init_identity2 = __esm({
18831
19463
  });
18832
19464
 
18833
19465
  // ../cli/src/lib/signals/migrate.ts
18834
- import fs55 from "node:fs";
18835
- import path58 from "node:path";
19466
+ import fs57 from "node:fs";
19467
+ import path60 from "node:path";
18836
19468
  function readHandled() {
18837
19469
  let text5;
18838
19470
  try {
18839
- text5 = fs55.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19471
+ text5 = fs57.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
18840
19472
  } catch {
18841
19473
  return [];
18842
19474
  }
@@ -18853,57 +19485,57 @@ function readHandled() {
18853
19485
  return held4;
18854
19486
  }
18855
19487
  function lift(from, into) {
18856
- fs55.mkdirSync(into, { recursive: true });
18857
- fs55.renameSync(from, path58.join(into, freeName(into, path58.basename(from))));
19488
+ fs57.mkdirSync(into, { recursive: true });
19489
+ fs57.renameSync(from, path60.join(into, freeName(into, path60.basename(from))));
18858
19490
  }
18859
19491
  function repoint(dir, from, into) {
18860
19492
  let entries;
18861
19493
  try {
18862
- entries = fs55.readdirSync(dir, { withFileTypes: true });
19494
+ entries = fs57.readdirSync(dir, { withFileTypes: true });
18863
19495
  } catch {
18864
19496
  return;
18865
19497
  }
18866
19498
  for (const entry of entries) {
18867
19499
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
18868
- const file = path58.join(dir, entry.name);
18869
- const text5 = fs55.readFileSync(file, "utf8");
18870
- if (text5.includes(from)) fs55.writeFileSync(file, text5.split(from).join(into));
19500
+ const file = path60.join(dir, entry.name);
19501
+ const text5 = fs57.readFileSync(file, "utf8");
19502
+ if (text5.includes(from)) fs57.writeFileSync(file, text5.split(from).join(into));
18871
19503
  }
18872
19504
  }
18873
19505
  function dropIfEmpty2(dir) {
18874
19506
  try {
18875
- fs55.rmdirSync(dir);
19507
+ fs57.rmdirSync(dir);
18876
19508
  } catch {
18877
19509
  }
18878
19510
  }
18879
19511
  function liftInbox() {
18880
- if (!fs55.existsSync(SIGNALS_OLD_INBOX)) return;
18881
- const oldFiles = path58.join(SIGNALS_OLD_INBOX, "files");
18882
- if (fs55.existsSync(oldFiles)) {
18883
- for (const entry of fs55.readdirSync(oldFiles, { withFileTypes: true })) {
18884
- if (entry.isFile()) lift(path58.join(oldFiles, entry.name), SIGNALS_FILES);
19512
+ if (!fs57.existsSync(SIGNALS_OLD_INBOX)) return;
19513
+ const oldFiles = path60.join(SIGNALS_OLD_INBOX, "files");
19514
+ if (fs57.existsSync(oldFiles)) {
19515
+ for (const entry of fs57.readdirSync(oldFiles, { withFileTypes: true })) {
19516
+ if (entry.isFile()) lift(path60.join(oldFiles, entry.name), SIGNALS_FILES);
18885
19517
  }
18886
19518
  dropIfEmpty2(oldFiles);
18887
19519
  }
18888
19520
  const held4 = new Set(readFolder(TRIAGE).map((signal2) => signal2.sourceId));
18889
- for (const entry of fs55.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19521
+ for (const entry of fs57.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
18890
19522
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
18891
- const from = path58.join(SIGNALS_OLD_INBOX, entry.name);
19523
+ const from = path60.join(SIGNALS_OLD_INBOX, entry.name);
18892
19524
  const item = parse(from);
18893
19525
  if (item && held4.has(item.sourceId)) {
18894
- fs55.rmSync(from, { force: true });
19526
+ fs57.rmSync(from, { force: true });
18895
19527
  continue;
18896
19528
  }
18897
19529
  if (item) held4.add(item.sourceId);
18898
19530
  lift(from, TRIAGE);
18899
19531
  }
18900
- const wasAt = asWritten(path58.join(SIGNALS_OLD_INBOX, "files"));
19532
+ const wasAt = asWritten(path60.join(SIGNALS_OLD_INBOX, "files"));
18901
19533
  const nowAt = asWritten(SIGNALS_FILES);
18902
19534
  for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
18903
19535
  dropIfEmpty2(SIGNALS_OLD_INBOX);
18904
19536
  }
18905
19537
  function liftHandled() {
18906
- if (!fs55.existsSync(SIGNALS_OLD_HANDLED)) return;
19538
+ if (!fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
18907
19539
  const lines = readHandled();
18908
19540
  const held4 = /* @__PURE__ */ new Set([
18909
19541
  ...readFolder(TRIAGE).map((signal2) => signal2.sourceId),
@@ -18913,7 +19545,7 @@ function liftHandled() {
18913
19545
  for (const { sourceId, when } of lines) {
18914
19546
  if (held4.has(sourceId)) continue;
18915
19547
  held4.add(sourceId);
18916
- fs55.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19548
+ fs57.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
18917
19549
  const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
18918
19550
  const front = [
18919
19551
  "---",
@@ -18923,13 +19555,13 @@ function liftHandled() {
18923
19555
  "---",
18924
19556
  ""
18925
19557
  ];
18926
- fs55.writeFileSync(path58.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19558
+ fs57.writeFileSync(path60.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
18927
19559
  `);
18928
19560
  }
18929
- fs55.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19561
+ fs57.rmSync(SIGNALS_OLD_HANDLED, { force: true });
18930
19562
  }
18931
19563
  function migrateTriage() {
18932
- if (!fs55.existsSync(SIGNALS_OLD_INBOX) && !fs55.existsSync(SIGNALS_OLD_HANDLED)) return;
19564
+ if (!fs57.existsSync(SIGNALS_OLD_INBOX) && !fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
18933
19565
  try {
18934
19566
  liftInbox();
18935
19567
  liftHandled();
@@ -18944,13 +19576,13 @@ var init_migrate = __esm({
18944
19576
  init_yaml();
18945
19577
  init_inbox();
18946
19578
  HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
18947
- asWritten = (dir) => `${rel(dir).split(path58.sep).join("/")}/`;
19579
+ asWritten = (dir) => `${rel(dir).split(path60.sep).join("/")}/`;
18948
19580
  }
18949
19581
  });
18950
19582
 
18951
19583
  // ../cli/src/lib/signals/add.ts
18952
- import fs56 from "node:fs";
18953
- import path59 from "node:path";
19584
+ import fs58 from "node:fs";
19585
+ import path61 from "node:path";
18954
19586
  import { createHash as createHash4 } from "node:crypto";
18955
19587
  function linkTitle(url) {
18956
19588
  let at2;
@@ -18963,7 +19595,7 @@ function linkTitle(url) {
18963
19595
  return oneLine(where) || url.slice(0, TITLE_MAX);
18964
19596
  }
18965
19597
  function asText(file) {
18966
- const ext = path59.extname(file.name).toLowerCase();
19598
+ const ext = path61.extname(file.name).toLowerCase();
18967
19599
  if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
18968
19600
  try {
18969
19601
  const text5 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
@@ -18973,9 +19605,9 @@ function asText(file) {
18973
19605
  }
18974
19606
  }
18975
19607
  function fileName2(name, data) {
18976
- const base = path59.basename(name);
18977
- const ext = path59.extname(base).toLowerCase().slice(0, 12);
18978
- const word = path59.basename(base, path59.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
19608
+ const base = path61.basename(name);
19609
+ const ext = path61.extname(base).toLowerCase().slice(0, 12);
19610
+ const word = path61.basename(base, path61.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
18979
19611
  const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
18980
19612
  return `${word}-${hash2}${ext}`;
18981
19613
  }
@@ -18984,20 +19616,20 @@ function addToInbox(drop) {
18984
19616
  const typed = (drop.text ?? "").trim();
18985
19617
  const file = drop.file;
18986
19618
  if (!typed && !file) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
18987
- if (file && file.data.length === 0) return { ok: false, error: `${path59.basename(file.name)} is empty.` };
19619
+ if (file && file.data.length === 0) return { ok: false, error: `${path61.basename(file.name)} is empty.` };
18988
19620
  if (file && file.data.length > MAX_BYTES) {
18989
- return { ok: false, error: `${path59.basename(file.name)} is over ${MAX_BYTES / 1024 / 1024} MB \u2014 too big for the board.` };
19621
+ return { ok: false, error: `${path61.basename(file.name)} is over ${MAX_BYTES / 1024 / 1024} MB \u2014 too big for the board.` };
18990
19622
  }
18991
- const read4 = describe(typed, file);
18992
- const keep2 = read4.keep;
19623
+ const read5 = describe(typed, file);
19624
+ const keep2 = read5.keep;
18993
19625
  const said3 = drop.source?.trim() ?? "";
18994
19626
  const hit = said3 ? matchSourceType(said3) : "";
18995
19627
  const kept2 = said3 && !hit ? metaPair("source", said3) : null;
18996
19628
  const incoming = {
18997
- ...read4.incoming,
19629
+ ...read5.incoming,
18998
19630
  ...drop.title?.trim() ? { title: oneLine(drop.title) } : {},
18999
19631
  ...hit ? { sourceType: hit } : {},
19000
- ...kept2 ? { meta: [kept2, ...read4.incoming.meta] } : {},
19632
+ ...kept2 ? { meta: [kept2, ...read5.incoming.meta] } : {},
19001
19633
  ...drop.agent ? { agent: drop.agent } : {},
19002
19634
  ...drop.workflow ? { workflow: drop.workflow } : {}
19003
19635
  };
@@ -19008,8 +19640,8 @@ ${incoming.summary}`);
19008
19640
  if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
19009
19641
  try {
19010
19642
  if (keep2) {
19011
- fs56.mkdirSync(SIGNALS_FILES, { recursive: true });
19012
- fs56.writeFileSync(keep2.at, keep2.data);
19643
+ fs58.mkdirSync(SIGNALS_FILES, { recursive: true });
19644
+ fs58.writeFileSync(keep2.at, keep2.data);
19013
19645
  }
19014
19646
  return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
19015
19647
  } catch (e2) {
@@ -19023,7 +19655,7 @@ function describe(typed, file) {
19023
19655
  return only ? [only] : [];
19024
19656
  };
19025
19657
  if (file) {
19026
- const name = path59.basename(file.name);
19658
+ const name = path61.basename(file.name);
19027
19659
  const text5 = asText(file);
19028
19660
  const note = typed ? `
19029
19661
 
@@ -19035,7 +19667,7 @@ ${typed}` : "";
19035
19667
  const at2 = keepAt(file);
19036
19668
  return {
19037
19669
  incoming: {
19038
- title: path59.basename(name, path59.extname(name)) || name,
19670
+ title: path61.basename(name, path61.extname(name)) || name,
19039
19671
  summary: `${name} \u2014 ${boardRel2(at2)}${note}`,
19040
19672
  ...named2
19041
19673
  },
@@ -19073,73 +19705,73 @@ var init_add = __esm({
19073
19705
  MAX_BYTES = 25 * 1024 * 1024;
19074
19706
  TITLE_MAX = 120;
19075
19707
  TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
19076
- boardRel2 = (file) => rel(file).split(path59.sep).join("/");
19708
+ boardRel2 = (file) => rel(file).split(path61.sep).join("/");
19077
19709
  oneLine = (text5) => {
19078
19710
  const first = text5.split("\n").find((line) => line.trim()) ?? "";
19079
19711
  const clean = first.replace(/^#+\s*/, "").trim();
19080
19712
  return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
19081
19713
  };
19082
- keepAt = (file) => path59.join(SIGNALS_FILES, fileName2(file.name, file.data));
19714
+ keepAt = (file) => path61.join(SIGNALS_FILES, fileName2(file.name, file.data));
19083
19715
  }
19084
19716
  });
19085
19717
 
19086
19718
  // ../cli/src/lib/recurring.ts
19087
- import fs57 from "node:fs";
19088
- import path60 from "node:path";
19719
+ import fs59 from "node:fs";
19720
+ import path62 from "node:path";
19089
19721
  function migratePruneMemoryCard() {
19090
19722
  const dir = recurringDir();
19091
19723
  let names3;
19092
19724
  try {
19093
- names3 = fs57.readdirSync(dir);
19725
+ names3 = fs59.readdirSync(dir);
19094
19726
  } catch {
19095
19727
  return null;
19096
19728
  }
19097
19729
  const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
19098
19730
  if (!name) return null;
19099
- const file = path60.join(dir, name);
19731
+ const file = path62.join(dir, name);
19100
19732
  try {
19101
- const { meta } = parseFrontmatter(fs57.readFileSync(file, "utf8"));
19733
+ const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19102
19734
  const cadence = meta?.cadence;
19103
19735
  if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
19104
19736
  } catch {
19105
19737
  }
19106
- fs57.rmSync(file, { force: true });
19738
+ fs59.rmSync(file, { force: true });
19107
19739
  return rel(file);
19108
19740
  }
19109
19741
  function legacyCards() {
19110
19742
  const dir = recurringDir();
19111
- if (!fs57.existsSync(dir)) return [];
19743
+ if (!fs59.existsSync(dir)) return [];
19112
19744
  const cards = [];
19113
- for (const entry of fs57.readdirSync(dir, { withFileTypes: true })) {
19745
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19114
19746
  const id = idPrefix(entry.name);
19115
19747
  if (id === null) continue;
19116
- const full = path60.join(dir, entry.name);
19748
+ const full = path62.join(dir, entry.name);
19117
19749
  const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
19118
19750
  if (entry.isFile() && entry.name.endsWith(".md")) cards.push({ id, slug: slug2, file: full });
19119
- else if (entry.isDirectory() && fs57.existsSync(path60.join(full, "root.md"))) {
19120
- cards.push({ id, slug: slug2, file: path60.join(full, "root.md"), folder: full });
19751
+ else if (entry.isDirectory() && fs59.existsSync(path62.join(full, "root.md"))) {
19752
+ cards.push({ id, slug: slug2, file: path62.join(full, "root.md"), folder: full });
19121
19753
  }
19122
19754
  }
19123
19755
  return cards.sort((a2, b2) => a2.id - b2.id);
19124
19756
  }
19125
19757
  function mergeInto2(from, to, skip = []) {
19126
- fs57.mkdirSync(to, { recursive: true });
19127
- for (const entry of fs57.readdirSync(from, { withFileTypes: true })) {
19758
+ fs59.mkdirSync(to, { recursive: true });
19759
+ for (const entry of fs59.readdirSync(from, { withFileTypes: true })) {
19128
19760
  if (skip.includes(entry.name)) continue;
19129
- const source = path60.join(from, entry.name);
19130
- const target = path60.join(to, entry.name);
19131
- if (!fs57.existsSync(target)) fs57.renameSync(source, target);
19132
- else if (entry.isDirectory() && fs57.statSync(target).isDirectory()) mergeInto2(source, target);
19761
+ const source = path62.join(from, entry.name);
19762
+ const target = path62.join(to, entry.name);
19763
+ if (!fs59.existsSync(target)) fs59.renameSync(source, target);
19764
+ else if (entry.isDirectory() && fs59.statSync(target).isDirectory()) mergeInto2(source, target);
19133
19765
  }
19134
- if (isEmpty(from)) fs57.rmSync(from, { recursive: true, force: true });
19766
+ if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
19135
19767
  }
19136
19768
  function moveSideFolders() {
19137
19769
  const dir = recurringDir();
19138
- for (const entry of fs57.readdirSync(dir, { withFileTypes: true })) {
19770
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19139
19771
  if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
19140
- const from = path60.join(dir, entry.name);
19141
- if (isEmpty(from)) fs57.rmSync(from, { recursive: true, force: true });
19142
- else mergeInto2(from, path60.join(AGENTS, entry.name));
19772
+ const from = path62.join(dir, entry.name);
19773
+ if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
19774
+ else mergeInto2(from, path62.join(AGENTS, entry.name));
19143
19775
  }
19144
19776
  }
19145
19777
  function sections(body) {
@@ -19189,8 +19821,8 @@ function agentName(card, text5) {
19189
19821
  const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a2) => a2.name), ...ROLE_NAMES]);
19190
19822
  for (const name of [slug2, `${slug2}-${card.id}`]) {
19191
19823
  if (!AGENT_NAME.test(name)) continue;
19192
- const file = path60.join(AGENTS, name, AGENT_FILE3);
19193
- const written = fs57.existsSync(file) ? fs57.readFileSync(file, "utf8") : null;
19824
+ const file = path62.join(AGENTS, name, AGENT_FILE3);
19825
+ const written = fs59.existsSync(file) ? fs59.readFileSync(file, "utf8") : null;
19194
19826
  if (written === text5(name)) return name;
19195
19827
  if (written === null && !known2.has(name)) return name;
19196
19828
  }
@@ -19207,11 +19839,11 @@ ${q3.options.map((o3) => `- ${o3}`).join("\n")}` : "";
19207
19839
  function removeCard(card) {
19208
19840
  dropCrossRefs(card.id);
19209
19841
  const target = card.folder ?? card.file;
19210
- stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path60.relative(TODO, target).split(path60.sep).join("/") });
19211
- fs57.rmSync(target, { recursive: true, force: true });
19842
+ stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path62.relative(TODO, target).split(path62.sep).join("/") });
19843
+ fs59.rmSync(target, { recursive: true, force: true });
19212
19844
  }
19213
19845
  function migrateCard(card) {
19214
- const { meta, body } = parseFrontmatter(fs57.readFileSync(card.file, "utf8"));
19846
+ const { meta, body } = parseFrontmatter(fs59.readFileSync(card.file, "utf8"));
19215
19847
  if (!meta) throw new Error("its frontmatter cannot be read");
19216
19848
  const raw = meta;
19217
19849
  const said3 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
@@ -19221,19 +19853,19 @@ function migrateCard(card) {
19221
19853
  if (!flow) throw new Error("this board has no workflow to put it in");
19222
19854
  const text5 = (name2) => agentText(name2, meta.title || card.slug, body);
19223
19855
  const name = agentName(card, text5);
19224
- const dir = path60.join(AGENTS, name);
19225
- const file = path60.join(dir, AGENT_FILE3);
19226
- const madeDir = !fs57.existsSync(dir);
19227
- const wrote = !fs57.existsSync(file);
19856
+ const dir = path62.join(AGENTS, name);
19857
+ const file = path62.join(dir, AGENT_FILE3);
19858
+ const madeDir = !fs59.existsSync(dir);
19859
+ const wrote = !fs59.existsSync(file);
19228
19860
  try {
19229
- fs57.mkdirSync(dir, { recursive: true });
19230
- if (wrote) fs57.writeFileSync(file, text5(name));
19861
+ fs59.mkdirSync(dir, { recursive: true });
19862
+ if (wrote) fs59.writeFileSync(file, text5(name));
19231
19863
  const adopted = adoptWorkflowScheduled(flow.id, name, { cadence, lastRun });
19232
19864
  if (!adopted.ok) throw new Error(adopted.error);
19233
19865
  questionsToTriage(meta, name);
19234
19866
  } catch (e2) {
19235
- if (madeDir) fs57.rmSync(dir, { recursive: true, force: true });
19236
- else if (wrote) fs57.rmSync(file, { force: true });
19867
+ if (madeDir) fs59.rmSync(dir, { recursive: true, force: true });
19868
+ else if (wrote) fs59.rmSync(file, { force: true });
19237
19869
  throw e2;
19238
19870
  }
19239
19871
  if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
@@ -19243,7 +19875,7 @@ function migrateCard(card) {
19243
19875
  function migrateRecurringCards() {
19244
19876
  const done2 = { agents: [], removed: [], failed: [] };
19245
19877
  const dir = recurringDir();
19246
- if (!fs57.existsSync(dir)) return done2;
19878
+ if (!fs59.existsSync(dir)) return done2;
19247
19879
  migratePruneMemoryCard();
19248
19880
  moveSideFolders();
19249
19881
  for (const card of legacyCards()) {
@@ -19256,7 +19888,7 @@ function migrateRecurringCards() {
19256
19888
  done2.failed.push({ card: rel(card.file), why: e2 instanceof Error ? e2.message : String(e2) });
19257
19889
  }
19258
19890
  }
19259
- if (isEmpty(dir)) fs57.rmSync(dir, { recursive: true, force: true });
19891
+ if (isEmpty(dir)) fs59.rmSync(dir, { recursive: true, force: true });
19260
19892
  return done2;
19261
19893
  }
19262
19894
  function recurringMigrationLines(done2) {
@@ -19289,14 +19921,14 @@ var init_recurring = __esm({
19289
19921
  PRUNE_SLUG = "prune-the-memory";
19290
19922
  FETCH_SLUG = "fetch-triage-items";
19291
19923
  AGENT_FILE3 = "AGENT.md";
19292
- recurringDir = () => path60.join(TODO, LEGACY_RECURRING);
19293
- isEmpty = (dir) => fs57.readdirSync(dir).every((name) => name === ".DS_Store");
19924
+ recurringDir = () => path62.join(TODO, LEGACY_RECURRING);
19925
+ isEmpty = (dir) => fs59.readdirSync(dir).every((name) => name === ".DS_Store");
19294
19926
  SECTION = /^##\s+(.+?)\s*$/;
19295
19927
  }
19296
19928
  });
19297
19929
 
19298
19930
  // ../cli/src/commands/init.ts
19299
- import fs58 from "node:fs";
19931
+ import fs60 from "node:fs";
19300
19932
  function boardReadme() {
19301
19933
  return `# Board
19302
19934
 
@@ -19309,20 +19941,20 @@ _(none)_
19309
19941
  `;
19310
19942
  }
19311
19943
  function writeConfigIfMissing() {
19312
- if (fs58.existsSync(CONFIG)) return false;
19313
- fs58.mkdirSync(KANBAN, { recursive: true });
19314
- fs58.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19944
+ if (fs60.existsSync(CONFIG)) return false;
19945
+ fs60.mkdirSync(KANBAN, { recursive: true });
19946
+ fs60.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19315
19947
  return true;
19316
19948
  }
19317
19949
  function writeModulesIfMissing() {
19318
- if (fs58.existsSync(MODULES_MD)) return false;
19319
- fs58.mkdirSync(KANBAN, { recursive: true });
19320
- fs58.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
19950
+ if (fs60.existsSync(MODULES_MD)) return false;
19951
+ fs60.mkdirSync(KANBAN, { recursive: true });
19952
+ fs60.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
19321
19953
  return true;
19322
19954
  }
19323
19955
  function writeGitignoreIfMissing() {
19324
- fs58.mkdirSync(KANBAN, { recursive: true });
19325
- const text5 = fs58.existsSync(KANBAN_GITIGNORE) ? fs58.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
19956
+ fs60.mkdirSync(KANBAN, { recursive: true });
19957
+ const text5 = fs60.existsSync(KANBAN_GITIGNORE) ? fs60.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
19326
19958
  const has = (rule) => text5.split("\n").some((line) => line.trim() === rule.line);
19327
19959
  const missing = IGNORE_RULES.filter((rule) => !has(rule));
19328
19960
  if (!missing.length) return false;
@@ -19330,37 +19962,37 @@ function writeGitignoreIfMissing() {
19330
19962
  ${rule.line}
19331
19963
  `).join("");
19332
19964
  const separator = !text5 || text5.endsWith("\n") ? "" : "\n";
19333
- fs58.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19965
+ fs60.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19334
19966
  return true;
19335
19967
  }
19336
19968
  function writeSkeletonIfMissing() {
19337
19969
  const added = [];
19338
- if (!fs58.existsSync(TODO)) {
19339
- fs58.mkdirSync(TODO, { recursive: true });
19970
+ if (!fs60.existsSync(TODO)) {
19971
+ fs60.mkdirSync(TODO, { recursive: true });
19340
19972
  added.push(`${rel(TODO)}/`);
19341
19973
  }
19342
- if (!fs58.existsSync(README)) {
19343
- fs58.writeFileSync(README, boardReadme());
19974
+ if (!fs60.existsSync(README)) {
19975
+ fs60.writeFileSync(README, boardReadme());
19344
19976
  added.push(rel(README));
19345
19977
  }
19346
19978
  return added;
19347
19979
  }
19348
19980
  function retireReleases() {
19349
19981
  const done2 = [];
19350
- if (fs58.existsSync(RELEASES)) {
19351
- fs58.rmSync(RELEASES);
19982
+ if (fs60.existsSync(RELEASES)) {
19983
+ fs60.rmSync(RELEASES);
19352
19984
  done2.push(`deleted ${rel(RELEASES)}`);
19353
19985
  }
19354
19986
  let cards = 0;
19355
19987
  for (const dir of [TODO, ARCHIVE]) {
19356
- if (!fs58.existsSync(dir)) continue;
19988
+ if (!fs60.existsSync(dir)) continue;
19357
19989
  for (const file of walkMd(dir)) {
19358
- const text5 = fs58.readFileSync(file, "utf8");
19990
+ const text5 = fs60.readFileSync(file, "utf8");
19359
19991
  const end2 = text5.startsWith("---\n") ? text5.indexOf("\n---", 3) : -1;
19360
19992
  if (end2 < 0) continue;
19361
19993
  const head2 = text5.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
19362
19994
  if (head2.length === end2) continue;
19363
- fs58.writeFileSync(file, head2 + text5.slice(end2));
19995
+ fs60.writeFileSync(file, head2 + text5.slice(end2));
19364
19996
  cards++;
19365
19997
  }
19366
19998
  }
@@ -19368,7 +20000,7 @@ function retireReleases() {
19368
20000
  return done2.join(", ");
19369
20001
  }
19370
20002
  function cmdInit() {
19371
- if (fs58.existsSync(KANBAN)) {
20003
+ if (fs60.existsSync(KANBAN)) {
19372
20004
  const added = [
19373
20005
  ...writeSkeletonIfMissing(),
19374
20006
  writeConfigIfMissing() && rel(CONFIG),
@@ -19403,8 +20035,8 @@ function cmdInit() {
19403
20035
  }
19404
20036
  return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
19405
20037
  }
19406
- fs58.mkdirSync(TODO, { recursive: true });
19407
- fs58.writeFileSync(README, boardReadme());
20038
+ fs60.mkdirSync(TODO, { recursive: true });
20039
+ fs60.writeFileSync(README, boardReadme());
19408
20040
  writeConfigIfMissing();
19409
20041
  scaffoldProjectMemory();
19410
20042
  writeModulesIfMissing();
@@ -19493,25 +20125,25 @@ var init_scheduled = __esm({
19493
20125
  });
19494
20126
 
19495
20127
  // ../cli/src/lib/card-age.ts
19496
- import fs59 from "node:fs";
19497
- import path61 from "node:path";
20128
+ import fs61 from "node:fs";
20129
+ import path63 from "node:path";
19498
20130
  function staleAfterIn(config) {
19499
20131
  const days = Number(LINE.exec(config)?.[1]);
19500
20132
  return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
19501
20133
  }
19502
20134
  function staleAfter() {
19503
- if (!fs59.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
19504
- return staleAfterIn(fs59.readFileSync(CONFIG, "utf8"));
20135
+ if (!fs61.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
20136
+ return staleAfterIn(fs61.readFileSync(CONFIG, "utf8"));
19505
20137
  }
19506
20138
  function todoPathspec(top) {
19507
- const from = path61.relative(real(top), real(TODO));
19508
- if (!from || from.startsWith("..") || path61.isAbsolute(from)) return null;
19509
- return from.split(path61.sep).join("/");
20139
+ const from = path63.relative(real(top), real(TODO));
20140
+ if (!from || from.startsWith("..") || path63.isAbsolute(from)) return null;
20141
+ return from.split(path63.sep).join("/");
19510
20142
  }
19511
20143
  function cardFile2(spec, printed) {
19512
20144
  const p2 = unquotePath(printed);
19513
20145
  if (!p2.startsWith(`${spec}/`)) return null;
19514
- return path61.join(TODO, ...p2.slice(spec.length + 1).split("/"));
20146
+ return path63.join(TODO, ...p2.slice(spec.length + 1).split("/"));
19515
20147
  }
19516
20148
  function dirtyCards(top, spec) {
19517
20149
  const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
@@ -19558,9 +20190,9 @@ var init_card_age = __esm({
19558
20190
  gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
19559
20191
  real = (p2) => {
19560
20192
  try {
19561
- return fs59.realpathSync(p2);
20193
+ return fs61.realpathSync(p2);
19562
20194
  } catch {
19563
- return path61.resolve(p2);
20195
+ return path63.resolve(p2);
19564
20196
  }
19565
20197
  };
19566
20198
  unquotePath = (line) => {
@@ -19595,8 +20227,8 @@ var init_card_holds = __esm({
19595
20227
  });
19596
20228
 
19597
20229
  // ../cli/src/commands/list.ts
19598
- import fs60 from "node:fs";
19599
- import path62 from "node:path";
20230
+ import fs62 from "node:fs";
20231
+ import path64 from "node:path";
19600
20232
  function summaryLine(body) {
19601
20233
  const lines = body.split("\n");
19602
20234
  let i = 0;
@@ -19612,13 +20244,13 @@ function summaryLine(body) {
19612
20244
  function openRows() {
19613
20245
  const rows = [];
19614
20246
  for (const file of walkMd(TODO)) {
19615
- const base = path62.basename(file);
20247
+ const base = path64.basename(file);
19616
20248
  if (base === "README.md") continue;
19617
20249
  const isRoot = base === "root.md";
19618
- const id = isRoot ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
20250
+ const id = isRoot ? idPrefix(path64.basename(path64.dirname(file))) : idPrefix(base);
19619
20251
  if (id == null) continue;
19620
- if (isLegacyRecurring(path62.relative(TODO, file))) continue;
19621
- const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
20252
+ if (isLegacyRecurring(path64.relative(TODO, file))) continue;
20253
+ const { meta, body } = parseFrontmatter(fs62.readFileSync(file, "utf8"));
19622
20254
  rows.push({
19623
20255
  id,
19624
20256
  file,
@@ -19660,15 +20292,15 @@ function cmdStale(rows, all2, scope, mod) {
19660
20292
  }
19661
20293
  function archivedFiles() {
19662
20294
  const files2 = /* @__PURE__ */ new Map();
19663
- if (!fs60.existsSync(ARCHIVE)) return files2;
20295
+ if (!fs62.existsSync(ARCHIVE)) return files2;
19664
20296
  for (const file of walkMd(ARCHIVE)) {
19665
- const id = idPrefix(path62.basename(file));
20297
+ const id = idPrefix(path64.basename(file));
19666
20298
  if (id !== null) files2.set(id, file);
19667
20299
  }
19668
20300
  for (const dir of walkDirs(ARCHIVE)) {
19669
- const id = idPrefix(path62.basename(dir));
19670
- const root2 = path62.join(dir, "root.md");
19671
- if (id !== null && fs60.existsSync(root2)) files2.set(id, root2);
20301
+ const id = idPrefix(path64.basename(dir));
20302
+ const root2 = path64.join(dir, "root.md");
20303
+ if (id !== null && fs62.existsSync(root2)) files2.set(id, root2);
19672
20304
  }
19673
20305
  return files2;
19674
20306
  }
@@ -19779,14 +20411,14 @@ var init_list = __esm({
19779
20411
  });
19780
20412
 
19781
20413
  // ../cli/src/commands/misc.ts
19782
- import fs61 from "node:fs";
19783
- import path63 from "node:path";
20414
+ import fs63 from "node:fs";
20415
+ import path65 from "node:path";
19784
20416
  function extractOldMeta(text5, file) {
19785
20417
  const grab = (re3) => {
19786
20418
  const m = text5.match(re3);
19787
20419
  return m ? m[1].trim() : null;
19788
20420
  };
19789
- const title = grab(/^#\s+(.+)$/m) || slugify(path63.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
20421
+ const title = grab(/^#\s+(.+)$/m) || slugify(path65.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
19790
20422
  const norm = (raw) => {
19791
20423
  const v = (raw || "").toLowerCase();
19792
20424
  return LEVELS.includes(v) ? v : "med";
@@ -19813,11 +20445,11 @@ function stripOldHeader(text5) {
19813
20445
  }
19814
20446
  function cmdMigrate(opts) {
19815
20447
  const dry = opts.dryRun === true;
19816
- const files2 = walkMd(TODO).filter((f2) => path63.basename(f2) !== "README.md");
20448
+ const files2 = walkMd(TODO).filter((f2) => path65.basename(f2) !== "README.md");
19817
20449
  let changed = 0;
19818
20450
  let skipped = 0;
19819
20451
  for (const file of files2) {
19820
- const text5 = fs61.readFileSync(file, "utf8");
20452
+ const text5 = fs63.readFileSync(file, "utf8");
19821
20453
  if (text5.trimStart().startsWith("---")) {
19822
20454
  skipped++;
19823
20455
  continue;
@@ -19826,7 +20458,7 @@ function cmdMigrate(opts) {
19826
20458
  const out = serializeFrontmatter(meta) + "\n\n" + stripOldHeader(text5).replace(/^\n+/, "");
19827
20459
  if (dry) say(`would migrate ${rel(file)} (priority=${meta.priority})`);
19828
20460
  else {
19829
- fs61.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
20461
+ fs63.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
19830
20462
  say(`migrated ${rel(file)}`);
19831
20463
  }
19832
20464
  changed++;
@@ -19847,8 +20479,8 @@ var init_misc = __esm({
19847
20479
  });
19848
20480
 
19849
20481
  // ../cli/src/lib/card-sources.ts
19850
- import fs62 from "node:fs";
19851
- import path64 from "node:path";
20482
+ import fs64 from "node:fs";
20483
+ import path66 from "node:path";
19852
20484
  function planById(id) {
19853
20485
  const found2 = readPlan(`plans/${id}-.md`);
19854
20486
  return found2?.text.trim() ? found2 : null;
@@ -19858,8 +20490,8 @@ function cardLink(id) {
19858
20490
  const found2 = open3 ?? locateArchived(id);
19859
20491
  if (!found2) return null;
19860
20492
  try {
19861
- const file = found2.kind === "group" ? path64.join(found2.target, "root.md") : found2.target;
19862
- const title = parseFrontmatter(fs62.readFileSync(file, "utf8")).meta?.title ?? "";
20493
+ const file = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
20494
+ const title = parseFrontmatter(fs64.readFileSync(file, "utf8")).meta?.title ?? "";
19863
20495
  return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
19864
20496
  } catch {
19865
20497
  return null;
@@ -19884,7 +20516,7 @@ function link(ref, items) {
19884
20516
  if (ref.kind === "plan") return planLink(ref.id);
19885
20517
  if (ref.kind === "card") return cardLink(ref.id);
19886
20518
  if (ref.kind === "url") return urlLink(ref.url);
19887
- const item = items().find((signal2) => path64.basename(signal2.relPath) === ref.file);
20519
+ const item = items().find((signal2) => path66.basename(signal2.relPath) === ref.file);
19888
20520
  return item ? itemLink(item) : null;
19889
20521
  }
19890
20522
  function cardSources(meta, body) {
@@ -19925,12 +20557,12 @@ var init_card_sources = __esm({
19925
20557
  });
19926
20558
 
19927
20559
  // ../cli/src/lib/view/read.ts
19928
- import fs63 from "node:fs";
19929
- import path65 from "node:path";
20560
+ import fs65 from "node:fs";
20561
+ import path67 from "node:path";
19930
20562
  function readCard(file, relFromTodo) {
19931
- const id = idPrefix(path65.basename(relFromTodo));
20563
+ const id = idPrefix(path67.basename(relFromTodo));
19932
20564
  if (id === null) {
19933
- const parts = relFromTodo.split(path65.sep);
20565
+ const parts = relFromTodo.split(path67.sep);
19934
20566
  const folderId = idPrefix(parts[parts.length - 2] || "");
19935
20567
  if (folderId === null) return null;
19936
20568
  return buildCard(folderId, file, relFromTodo);
@@ -19938,10 +20570,10 @@ function readCard(file, relFromTodo) {
19938
20570
  return buildCard(id, file, relFromTodo);
19939
20571
  }
19940
20572
  function buildCard(id, file, relFromTodo) {
19941
- const text5 = fs63.readFileSync(file, "utf8");
20573
+ const text5 = fs65.readFileSync(file, "utf8");
19942
20574
  const { meta, body } = parseFrontmatter(text5);
19943
20575
  if (!meta) return null;
19944
- const relPath = relFromTodo.split(path65.sep).join("/");
20576
+ const relPath = relFromTodo.split(path67.sep).join("/");
19945
20577
  const flow = workflowFor(meta.workflow);
19946
20578
  const plan = !!meta.workflow && archivesOnApproval(flow);
19947
20579
  const stages = cardStages(meta, flow).length;
@@ -19950,7 +20582,7 @@ function buildCard(id, file, relFromTodo) {
19950
20582
  // Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
19951
20583
  // read here and a card read by the contract agree on what version this is.
19952
20584
  revision: revisionOf(text5),
19953
- updatedAt: fs63.statSync(file).mtime.toISOString(),
20585
+ updatedAt: fs65.statSync(file).mtime.toISOString(),
19954
20586
  relPath,
19955
20587
  title: meta.title,
19956
20588
  priority: meta.priority,
@@ -19971,22 +20603,22 @@ function buildCard(id, file, relFromTodo) {
19971
20603
  };
19972
20604
  }
19973
20605
  function readGroup2(folderName) {
19974
- const groupDir = path65.join(TODO, folderName);
19975
- const rootFile = path65.join(groupDir, "root.md");
19976
- if (!fs63.existsSync(rootFile)) return null;
19977
- const root2 = readCard(rootFile, path65.join(folderName, "root.md"));
20606
+ const groupDir = path67.join(TODO, folderName);
20607
+ const rootFile = path67.join(groupDir, "root.md");
20608
+ if (!fs65.existsSync(rootFile)) return null;
20609
+ const root2 = readCard(rootFile, path67.join(folderName, "root.md"));
19978
20610
  if (!root2) return null;
19979
20611
  root2.isGroup = true;
19980
20612
  const { total, resolved: resolved2 } = subtaskLines(root2.body);
19981
20613
  root2.subtaskLines = { total, resolved: resolved2 };
19982
20614
  const subCards = [];
19983
20615
  const recurse = (dir, relDir) => {
19984
- for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
19985
- const childRel = path65.join(relDir, entry.name);
20616
+ for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
20617
+ const childRel = path67.join(relDir, entry.name);
19986
20618
  if (entry.isDirectory()) {
19987
- recurse(path65.join(dir, entry.name), childRel);
20619
+ recurse(path67.join(dir, entry.name), childRel);
19988
20620
  } else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
19989
- const c2 = readCard(path65.join(dir, entry.name), childRel);
20621
+ const c2 = readCard(path67.join(dir, entry.name), childRel);
19990
20622
  if (c2) {
19991
20623
  c2.parent = { id: root2.id, title: root2.title };
19992
20624
  subCards.push(c2);
@@ -20007,12 +20639,12 @@ function readGroup2(folderName) {
20007
20639
  return { root: root2, subCards };
20008
20640
  }
20009
20641
  function standaloneCards(dirRel) {
20010
- const dir = dirRel ? path65.join(TODO, dirRel) : TODO;
20011
- if (!fs63.existsSync(dir)) return [];
20642
+ const dir = dirRel ? path67.join(TODO, dirRel) : TODO;
20643
+ if (!fs65.existsSync(dir)) return [];
20012
20644
  const cards = [];
20013
- for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
20645
+ for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
20014
20646
  if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
20015
- const c2 = readCard(path65.join(dir, entry.name), path65.join(dirRel, entry.name));
20647
+ const c2 = readCard(path67.join(dir, entry.name), path67.join(dirRel, entry.name));
20016
20648
  if (c2) cards.push(c2);
20017
20649
  }
20018
20650
  }
@@ -20024,7 +20656,7 @@ function collectCards() {
20024
20656
  const top = standaloneCards("");
20025
20657
  board2.push(...top);
20026
20658
  every.push(...top);
20027
- for (const entry of fs63.readdirSync(TODO, { withFileTypes: true })) {
20659
+ for (const entry of fs65.readdirSync(TODO, { withFileTypes: true })) {
20028
20660
  if (!entry.isDirectory()) continue;
20029
20661
  if (isGroupFolder(entry.name)) {
20030
20662
  const g3 = readGroup2(entry.name);
@@ -20056,7 +20688,7 @@ function findCard(id) {
20056
20688
  }
20057
20689
  function attachSources(card) {
20058
20690
  try {
20059
- const { meta, body } = parseFrontmatter(fs63.readFileSync(path65.join(TODO, card.relPath), "utf8"));
20691
+ const { meta, body } = parseFrontmatter(fs65.readFileSync(path67.join(TODO, card.relPath), "utf8"));
20060
20692
  const sources2 = meta ? cardSources(meta, body) : [];
20061
20693
  if (sources2.length) card.sources = sources2;
20062
20694
  } catch {
@@ -20161,10 +20793,10 @@ var init_read = __esm({
20161
20793
  });
20162
20794
 
20163
20795
  // ../cli/src/lib/group-close.ts
20164
- import fs64 from "node:fs";
20796
+ import fs66 from "node:fs";
20165
20797
  function groupCloses(rootFile) {
20166
20798
  try {
20167
- return groupCloseOf(fs64.readFileSync(rootFile, "utf8"));
20799
+ return groupCloseOf(fs66.readFileSync(rootFile, "utf8"));
20168
20800
  } catch {
20169
20801
  return false;
20170
20802
  }
@@ -20177,12 +20809,12 @@ var init_group_close = __esm({
20177
20809
  });
20178
20810
 
20179
20811
  // ../cli/src/commands/remove.ts
20180
- import fs65 from "node:fs";
20181
- import path66 from "node:path";
20812
+ import fs67 from "node:fs";
20813
+ import path68 from "node:path";
20182
20814
  function leavingIds(id, found2) {
20183
20815
  const ids = /* @__PURE__ */ new Set([id]);
20184
20816
  if (found2.kind === "group") {
20185
- const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path66.basename(f2));
20817
+ const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path68.basename(f2));
20186
20818
  for (const name of names3) {
20187
20819
  const n = idPrefix(name);
20188
20820
  if (n !== null) ids.add(n);
@@ -20194,10 +20826,10 @@ function findMentions(ids) {
20194
20826
  const hits = [];
20195
20827
  const re3 = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
20196
20828
  for (const dir of [TODO, MEMORY]) {
20197
- if (!fs65.existsSync(dir)) continue;
20829
+ if (!fs67.existsSync(dir)) continue;
20198
20830
  for (const file of walkMd(dir)) {
20199
- if (path66.basename(file) === "README.md") continue;
20200
- const lines = fs65.readFileSync(file, "utf8").split("\n");
20831
+ if (path68.basename(file) === "README.md") continue;
20832
+ const lines = fs67.readFileSync(file, "utf8").split("\n");
20201
20833
  const fmEnd = frontmatterEnd(lines);
20202
20834
  lines.forEach((line, i) => {
20203
20835
  if (!re3.test(line)) return;
@@ -20213,12 +20845,12 @@ function findMentions(ids) {
20213
20845
  return hits;
20214
20846
  }
20215
20847
  function leavingCards(id, found2) {
20216
- const own = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
20848
+ const own = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20217
20849
  const cards = [{ id, file: own }];
20218
20850
  if (found2.kind !== "group") return cards;
20219
20851
  for (const file of walkMd(found2.target)) {
20220
20852
  if (file === own) continue;
20221
- const n = idPrefix(path66.basename(file));
20853
+ const n = idPrefix(path68.basename(file));
20222
20854
  if (n !== null) cards.push({ id: n, file });
20223
20855
  }
20224
20856
  return cards;
@@ -20227,10 +20859,10 @@ function stampLeaving(cards, rejection) {
20227
20859
  const day = formatDay();
20228
20860
  const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
20229
20861
  for (const card of cards) {
20230
- if (!fs65.existsSync(card.file)) continue;
20231
- const text5 = fs65.readFileSync(card.file, "utf8");
20862
+ if (!fs67.existsSync(card.file)) continue;
20863
+ const text5 = fs67.readFileSync(card.file, "utf8");
20232
20864
  const stamped = stampLeavingIn(text5, day, stamp4);
20233
- if (stamped !== text5) fs65.writeFileSync(card.file, stamped);
20865
+ if (stamped !== text5) fs67.writeFileSync(card.file, stamped);
20234
20866
  }
20235
20867
  }
20236
20868
  function unfinishedDelivery(id) {
@@ -20246,7 +20878,7 @@ function unfinishedDelivery(id) {
20246
20878
  }[gap];
20247
20879
  return `#${id} is not finished: ${what}.`;
20248
20880
  }
20249
- const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs65.existsSync(path66.join(ASSETS, src.slice(".assets/".length))));
20881
+ const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs67.existsSync(path68.join(ASSETS, src.slice(".assets/".length))));
20250
20882
  return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
20251
20883
  }
20252
20884
  function agentDecisions(text5) {
@@ -20277,8 +20909,8 @@ function removeCard2(id, metric, options) {
20277
20909
  const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
20278
20910
  if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
20279
20911
  const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
20280
- const cardFile3 = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
20281
- const cardText = fs65.existsSync(cardFile3) ? fs65.readFileSync(cardFile3, "utf8") : "";
20912
+ const cardFile3 = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20913
+ const cardText = fs67.existsSync(cardFile3) ? fs67.readFileSync(cardFile3, "utf8") : "";
20282
20914
  const { meta: cardMeta3 } = parseFrontmatter(cardText);
20283
20915
  const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f2) => f2 !== cardFile3).map((f2) => rel(f2)).sort() : [];
20284
20916
  const leftIds = leavingIds(id, found2);
@@ -20309,10 +20941,10 @@ function removeCard2(id, metric, options) {
20309
20941
  const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
20310
20942
  if (dest) {
20311
20943
  stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
20312
- fs65.mkdirSync(ARCHIVE, { recursive: true });
20313
- fs65.renameSync(found2.target, dest);
20944
+ fs67.mkdirSync(ARCHIVE, { recursive: true });
20945
+ fs67.renameSync(found2.target, dest);
20314
20946
  } else {
20315
- fs65.rmSync(found2.target, { recursive: true, force: true });
20947
+ fs67.rmSync(found2.target, { recursive: true, force: true });
20316
20948
  }
20317
20949
  const removedRefs = stripReadmeRefs(found2);
20318
20950
  let marked2 = null;
@@ -20361,14 +20993,14 @@ function removeCard2(id, metric, options) {
20361
20993
  };
20362
20994
  }
20363
20995
  function closeGroup(rootFile) {
20364
- const rootId = idPrefix(path66.basename(path66.dirname(rootFile)));
20996
+ const rootId = idPrefix(path68.basename(path68.dirname(rootFile)));
20365
20997
  if (rootId === null) return null;
20366
20998
  if (runnerProject(KANBAN)) return null;
20367
20999
  if (!groupCloses(rootFile)) return null;
20368
21000
  say(`
20369
21001
  every subtask line on #${rootId} is resolved \u2014 closing the group:`);
20370
21002
  try {
20371
- const { meta, body } = parseFrontmatter(fs65.readFileSync(rootFile, "utf8"));
21003
+ const { meta, body } = parseFrontmatter(fs67.readFileSync(rootFile, "utf8"));
20372
21004
  const res = cmdRemove(rootId, "completed", { closing: true });
20373
21005
  return {
20374
21006
  id: rootId,
@@ -20425,7 +21057,7 @@ function cleanupDiscardedCards(sessionId) {
20425
21057
  if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
20426
21058
  while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
20427
21059
  dropCrossRefs(card.id);
20428
- stripReadmeRefs({ kind: "file", rel: path66.relative(TODO, path66.resolve(REPO_ROOT, card.path)).split(path66.sep).join("/") });
21060
+ stripReadmeRefs({ kind: "file", rel: path68.relative(TODO, path68.resolve(REPO_ROOT, card.path)).split(path68.sep).join("/") });
20429
21061
  }
20430
21062
  return discarded.map((c2) => c2.id);
20431
21063
  });
@@ -20433,8 +21065,8 @@ function cleanupDiscardedCards(sessionId) {
20433
21065
  function recoveredArchiveHandoff(id, source) {
20434
21066
  const found2 = locateArchived(id);
20435
21067
  if (!found2) throw new Error(`No archived card #${id} was found.`);
20436
- const file = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
20437
- const { meta } = parseFrontmatter(fs65.readFileSync(file, "utf8"));
21068
+ const file = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
21069
+ const { meta } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
20438
21070
  stripReadmeRefs(source ?? found2);
20439
21071
  const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
20440
21072
  if (root2) markSubtask(root2, id, "tick");
@@ -20532,8 +21164,8 @@ var init_memory_file = __esm({
20532
21164
  });
20533
21165
 
20534
21166
  // ../cli/src/commands/rule.ts
20535
- import fs66 from "node:fs";
20536
- import path67 from "node:path";
21167
+ import fs68 from "node:fs";
21168
+ import path69 from "node:path";
20537
21169
  function cmdRule(askedName, flags) {
20538
21170
  const agent = askedName.trim();
20539
21171
  if (!agentRoster().some((a2) => a2.name === agent)) {
@@ -20542,7 +21174,7 @@ function cmdRule(askedName, flags) {
20542
21174
  const rule = readRuleText(flags.file, flags.text);
20543
21175
  const res = setAgentRule(agent, rule);
20544
21176
  if (!res.ok) die(res.error);
20545
- const file = rel(path67.join(RULES, `${agent}.md`));
21177
+ const file = rel(path69.join(RULES, `${agent}.md`));
20546
21178
  say(rule ? `wrote the \`${agent}\` rule (${file})` : `cleared the \`${agent}\` rule`);
20547
21179
  return { agent, file, cleared: !rule };
20548
21180
  }
@@ -20550,7 +21182,7 @@ function readRuleText(file, text5) {
20550
21182
  if (file !== void 0 && text5 !== void 0) die("pass --file or --text, not both");
20551
21183
  if (file !== void 0) {
20552
21184
  try {
20553
- return fs66.readFileSync(file, "utf8").trim();
21185
+ return fs68.readFileSync(file, "utf8").trim();
20554
21186
  } catch {
20555
21187
  die(`can't read ${file} \u2014 write the rule to a file, then pass its path`);
20556
21188
  }
@@ -20869,7 +21501,7 @@ var shared_exports = {};
20869
21501
  __export(shared_exports, {
20870
21502
  InvalidArgumentError: () => InvalidArgumentError,
20871
21503
  cardId: () => cardId,
20872
- collect: () => collect,
21504
+ collect: () => collect2,
20873
21505
  collectList: () => collectList,
20874
21506
  ctxOf: () => ctxOf,
20875
21507
  intInRange: () => intInRange,
@@ -20965,7 +21597,7 @@ function ordered(into) {
20965
21597
  return value ?? "";
20966
21598
  };
20967
21599
  }
20968
- var HELP_WIDTH, collect;
21600
+ var HELP_WIDTH, collect2;
20969
21601
  var init_shared = __esm({
20970
21602
  "../cli/src/lib/cli/shared.ts"() {
20971
21603
  "use strict";
@@ -20974,7 +21606,7 @@ var init_shared = __esm({
20974
21606
  init_board_cli();
20975
21607
  init_moved();
20976
21608
  HELP_WIDTH = 100;
20977
- collect = (value, previous = []) => previous.concat(value);
21609
+ collect2 = (value, previous = []) => previous.concat(value);
20978
21610
  }
20979
21611
  });
20980
21612
 
@@ -20984,8 +21616,8 @@ __export(board_exports, {
20984
21616
  buildBoardProgram: () => buildBoardProgram
20985
21617
  });
20986
21618
  import crypto5 from "node:crypto";
20987
- import fs67 from "node:fs";
20988
- import path68 from "node:path";
21619
+ import fs69 from "node:fs";
21620
+ import path70 from "node:path";
20989
21621
  async function dispatch(move, cmd, args, opts, cli) {
20990
21622
  const ctx = ctxOf(cmd, cli.program);
20991
21623
  const data = await runAction(ctx, {}, async () => {
@@ -21025,7 +21657,7 @@ async function cloudCard(task, opts) {
21025
21657
  let request2;
21026
21658
  if (typeof opts.bodyFile === "string") {
21027
21659
  try {
21028
- request2 = fs67.readFileSync(opts.bodyFile, "utf8");
21660
+ request2 = fs69.readFileSync(opts.bodyFile, "utf8");
21029
21661
  } catch {
21030
21662
  }
21031
21663
  }
@@ -21055,7 +21687,7 @@ async function cloudCard(task, opts) {
21055
21687
  const file = creationReceipt(`${checked.value}:${requestId}`, slot);
21056
21688
  const journal = readCreation(file, said3);
21057
21689
  if (!journal.made) {
21058
- const key = `akb-${path68.basename(file, ".json").slice(0, 40)}`;
21690
+ const key = `akb-${path70.basename(file, ".json").slice(0, 40)}`;
21059
21691
  const made = await createProjectTask(checked.value, journal.said, key);
21060
21692
  if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
21061
21693
  journal.made = made.value;
@@ -21085,13 +21717,13 @@ function buildBoardProgram(cli) {
21085
21717
  const inOrder = ordered(asked);
21086
21718
  move("create").summary("write exactly one card \u2014 its fields, its body template and its index entry").description(
21087
21719
  'Write exactly ONE card: allocate its id, write its frontmatter and a body template, and index it. There is no separate id-reservation mode. --blocked-by and --related take ids of existing open cards; for a group, create the root first, then create each subtask related to its id (see "Group tasks" in `akb guide add-task`). The script owns the frontmatter and writes the body scaffold; fill only the body by hand. Without --id, Cloud assigns the number in the linked project (no source task required). A failed local write can resume the same creation without making another Cloud task. Missing or invalid project links and denied access exit with code 1 using the existing error envelope. --body-file accepts a short draft or full card body. Invalid bodies fail before allocating a task or writing a card, with repair instructions. Cloud moves the card on by itself once it reaches the board: do not refine it here. Turning what a user just asked for into a card goes through `akb create` instead: this move only writes what you already decided. Example: akb raw create --title "Add a delete command" --body-file /tmp/delete-command.md'
21088
- ).requiredOption("--title <title>", "what the card is called").addOption(new Option("--recurring").hideHelp()).option("--priority <level>", `how much it matters: ${LEVELS.join(" | ")} (default: med)`, oneOf(LEVELS)).option("--blocked-by <ids>", "ids of open cards this one waits on", collectList).option("--related <ids>", "ids of open cards this one relates to", collectList).option("--modules <names>", "the parts of the project it touches, validated against modules.md", collectList).option("--question <text>", "an open question; needs its --option choices. Repeatable; follow `akb guide update-questions`", inOrder("question")).option("--option <text>", "a choice for the --question before it", inOrder("option")).option("--recommended-option <text>", "a choice for the --question before it, ticked to start", inOrder("recommended-option")).option("--mode <mode>", "how many choices the --question before it takes: single | multi", inOrder("mode")).option("--slug <slug>", "the filename to write it under (default: from the title)").option("--no-body", "write the frontmatter and no body template").option("--body-file <path>", "a short draft or full card body, written to a file first").addOption(new Option("--cadence <cadence>").hideHelp()).option("--workflow <id>", "the workflow it runs through (`akb workflow list`). Left off, the board's default").option("--previews <agents>", `the preview agents it chose, from its workflow's; "" chooses none`, collectList).addOption(new Option("--id <n>", "the number Cloud gave this card's task; for the Runner").argParser(cardId).hideHelp()).option("--triage <source-id>", "the triage item this card is made of, so the item is never carded twice").option("--source <ref>", "where it came from: a plan's path, plan:<id>, #<id> or a URL. Repeatable", collect).action(async function() {
21720
+ ).requiredOption("--title <title>", "what the card is called").addOption(new Option("--recurring").hideHelp()).option("--priority <level>", `how much it matters: ${LEVELS.join(" | ")} (default: med)`, oneOf(LEVELS)).option("--blocked-by <ids>", "ids of open cards this one waits on", collectList).option("--related <ids>", "ids of open cards this one relates to", collectList).option("--modules <names>", "the parts of the project it touches, validated against modules.md", collectList).option("--question <text>", "an open question; needs its --option choices. Repeatable; follow `akb guide update-questions`", inOrder("question")).option("--option <text>", "a choice for the --question before it", inOrder("option")).option("--recommended-option <text>", "a choice for the --question before it, ticked to start", inOrder("recommended-option")).option("--mode <mode>", "how many choices the --question before it takes: single | multi", inOrder("mode")).option("--slug <slug>", "the filename to write it under (default: from the title)").option("--no-body", "write the frontmatter and no body template").option("--body-file <path>", "a short draft or full card body, written to a file first").addOption(new Option("--cadence <cadence>").hideHelp()).option("--workflow <id>", "the workflow it runs through (`akb workflow list`). Left off, the board's default").option("--previews <agents>", `the preview agents it chose, from its workflow's; "" chooses none`, collectList).addOption(new Option("--id <n>", "the number Cloud gave this card's task; for the Runner").argParser(cardId).hideHelp()).option("--triage <source-id>", "the triage item this card is made of, so the item is never carded twice").option("--source <ref>", "where it came from: a plan's path, plan:<id>, #<id> or a URL. Repeatable", collect2).action(async function() {
21089
21721
  refuseRecurring(this);
21090
21722
  await dispatch("create", this, [], { ...this.opts(), asked }, cli);
21091
21723
  });
21092
21724
  move("update").argument("<id>", ID, cardId).summary("rewrite a card's fields").description(
21093
21725
  "Rewrite a card's frontmatter fields. --slug renames it. Body and questions are left untouched \u2014 those have their own moves."
21094
- ).option("--title <title>", "what the card is called").option("--priority <level>", LEVELS.join(" | "), oneOf(LEVELS)).option("--status <status>", STATUSES.join(" | "), oneOf(STATUSES)).option("--blocked-by <ids>", "ids of open cards this one waits on", collectList).option("--related <ids>", "ids of open cards this one relates to", collectList).option("--add-blocked-by <ids>", "append ids to blocked_by, keeping the ids already there", collectList).option("--add-related <ids>", "append ids to related, keeping the ids already there", collectList).option("--modules <names>", "the parts of the project it touches", collectList).option("--source <ref>", `where it came from: a plan's path, plan:<id>, #<id> or a URL. Repeatable; "" clears the list`, collect).option("--add-source <ref>", "append one source, keeping the ones already there. Repeatable", collect).option("--previews <agents>", `the preview agents it chose, from its workflow's; "" chooses none`, collectList).option("--phase <n>", "the approval it is on, 1-based").option("--slug <slug>", "rename the file").option("--workflow <id>", 'the workflow it runs through; "" puts it back on the default. The card goes back to todo and is re-planned').addOption(new Option("--cadence <cadence>").hideHelp()).action(async function(id) {
21726
+ ).option("--title <title>", "what the card is called").option("--priority <level>", LEVELS.join(" | "), oneOf(LEVELS)).option("--status <status>", STATUSES.join(" | "), oneOf(STATUSES)).option("--blocked-by <ids>", "ids of open cards this one waits on", collectList).option("--related <ids>", "ids of open cards this one relates to", collectList).option("--add-blocked-by <ids>", "append ids to blocked_by, keeping the ids already there", collectList).option("--add-related <ids>", "append ids to related, keeping the ids already there", collectList).option("--modules <names>", "the parts of the project it touches", collectList).option("--source <ref>", `where it came from: a plan's path, plan:<id>, #<id> or a URL. Repeatable; "" clears the list`, collect2).option("--add-source <ref>", "append one source, keeping the ones already there. Repeatable", collect2).option("--previews <agents>", `the preview agents it chose, from its workflow's; "" chooses none`, collectList).option("--phase <n>", "the approval it is on, 1-based").option("--slug <slug>", "rename the file").option("--workflow <id>", 'the workflow it runs through; "" puts it back on the default. The card goes back to todo and is re-planned').addOption(new Option("--cadence <cadence>").hideHelp()).action(async function(id) {
21095
21727
  refuseRecurring(this);
21096
21728
  await dispatch("update", this, [String(id)], this.opts(), cli);
21097
21729
  });
@@ -21197,16 +21829,16 @@ var init_board2 = __esm({
21197
21829
  });
21198
21830
 
21199
21831
  // ../cli/src/lib/board-cli.ts
21200
- import fs68 from "node:fs";
21201
- import path69 from "node:path";
21832
+ import fs70 from "node:fs";
21833
+ import path71 from "node:path";
21202
21834
  function useBoard(found2, dirNamed) {
21203
- if (!found2.named && found2.board === path69.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21835
+ if (!found2.named && found2.board === path71.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21204
21836
  else setBoardDir(found2.board, found2.root);
21205
21837
  useProjectState();
21206
21838
  }
21207
21839
  function whole(found2, move) {
21208
21840
  if (move === MAKES_A_BOARD) return found2;
21209
- if (!fs68.existsSync(path69.join(found2.board, "todo"))) {
21841
+ if (!fs70.existsSync(path71.join(found2.board, "todo"))) {
21210
21842
  die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
21211
21843
  kind: "board-incomplete",
21212
21844
  dir: found2.root
@@ -21215,13 +21847,13 @@ function whole(found2, move) {
21215
21847
  return found2;
21216
21848
  }
21217
21849
  function findBoardUpward(from, move) {
21218
- let dir = path69.resolve(from);
21850
+ let dir = path71.resolve(from);
21219
21851
  for (; ; ) {
21220
- if (hasBoard(dir)) return { root: dir, board: path69.join(dir, "docs", "kanban") };
21852
+ if (hasBoard(dir)) return { root: dir, board: path71.join(dir, "docs", "kanban") };
21221
21853
  if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
21222
- const kept2 = path69.join(dir, ".akb", "kanban");
21223
- if (move !== MAKES_A_BOARD && fs68.existsSync(path69.join(kept2, "todo"))) return { root: dir, board: kept2 };
21224
- const up = path69.dirname(dir);
21854
+ const kept2 = path71.join(dir, ".akb", "kanban");
21855
+ if (move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return { root: dir, board: kept2 };
21856
+ const up = path71.dirname(dir);
21225
21857
  if (up === dir) return null;
21226
21858
  dir = up;
21227
21859
  }
@@ -21229,11 +21861,11 @@ function findBoardUpward(from, move) {
21229
21861
  function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21230
21862
  const named2 = board2 ?? boardFromEnv();
21231
21863
  if (named2) {
21232
- const folder = path69.resolve(cwd, named2);
21233
- if (!fs68.existsSync(folder) && move !== MAKES_A_BOARD) {
21864
+ const folder = path71.resolve(cwd, named2);
21865
+ if (!fs70.existsSync(folder) && move !== MAKES_A_BOARD) {
21234
21866
  die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
21235
21867
  }
21236
- if (fs68.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21868
+ if (fs70.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21237
21869
  die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
21238
21870
  kind: "no-board",
21239
21871
  dir: folder
@@ -21242,24 +21874,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21242
21874
  return { root: projectRootOf(folder), board: folder, named: true };
21243
21875
  }
21244
21876
  if (dir !== null) {
21245
- const root2 = path69.resolve(dir);
21246
- if (!fs68.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
21247
- const kept2 = path69.join(root2, ".akb", "kanban");
21248
- if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs68.existsSync(path69.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
21877
+ const root2 = path71.resolve(dir);
21878
+ if (!fs70.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
21879
+ const kept2 = path71.join(root2, ".akb", "kanban");
21880
+ if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
21249
21881
  if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
21250
21882
  die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
21251
21883
  kind: "no-board",
21252
21884
  dir: root2
21253
21885
  });
21254
21886
  }
21255
- return whole({ root: root2, board: path69.join(root2, "docs", "kanban") }, move);
21887
+ return whole({ root: root2, board: path71.join(root2, "docs", "kanban") }, move);
21256
21888
  }
21257
21889
  const found2 = findBoardUpward(cwd, move);
21258
21890
  if (found2) return whole(found2, move);
21259
- if (move === MAKES_A_BOARD) return { root: path69.resolve(cwd), board: path69.join(path69.resolve(cwd), "docs", "kanban") };
21891
+ if (move === MAKES_A_BOARD) return { root: path71.resolve(cwd), board: path71.join(path71.resolve(cwd), "docs", "kanban") };
21260
21892
  die(
21261
- `no board here. Looked in ${path69.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
21262
- { kind: "no-board", dir: path69.resolve(cwd) }
21893
+ `no board here. Looked in ${path71.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
21894
+ { kind: "no-board", dir: path71.resolve(cwd) }
21263
21895
  );
21264
21896
  }
21265
21897
  function editDistance(a2, b2) {
@@ -21341,8 +21973,8 @@ var init_board_cli = __esm({
21341
21973
  init_io();
21342
21974
  init_pointer();
21343
21975
  MAKES_A_BOARD = "init";
21344
- hasBoard = (dir) => fs68.existsSync(path69.join(dir, "docs", "kanban"));
21345
- isBoardDir = (dir) => fs68.existsSync(path69.join(dir, "todo")) && fs68.existsSync(path69.join(dir, "config.md"));
21976
+ hasBoard = (dir) => fs70.existsSync(path71.join(dir, "docs", "kanban"));
21977
+ isBoardDir = (dir) => fs70.existsSync(path71.join(dir, "todo")) && fs70.existsSync(path71.join(dir, "config.md"));
21346
21978
  boardFromEnv = () => {
21347
21979
  const named2 = process.env.AI4KANBAN_BOARD?.trim();
21348
21980
  return named2 ? named2 : null;
@@ -21450,7 +22082,7 @@ var init_review_rejections = __esm({
21450
22082
  var refine_default;
21451
22083
  var init_refine = __esm({
21452
22084
  "../cli/src/guide/refine.md"() {
21453
- refine_default = '# Refine a card\n\nPlan one card in this session until it can be built. Change no project code.\n\n- **\u91CD\u590D\u5361\u7247**: \u82E5\u53D1\u73B0\u53E6\u4E00\u5F20\u4EFB\u52A1\u5B8C\u6574\u8986\u76D6\u672C\u5361\uFF0C\u5373\u4F7F\u5BF9\u65B9\u5C1A\u672A\u5B9E\u65BD\uFF0C\u4E5F\u5148\u5C06\u5176\u7F3A\u5C11\u7684\u6709\u7528\u4FE1\u606F\u8865\u5165\u5E76\u786E\u8BA4\u4FDD\u5B58\u6210\u529F\uFF1B\n \u4FDD\u5B58\u5931\u8D25\u5219\u4FDD\u7559\u672C\u5361\u5E76\u505C\u6B62\u3002\u6CA1\u6709\u4FE1\u606F\u9700\u8981\u8865\u5145\u6216\u5DF2\u4FDD\u5B58\u6210\u529F\u540E\uFF0C\u8FD0\u884C\n `akb raw reject <id> --reason "<\u627F\u63A5\u4EFB\u52A1\u7F16\u53F7\u53CA\u5B8C\u6574\u8986\u76D6\u539F\u56E0>"` \u5E76\u505C\u6B62\u3002\n \u4E0D\u8BF7\u6C42\u786E\u8BA4\uFF0C\u4E0D\u8FD0\u884C\u9884\u89C8\uFF1B\u4EC5\u90E8\u5206\u91CD\u53E0\u4E0D\u4E22\u5F03\u3002\n- **Unchecked card**: a card with `triage:` set and an empty `## Scope` was never checked\n against the project. Search the relevant code and docs first; when the project already does\n the work, or what it concerns no longer exists, run\n `akb raw reject <id> --reason "<what shows it>"` and stop.\n- **Gone or already done**: for any other card, append a question asking the user whether to\n discard it, run no preview agent, and stop.\n- **Split**: only when the card holds independently plannable areas and one is still vague,\n follow the group procedure in `akb guide add-task`, create each subtask, and stop: Cloud\n refines each one itself.\n- **Workflow rules**: write the card as the workflow rules at the end of this prompt say.\n- **Preview agents**: an agent\'s `After` names the previews it waits for; the board approves\n previews in stages, one stage per Approve, and the card\'s `previews` were chosen when its\n goal was written. A card without `previews` has not chosen: choose and save them first, as\n the list says, then run only its first stage. Run each agent the list above names whose\n section is missing or outdated with `akb previews <agent> <id> --print`, one at a time in this\n session; leave out `--print` only for an agent the list says runs in a session of its own.\n- **Stale mentions**: rewrite any sentence that relies on a card no longer on the board.\n- **Questions**: settle every decision you can and record the answers as `akb guide writing`\n says; ask only what `akb guide update-questions` says to ask.\n- **Write**: shape the card as `akb guide writing` says, then run `akb raw validate <id>` and\n fix every reported line.\n- **Think like the one who ships it**: settle every fact from the code and authoritative\n sources, and write what shipping takes beyond the happy path: existing data and settings,\n release and rollback, failure, access, and ongoing cost. Once the card validates, judge\n whether it can be built as written, or before its last\n Approve: if so, run `akb raw update <id> --status ready`; otherwise leave what blocks it as\n an open question.\n\nFollow any closing steps the flow printed, then stop: the user approves the previews or starts\nthe build.\n';
22085
+ refine_default = '# Refine a card\n\nPlan one card in this session until it can be built.\n\n- **\u91CD\u590D\u5361\u7247**: \u82E5\u53D1\u73B0\u53E6\u4E00\u5F20\u4EFB\u52A1\u5B8C\u6574\u8986\u76D6\u672C\u5361\uFF0C\u5373\u4F7F\u5BF9\u65B9\u5C1A\u672A\u5B9E\u65BD\uFF0C\u4E5F\u5148\u5C06\u5176\u7F3A\u5C11\u7684\u6709\u7528\u4FE1\u606F\u8865\u5165\u5E76\u786E\u8BA4\u4FDD\u5B58\u6210\u529F\uFF1B\n \u4FDD\u5B58\u5931\u8D25\u5219\u4FDD\u7559\u672C\u5361\u5E76\u505C\u6B62\u3002\u6CA1\u6709\u4FE1\u606F\u9700\u8981\u8865\u5145\u6216\u5DF2\u4FDD\u5B58\u6210\u529F\u540E\uFF0C\u8FD0\u884C\n `akb raw reject <id> --reason "<\u627F\u63A5\u4EFB\u52A1\u7F16\u53F7\u53CA\u5B8C\u6574\u8986\u76D6\u539F\u56E0>"` \u5E76\u505C\u6B62\u3002\n \u4E0D\u8BF7\u6C42\u786E\u8BA4\uFF0C\u4E0D\u8FD0\u884C\u9884\u89C8\uFF1B\u4EC5\u90E8\u5206\u91CD\u53E0\u4E0D\u4E22\u5F03\u3002\n- **Unchecked card**: a card with `triage:` set and an empty `## Scope` was never checked\n against the project. Check it first; when the project already does\n the work, or what it concerns no longer exists, run\n `akb raw reject <id> --reason "<what shows it>"` and stop.\n- **Gone or already done**: for any other card, append a question asking the user whether to\n discard it, run no preview agent, and stop.\n- **Workflow rules**: write the card as the workflow rules at the end of this prompt say.\n- **Preview agents**: an agent\'s `After` names the previews it waits for; the board approves\n previews in stages, one stage per Approve, and the card\'s `previews` were chosen when its\n goal was written. A card without `previews` has not chosen: choose and save them first, as\n the list says, then run only its first stage. Run each agent the list above names whose\n section is missing or outdated with `akb previews <agent> <id> --print`, one at a time in this\n session; leave out `--print` only for an agent the list says runs in a session of its own.\n- **Stale mentions**: rewrite any sentence that relies on a card no longer on the board.\n- **Questions**: settle every decision you can and record the answers as `akb guide writing`\n says; ask only what `akb guide update-questions` says to ask.\n- **Write**: shape the card as `akb guide writing` says, then run `akb raw validate <id>` and\n fix every reported line.\n- **Ready**: settle every fact from the project and authoritative sources. Once the card\n validates, judge whether it can be built as written, or before its last Approve: if so, run\n `akb raw update <id> --status ready`; otherwise leave what blocks it as an open question.\n\nFollow any closing steps the flow printed, then stop: the user approves the previews or starts\nthe build.\n';
21454
22086
  }
21455
22087
  });
21456
22088
 
@@ -21506,7 +22138,7 @@ var init_troubleshoot = __esm({
21506
22138
  var write_agent_default;
21507
22139
  var init_write_agent = __esm({
21508
22140
  "../cli/src/guide/write-agent.md"() {
21509
- 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---\n\nYou write the words a screen shows.\n```\n\nIts workflow, not the agent, sets its role: `WORKFLOW.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\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 zh:\n # Display name; does not change the agent's name.\n title: \u754C\u9762\u6587\u6848\u5E08\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 a user's\ncorrection should change the agent's next output. Otherwise say in `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 answers or 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).\nTheir usage documentation is supplied with the run; omitted declarations default to Asset.\nUse `akb components --agent <name> --docs` or `--workflow <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.\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 previews`. Read all trigger conditions with `akb 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 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- **Workflow**: a new agent belongs to the workflow it was created in and starts switched on;\n a preview agent joins the end of that workflow's `previews`. `akb previews` refuses it while it is off.\n Switch it in that workflow's `WORKFLOW.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 workflow's `scheduled`.\n";
22141
+ 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 Workflow 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 workflow, not the agent, sets its role: `WORKFLOW.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\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 zh:\n # Display name; does not change the agent's name.\n title: \u754C\u9762\u6587\u6848\u5E08\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 a user's\ncorrection should change the agent's next output. Otherwise say in `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 answers or 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).\nTheir usage documentation is supplied with the run; omitted declarations default to Asset.\nUse `akb components --agent <name> --docs` or `--workflow <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.\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 previews`. Read all trigger conditions with `akb 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 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- **Workflow**: a new agent belongs to the workflow it was created in and starts switched on;\n a preview agent joins the end of that workflow's `previews`. `akb previews` refuses it while it is off.\n Switch it in that workflow's `WORKFLOW.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 workflow's `scheduled`.\n";
21510
22142
  }
21511
22143
  });
21512
22144
 
@@ -21599,8 +22231,8 @@ var init_guide = __esm({
21599
22231
  });
21600
22232
 
21601
22233
  // ../cli/src/lib/agent/approve.ts
21602
- import fs74 from "node:fs";
21603
- import path75 from "node:path";
22234
+ import fs77 from "node:fs";
22235
+ import path78 from "node:path";
21604
22236
  function approvalRequest(req) {
21605
22237
  const id = req.id;
21606
22238
  const card = id === void 0 ? null : findCard(id);
@@ -21618,12 +22250,12 @@ function advancePhase(id) {
21618
22250
  const card = findCard(id);
21619
22251
  const found2 = locate(id);
21620
22252
  if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
21621
- const file = found2.kind === "group" ? path75.join(found2.target, "root.md") : found2.target;
21622
- const { meta, body } = parseFrontmatter(fs74.readFileSync(file, "utf8"));
22253
+ const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
22254
+ const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
21623
22255
  if (!meta) return { error: `#${id} has no frontmatter` };
21624
22256
  meta.phase = card.stage + 1;
21625
22257
  meta.status = "todo";
21626
- fs74.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
22258
+ fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
21627
22259
  return null;
21628
22260
  }
21629
22261
  var init_approve = __esm({
@@ -21756,16 +22388,16 @@ var init_start = __esm({
21756
22388
  });
21757
22389
 
21758
22390
  // ../cli/src/lib/agent/task-chats.ts
21759
- import fs75 from "node:fs";
21760
- import path76 from "node:path";
22391
+ import fs78 from "node:fs";
22392
+ import path79 from "node:path";
21761
22393
  function taskChatFile(task, home3) {
21762
22394
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
21763
- return path76.join(taskChatsDir(home3), `${task}.jsonl`);
22395
+ return path79.join(taskChatsDir(home3), `${task}.jsonl`);
21764
22396
  }
21765
22397
  function readTaskChat(task, home3) {
21766
22398
  let text5;
21767
22399
  try {
21768
- text5 = fs75.readFileSync(taskChatFile(task, home3), "utf8");
22400
+ text5 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
21769
22401
  } catch {
21770
22402
  return [];
21771
22403
  }
@@ -21786,13 +22418,13 @@ var init_task_chats = __esm({
21786
22418
  "use strict";
21787
22419
  init_home();
21788
22420
  TASK = /^[\w-]{1,100}$/;
21789
- taskChatsDir = (home3 = machineHome()) => path76.join(home3, "chats");
22421
+ taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
21790
22422
  }
21791
22423
  });
21792
22424
 
21793
22425
  // ../cli/src/lib/agent/memory-review.ts
21794
- import fs76 from "node:fs";
21795
- import path77 from "node:path";
22426
+ import fs79 from "node:fs";
22427
+ import path80 from "node:path";
21796
22428
  function taskChatsToReview(tasks) {
21797
22429
  const out = [];
21798
22430
  for (const ref of [...new Set(tasks)]) {
@@ -21814,8 +22446,8 @@ function readArchived2(id) {
21814
22446
  const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
21815
22447
  if (!found2) return null;
21816
22448
  try {
21817
- const file = found2.kind === "group" ? path77.join(found2.target, "root.md") : found2.target;
21818
- const { meta, body } = parseFrontmatter(fs76.readFileSync(file, "utf8"));
22449
+ const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
22450
+ const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
21819
22451
  if (!meta) return null;
21820
22452
  return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
21821
22453
  } catch {
@@ -21884,17 +22516,17 @@ var init_memory_review = __esm({
21884
22516
  });
21885
22517
 
21886
22518
  // ../cli/src/lib/agent/dismissal-review.ts
21887
- import fs77 from "node:fs";
21888
- import path78 from "node:path";
22519
+ import fs80 from "node:fs";
22520
+ import path81 from "node:path";
21889
22521
  function rejectionsToReview() {
21890
- const dir = path78.join(ARCHIVE, REJECTIONS_TO_REVIEW);
21891
- if (!fs77.existsSync(dir)) return [];
22522
+ const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
22523
+ if (!fs80.existsSync(dir)) return [];
21892
22524
  const found2 = [];
21893
22525
  for (const file of walkMd(dir)) {
21894
22526
  const id = archivedId(file);
21895
22527
  if (id === null) continue;
21896
22528
  try {
21897
- const { meta } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
22529
+ const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
21898
22530
  if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
21899
22531
  found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
21900
22532
  } catch {
@@ -21924,7 +22556,7 @@ function citedSources(text5) {
21924
22556
  function withdrawnSources() {
21925
22557
  const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
21926
22558
  try {
21927
- return citedSources(fs77.readFileSync(file, "utf8"));
22559
+ return citedSources(fs80.readFileSync(file, "utf8"));
21928
22560
  } catch {
21929
22561
  return [];
21930
22562
  }
@@ -21949,8 +22581,8 @@ var init_dismissal_review = __esm({
21949
22581
  });
21950
22582
 
21951
22583
  // ../cli/src/lib/agent/flow.ts
21952
- import fs78 from "node:fs";
21953
- import path79 from "node:path";
22584
+ import fs81 from "node:fs";
22585
+ import path82 from "node:path";
21954
22586
  function readCard2(id, home3 = "board") {
21955
22587
  const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
21956
22588
  const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
@@ -21960,10 +22592,10 @@ function readCard2(id, home3 = "board") {
21960
22592
  { kind: "card-not-found", id }
21961
22593
  );
21962
22594
  }
21963
- const file = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
22595
+ const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
21964
22596
  let text5;
21965
22597
  try {
21966
- text5 = fs78.readFileSync(file, "utf8");
22598
+ text5 = fs81.readFileSync(file, "utf8");
21967
22599
  } catch {
21968
22600
  die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
21969
22601
  }
@@ -22651,94 +23283,6 @@ var init_refine2 = __esm({
22651
23283
  }
22652
23284
  });
22653
23285
 
22654
- // ../artifact-sdk/src/internal/references.ts
22655
- function bodyReferences(body) {
22656
- const lines = body.replace(/<!--[^]*?-->/g, "").split(/\r?\n/);
22657
- let fence = "";
22658
- let inTag = false;
22659
- const out = [];
22660
- const visible = [];
22661
- for (const line of lines) {
22662
- const delimiter = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
22663
- if (fence) {
22664
- if (delimiter && delimiter[0] === fence[0] && delimiter.length >= fence.length) fence = "";
22665
- visible.push("");
22666
- continue;
22667
- }
22668
- if (delimiter) {
22669
- fence = delimiter;
22670
- visible.push("");
22671
- continue;
22672
- }
22673
- const kept2 = inTag || !/^(?: {4}|\t)/.test(line);
22674
- visible.push(kept2 ? line : "");
22675
- if (kept2 && /^ {0,3}<(?:Asset|Mockup|Compare|Storyboard)\b/.test(line)) inTag = true;
22676
- if (line.includes("/>")) inTag = false;
22677
- }
22678
- const text5 = visible.join("\n").replace(/(`+)[^]*?\1/g, "");
22679
- const tag = /<(Asset|Mockup|Compare|Storyboard)\b([^<>]*?)\/>/g;
22680
- const blocks = text5.matchAll(/^ {0,3}(?:<(?:Asset|Mockup|Compare|Storyboard)\b[^<>]*?\/>[ \t]*(?:\n[ \t]*)?)+$/gm);
22681
- for (const block of blocks) {
22682
- const tags = [...block[0].matchAll(tag)];
22683
- for (const m of tags) {
22684
- const a2 = {};
22685
- for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
22686
- if (m[1] === "Compare") {
22687
- if (!a2.a || !a2.b) continue;
22688
- for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], purpose: "compare" });
22689
- } else if (a2.src) {
22690
- out.push({ src: a2.src, purpose: m[1] === "Storyboard" ? "storyboard" : "asset" });
22691
- if (a2.variants) {
22692
- try {
22693
- const v = JSON.parse(a2.variants);
22694
- if (isObject(v)) {
22695
- for (const src of Object.values(v)) if (typeof src === "string" && src) out.push({ src, purpose: "asset" });
22696
- }
22697
- } catch {
22698
- }
22699
- }
22700
- }
22701
- }
22702
- }
22703
- for (const m of text5.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1], purpose: "asset" });
22704
- return out;
22705
- }
22706
- function kindOf2(ext) {
22707
- if (ext === ".tsx" || ext === ".html") return "html";
22708
- if (ext === ".md" || ext === ".mdx") return "markdown";
22709
- const type = TYPES2[ext] ?? "";
22710
- if (type.startsWith("image/")) return "image";
22711
- return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
22712
- }
22713
- var isObject, bodySources, TYPES2;
22714
- var init_references = __esm({
22715
- "../artifact-sdk/src/internal/references.ts"() {
22716
- "use strict";
22717
- isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
22718
- bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
22719
- TYPES2 = {
22720
- ".png": "image/png",
22721
- ".jpg": "image/jpeg",
22722
- ".jpeg": "image/jpeg",
22723
- ".gif": "image/gif",
22724
- ".webp": "image/webp",
22725
- ".svg": "image/svg+xml",
22726
- ".mp4": "video/mp4",
22727
- ".webm": "video/webm",
22728
- ".mp3": "audio/mpeg",
22729
- ".pdf": "application/pdf",
22730
- ".html": "text/html",
22731
- ".md": "text/markdown",
22732
- ".mdx": "text/markdown",
22733
- ".mov": "video/quicktime",
22734
- ".wav": "audio/wav",
22735
- ".m4a": "audio/mp4",
22736
- ".json": "application/json",
22737
- ".txt": "text/plain"
22738
- };
22739
- }
22740
- });
22741
-
22742
23286
  // ../cli/node_modules/react/cjs/react.production.js
22743
23287
  var require_react_production = __commonJS({
22744
23288
  "../cli/node_modules/react/cjs/react.production.js"(exports) {
@@ -30262,13 +30806,13 @@ var require_react_dom_server_node_production = __commonJS({
30262
30806
  var target = currentView;
30263
30807
  0 < writtenBytes && (target = currentView.subarray(writtenBytes));
30264
30808
  target = textEncoder.encodeInto(chunk, target);
30265
- var read4 = target.read;
30809
+ var read5 = target.read;
30266
30810
  writtenBytes += target.written;
30267
- read4 < chunk.length && (writeToDestination(
30811
+ read5 < chunk.length && (writeToDestination(
30268
30812
  destination,
30269
30813
  currentView.subarray(0, writtenBytes)
30270
30814
  ), currentView = new Uint8Array(4096), writtenBytes = textEncoder.encodeInto(
30271
- chunk.slice(read4),
30815
+ chunk.slice(read5),
30272
30816
  currentView
30273
30817
  ).written);
30274
30818
  4096 === writtenBytes && (writeToDestination(destination, currentView), currentView = new Uint8Array(4096), writtenBytes = 0);
@@ -44018,13 +44562,13 @@ var require_react_dom_server_node_development = __commonJS({
44018
44562
  var target = currentView;
44019
44563
  0 < writtenBytes && (target = currentView.subarray(writtenBytes));
44020
44564
  target = textEncoder.encodeInto(chunk, target);
44021
- var read4 = target.read;
44565
+ var read5 = target.read;
44022
44566
  writtenBytes += target.written;
44023
- read4 < chunk.length && (writeToDestination(
44567
+ read5 < chunk.length && (writeToDestination(
44024
44568
  destination,
44025
44569
  currentView.subarray(0, writtenBytes)
44026
44570
  ), currentView = new Uint8Array(4096), writtenBytes = textEncoder.encodeInto(
44027
- chunk.slice(read4),
44571
+ chunk.slice(read5),
44028
44572
  currentView
44029
44573
  ).written);
44030
44574
  4096 === writtenBytes && (writeToDestination(destination, currentView), currentView = new Uint8Array(4096), writtenBytes = 0);
@@ -63946,8 +64490,8 @@ var require_JSXTransformer = __commonJS({
63946
64490
  }
63947
64491
  if (this.isAutomaticRuntime) {
63948
64492
  if (this.importProcessor) {
63949
- for (const [path87, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
63950
- prefix += `var ${resolvedName} = require("${path87}");`;
64493
+ for (const [path90, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
64494
+ prefix += `var ${resolvedName} = require("${path90}");`;
63951
64495
  }
63952
64496
  } else {
63953
64497
  const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
@@ -64140,11 +64684,11 @@ var require_JSXTransformer = __commonJS({
64140
64684
  }
64141
64685
  claimAutoImportedName(funcName, importPathSuffix) {
64142
64686
  if (this.importProcessor) {
64143
- const path87 = this.jsxImportSource + importPathSuffix;
64144
- if (!this.cjsAutomaticModuleNameResolutions[path87]) {
64145
- this.cjsAutomaticModuleNameResolutions[path87] = this.importProcessor.getFreeIdentifierForPath(path87);
64687
+ const path90 = this.jsxImportSource + importPathSuffix;
64688
+ if (!this.cjsAutomaticModuleNameResolutions[path90]) {
64689
+ this.cjsAutomaticModuleNameResolutions[path90] = this.importProcessor.getFreeIdentifierForPath(path90);
64146
64690
  }
64147
- return `${this.cjsAutomaticModuleNameResolutions[path87]}.${funcName}`;
64691
+ return `${this.cjsAutomaticModuleNameResolutions[path90]}.${funcName}`;
64148
64692
  } else {
64149
64693
  if (!this.esmAutomaticImportNameResolutions[funcName]) {
64150
64694
  this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
@@ -64580,7 +65124,7 @@ var require_CJSImportProcessor = __commonJS({
64580
65124
  */
64581
65125
  pruneTypeOnlyImports() {
64582
65126
  this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
64583
- for (const [path87, importInfo] of this.importInfoByPath.entries()) {
65127
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
64584
65128
  if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
64585
65129
  continue;
64586
65130
  }
@@ -64590,7 +65134,7 @@ var require_CJSImportProcessor = __commonJS({
64590
65134
  ...importInfo.namedImports.map(({ localName }) => localName)
64591
65135
  ];
64592
65136
  if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
64593
- this.importsToReplace.set(path87, "");
65137
+ this.importsToReplace.set(path90, "");
64594
65138
  }
64595
65139
  }
64596
65140
  }
@@ -64598,7 +65142,7 @@ var require_CJSImportProcessor = __commonJS({
64598
65142
  return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
64599
65143
  }
64600
65144
  generateImportReplacements() {
64601
- for (const [path87, importInfo] of this.importInfoByPath.entries()) {
65145
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
64602
65146
  const {
64603
65147
  defaultNames,
64604
65148
  wildcardNames,
@@ -64608,17 +65152,17 @@ var require_CJSImportProcessor = __commonJS({
64608
65152
  hasStarExport
64609
65153
  } = importInfo;
64610
65154
  if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
64611
- this.importsToReplace.set(path87, `require('${path87}');`);
65155
+ this.importsToReplace.set(path90, `require('${path90}');`);
64612
65156
  continue;
64613
65157
  }
64614
- const primaryImportName = this.getFreeIdentifierForPath(path87);
65158
+ const primaryImportName = this.getFreeIdentifierForPath(path90);
64615
65159
  let secondaryImportName;
64616
65160
  if (this.enableLegacyTypeScriptModuleInterop) {
64617
65161
  secondaryImportName = primaryImportName;
64618
65162
  } else {
64619
- secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path87);
65163
+ secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path90);
64620
65164
  }
64621
- let requireCode = `var ${primaryImportName} = require('${path87}');`;
65165
+ let requireCode = `var ${primaryImportName} = require('${path90}');`;
64622
65166
  if (wildcardNames.length > 0) {
64623
65167
  for (const wildcardName of wildcardNames) {
64624
65168
  const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
@@ -64646,7 +65190,7 @@ var require_CJSImportProcessor = __commonJS({
64646
65190
  "createStarExport"
64647
65191
  )}(${primaryImportName});`;
64648
65192
  }
64649
- this.importsToReplace.set(path87, requireCode);
65193
+ this.importsToReplace.set(path90, requireCode);
64650
65194
  for (const defaultName of defaultNames) {
64651
65195
  this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
64652
65196
  }
@@ -64655,8 +65199,8 @@ var require_CJSImportProcessor = __commonJS({
64655
65199
  }
64656
65200
  }
64657
65201
  }
64658
- getFreeIdentifierForPath(path87) {
64659
- const components = path87.split("/");
65202
+ getFreeIdentifierForPath(path90) {
65203
+ const components = path90.split("/");
64660
65204
  const lastComponent = components[components.length - 1];
64661
65205
  const baseName = lastComponent.replace(/\W/g, "");
64662
65206
  return this.nameManager.claimFreeName(`_${baseName}`);
@@ -64701,8 +65245,8 @@ var require_CJSImportProcessor = __commonJS({
64701
65245
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
64702
65246
  throw new Error("Expected string token at the end of import statement.");
64703
65247
  }
64704
- const path87 = this.tokens.stringValueAtIndex(index);
64705
- const importInfo = this.getImportInfo(path87);
65248
+ const path90 = this.tokens.stringValueAtIndex(index);
65249
+ const importInfo = this.getImportInfo(path90);
64706
65250
  importInfo.defaultNames.push(...defaultNames);
64707
65251
  importInfo.wildcardNames.push(...wildcardNames);
64708
65252
  importInfo.namedImports.push(...namedImports);
@@ -64769,8 +65313,8 @@ var require_CJSImportProcessor = __commonJS({
64769
65313
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
64770
65314
  throw new Error("Expected string token at the end of import statement.");
64771
65315
  }
64772
- const path87 = this.tokens.stringValueAtIndex(index);
64773
- const importInfo = this.getImportInfo(path87);
65316
+ const path90 = this.tokens.stringValueAtIndex(index);
65317
+ const importInfo = this.getImportInfo(path90);
64774
65318
  importInfo.namedExports.push(...namedImports);
64775
65319
  }
64776
65320
  preprocessExportStarAtIndex(index) {
@@ -64785,8 +65329,8 @@ var require_CJSImportProcessor = __commonJS({
64785
65329
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
64786
65330
  throw new Error("Expected string token at the end of star export statement.");
64787
65331
  }
64788
- const path87 = this.tokens.stringValueAtIndex(index);
64789
- const importInfo = this.getImportInfo(path87);
65332
+ const path90 = this.tokens.stringValueAtIndex(index);
65333
+ const importInfo = this.getImportInfo(path90);
64790
65334
  if (exportedName !== null) {
64791
65335
  importInfo.exportStarNames.push(exportedName);
64792
65336
  } else {
@@ -64826,8 +65370,8 @@ var require_CJSImportProcessor = __commonJS({
64826
65370
  * Get a mutable import info object for this path, creating one if it doesn't
64827
65371
  * exist yet.
64828
65372
  */
64829
- getImportInfo(path87) {
64830
- const existingInfo = this.importInfoByPath.get(path87);
65373
+ getImportInfo(path90) {
65374
+ const existingInfo = this.importInfoByPath.get(path90);
64831
65375
  if (existingInfo) {
64832
65376
  return existingInfo;
64833
65377
  }
@@ -64840,7 +65384,7 @@ var require_CJSImportProcessor = __commonJS({
64840
65384
  exportStarNames: [],
64841
65385
  hasStarExport: false
64842
65386
  };
64843
- this.importInfoByPath.set(path87, newInfo);
65387
+ this.importInfoByPath.set(path90, newInfo);
64844
65388
  return newInfo;
64845
65389
  }
64846
65390
  addExportBinding(localName, exportedName) {
@@ -65420,16 +65964,16 @@ var require_resolve_uri_umd = __commonJS({
65420
65964
  }
65421
65965
  function parseFileUrl(input) {
65422
65966
  const match = fileRegex.exec(input);
65423
- const path87 = match[2];
65424
- return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path87) ? path87 : "/" + path87, match[3] || "", match[4] || "");
65967
+ const path90 = match[2];
65968
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path90) ? path90 : "/" + path90, match[3] || "", match[4] || "");
65425
65969
  }
65426
- function makeUrl(scheme, user, host2, port, path87, query, hash2) {
65970
+ function makeUrl(scheme, user, host2, port, path90, query, hash2) {
65427
65971
  return {
65428
65972
  scheme,
65429
65973
  user,
65430
65974
  host: host2,
65431
65975
  port,
65432
- path: path87,
65976
+ path: path90,
65433
65977
  query,
65434
65978
  hash: hash2,
65435
65979
  type: 7
@@ -65459,11 +66003,11 @@ var require_resolve_uri_umd = __commonJS({
65459
66003
  url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
65460
66004
  return url;
65461
66005
  }
65462
- function stripPathFilename(path87) {
65463
- if (path87.endsWith("/.."))
65464
- return path87;
65465
- const index = path87.lastIndexOf("/");
65466
- return path87.slice(0, index + 1);
66006
+ function stripPathFilename(path90) {
66007
+ if (path90.endsWith("/.."))
66008
+ return path90;
66009
+ const index = path90.lastIndexOf("/");
66010
+ return path90.slice(0, index + 1);
65467
66011
  }
65468
66012
  function mergePaths(url, base) {
65469
66013
  normalizePath(base, base.type);
@@ -65501,14 +66045,14 @@ var require_resolve_uri_umd = __commonJS({
65501
66045
  pieces[pointer++] = piece;
65502
66046
  positive++;
65503
66047
  }
65504
- let path87 = "";
66048
+ let path90 = "";
65505
66049
  for (let i = 1; i < pointer; i++) {
65506
- path87 += "/" + pieces[i];
66050
+ path90 += "/" + pieces[i];
65507
66051
  }
65508
- if (!path87 || addTrailingSlash && !path87.endsWith("/..")) {
65509
- path87 += "/";
66052
+ if (!path90 || addTrailingSlash && !path90.endsWith("/..")) {
66053
+ path90 += "/";
65510
66054
  }
65511
- url.path = path87;
66055
+ url.path = path90;
65512
66056
  }
65513
66057
  function resolve2(input, base) {
65514
66058
  if (!input && !base)
@@ -65549,13 +66093,13 @@ var require_resolve_uri_umd = __commonJS({
65549
66093
  case 3:
65550
66094
  return queryHash;
65551
66095
  case 4: {
65552
- const path87 = url.path.slice(1);
65553
- if (!path87)
66096
+ const path90 = url.path.slice(1);
66097
+ if (!path90)
65554
66098
  return queryHash || ".";
65555
- if (isRelative(base || input) && !isRelative(path87)) {
65556
- return "./" + path87 + queryHash;
66099
+ if (isRelative(base || input) && !isRelative(path90)) {
66100
+ return "./" + path90 + queryHash;
65557
66101
  }
65558
- return path87 + queryHash;
66102
+ return path90 + queryHash;
65559
66103
  }
65560
66104
  case 5:
65561
66105
  return url.path + queryHash;
@@ -65654,12 +66198,12 @@ var require_trace_mapping_umd = __commonJS({
65654
66198
  module2.exports = __toCommonJS(trace_mapping_exports);
65655
66199
  var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
65656
66200
  var import_resolve_uri = __toESM2(require_resolve_uri());
65657
- function stripFilename(path87) {
65658
- if (!path87) return "";
65659
- const index = path87.lastIndexOf("/");
65660
- return path87.slice(0, index + 1);
66201
+ function stripFilename(path90) {
66202
+ if (!path90) return "";
66203
+ const index = path90.lastIndexOf("/");
66204
+ return path90.slice(0, index + 1);
65661
66205
  }
65662
- function resolver(mapUrl, sourceRoot) {
66206
+ function resolver2(mapUrl, sourceRoot) {
65663
66207
  const from = stripFilename(mapUrl);
65664
66208
  const prefix = sourceRoot ? sourceRoot + "/" : "";
65665
66209
  return (source) => (0, import_resolve_uri.default)(prefix + (source || ""), from);
@@ -65908,7 +66452,7 @@ var require_trace_mapping_umd = __commonJS({
65908
66452
  this.sources = sources2;
65909
66453
  this.sourcesContent = sourcesContent;
65910
66454
  this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
65911
- const resolve2 = resolver(mapUrl, sourceRoot);
66455
+ const resolve2 = resolver2(mapUrl, sourceRoot);
65912
66456
  this.resolvedSources = sources2.map(resolve2);
65913
66457
  const { mappings } = parsed;
65914
66458
  if (typeof mappings === "string") {
@@ -66865,9 +67409,9 @@ var require_util2 = __commonJS({
66865
67409
  /** @class */
66866
67410
  (function(_super) {
66867
67411
  __extends(VError2, _super);
66868
- function VError2(path87, message) {
67412
+ function VError2(path90, message) {
66869
67413
  var _this = _super.call(this, message) || this;
66870
- _this.path = path87;
67414
+ _this.path = path90;
66871
67415
  Object.setPrototypeOf(_this, VError2.prototype);
66872
67416
  return _this;
66873
67417
  }
@@ -66927,26 +67471,26 @@ var require_util2 = __commonJS({
66927
67471
  (_b = this._messages).push.apply(_b, best._messages);
66928
67472
  }
66929
67473
  };
66930
- DetailContext2.prototype.getError = function(path87) {
67474
+ DetailContext2.prototype.getError = function(path90) {
66931
67475
  var msgParts = [];
66932
67476
  for (var i = this._propNames.length - 1; i >= 0; i--) {
66933
67477
  var p2 = this._propNames[i];
66934
- path87 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67478
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
66935
67479
  var m = this._messages[i];
66936
67480
  if (m) {
66937
- msgParts.push(path87 + " " + m);
67481
+ msgParts.push(path90 + " " + m);
66938
67482
  }
66939
67483
  }
66940
- return new VError(path87, msgParts.join("; "));
67484
+ return new VError(path90, msgParts.join("; "));
66941
67485
  };
66942
- DetailContext2.prototype.getErrorDetail = function(path87) {
67486
+ DetailContext2.prototype.getErrorDetail = function(path90) {
66943
67487
  var details = [];
66944
67488
  for (var i = this._propNames.length - 1; i >= 0; i--) {
66945
67489
  var p2 = this._propNames[i];
66946
- path87 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67490
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
66947
67491
  var message = this._messages[i];
66948
67492
  if (message) {
66949
- details.push({ path: path87, message });
67493
+ details.push({ path: path90, message });
66950
67494
  }
66951
67495
  }
66952
67496
  var detail = null;
@@ -67759,8 +68303,8 @@ var require_dist = __commonJS({
67759
68303
  this.checkerPlain = this.ttype.getChecker(suite, false);
67760
68304
  this.checkerStrict = this.ttype.getChecker(suite, true);
67761
68305
  }
67762
- Checker2.prototype.setReportedPath = function(path87) {
67763
- this._path = path87;
68306
+ Checker2.prototype.setReportedPath = function(path90) {
68307
+ this._path = path90;
67764
68308
  };
67765
68309
  Checker2.prototype.check = function(value) {
67766
68310
  return this._doCheck(this.checkerPlain, value);
@@ -73193,9 +73737,9 @@ var require_CJSImportTransformer = __commonJS({
73193
73737
  if (shouldElideImport) {
73194
73738
  this.tokens.removeToken();
73195
73739
  } else {
73196
- const path87 = this.tokens.stringValue();
73197
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path87));
73198
- this.tokens.appendCode(this.importProcessor.claimImportCode(path87));
73740
+ const path90 = this.tokens.stringValue();
73741
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
73742
+ this.tokens.appendCode(this.importProcessor.claimImportCode(path90));
73199
73743
  }
73200
73744
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
73201
73745
  if (this.tokens.matches1(_types.TokenType.semi)) {
@@ -73775,8 +74319,8 @@ var require_CJSImportTransformer = __commonJS({
73775
74319
  }
73776
74320
  if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
73777
74321
  this.tokens.removeToken();
73778
- const path87 = this.tokens.stringValue();
73779
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path87));
74322
+ const path90 = this.tokens.stringValue();
74323
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
73780
74324
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
73781
74325
  } else {
73782
74326
  this.tokens.appendCode(exportStatements.join(" "));
@@ -73790,8 +74334,8 @@ var require_CJSImportTransformer = __commonJS({
73790
74334
  while (!this.tokens.matches1(_types.TokenType.string)) {
73791
74335
  this.tokens.removeToken();
73792
74336
  }
73793
- const path87 = this.tokens.stringValue();
73794
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path87));
74337
+ const path90 = this.tokens.stringValue();
74338
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
73795
74339
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
73796
74340
  if (this.tokens.matches1(_types.TokenType.semi)) {
73797
74341
  this.tokens.removeToken();
@@ -103645,9 +104189,9 @@ var init_bundle_mjs = __esm({
103645
104189
  processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
103646
104190
  }
103647
104191
  };
103648
- getPart = (classPartObject, path87) => {
104192
+ getPart = (classPartObject, path90) => {
103649
104193
  let current = classPartObject;
103650
- const parts = path87.split(CLASS_PART_SEPARATOR);
104194
+ const parts = path90.split(CLASS_PART_SEPARATOR);
103651
104195
  const len = parts.length;
103652
104196
  for (let i = 0; i < len; i++) {
103653
104197
  const part = parts[i];
@@ -106897,8 +107441,8 @@ var init_dist = __esm({
106897
107441
  });
106898
107442
 
106899
107443
  // ../cli/src/lib/draw-mockup.ts
106900
- import fs79 from "node:fs";
106901
- import path81 from "node:path";
107444
+ import fs82 from "node:fs";
107445
+ import path84 from "node:path";
106902
107446
  import vm from "node:vm";
106903
107447
  async function loadPackage(id) {
106904
107448
  if (id === "react") return import_react3.default;
@@ -106911,22 +107455,22 @@ async function loadPackage(id) {
106911
107455
  return { __esModule: true, ...await load() };
106912
107456
  }
106913
107457
  function resolveFile(id, from, folder) {
106914
- const at2 = path81.resolve(path81.dirname(from), id);
106915
- if (at2 !== folder && !at2.startsWith(folder + path81.sep)) throw new Error(`${id} is outside the mockup's folder`);
106916
- const tries = path81.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path81.join(at2, `index${e2}`))];
106917
- const file = tries.find((f2) => fs79.statSync(f2, { throwIfNoEntry: false })?.isFile());
107458
+ const at2 = path84.resolve(path84.dirname(from), id);
107459
+ if (at2 !== folder && !at2.startsWith(folder + path84.sep)) throw new Error(`${id} is outside the mockup's folder`);
107460
+ const tries = path84.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path84.join(at2, `index${e2}`))];
107461
+ const file = tries.find((f2) => fs82.statSync(f2, { throwIfNoEntry: false })?.isFile());
106918
107462
  if (!file) throw new Error(`no such file: ${id}`);
106919
107463
  return file;
106920
107464
  }
106921
107465
  async function readGraph(entry) {
106922
- const folder = path81.dirname(entry);
107466
+ const folder = path84.dirname(entry);
106923
107467
  const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
106924
107468
  const walk3 = async (file) => {
106925
107469
  if (graph.code.has(file)) return;
106926
107470
  if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
106927
107471
  let location = file;
106928
107472
  try {
106929
- const js = (0, import_sucrase.transform)(fs79.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
107473
+ const js = (0, import_sucrase.transform)(fs82.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
106930
107474
  graph.code.set(file, js);
106931
107475
  const link2 = /* @__PURE__ */ new Map();
106932
107476
  graph.links.set(file, link2);
@@ -106940,7 +107484,7 @@ async function readGraph(entry) {
106940
107484
  const target = resolveFile(id, file, folder);
106941
107485
  link2.set(id, target);
106942
107486
  if (!target.endsWith(".css")) await walk3(target);
106943
- else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs79.readFileSync(target, "utf8") });
107487
+ else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs82.readFileSync(target, "utf8") });
106944
107488
  }
106945
107489
  } catch (error) {
106946
107490
  throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
@@ -106957,29 +107501,17 @@ function run2(script, context, name, deadline, lineOffset = 0) {
106957
107501
  async function tailwindFor(markup, sheets) {
106958
107502
  const source = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
106959
107503
  const compiler = await rc(source, {
106960
- base: sheets.length ? path81.dirname(sheets[0].path) : "/",
107504
+ base: sheets.length ? path84.dirname(sheets[0].path) : "/",
106961
107505
  loadStylesheet: async (id, from) => {
106962
107506
  if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
106963
107507
  if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
106964
- const at2 = path81.resolve(from, id);
106965
- return { path: at2, base: path81.dirname(at2), content: fs79.readFileSync(at2, "utf8") };
107508
+ const at2 = path84.resolve(from, id);
107509
+ return { path: at2, base: path84.dirname(at2), content: fs82.readFileSync(at2, "utf8") };
106966
107510
  }
106967
107511
  });
106968
107512
  const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
106969
107513
  return compiler.build(classes.filter(Boolean));
106970
107514
  }
106971
- function dressPage(file) {
106972
- const folder = path81.dirname(file);
106973
- const html = fs79.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
106974
- const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
106975
- if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
106976
- const at3 = path81.resolve(folder, href);
106977
- if (!at3.startsWith(folder + path81.sep) || !fs79.existsSync(at3)) return tag;
106978
- return `<style>${fs79.readFileSync(at3, "utf8").replace(/<\/style/gi, "<\\/style")}</style>`;
106979
- });
106980
- const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
106981
- return /<!doctype\b|<html[\s>]|<head[\s>]/i.test(html) ? html.slice(0, at2) + head + html.slice(at2) : `<!doctype html><html><head>${head}</head><body>${html}</body></html>`;
106982
- }
106983
107515
  async function drawMockup(entry) {
106984
107516
  if (entry.toLowerCase().endsWith(".html")) return dressPage(entry);
106985
107517
  const graph = await readGraph(entry);
@@ -107026,7 +107558,7 @@ ${graph.code.get(file)}
107026
107558
  const css = (await tailwindFor(markup, graph.sheets)).replace(/<\/style/gi, "<\\/style");
107027
107559
  return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
107028
107560
  }
107029
- var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES, CSP, head;
107561
+ var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES;
107030
107562
  var init_draw_mockup = __esm({
107031
107563
  "../cli/src/lib/draw-mockup.ts"() {
107032
107564
  "use strict";
@@ -107036,6 +107568,7 @@ var init_draw_mockup = __esm({
107036
107568
  import_sucrase = __toESM(require_dist2(), 1);
107037
107569
  init_lib();
107038
107570
  init_tailwindcss();
107571
+ init_dress_page();
107039
107572
  DRAW_MS = 5e3;
107040
107573
  MAX_FILES = 60;
107041
107574
  CODE_EXTS = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
@@ -107078,14 +107611,12 @@ var init_draw_mockup = __esm({
107078
107611
  "tailwind-merge": () => Promise.resolve().then(() => (init_bundle_mjs(), bundle_mjs_exports)),
107079
107612
  "class-variance-authority": () => Promise.resolve().then(() => (init_dist(), dist_exports))
107080
107613
  };
107081
- CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; media-src data:; font-src data:; worker-src 'none'; base-uri 'none'; form-action 'none'";
107082
- 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>`;
107083
107614
  }
107084
107615
  });
107085
107616
 
107086
107617
  // ../cli/src/lib/preview-validation.ts
107087
- import fs80 from "node:fs";
107088
- import path82 from "node:path";
107618
+ import fs83 from "node:fs";
107619
+ import path85 from "node:path";
107089
107620
  function renderError(error) {
107090
107621
  if (!error || typeof error !== "object") return String(error);
107091
107622
  const { message, stack } = error;
@@ -107096,7 +107627,7 @@ function renderError(error) {
107096
107627
  async function validateScreens(files2) {
107097
107628
  const errors = [];
107098
107629
  const entries = /* @__PURE__ */ new Map();
107099
- for (const file of files2) entries.set(fs80.existsSync(file) ? fs80.realpathSync(file) : path82.resolve(file), path82.resolve(file));
107630
+ for (const file of files2) entries.set(fs83.existsSync(file) ? fs83.realpathSync(file) : path85.resolve(file), path85.resolve(file));
107100
107631
  for (const file of entries.values()) {
107101
107632
  try {
107102
107633
  await drawMockup(file);
@@ -107115,7 +107646,7 @@ async function validatePreview(file, text5) {
107115
107646
  if (/^ {0,3}<!--\s*agent\s*-->\s*$/.test(line)) own = false;
107116
107647
  if (own) section.push(line);
107117
107648
  }
107118
- const files2 = bodySources(section.join("\n")).filter((src) => !/^[a-z][\w+.-]*:|^#|^\/\//i.test(src) && kindOf2(path82.extname(src).toLowerCase()) === "html").map((src) => src.startsWith(".assets/") ? path82.join(ASSETS, src.slice(8)) : src.startsWith(".mockups/") ? path82.join(MOCKUPS, src.slice(9)) : path82.resolve(path82.dirname(file), src));
107649
+ const files2 = bodySources(section.join("\n")).filter((src) => !/^[a-z][\w+.-]*:|^#|^\/\//i.test(src) && kindOf(path85.extname(src).toLowerCase()) === "html").map((src) => src.startsWith(".assets/") ? path85.join(ASSETS, src.slice(8)) : src.startsWith(".mockups/") ? path85.join(MOCKUPS, src.slice(9)) : path85.resolve(path85.dirname(file), src));
107119
107650
  return validateScreens(files2);
107120
107651
  }
107121
107652
  var init_preview_validation = __esm({
@@ -107272,7 +107803,7 @@ __export(watch_exports, {
107272
107803
  watchRun: () => watchRun
107273
107804
  });
107274
107805
  import { spawn as spawn4 } from "node:child_process";
107275
- import fs81 from "node:fs";
107806
+ import fs84 from "node:fs";
107276
107807
  async function watchRun(sessionId, resume = startResume) {
107277
107808
  const spec = readSpec(sessionId);
107278
107809
  const run3 = peekRun(sessionId);
@@ -107308,11 +107839,11 @@ async function watchRun(sessionId, resume = startResume) {
107308
107839
  const record = claimed ?? run3;
107309
107840
  const sub = record.action === "sub";
107310
107841
  if (claim) await setCardStatus(claim.cardId, claim.status);
107311
- fs81.mkdirSync(SESSIONS_DIR, { recursive: true });
107312
- const logFile = fs81.createWriteStream(record.logPath, { flags: "a" });
107842
+ fs84.mkdirSync(SESSIONS_DIR, { recursive: true });
107843
+ const logFile = fs84.createWriteStream(record.logPath, { flags: "a" });
107313
107844
  logFile.on("error", () => {
107314
107845
  });
107315
- const eventsFile = fs81.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107846
+ const eventsFile = fs84.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107316
107847
  eventsFile.on("error", () => {
107317
107848
  });
107318
107849
  const event2 = (e2) => eventsFile.write(`${JSON.stringify(e2)}
@@ -107791,8 +108322,8 @@ function brokeBoard(wasBroken) {
107791
108322
  if (!broke.length) return null;
107792
108323
  const shown = broke.slice(0, MAX_BROKEN);
107793
108324
  const rest = broke.length - shown.length;
107794
- const why = { kind: "broken", args: { n: String(broke.length), more: String(rest) }, lines: shown };
107795
- return { why, note: [
108325
+ const why2 = { kind: "broken", args: { n: String(broke.length), more: String(rest) }, lines: shown };
108326
+ return { why: why2, note: [
107796
108327
  `the work is done, but the board came out of this run inconsistent \u2014 ${broke.length} thing${broke.length === 1 ? "" : "s"} to put right:`,
107797
108328
  ...shown.map((line) => ` ${line}`),
107798
108329
  ...rest ? [` \u2026 and ${rest} more`] : [],
@@ -107906,7 +108437,7 @@ var init_watch = __esm({
107906
108437
  });
107907
108438
 
107908
108439
  // ../cli/src/kanban.ts
107909
- import fs87 from "node:fs";
108440
+ import fs90 from "node:fs";
107910
108441
  import { fileURLToPath as fileURLToPath4 } from "node:url";
107911
108442
 
107912
108443
  // ../cli/src/lib/cli/agent.ts
@@ -108389,8 +108920,8 @@ async function testAgent(args) {
108389
108920
  }
108390
108921
 
108391
108922
  // ../cli/src/commands/cloud.ts
108392
- import fs70 from "node:fs";
108393
- import path71 from "node:path";
108923
+ import fs72 from "node:fs";
108924
+ import path73 from "node:path";
108394
108925
 
108395
108926
  // ../cli/src/lib/cloud/avatar.ts
108396
108927
  init_session();
@@ -108438,13 +108969,13 @@ init_config();
108438
108969
  init_home();
108439
108970
  init_config();
108440
108971
  init_session();
108441
- import fs69 from "node:fs";
108442
- import path70 from "node:path";
108972
+ import fs71 from "node:fs";
108973
+ import path72 from "node:path";
108443
108974
  var FRESH_MS2 = 10 * 6e4;
108444
108975
  var GRACE_MS = 7 * 24 * 60 * 6e4;
108445
- var heldFile = () => path70.join(machineHome(), "pro.json");
108976
+ var heldFile = () => path72.join(machineHome(), "pro.json");
108446
108977
  function forgetPro() {
108447
- fs69.rmSync(heldFile(), { force: true });
108978
+ fs71.rmSync(heldFile(), { force: true });
108448
108979
  }
108449
108980
 
108450
108981
  // ../cli/src/lib/cloud/account.ts
@@ -108621,10 +109152,10 @@ async function cloudImage(opts, program2) {
108621
109152
  const prompt = opts.prompt.trim();
108622
109153
  if (!prompt) usage("Missing the prompt.", line);
108623
109154
  const references = opts.refs.map((file) => {
108624
- const type = REF_TYPES[path71.extname(file).toLowerCase()];
109155
+ const type = REF_TYPES[path73.extname(file).toLowerCase()];
108625
109156
  if (!type) usage(`--ref ${file}: use a PNG, JPEG or WebP file.`, line);
108626
109157
  try {
108627
- return `data:${type};base64,${fs70.readFileSync(file).toString("base64")}`;
109158
+ return `data:${type};base64,${fs72.readFileSync(file).toString("base64")}`;
108628
109159
  } catch (e2) {
108629
109160
  usage(`--ref ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`, line);
108630
109161
  }
@@ -108730,8 +109261,8 @@ async function generate(g3) {
108730
109261
  refuse(g3.failed, g3.fallback);
108731
109262
  }
108732
109263
  const out = g3.outFor?.(res, g3.out) ?? g3.out;
108733
- fs70.mkdirSync(path71.dirname(path71.resolve(out)), { recursive: true });
108734
- fs70.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
109264
+ fs72.mkdirSync(path73.dirname(path73.resolve(out)), { recursive: true });
109265
+ fs72.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
108735
109266
  say(`${out} (${g3.label(res)})`);
108736
109267
  return { out };
108737
109268
  }
@@ -108740,35 +109271,35 @@ async function generate(g3) {
108740
109271
  init_board_files();
108741
109272
  init_workflow_files();
108742
109273
  import crypto6 from "node:crypto";
108743
- import fs72 from "node:fs";
108744
- import path73 from "node:path";
109274
+ import fs74 from "node:fs";
109275
+ import path75 from "node:path";
108745
109276
 
108746
109277
  // ../cli/src/lib/agents/shared-memory.ts
108747
109278
  init_bundled();
108748
109279
  init_parse();
108749
- import fs71 from "node:fs";
108750
- import path72 from "node:path";
109280
+ import fs73 from "node:fs";
109281
+ import path74 from "node:path";
108751
109282
  function sharedMemory(board2) {
108752
109283
  const declared = /* @__PURE__ */ new Map();
108753
109284
  const take = (folder, text5, builtIn) => {
108754
109285
  if (text5 === null || declared.has(folder)) return;
108755
- const read4 = parseSpecAgent(text5, folder, () => null, builtIn);
108756
- if ("agent" in read4 && read4.agent.name === folder) declared.set(folder, read4.agent.memoryFiles.workspace);
109286
+ const read5 = parseSpecAgent(text5, folder, () => null, builtIn);
109287
+ if ("agent" in read5 && read5.agent.name === folder) declared.set(folder, read5.agent.memoryFiles.workspace);
108757
109288
  };
108758
109289
  for (const [key, text5] of Object.entries(shippedAgentFiles())) {
108759
109290
  const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
108760
109291
  if (at2) take(at2[1], text5, officialAgent(at2[1]));
108761
109292
  }
108762
- const root2 = path72.join(board2, "agents");
109293
+ const root2 = path74.join(board2, "agents");
108763
109294
  let folders2 = [];
108764
109295
  try {
108765
- folders2 = fs71.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
109296
+ folders2 = fs73.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
108766
109297
  } catch {
108767
109298
  }
108768
109299
  for (const folder of folders2.sort()) {
108769
109300
  let text5 = null;
108770
109301
  try {
108771
- text5 = fs71.readFileSync(path72.join(root2, folder, "AGENT.md"), "utf8");
109302
+ text5 = fs73.readFileSync(path74.join(root2, folder, "AGENT.md"), "utf8");
108772
109303
  } catch {
108773
109304
  }
108774
109305
  take(folder, text5, false);
@@ -108858,27 +109389,27 @@ async function findProject(asked) {
108858
109389
  }
108859
109390
  throw new Refused(`No project of yours has the id or prefix "${asked}".`, "not_found");
108860
109391
  }
108861
- var read = (file) => fs72.readFileSync(file, "utf8");
109392
+ var read2 = (file) => fs74.readFileSync(file, "utf8");
108862
109393
  var bytes2 = (text5) => Buffer.byteLength(text5, "utf8");
108863
109394
  function files(dir) {
108864
- if (!fs72.existsSync(dir)) return [];
109395
+ if (!fs74.existsSync(dir)) return [];
108865
109396
  const out = [];
108866
- for (const entry of fs72.readdirSync(dir, { withFileTypes: true })) {
109397
+ for (const entry of fs74.readdirSync(dir, { withFileTypes: true })) {
108867
109398
  if (entry.name.startsWith(".")) continue;
108868
- const full = path73.join(dir, entry.name);
109399
+ const full = path75.join(dir, entry.name);
108869
109400
  if (entry.isDirectory()) out.push(...files(full));
108870
109401
  else if (entry.isFile()) out.push(full);
108871
109402
  }
108872
109403
  return out;
108873
109404
  }
108874
- var posix = (p2) => p2.split(path73.sep).join("/");
109405
+ var posix = (p2) => p2.split(path75.sep).join("/");
108875
109406
  function openCards() {
108876
109407
  const out = [];
108877
109408
  for (const file of walkMd(TODO)) {
108878
- const rel2 = posix(path73.relative(TODO, file));
109409
+ const rel2 = posix(path75.relative(TODO, file));
108879
109410
  if (rel2 === "README.md") continue;
108880
109411
  const parts = rel2.split("/");
108881
- const text5 = read(file);
109412
+ const text5 = read2(file);
108882
109413
  const meta = parseFrontmatter(text5).meta;
108883
109414
  if (!meta) continue;
108884
109415
  const name = parts[parts.length - 1];
@@ -108962,12 +109493,12 @@ function draftsOf(text5) {
108962
109493
  const at2 = /^\.(assets|mockups)\/(.+)$/.exec(name);
108963
109494
  if (!at2) continue;
108964
109495
  const base = at2[1] === "assets" ? ASSETS : MOCKUPS;
108965
- const file = path73.resolve(base, at2[2]);
108966
- if (file.startsWith(base + path73.sep) && fs72.statSync(file, { throwIfNoEntry: false })?.isFile()) out.set(name, file);
109496
+ const file = path75.resolve(base, at2[2]);
109497
+ if (file.startsWith(base + path75.sep) && fs74.statSync(file, { throwIfNoEntry: false })?.isFile()) out.set(name, file);
108967
109498
  }
108968
109499
  return [...out].map(([name, file]) => ({ name, file }));
108969
109500
  }
108970
- var TYPES = {
109501
+ var TYPES2 = {
108971
109502
  ".png": "image/png",
108972
109503
  ".jpg": "image/jpeg",
108973
109504
  ".jpeg": "image/jpeg",
@@ -108984,10 +109515,10 @@ var TYPES = {
108984
109515
  ".wav": "audio/wav",
108985
109516
  ".json": "application/json"
108986
109517
  };
108987
- function kindOf(ext) {
109518
+ function kindOf2(ext) {
108988
109519
  if (ext === ".html") return "html";
108989
109520
  if (ext === ".md" || ext === ".mdx") return "markdown";
108990
- const type = TYPES[ext] ?? "";
109521
+ const type = TYPES2[ext] ?? "";
108991
109522
  if (type.startsWith("image/")) return "image";
108992
109523
  return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
108993
109524
  }
@@ -108997,10 +109528,10 @@ async function uploadDrafts(task, drafts) {
108997
109528
  const assets = {};
108998
109529
  for (const { name, file } of drafts) {
108999
109530
  if (!card.body.includes(name)) continue;
109000
- const ext = path73.extname(file).toLowerCase();
109001
- const type = TYPES[ext] ?? "application/octet-stream";
109002
- const data = fs72.readFileSync(file);
109003
- const artifact = await api("POST", `/v1/tasks/${task}/artifacts`, { type: kindOf(ext), name: name.slice(0, 200) });
109531
+ const ext = path75.extname(file).toLowerCase();
109532
+ const type = TYPES2[ext] ?? "application/octet-stream";
109533
+ const data = fs74.readFileSync(file);
109534
+ const artifact = await api("POST", `/v1/tasks/${task}/artifacts`, { type: kindOf2(ext), name: name.slice(0, 200) });
109004
109535
  const upload = await api("POST", `/v1/artifacts/${artifact.id}/uploads`, { content_type: type, size: Math.max(data.length, 1) });
109005
109536
  await api("PUT", `/v1/uploads/${upload.id}`, void 0, { bytes: data, type });
109006
109537
  const version = await api("POST", `/v1/artifacts/${artifact.id}/versions`, { upload: upload.id });
@@ -109042,7 +109573,7 @@ usage: ${program2} cloud import --project <id or prefix> [--dry-run]`, { kind: "
109042
109573
  function localWorkflowFolders() {
109043
109574
  let folders2;
109044
109575
  try {
109045
- folders2 = fs72.readdirSync(WORKFLOWS, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".") && !e2.name.startsWith("task-")).map((e2) => e2.name).sort((a2, b2) => a2.localeCompare(b2, "en", { numeric: true }));
109576
+ folders2 = fs74.readdirSync(WORKFLOWS, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".") && !e2.name.startsWith("task-")).map((e2) => e2.name).sort((a2, b2) => a2.localeCompare(b2, "en", { numeric: true }));
109046
109577
  } catch {
109047
109578
  return [];
109048
109579
  }
@@ -109053,19 +109584,19 @@ function localWorkflowFolders() {
109053
109584
  });
109054
109585
  }
109055
109586
  function filesUnder(dir, base = dir) {
109056
- return fs72.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
109057
- const full = path73.join(dir, e2.name);
109058
- return e2.isDirectory() ? filesUnder(full, base) : [posix(path73.relative(base, full))];
109587
+ return fs74.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
109588
+ const full = path75.join(dir, e2.name);
109589
+ return e2.isDirectory() ? filesUnder(full, base) : [posix(path75.relative(base, full))];
109059
109590
  });
109060
109591
  }
109061
109592
  function packLocalWorkflow(id, def, shipped) {
109062
- const dir = path73.join(WORKFLOWS, id);
109063
- const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2, fs72.readFileSync(path73.join(dir, f2), "utf8")]));
109593
+ const dir = path75.join(WORKFLOWS, id);
109594
+ const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2, fs74.readFileSync(path75.join(dir, f2), "utf8")]));
109064
109595
  const named2 = [...def.previews, ...def.land, ...def.scheduled].map((h3) => h3.agent).filter((a2) => !LAND_ROLES2.includes(a2));
109065
109596
  for (const agent of new Set(named2)) {
109066
- const at2 = path73.join(AGENTS, agent);
109067
- if (fs72.existsSync(path73.join(at2, "AGENT.md"))) {
109068
- for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] = fs72.readFileSync(path73.join(at2, file), "utf8");
109597
+ const at2 = path75.join(AGENTS, agent);
109598
+ if (fs74.existsSync(path75.join(at2, "AGENT.md"))) {
109599
+ for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] = fs74.readFileSync(path75.join(at2, file), "utf8");
109069
109600
  continue;
109070
109601
  }
109071
109602
  for (const [key, text5] of Object.entries(shipped)) if (key.startsWith(`${agent}/`)) out[`agents/${key}`] = text5;
@@ -109075,10 +109606,10 @@ function packLocalWorkflow(id, def, shipped) {
109075
109606
  async function run(asked, dryRun) {
109076
109607
  const project = await findProject(asked);
109077
109608
  const cloudFlows2 = await all(`/v1/workflows?workspace=${encodeURIComponent(project.workspace)}`);
109078
- const board2 = crypto6.createHash("sha256").update(fs72.realpathSync(KANBAN)).digest("hex").slice(0, 16);
109609
+ const board2 = crypto6.createHash("sha256").update(fs74.realpathSync(KANBAN)).digest("hex").slice(0, 16);
109079
109610
  const cards = openCards();
109080
109611
  const problems = [];
109081
- const where = (file) => posix(path73.relative(KANBAN, file));
109612
+ const where = (file) => posix(path75.relative(KANBAN, file));
109082
109613
  const own = [];
109083
109614
  for (const f2 of localWorkflowFolders()) {
109084
109615
  if (f2.def) own.push({ id: f2.id, name: f2.def.name, def: f2.def });
@@ -109107,10 +109638,10 @@ async function run(asked, dryRun) {
109107
109638
  const root2 = `projects/${project.id}/`;
109108
109639
  const boardFiles = [];
109109
109640
  for (const file of [...files(MEMORY), ...files(RULES), CONFIG, MODULES_MD]) {
109110
- if (!fs72.existsSync(file)) continue;
109641
+ if (!fs74.existsSync(file)) continue;
109111
109642
  const rel2 = where(file);
109112
109643
  if (!isBoardPath(rel2)) continue;
109113
- const content = read(file);
109644
+ const content = read2(file);
109114
109645
  if (bytes2(content) > BOARD_FILE_LIMIT) {
109115
109646
  problems.push({ file: rel2, reason: { zh: "\u8D85\u8FC7 256 KB", en: "over 256 KB" } });
109116
109647
  continue;
@@ -109218,16 +109749,16 @@ async function run(asked, dryRun) {
109218
109749
  }
109219
109750
  function leftLocal(own) {
109220
109751
  const out = [];
109221
- const count4 = (dir) => fs72.existsSync(dir) ? walkMd(dir).length : 0;
109752
+ const count4 = (dir) => fs74.existsSync(dir) ? walkMd(dir).length : 0;
109222
109753
  const archived = count4(ARCHIVE);
109223
109754
  if (archived) out.push(`.archive/ (${archived})`);
109224
109755
  const triage = count4(TRIAGE);
109225
109756
  if (triage) out.push(`triage/ (${triage})`);
109226
- if (fs72.existsSync(DELIVERIES)) out.push("deliveries/");
109227
- if (fs72.existsSync(path73.join(KANBAN, "metrics.csv"))) out.push("metrics.csv");
109757
+ if (fs74.existsSync(DELIVERIES)) out.push("deliveries/");
109758
+ if (fs74.existsSync(path75.join(KANBAN, "metrics.csv"))) out.push("metrics.csv");
109228
109759
  const named2 = new Set(own.flatMap((w2) => [...w2.def.previews, ...w2.def.land, ...w2.def.scheduled].map((h3) => h3.agent)));
109229
- if (fs72.existsSync(AGENTS)) {
109230
- for (const e2 of fs72.readdirSync(AGENTS, { withFileTypes: true })) {
109760
+ if (fs74.existsSync(AGENTS)) {
109761
+ for (const e2 of fs74.readdirSync(AGENTS, { withFileTypes: true })) {
109231
109762
  if (e2.isDirectory() && !e2.name.startsWith(".") && !named2.has(e2.name)) out.push(`agents/${e2.name}/`);
109232
109763
  }
109233
109764
  }
@@ -109245,8 +109776,8 @@ init_session();
109245
109776
  init_io();
109246
109777
  init_paths();
109247
109778
  import { createHash as createHash5 } from "node:crypto";
109248
- import fs73 from "node:fs";
109249
- import path74 from "node:path";
109779
+ import fs75 from "node:fs";
109780
+ import path76 from "node:path";
109250
109781
  var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
109251
109782
  var CAPTURED = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/;
109252
109783
  var MAX_BYTES3 = 50 * 1024 * 1024;
@@ -109345,10 +109876,10 @@ This template has no preview.`);
109345
109876
  const written = [];
109346
109877
  for (const p2 of previews) {
109347
109878
  const bytes3 = Buffer.from(await (await ask(`/${at2}/previews/${route(p2.path)}`, {}, WITHOUT)).arrayBuffer());
109348
- const file = path74.basename(p2.path);
109349
- const out = path74.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
109350
- fs73.mkdirSync(opts.to, { recursive: true });
109351
- fs73.writeFileSync(out, bytes3);
109879
+ const file = path76.basename(p2.path);
109880
+ const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
109881
+ fs75.mkdirSync(opts.to, { recursive: true });
109882
+ fs75.writeFileSync(out, bytes3);
109352
109883
  written.push(out);
109353
109884
  say(out);
109354
109885
  }
@@ -109361,15 +109892,15 @@ async function templateGet(name, opts, program2) {
109361
109892
  const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
109362
109893
  const fetched = [];
109363
109894
  for (const f2 of template.files) {
109364
- const out = path74.resolve(to, f2.path);
109365
- if (!out.startsWith(path74.resolve(to) + path74.sep)) refuse2(T.corrupt, WITHOUT);
109895
+ const out = path76.resolve(to, f2.path);
109896
+ if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse2(T.corrupt, WITHOUT);
109366
109897
  const bytes3 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
109367
109898
  if (bytes3.byteLength !== f2.size || createHash5("sha256").update(bytes3).digest("hex") !== f2.sha256) {
109368
109899
  refuse2(T.corrupt, WITHOUT);
109369
109900
  }
109370
109901
  fetched.push({ out, bytes: bytes3 });
109371
109902
  }
109372
- const taken = fetched.filter((f2) => fs73.existsSync(f2.out)).map((f2) => path74.relative(to, f2.out));
109903
+ const taken = fetched.filter((f2) => fs75.existsSync(f2.out)).map((f2) => path76.relative(to, f2.out));
109373
109904
  if (taken.length > 0) {
109374
109905
  refuse2({
109375
109906
  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`,
@@ -109377,8 +109908,8 @@ async function templateGet(name, opts, program2) {
109377
109908
  });
109378
109909
  }
109379
109910
  for (const f2 of fetched) {
109380
- fs73.mkdirSync(path74.dirname(f2.out), { recursive: true });
109381
- fs73.writeFileSync(f2.out, f2.bytes);
109911
+ fs75.mkdirSync(path76.dirname(f2.out), { recursive: true });
109912
+ fs75.writeFileSync(f2.out, f2.bytes);
109382
109913
  }
109383
109914
  say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
109384
109915
  Fetched ${name}: ${fetched.length} files into ${to}`);
@@ -109396,25 +109927,25 @@ async function templateSource(name, opts) {
109396
109927
  say(`evidence: ${e2.path}`);
109397
109928
  continue;
109398
109929
  }
109399
- const out = path74.join(opts.to, `${name}-${path74.basename(e2.path)}`);
109400
- fs73.mkdirSync(opts.to, { recursive: true });
109401
- fs73.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
109930
+ const out = path76.join(opts.to, `${name}-${path76.basename(e2.path)}`);
109931
+ fs75.mkdirSync(opts.to, { recursive: true });
109932
+ fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
109402
109933
  written.push(out);
109403
109934
  say(out);
109404
109935
  }
109405
109936
  return { name, source, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
109406
109937
  }
109407
109938
  async function templatePublish(dir, opts) {
109408
- const root2 = path74.resolve(dir);
109409
- const manifest = path74.join(root2, "template.md");
109410
- if (!fs73.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
109411
- const meta = readTemplateMeta(fs73.readFileSync(manifest, "utf8"));
109939
+ const root2 = path76.resolve(dir);
109940
+ const manifest = path76.join(root2, "template.md");
109941
+ 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.");
109942
+ const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
109412
109943
  const files2 = walk2(root2);
109413
- const total = files2.reduce((sum, f2) => sum + fs73.statSync(path74.join(root2, f2)).size, 0);
109944
+ const total = files2.reduce((sum, f2) => sum + fs75.statSync(path76.join(root2, f2)).size, 0);
109414
109945
  if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
109415
109946
  for (const extra of [...opts.preview, ...opts.evidence]) {
109416
- if (!fs73.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
109417
- if (path74.resolve(extra).startsWith(root2 + path74.sep)) {
109947
+ if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
109948
+ if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
109418
109949
  invalid(
109419
109950
  `${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`,
109420
109951
  `${extra} is inside the template folder; keep previews and evidence outside it.`
@@ -109426,10 +109957,10 @@ async function templatePublish(dir, opts) {
109426
109957
  }
109427
109958
  const form = new FormData();
109428
109959
  form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
109429
- const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs73.readFileSync(file)]), path74.basename(name));
109430
- for (const f2 of files2) add("files", f2, path74.join(root2, f2));
109431
- for (const f2 of opts.preview) add("previews", path74.basename(f2), f2);
109432
- for (const f2 of opts.evidence) add("evidence", path74.basename(f2), f2);
109960
+ const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
109961
+ for (const f2 of files2) add("files", f2, path76.join(root2, f2));
109962
+ for (const f2 of opts.preview) add("previews", path76.basename(f2), f2);
109963
+ for (const f2 of opts.evidence) add("evidence", path76.basename(f2), f2);
109433
109964
  const done2 = await asJson(await ask("", { method: "POST", body: form }));
109434
109965
  say(
109435
109966
  done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files2.length} \u4E2A\u6587\u4EF6\u3002
@@ -109445,11 +109976,11 @@ Deleted ${name} from the catalog.`);
109445
109976
  return { name, deleted: true };
109446
109977
  }
109447
109978
  async function templateShowcase(name, dir) {
109448
- const file = path74.join(dir, "showcase.json");
109449
- if (!fs73.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
109979
+ const file = path76.join(dir, "showcase.json");
109980
+ if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
109450
109981
  let meta;
109451
109982
  try {
109452
- meta = JSON.parse(fs73.readFileSync(file, "utf8"));
109983
+ meta = JSON.parse(fs75.readFileSync(file, "utf8"));
109453
109984
  } catch {
109454
109985
  return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
109455
109986
  }
@@ -109461,9 +109992,9 @@ async function templateShowcase(name, dir) {
109461
109992
  const form = new FormData();
109462
109993
  form.set("meta", JSON.stringify(meta));
109463
109994
  for (const p2 of new Set(named2)) {
109464
- const at2 = path74.join(dir, p2);
109465
- if (!fs73.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
109466
- form.append(`media:${p2}`, new Blob([fs73.readFileSync(at2)]), p2);
109995
+ const at2 = path76.join(dir, p2);
109996
+ if (!fs75.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
109997
+ form.append(`media:${p2}`, new Blob([fs75.readFileSync(at2)]), p2);
109467
109998
  }
109468
109999
  const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
109469
110000
  say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
@@ -109472,7 +110003,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
109472
110003
  }
109473
110004
  function walk2(root2, sub = "") {
109474
110005
  const out = [];
109475
- for (const entry of fs73.readdirSync(path74.join(root2, sub), { withFileTypes: true })) {
110006
+ for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
109476
110007
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
109477
110008
  const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
109478
110009
  if (entry.isDirectory()) out.push(...walk2(root2, rel2));
@@ -109622,10 +110153,15 @@ function cmdGuide(topic, program2 = "akb") {
109622
110153
  }
109623
110154
 
109624
110155
  // ../cli/src/commands/workflow.ts
110156
+ init_agents();
110157
+ init_cards();
109625
110158
  init_io();
109626
110159
  init_paths();
110160
+ init_workflow_diagram();
109627
110161
  init_cloud_workflows();
109628
110162
  init_workflows();
110163
+ import fs76 from "node:fs";
110164
+ import path77 from "node:path";
109629
110165
  var found = (id) => {
109630
110166
  const flow = workflowById(id);
109631
110167
  if (!flow) {
@@ -109685,6 +110221,22 @@ function cmdWorkflowRename(id, name) {
109685
110221
  say(`renamed ${id} to "${name.trim()}"`);
109686
110222
  return { id, name: name.trim() };
109687
110223
  }
110224
+ function cmdWorkflowDiagram(id, card) {
110225
+ const flow = found(id);
110226
+ const cardId2 = Number(card);
110227
+ if (!Number.isInteger(cardId2) || !locate(cardId2)) die(`no card #${card} on this board`, "no-such-card");
110228
+ const diagram = workflowDiagram({ previews: previewMembers(flow), land: flow.land, scheduled: scheduledMembers(flow) }, (name) => {
110229
+ const agent = findSpecAgent(name);
110230
+ return agent ? { ...agent, after: agentAfter(name) } : null;
110231
+ });
110232
+ const file = path77.join(ASSETS, String(cardId2), "workflow.json");
110233
+ fs76.mkdirSync(path77.dirname(file), { recursive: true });
110234
+ fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
110235
+ `);
110236
+ const tag = `<Workflow src=".assets/${cardId2}/workflow.json" label="${flow.name.replace(/"/g, "")}" />`;
110237
+ say(tag);
110238
+ return { file, tag, diagram };
110239
+ }
109688
110240
 
109689
110241
  // ../cli/src/commands/run.ts
109690
110242
  init_progress();
@@ -109835,7 +110387,7 @@ init_opencode();
109835
110387
  init_locate();
109836
110388
  init_store();
109837
110389
  import { spawnSync as spawnSync5 } from "node:child_process";
109838
- import path80 from "node:path";
110390
+ import path83 from "node:path";
109839
110391
  var AGENTS2 = {
109840
110392
  claude: "claude-code",
109841
110393
  codex: "codex",
@@ -109850,10 +110402,10 @@ var AGENTS2 = {
109850
110402
  var RUNTIMES = /* @__PURE__ */ new Set(["node", "bun", "deno"]);
109851
110403
  function agentOf2(args) {
109852
110404
  const words = args.trim().split(/\s+/);
109853
- const first = path80.basename(words[0] ?? "");
110405
+ const first = path83.basename(words[0] ?? "");
109854
110406
  const script = RUNTIMES.has(first) ? words[1] ?? "" : words[0] ?? "";
109855
110407
  if (script.includes("/@anthropic-ai/claude-code/")) return "claude-code";
109856
- return AGENTS2[path80.basename(script).replace(/\.(m?js|cjs|exe)$/, "")];
110408
+ return AGENTS2[path83.basename(script).replace(/\.(m?js|cjs|exe)$/, "")];
109857
110409
  }
109858
110410
  function processChain() {
109859
110411
  if (process.platform === "win32") return [];
@@ -109917,8 +110469,8 @@ init_tasks();
109917
110469
  init_read();
109918
110470
  init_rules();
109919
110471
  init_board();
109920
- import fs82 from "node:fs";
109921
- import path83 from "node:path";
110472
+ import fs85 from "node:fs";
110473
+ import path86 from "node:path";
109922
110474
  var FOLLOW_MS = 400;
109923
110475
  async function cmdStartRun(action, args, opts, program2 = "akb") {
109924
110476
  const { req, follow: follow2, print } = readRequest(action, args, opts);
@@ -110005,8 +110557,8 @@ async function approveInCloud(project, id) {
110005
110557
  say(`approved #${id} in Cloud`);
110006
110558
  return { id, task: approved.value.key, approved: true };
110007
110559
  }
110008
- async function cmdReject(id, why, opts) {
110009
- const reason = why.trim();
110560
+ async function cmdReject(id, why2, opts) {
110561
+ const reason = why2.trim();
110010
110562
  const discard = opts.discard === true;
110011
110563
  if (!discard && !reason) die("say why the card is being dropped, or pass --discard to just drop it");
110012
110564
  const res = await rejectCard(id, { reason, discard }, true);
@@ -110166,7 +110718,7 @@ async function cmdSubStart(words, opts) {
110166
110718
  let prompt = words.join(" ");
110167
110719
  if (opts.file) {
110168
110720
  try {
110169
- prompt = fs82.readFileSync(path83.resolve(opts.file), "utf8");
110721
+ prompt = fs85.readFileSync(path86.resolve(opts.file), "utf8");
110170
110722
  } catch {
110171
110723
  die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
110172
110724
  }
@@ -110457,7 +111009,7 @@ function cmdCompleteDelivery(id, options) {
110457
111009
  // ../cli/src/commands/triage.ts
110458
111010
  init_scheduled();
110459
111011
  init_workflows();
110460
- import fs84 from "node:fs";
111012
+ import fs87 from "node:fs";
110461
111013
 
110462
111014
  // ../cli/src/lib/signals/index.ts
110463
111015
  init_cards();
@@ -110467,16 +111019,16 @@ init_yaml();
110467
111019
  // ../cli/src/lib/signals/config.ts
110468
111020
  init_settings2();
110469
111021
  init_paths();
110470
- import fs83 from "node:fs";
110471
- import path84 from "node:path";
111022
+ import fs86 from "node:fs";
111023
+ import path87 from "node:path";
110472
111024
  var TOKEN_KEY = "TRIAGE_ENDPOINT_TOKEN";
110473
111025
  var ENDPOINT_SETTING = "Triage endpoint";
110474
111026
  var LINE2 = /^- \*\*Triage endpoint\*\*\s*[—-]\s*(.+)$/m;
110475
- var boardRel3 = (file) => rel(file).split(path84.sep).join("/");
111027
+ var boardRel3 = (file) => rel(file).split(path87.sep).join("/");
110476
111028
  function signalEndpoint() {
110477
111029
  let text5;
110478
111030
  try {
110479
- text5 = fs83.readFileSync(CONFIG, "utf8");
111031
+ text5 = fs86.readFileSync(CONFIG, "utf8");
110480
111032
  } catch {
110481
111033
  return "";
110482
111034
  }
@@ -110520,7 +111072,7 @@ function readMeta(sent) {
110520
111072
  }
110521
111073
  return pairs;
110522
111074
  }
110523
- function read2(raw) {
111075
+ function read3(raw) {
110524
111076
  const missing = REQUIRED.filter((field2) => !text4(raw[field2]));
110525
111077
  if (missing.length > 0) return { ok: false, why: `missing ${missing.join(", ")}` };
110526
111078
  const sent = text4(raw.collected_at);
@@ -110570,8 +111122,8 @@ async function fetchSignals() {
110570
111122
  });
110571
111123
  } catch (e2) {
110572
111124
  const late = e2 instanceof Error && (e2.name === "TimeoutError" || e2.name === "AbortError");
110573
- const why = late ? `did not answer within ${ANSWER_BY_MS2 / 1e3}s` : `could not be reached: ${e2 instanceof Error ? e2.message : String(e2)}`;
110574
- die(`${endpoint2} ${why}`, { kind: "triage-unreachable" });
111125
+ const why2 = late ? `did not answer within ${ANSWER_BY_MS2 / 1e3}s` : `could not be reached: ${e2 instanceof Error ? e2.message : String(e2)}`;
111126
+ die(`${endpoint2} ${why2}`, { kind: "triage-unreachable" });
110575
111127
  }
110576
111128
  if (!response.ok) {
110577
111129
  die(`${endpoint2} answered ${response.status}.`, { kind: "triage-endpoint-refused" });
@@ -110596,7 +111148,7 @@ async function fetchSignals() {
110596
111148
  report3.failed.push({ which: `item ${at2 + 1}`, why: "not an object" });
110597
111149
  return;
110598
111150
  }
110599
- const found2 = read2(raw);
111151
+ const found2 = read3(raw);
110600
111152
  if (!found2.ok) {
110601
111153
  report3.failed.push({ which: text4(raw.source_id) || `item ${at2 + 1}`, why: found2.why });
110602
111154
  return;
@@ -110652,7 +111204,7 @@ async function cmdTriageAdd(opts) {
110652
111204
  let body = opts.text;
110653
111205
  if (opts.file !== void 0) {
110654
111206
  try {
110655
- body = fs84.readFileSync(opts.file, "utf8");
111207
+ body = fs87.readFileSync(opts.file, "utf8");
110656
111208
  } catch {
110657
111209
  die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
110658
111210
  }
@@ -110688,13 +111240,13 @@ function cmdTriageArchive(sourceId, cardId2) {
110688
111240
  function cmdTriageDismiss(sourceId, reason) {
110689
111241
  const said3 = sourceId.trim();
110690
111242
  if (!said3) die('say which one: `dismiss <source-id> --reason "<why>"`', { kind: "needs-input" });
110691
- const why = reason.trim();
110692
- if (!why) die('say why it is being ignored: --reason "<why>"', { kind: "needs-input" });
111243
+ const why2 = reason.trim();
111244
+ if (!why2) die('say why it is being ignored: --reason "<why>"', { kind: "needs-input" });
110693
111245
  migrateTriage();
110694
- const done2 = dismissInboxItem(said3, "agent", why);
111246
+ const done2 = dismissInboxItem(said3, "agent", why2);
110695
111247
  if (!done2.ok) die(done2.error, { kind: "triage-item-gone" });
110696
111248
  say(`${said3} \u2014 ignored: ${done2.relPath}`);
110697
- return { source_id: said3, reason: why, file: done2.relPath };
111249
+ return { source_id: said3, reason: why2, file: done2.relPath };
110698
111250
  }
110699
111251
  function cmdTriageRestore(sourceId) {
110700
111252
  const said3 = sourceId.trim();
@@ -110904,8 +111456,8 @@ function declareRuns(program2, cli) {
110904
111456
  };
110905
111457
  for (const flow of FLOWS) declareFlow(flow.group ? groups[flow.group] : program2, flow, cli);
110906
111458
  withShared(groups.card.command("reject")).argument("<id>", "the card's id", cardId).argument("[why...]", "why the card is being dropped \u2014 required unless --discard").summary("drop the card").option("--discard", "just drop it: the why may be left off, and nothing learns from it").action(async function(...vals) {
110907
- const [id, why] = positional(vals);
110908
- await onBoard2(this, cli, () => cmdReject(id, why.join(" "), this.opts()));
111459
+ const [id, why2] = positional(vals);
111460
+ await onBoard2(this, cli, () => cmdReject(id, why2.join(" "), this.opts()));
110909
111461
  });
110910
111462
  declareRunning(groups.run, cli);
110911
111463
  declareDelivery(groups.delivery, cli);
@@ -111049,6 +111601,9 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
111049
111601
  flowWord("rename").argument("<id>", "the draft, from `workflow list`").argument("<name...>", "what to call it now").summary("rename the Workflow builder draft. Only inside that task's run.").action(async function(id, name) {
111050
111602
  await onBoard2(this, cli, () => cmdWorkflowRename(id, name.join(" ")));
111051
111603
  });
111604
+ flowWord("diagram").argument("<id>", "the workflow, from `workflow list`").argument("<card>", "the card whose asset folder gets workflow.json").summary("write the workflow's diagram to .assets/<card>/workflow.json and print the <Workflow> tag that shows it").action(async function(id, card) {
111605
+ await onBoard2(this, cli, () => cmdWorkflowDiagram(id, card));
111606
+ });
111052
111607
  withShared(program2.command("components")).summary("list an agent or workflow\u2019s preview components and their usage").option("--agent <name>", "one agent\u2019s components").option("--workflow <id>", "all components used by a workflow").option("--docs", "include component usage documentation").action(async function() {
111053
111608
  const ctx = ctxOf(this, cli.program);
111054
111609
  useBoard(resolveBoard("components", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint }), ctx.dir !== null);
@@ -111225,8 +111780,8 @@ function declareAgent(program2, cli) {
111225
111780
  }
111226
111781
 
111227
111782
  // ../cli/src/lib/cli/setup.ts
111228
- import fs86 from "node:fs";
111229
- import path86 from "node:path";
111783
+ import fs89 from "node:fs";
111784
+ import path89 from "node:path";
111230
111785
  import { fileURLToPath as fileURLToPath3 } from "node:url";
111231
111786
 
111232
111787
  // ../cli/src/commands/update.ts
@@ -111240,8 +111795,8 @@ init_paths();
111240
111795
  init_memory();
111241
111796
  init_yaml2();
111242
111797
  init_version();
111243
- import fs85 from "node:fs";
111244
- import path85 from "node:path";
111798
+ import fs88 from "node:fs";
111799
+ import path88 from "node:path";
111245
111800
  import { spawnSync as spawnSync6 } from "node:child_process";
111246
111801
  var NAME = "wildcrane";
111247
111802
  var REPO = "https://github.com/ai4kanban/ai4kanban";
@@ -111263,10 +111818,10 @@ var Report = class {
111263
111818
  for (const line of this.notes) say(` ! ${line}`);
111264
111819
  }
111265
111820
  };
111266
- var read3 = (file) => fs85.existsSync(file) ? fs85.readFileSync(file, "utf8") : null;
111821
+ var read4 = (file) => fs88.existsSync(file) ? fs88.readFileSync(file, "utf8") : null;
111267
111822
  function statOf(p2) {
111268
111823
  try {
111269
- return fs85.lstatSync(p2);
111824
+ return fs88.lstatSync(p2);
111270
111825
  } catch {
111271
111826
  return null;
111272
111827
  }
@@ -111291,10 +111846,10 @@ async function cmdUpdate2(ctx) {
111291
111846
  return { updated: ctx.dir, from, to: SKILL_VERSION };
111292
111847
  }
111293
111848
  async function repairBoard(root2, report3, named2) {
111294
- const legacy2 = path85.join(root2, "docs", "kanban");
111295
- const kept2 = path85.join(root2, ".akb", "kanban");
111296
- const board2 = named2 ?? (fs85.existsSync(legacy2) ? legacy2 : kept2);
111297
- if (!fs85.existsSync(board2)) {
111849
+ const legacy2 = path88.join(root2, "docs", "kanban");
111850
+ const kept2 = path88.join(root2, ".akb", "kanban");
111851
+ const board2 = named2 ?? (fs88.existsSync(legacy2) ? legacy2 : kept2);
111852
+ if (!fs88.existsSync(board2)) {
111298
111853
  report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
111299
111854
  return false;
111300
111855
  }
@@ -111325,20 +111880,20 @@ function moveRuntimes(root2, board2, report3) {
111325
111880
  }
111326
111881
  }
111327
111882
  function moveLegacyMemory(board2, report3) {
111328
- const memory = path85.join(board2, "memory");
111883
+ const memory = path88.join(board2, "memory");
111329
111884
  const moved = [];
111330
111885
  for (const name of MEMORY_FILES) {
111331
- const from = path85.join(board2, name);
111886
+ const from = path88.join(board2, name);
111332
111887
  const st2 = statOf(from);
111333
111888
  if (!st2 || !st2.isFile()) continue;
111334
- fs85.mkdirSync(memory, { recursive: true });
111335
- const to = path85.join(memory, name);
111336
- const there = read3(to);
111889
+ fs88.mkdirSync(memory, { recursive: true });
111890
+ const to = path88.join(memory, name);
111891
+ const there = read4(to);
111337
111892
  if (there === null) {
111338
- fs85.renameSync(from, to);
111893
+ fs88.renameSync(from, to);
111339
111894
  moved.push(name);
111340
- } else if (there === read3(from)) {
111341
- fs85.rmSync(from);
111895
+ } else if (there === read4(from)) {
111896
+ fs88.rmSync(from);
111342
111897
  moved.push(name);
111343
111898
  } else {
111344
111899
  report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
@@ -111347,23 +111902,23 @@ function moveLegacyMemory(board2, report3) {
111347
111902
  if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
111348
111903
  }
111349
111904
  function dropRecordFile(board2) {
111350
- const file = path85.join(board2, "record.csv");
111351
- if (!fs85.existsSync(file)) return null;
111352
- fs85.rmSync(file);
111905
+ const file = path88.join(board2, "record.csv");
111906
+ if (!fs88.existsSync(file)) return null;
111907
+ fs88.rmSync(file);
111353
111908
  return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
111354
111909
  }
111355
111910
  function dropModuleGoals(board2, report3) {
111356
- const memory = path85.join(board2, "memory");
111357
- if (!fs85.existsSync(memory)) return;
111358
- const root2 = read3(path85.join(memory, "goal.md"));
111911
+ const memory = path88.join(board2, "memory");
111912
+ if (!fs88.existsSync(memory)) return;
111913
+ const root2 = read4(path88.join(memory, "goal.md"));
111359
111914
  let dropped = 0;
111360
- for (const entry of fs85.readdirSync(memory, { withFileTypes: true })) {
111915
+ for (const entry of fs88.readdirSync(memory, { withFileTypes: true })) {
111361
111916
  if (!entry.isDirectory()) continue;
111362
- const file = path85.join(memory, entry.name, "goal.md");
111363
- const text5 = read3(file);
111917
+ const file = path88.join(memory, entry.name, "goal.md");
111918
+ const text5 = read4(file);
111364
111919
  if (text5 === null) continue;
111365
111920
  if (text5 === root2 || text5.includes(UNFILLED) || !goalWords(text5)) {
111366
- fs85.rmSync(file);
111921
+ fs88.rmSync(file);
111367
111922
  dropped++;
111368
111923
  } else {
111369
111924
  report3.notes.push(
@@ -111385,10 +111940,10 @@ var PLAN_LEADS = {
111385
111940
  var GONE_LEADS = ["software-planner", "planner"];
111386
111941
  function planLeads(board2) {
111387
111942
  const leads = { ...PLAN_LEADS };
111388
- const root2 = path85.join(board2, "workflows");
111389
- for (const entry of fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []) {
111943
+ const root2 = path88.join(board2, "workflows");
111944
+ for (const entry of fs88.existsSync(root2) ? fs88.readdirSync(root2, { withFileTypes: true }) : []) {
111390
111945
  if (!entry.isDirectory()) continue;
111391
- const meta = splitFrontmatter(read3(path85.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
111946
+ const meta = splitFrontmatter(read4(path88.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
111392
111947
  const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
111393
111948
  const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
111394
111949
  const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
@@ -111397,30 +111952,30 @@ function planLeads(board2) {
111397
111952
  return leads;
111398
111953
  }
111399
111954
  function movePlanRules(board2, report3) {
111400
- const rules = path85.join(board2, "rules");
111955
+ const rules = path88.join(board2, "rules");
111401
111956
  const moved = [];
111402
111957
  for (const [id, leads] of Object.entries(planLeads(board2))) {
111403
111958
  for (const lead of leads) {
111404
- const from = path85.join(rules, `${lead}.md`);
111405
- const rule = read3(from)?.trim();
111959
+ const from = path88.join(rules, `${lead}.md`);
111960
+ const rule = read4(from)?.trim();
111406
111961
  if (!rule) continue;
111407
- const to = path85.join(rules, "workflows", `${id}.md`);
111408
- const there = read3(to)?.trim() ?? "";
111962
+ const to = path88.join(rules, "workflows", `${id}.md`);
111963
+ const there = read4(to)?.trim() ?? "";
111409
111964
  if (!there.includes(rule)) {
111410
- fs85.mkdirSync(path85.dirname(to), { recursive: true });
111411
- fs85.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
111965
+ fs88.mkdirSync(path88.dirname(to), { recursive: true });
111966
+ fs88.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
111412
111967
  `);
111413
111968
  moved.push(`${lead} \u2192 ${id}`);
111414
111969
  }
111415
111970
  }
111416
111971
  }
111417
- for (const lead of GONE_LEADS) fs85.rmSync(path85.join(rules, `${lead}.md`), { force: true });
111972
+ for (const lead of GONE_LEADS) fs88.rmSync(path88.join(rules, `${lead}.md`), { force: true });
111418
111973
  if (moved.length) report3.did.push(`made each plan agent's rule its workflow's card rule (docs/kanban/rules/workflows/): ${moved.join(", ")}`);
111419
111974
  }
111420
111975
  function noteOldWorkflows(board2, report3) {
111421
111976
  const old = (dir, file, keys) => {
111422
- const root2 = path85.join(board2, dir);
111423
- return (fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []).filter((e2) => e2.isDirectory() && keys.test(splitFrontmatter(read3(path85.join(root2, e2.name, file)) ?? "").meta ?? "")).map((e2) => `docs/kanban/${dir}/${e2.name}/${file}`);
111977
+ const root2 = path88.join(board2, dir);
111978
+ return (fs88.existsSync(root2) ? fs88.readdirSync(root2, { withFileTypes: true }) : []).filter((e2) => e2.isDirectory() && keys.test(splitFrontmatter(read4(path88.join(root2, e2.name, file)) ?? "").meta ?? "")).map((e2) => `docs/kanban/${dir}/${e2.name}/${file}`);
111424
111979
  };
111425
111980
  const files2 = [...old("workflows", "WORKFLOW.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
111426
111981
  if (files2.length) {
@@ -111430,7 +111985,7 @@ function noteOldWorkflows(board2, report3) {
111430
111985
  }
111431
111986
  }
111432
111987
  function checkConfig(board2, report3) {
111433
- const current = read3(path85.join(board2, "config.md"));
111988
+ const current = read4(path88.join(board2, "config.md"));
111434
111989
  if (!current) return;
111435
111990
  const added = missingConfigKeys(current);
111436
111991
  if (added.length) {
@@ -111440,7 +111995,7 @@ function checkConfig(board2, report3) {
111440
111995
  }
111441
111996
  }
111442
111997
  function checkModules(board2, report3) {
111443
- const map2 = read3(path85.join(board2, "modules.md"));
111998
+ const map2 = read4(path88.join(board2, "modules.md"));
111444
111999
  if (map2 && map2.includes(UNFILLED)) {
111445
112000
  report3.notes.push(
111446
112001
  "docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
@@ -111494,14 +112049,14 @@ function declareSetup(program2, cli) {
111494
112049
  program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
111495
112050
  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");
111496
112051
  const where = (cmd) => {
111497
- const dir = path86.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
111498
- if (!fs86.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
112052
+ const dir = path89.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
112053
+ if (!fs89.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
111499
112054
  return dir;
111500
112055
  };
111501
112056
  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() {
111502
112057
  const dir = where(this);
111503
112058
  const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
111504
- const board2 = named2 ? path86.resolve(cli.cwd, named2) : null;
112059
+ const board2 = named2 ? path89.resolve(cli.cwd, named2) : null;
111505
112060
  await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
111506
112061
  });
111507
112062
  program2.command("__rules", { hidden: true }).action(function() {
@@ -111546,7 +112101,7 @@ function invokedDirectly() {
111546
112101
  const entry = process.argv[1];
111547
112102
  if (!entry) return false;
111548
112103
  try {
111549
- return fs87.realpathSync(entry) === fs87.realpathSync(SELF2);
112104
+ return fs90.realpathSync(entry) === fs90.realpathSync(SELF2);
111550
112105
  } catch {
111551
112106
  return false;
111552
112107
  }