wildcrane-runner 0.6.26 → 0.6.28

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.25 — 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.25",
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 ?? {};
@@ -6744,6 +6877,7 @@ function checkWorkflowFiles(value, official = false) {
6744
6877
  if (problem) return fail(file, problem);
6745
6878
  continue;
6746
6879
  }
6880
+ if (official && isAboutFile(file)) continue;
6747
6881
  if (official && file.startsWith("skills/")) {
6748
6882
  if (!folderPath(file, "skills")) return fail(file, "is not inside skills/<name>/");
6749
6883
  skills.add(file.split("/")[1]);
@@ -6759,9 +6893,9 @@ function checkWorkflowFiles(value, official = false) {
6759
6893
  }
6760
6894
  const source = value[WORKFLOW_FILE];
6761
6895
  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;
6896
+ const read5 = parseWorkflowFile("workflow", source, WORKFLOW_FILE);
6897
+ if ("problem" in read5) return fail(WORKFLOW_FILE, read5.problem.replace(`${WORKFLOW_FILE}: `, ""));
6898
+ const def = read5.def;
6765
6899
  const agents = /* @__PURE__ */ new Map();
6766
6900
  for (const [name, own] of folders2) {
6767
6901
  const from = `agents/${name}/AGENT.md`;
@@ -6777,17 +6911,18 @@ function checkWorkflowFiles(value, official = false) {
6777
6911
  ...def.land.filter((h3) => !LAND_ROLES.includes(h3.agent)).map((h3) => [h3.agent, "it lands with"]),
6778
6912
  ...def.scheduled.map((s) => [s.agent, "it schedules"])
6779
6913
  ];
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`);
6914
+ for (const [name, why2] of named2) {
6915
+ if (!agents.has(name)) return fail(WORKFLOW_FILE, `${why2} \`${name}\`, which has no agents/${name}/AGENT.md`);
6782
6916
  }
6783
6917
  return { ok: true, def, files: value };
6784
6918
  }
6785
- var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, LAND_ROLES, landsOf, SEGMENT, bytes;
6919
+ var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, LAND_ROLES, landsOf, SEGMENT, isAboutFile, bytes;
6786
6920
  var init_workflow_files = __esm({
6787
6921
  "../cloud/src/v1/workflow-files.ts"() {
6788
6922
  "use strict";
6789
6923
  init_workflow_def();
6790
6924
  init_parse();
6925
+ init_workflow_diagram();
6791
6926
  WORKFLOW_FILE = "WORKFLOW.md";
6792
6927
  MCP_FILE = "mcp.json";
6793
6928
  KB = 1024;
@@ -6795,6 +6930,7 @@ var init_workflow_files = __esm({
6795
6930
  LAND_ROLES = ["builder"];
6796
6931
  landsOf = (def) => ({ lands: def.land.some((h3) => !h3.off) });
6797
6932
  SEGMENT = /^[\w.-]+$/;
6933
+ isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
6798
6934
  bytes = (text5) => new TextEncoder().encode(text5).length;
6799
6935
  }
6800
6936
  });
@@ -6817,20 +6953,21 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
6817
6953
  return [name, Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, fs20.readFileSync(path21.join(dir, f2), "utf8")]))];
6818
6954
  }));
6819
6955
  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);
6956
+ const read5 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
6957
+ if ("problem" in read5) throw new Error(read5.problem);
6822
6958
  }
6823
6959
  const workflowsDir = path21.join(root2, "workflows");
6824
6960
  return dirs(workflowsDir).map((folder) => {
6825
6961
  const dir = path21.join(workflowsDir, folder);
6826
6962
  const files2 = {};
6827
6963
  for (const f2 of filesOf(dir).sort()) {
6828
- if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/")) files2[f2] = fs20.readFileSync(path21.join(dir, f2), "utf8");
6964
+ if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || /^ABOUT(\.[a-z]{2})?\.md$/.test(f2)) files2[f2] = fs20.readFileSync(path21.join(dir, f2), "utf8");
6965
+ else if (isAboutFile(f2)) files2[f2] = `data:${MIME[path21.extname(f2)]};base64,${fs20.readFileSync(path21.join(dir, f2)).toString("base64")}`;
6829
6966
  }
6830
- const read4 = checkWorkflowFiles({ [WORKFLOW_FILE]: files2[WORKFLOW_FILE], ...Object.fromEntries(
6967
+ const read5 = checkWorkflowFiles({ [WORKFLOW_FILE]: files2[WORKFLOW_FILE], ...Object.fromEntries(
6831
6968
  Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f2, t]) => [`agents/${name}/${f2}`, t]))
6832
6969
  ) });
6833
- if (!read4.ok && !loose) throw new Error(`official/workflows/${folder}: ${read4.file}: ${read4.reason}`);
6970
+ if (!read5.ok && !loose) throw new Error(`official/workflows/${folder}: ${read5.file}: ${read5.reason}`);
6834
6971
  const parsed = parseWorkflowFile(folder, files2[WORKFLOW_FILE] ?? "", WORKFLOW_FILE);
6835
6972
  if ("problem" in parsed) throw new Error(parsed.problem);
6836
6973
  const def = parsed.def;
@@ -6852,13 +6989,14 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
6852
6989
  };
6853
6990
  });
6854
6991
  }
6855
- var OFFICIAL, dirs, officialId, hashOf;
6992
+ var OFFICIAL, MIME, dirs, officialId, hashOf;
6856
6993
  var init_pack = __esm({
6857
6994
  "../official/pack.ts"() {
6858
6995
  init_parse();
6859
6996
  init_workflow_def();
6860
6997
  init_workflow_files();
6861
6998
  OFFICIAL = path21.dirname(fileURLToPath(import.meta.url));
6999
+ MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
6862
7000
  dirs = (dir) => fs20.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
6863
7001
  officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
6864
7002
  hashOf = (files2) => crypto4.createHash("sha256").update(JSON.stringify(Object.entries(files2).sort(([a2], [b2]) => a2 < b2 ? -1 : 1))).digest("hex");
@@ -6903,18 +7041,18 @@ function pinMissing() {
6903
7041
  async function versionOf(id, version) {
6904
7042
  const held4 = readVersion(id, version);
6905
7043
  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;
7044
+ const read5 = await call("GET", `/v1/workflows/${encodeURIComponent(id)}`);
7045
+ if (!read5.ok) return read5;
7046
+ saveVersion(read5.value);
7047
+ return read5;
6910
7048
  }
6911
7049
  async function pinTask(task) {
6912
7050
  const pin = readPin(task);
6913
7051
  const held4 = pin && readVersion(pin.workflow, pin.version);
6914
7052
  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 };
7053
+ const read5 = await call("GET", `/v1/tasks/${encodeURIComponent(task)}/workflow`);
7054
+ if (!read5.ok) return read5;
7055
+ const value = { id: read5.value.workflow, version: read5.value.version, name: read5.value.name, files: read5.value.files };
6918
7056
  savePin(task, value);
6919
7057
  return { ok: true, value };
6920
7058
  }
@@ -6933,12 +7071,12 @@ async function syncWorkflows(force = false) {
6933
7071
  if (fresh && !force) return;
6934
7072
  let workspace = held4?.workspace;
6935
7073
  if (!workspace) {
6936
- const read4 = await call("GET", `/v1/projects/${encodeURIComponent(project)}`);
6937
- if (!read4.ok) {
6938
- offline = !read4.code;
7074
+ const read5 = await call("GET", `/v1/projects/${encodeURIComponent(project)}`);
7075
+ if (!read5.ok) {
7076
+ offline = !read5.code;
6939
7077
  return;
6940
7078
  }
6941
- workspace = read4.value.workspace;
7079
+ workspace = read5.value.workspace;
6942
7080
  }
6943
7081
  const listed = [];
6944
7082
  let after2 = null;
@@ -6956,9 +7094,9 @@ async function syncWorkflows(force = false) {
6956
7094
  } while (after2);
6957
7095
  const kept2 = [];
6958
7096
  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;
7097
+ const read5 = await versionOf(w2.id, w2.version);
7098
+ if (read5.ok) kept2.push({ id: read5.value.id, version: read5.value.version });
7099
+ else if (!read5.code) offline = true;
6962
7100
  }
6963
7101
  writeJson(listFile(project), { at: (/* @__PURE__ */ new Date()).toISOString(), workspace, workflows: kept2 });
6964
7102
  } catch {
@@ -7031,9 +7169,9 @@ var init_cloud_workflows = __esm({
7031
7169
  workflowsOffline = () => offline;
7032
7170
  flowOf = (held4) => {
7033
7171
  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 };
7172
+ const read5 = parseWorkflowFile(id, held4.files["WORKFLOW.md"] ?? "", `the \`${id}\` workflow`);
7173
+ if ("problem" in read5) return null;
7174
+ return { def: read5.def, cloudId: held4.id, version: held4.version, builtIn: held4.id.startsWith("wf_builtin_"), files: held4.files };
7037
7175
  };
7038
7176
  sources = () => {
7039
7177
  if (devFolder()) return [devFolder()];
@@ -7065,16 +7203,16 @@ function readCatalog() {
7065
7203
  const agents = [];
7066
7204
  const problems = [];
7067
7205
  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";
7206
+ const take = (read5, folder) => {
7207
+ if ("problem" in read5) {
7208
+ if (!read5.missing) problems.push(read5.problem);
7209
+ if (!read5.file) return;
7210
+ const { file, name: name2, old } = read5;
7211
+ const cause = read5.missing ? "noFile" : old ? "oldKeys" : "file";
7074
7212
  refused.push({ folder, file, cause, ...name2 ? { name: name2 } : {}, ...old ? { keys: old.keys } : {} });
7075
7213
  return;
7076
7214
  }
7077
- const { name, from, builtIn } = read4.agent;
7215
+ const { name, from, builtIn } = read5.agent;
7078
7216
  const refuse3 = (cause, problem) => {
7079
7217
  problems.push(problem);
7080
7218
  if (!builtIn) refused.push({ folder, name, file: from, cause });
@@ -7098,14 +7236,14 @@ function readCatalog() {
7098
7236
  `${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
7237
  );
7100
7238
  }
7101
- agents.push(read4.agent);
7239
+ agents.push(read5.agent);
7102
7240
  };
7103
7241
  for (const folder of bundledFolders()) take(readBundled(folder), folder);
7104
7242
  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}`);
7243
+ const read5 = readProject(AGENTS, folder);
7244
+ take(read5, folder);
7245
+ if ("agent" in read5 && read5.agent.from.endsWith(LEGACY_AGENT_FILE)) {
7246
+ problems.push(`${read5.agent.from}: rename it to ${AGENT_FILE}`);
7109
7247
  }
7110
7248
  }
7111
7249
  for (const folder of projectFolders(LEGACY_AGENTS)) {
@@ -7210,10 +7348,10 @@ function readProject(root2, folder) {
7210
7348
  const missing = rel(path23.join(dir, AGENT_FILE));
7211
7349
  if (!found2) return { problem: `${missing} is missing`, file: missing, missing: true };
7212
7350
  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;
7351
+ const read5 = parseSpecAgent(found2.text, from, file, false, () => ownFiles(walkFolder(dir, "")));
7352
+ if ("problem" in read5) return { ...read5, file: from };
7353
+ if ("agent" in read5) Object.assign(read5.agent, { dir, text: found2.text });
7354
+ return read5;
7217
7355
  }
7218
7356
  var specAgentCatalog, bundledFolders, AGENT_FILE, LEGACY_AGENT_FILE, AGENT_FILES, ownFiles;
7219
7357
  var init_catalog2 = __esm({
@@ -8255,10 +8393,10 @@ function findRollout(threadId) {
8255
8393
  }
8256
8394
  for (const name of names3) {
8257
8395
  if (!name.startsWith("rollout-") || !name.endsWith(tail2)) continue;
8258
- const path87 = join(dir, name);
8396
+ const path90 = join(dir, name);
8259
8397
  try {
8260
- const at2 = statSync(path87).mtimeMs;
8261
- if (!newest2 || at2 > newest2.at) newest2 = { path: path87, at: at2 };
8398
+ const at2 = statSync(path90).mtimeMs;
8399
+ if (!newest2 || at2 > newest2.at) newest2 = { path: path90, at: at2 };
8262
8400
  } catch {
8263
8401
  }
8264
8402
  }
@@ -8266,11 +8404,11 @@ function findRollout(threadId) {
8266
8404
  return newest2?.path;
8267
8405
  }
8268
8406
  function readCodexRunFacts(threadId) {
8269
- const path87 = findRollout(threadId);
8270
- if (!path87) return void 0;
8407
+ const path90 = findRollout(threadId);
8408
+ if (!path90) return void 0;
8271
8409
  let raw;
8272
8410
  try {
8273
- raw = readFileSync(path87, "utf8");
8411
+ raw = readFileSync(path90, "utf8");
8274
8412
  } catch {
8275
8413
  return void 0;
8276
8414
  }
@@ -8398,8 +8536,8 @@ function renderCompleted(item) {
8398
8536
  const changes = Array.isArray(item.changes) ? item.changes : [];
8399
8537
  return changes.map((raw) => {
8400
8538
  const change2 = obj(raw);
8401
- const path87 = str2(change2.path);
8402
- return path87 ? `\u23FA ${str2(change2.kind) || "change"}(${path87})
8539
+ const path90 = str2(change2.path);
8540
+ return path90 ? `\u23FA ${str2(change2.kind) || "change"}(${path90})
8403
8541
  ` : "";
8404
8542
  }).join("");
8405
8543
  }
@@ -8661,10 +8799,10 @@ function readKimiRunFacts(sessionId) {
8661
8799
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
8662
8800
  let model;
8663
8801
  let holding = 0;
8664
- for (const { path: path87, main } of wireFiles(entry.sessionDir)) {
8802
+ for (const { path: path90, main } of wireFiles(entry.sessionDir)) {
8665
8803
  let raw;
8666
8804
  try {
8667
- raw = readFileSync2(path87, "utf8");
8805
+ raw = readFileSync2(path90, "utf8");
8668
8806
  } catch {
8669
8807
  continue;
8670
8808
  }
@@ -8727,9 +8865,9 @@ function toolCalls(row) {
8727
8865
  }).join("");
8728
8866
  }
8729
8867
  function retry(row) {
8730
- const why = str2(row.error_message) || str2(row.error_name) || "the provider failed";
8868
+ const why2 = str2(row.error_message) || str2(row.error_name) || "the provider failed";
8731
8869
  const attempt2 = `${num(row.next_attempt)}/${num(row.max_attempts)}`;
8732
- return `[retry ${attempt2}] ${why}
8870
+ return `[retry ${attempt2}] ${why2}
8733
8871
  `;
8734
8872
  }
8735
8873
  function createKimiStreamRenderer(cwd) {
@@ -8818,10 +8956,10 @@ function connect(stdout, stdin, onCall, dialect = {}) {
8818
8956
  } catch {
8819
8957
  }
8820
8958
  };
8821
- const closed2 = (why) => {
8959
+ const closed2 = (why2) => {
8822
8960
  if (gone) return;
8823
- gone = why;
8824
- for (const { fail } of waiting.values()) fail(new Error(why));
8961
+ gone = why2;
8962
+ for (const { fail } of waiting.values()) fail(new Error(why2));
8825
8963
  waiting.clear();
8826
8964
  };
8827
8965
  stdout.on("data", (chunk) => {
@@ -8945,8 +9083,8 @@ var init_tail = __esm({
8945
9083
  import fs28 from "node:fs";
8946
9084
  function whereHint(update2, title) {
8947
9085
  const locations = Array.isArray(update2.locations) ? update2.locations : [];
8948
- const path87 = str2(obj(locations[0]).path);
8949
- return path87 && !title.includes(path87) ? hint(path87) : "";
9086
+ const path90 = str2(obj(locations[0]).path);
9087
+ return path90 && !title.includes(path90) ? hint(path90) : "";
8950
9088
  }
8951
9089
  function saidBy(update2) {
8952
9090
  const content = Array.isArray(update2.content) ? update2.content : [];
@@ -9111,12 +9249,12 @@ async function oneTurn(io, options) {
9111
9249
  const usage3 = usageOf2(done2.usage) ?? usageOf2(spent, true);
9112
9250
  costUsd ??= ticksUsd(spent.costUsdTicks);
9113
9251
  if (stopReason2 && stopReason2 !== "end_turn") {
9114
- const why = STOPPED[stopReason2] ?? `the agent stopped: ${stopReason2}`;
9115
- io.log(`[error] ${why}
9252
+ const why2 = STOPPED[stopReason2] ?? `the agent stopped: ${stopReason2}`;
9253
+ io.log(`[error] ${why2}
9116
9254
  `);
9117
- events.error(why);
9255
+ events.error(why2);
9118
9256
  emit();
9119
- return { ok: false, result, error: why, usage: usage3, context, costUsd };
9257
+ return { ok: false, result, error: why2, usage: usage3, context, costUsd };
9120
9258
  }
9121
9259
  emit();
9122
9260
  return { ok: true, result, usage: usage3, context, costUsd };
@@ -9146,8 +9284,8 @@ function update(raw, tail2, gotCost, gotContext) {
9146
9284
  }
9147
9285
  case "tool_call_update": {
9148
9286
  if (change2.status !== "failed") return;
9149
- const why = saidBy(change2);
9150
- tail2.line(`[error] ${str2(change2.title) || "that tool call"} failed${why ? `: ${why}` : ""}`);
9287
+ const why2 = saidBy(change2);
9288
+ tail2.line(`[error] ${str2(change2.title) || "that tool call"} failed${why2 ? `: ${why2}` : ""}`);
9151
9289
  return;
9152
9290
  }
9153
9291
  case "usage_update": {
@@ -9261,8 +9399,8 @@ function createParts(tail2) {
9261
9399
  tail2.line(`\u23FA ${title}${whereHint2(state.input, title)}`);
9262
9400
  }
9263
9401
  if (str2(state.status) === "error") {
9264
- const why = str2(state.error).trim();
9265
- tail2.line(`[error] ${title} failed${why ? `: ${why}` : ""}`);
9402
+ const why2 = str2(state.error).trim();
9403
+ tail2.line(`[error] ${title} failed${why2 ? `: ${why2}` : ""}`);
9266
9404
  }
9267
9405
  },
9268
9406
  /** A piece of one part, as `part.delta` sends it. */
@@ -9295,18 +9433,18 @@ function createParts(tail2) {
9295
9433
  toolUpdate(payload) {
9296
9434
  if (str2(payload.kind) !== "error") return;
9297
9435
  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)}` : ""}`);
9436
+ const why2 = str2(obj(payload.error).message).split("\n")[0].trim();
9437
+ tail2.line(`[error] ${name} failed${why2 ? `: ${why2.slice(0, 200)}` : ""}`);
9300
9438
  }
9301
9439
  };
9302
9440
  }
9303
9441
  function createZcodeClient(options = {}) {
9304
9442
  return { turn: (io) => oneTurn2(io, options) };
9305
9443
  }
9306
- function stopped(io, why) {
9307
- io.log(`[error] ${why}
9444
+ function stopped(io, why2) {
9445
+ io.log(`[error] ${why2}
9308
9446
  `);
9309
- if (MISSING_KEY.test(why)) {
9447
+ if (MISSING_KEY.test(why2)) {
9310
9448
  io.log("[board] paste a Z.AI or BigModel Coding Plan key into ZCode's key box in Configuration.\n");
9311
9449
  }
9312
9450
  }
@@ -9396,9 +9534,9 @@ async function oneTurn2(io, options) {
9396
9534
  const usage3 = done2.usage ?? await tokensOf(rpc, sessionId);
9397
9535
  const context = await contextOf(rpc, sessionId);
9398
9536
  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 };
9537
+ const why2 = done2.error ?? "the agent stopped without saying why";
9538
+ stopped(io, why2);
9539
+ return { ok: false, result, error: why2, usage: usage3, context };
9402
9540
  }
9403
9541
  return { ok: true, result, usage: usage3, context };
9404
9542
  } catch (e2) {
@@ -9417,8 +9555,8 @@ async function tokensOf(rpc, sessionId) {
9417
9555
  }
9418
9556
  async function contextOf(rpc, sessionId) {
9419
9557
  try {
9420
- const read4 = await rpc.call("session/read", { sessionId, messageLimit: 1 });
9421
- const state = obj(read4.projection);
9558
+ const read5 = await rpc.call("session/read", { sessionId, messageLimit: 1 });
9559
+ const state = obj(read5.projection);
9422
9560
  const used = num(state.contextUsed);
9423
9561
  const limit = num(state.contextWindow);
9424
9562
  return used > 0 ? { used, limit: limit > 0 ? limit : void 0 } : void 0;
@@ -11134,12 +11272,12 @@ var init_language = __esm({
11134
11272
 
11135
11273
  // ../cli/src/lib/agent/proxy.ts
11136
11274
  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"] })) {
11275
+ function withSystemProxy(env2 = process.env, platform = process.platform, read5 = () => execFileSync("/usr/sbin/scutil", ["--proxy"], { encoding: "utf8", timeout: 1e3, stdio: ["ignore", "pipe", "ignore"] })) {
11138
11276
  const out = { ...env2 };
11139
11277
  if (platform !== "darwin" || PROXY_KEYS.some((key) => env2[key] !== void 0)) return out;
11140
11278
  let raw;
11141
11279
  try {
11142
- raw = read4();
11280
+ raw = read5();
11143
11281
  } catch {
11144
11282
  return out;
11145
11283
  }
@@ -11779,12 +11917,12 @@ function readAnswers(raw) {
11779
11917
  if (!Array.isArray(raw)) return void 0;
11780
11918
  const answers2 = raw.flatMap((entry) => {
11781
11919
  if (!entry || entry.outcome !== "changed" && entry.outcome !== "unchanged") return [];
11782
- const why = text3(entry.why);
11783
- if (!why) return [];
11920
+ const why2 = text3(entry.why);
11921
+ if (!why2) return [];
11784
11922
  return [
11785
11923
  {
11786
11924
  outcome: entry.outcome,
11787
- why,
11925
+ why: why2,
11788
11926
  at: typeof entry.at === "number" ? entry.at : 0,
11789
11927
  actedAt: typeof entry.actedAt === "number" ? entry.actedAt : void 0
11790
11928
  }
@@ -12211,12 +12349,12 @@ function writeConfig(change2) {
12211
12349
  try {
12212
12350
  cfg = readConfigRaw();
12213
12351
  } catch (e2) {
12214
- const why = e2 instanceof Error ? e2.message : String(e2);
12352
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12215
12353
  return {
12216
12354
  ok: false,
12217
- ...refusal("fileParse", `couldn't save: ${UI_CONFIG} won't parse (${why}). Fix the file, then try again.`, {
12355
+ ...refusal("fileParse", `couldn't save: ${UI_CONFIG} won't parse (${why2}). Fix the file, then try again.`, {
12218
12356
  path: UI_CONFIG,
12219
- details: why
12357
+ details: why2
12220
12358
  })
12221
12359
  };
12222
12360
  }
@@ -12227,8 +12365,8 @@ function writeConfig(change2) {
12227
12365
  forgetFileMemos();
12228
12366
  return { ok: true };
12229
12367
  } 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 }) };
12368
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12369
+ return { ok: false, ...refusal("fileWrite", `couldn't write ${UI_CONFIG}: ${why2}`, { path: UI_CONFIG, details: why2 }) };
12232
12370
  }
12233
12371
  }
12234
12372
  function parseLine(line) {
@@ -12274,12 +12412,12 @@ function ensureIgnored() {
12274
12412
  fs34.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${IGNORE_BLOCK}`);
12275
12413
  return { ok: true };
12276
12414
  } catch (e2) {
12277
- const why = e2 instanceof Error ? e2.message : String(e2);
12415
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12278
12416
  return {
12279
12417
  ok: false,
12280
- ...refusal("gitignoreWrite", `couldn't write ${KANBAN_GITIGNORE} to keep the key out of git: ${why}`, {
12418
+ ...refusal("gitignoreWrite", `couldn't write ${KANBAN_GITIGNORE} to keep the key out of git: ${why2}`, {
12281
12419
  path: KANBAN_GITIGNORE,
12282
- details: why
12420
+ details: why2
12283
12421
  })
12284
12422
  };
12285
12423
  }
@@ -12291,8 +12429,8 @@ function setSecret(name, value) {
12291
12429
  try {
12292
12430
  lines = fs34.existsSync(ENV_FILE) ? fs34.readFileSync(ENV_FILE, "utf8").split("\n") : [];
12293
12431
  } 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 }) };
12432
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12433
+ return { ok: false, ...refusal("fileRead", `couldn't read ${ENV_FILE}: ${why2}`, { path: ENV_FILE, details: why2 }) };
12296
12434
  }
12297
12435
  const next = value.trim();
12298
12436
  const kept2 = [];
@@ -12315,8 +12453,8 @@ function setSecret(name, value) {
12315
12453
  fs34.writeFileSync(ENV_FILE, text5, { mode: 384 });
12316
12454
  return { ok: true };
12317
12455
  } 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 }) };
12456
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
12457
+ return { ok: false, ...refusal("fileWrite", `couldn't write ${ENV_FILE}: ${why2}`, { path: ENV_FILE, details: why2 }) };
12320
12458
  }
12321
12459
  }
12322
12460
  function stampSchedule(key, when) {
@@ -13594,12 +13732,12 @@ function readFolder2(id, problems) {
13594
13732
  problems.push(`${rel(fileOf(id))} is missing`);
13595
13733
  return null;
13596
13734
  }
13597
- const read4 = parseWorkflowFile(id, source, rel(fileOf(id)));
13598
- if ("problem" in read4) {
13599
- problems.push(read4.problem);
13735
+ const read5 = parseWorkflowFile(id, source, rel(fileOf(id)));
13736
+ if ("problem" in read5) {
13737
+ problems.push(read5.problem);
13600
13738
  return null;
13601
13739
  }
13602
- return read4.def;
13740
+ return read5.def;
13603
13741
  }
13604
13742
  function boardWorkflowDefs() {
13605
13743
  const problems = [];
@@ -13760,8 +13898,8 @@ function writeDraft(def, settings) {
13760
13898
  try {
13761
13899
  writeWorkflowDef(def);
13762
13900
  } 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 }) };
13901
+ const why2 = e2 instanceof Error ? e2.message : String(e2);
13902
+ return { ok: false, ...refusal("fileWrite", `couldn't write the "${def.name}" workflow: ${why2}`, { path: def.id, details: why2 }) };
13765
13903
  }
13766
13904
  return settings ? save2(settings) : { ok: true };
13767
13905
  }
@@ -14717,8 +14855,8 @@ function takeUnchanged(delivery) {
14717
14855
  for (const answer2 of live.answers ?? []) if (!answer2.actedAt && answer2.outcome === "unchanged") answer2.actedAt = now;
14718
14856
  });
14719
14857
  }
14720
- function recordAnswer(deliveryId, outcome, why) {
14721
- const line = why.trim();
14858
+ function recordAnswer(deliveryId, outcome, why2) {
14859
+ const line = why2.trim();
14722
14860
  if (!line) return { ok: false, error: "say in one sentence what the answers did \u2014 an unexplained conclusion is not one." };
14723
14861
  return withStore((store) => {
14724
14862
  const delivery = store.deliveries.find((d2) => d2.deliveryId === deliveryId);
@@ -15533,6 +15671,14 @@ var init_Storyboard = __esm({
15533
15671
  }
15534
15672
  });
15535
15673
 
15674
+ // ../cli/src/components/Workflow.md
15675
+ var Workflow_default;
15676
+ var init_Workflow = __esm({
15677
+ "../cli/src/components/Workflow.md"() {
15678
+ 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';
15679
+ }
15680
+ });
15681
+
15536
15682
  // ../cli/src/lib/components.ts
15537
15683
  function agentComponents(names3, documents = DOCUMENTS) {
15538
15684
  const docs = /* @__PURE__ */ new Map();
@@ -15565,11 +15711,12 @@ var init_components = __esm({
15565
15711
  init_Asset();
15566
15712
  init_Compare();
15567
15713
  init_Storyboard();
15714
+ init_Workflow();
15568
15715
  init_agents();
15569
15716
  init_io();
15570
15717
  init_paths();
15571
15718
  init_workflows();
15572
- DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default };
15719
+ DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default, Workflow: Workflow_default };
15573
15720
  componentDocsText = (docs) => docs.map((doc) => doc.text.trim()).join("\n\n");
15574
15721
  }
15575
15722
  });
@@ -15714,8 +15861,8 @@ import path51 from "node:path";
15714
15861
  function stopReason(deliveryId) {
15715
15862
  const delivery = findDelivery(deliveryId);
15716
15863
  if (!delivery) return void 0;
15717
- const why = firstLine(delivery.review?.stopped?.why);
15718
- if (why) return why;
15864
+ const why2 = firstLine(delivery.review?.stopped?.why);
15865
+ if (why2) return why2;
15719
15866
  const ids = new Set(delivery.sessions);
15720
15867
  const last = readRuns().filter((r2) => ids.has(r2.sessionId) && r2.action === "implement" && r2.status !== "running").at(-1);
15721
15868
  if (!last) return void 0;
@@ -16529,9 +16676,9 @@ function endedDeliveryRefusal(r2, refusals) {
16529
16676
  if (refusals?.has(r2.deliveryId)) return refusals.get(r2.deliveryId);
16530
16677
  const delivery = findDelivery(r2.deliveryId);
16531
16678
  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;
16679
+ const why2 = ended ? resumeRefusal(delivery) : void 0;
16680
+ refusals?.set(r2.deliveryId, why2);
16681
+ return why2;
16535
16682
  }
16536
16683
  function retryAsk(r2) {
16537
16684
  if (r2.resumedFrom && r2.action !== "create" || isRetired(r2.action)) return void 0;
@@ -16862,7 +17009,7 @@ function planningSession(cardId2, cwd = REPO_ROOT) {
16862
17009
  function carriedSession(req) {
16863
17010
  const carries = PLANNING.has(req.action) || req.action === "implement" && !!req.carry?.resumeId;
16864
17011
  if (!Number.isInteger(req.id) || !carries) return void 0;
16865
- const fresh = (why) => ({ note: `new session \u2014 ${why}` });
17012
+ const fresh = (why2) => ({ note: `new session \u2014 ${why2}` });
16866
17013
  if (req.session === "new") return fresh("the earlier one is gone, so this step was started again");
16867
17014
  const agent = agentForRun(req);
16868
17015
  const own = planRun(randomUUID5(), REPO_ROOT, agent, req.runtime ? { pin: req.runtime } : {});
@@ -17446,7 +17593,7 @@ var init_sessions = __esm({
17446
17593
  asksPathOf = (sessionId) => path52.join(SESSIONS_DIR, `${sessionId}.asks.json`);
17447
17594
  carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
17448
17595
  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");
17596
+ neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
17450
17597
  lacksSession = (r2) => neverStarted(r2) || !resumeIdOf(r2);
17451
17598
  carriesOn = (r2) => resumesUnder(r2.harness) || restartable(r2);
17452
17599
  CARDLESS = /* @__PURE__ */ new Set(["prune-memory", "review-memory", "review-dismissals", "describe-project"]);
@@ -17827,7 +17974,7 @@ function storyboardAttrs(raw) {
17827
17974
  const text5 = label ? (label[1] ?? label[2]).trim() : "";
17828
17975
  return { src: src[1] ?? src[2], ...text5 ? { label: text5 } : {} };
17829
17976
  }
17830
- function storyboardMarkers(body) {
17977
+ function storyboardMarkers(body, tagOf = storyboardTag) {
17831
17978
  const lines = body.replace(/\r\n/g, "\n").split("\n");
17832
17979
  const found2 = [];
17833
17980
  let fence = null;
@@ -17841,7 +17988,7 @@ function storyboardMarkers(body) {
17841
17988
  fence = delimiter[1];
17842
17989
  return;
17843
17990
  }
17844
- const src = storyboardTag(line);
17991
+ const src = tagOf(line);
17845
17992
  if (src !== null && !lines[i - 1]?.trim() && !lines[i + 1]?.trim()) found2.push({ src, line: i + 1 });
17846
17993
  });
17847
17994
  return found2;
@@ -17858,7 +18005,7 @@ function assetName(src, cardId2, exts, nested = false) {
17858
18005
  if (!name.includes(".") || !exts.includes(ext)) return { expected, actual: `file type ${JSON.stringify(name.includes(".") ? ext : "")}` };
17859
18006
  return { name };
17860
18007
  }
17861
- var TAG2, attr, SRC_ATTR, LABEL_ATTR, SEGMENT2, storyboardTag;
18008
+ var TAG2, attr, SRC_ATTR, LABEL_ATTR, SEGMENT2, storyboardTag, workflowTag;
17862
18009
  var init_storyboard = __esm({
17863
18010
  "../cli/src/lib/storyboard.ts"() {
17864
18011
  "use strict";
@@ -17868,12 +18015,492 @@ var init_storyboard = __esm({
17868
18015
  LABEL_ATTR = attr("label");
17869
18016
  SEGMENT2 = /^(?!\.)[^/\\]+$/;
17870
18017
  storyboardTag = (raw) => storyboardAttrs(raw)?.src ?? null;
18018
+ workflowTag = (raw) => {
18019
+ const m = /^<Workflow\b([^<>]*?)\/>$/.exec(raw.trim());
18020
+ const src = m ? SRC_ATTR.exec(m[1]) : null;
18021
+ return src ? src[1] ?? src[2] : null;
18022
+ };
17871
18023
  }
17872
18024
  });
17873
18025
 
17874
- // ../cli/src/lib/spec-contract.ts
18026
+ // ../artifact-sdk/src/builtin/compare.json
18027
+ var compare_default;
18028
+ var init_compare2 = __esm({
18029
+ "../artifact-sdk/src/builtin/compare.json"() {
18030
+ 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';
18031
+ }
18032
+ });
18033
+
18034
+ // ../artifact-sdk/src/builtin/html.json
18035
+ var html_default;
18036
+ var init_html = __esm({
18037
+ "../artifact-sdk/src/builtin/html.json"() {
18038
+ html_default = `{
18039
+ "name": "html",
18040
+ "title": { "en": "Page", "zh": "\u9875\u9762" },
18041
+ "types": ["html"],
18042
+ "references": [
18043
+ { "text": "<[a-z][^<>]*?\\\\ssrc\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
18044
+ { "text": "<[a-z][^<>]*?\\\\sposter\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
18045
+ { "text": "<[a-z][^<>]*?\\\\ssrcset\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']", "list": "," },
18046
+ { "text": "<link\\\\b[^<>]*?\\\\shref\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
18047
+ { "text": "url\\\\(\\\\s*[\\"']?([^\\"')]+?)[\\"']?\\\\s*\\\\)" }
18048
+ ]
18049
+ }
18050
+ `;
18051
+ }
18052
+ });
18053
+
18054
+ // ../artifact-sdk/src/builtin/image.json
18055
+ var image_default;
18056
+ var init_image = __esm({
18057
+ "../artifact-sdk/src/builtin/image.json"() {
18058
+ image_default = '{ "name": "image", "title": { "en": "Image", "zh": "\u56FE\u7247" }, "types": ["image"] }\n';
18059
+ }
18060
+ });
18061
+
18062
+ // ../artifact-sdk/src/builtin/markdown.json
18063
+ var markdown_default;
18064
+ var init_markdown = __esm({
18065
+ "../artifact-sdk/src/builtin/markdown.json"() {
18066
+ markdown_default = '{ "name": "markdown", "title": { "en": "Document", "zh": "\u6587\u6863" }, "types": ["markdown"] }\n';
18067
+ }
18068
+ });
18069
+
18070
+ // ../artifact-sdk/src/builtin/storyboard.json
18071
+ var storyboard_default;
18072
+ var init_storyboard2 = __esm({
18073
+ "../artifact-sdk/src/builtin/storyboard.json"() {
18074
+ 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';
18075
+ }
18076
+ });
18077
+
18078
+ // ../artifact-sdk/src/builtin/video.json
18079
+ var video_default;
18080
+ var init_video = __esm({
18081
+ "../artifact-sdk/src/builtin/video.json"() {
18082
+ video_default = '{ "name": "video", "title": { "en": "Video", "zh": "\u89C6\u9891" }, "types": ["video"] }\n';
18083
+ }
18084
+ });
18085
+
18086
+ // ../artifact-sdk/src/builtin/workflow.json
18087
+ var workflow_default;
18088
+ var init_workflow = __esm({
18089
+ "../artifact-sdk/src/builtin/workflow.json"() {
18090
+ 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';
18091
+ }
18092
+ });
18093
+
18094
+ // ../artifact-sdk/src/builtin/index.ts
18095
+ var read, builtin_default;
18096
+ var init_builtin = __esm({
18097
+ "../artifact-sdk/src/builtin/index.ts"() {
18098
+ "use strict";
18099
+ init_compare2();
18100
+ init_html();
18101
+ init_image();
18102
+ init_markdown();
18103
+ init_storyboard2();
18104
+ init_video();
18105
+ init_workflow();
18106
+ read = (m) => typeof m === "string" ? JSON.parse(m) : m;
18107
+ builtin_default = [html_default, image_default, video_default, markdown_default, storyboard_default, compare_default, workflow_default].map(read);
18108
+ }
18109
+ });
18110
+
18111
+ // ../artifact-sdk/src/internal/schema.ts
18112
+ function typeOk(type, v) {
18113
+ const types = Array.isArray(type) ? type : [type];
18114
+ return types.some(
18115
+ (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
18116
+ );
18117
+ }
18118
+ function schemaProblem(schema, value, at2 = "") {
18119
+ if (!isObj(schema)) return null;
18120
+ const s = schema;
18121
+ const here = at2 || "/";
18122
+ if (s.type !== void 0 && !typeOk(s.type, value)) return here;
18123
+ if (Array.isArray(s.enum) && !s.enum.some((e2) => JSON.stringify(e2) === JSON.stringify(value))) return here;
18124
+ if (s.const !== void 0 && JSON.stringify(s.const) !== JSON.stringify(value)) return here;
18125
+ if (Array.isArray(s.anyOf) && !s.anyOf.some((x2) => !schemaProblem(x2, value, at2))) return here;
18126
+ if (typeof value === "string") {
18127
+ if (typeof s.minLength === "number" && value.length < s.minLength) return here;
18128
+ if (typeof s.maxLength === "number" && value.length > s.maxLength) return here;
18129
+ if (typeof s.pattern === "string") {
18130
+ try {
18131
+ if (!new RegExp(s.pattern, "u").test(value)) return here;
18132
+ } catch {
18133
+ }
18134
+ }
18135
+ }
18136
+ if (typeof value === "number") {
18137
+ if (typeof s.minimum === "number" && value < s.minimum) return here;
18138
+ if (typeof s.maximum === "number" && value > s.maximum) return here;
18139
+ }
18140
+ if (Array.isArray(value)) {
18141
+ if (typeof s.minItems === "number" && value.length < s.minItems) return here;
18142
+ if (typeof s.maxItems === "number" && value.length > s.maxItems) return here;
18143
+ if (isObj(s.items)) {
18144
+ for (let i = 0; i < value.length; i++) {
18145
+ const bad = schemaProblem(s.items, value[i], `${at2}/${i}`);
18146
+ if (bad) return bad;
18147
+ }
18148
+ }
18149
+ }
18150
+ if (isObj(value)) {
18151
+ const props = isObj(s.properties) ? s.properties : {};
18152
+ if (Array.isArray(s.required)) {
18153
+ for (const k2 of s.required) if (typeof k2 === "string" && !(k2 in value)) return `${at2}/${k2}`;
18154
+ }
18155
+ for (const [k2, v] of Object.entries(value)) {
18156
+ if (k2 in props) {
18157
+ const bad = schemaProblem(props[k2], v, `${at2}/${k2}`);
18158
+ if (bad) return bad;
18159
+ } else if (s.additionalProperties === false) return `${at2}/${k2}`;
18160
+ else if (isObj(s.additionalProperties)) {
18161
+ const bad = schemaProblem(s.additionalProperties, v, `${at2}/${k2}`);
18162
+ if (bad) return bad;
18163
+ }
18164
+ }
18165
+ }
18166
+ return null;
18167
+ }
18168
+ var isObj;
18169
+ var init_schema = __esm({
18170
+ "../artifact-sdk/src/internal/schema.ts"() {
18171
+ "use strict";
18172
+ isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
18173
+ }
18174
+ });
18175
+
18176
+ // ../artifact-sdk/src/internal/manifest.ts
18177
+ function typeOf(data, types) {
18178
+ for (const type of types) if (!schemaProblem(manifestOf(type)?.schema, data)) return { type };
18179
+ if (types.length !== 1) return { type: null };
18180
+ return { type: types[0], problem: `does not match ${types[0]} at ${schemaProblem(manifestOf(types[0])?.schema, data)}` };
18181
+ }
18182
+ function mapJson(node, keys, at2, visit) {
18183
+ if (!keys.length) return typeof node === "string" && node ? visit(node, at2) : node;
18184
+ const [key, ...rest] = keys;
18185
+ if (Array.isArray(node)) {
18186
+ if (key === "*") return node.map((x2, i2) => mapJson(x2, rest, `${at2}/${i2}`, visit));
18187
+ const i = Number(key);
18188
+ return Number.isInteger(i) && i in node ? node.map((x2, j2) => j2 === i ? mapJson(x2, rest, `${at2}/${j2}`, visit) : x2) : node;
18189
+ }
18190
+ if (!isObject(node)) return node;
18191
+ const out = { ...node };
18192
+ for (const k2 of key === "*" ? Object.keys(node) : key in node ? [key] : []) out[k2] = mapJson(node[k2], rest, `${at2}/${k2}`, visit);
18193
+ return out;
18194
+ }
18195
+ function mapText(text5, rule, visit) {
18196
+ let out = "";
18197
+ let last = 0;
18198
+ for (const m of text5.matchAll(new RegExp(rule.text, "gid"))) {
18199
+ const span = m.indices?.[1];
18200
+ if (!span || m[1] === void 0) continue;
18201
+ const line = text5.slice(0, span[0]).split("\n").length;
18202
+ const one = (src) => remote(src) ? src : visit(src, line);
18203
+ 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]);
18204
+ out += text5.slice(last, span[0]) + value;
18205
+ last = span[1];
18206
+ }
18207
+ return out + text5.slice(last);
18208
+ }
18209
+ function mapReferences(manifest, content, map2) {
18210
+ for (const rule of manifest?.references ?? []) {
18211
+ const types = rule.types ?? [];
18212
+ if ("json" in rule) {
18213
+ if (typeof content !== "string") content = mapJson(content, rule.json.split("/").filter(Boolean), "", (src, at2) => map2(src, { src, types, text: false, at: at2 || "/" }));
18214
+ } else if (typeof content === "string") {
18215
+ content = mapText(content, rule, (src, line) => map2(src, { src, types, text: true, line }));
18216
+ }
18217
+ }
18218
+ return content;
18219
+ }
18220
+ function referencesOf(manifest, content) {
18221
+ const found2 = [];
18222
+ mapReferences(manifest, content, (src, ref) => (found2.push(ref), src));
18223
+ return found2;
18224
+ }
18225
+ var BUILTINS, manifestOf, isObject, remote;
18226
+ var init_manifest = __esm({
18227
+ "../artifact-sdk/src/internal/manifest.ts"() {
18228
+ "use strict";
18229
+ init_builtin();
18230
+ init_schema();
18231
+ BUILTINS = builtin_default;
18232
+ manifestOf = (type) => BUILTINS.find((m) => m.types.includes(type));
18233
+ isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
18234
+ remote = (src) => !src || /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src);
18235
+ }
18236
+ });
18237
+
18238
+ // ../artifact-sdk/src/internal/references.ts
18239
+ function bodyReferences(body) {
18240
+ const lines = body.replace(/<!--[^]*?-->/g, "").split(/\r?\n/);
18241
+ let fence = "";
18242
+ let inTag = false;
18243
+ const out = [];
18244
+ const visible = [];
18245
+ for (const line of lines) {
18246
+ const delimiter = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
18247
+ if (fence) {
18248
+ if (delimiter && delimiter[0] === fence[0] && delimiter.length >= fence.length) fence = "";
18249
+ visible.push("");
18250
+ continue;
18251
+ }
18252
+ if (delimiter) {
18253
+ fence = delimiter;
18254
+ visible.push("");
18255
+ continue;
18256
+ }
18257
+ const kept2 = inTag || !/^(?: {4}|\t)/.test(line);
18258
+ visible.push(kept2 ? line : "");
18259
+ if (kept2 && /^ {0,3}<(?:Asset|Mockup|Compare|Storyboard|Workflow)\b/.test(line)) inTag = true;
18260
+ if (line.includes("/>")) inTag = false;
18261
+ }
18262
+ const text5 = visible.join("\n").replace(/(`+)[^]*?\1/g, "");
18263
+ const tag = /<(Asset|Mockup|Compare|Storyboard|Workflow)\b([^<>]*?)\/>/g;
18264
+ const blocks = text5.matchAll(/^ {0,3}(?:<(?:Asset|Mockup|Compare|Storyboard|Workflow)\b[^<>]*?\/>[ \t]*(?:\n[ \t]*)?)+$/gm);
18265
+ for (const block of blocks) {
18266
+ const tags = [...block[0].matchAll(tag)];
18267
+ for (const m of tags) {
18268
+ const a2 = {};
18269
+ for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
18270
+ if (m[1] === "Compare") {
18271
+ if (!a2.a || !a2.b) continue;
18272
+ for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types: COMPARE });
18273
+ } else if (a2.src) {
18274
+ out.push({ src: a2.src, types: m[1] === "Storyboard" ? STORYBOARD : m[1] === "Workflow" ? WORKFLOW : [] });
18275
+ if (a2.variants) {
18276
+ try {
18277
+ const v = JSON.parse(a2.variants);
18278
+ if (isObject2(v)) {
18279
+ for (const src of Object.values(v)) if (typeof src === "string" && src) out.push({ src, types: [] });
18280
+ }
18281
+ } catch {
18282
+ }
18283
+ }
18284
+ }
18285
+ }
18286
+ }
18287
+ for (const m of text5.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1], types: [] });
18288
+ return out;
18289
+ }
18290
+ function kindOf(ext) {
18291
+ if (ext === ".tsx" || ext === ".html") return "html";
18292
+ if (ext === ".md" || ext === ".mdx") return "markdown";
18293
+ const type = TYPES[ext] ?? "";
18294
+ if (type.startsWith("image/")) return "image";
18295
+ return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
18296
+ }
18297
+ var STORYBOARD, WORKFLOW, COMPARE, isObject2, bodySources, TYPES;
18298
+ var init_references = __esm({
18299
+ "../artifact-sdk/src/internal/references.ts"() {
18300
+ "use strict";
18301
+ STORYBOARD = ["storyboard"];
18302
+ WORKFLOW = ["workflow"];
18303
+ COMPARE = ["storyboard", "compare"];
18304
+ isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
18305
+ bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
18306
+ TYPES = {
18307
+ ".png": "image/png",
18308
+ ".jpg": "image/jpeg",
18309
+ ".jpeg": "image/jpeg",
18310
+ ".gif": "image/gif",
18311
+ ".webp": "image/webp",
18312
+ ".svg": "image/svg+xml",
18313
+ ".mp4": "video/mp4",
18314
+ ".webm": "video/webm",
18315
+ ".mp3": "audio/mpeg",
18316
+ ".pdf": "application/pdf",
18317
+ ".html": "text/html",
18318
+ ".md": "text/markdown",
18319
+ ".mdx": "text/markdown",
18320
+ ".mov": "video/quicktime",
18321
+ ".wav": "audio/wav",
18322
+ ".m4a": "audio/mp4",
18323
+ ".json": "application/json",
18324
+ ".txt": "text/plain",
18325
+ ".otf": "font/otf",
18326
+ ".ttf": "font/ttf",
18327
+ ".woff": "font/woff",
18328
+ ".woff2": "font/woff2",
18329
+ ".css": "text/css"
18330
+ };
18331
+ }
18332
+ });
18333
+
18334
+ // ../artifact-sdk/src/internal/collect.ts
18335
+ function collect(body, card, host2) {
18336
+ const nodes = /* @__PURE__ */ new Map();
18337
+ const active2 = /* @__PURE__ */ new Set();
18338
+ const out = [];
18339
+ const visit = (src, types, owner) => {
18340
+ const path90 = src.replace(/[?#].*$/, "");
18341
+ let resolved2;
18342
+ try {
18343
+ resolved2 = host2.resolve(path90, owner);
18344
+ } catch (error) {
18345
+ if (owner !== card) return { key: null, error: why(error) };
18346
+ if (!nodes.has(src)) {
18347
+ const node2 = { key: src, file: null, kind: kindAt(path90, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18348
+ nodes.set(src, node2);
18349
+ out.push(node2);
18350
+ }
18351
+ return { key: src, error: nodes.get(src).error };
18352
+ }
18353
+ if (!resolved2) return { key: null };
18354
+ const { key, file } = resolved2;
18355
+ if (active2.has(key)) throw new Error(`${owner}: ${src}: \u8D44\u6E90\u4F9D\u8D56\u5FAA\u73AF`);
18356
+ const json = !!file && extOf(file) === ".json";
18357
+ const held4 = nodes.get(key);
18358
+ if (held4) {
18359
+ if (owner === card) held4.aliases.add(src);
18360
+ if (held4.error || !json || !types.length || held4.kind !== "asset") return { key, error: held4.error };
18361
+ out.splice(out.indexOf(held4), 1);
18362
+ }
18363
+ const node = { key, file, kind: "asset", problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: held4?.aliases ?? /* @__PURE__ */ new Set([key]) };
18364
+ if (owner === card) node.aliases.add(src);
18365
+ nodes.set(key, node);
18366
+ active2.add(key);
18367
+ const child = (ref, from) => {
18368
+ const found2 = visit(ref.src, ref.types, from);
18369
+ if (found2.key) node.dependencies.set(ref.src, found2.key);
18370
+ 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 });
18371
+ node.error ??= found2.error;
18372
+ };
18373
+ if (file) {
18374
+ if (json) {
18375
+ try {
18376
+ node.data = JSON.parse(host2.read(file));
18377
+ const typed = typeOf(node.data, types);
18378
+ node.kind = typed.type ?? "asset";
18379
+ if (typed.problem) node.problems.push({ src: file, message: `${typed.problem}: ${file}` });
18380
+ } catch {
18381
+ node.problems.push({ src: file, message: `not valid JSON: ${file}` });
18382
+ }
18383
+ } else {
18384
+ node.kind = kindOf(extOf(file));
18385
+ try {
18386
+ if (manifestOf(node.kind)?.references) node.data = host2.read(file);
18387
+ } catch (error) {
18388
+ node.problems.push({ src: file, message: why(error) });
18389
+ }
18390
+ }
18391
+ node.error = node.problems[0]?.message;
18392
+ if (!node.error) for (const ref of referencesOf(manifestOf(node.kind), node.data)) child(ref, file);
18393
+ } else {
18394
+ for (const ref of host2.retained(key)) child(ref, card);
18395
+ }
18396
+ active2.delete(key);
18397
+ out.push(node);
18398
+ return { key, error: node.error };
18399
+ };
18400
+ for (const ref of bodyReferences(body)) visit(ref.src, ref.types, card);
18401
+ const sorted = [];
18402
+ const done2 = /* @__PURE__ */ new Set();
18403
+ const order = (node) => {
18404
+ if (done2.has(node.key)) return;
18405
+ done2.add(node.key);
18406
+ for (const key of node.dependencies.values()) {
18407
+ const child = nodes.get(key);
18408
+ if (child) order(child);
18409
+ }
18410
+ sorted.push(node);
18411
+ };
18412
+ for (const node of out) order(node);
18413
+ return sorted;
18414
+ }
18415
+ var extOf, why, kindAt;
18416
+ var init_collect = __esm({
18417
+ "../artifact-sdk/src/internal/collect.ts"() {
18418
+ "use strict";
18419
+ init_manifest();
18420
+ init_references();
18421
+ extOf = (file) => /\.[^./\\]+$/.exec(file)?.[0].toLowerCase() ?? "";
18422
+ why = (error) => error instanceof Error ? error.message : String(error);
18423
+ kindAt = (src, types) => extOf(src) === ".json" ? types[0] ?? "asset" : kindOf(extOf(src));
18424
+ }
18425
+ });
18426
+
18427
+ // ../cli/src/lib/dress-page.ts
17875
18428
  import fs51 from "node:fs";
17876
18429
  import path54 from "node:path";
18430
+ function dressPage(file) {
18431
+ const folder = path54.dirname(file);
18432
+ const html = fs51.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
18433
+ const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
18434
+ if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
18435
+ const at3 = path54.resolve(folder, href);
18436
+ if (!at3.startsWith(folder + path54.sep) || !fs51.existsSync(at3)) return tag;
18437
+ 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})`);
18438
+ return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
18439
+ });
18440
+ const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
18441
+ 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>`;
18442
+ }
18443
+ var CSP, head, referenceText;
18444
+ var init_dress_page = __esm({
18445
+ "../cli/src/lib/dress-page.ts"() {
18446
+ "use strict";
18447
+ 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'";
18448
+ 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>`;
18449
+ referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs51.readFileSync(file, "utf8");
18450
+ }
18451
+ });
18452
+
18453
+ // ../cli/src/lib/preview-files.ts
18454
+ import fs52 from "node:fs";
18455
+ import path55 from "node:path";
18456
+ function resolver(card, id) {
18457
+ const roots = [KANBAN, path55.join(ASSETS, String(id)), path55.join(MOCKUPS, String(id))];
18458
+ const real2 = (p2) => fs52.existsSync(p2) ? fs52.realpathSync(p2) : p2;
18459
+ const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path55.sep));
18460
+ return (src, owner) => {
18461
+ if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
18462
+ if (path55.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
18463
+ const held4 = /^\.(assets|mockups)\//.exec(src);
18464
+ const file = held4 ? path55.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path55.resolve(path55.dirname(owner), src);
18465
+ if (!inside2(path55.resolve(file)) || fs52.existsSync(file) && !inside2(fs52.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
18466
+ if (!fs52.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
18467
+ return { key: fs52.realpathSync(file), file };
18468
+ };
18469
+ }
18470
+ function validatePreviewFiles(card, id, text5) {
18471
+ const resolve2 = resolver(card, id);
18472
+ const errors = [];
18473
+ const graph = collect(text5, card, {
18474
+ resolve: (src, owner) => {
18475
+ if (owner !== card) return resolve2(src, owner);
18476
+ try {
18477
+ return resolve2(src, owner);
18478
+ } catch {
18479
+ return null;
18480
+ }
18481
+ },
18482
+ read: referenceText,
18483
+ retained: () => []
18484
+ });
18485
+ for (const node of graph) {
18486
+ for (const p2 of node.problems) {
18487
+ 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.` });
18488
+ }
18489
+ }
18490
+ return errors;
18491
+ }
18492
+ var init_preview_files = __esm({
18493
+ "../cli/src/lib/preview-files.ts"() {
18494
+ "use strict";
18495
+ init_collect();
18496
+ init_dress_page();
18497
+ init_paths();
18498
+ }
18499
+ });
18500
+
18501
+ // ../cli/src/lib/spec-contract.ts
18502
+ import fs53 from "node:fs";
18503
+ import path56 from "node:path";
17877
18504
  function scanCardLines(lines, start = 0) {
17878
18505
  const visible = lines.map(() => "");
17879
18506
  let fence = null;
@@ -17906,18 +18533,18 @@ function scanCardLines(lines, start = 0) {
17906
18533
  }
17907
18534
  function snapshotSpecs() {
17908
18535
  const out = /* @__PURE__ */ new Map();
17909
- if (!fs51.existsSync(TODO)) return out;
18536
+ if (!fs53.existsSync(TODO)) return out;
17910
18537
  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") });
18538
+ if (isLegacyRecurring(path56.relative(TODO, file))) continue;
18539
+ const id = idPrefix(path56.basename(file) === "root.md" ? path56.basename(path56.dirname(file)) : path56.basename(file));
18540
+ if (id !== null) out.set(file, { id, text: fs53.readFileSync(file, "utf8") });
17914
18541
  }
17915
18542
  return out;
17916
18543
  }
17917
18544
  function enclosingGroups(file) {
17918
18545
  const ids = [];
17919
18546
  for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
17920
- const id = idPrefix(path54.basename(path54.dirname(root2)));
18547
+ const id = idPrefix(path56.basename(path56.dirname(root2)));
17921
18548
  if (id !== null) ids.push(id);
17922
18549
  }
17923
18550
  return ids;
@@ -18015,8 +18642,8 @@ function validateSpec(file, text5, id) {
18015
18642
  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
18643
  const src = line.match(/\bsrc="([^"]*)"/)?.[1] ?? "";
18017
18644
  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);
18645
+ const why2 = variants === void 0 ? null : variantsProblem(variants, src, id);
18646
+ if (why2) add(i + 1, "mockup-variants", why2);
18020
18647
  else if (id !== void 0 && src.startsWith(".assets/") && !inside(ASSETS, src.slice(".assets/".length))) {
18021
18648
  add(i + 1, "asset-src", `src="${src}" names no file. Write it as ${rel(ASSETS)}/${src.slice(".assets/".length)}, or fix the path.`);
18022
18649
  }
@@ -18024,13 +18651,16 @@ function validateSpec(file, text5, id) {
18024
18651
  if (/^\s*<Storyboard\b/.test(line) && (storyboardTag(line) === null || lines[i - 1]?.trim() || lines[i + 1]?.trim())) {
18025
18652
  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
18653
  }
18654
+ if (/^\s*<Workflow\b/.test(line) && (workflowTag(line) === null || !/\blabel="[^"]+"/.test(line) || lines[i - 1]?.trim() || lines[i + 1]?.trim())) {
18655
+ 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.');
18656
+ }
18027
18657
  if (/^\s*<Compare\b/.test(line)) {
18028
18658
  const attrs = compareAttrs(line);
18029
18659
  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
18660
  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
18661
  else if (id !== void 0) {
18032
- const why = compareProblem(attrs, id);
18033
- if (why) add(i + 1, why.rule, why.message);
18662
+ const why2 = compareProblem(attrs, id);
18663
+ if (why2) add(i + 1, why2.rule, why2.message);
18034
18664
  }
18035
18665
  }
18036
18666
  }
@@ -18067,14 +18697,14 @@ function validateSpec(file, text5, id) {
18067
18697
  const next = headings.find((h3) => h3.line > todo.line)?.line ?? lines.length + 1;
18068
18698
  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
18699
  }
18070
- if (id !== void 0) errors.push(...validateStoryboards(file, id, text5));
18700
+ if (id !== void 0) errors.push(...validateStoryboards(file, id, text5), ...validatePreviewFiles(file, id, text5));
18071
18701
  return errors;
18072
18702
  }
18073
18703
  function inside(dir, name) {
18074
18704
  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;
18705
+ const root2 = fs53.realpathSync(dir);
18706
+ const real2 = fs53.realpathSync(path56.join(dir, name));
18707
+ return real2.startsWith(root2 + path56.sep) && fs53.statSync(real2).isFile() ? real2 : null;
18078
18708
  } catch {
18079
18709
  return null;
18080
18710
  }
@@ -18092,7 +18722,7 @@ function variantsProblem(raw, src, id) {
18092
18722
  if (files2.length < 2 || !files2.every((f2) => typeof f2 === "string" && f2)) return `variants needs at least two labels, each naming a file. ${shape}`;
18093
18723
  if (!files2.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
18094
18724
  if (id === void 0) return null;
18095
- const dir = path54.join(ASSETS, String(id));
18725
+ const dir = path56.join(ASSETS, String(id));
18096
18726
  for (const f2 of files2) {
18097
18727
  const parts = f2.split("/");
18098
18728
  if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
@@ -18102,7 +18732,7 @@ function variantsProblem(raw, src, id) {
18102
18732
  return null;
18103
18733
  }
18104
18734
  function compareProblem(attrs, id) {
18105
- const dir = path54.join(ASSETS, String(id));
18735
+ const dir = path56.join(ASSETS, String(id));
18106
18736
  const src = (message) => ({ rule: "compare-src", message });
18107
18737
  const shots = (message) => ({ rule: "compare-shots", message });
18108
18738
  for (const side of ["a", "b"]) {
@@ -18116,23 +18746,23 @@ function compareProblem(attrs, id) {
18116
18746
  if (!script && kind !== compareKind(attrs.b)) return src("Compare a and b must both be images or both be videos.");
18117
18747
  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
18748
  if (kind !== "video") return shots("shots is for videos only. Remove it from this Compare tag.");
18119
- const read4 = (at2) => {
18749
+ const read5 = (at2) => {
18120
18750
  const named2 = assetName(at2, id, ["json"]);
18121
18751
  if (!("name" in named2)) return { message: `Compare shots is ${named2.actual}; expected ${named2.expected}.` };
18122
18752
  const file = inside(dir, named2.name);
18123
18753
  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
18754
  try {
18125
- return { data: JSON.parse(fs51.readFileSync(file, "utf8")) };
18755
+ return { data: JSON.parse(fs53.readFileSync(file, "utf8")) };
18126
18756
  } catch {
18127
18757
  return { message: `${at2} is not valid JSON.` };
18128
18758
  }
18129
18759
  };
18130
- const list = read4(attrs.shots);
18760
+ const list = read5(attrs.shots);
18131
18761
  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}`);
18762
+ const why2 = Array.isArray(list.data) ? shotsProblem(list.data) : storyboardProblem(list.data);
18763
+ if (why2) return shots(`${attrs.shots}: ${why2}`);
18134
18764
  if (!script) return null;
18135
- const b2 = read4(attrs.b);
18765
+ const b2 = read5(attrs.b);
18136
18766
  if ("message" in b2) return src(b2.message);
18137
18767
  const bad = storyboardProblem(b2.data);
18138
18768
  if (bad) return src(`${attrs.b}: ${bad}`);
@@ -18142,12 +18772,17 @@ function compareProblem(attrs, id) {
18142
18772
  }
18143
18773
  function validateStoryboards(file, id, text5) {
18144
18774
  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.`);
18775
+ const dir = path56.join(ASSETS, String(id));
18776
+ for (const [tag, tagOf, rule, fix] of [
18777
+ ["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
18778
+ ["Workflow", workflowTag, "workflow-src", "Write it with `akb workflow diagram <workflow id> <card id>` or fix the path."]
18779
+ ]) {
18780
+ for (const marker of storyboardMarkers(text5, tagOf)) {
18781
+ const named2 = assetName(marker.src, id, ["json"]);
18782
+ const add = (message) => errors.push({ file: rel(file), line: marker.line, rule, message });
18783
+ if (!("name" in named2)) add(`${tag} src is ${named2.actual}; expected ${named2.expected}.`);
18784
+ else if (!inside(dir, named2.name)) add(`${tag} src ${marker.src} names no file in this card's asset folder. ${fix}`);
18785
+ }
18151
18786
  }
18152
18787
  return errors;
18153
18788
  }
@@ -18208,19 +18843,20 @@ var init_spec_contract = __esm({
18208
18843
  init_paths();
18209
18844
  init_compare();
18210
18845
  init_storyboard();
18846
+ init_preview_files();
18211
18847
  init_validate();
18212
18848
  }
18213
18849
  });
18214
18850
 
18215
18851
  // ../cli/src/lib/reconcile.ts
18216
- import fs52 from "node:fs";
18217
- import path55 from "node:path";
18852
+ import fs54 from "node:fs";
18853
+ import path57 from "node:path";
18218
18854
  function liveIds() {
18219
18855
  const ids = /* @__PURE__ */ new Set();
18220
18856
  for (const file of walkMd(TODO)) {
18221
- const base = path55.basename(file);
18857
+ const base = path57.basename(file);
18222
18858
  if (base === "README.md") continue;
18223
- const id = base === "root.md" ? idPrefix(path55.basename(path55.dirname(file))) : idPrefix(base);
18859
+ const id = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
18224
18860
  if (id != null) ids.add(id);
18225
18861
  }
18226
18862
  return ids;
@@ -18228,16 +18864,16 @@ function liveIds() {
18228
18864
  function indexableCards() {
18229
18865
  const out = [];
18230
18866
  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("/") });
18867
+ const id = idPrefix(path57.basename(dir));
18868
+ if (id != null && fs54.existsSync(path57.join(dir, "root.md"))) {
18869
+ out.push({ id, rel: path57.join(path57.relative(TODO, dir), "root.md").split(path57.sep).join("/") });
18234
18870
  }
18235
18871
  }
18236
18872
  for (const file of walkMd(TODO)) {
18237
- const base = path55.basename(file);
18873
+ const base = path57.basename(file);
18238
18874
  if (base === "README.md" || base === "root.md") continue;
18239
- const relTODO = path55.relative(TODO, file);
18240
- const segs = relTODO.split(path55.sep);
18875
+ const relTODO = path57.relative(TODO, file);
18876
+ const segs = relTODO.split(path57.sep);
18241
18877
  if (segs.length !== 1) continue;
18242
18878
  const id = idPrefix(base);
18243
18879
  if (id != null) out.push({ id, rel: segs.join("/") });
@@ -18246,7 +18882,7 @@ function indexableCards() {
18246
18882
  }
18247
18883
  function readmeComplaints(fix) {
18248
18884
  const said3 = [];
18249
- const lines = fs52.readFileSync(README, "utf8").split("\n");
18885
+ const lines = fs54.readFileSync(README, "utf8").split("\n");
18250
18886
  const indexed = /* @__PURE__ */ new Set();
18251
18887
  let fixed = 0;
18252
18888
  for (let i = 0; i < lines.length; i++) {
@@ -18255,13 +18891,13 @@ function readmeComplaints(fix) {
18255
18891
  const id = Number(m[1]);
18256
18892
  const linkPath = m[2];
18257
18893
  indexed.add(id);
18258
- if (fs52.existsSync(path55.join(TODO, linkPath))) continue;
18894
+ if (fs54.existsSync(path57.join(TODO, linkPath))) continue;
18259
18895
  const found2 = locate(id);
18260
18896
  if (!found2) {
18261
18897
  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
18898
  continue;
18263
18899
  }
18264
- const want = (found2.kind === "group" ? path55.join(found2.rel, "root.md") : found2.rel).split(path55.sep).join("/");
18900
+ const want = (found2.kind === "group" ? path57.join(found2.rel, "root.md") : found2.rel).split(path57.sep).join("/");
18265
18901
  if (want === linkPath) continue;
18266
18902
  if (!fix) {
18267
18903
  said3.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
@@ -18271,7 +18907,7 @@ function readmeComplaints(fix) {
18271
18907
  said3.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
18272
18908
  fixed++;
18273
18909
  }
18274
- if (fixed) fs52.writeFileSync(README, lines.join("\n"));
18910
+ if (fixed) fs54.writeFileSync(README, lines.join("\n"));
18275
18911
  for (const c2 of indexableCards()) {
18276
18912
  if (!indexed.has(c2.id)) {
18277
18913
  said3.push(`card ${c2.rel} (#${c2.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
@@ -18283,11 +18919,11 @@ function crossRefComplaints() {
18283
18919
  const said3 = [];
18284
18920
  const live = liveIds();
18285
18921
  for (const file of walkMd(TODO)) {
18286
- const base = path55.basename(file);
18922
+ const base = path57.basename(file);
18287
18923
  if (base === "README.md") continue;
18288
- const ownerId = base === "root.md" ? idPrefix(path55.basename(path55.dirname(file))) : idPrefix(base);
18924
+ const ownerId = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
18289
18925
  if (ownerId == null) continue;
18290
- const { meta } = parseFrontmatter(fs52.readFileSync(file, "utf8"));
18926
+ const { meta } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
18291
18927
  if (!meta) continue;
18292
18928
  for (const field2 of ["blocked_by", "related"]) {
18293
18929
  for (const ref of meta[field2] || []) {
@@ -18300,11 +18936,11 @@ function crossRefComplaints() {
18300
18936
  return said3;
18301
18937
  }
18302
18938
  function reconcileBoard() {
18303
- if (!fs52.existsSync(README)) return;
18939
+ if (!fs54.existsSync(README)) return;
18304
18940
  for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
18305
18941
  }
18306
18942
  function boardComplaints() {
18307
- if (!fs52.existsSync(README)) return [];
18943
+ if (!fs54.existsSync(README)) return [];
18308
18944
  try {
18309
18945
  return [...readmeComplaints(false), ...crossRefComplaints()];
18310
18946
  } catch {
@@ -18324,8 +18960,8 @@ var init_reconcile = __esm({
18324
18960
  });
18325
18961
 
18326
18962
  // ../cli/src/commands/card.ts
18327
- import fs53 from "node:fs";
18328
- import path56 from "node:path";
18963
+ import fs55 from "node:fs";
18964
+ import path58 from "node:path";
18329
18965
  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
18966
  return [
18331
18967
  summary,
@@ -18351,7 +18987,7 @@ function bodyFromFile(opts) {
18351
18987
  if (opts.body === false) die("pass --body-file or --no-body, not both");
18352
18988
  let text5;
18353
18989
  try {
18354
- text5 = fs53.readFileSync(opts.bodyFile, "utf8");
18990
+ text5 = fs55.readFileSync(opts.bodyFile, "utf8");
18355
18991
  } catch {
18356
18992
  die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
18357
18993
  }
@@ -18431,20 +19067,20 @@ function cmdCreate(opts) {
18431
19067
  const start = opts.id;
18432
19068
  const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
18433
19069
  const fileRel = `${start}-${slug2}.md`;
18434
- const file = path56.join(TODO, fileRel);
19070
+ const file = path58.join(TODO, fileRel);
18435
19071
  const held4 = locate(start) ?? locateArchived(start);
18436
- if (held4 && path56.basename(held4.target) === `${start}-${slug2}.md`) {
19072
+ if (held4 && path58.basename(held4.target) === `${start}-${slug2}.md`) {
18437
19073
  say(start);
18438
19074
  say(` ${rel(held4.target)} was already written`);
18439
19075
  return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
18440
19076
  }
18441
19077
  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`);
19078
+ if (fs55.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
18443
19079
  countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
18444
19080
  const meta = { title, priority, status: "todo", blocked_by, related, modules, workflow, previews, stages, triage, source, questions };
18445
19081
  const scaffolded = !written && opts.body !== false;
18446
19082
  const body = written ?? (scaffolded ? defaultBody() : "");
18447
- fs53.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
19083
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
18448
19084
  const indexed = addReadmeRef(start, title, fileRel);
18449
19085
  say(start);
18450
19086
  say(
@@ -18491,8 +19127,8 @@ function cmdUpdate(id, flags) {
18491
19127
  if (creating) die(creating, { kind: "card-being-created", id });
18492
19128
  const found2 = locate(id);
18493
19129
  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"));
19130
+ const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
19131
+ const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
18496
19132
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
18497
19133
  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
19134
  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 +19202,26 @@ function cmdUpdate(id, flags) {
18566
19202
  meta.status = "todo";
18567
19203
  changes.push("status\u2192todo (open questions)");
18568
19204
  }
18569
- const curRel = path56.relative(TODO, file);
19205
+ const curRel = path58.relative(TODO, file);
18570
19206
  const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
18571
- let base = path56.basename(file);
19207
+ let base = path58.basename(file);
18572
19208
  if (flags.slug !== void 0) {
18573
19209
  if (found2.kind === "group") die("renaming a group root by script is not supported");
18574
19210
  base = `${id}-${slugify(flags.slug)}.md`;
18575
19211
  }
18576
- const destRel = path56.join(path56.dirname(curRel), base);
18577
- const dest = path56.join(TODO, destRel);
19212
+ const destRel = path58.join(path58.dirname(curRel), base);
19213
+ const dest = path58.join(TODO, destRel);
18578
19214
  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);
19215
+ if (moving && fs55.existsSync(dest)) die(`${rel(dest)} already exists`);
19216
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19217
+ if (moving) fs55.renameSync(file, dest);
18582
19218
  if (isSubtask) {
18583
19219
  if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
18584
- if (moving) changes.push(`renamed \u2192 ${destRel.split(path56.sep).join("/")}`);
19220
+ if (moving) changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
18585
19221
  } else if (moving) {
18586
19222
  stripReadmeRefs({ kind: "file", rel: curRel });
18587
19223
  addReadmeRef(id, meta.title, destRel);
18588
- changes.push(`renamed \u2192 ${destRel.split(path56.sep).join("/")}`);
19224
+ changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
18589
19225
  } else if (changes.includes("title")) {
18590
19226
  stripReadmeRefs({ kind: "file", rel: curRel });
18591
19227
  addReadmeRef(id, meta.title, curRel);
@@ -18597,8 +19233,8 @@ function cmdUpdateQuestions(id, input) {
18597
19233
  const ops = readQuestionOps(input.ops ?? []);
18598
19234
  const found2 = locate(id);
18599
19235
  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"));
19236
+ const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
19237
+ const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
18602
19238
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
18603
19239
  if (insideRun() && ops.some((op) => op.kind === "skip" || op.kind === "unskip")) {
18604
19240
  die("only the user skips or reopens a question \u2014 a run leaves questions for them to answer");
@@ -18671,7 +19307,7 @@ function cmdUpdateQuestions(id, input) {
18671
19307
  meta.status = "todo";
18672
19308
  changes.push("status\u2192todo (open questions)");
18673
19309
  }
18674
- fs53.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19310
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
18675
19311
  for (const kind of closed2) countBoardEvent(kind);
18676
19312
  settleDelivery2(id, skipped, unskipped);
18677
19313
  say(
@@ -18746,13 +19382,13 @@ var init_config_template = __esm({
18746
19382
  });
18747
19383
 
18748
19384
  // ../cli/src/lib/agent/local.ts
18749
- import fs54 from "node:fs";
18750
- import path57 from "node:path";
19385
+ import fs56 from "node:fs";
19386
+ import path59 from "node:path";
18751
19387
  function takeLocalModels(board2) {
18752
- const file = path57.join(board2, ".local.json");
19388
+ const file = path59.join(board2, ".local.json");
18753
19389
  let held4;
18754
19390
  try {
18755
- held4 = configBlock(JSON.parse(fs54.readFileSync(file, "utf8")));
19391
+ held4 = configBlock(JSON.parse(fs56.readFileSync(file, "utf8")));
18756
19392
  } catch {
18757
19393
  return {};
18758
19394
  }
@@ -18770,7 +19406,7 @@ function takeLocalModels(board2) {
18770
19406
  }
18771
19407
  if (!Object.keys(agents).length) return out;
18772
19408
  delete held4.agents;
18773
- fs54.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19409
+ fs56.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
18774
19410
  return out;
18775
19411
  }
18776
19412
  var LOCAL_IGNORE_LINE;
@@ -18831,12 +19467,12 @@ var init_identity2 = __esm({
18831
19467
  });
18832
19468
 
18833
19469
  // ../cli/src/lib/signals/migrate.ts
18834
- import fs55 from "node:fs";
18835
- import path58 from "node:path";
19470
+ import fs57 from "node:fs";
19471
+ import path60 from "node:path";
18836
19472
  function readHandled() {
18837
19473
  let text5;
18838
19474
  try {
18839
- text5 = fs55.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19475
+ text5 = fs57.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
18840
19476
  } catch {
18841
19477
  return [];
18842
19478
  }
@@ -18853,57 +19489,57 @@ function readHandled() {
18853
19489
  return held4;
18854
19490
  }
18855
19491
  function lift(from, into) {
18856
- fs55.mkdirSync(into, { recursive: true });
18857
- fs55.renameSync(from, path58.join(into, freeName(into, path58.basename(from))));
19492
+ fs57.mkdirSync(into, { recursive: true });
19493
+ fs57.renameSync(from, path60.join(into, freeName(into, path60.basename(from))));
18858
19494
  }
18859
19495
  function repoint(dir, from, into) {
18860
19496
  let entries;
18861
19497
  try {
18862
- entries = fs55.readdirSync(dir, { withFileTypes: true });
19498
+ entries = fs57.readdirSync(dir, { withFileTypes: true });
18863
19499
  } catch {
18864
19500
  return;
18865
19501
  }
18866
19502
  for (const entry of entries) {
18867
19503
  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));
19504
+ const file = path60.join(dir, entry.name);
19505
+ const text5 = fs57.readFileSync(file, "utf8");
19506
+ if (text5.includes(from)) fs57.writeFileSync(file, text5.split(from).join(into));
18871
19507
  }
18872
19508
  }
18873
19509
  function dropIfEmpty2(dir) {
18874
19510
  try {
18875
- fs55.rmdirSync(dir);
19511
+ fs57.rmdirSync(dir);
18876
19512
  } catch {
18877
19513
  }
18878
19514
  }
18879
19515
  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);
19516
+ if (!fs57.existsSync(SIGNALS_OLD_INBOX)) return;
19517
+ const oldFiles = path60.join(SIGNALS_OLD_INBOX, "files");
19518
+ if (fs57.existsSync(oldFiles)) {
19519
+ for (const entry of fs57.readdirSync(oldFiles, { withFileTypes: true })) {
19520
+ if (entry.isFile()) lift(path60.join(oldFiles, entry.name), SIGNALS_FILES);
18885
19521
  }
18886
19522
  dropIfEmpty2(oldFiles);
18887
19523
  }
18888
19524
  const held4 = new Set(readFolder(TRIAGE).map((signal2) => signal2.sourceId));
18889
- for (const entry of fs55.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19525
+ for (const entry of fs57.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
18890
19526
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
18891
- const from = path58.join(SIGNALS_OLD_INBOX, entry.name);
19527
+ const from = path60.join(SIGNALS_OLD_INBOX, entry.name);
18892
19528
  const item = parse(from);
18893
19529
  if (item && held4.has(item.sourceId)) {
18894
- fs55.rmSync(from, { force: true });
19530
+ fs57.rmSync(from, { force: true });
18895
19531
  continue;
18896
19532
  }
18897
19533
  if (item) held4.add(item.sourceId);
18898
19534
  lift(from, TRIAGE);
18899
19535
  }
18900
- const wasAt = asWritten(path58.join(SIGNALS_OLD_INBOX, "files"));
19536
+ const wasAt = asWritten(path60.join(SIGNALS_OLD_INBOX, "files"));
18901
19537
  const nowAt = asWritten(SIGNALS_FILES);
18902
19538
  for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
18903
19539
  dropIfEmpty2(SIGNALS_OLD_INBOX);
18904
19540
  }
18905
19541
  function liftHandled() {
18906
- if (!fs55.existsSync(SIGNALS_OLD_HANDLED)) return;
19542
+ if (!fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
18907
19543
  const lines = readHandled();
18908
19544
  const held4 = /* @__PURE__ */ new Set([
18909
19545
  ...readFolder(TRIAGE).map((signal2) => signal2.sourceId),
@@ -18913,7 +19549,7 @@ function liftHandled() {
18913
19549
  for (const { sourceId, when } of lines) {
18914
19550
  if (held4.has(sourceId)) continue;
18915
19551
  held4.add(sourceId);
18916
- fs55.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19552
+ fs57.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
18917
19553
  const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
18918
19554
  const front = [
18919
19555
  "---",
@@ -18923,13 +19559,13 @@ function liftHandled() {
18923
19559
  "---",
18924
19560
  ""
18925
19561
  ];
18926
- fs55.writeFileSync(path58.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19562
+ fs57.writeFileSync(path60.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
18927
19563
  `);
18928
19564
  }
18929
- fs55.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19565
+ fs57.rmSync(SIGNALS_OLD_HANDLED, { force: true });
18930
19566
  }
18931
19567
  function migrateTriage() {
18932
- if (!fs55.existsSync(SIGNALS_OLD_INBOX) && !fs55.existsSync(SIGNALS_OLD_HANDLED)) return;
19568
+ if (!fs57.existsSync(SIGNALS_OLD_INBOX) && !fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
18933
19569
  try {
18934
19570
  liftInbox();
18935
19571
  liftHandled();
@@ -18944,13 +19580,13 @@ var init_migrate = __esm({
18944
19580
  init_yaml();
18945
19581
  init_inbox();
18946
19582
  HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
18947
- asWritten = (dir) => `${rel(dir).split(path58.sep).join("/")}/`;
19583
+ asWritten = (dir) => `${rel(dir).split(path60.sep).join("/")}/`;
18948
19584
  }
18949
19585
  });
18950
19586
 
18951
19587
  // ../cli/src/lib/signals/add.ts
18952
- import fs56 from "node:fs";
18953
- import path59 from "node:path";
19588
+ import fs58 from "node:fs";
19589
+ import path61 from "node:path";
18954
19590
  import { createHash as createHash4 } from "node:crypto";
18955
19591
  function linkTitle(url) {
18956
19592
  let at2;
@@ -18963,7 +19599,7 @@ function linkTitle(url) {
18963
19599
  return oneLine(where) || url.slice(0, TITLE_MAX);
18964
19600
  }
18965
19601
  function asText(file) {
18966
- const ext = path59.extname(file.name).toLowerCase();
19602
+ const ext = path61.extname(file.name).toLowerCase();
18967
19603
  if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
18968
19604
  try {
18969
19605
  const text5 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
@@ -18973,9 +19609,9 @@ function asText(file) {
18973
19609
  }
18974
19610
  }
18975
19611
  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";
19612
+ const base = path61.basename(name);
19613
+ const ext = path61.extname(base).toLowerCase().slice(0, 12);
19614
+ const word = path61.basename(base, path61.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
18979
19615
  const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
18980
19616
  return `${word}-${hash2}${ext}`;
18981
19617
  }
@@ -18984,20 +19620,20 @@ function addToInbox(drop) {
18984
19620
  const typed = (drop.text ?? "").trim();
18985
19621
  const file = drop.file;
18986
19622
  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.` };
19623
+ if (file && file.data.length === 0) return { ok: false, error: `${path61.basename(file.name)} is empty.` };
18988
19624
  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.` };
19625
+ return { ok: false, error: `${path61.basename(file.name)} is over ${MAX_BYTES / 1024 / 1024} MB \u2014 too big for the board.` };
18990
19626
  }
18991
- const read4 = describe(typed, file);
18992
- const keep2 = read4.keep;
19627
+ const read5 = describe(typed, file);
19628
+ const keep2 = read5.keep;
18993
19629
  const said3 = drop.source?.trim() ?? "";
18994
19630
  const hit = said3 ? matchSourceType(said3) : "";
18995
19631
  const kept2 = said3 && !hit ? metaPair("source", said3) : null;
18996
19632
  const incoming = {
18997
- ...read4.incoming,
19633
+ ...read5.incoming,
18998
19634
  ...drop.title?.trim() ? { title: oneLine(drop.title) } : {},
18999
19635
  ...hit ? { sourceType: hit } : {},
19000
- ...kept2 ? { meta: [kept2, ...read4.incoming.meta] } : {},
19636
+ ...kept2 ? { meta: [kept2, ...read5.incoming.meta] } : {},
19001
19637
  ...drop.agent ? { agent: drop.agent } : {},
19002
19638
  ...drop.workflow ? { workflow: drop.workflow } : {}
19003
19639
  };
@@ -19008,8 +19644,8 @@ ${incoming.summary}`);
19008
19644
  if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
19009
19645
  try {
19010
19646
  if (keep2) {
19011
- fs56.mkdirSync(SIGNALS_FILES, { recursive: true });
19012
- fs56.writeFileSync(keep2.at, keep2.data);
19647
+ fs58.mkdirSync(SIGNALS_FILES, { recursive: true });
19648
+ fs58.writeFileSync(keep2.at, keep2.data);
19013
19649
  }
19014
19650
  return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
19015
19651
  } catch (e2) {
@@ -19023,7 +19659,7 @@ function describe(typed, file) {
19023
19659
  return only ? [only] : [];
19024
19660
  };
19025
19661
  if (file) {
19026
- const name = path59.basename(file.name);
19662
+ const name = path61.basename(file.name);
19027
19663
  const text5 = asText(file);
19028
19664
  const note = typed ? `
19029
19665
 
@@ -19035,7 +19671,7 @@ ${typed}` : "";
19035
19671
  const at2 = keepAt(file);
19036
19672
  return {
19037
19673
  incoming: {
19038
- title: path59.basename(name, path59.extname(name)) || name,
19674
+ title: path61.basename(name, path61.extname(name)) || name,
19039
19675
  summary: `${name} \u2014 ${boardRel2(at2)}${note}`,
19040
19676
  ...named2
19041
19677
  },
@@ -19073,73 +19709,73 @@ var init_add = __esm({
19073
19709
  MAX_BYTES = 25 * 1024 * 1024;
19074
19710
  TITLE_MAX = 120;
19075
19711
  TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
19076
- boardRel2 = (file) => rel(file).split(path59.sep).join("/");
19712
+ boardRel2 = (file) => rel(file).split(path61.sep).join("/");
19077
19713
  oneLine = (text5) => {
19078
19714
  const first = text5.split("\n").find((line) => line.trim()) ?? "";
19079
19715
  const clean = first.replace(/^#+\s*/, "").trim();
19080
19716
  return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
19081
19717
  };
19082
- keepAt = (file) => path59.join(SIGNALS_FILES, fileName2(file.name, file.data));
19718
+ keepAt = (file) => path61.join(SIGNALS_FILES, fileName2(file.name, file.data));
19083
19719
  }
19084
19720
  });
19085
19721
 
19086
19722
  // ../cli/src/lib/recurring.ts
19087
- import fs57 from "node:fs";
19088
- import path60 from "node:path";
19723
+ import fs59 from "node:fs";
19724
+ import path62 from "node:path";
19089
19725
  function migratePruneMemoryCard() {
19090
19726
  const dir = recurringDir();
19091
19727
  let names3;
19092
19728
  try {
19093
- names3 = fs57.readdirSync(dir);
19729
+ names3 = fs59.readdirSync(dir);
19094
19730
  } catch {
19095
19731
  return null;
19096
19732
  }
19097
19733
  const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
19098
19734
  if (!name) return null;
19099
- const file = path60.join(dir, name);
19735
+ const file = path62.join(dir, name);
19100
19736
  try {
19101
- const { meta } = parseFrontmatter(fs57.readFileSync(file, "utf8"));
19737
+ const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19102
19738
  const cadence = meta?.cadence;
19103
19739
  if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
19104
19740
  } catch {
19105
19741
  }
19106
- fs57.rmSync(file, { force: true });
19742
+ fs59.rmSync(file, { force: true });
19107
19743
  return rel(file);
19108
19744
  }
19109
19745
  function legacyCards() {
19110
19746
  const dir = recurringDir();
19111
- if (!fs57.existsSync(dir)) return [];
19747
+ if (!fs59.existsSync(dir)) return [];
19112
19748
  const cards = [];
19113
- for (const entry of fs57.readdirSync(dir, { withFileTypes: true })) {
19749
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19114
19750
  const id = idPrefix(entry.name);
19115
19751
  if (id === null) continue;
19116
- const full = path60.join(dir, entry.name);
19752
+ const full = path62.join(dir, entry.name);
19117
19753
  const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
19118
19754
  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 });
19755
+ else if (entry.isDirectory() && fs59.existsSync(path62.join(full, "root.md"))) {
19756
+ cards.push({ id, slug: slug2, file: path62.join(full, "root.md"), folder: full });
19121
19757
  }
19122
19758
  }
19123
19759
  return cards.sort((a2, b2) => a2.id - b2.id);
19124
19760
  }
19125
19761
  function mergeInto2(from, to, skip = []) {
19126
- fs57.mkdirSync(to, { recursive: true });
19127
- for (const entry of fs57.readdirSync(from, { withFileTypes: true })) {
19762
+ fs59.mkdirSync(to, { recursive: true });
19763
+ for (const entry of fs59.readdirSync(from, { withFileTypes: true })) {
19128
19764
  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);
19765
+ const source = path62.join(from, entry.name);
19766
+ const target = path62.join(to, entry.name);
19767
+ if (!fs59.existsSync(target)) fs59.renameSync(source, target);
19768
+ else if (entry.isDirectory() && fs59.statSync(target).isDirectory()) mergeInto2(source, target);
19133
19769
  }
19134
- if (isEmpty(from)) fs57.rmSync(from, { recursive: true, force: true });
19770
+ if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
19135
19771
  }
19136
19772
  function moveSideFolders() {
19137
19773
  const dir = recurringDir();
19138
- for (const entry of fs57.readdirSync(dir, { withFileTypes: true })) {
19774
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19139
19775
  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));
19776
+ const from = path62.join(dir, entry.name);
19777
+ if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
19778
+ else mergeInto2(from, path62.join(AGENTS, entry.name));
19143
19779
  }
19144
19780
  }
19145
19781
  function sections(body) {
@@ -19189,8 +19825,8 @@ function agentName(card, text5) {
19189
19825
  const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a2) => a2.name), ...ROLE_NAMES]);
19190
19826
  for (const name of [slug2, `${slug2}-${card.id}`]) {
19191
19827
  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;
19828
+ const file = path62.join(AGENTS, name, AGENT_FILE3);
19829
+ const written = fs59.existsSync(file) ? fs59.readFileSync(file, "utf8") : null;
19194
19830
  if (written === text5(name)) return name;
19195
19831
  if (written === null && !known2.has(name)) return name;
19196
19832
  }
@@ -19207,11 +19843,11 @@ ${q3.options.map((o3) => `- ${o3}`).join("\n")}` : "";
19207
19843
  function removeCard(card) {
19208
19844
  dropCrossRefs(card.id);
19209
19845
  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 });
19846
+ stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path62.relative(TODO, target).split(path62.sep).join("/") });
19847
+ fs59.rmSync(target, { recursive: true, force: true });
19212
19848
  }
19213
19849
  function migrateCard(card) {
19214
- const { meta, body } = parseFrontmatter(fs57.readFileSync(card.file, "utf8"));
19850
+ const { meta, body } = parseFrontmatter(fs59.readFileSync(card.file, "utf8"));
19215
19851
  if (!meta) throw new Error("its frontmatter cannot be read");
19216
19852
  const raw = meta;
19217
19853
  const said3 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
@@ -19221,19 +19857,19 @@ function migrateCard(card) {
19221
19857
  if (!flow) throw new Error("this board has no workflow to put it in");
19222
19858
  const text5 = (name2) => agentText(name2, meta.title || card.slug, body);
19223
19859
  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);
19860
+ const dir = path62.join(AGENTS, name);
19861
+ const file = path62.join(dir, AGENT_FILE3);
19862
+ const madeDir = !fs59.existsSync(dir);
19863
+ const wrote = !fs59.existsSync(file);
19228
19864
  try {
19229
- fs57.mkdirSync(dir, { recursive: true });
19230
- if (wrote) fs57.writeFileSync(file, text5(name));
19865
+ fs59.mkdirSync(dir, { recursive: true });
19866
+ if (wrote) fs59.writeFileSync(file, text5(name));
19231
19867
  const adopted = adoptWorkflowScheduled(flow.id, name, { cadence, lastRun });
19232
19868
  if (!adopted.ok) throw new Error(adopted.error);
19233
19869
  questionsToTriage(meta, name);
19234
19870
  } catch (e2) {
19235
- if (madeDir) fs57.rmSync(dir, { recursive: true, force: true });
19236
- else if (wrote) fs57.rmSync(file, { force: true });
19871
+ if (madeDir) fs59.rmSync(dir, { recursive: true, force: true });
19872
+ else if (wrote) fs59.rmSync(file, { force: true });
19237
19873
  throw e2;
19238
19874
  }
19239
19875
  if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
@@ -19243,7 +19879,7 @@ function migrateCard(card) {
19243
19879
  function migrateRecurringCards() {
19244
19880
  const done2 = { agents: [], removed: [], failed: [] };
19245
19881
  const dir = recurringDir();
19246
- if (!fs57.existsSync(dir)) return done2;
19882
+ if (!fs59.existsSync(dir)) return done2;
19247
19883
  migratePruneMemoryCard();
19248
19884
  moveSideFolders();
19249
19885
  for (const card of legacyCards()) {
@@ -19256,7 +19892,7 @@ function migrateRecurringCards() {
19256
19892
  done2.failed.push({ card: rel(card.file), why: e2 instanceof Error ? e2.message : String(e2) });
19257
19893
  }
19258
19894
  }
19259
- if (isEmpty(dir)) fs57.rmSync(dir, { recursive: true, force: true });
19895
+ if (isEmpty(dir)) fs59.rmSync(dir, { recursive: true, force: true });
19260
19896
  return done2;
19261
19897
  }
19262
19898
  function recurringMigrationLines(done2) {
@@ -19289,14 +19925,14 @@ var init_recurring = __esm({
19289
19925
  PRUNE_SLUG = "prune-the-memory";
19290
19926
  FETCH_SLUG = "fetch-triage-items";
19291
19927
  AGENT_FILE3 = "AGENT.md";
19292
- recurringDir = () => path60.join(TODO, LEGACY_RECURRING);
19293
- isEmpty = (dir) => fs57.readdirSync(dir).every((name) => name === ".DS_Store");
19928
+ recurringDir = () => path62.join(TODO, LEGACY_RECURRING);
19929
+ isEmpty = (dir) => fs59.readdirSync(dir).every((name) => name === ".DS_Store");
19294
19930
  SECTION = /^##\s+(.+?)\s*$/;
19295
19931
  }
19296
19932
  });
19297
19933
 
19298
19934
  // ../cli/src/commands/init.ts
19299
- import fs58 from "node:fs";
19935
+ import fs60 from "node:fs";
19300
19936
  function boardReadme() {
19301
19937
  return `# Board
19302
19938
 
@@ -19309,20 +19945,20 @@ _(none)_
19309
19945
  `;
19310
19946
  }
19311
19947
  function writeConfigIfMissing() {
19312
- if (fs58.existsSync(CONFIG)) return false;
19313
- fs58.mkdirSync(KANBAN, { recursive: true });
19314
- fs58.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19948
+ if (fs60.existsSync(CONFIG)) return false;
19949
+ fs60.mkdirSync(KANBAN, { recursive: true });
19950
+ fs60.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19315
19951
  return true;
19316
19952
  }
19317
19953
  function writeModulesIfMissing() {
19318
- if (fs58.existsSync(MODULES_MD)) return false;
19319
- fs58.mkdirSync(KANBAN, { recursive: true });
19320
- fs58.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
19954
+ if (fs60.existsSync(MODULES_MD)) return false;
19955
+ fs60.mkdirSync(KANBAN, { recursive: true });
19956
+ fs60.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
19321
19957
  return true;
19322
19958
  }
19323
19959
  function writeGitignoreIfMissing() {
19324
- fs58.mkdirSync(KANBAN, { recursive: true });
19325
- const text5 = fs58.existsSync(KANBAN_GITIGNORE) ? fs58.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
19960
+ fs60.mkdirSync(KANBAN, { recursive: true });
19961
+ const text5 = fs60.existsSync(KANBAN_GITIGNORE) ? fs60.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
19326
19962
  const has = (rule) => text5.split("\n").some((line) => line.trim() === rule.line);
19327
19963
  const missing = IGNORE_RULES.filter((rule) => !has(rule));
19328
19964
  if (!missing.length) return false;
@@ -19330,37 +19966,37 @@ function writeGitignoreIfMissing() {
19330
19966
  ${rule.line}
19331
19967
  `).join("");
19332
19968
  const separator = !text5 || text5.endsWith("\n") ? "" : "\n";
19333
- fs58.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19969
+ fs60.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19334
19970
  return true;
19335
19971
  }
19336
19972
  function writeSkeletonIfMissing() {
19337
19973
  const added = [];
19338
- if (!fs58.existsSync(TODO)) {
19339
- fs58.mkdirSync(TODO, { recursive: true });
19974
+ if (!fs60.existsSync(TODO)) {
19975
+ fs60.mkdirSync(TODO, { recursive: true });
19340
19976
  added.push(`${rel(TODO)}/`);
19341
19977
  }
19342
- if (!fs58.existsSync(README)) {
19343
- fs58.writeFileSync(README, boardReadme());
19978
+ if (!fs60.existsSync(README)) {
19979
+ fs60.writeFileSync(README, boardReadme());
19344
19980
  added.push(rel(README));
19345
19981
  }
19346
19982
  return added;
19347
19983
  }
19348
19984
  function retireReleases() {
19349
19985
  const done2 = [];
19350
- if (fs58.existsSync(RELEASES)) {
19351
- fs58.rmSync(RELEASES);
19986
+ if (fs60.existsSync(RELEASES)) {
19987
+ fs60.rmSync(RELEASES);
19352
19988
  done2.push(`deleted ${rel(RELEASES)}`);
19353
19989
  }
19354
19990
  let cards = 0;
19355
19991
  for (const dir of [TODO, ARCHIVE]) {
19356
- if (!fs58.existsSync(dir)) continue;
19992
+ if (!fs60.existsSync(dir)) continue;
19357
19993
  for (const file of walkMd(dir)) {
19358
- const text5 = fs58.readFileSync(file, "utf8");
19994
+ const text5 = fs60.readFileSync(file, "utf8");
19359
19995
  const end2 = text5.startsWith("---\n") ? text5.indexOf("\n---", 3) : -1;
19360
19996
  if (end2 < 0) continue;
19361
19997
  const head2 = text5.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
19362
19998
  if (head2.length === end2) continue;
19363
- fs58.writeFileSync(file, head2 + text5.slice(end2));
19999
+ fs60.writeFileSync(file, head2 + text5.slice(end2));
19364
20000
  cards++;
19365
20001
  }
19366
20002
  }
@@ -19368,7 +20004,7 @@ function retireReleases() {
19368
20004
  return done2.join(", ");
19369
20005
  }
19370
20006
  function cmdInit() {
19371
- if (fs58.existsSync(KANBAN)) {
20007
+ if (fs60.existsSync(KANBAN)) {
19372
20008
  const added = [
19373
20009
  ...writeSkeletonIfMissing(),
19374
20010
  writeConfigIfMissing() && rel(CONFIG),
@@ -19403,8 +20039,8 @@ function cmdInit() {
19403
20039
  }
19404
20040
  return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
19405
20041
  }
19406
- fs58.mkdirSync(TODO, { recursive: true });
19407
- fs58.writeFileSync(README, boardReadme());
20042
+ fs60.mkdirSync(TODO, { recursive: true });
20043
+ fs60.writeFileSync(README, boardReadme());
19408
20044
  writeConfigIfMissing();
19409
20045
  scaffoldProjectMemory();
19410
20046
  writeModulesIfMissing();
@@ -19493,25 +20129,25 @@ var init_scheduled = __esm({
19493
20129
  });
19494
20130
 
19495
20131
  // ../cli/src/lib/card-age.ts
19496
- import fs59 from "node:fs";
19497
- import path61 from "node:path";
20132
+ import fs61 from "node:fs";
20133
+ import path63 from "node:path";
19498
20134
  function staleAfterIn(config) {
19499
20135
  const days = Number(LINE.exec(config)?.[1]);
19500
20136
  return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
19501
20137
  }
19502
20138
  function staleAfter() {
19503
- if (!fs59.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
19504
- return staleAfterIn(fs59.readFileSync(CONFIG, "utf8"));
20139
+ if (!fs61.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
20140
+ return staleAfterIn(fs61.readFileSync(CONFIG, "utf8"));
19505
20141
  }
19506
20142
  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("/");
20143
+ const from = path63.relative(real(top), real(TODO));
20144
+ if (!from || from.startsWith("..") || path63.isAbsolute(from)) return null;
20145
+ return from.split(path63.sep).join("/");
19510
20146
  }
19511
20147
  function cardFile2(spec, printed) {
19512
20148
  const p2 = unquotePath(printed);
19513
20149
  if (!p2.startsWith(`${spec}/`)) return null;
19514
- return path61.join(TODO, ...p2.slice(spec.length + 1).split("/"));
20150
+ return path63.join(TODO, ...p2.slice(spec.length + 1).split("/"));
19515
20151
  }
19516
20152
  function dirtyCards(top, spec) {
19517
20153
  const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
@@ -19558,9 +20194,9 @@ var init_card_age = __esm({
19558
20194
  gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
19559
20195
  real = (p2) => {
19560
20196
  try {
19561
- return fs59.realpathSync(p2);
20197
+ return fs61.realpathSync(p2);
19562
20198
  } catch {
19563
- return path61.resolve(p2);
20199
+ return path63.resolve(p2);
19564
20200
  }
19565
20201
  };
19566
20202
  unquotePath = (line) => {
@@ -19595,8 +20231,8 @@ var init_card_holds = __esm({
19595
20231
  });
19596
20232
 
19597
20233
  // ../cli/src/commands/list.ts
19598
- import fs60 from "node:fs";
19599
- import path62 from "node:path";
20234
+ import fs62 from "node:fs";
20235
+ import path64 from "node:path";
19600
20236
  function summaryLine(body) {
19601
20237
  const lines = body.split("\n");
19602
20238
  let i = 0;
@@ -19612,13 +20248,13 @@ function summaryLine(body) {
19612
20248
  function openRows() {
19613
20249
  const rows = [];
19614
20250
  for (const file of walkMd(TODO)) {
19615
- const base = path62.basename(file);
20251
+ const base = path64.basename(file);
19616
20252
  if (base === "README.md") continue;
19617
20253
  const isRoot = base === "root.md";
19618
- const id = isRoot ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
20254
+ const id = isRoot ? idPrefix(path64.basename(path64.dirname(file))) : idPrefix(base);
19619
20255
  if (id == null) continue;
19620
- if (isLegacyRecurring(path62.relative(TODO, file))) continue;
19621
- const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
20256
+ if (isLegacyRecurring(path64.relative(TODO, file))) continue;
20257
+ const { meta, body } = parseFrontmatter(fs62.readFileSync(file, "utf8"));
19622
20258
  rows.push({
19623
20259
  id,
19624
20260
  file,
@@ -19660,15 +20296,15 @@ function cmdStale(rows, all2, scope, mod) {
19660
20296
  }
19661
20297
  function archivedFiles() {
19662
20298
  const files2 = /* @__PURE__ */ new Map();
19663
- if (!fs60.existsSync(ARCHIVE)) return files2;
20299
+ if (!fs62.existsSync(ARCHIVE)) return files2;
19664
20300
  for (const file of walkMd(ARCHIVE)) {
19665
- const id = idPrefix(path62.basename(file));
20301
+ const id = idPrefix(path64.basename(file));
19666
20302
  if (id !== null) files2.set(id, file);
19667
20303
  }
19668
20304
  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);
20305
+ const id = idPrefix(path64.basename(dir));
20306
+ const root2 = path64.join(dir, "root.md");
20307
+ if (id !== null && fs62.existsSync(root2)) files2.set(id, root2);
19672
20308
  }
19673
20309
  return files2;
19674
20310
  }
@@ -19779,14 +20415,14 @@ var init_list = __esm({
19779
20415
  });
19780
20416
 
19781
20417
  // ../cli/src/commands/misc.ts
19782
- import fs61 from "node:fs";
19783
- import path63 from "node:path";
20418
+ import fs63 from "node:fs";
20419
+ import path65 from "node:path";
19784
20420
  function extractOldMeta(text5, file) {
19785
20421
  const grab = (re3) => {
19786
20422
  const m = text5.match(re3);
19787
20423
  return m ? m[1].trim() : null;
19788
20424
  };
19789
- const title = grab(/^#\s+(.+)$/m) || slugify(path63.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
20425
+ const title = grab(/^#\s+(.+)$/m) || slugify(path65.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
19790
20426
  const norm = (raw) => {
19791
20427
  const v = (raw || "").toLowerCase();
19792
20428
  return LEVELS.includes(v) ? v : "med";
@@ -19813,11 +20449,11 @@ function stripOldHeader(text5) {
19813
20449
  }
19814
20450
  function cmdMigrate(opts) {
19815
20451
  const dry = opts.dryRun === true;
19816
- const files2 = walkMd(TODO).filter((f2) => path63.basename(f2) !== "README.md");
20452
+ const files2 = walkMd(TODO).filter((f2) => path65.basename(f2) !== "README.md");
19817
20453
  let changed = 0;
19818
20454
  let skipped = 0;
19819
20455
  for (const file of files2) {
19820
- const text5 = fs61.readFileSync(file, "utf8");
20456
+ const text5 = fs63.readFileSync(file, "utf8");
19821
20457
  if (text5.trimStart().startsWith("---")) {
19822
20458
  skipped++;
19823
20459
  continue;
@@ -19826,7 +20462,7 @@ function cmdMigrate(opts) {
19826
20462
  const out = serializeFrontmatter(meta) + "\n\n" + stripOldHeader(text5).replace(/^\n+/, "");
19827
20463
  if (dry) say(`would migrate ${rel(file)} (priority=${meta.priority})`);
19828
20464
  else {
19829
- fs61.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
20465
+ fs63.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
19830
20466
  say(`migrated ${rel(file)}`);
19831
20467
  }
19832
20468
  changed++;
@@ -19847,8 +20483,8 @@ var init_misc = __esm({
19847
20483
  });
19848
20484
 
19849
20485
  // ../cli/src/lib/card-sources.ts
19850
- import fs62 from "node:fs";
19851
- import path64 from "node:path";
20486
+ import fs64 from "node:fs";
20487
+ import path66 from "node:path";
19852
20488
  function planById(id) {
19853
20489
  const found2 = readPlan(`plans/${id}-.md`);
19854
20490
  return found2?.text.trim() ? found2 : null;
@@ -19858,8 +20494,8 @@ function cardLink(id) {
19858
20494
  const found2 = open3 ?? locateArchived(id);
19859
20495
  if (!found2) return null;
19860
20496
  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 ?? "";
20497
+ const file = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
20498
+ const title = parseFrontmatter(fs64.readFileSync(file, "utf8")).meta?.title ?? "";
19863
20499
  return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
19864
20500
  } catch {
19865
20501
  return null;
@@ -19884,7 +20520,7 @@ function link(ref, items) {
19884
20520
  if (ref.kind === "plan") return planLink(ref.id);
19885
20521
  if (ref.kind === "card") return cardLink(ref.id);
19886
20522
  if (ref.kind === "url") return urlLink(ref.url);
19887
- const item = items().find((signal2) => path64.basename(signal2.relPath) === ref.file);
20523
+ const item = items().find((signal2) => path66.basename(signal2.relPath) === ref.file);
19888
20524
  return item ? itemLink(item) : null;
19889
20525
  }
19890
20526
  function cardSources(meta, body) {
@@ -19925,12 +20561,12 @@ var init_card_sources = __esm({
19925
20561
  });
19926
20562
 
19927
20563
  // ../cli/src/lib/view/read.ts
19928
- import fs63 from "node:fs";
19929
- import path65 from "node:path";
20564
+ import fs65 from "node:fs";
20565
+ import path67 from "node:path";
19930
20566
  function readCard(file, relFromTodo) {
19931
- const id = idPrefix(path65.basename(relFromTodo));
20567
+ const id = idPrefix(path67.basename(relFromTodo));
19932
20568
  if (id === null) {
19933
- const parts = relFromTodo.split(path65.sep);
20569
+ const parts = relFromTodo.split(path67.sep);
19934
20570
  const folderId = idPrefix(parts[parts.length - 2] || "");
19935
20571
  if (folderId === null) return null;
19936
20572
  return buildCard(folderId, file, relFromTodo);
@@ -19938,10 +20574,10 @@ function readCard(file, relFromTodo) {
19938
20574
  return buildCard(id, file, relFromTodo);
19939
20575
  }
19940
20576
  function buildCard(id, file, relFromTodo) {
19941
- const text5 = fs63.readFileSync(file, "utf8");
20577
+ const text5 = fs65.readFileSync(file, "utf8");
19942
20578
  const { meta, body } = parseFrontmatter(text5);
19943
20579
  if (!meta) return null;
19944
- const relPath = relFromTodo.split(path65.sep).join("/");
20580
+ const relPath = relFromTodo.split(path67.sep).join("/");
19945
20581
  const flow = workflowFor(meta.workflow);
19946
20582
  const plan = !!meta.workflow && archivesOnApproval(flow);
19947
20583
  const stages = cardStages(meta, flow).length;
@@ -19950,7 +20586,7 @@ function buildCard(id, file, relFromTodo) {
19950
20586
  // Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
19951
20587
  // read here and a card read by the contract agree on what version this is.
19952
20588
  revision: revisionOf(text5),
19953
- updatedAt: fs63.statSync(file).mtime.toISOString(),
20589
+ updatedAt: fs65.statSync(file).mtime.toISOString(),
19954
20590
  relPath,
19955
20591
  title: meta.title,
19956
20592
  priority: meta.priority,
@@ -19971,22 +20607,22 @@ function buildCard(id, file, relFromTodo) {
19971
20607
  };
19972
20608
  }
19973
20609
  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"));
20610
+ const groupDir = path67.join(TODO, folderName);
20611
+ const rootFile = path67.join(groupDir, "root.md");
20612
+ if (!fs65.existsSync(rootFile)) return null;
20613
+ const root2 = readCard(rootFile, path67.join(folderName, "root.md"));
19978
20614
  if (!root2) return null;
19979
20615
  root2.isGroup = true;
19980
20616
  const { total, resolved: resolved2 } = subtaskLines(root2.body);
19981
20617
  root2.subtaskLines = { total, resolved: resolved2 };
19982
20618
  const subCards = [];
19983
20619
  const recurse = (dir, relDir) => {
19984
- for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
19985
- const childRel = path65.join(relDir, entry.name);
20620
+ for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
20621
+ const childRel = path67.join(relDir, entry.name);
19986
20622
  if (entry.isDirectory()) {
19987
- recurse(path65.join(dir, entry.name), childRel);
20623
+ recurse(path67.join(dir, entry.name), childRel);
19988
20624
  } else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
19989
- const c2 = readCard(path65.join(dir, entry.name), childRel);
20625
+ const c2 = readCard(path67.join(dir, entry.name), childRel);
19990
20626
  if (c2) {
19991
20627
  c2.parent = { id: root2.id, title: root2.title };
19992
20628
  subCards.push(c2);
@@ -20007,12 +20643,12 @@ function readGroup2(folderName) {
20007
20643
  return { root: root2, subCards };
20008
20644
  }
20009
20645
  function standaloneCards(dirRel) {
20010
- const dir = dirRel ? path65.join(TODO, dirRel) : TODO;
20011
- if (!fs63.existsSync(dir)) return [];
20646
+ const dir = dirRel ? path67.join(TODO, dirRel) : TODO;
20647
+ if (!fs65.existsSync(dir)) return [];
20012
20648
  const cards = [];
20013
- for (const entry of fs63.readdirSync(dir, { withFileTypes: true })) {
20649
+ for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
20014
20650
  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));
20651
+ const c2 = readCard(path67.join(dir, entry.name), path67.join(dirRel, entry.name));
20016
20652
  if (c2) cards.push(c2);
20017
20653
  }
20018
20654
  }
@@ -20024,7 +20660,7 @@ function collectCards() {
20024
20660
  const top = standaloneCards("");
20025
20661
  board2.push(...top);
20026
20662
  every.push(...top);
20027
- for (const entry of fs63.readdirSync(TODO, { withFileTypes: true })) {
20663
+ for (const entry of fs65.readdirSync(TODO, { withFileTypes: true })) {
20028
20664
  if (!entry.isDirectory()) continue;
20029
20665
  if (isGroupFolder(entry.name)) {
20030
20666
  const g3 = readGroup2(entry.name);
@@ -20056,7 +20692,7 @@ function findCard(id) {
20056
20692
  }
20057
20693
  function attachSources(card) {
20058
20694
  try {
20059
- const { meta, body } = parseFrontmatter(fs63.readFileSync(path65.join(TODO, card.relPath), "utf8"));
20695
+ const { meta, body } = parseFrontmatter(fs65.readFileSync(path67.join(TODO, card.relPath), "utf8"));
20060
20696
  const sources2 = meta ? cardSources(meta, body) : [];
20061
20697
  if (sources2.length) card.sources = sources2;
20062
20698
  } catch {
@@ -20161,10 +20797,10 @@ var init_read = __esm({
20161
20797
  });
20162
20798
 
20163
20799
  // ../cli/src/lib/group-close.ts
20164
- import fs64 from "node:fs";
20800
+ import fs66 from "node:fs";
20165
20801
  function groupCloses(rootFile) {
20166
20802
  try {
20167
- return groupCloseOf(fs64.readFileSync(rootFile, "utf8"));
20803
+ return groupCloseOf(fs66.readFileSync(rootFile, "utf8"));
20168
20804
  } catch {
20169
20805
  return false;
20170
20806
  }
@@ -20177,12 +20813,12 @@ var init_group_close = __esm({
20177
20813
  });
20178
20814
 
20179
20815
  // ../cli/src/commands/remove.ts
20180
- import fs65 from "node:fs";
20181
- import path66 from "node:path";
20816
+ import fs67 from "node:fs";
20817
+ import path68 from "node:path";
20182
20818
  function leavingIds(id, found2) {
20183
20819
  const ids = /* @__PURE__ */ new Set([id]);
20184
20820
  if (found2.kind === "group") {
20185
- const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path66.basename(f2));
20821
+ const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path68.basename(f2));
20186
20822
  for (const name of names3) {
20187
20823
  const n = idPrefix(name);
20188
20824
  if (n !== null) ids.add(n);
@@ -20194,10 +20830,10 @@ function findMentions(ids) {
20194
20830
  const hits = [];
20195
20831
  const re3 = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
20196
20832
  for (const dir of [TODO, MEMORY]) {
20197
- if (!fs65.existsSync(dir)) continue;
20833
+ if (!fs67.existsSync(dir)) continue;
20198
20834
  for (const file of walkMd(dir)) {
20199
- if (path66.basename(file) === "README.md") continue;
20200
- const lines = fs65.readFileSync(file, "utf8").split("\n");
20835
+ if (path68.basename(file) === "README.md") continue;
20836
+ const lines = fs67.readFileSync(file, "utf8").split("\n");
20201
20837
  const fmEnd = frontmatterEnd(lines);
20202
20838
  lines.forEach((line, i) => {
20203
20839
  if (!re3.test(line)) return;
@@ -20213,12 +20849,12 @@ function findMentions(ids) {
20213
20849
  return hits;
20214
20850
  }
20215
20851
  function leavingCards(id, found2) {
20216
- const own = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
20852
+ const own = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20217
20853
  const cards = [{ id, file: own }];
20218
20854
  if (found2.kind !== "group") return cards;
20219
20855
  for (const file of walkMd(found2.target)) {
20220
20856
  if (file === own) continue;
20221
- const n = idPrefix(path66.basename(file));
20857
+ const n = idPrefix(path68.basename(file));
20222
20858
  if (n !== null) cards.push({ id: n, file });
20223
20859
  }
20224
20860
  return cards;
@@ -20227,10 +20863,10 @@ function stampLeaving(cards, rejection) {
20227
20863
  const day = formatDay();
20228
20864
  const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
20229
20865
  for (const card of cards) {
20230
- if (!fs65.existsSync(card.file)) continue;
20231
- const text5 = fs65.readFileSync(card.file, "utf8");
20866
+ if (!fs67.existsSync(card.file)) continue;
20867
+ const text5 = fs67.readFileSync(card.file, "utf8");
20232
20868
  const stamped = stampLeavingIn(text5, day, stamp4);
20233
- if (stamped !== text5) fs65.writeFileSync(card.file, stamped);
20869
+ if (stamped !== text5) fs67.writeFileSync(card.file, stamped);
20234
20870
  }
20235
20871
  }
20236
20872
  function unfinishedDelivery(id) {
@@ -20246,7 +20882,7 @@ function unfinishedDelivery(id) {
20246
20882
  }[gap];
20247
20883
  return `#${id} is not finished: ${what}.`;
20248
20884
  }
20249
- const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs65.existsSync(path66.join(ASSETS, src.slice(".assets/".length))));
20885
+ const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs67.existsSync(path68.join(ASSETS, src.slice(".assets/".length))));
20250
20886
  return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
20251
20887
  }
20252
20888
  function agentDecisions(text5) {
@@ -20277,8 +20913,8 @@ function removeCard2(id, metric, options) {
20277
20913
  const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
20278
20914
  if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
20279
20915
  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") : "";
20916
+ const cardFile3 = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20917
+ const cardText = fs67.existsSync(cardFile3) ? fs67.readFileSync(cardFile3, "utf8") : "";
20282
20918
  const { meta: cardMeta3 } = parseFrontmatter(cardText);
20283
20919
  const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f2) => f2 !== cardFile3).map((f2) => rel(f2)).sort() : [];
20284
20920
  const leftIds = leavingIds(id, found2);
@@ -20309,10 +20945,10 @@ function removeCard2(id, metric, options) {
20309
20945
  const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
20310
20946
  if (dest) {
20311
20947
  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);
20948
+ fs67.mkdirSync(ARCHIVE, { recursive: true });
20949
+ fs67.renameSync(found2.target, dest);
20314
20950
  } else {
20315
- fs65.rmSync(found2.target, { recursive: true, force: true });
20951
+ fs67.rmSync(found2.target, { recursive: true, force: true });
20316
20952
  }
20317
20953
  const removedRefs = stripReadmeRefs(found2);
20318
20954
  let marked2 = null;
@@ -20361,14 +20997,14 @@ function removeCard2(id, metric, options) {
20361
20997
  };
20362
20998
  }
20363
20999
  function closeGroup(rootFile) {
20364
- const rootId = idPrefix(path66.basename(path66.dirname(rootFile)));
21000
+ const rootId = idPrefix(path68.basename(path68.dirname(rootFile)));
20365
21001
  if (rootId === null) return null;
20366
21002
  if (runnerProject(KANBAN)) return null;
20367
21003
  if (!groupCloses(rootFile)) return null;
20368
21004
  say(`
20369
21005
  every subtask line on #${rootId} is resolved \u2014 closing the group:`);
20370
21006
  try {
20371
- const { meta, body } = parseFrontmatter(fs65.readFileSync(rootFile, "utf8"));
21007
+ const { meta, body } = parseFrontmatter(fs67.readFileSync(rootFile, "utf8"));
20372
21008
  const res = cmdRemove(rootId, "completed", { closing: true });
20373
21009
  return {
20374
21010
  id: rootId,
@@ -20425,7 +21061,7 @@ function cleanupDiscardedCards(sessionId) {
20425
21061
  if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
20426
21062
  while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
20427
21063
  dropCrossRefs(card.id);
20428
- stripReadmeRefs({ kind: "file", rel: path66.relative(TODO, path66.resolve(REPO_ROOT, card.path)).split(path66.sep).join("/") });
21064
+ stripReadmeRefs({ kind: "file", rel: path68.relative(TODO, path68.resolve(REPO_ROOT, card.path)).split(path68.sep).join("/") });
20429
21065
  }
20430
21066
  return discarded.map((c2) => c2.id);
20431
21067
  });
@@ -20433,8 +21069,8 @@ function cleanupDiscardedCards(sessionId) {
20433
21069
  function recoveredArchiveHandoff(id, source) {
20434
21070
  const found2 = locateArchived(id);
20435
21071
  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"));
21072
+ const file = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
21073
+ const { meta } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
20438
21074
  stripReadmeRefs(source ?? found2);
20439
21075
  const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
20440
21076
  if (root2) markSubtask(root2, id, "tick");
@@ -20532,8 +21168,8 @@ var init_memory_file = __esm({
20532
21168
  });
20533
21169
 
20534
21170
  // ../cli/src/commands/rule.ts
20535
- import fs66 from "node:fs";
20536
- import path67 from "node:path";
21171
+ import fs68 from "node:fs";
21172
+ import path69 from "node:path";
20537
21173
  function cmdRule(askedName, flags) {
20538
21174
  const agent = askedName.trim();
20539
21175
  if (!agentRoster().some((a2) => a2.name === agent)) {
@@ -20542,7 +21178,7 @@ function cmdRule(askedName, flags) {
20542
21178
  const rule = readRuleText(flags.file, flags.text);
20543
21179
  const res = setAgentRule(agent, rule);
20544
21180
  if (!res.ok) die(res.error);
20545
- const file = rel(path67.join(RULES, `${agent}.md`));
21181
+ const file = rel(path69.join(RULES, `${agent}.md`));
20546
21182
  say(rule ? `wrote the \`${agent}\` rule (${file})` : `cleared the \`${agent}\` rule`);
20547
21183
  return { agent, file, cleared: !rule };
20548
21184
  }
@@ -20550,7 +21186,7 @@ function readRuleText(file, text5) {
20550
21186
  if (file !== void 0 && text5 !== void 0) die("pass --file or --text, not both");
20551
21187
  if (file !== void 0) {
20552
21188
  try {
20553
- return fs66.readFileSync(file, "utf8").trim();
21189
+ return fs68.readFileSync(file, "utf8").trim();
20554
21190
  } catch {
20555
21191
  die(`can't read ${file} \u2014 write the rule to a file, then pass its path`);
20556
21192
  }
@@ -20869,7 +21505,7 @@ var shared_exports = {};
20869
21505
  __export(shared_exports, {
20870
21506
  InvalidArgumentError: () => InvalidArgumentError,
20871
21507
  cardId: () => cardId,
20872
- collect: () => collect,
21508
+ collect: () => collect2,
20873
21509
  collectList: () => collectList,
20874
21510
  ctxOf: () => ctxOf,
20875
21511
  intInRange: () => intInRange,
@@ -20965,7 +21601,7 @@ function ordered(into) {
20965
21601
  return value ?? "";
20966
21602
  };
20967
21603
  }
20968
- var HELP_WIDTH, collect;
21604
+ var HELP_WIDTH, collect2;
20969
21605
  var init_shared = __esm({
20970
21606
  "../cli/src/lib/cli/shared.ts"() {
20971
21607
  "use strict";
@@ -20974,7 +21610,7 @@ var init_shared = __esm({
20974
21610
  init_board_cli();
20975
21611
  init_moved();
20976
21612
  HELP_WIDTH = 100;
20977
- collect = (value, previous = []) => previous.concat(value);
21613
+ collect2 = (value, previous = []) => previous.concat(value);
20978
21614
  }
20979
21615
  });
20980
21616
 
@@ -20984,8 +21620,8 @@ __export(board_exports, {
20984
21620
  buildBoardProgram: () => buildBoardProgram
20985
21621
  });
20986
21622
  import crypto5 from "node:crypto";
20987
- import fs67 from "node:fs";
20988
- import path68 from "node:path";
21623
+ import fs69 from "node:fs";
21624
+ import path70 from "node:path";
20989
21625
  async function dispatch(move, cmd, args, opts, cli) {
20990
21626
  const ctx = ctxOf(cmd, cli.program);
20991
21627
  const data = await runAction(ctx, {}, async () => {
@@ -21025,7 +21661,7 @@ async function cloudCard(task, opts) {
21025
21661
  let request2;
21026
21662
  if (typeof opts.bodyFile === "string") {
21027
21663
  try {
21028
- request2 = fs67.readFileSync(opts.bodyFile, "utf8");
21664
+ request2 = fs69.readFileSync(opts.bodyFile, "utf8");
21029
21665
  } catch {
21030
21666
  }
21031
21667
  }
@@ -21055,7 +21691,7 @@ async function cloudCard(task, opts) {
21055
21691
  const file = creationReceipt(`${checked.value}:${requestId}`, slot);
21056
21692
  const journal = readCreation(file, said3);
21057
21693
  if (!journal.made) {
21058
- const key = `akb-${path68.basename(file, ".json").slice(0, 40)}`;
21694
+ const key = `akb-${path70.basename(file, ".json").slice(0, 40)}`;
21059
21695
  const made = await createProjectTask(checked.value, journal.said, key);
21060
21696
  if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
21061
21697
  journal.made = made.value;
@@ -21085,13 +21721,13 @@ function buildBoardProgram(cli) {
21085
21721
  const inOrder = ordered(asked);
21086
21722
  move("create").summary("write exactly one card \u2014 its fields, its body template and its index entry").description(
21087
21723
  '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() {
21724
+ ).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
21725
  refuseRecurring(this);
21090
21726
  await dispatch("create", this, [], { ...this.opts(), asked }, cli);
21091
21727
  });
21092
21728
  move("update").argument("<id>", ID, cardId).summary("rewrite a card's fields").description(
21093
21729
  "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) {
21730
+ ).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
21731
  refuseRecurring(this);
21096
21732
  await dispatch("update", this, [String(id)], this.opts(), cli);
21097
21733
  });
@@ -21197,16 +21833,16 @@ var init_board2 = __esm({
21197
21833
  });
21198
21834
 
21199
21835
  // ../cli/src/lib/board-cli.ts
21200
- import fs68 from "node:fs";
21201
- import path69 from "node:path";
21836
+ import fs70 from "node:fs";
21837
+ import path71 from "node:path";
21202
21838
  function useBoard(found2, dirNamed) {
21203
- if (!found2.named && found2.board === path69.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21839
+ if (!found2.named && found2.board === path71.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21204
21840
  else setBoardDir(found2.board, found2.root);
21205
21841
  useProjectState();
21206
21842
  }
21207
21843
  function whole(found2, move) {
21208
21844
  if (move === MAKES_A_BOARD) return found2;
21209
- if (!fs68.existsSync(path69.join(found2.board, "todo"))) {
21845
+ if (!fs70.existsSync(path71.join(found2.board, "todo"))) {
21210
21846
  die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
21211
21847
  kind: "board-incomplete",
21212
21848
  dir: found2.root
@@ -21215,13 +21851,13 @@ function whole(found2, move) {
21215
21851
  return found2;
21216
21852
  }
21217
21853
  function findBoardUpward(from, move) {
21218
- let dir = path69.resolve(from);
21854
+ let dir = path71.resolve(from);
21219
21855
  for (; ; ) {
21220
- if (hasBoard(dir)) return { root: dir, board: path69.join(dir, "docs", "kanban") };
21856
+ if (hasBoard(dir)) return { root: dir, board: path71.join(dir, "docs", "kanban") };
21221
21857
  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);
21858
+ const kept2 = path71.join(dir, ".akb", "kanban");
21859
+ if (move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return { root: dir, board: kept2 };
21860
+ const up = path71.dirname(dir);
21225
21861
  if (up === dir) return null;
21226
21862
  dir = up;
21227
21863
  }
@@ -21229,11 +21865,11 @@ function findBoardUpward(from, move) {
21229
21865
  function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21230
21866
  const named2 = board2 ?? boardFromEnv();
21231
21867
  if (named2) {
21232
- const folder = path69.resolve(cwd, named2);
21233
- if (!fs68.existsSync(folder) && move !== MAKES_A_BOARD) {
21868
+ const folder = path71.resolve(cwd, named2);
21869
+ if (!fs70.existsSync(folder) && move !== MAKES_A_BOARD) {
21234
21870
  die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
21235
21871
  }
21236
- if (fs68.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21872
+ if (fs70.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21237
21873
  die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
21238
21874
  kind: "no-board",
21239
21875
  dir: folder
@@ -21242,24 +21878,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21242
21878
  return { root: projectRootOf(folder), board: folder, named: true };
21243
21879
  }
21244
21880
  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);
21881
+ const root2 = path71.resolve(dir);
21882
+ if (!fs70.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
21883
+ const kept2 = path71.join(root2, ".akb", "kanban");
21884
+ if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
21249
21885
  if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
21250
21886
  die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
21251
21887
  kind: "no-board",
21252
21888
  dir: root2
21253
21889
  });
21254
21890
  }
21255
- return whole({ root: root2, board: path69.join(root2, "docs", "kanban") }, move);
21891
+ return whole({ root: root2, board: path71.join(root2, "docs", "kanban") }, move);
21256
21892
  }
21257
21893
  const found2 = findBoardUpward(cwd, move);
21258
21894
  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") };
21895
+ if (move === MAKES_A_BOARD) return { root: path71.resolve(cwd), board: path71.join(path71.resolve(cwd), "docs", "kanban") };
21260
21896
  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) }
21897
+ `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`,
21898
+ { kind: "no-board", dir: path71.resolve(cwd) }
21263
21899
  );
21264
21900
  }
21265
21901
  function editDistance(a2, b2) {
@@ -21341,8 +21977,8 @@ var init_board_cli = __esm({
21341
21977
  init_io();
21342
21978
  init_pointer();
21343
21979
  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"));
21980
+ hasBoard = (dir) => fs70.existsSync(path71.join(dir, "docs", "kanban"));
21981
+ isBoardDir = (dir) => fs70.existsSync(path71.join(dir, "todo")) && fs70.existsSync(path71.join(dir, "config.md"));
21346
21982
  boardFromEnv = () => {
21347
21983
  const named2 = process.env.AI4KANBAN_BOARD?.trim();
21348
21984
  return named2 ? named2 : null;
@@ -21450,7 +22086,7 @@ var init_review_rejections = __esm({
21450
22086
  var refine_default;
21451
22087
  var init_refine = __esm({
21452
22088
  "../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';
22089
+ 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
22090
  }
21455
22091
  });
21456
22092
 
@@ -21506,7 +22142,7 @@ var init_troubleshoot = __esm({
21506
22142
  var write_agent_default;
21507
22143
  var init_write_agent = __esm({
21508
22144
  "../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";
22145
+ 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
22146
  }
21511
22147
  });
21512
22148
 
@@ -21599,8 +22235,8 @@ var init_guide = __esm({
21599
22235
  });
21600
22236
 
21601
22237
  // ../cli/src/lib/agent/approve.ts
21602
- import fs74 from "node:fs";
21603
- import path75 from "node:path";
22238
+ import fs77 from "node:fs";
22239
+ import path78 from "node:path";
21604
22240
  function approvalRequest(req) {
21605
22241
  const id = req.id;
21606
22242
  const card = id === void 0 ? null : findCard(id);
@@ -21618,12 +22254,12 @@ function advancePhase(id) {
21618
22254
  const card = findCard(id);
21619
22255
  const found2 = locate(id);
21620
22256
  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"));
22257
+ const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
22258
+ const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
21623
22259
  if (!meta) return { error: `#${id} has no frontmatter` };
21624
22260
  meta.phase = card.stage + 1;
21625
22261
  meta.status = "todo";
21626
- fs74.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
22262
+ fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
21627
22263
  return null;
21628
22264
  }
21629
22265
  var init_approve = __esm({
@@ -21756,16 +22392,16 @@ var init_start = __esm({
21756
22392
  });
21757
22393
 
21758
22394
  // ../cli/src/lib/agent/task-chats.ts
21759
- import fs75 from "node:fs";
21760
- import path76 from "node:path";
22395
+ import fs78 from "node:fs";
22396
+ import path79 from "node:path";
21761
22397
  function taskChatFile(task, home3) {
21762
22398
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
21763
- return path76.join(taskChatsDir(home3), `${task}.jsonl`);
22399
+ return path79.join(taskChatsDir(home3), `${task}.jsonl`);
21764
22400
  }
21765
22401
  function readTaskChat(task, home3) {
21766
22402
  let text5;
21767
22403
  try {
21768
- text5 = fs75.readFileSync(taskChatFile(task, home3), "utf8");
22404
+ text5 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
21769
22405
  } catch {
21770
22406
  return [];
21771
22407
  }
@@ -21786,13 +22422,13 @@ var init_task_chats = __esm({
21786
22422
  "use strict";
21787
22423
  init_home();
21788
22424
  TASK = /^[\w-]{1,100}$/;
21789
- taskChatsDir = (home3 = machineHome()) => path76.join(home3, "chats");
22425
+ taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
21790
22426
  }
21791
22427
  });
21792
22428
 
21793
22429
  // ../cli/src/lib/agent/memory-review.ts
21794
- import fs76 from "node:fs";
21795
- import path77 from "node:path";
22430
+ import fs79 from "node:fs";
22431
+ import path80 from "node:path";
21796
22432
  function taskChatsToReview(tasks) {
21797
22433
  const out = [];
21798
22434
  for (const ref of [...new Set(tasks)]) {
@@ -21814,8 +22450,8 @@ function readArchived2(id) {
21814
22450
  const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
21815
22451
  if (!found2) return null;
21816
22452
  try {
21817
- const file = found2.kind === "group" ? path77.join(found2.target, "root.md") : found2.target;
21818
- const { meta, body } = parseFrontmatter(fs76.readFileSync(file, "utf8"));
22453
+ const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
22454
+ const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
21819
22455
  if (!meta) return null;
21820
22456
  return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
21821
22457
  } catch {
@@ -21884,17 +22520,17 @@ var init_memory_review = __esm({
21884
22520
  });
21885
22521
 
21886
22522
  // ../cli/src/lib/agent/dismissal-review.ts
21887
- import fs77 from "node:fs";
21888
- import path78 from "node:path";
22523
+ import fs80 from "node:fs";
22524
+ import path81 from "node:path";
21889
22525
  function rejectionsToReview() {
21890
- const dir = path78.join(ARCHIVE, REJECTIONS_TO_REVIEW);
21891
- if (!fs77.existsSync(dir)) return [];
22526
+ const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
22527
+ if (!fs80.existsSync(dir)) return [];
21892
22528
  const found2 = [];
21893
22529
  for (const file of walkMd(dir)) {
21894
22530
  const id = archivedId(file);
21895
22531
  if (id === null) continue;
21896
22532
  try {
21897
- const { meta } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
22533
+ const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
21898
22534
  if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
21899
22535
  found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
21900
22536
  } catch {
@@ -21924,7 +22560,7 @@ function citedSources(text5) {
21924
22560
  function withdrawnSources() {
21925
22561
  const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
21926
22562
  try {
21927
- return citedSources(fs77.readFileSync(file, "utf8"));
22563
+ return citedSources(fs80.readFileSync(file, "utf8"));
21928
22564
  } catch {
21929
22565
  return [];
21930
22566
  }
@@ -21949,8 +22585,8 @@ var init_dismissal_review = __esm({
21949
22585
  });
21950
22586
 
21951
22587
  // ../cli/src/lib/agent/flow.ts
21952
- import fs78 from "node:fs";
21953
- import path79 from "node:path";
22588
+ import fs81 from "node:fs";
22589
+ import path82 from "node:path";
21954
22590
  function readCard2(id, home3 = "board") {
21955
22591
  const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
21956
22592
  const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
@@ -21960,10 +22596,10 @@ function readCard2(id, home3 = "board") {
21960
22596
  { kind: "card-not-found", id }
21961
22597
  );
21962
22598
  }
21963
- const file = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
22599
+ const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
21964
22600
  let text5;
21965
22601
  try {
21966
- text5 = fs78.readFileSync(file, "utf8");
22602
+ text5 = fs81.readFileSync(file, "utf8");
21967
22603
  } catch {
21968
22604
  die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
21969
22605
  }
@@ -22651,94 +23287,6 @@ var init_refine2 = __esm({
22651
23287
  }
22652
23288
  });
22653
23289
 
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
23290
  // ../cli/node_modules/react/cjs/react.production.js
22743
23291
  var require_react_production = __commonJS({
22744
23292
  "../cli/node_modules/react/cjs/react.production.js"(exports) {
@@ -30262,13 +30810,13 @@ var require_react_dom_server_node_production = __commonJS({
30262
30810
  var target = currentView;
30263
30811
  0 < writtenBytes && (target = currentView.subarray(writtenBytes));
30264
30812
  target = textEncoder.encodeInto(chunk, target);
30265
- var read4 = target.read;
30813
+ var read5 = target.read;
30266
30814
  writtenBytes += target.written;
30267
- read4 < chunk.length && (writeToDestination(
30815
+ read5 < chunk.length && (writeToDestination(
30268
30816
  destination,
30269
30817
  currentView.subarray(0, writtenBytes)
30270
30818
  ), currentView = new Uint8Array(4096), writtenBytes = textEncoder.encodeInto(
30271
- chunk.slice(read4),
30819
+ chunk.slice(read5),
30272
30820
  currentView
30273
30821
  ).written);
30274
30822
  4096 === writtenBytes && (writeToDestination(destination, currentView), currentView = new Uint8Array(4096), writtenBytes = 0);
@@ -44018,13 +44566,13 @@ var require_react_dom_server_node_development = __commonJS({
44018
44566
  var target = currentView;
44019
44567
  0 < writtenBytes && (target = currentView.subarray(writtenBytes));
44020
44568
  target = textEncoder.encodeInto(chunk, target);
44021
- var read4 = target.read;
44569
+ var read5 = target.read;
44022
44570
  writtenBytes += target.written;
44023
- read4 < chunk.length && (writeToDestination(
44571
+ read5 < chunk.length && (writeToDestination(
44024
44572
  destination,
44025
44573
  currentView.subarray(0, writtenBytes)
44026
44574
  ), currentView = new Uint8Array(4096), writtenBytes = textEncoder.encodeInto(
44027
- chunk.slice(read4),
44575
+ chunk.slice(read5),
44028
44576
  currentView
44029
44577
  ).written);
44030
44578
  4096 === writtenBytes && (writeToDestination(destination, currentView), currentView = new Uint8Array(4096), writtenBytes = 0);
@@ -63946,8 +64494,8 @@ var require_JSXTransformer = __commonJS({
63946
64494
  }
63947
64495
  if (this.isAutomaticRuntime) {
63948
64496
  if (this.importProcessor) {
63949
- for (const [path87, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
63950
- prefix += `var ${resolvedName} = require("${path87}");`;
64497
+ for (const [path90, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
64498
+ prefix += `var ${resolvedName} = require("${path90}");`;
63951
64499
  }
63952
64500
  } else {
63953
64501
  const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
@@ -64140,11 +64688,11 @@ var require_JSXTransformer = __commonJS({
64140
64688
  }
64141
64689
  claimAutoImportedName(funcName, importPathSuffix) {
64142
64690
  if (this.importProcessor) {
64143
- const path87 = this.jsxImportSource + importPathSuffix;
64144
- if (!this.cjsAutomaticModuleNameResolutions[path87]) {
64145
- this.cjsAutomaticModuleNameResolutions[path87] = this.importProcessor.getFreeIdentifierForPath(path87);
64691
+ const path90 = this.jsxImportSource + importPathSuffix;
64692
+ if (!this.cjsAutomaticModuleNameResolutions[path90]) {
64693
+ this.cjsAutomaticModuleNameResolutions[path90] = this.importProcessor.getFreeIdentifierForPath(path90);
64146
64694
  }
64147
- return `${this.cjsAutomaticModuleNameResolutions[path87]}.${funcName}`;
64695
+ return `${this.cjsAutomaticModuleNameResolutions[path90]}.${funcName}`;
64148
64696
  } else {
64149
64697
  if (!this.esmAutomaticImportNameResolutions[funcName]) {
64150
64698
  this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
@@ -64580,7 +65128,7 @@ var require_CJSImportProcessor = __commonJS({
64580
65128
  */
64581
65129
  pruneTypeOnlyImports() {
64582
65130
  this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
64583
- for (const [path87, importInfo] of this.importInfoByPath.entries()) {
65131
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
64584
65132
  if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
64585
65133
  continue;
64586
65134
  }
@@ -64590,7 +65138,7 @@ var require_CJSImportProcessor = __commonJS({
64590
65138
  ...importInfo.namedImports.map(({ localName }) => localName)
64591
65139
  ];
64592
65140
  if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
64593
- this.importsToReplace.set(path87, "");
65141
+ this.importsToReplace.set(path90, "");
64594
65142
  }
64595
65143
  }
64596
65144
  }
@@ -64598,7 +65146,7 @@ var require_CJSImportProcessor = __commonJS({
64598
65146
  return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
64599
65147
  }
64600
65148
  generateImportReplacements() {
64601
- for (const [path87, importInfo] of this.importInfoByPath.entries()) {
65149
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
64602
65150
  const {
64603
65151
  defaultNames,
64604
65152
  wildcardNames,
@@ -64608,17 +65156,17 @@ var require_CJSImportProcessor = __commonJS({
64608
65156
  hasStarExport
64609
65157
  } = importInfo;
64610
65158
  if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
64611
- this.importsToReplace.set(path87, `require('${path87}');`);
65159
+ this.importsToReplace.set(path90, `require('${path90}');`);
64612
65160
  continue;
64613
65161
  }
64614
- const primaryImportName = this.getFreeIdentifierForPath(path87);
65162
+ const primaryImportName = this.getFreeIdentifierForPath(path90);
64615
65163
  let secondaryImportName;
64616
65164
  if (this.enableLegacyTypeScriptModuleInterop) {
64617
65165
  secondaryImportName = primaryImportName;
64618
65166
  } else {
64619
- secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path87);
65167
+ secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path90);
64620
65168
  }
64621
- let requireCode = `var ${primaryImportName} = require('${path87}');`;
65169
+ let requireCode = `var ${primaryImportName} = require('${path90}');`;
64622
65170
  if (wildcardNames.length > 0) {
64623
65171
  for (const wildcardName of wildcardNames) {
64624
65172
  const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
@@ -64646,7 +65194,7 @@ var require_CJSImportProcessor = __commonJS({
64646
65194
  "createStarExport"
64647
65195
  )}(${primaryImportName});`;
64648
65196
  }
64649
- this.importsToReplace.set(path87, requireCode);
65197
+ this.importsToReplace.set(path90, requireCode);
64650
65198
  for (const defaultName of defaultNames) {
64651
65199
  this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
64652
65200
  }
@@ -64655,8 +65203,8 @@ var require_CJSImportProcessor = __commonJS({
64655
65203
  }
64656
65204
  }
64657
65205
  }
64658
- getFreeIdentifierForPath(path87) {
64659
- const components = path87.split("/");
65206
+ getFreeIdentifierForPath(path90) {
65207
+ const components = path90.split("/");
64660
65208
  const lastComponent = components[components.length - 1];
64661
65209
  const baseName = lastComponent.replace(/\W/g, "");
64662
65210
  return this.nameManager.claimFreeName(`_${baseName}`);
@@ -64701,8 +65249,8 @@ var require_CJSImportProcessor = __commonJS({
64701
65249
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
64702
65250
  throw new Error("Expected string token at the end of import statement.");
64703
65251
  }
64704
- const path87 = this.tokens.stringValueAtIndex(index);
64705
- const importInfo = this.getImportInfo(path87);
65252
+ const path90 = this.tokens.stringValueAtIndex(index);
65253
+ const importInfo = this.getImportInfo(path90);
64706
65254
  importInfo.defaultNames.push(...defaultNames);
64707
65255
  importInfo.wildcardNames.push(...wildcardNames);
64708
65256
  importInfo.namedImports.push(...namedImports);
@@ -64769,8 +65317,8 @@ var require_CJSImportProcessor = __commonJS({
64769
65317
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
64770
65318
  throw new Error("Expected string token at the end of import statement.");
64771
65319
  }
64772
- const path87 = this.tokens.stringValueAtIndex(index);
64773
- const importInfo = this.getImportInfo(path87);
65320
+ const path90 = this.tokens.stringValueAtIndex(index);
65321
+ const importInfo = this.getImportInfo(path90);
64774
65322
  importInfo.namedExports.push(...namedImports);
64775
65323
  }
64776
65324
  preprocessExportStarAtIndex(index) {
@@ -64785,8 +65333,8 @@ var require_CJSImportProcessor = __commonJS({
64785
65333
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
64786
65334
  throw new Error("Expected string token at the end of star export statement.");
64787
65335
  }
64788
- const path87 = this.tokens.stringValueAtIndex(index);
64789
- const importInfo = this.getImportInfo(path87);
65336
+ const path90 = this.tokens.stringValueAtIndex(index);
65337
+ const importInfo = this.getImportInfo(path90);
64790
65338
  if (exportedName !== null) {
64791
65339
  importInfo.exportStarNames.push(exportedName);
64792
65340
  } else {
@@ -64826,8 +65374,8 @@ var require_CJSImportProcessor = __commonJS({
64826
65374
  * Get a mutable import info object for this path, creating one if it doesn't
64827
65375
  * exist yet.
64828
65376
  */
64829
- getImportInfo(path87) {
64830
- const existingInfo = this.importInfoByPath.get(path87);
65377
+ getImportInfo(path90) {
65378
+ const existingInfo = this.importInfoByPath.get(path90);
64831
65379
  if (existingInfo) {
64832
65380
  return existingInfo;
64833
65381
  }
@@ -64840,7 +65388,7 @@ var require_CJSImportProcessor = __commonJS({
64840
65388
  exportStarNames: [],
64841
65389
  hasStarExport: false
64842
65390
  };
64843
- this.importInfoByPath.set(path87, newInfo);
65391
+ this.importInfoByPath.set(path90, newInfo);
64844
65392
  return newInfo;
64845
65393
  }
64846
65394
  addExportBinding(localName, exportedName) {
@@ -65420,16 +65968,16 @@ var require_resolve_uri_umd = __commonJS({
65420
65968
  }
65421
65969
  function parseFileUrl(input) {
65422
65970
  const match = fileRegex.exec(input);
65423
- const path87 = match[2];
65424
- return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path87) ? path87 : "/" + path87, match[3] || "", match[4] || "");
65971
+ const path90 = match[2];
65972
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path90) ? path90 : "/" + path90, match[3] || "", match[4] || "");
65425
65973
  }
65426
- function makeUrl(scheme, user, host2, port, path87, query, hash2) {
65974
+ function makeUrl(scheme, user, host2, port, path90, query, hash2) {
65427
65975
  return {
65428
65976
  scheme,
65429
65977
  user,
65430
65978
  host: host2,
65431
65979
  port,
65432
- path: path87,
65980
+ path: path90,
65433
65981
  query,
65434
65982
  hash: hash2,
65435
65983
  type: 7
@@ -65459,11 +66007,11 @@ var require_resolve_uri_umd = __commonJS({
65459
66007
  url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
65460
66008
  return url;
65461
66009
  }
65462
- function stripPathFilename(path87) {
65463
- if (path87.endsWith("/.."))
65464
- return path87;
65465
- const index = path87.lastIndexOf("/");
65466
- return path87.slice(0, index + 1);
66010
+ function stripPathFilename(path90) {
66011
+ if (path90.endsWith("/.."))
66012
+ return path90;
66013
+ const index = path90.lastIndexOf("/");
66014
+ return path90.slice(0, index + 1);
65467
66015
  }
65468
66016
  function mergePaths(url, base) {
65469
66017
  normalizePath(base, base.type);
@@ -65501,14 +66049,14 @@ var require_resolve_uri_umd = __commonJS({
65501
66049
  pieces[pointer++] = piece;
65502
66050
  positive++;
65503
66051
  }
65504
- let path87 = "";
66052
+ let path90 = "";
65505
66053
  for (let i = 1; i < pointer; i++) {
65506
- path87 += "/" + pieces[i];
66054
+ path90 += "/" + pieces[i];
65507
66055
  }
65508
- if (!path87 || addTrailingSlash && !path87.endsWith("/..")) {
65509
- path87 += "/";
66056
+ if (!path90 || addTrailingSlash && !path90.endsWith("/..")) {
66057
+ path90 += "/";
65510
66058
  }
65511
- url.path = path87;
66059
+ url.path = path90;
65512
66060
  }
65513
66061
  function resolve2(input, base) {
65514
66062
  if (!input && !base)
@@ -65549,13 +66097,13 @@ var require_resolve_uri_umd = __commonJS({
65549
66097
  case 3:
65550
66098
  return queryHash;
65551
66099
  case 4: {
65552
- const path87 = url.path.slice(1);
65553
- if (!path87)
66100
+ const path90 = url.path.slice(1);
66101
+ if (!path90)
65554
66102
  return queryHash || ".";
65555
- if (isRelative(base || input) && !isRelative(path87)) {
65556
- return "./" + path87 + queryHash;
66103
+ if (isRelative(base || input) && !isRelative(path90)) {
66104
+ return "./" + path90 + queryHash;
65557
66105
  }
65558
- return path87 + queryHash;
66106
+ return path90 + queryHash;
65559
66107
  }
65560
66108
  case 5:
65561
66109
  return url.path + queryHash;
@@ -65654,12 +66202,12 @@ var require_trace_mapping_umd = __commonJS({
65654
66202
  module2.exports = __toCommonJS(trace_mapping_exports);
65655
66203
  var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
65656
66204
  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);
66205
+ function stripFilename(path90) {
66206
+ if (!path90) return "";
66207
+ const index = path90.lastIndexOf("/");
66208
+ return path90.slice(0, index + 1);
65661
66209
  }
65662
- function resolver(mapUrl, sourceRoot) {
66210
+ function resolver2(mapUrl, sourceRoot) {
65663
66211
  const from = stripFilename(mapUrl);
65664
66212
  const prefix = sourceRoot ? sourceRoot + "/" : "";
65665
66213
  return (source) => (0, import_resolve_uri.default)(prefix + (source || ""), from);
@@ -65908,7 +66456,7 @@ var require_trace_mapping_umd = __commonJS({
65908
66456
  this.sources = sources2;
65909
66457
  this.sourcesContent = sourcesContent;
65910
66458
  this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
65911
- const resolve2 = resolver(mapUrl, sourceRoot);
66459
+ const resolve2 = resolver2(mapUrl, sourceRoot);
65912
66460
  this.resolvedSources = sources2.map(resolve2);
65913
66461
  const { mappings } = parsed;
65914
66462
  if (typeof mappings === "string") {
@@ -66865,9 +67413,9 @@ var require_util2 = __commonJS({
66865
67413
  /** @class */
66866
67414
  (function(_super) {
66867
67415
  __extends(VError2, _super);
66868
- function VError2(path87, message) {
67416
+ function VError2(path90, message) {
66869
67417
  var _this = _super.call(this, message) || this;
66870
- _this.path = path87;
67418
+ _this.path = path90;
66871
67419
  Object.setPrototypeOf(_this, VError2.prototype);
66872
67420
  return _this;
66873
67421
  }
@@ -66927,26 +67475,26 @@ var require_util2 = __commonJS({
66927
67475
  (_b = this._messages).push.apply(_b, best._messages);
66928
67476
  }
66929
67477
  };
66930
- DetailContext2.prototype.getError = function(path87) {
67478
+ DetailContext2.prototype.getError = function(path90) {
66931
67479
  var msgParts = [];
66932
67480
  for (var i = this._propNames.length - 1; i >= 0; i--) {
66933
67481
  var p2 = this._propNames[i];
66934
- path87 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67482
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
66935
67483
  var m = this._messages[i];
66936
67484
  if (m) {
66937
- msgParts.push(path87 + " " + m);
67485
+ msgParts.push(path90 + " " + m);
66938
67486
  }
66939
67487
  }
66940
- return new VError(path87, msgParts.join("; "));
67488
+ return new VError(path90, msgParts.join("; "));
66941
67489
  };
66942
- DetailContext2.prototype.getErrorDetail = function(path87) {
67490
+ DetailContext2.prototype.getErrorDetail = function(path90) {
66943
67491
  var details = [];
66944
67492
  for (var i = this._propNames.length - 1; i >= 0; i--) {
66945
67493
  var p2 = this._propNames[i];
66946
- path87 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67494
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
66947
67495
  var message = this._messages[i];
66948
67496
  if (message) {
66949
- details.push({ path: path87, message });
67497
+ details.push({ path: path90, message });
66950
67498
  }
66951
67499
  }
66952
67500
  var detail = null;
@@ -67759,8 +68307,8 @@ var require_dist = __commonJS({
67759
68307
  this.checkerPlain = this.ttype.getChecker(suite, false);
67760
68308
  this.checkerStrict = this.ttype.getChecker(suite, true);
67761
68309
  }
67762
- Checker2.prototype.setReportedPath = function(path87) {
67763
- this._path = path87;
68310
+ Checker2.prototype.setReportedPath = function(path90) {
68311
+ this._path = path90;
67764
68312
  };
67765
68313
  Checker2.prototype.check = function(value) {
67766
68314
  return this._doCheck(this.checkerPlain, value);
@@ -73193,9 +73741,9 @@ var require_CJSImportTransformer = __commonJS({
73193
73741
  if (shouldElideImport) {
73194
73742
  this.tokens.removeToken();
73195
73743
  } else {
73196
- const path87 = this.tokens.stringValue();
73197
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path87));
73198
- this.tokens.appendCode(this.importProcessor.claimImportCode(path87));
73744
+ const path90 = this.tokens.stringValue();
73745
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
73746
+ this.tokens.appendCode(this.importProcessor.claimImportCode(path90));
73199
73747
  }
73200
73748
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
73201
73749
  if (this.tokens.matches1(_types.TokenType.semi)) {
@@ -73775,8 +74323,8 @@ var require_CJSImportTransformer = __commonJS({
73775
74323
  }
73776
74324
  if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
73777
74325
  this.tokens.removeToken();
73778
- const path87 = this.tokens.stringValue();
73779
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path87));
74326
+ const path90 = this.tokens.stringValue();
74327
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
73780
74328
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
73781
74329
  } else {
73782
74330
  this.tokens.appendCode(exportStatements.join(" "));
@@ -73790,8 +74338,8 @@ var require_CJSImportTransformer = __commonJS({
73790
74338
  while (!this.tokens.matches1(_types.TokenType.string)) {
73791
74339
  this.tokens.removeToken();
73792
74340
  }
73793
- const path87 = this.tokens.stringValue();
73794
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path87));
74341
+ const path90 = this.tokens.stringValue();
74342
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
73795
74343
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
73796
74344
  if (this.tokens.matches1(_types.TokenType.semi)) {
73797
74345
  this.tokens.removeToken();
@@ -103645,9 +104193,9 @@ var init_bundle_mjs = __esm({
103645
104193
  processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
103646
104194
  }
103647
104195
  };
103648
- getPart = (classPartObject, path87) => {
104196
+ getPart = (classPartObject, path90) => {
103649
104197
  let current = classPartObject;
103650
- const parts = path87.split(CLASS_PART_SEPARATOR);
104198
+ const parts = path90.split(CLASS_PART_SEPARATOR);
103651
104199
  const len = parts.length;
103652
104200
  for (let i = 0; i < len; i++) {
103653
104201
  const part = parts[i];
@@ -106897,8 +107445,8 @@ var init_dist = __esm({
106897
107445
  });
106898
107446
 
106899
107447
  // ../cli/src/lib/draw-mockup.ts
106900
- import fs79 from "node:fs";
106901
- import path81 from "node:path";
107448
+ import fs82 from "node:fs";
107449
+ import path84 from "node:path";
106902
107450
  import vm from "node:vm";
106903
107451
  async function loadPackage(id) {
106904
107452
  if (id === "react") return import_react3.default;
@@ -106911,22 +107459,22 @@ async function loadPackage(id) {
106911
107459
  return { __esModule: true, ...await load() };
106912
107460
  }
106913
107461
  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());
107462
+ const at2 = path84.resolve(path84.dirname(from), id);
107463
+ if (at2 !== folder && !at2.startsWith(folder + path84.sep)) throw new Error(`${id} is outside the mockup's folder`);
107464
+ const tries = path84.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path84.join(at2, `index${e2}`))];
107465
+ const file = tries.find((f2) => fs82.statSync(f2, { throwIfNoEntry: false })?.isFile());
106918
107466
  if (!file) throw new Error(`no such file: ${id}`);
106919
107467
  return file;
106920
107468
  }
106921
107469
  async function readGraph(entry) {
106922
- const folder = path81.dirname(entry);
107470
+ const folder = path84.dirname(entry);
106923
107471
  const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
106924
107472
  const walk3 = async (file) => {
106925
107473
  if (graph.code.has(file)) return;
106926
107474
  if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
106927
107475
  let location = file;
106928
107476
  try {
106929
- const js = (0, import_sucrase.transform)(fs79.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
107477
+ const js = (0, import_sucrase.transform)(fs82.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
106930
107478
  graph.code.set(file, js);
106931
107479
  const link2 = /* @__PURE__ */ new Map();
106932
107480
  graph.links.set(file, link2);
@@ -106940,7 +107488,7 @@ async function readGraph(entry) {
106940
107488
  const target = resolveFile(id, file, folder);
106941
107489
  link2.set(id, target);
106942
107490
  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") });
107491
+ else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs82.readFileSync(target, "utf8") });
106944
107492
  }
106945
107493
  } catch (error) {
106946
107494
  throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
@@ -106957,29 +107505,17 @@ function run2(script, context, name, deadline, lineOffset = 0) {
106957
107505
  async function tailwindFor(markup, sheets) {
106958
107506
  const source = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
106959
107507
  const compiler = await rc(source, {
106960
- base: sheets.length ? path81.dirname(sheets[0].path) : "/",
107508
+ base: sheets.length ? path84.dirname(sheets[0].path) : "/",
106961
107509
  loadStylesheet: async (id, from) => {
106962
107510
  if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
106963
107511
  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") };
107512
+ const at2 = path84.resolve(from, id);
107513
+ return { path: at2, base: path84.dirname(at2), content: fs82.readFileSync(at2, "utf8") };
106966
107514
  }
106967
107515
  });
106968
107516
  const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
106969
107517
  return compiler.build(classes.filter(Boolean));
106970
107518
  }
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
107519
  async function drawMockup(entry) {
106984
107520
  if (entry.toLowerCase().endsWith(".html")) return dressPage(entry);
106985
107521
  const graph = await readGraph(entry);
@@ -107026,7 +107562,7 @@ ${graph.code.get(file)}
107026
107562
  const css = (await tailwindFor(markup, graph.sheets)).replace(/<\/style/gi, "<\\/style");
107027
107563
  return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
107028
107564
  }
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;
107565
+ var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES;
107030
107566
  var init_draw_mockup = __esm({
107031
107567
  "../cli/src/lib/draw-mockup.ts"() {
107032
107568
  "use strict";
@@ -107036,6 +107572,7 @@ var init_draw_mockup = __esm({
107036
107572
  import_sucrase = __toESM(require_dist2(), 1);
107037
107573
  init_lib();
107038
107574
  init_tailwindcss();
107575
+ init_dress_page();
107039
107576
  DRAW_MS = 5e3;
107040
107577
  MAX_FILES = 60;
107041
107578
  CODE_EXTS = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
@@ -107078,14 +107615,12 @@ var init_draw_mockup = __esm({
107078
107615
  "tailwind-merge": () => Promise.resolve().then(() => (init_bundle_mjs(), bundle_mjs_exports)),
107079
107616
  "class-variance-authority": () => Promise.resolve().then(() => (init_dist(), dist_exports))
107080
107617
  };
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
107618
  }
107084
107619
  });
107085
107620
 
107086
107621
  // ../cli/src/lib/preview-validation.ts
107087
- import fs80 from "node:fs";
107088
- import path82 from "node:path";
107622
+ import fs83 from "node:fs";
107623
+ import path85 from "node:path";
107089
107624
  function renderError(error) {
107090
107625
  if (!error || typeof error !== "object") return String(error);
107091
107626
  const { message, stack } = error;
@@ -107096,7 +107631,7 @@ function renderError(error) {
107096
107631
  async function validateScreens(files2) {
107097
107632
  const errors = [];
107098
107633
  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));
107634
+ for (const file of files2) entries.set(fs83.existsSync(file) ? fs83.realpathSync(file) : path85.resolve(file), path85.resolve(file));
107100
107635
  for (const file of entries.values()) {
107101
107636
  try {
107102
107637
  await drawMockup(file);
@@ -107115,7 +107650,7 @@ async function validatePreview(file, text5) {
107115
107650
  if (/^ {0,3}<!--\s*agent\s*-->\s*$/.test(line)) own = false;
107116
107651
  if (own) section.push(line);
107117
107652
  }
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));
107653
+ 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
107654
  return validateScreens(files2);
107120
107655
  }
107121
107656
  var init_preview_validation = __esm({
@@ -107272,7 +107807,7 @@ __export(watch_exports, {
107272
107807
  watchRun: () => watchRun
107273
107808
  });
107274
107809
  import { spawn as spawn4 } from "node:child_process";
107275
- import fs81 from "node:fs";
107810
+ import fs84 from "node:fs";
107276
107811
  async function watchRun(sessionId, resume = startResume) {
107277
107812
  const spec = readSpec(sessionId);
107278
107813
  const run3 = peekRun(sessionId);
@@ -107308,11 +107843,11 @@ async function watchRun(sessionId, resume = startResume) {
107308
107843
  const record = claimed ?? run3;
107309
107844
  const sub = record.action === "sub";
107310
107845
  if (claim) await setCardStatus(claim.cardId, claim.status);
107311
- fs81.mkdirSync(SESSIONS_DIR, { recursive: true });
107312
- const logFile = fs81.createWriteStream(record.logPath, { flags: "a" });
107846
+ fs84.mkdirSync(SESSIONS_DIR, { recursive: true });
107847
+ const logFile = fs84.createWriteStream(record.logPath, { flags: "a" });
107313
107848
  logFile.on("error", () => {
107314
107849
  });
107315
- const eventsFile = fs81.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107850
+ const eventsFile = fs84.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107316
107851
  eventsFile.on("error", () => {
107317
107852
  });
107318
107853
  const event2 = (e2) => eventsFile.write(`${JSON.stringify(e2)}
@@ -107791,8 +108326,8 @@ function brokeBoard(wasBroken) {
107791
108326
  if (!broke.length) return null;
107792
108327
  const shown = broke.slice(0, MAX_BROKEN);
107793
108328
  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: [
108329
+ const why2 = { kind: "broken", args: { n: String(broke.length), more: String(rest) }, lines: shown };
108330
+ return { why: why2, note: [
107796
108331
  `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
108332
  ...shown.map((line) => ` ${line}`),
107798
108333
  ...rest ? [` \u2026 and ${rest} more`] : [],
@@ -107906,7 +108441,7 @@ var init_watch = __esm({
107906
108441
  });
107907
108442
 
107908
108443
  // ../cli/src/kanban.ts
107909
- import fs87 from "node:fs";
108444
+ import fs90 from "node:fs";
107910
108445
  import { fileURLToPath as fileURLToPath4 } from "node:url";
107911
108446
 
107912
108447
  // ../cli/src/lib/cli/agent.ts
@@ -108389,8 +108924,8 @@ async function testAgent(args) {
108389
108924
  }
108390
108925
 
108391
108926
  // ../cli/src/commands/cloud.ts
108392
- import fs70 from "node:fs";
108393
- import path71 from "node:path";
108927
+ import fs72 from "node:fs";
108928
+ import path73 from "node:path";
108394
108929
 
108395
108930
  // ../cli/src/lib/cloud/avatar.ts
108396
108931
  init_session();
@@ -108438,13 +108973,13 @@ init_config();
108438
108973
  init_home();
108439
108974
  init_config();
108440
108975
  init_session();
108441
- import fs69 from "node:fs";
108442
- import path70 from "node:path";
108976
+ import fs71 from "node:fs";
108977
+ import path72 from "node:path";
108443
108978
  var FRESH_MS2 = 10 * 6e4;
108444
108979
  var GRACE_MS = 7 * 24 * 60 * 6e4;
108445
- var heldFile = () => path70.join(machineHome(), "pro.json");
108980
+ var heldFile = () => path72.join(machineHome(), "pro.json");
108446
108981
  function forgetPro() {
108447
- fs69.rmSync(heldFile(), { force: true });
108982
+ fs71.rmSync(heldFile(), { force: true });
108448
108983
  }
108449
108984
 
108450
108985
  // ../cli/src/lib/cloud/account.ts
@@ -108621,10 +109156,10 @@ async function cloudImage(opts, program2) {
108621
109156
  const prompt = opts.prompt.trim();
108622
109157
  if (!prompt) usage("Missing the prompt.", line);
108623
109158
  const references = opts.refs.map((file) => {
108624
- const type = REF_TYPES[path71.extname(file).toLowerCase()];
109159
+ const type = REF_TYPES[path73.extname(file).toLowerCase()];
108625
109160
  if (!type) usage(`--ref ${file}: use a PNG, JPEG or WebP file.`, line);
108626
109161
  try {
108627
- return `data:${type};base64,${fs70.readFileSync(file).toString("base64")}`;
109162
+ return `data:${type};base64,${fs72.readFileSync(file).toString("base64")}`;
108628
109163
  } catch (e2) {
108629
109164
  usage(`--ref ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`, line);
108630
109165
  }
@@ -108730,8 +109265,8 @@ async function generate(g3) {
108730
109265
  refuse(g3.failed, g3.fallback);
108731
109266
  }
108732
109267
  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()));
109268
+ fs72.mkdirSync(path73.dirname(path73.resolve(out)), { recursive: true });
109269
+ fs72.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
108735
109270
  say(`${out} (${g3.label(res)})`);
108736
109271
  return { out };
108737
109272
  }
@@ -108740,35 +109275,35 @@ async function generate(g3) {
108740
109275
  init_board_files();
108741
109276
  init_workflow_files();
108742
109277
  import crypto6 from "node:crypto";
108743
- import fs72 from "node:fs";
108744
- import path73 from "node:path";
109278
+ import fs74 from "node:fs";
109279
+ import path75 from "node:path";
108745
109280
 
108746
109281
  // ../cli/src/lib/agents/shared-memory.ts
108747
109282
  init_bundled();
108748
109283
  init_parse();
108749
- import fs71 from "node:fs";
108750
- import path72 from "node:path";
109284
+ import fs73 from "node:fs";
109285
+ import path74 from "node:path";
108751
109286
  function sharedMemory(board2) {
108752
109287
  const declared = /* @__PURE__ */ new Map();
108753
109288
  const take = (folder, text5, builtIn) => {
108754
109289
  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);
109290
+ const read5 = parseSpecAgent(text5, folder, () => null, builtIn);
109291
+ if ("agent" in read5 && read5.agent.name === folder) declared.set(folder, read5.agent.memoryFiles.workspace);
108757
109292
  };
108758
109293
  for (const [key, text5] of Object.entries(shippedAgentFiles())) {
108759
109294
  const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
108760
109295
  if (at2) take(at2[1], text5, officialAgent(at2[1]));
108761
109296
  }
108762
- const root2 = path72.join(board2, "agents");
109297
+ const root2 = path74.join(board2, "agents");
108763
109298
  let folders2 = [];
108764
109299
  try {
108765
- folders2 = fs71.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
109300
+ folders2 = fs73.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
108766
109301
  } catch {
108767
109302
  }
108768
109303
  for (const folder of folders2.sort()) {
108769
109304
  let text5 = null;
108770
109305
  try {
108771
- text5 = fs71.readFileSync(path72.join(root2, folder, "AGENT.md"), "utf8");
109306
+ text5 = fs73.readFileSync(path74.join(root2, folder, "AGENT.md"), "utf8");
108772
109307
  } catch {
108773
109308
  }
108774
109309
  take(folder, text5, false);
@@ -108858,27 +109393,27 @@ async function findProject(asked) {
108858
109393
  }
108859
109394
  throw new Refused(`No project of yours has the id or prefix "${asked}".`, "not_found");
108860
109395
  }
108861
- var read = (file) => fs72.readFileSync(file, "utf8");
109396
+ var read2 = (file) => fs74.readFileSync(file, "utf8");
108862
109397
  var bytes2 = (text5) => Buffer.byteLength(text5, "utf8");
108863
109398
  function files(dir) {
108864
- if (!fs72.existsSync(dir)) return [];
109399
+ if (!fs74.existsSync(dir)) return [];
108865
109400
  const out = [];
108866
- for (const entry of fs72.readdirSync(dir, { withFileTypes: true })) {
109401
+ for (const entry of fs74.readdirSync(dir, { withFileTypes: true })) {
108867
109402
  if (entry.name.startsWith(".")) continue;
108868
- const full = path73.join(dir, entry.name);
109403
+ const full = path75.join(dir, entry.name);
108869
109404
  if (entry.isDirectory()) out.push(...files(full));
108870
109405
  else if (entry.isFile()) out.push(full);
108871
109406
  }
108872
109407
  return out;
108873
109408
  }
108874
- var posix = (p2) => p2.split(path73.sep).join("/");
109409
+ var posix = (p2) => p2.split(path75.sep).join("/");
108875
109410
  function openCards() {
108876
109411
  const out = [];
108877
109412
  for (const file of walkMd(TODO)) {
108878
- const rel2 = posix(path73.relative(TODO, file));
109413
+ const rel2 = posix(path75.relative(TODO, file));
108879
109414
  if (rel2 === "README.md") continue;
108880
109415
  const parts = rel2.split("/");
108881
- const text5 = read(file);
109416
+ const text5 = read2(file);
108882
109417
  const meta = parseFrontmatter(text5).meta;
108883
109418
  if (!meta) continue;
108884
109419
  const name = parts[parts.length - 1];
@@ -108962,12 +109497,12 @@ function draftsOf(text5) {
108962
109497
  const at2 = /^\.(assets|mockups)\/(.+)$/.exec(name);
108963
109498
  if (!at2) continue;
108964
109499
  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);
109500
+ const file = path75.resolve(base, at2[2]);
109501
+ if (file.startsWith(base + path75.sep) && fs74.statSync(file, { throwIfNoEntry: false })?.isFile()) out.set(name, file);
108967
109502
  }
108968
109503
  return [...out].map(([name, file]) => ({ name, file }));
108969
109504
  }
108970
- var TYPES = {
109505
+ var TYPES2 = {
108971
109506
  ".png": "image/png",
108972
109507
  ".jpg": "image/jpeg",
108973
109508
  ".jpeg": "image/jpeg",
@@ -108984,10 +109519,10 @@ var TYPES = {
108984
109519
  ".wav": "audio/wav",
108985
109520
  ".json": "application/json"
108986
109521
  };
108987
- function kindOf(ext) {
109522
+ function kindOf2(ext) {
108988
109523
  if (ext === ".html") return "html";
108989
109524
  if (ext === ".md" || ext === ".mdx") return "markdown";
108990
- const type = TYPES[ext] ?? "";
109525
+ const type = TYPES2[ext] ?? "";
108991
109526
  if (type.startsWith("image/")) return "image";
108992
109527
  return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
108993
109528
  }
@@ -108997,10 +109532,10 @@ async function uploadDrafts(task, drafts) {
108997
109532
  const assets = {};
108998
109533
  for (const { name, file } of drafts) {
108999
109534
  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) });
109535
+ const ext = path75.extname(file).toLowerCase();
109536
+ const type = TYPES2[ext] ?? "application/octet-stream";
109537
+ const data = fs74.readFileSync(file);
109538
+ const artifact = await api("POST", `/v1/tasks/${task}/artifacts`, { type: kindOf2(ext), name: name.slice(0, 200) });
109004
109539
  const upload = await api("POST", `/v1/artifacts/${artifact.id}/uploads`, { content_type: type, size: Math.max(data.length, 1) });
109005
109540
  await api("PUT", `/v1/uploads/${upload.id}`, void 0, { bytes: data, type });
109006
109541
  const version = await api("POST", `/v1/artifacts/${artifact.id}/versions`, { upload: upload.id });
@@ -109042,7 +109577,7 @@ usage: ${program2} cloud import --project <id or prefix> [--dry-run]`, { kind: "
109042
109577
  function localWorkflowFolders() {
109043
109578
  let folders2;
109044
109579
  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 }));
109580
+ 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
109581
  } catch {
109047
109582
  return [];
109048
109583
  }
@@ -109053,19 +109588,19 @@ function localWorkflowFolders() {
109053
109588
  });
109054
109589
  }
109055
109590
  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))];
109591
+ return fs74.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
109592
+ const full = path75.join(dir, e2.name);
109593
+ return e2.isDirectory() ? filesUnder(full, base) : [posix(path75.relative(base, full))];
109059
109594
  });
109060
109595
  }
109061
109596
  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")]));
109597
+ const dir = path75.join(WORKFLOWS, id);
109598
+ const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2, fs74.readFileSync(path75.join(dir, f2), "utf8")]));
109064
109599
  const named2 = [...def.previews, ...def.land, ...def.scheduled].map((h3) => h3.agent).filter((a2) => !LAND_ROLES2.includes(a2));
109065
109600
  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");
109601
+ const at2 = path75.join(AGENTS, agent);
109602
+ if (fs74.existsSync(path75.join(at2, "AGENT.md"))) {
109603
+ for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] = fs74.readFileSync(path75.join(at2, file), "utf8");
109069
109604
  continue;
109070
109605
  }
109071
109606
  for (const [key, text5] of Object.entries(shipped)) if (key.startsWith(`${agent}/`)) out[`agents/${key}`] = text5;
@@ -109075,10 +109610,10 @@ function packLocalWorkflow(id, def, shipped) {
109075
109610
  async function run(asked, dryRun) {
109076
109611
  const project = await findProject(asked);
109077
109612
  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);
109613
+ const board2 = crypto6.createHash("sha256").update(fs74.realpathSync(KANBAN)).digest("hex").slice(0, 16);
109079
109614
  const cards = openCards();
109080
109615
  const problems = [];
109081
- const where = (file) => posix(path73.relative(KANBAN, file));
109616
+ const where = (file) => posix(path75.relative(KANBAN, file));
109082
109617
  const own = [];
109083
109618
  for (const f2 of localWorkflowFolders()) {
109084
109619
  if (f2.def) own.push({ id: f2.id, name: f2.def.name, def: f2.def });
@@ -109107,10 +109642,10 @@ async function run(asked, dryRun) {
109107
109642
  const root2 = `projects/${project.id}/`;
109108
109643
  const boardFiles = [];
109109
109644
  for (const file of [...files(MEMORY), ...files(RULES), CONFIG, MODULES_MD]) {
109110
- if (!fs72.existsSync(file)) continue;
109645
+ if (!fs74.existsSync(file)) continue;
109111
109646
  const rel2 = where(file);
109112
109647
  if (!isBoardPath(rel2)) continue;
109113
- const content = read(file);
109648
+ const content = read2(file);
109114
109649
  if (bytes2(content) > BOARD_FILE_LIMIT) {
109115
109650
  problems.push({ file: rel2, reason: { zh: "\u8D85\u8FC7 256 KB", en: "over 256 KB" } });
109116
109651
  continue;
@@ -109218,16 +109753,16 @@ async function run(asked, dryRun) {
109218
109753
  }
109219
109754
  function leftLocal(own) {
109220
109755
  const out = [];
109221
- const count4 = (dir) => fs72.existsSync(dir) ? walkMd(dir).length : 0;
109756
+ const count4 = (dir) => fs74.existsSync(dir) ? walkMd(dir).length : 0;
109222
109757
  const archived = count4(ARCHIVE);
109223
109758
  if (archived) out.push(`.archive/ (${archived})`);
109224
109759
  const triage = count4(TRIAGE);
109225
109760
  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");
109761
+ if (fs74.existsSync(DELIVERIES)) out.push("deliveries/");
109762
+ if (fs74.existsSync(path75.join(KANBAN, "metrics.csv"))) out.push("metrics.csv");
109228
109763
  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 })) {
109764
+ if (fs74.existsSync(AGENTS)) {
109765
+ for (const e2 of fs74.readdirSync(AGENTS, { withFileTypes: true })) {
109231
109766
  if (e2.isDirectory() && !e2.name.startsWith(".") && !named2.has(e2.name)) out.push(`agents/${e2.name}/`);
109232
109767
  }
109233
109768
  }
@@ -109245,8 +109780,8 @@ init_session();
109245
109780
  init_io();
109246
109781
  init_paths();
109247
109782
  import { createHash as createHash5 } from "node:crypto";
109248
- import fs73 from "node:fs";
109249
- import path74 from "node:path";
109783
+ import fs75 from "node:fs";
109784
+ import path76 from "node:path";
109250
109785
  var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
109251
109786
  var CAPTURED = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/;
109252
109787
  var MAX_BYTES3 = 50 * 1024 * 1024;
@@ -109345,10 +109880,10 @@ This template has no preview.`);
109345
109880
  const written = [];
109346
109881
  for (const p2 of previews) {
109347
109882
  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);
109883
+ const file = path76.basename(p2.path);
109884
+ const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
109885
+ fs75.mkdirSync(opts.to, { recursive: true });
109886
+ fs75.writeFileSync(out, bytes3);
109352
109887
  written.push(out);
109353
109888
  say(out);
109354
109889
  }
@@ -109361,15 +109896,15 @@ async function templateGet(name, opts, program2) {
109361
109896
  const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
109362
109897
  const fetched = [];
109363
109898
  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);
109899
+ const out = path76.resolve(to, f2.path);
109900
+ if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse2(T.corrupt, WITHOUT);
109366
109901
  const bytes3 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
109367
109902
  if (bytes3.byteLength !== f2.size || createHash5("sha256").update(bytes3).digest("hex") !== f2.sha256) {
109368
109903
  refuse2(T.corrupt, WITHOUT);
109369
109904
  }
109370
109905
  fetched.push({ out, bytes: bytes3 });
109371
109906
  }
109372
- const taken = fetched.filter((f2) => fs73.existsSync(f2.out)).map((f2) => path74.relative(to, f2.out));
109907
+ const taken = fetched.filter((f2) => fs75.existsSync(f2.out)).map((f2) => path76.relative(to, f2.out));
109373
109908
  if (taken.length > 0) {
109374
109909
  refuse2({
109375
109910
  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 +109912,8 @@ async function templateGet(name, opts, program2) {
109377
109912
  });
109378
109913
  }
109379
109914
  for (const f2 of fetched) {
109380
- fs73.mkdirSync(path74.dirname(f2.out), { recursive: true });
109381
- fs73.writeFileSync(f2.out, f2.bytes);
109915
+ fs75.mkdirSync(path76.dirname(f2.out), { recursive: true });
109916
+ fs75.writeFileSync(f2.out, f2.bytes);
109382
109917
  }
109383
109918
  say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
109384
109919
  Fetched ${name}: ${fetched.length} files into ${to}`);
@@ -109396,25 +109931,25 @@ async function templateSource(name, opts) {
109396
109931
  say(`evidence: ${e2.path}`);
109397
109932
  continue;
109398
109933
  }
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()));
109934
+ const out = path76.join(opts.to, `${name}-${path76.basename(e2.path)}`);
109935
+ fs75.mkdirSync(opts.to, { recursive: true });
109936
+ fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
109402
109937
  written.push(out);
109403
109938
  say(out);
109404
109939
  }
109405
109940
  return { name, source, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
109406
109941
  }
109407
109942
  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"));
109943
+ const root2 = path76.resolve(dir);
109944
+ const manifest = path76.join(root2, "template.md");
109945
+ 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.");
109946
+ const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
109412
109947
  const files2 = walk2(root2);
109413
- const total = files2.reduce((sum, f2) => sum + fs73.statSync(path74.join(root2, f2)).size, 0);
109948
+ const total = files2.reduce((sum, f2) => sum + fs75.statSync(path76.join(root2, f2)).size, 0);
109414
109949
  if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
109415
109950
  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)) {
109951
+ if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
109952
+ if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
109418
109953
  invalid(
109419
109954
  `${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
109955
  `${extra} is inside the template folder; keep previews and evidence outside it.`
@@ -109426,10 +109961,10 @@ async function templatePublish(dir, opts) {
109426
109961
  }
109427
109962
  const form = new FormData();
109428
109963
  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);
109964
+ const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
109965
+ for (const f2 of files2) add("files", f2, path76.join(root2, f2));
109966
+ for (const f2 of opts.preview) add("previews", path76.basename(f2), f2);
109967
+ for (const f2 of opts.evidence) add("evidence", path76.basename(f2), f2);
109433
109968
  const done2 = await asJson(await ask("", { method: "POST", body: form }));
109434
109969
  say(
109435
109970
  done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files2.length} \u4E2A\u6587\u4EF6\u3002
@@ -109445,11 +109980,11 @@ Deleted ${name} from the catalog.`);
109445
109980
  return { name, deleted: true };
109446
109981
  }
109447
109982
  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}.`);
109983
+ const file = path76.join(dir, "showcase.json");
109984
+ if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
109450
109985
  let meta;
109451
109986
  try {
109452
- meta = JSON.parse(fs73.readFileSync(file, "utf8"));
109987
+ meta = JSON.parse(fs75.readFileSync(file, "utf8"));
109453
109988
  } catch {
109454
109989
  return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
109455
109990
  }
@@ -109461,9 +109996,9 @@ async function templateShowcase(name, dir) {
109461
109996
  const form = new FormData();
109462
109997
  form.set("meta", JSON.stringify(meta));
109463
109998
  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);
109999
+ const at2 = path76.join(dir, p2);
110000
+ if (!fs75.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
110001
+ form.append(`media:${p2}`, new Blob([fs75.readFileSync(at2)]), p2);
109467
110002
  }
109468
110003
  const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
109469
110004
  say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
@@ -109472,7 +110007,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
109472
110007
  }
109473
110008
  function walk2(root2, sub = "") {
109474
110009
  const out = [];
109475
- for (const entry of fs73.readdirSync(path74.join(root2, sub), { withFileTypes: true })) {
110010
+ for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
109476
110011
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
109477
110012
  const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
109478
110013
  if (entry.isDirectory()) out.push(...walk2(root2, rel2));
@@ -109622,10 +110157,15 @@ function cmdGuide(topic, program2 = "akb") {
109622
110157
  }
109623
110158
 
109624
110159
  // ../cli/src/commands/workflow.ts
110160
+ init_agents();
110161
+ init_cards();
109625
110162
  init_io();
109626
110163
  init_paths();
110164
+ init_workflow_diagram();
109627
110165
  init_cloud_workflows();
109628
110166
  init_workflows();
110167
+ import fs76 from "node:fs";
110168
+ import path77 from "node:path";
109629
110169
  var found = (id) => {
109630
110170
  const flow = workflowById(id);
109631
110171
  if (!flow) {
@@ -109685,6 +110225,22 @@ function cmdWorkflowRename(id, name) {
109685
110225
  say(`renamed ${id} to "${name.trim()}"`);
109686
110226
  return { id, name: name.trim() };
109687
110227
  }
110228
+ function cmdWorkflowDiagram(id, card) {
110229
+ const flow = found(id);
110230
+ const cardId2 = Number(card);
110231
+ if (!Number.isInteger(cardId2) || !locate(cardId2)) die(`no card #${card} on this board`, "no-such-card");
110232
+ const diagram = workflowDiagram({ previews: previewMembers(flow), land: flow.land, scheduled: scheduledMembers(flow) }, (name) => {
110233
+ const agent = findSpecAgent(name);
110234
+ return agent ? { ...agent, after: agentAfter(name) } : null;
110235
+ });
110236
+ const file = path77.join(ASSETS, String(cardId2), "workflow.json");
110237
+ fs76.mkdirSync(path77.dirname(file), { recursive: true });
110238
+ fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
110239
+ `);
110240
+ const tag = `<Workflow src=".assets/${cardId2}/workflow.json" label="${flow.name.replace(/"/g, "")}" />`;
110241
+ say(tag);
110242
+ return { file, tag, diagram };
110243
+ }
109688
110244
 
109689
110245
  // ../cli/src/commands/run.ts
109690
110246
  init_progress();
@@ -109835,7 +110391,7 @@ init_opencode();
109835
110391
  init_locate();
109836
110392
  init_store();
109837
110393
  import { spawnSync as spawnSync5 } from "node:child_process";
109838
- import path80 from "node:path";
110394
+ import path83 from "node:path";
109839
110395
  var AGENTS2 = {
109840
110396
  claude: "claude-code",
109841
110397
  codex: "codex",
@@ -109850,10 +110406,10 @@ var AGENTS2 = {
109850
110406
  var RUNTIMES = /* @__PURE__ */ new Set(["node", "bun", "deno"]);
109851
110407
  function agentOf2(args) {
109852
110408
  const words = args.trim().split(/\s+/);
109853
- const first = path80.basename(words[0] ?? "");
110409
+ const first = path83.basename(words[0] ?? "");
109854
110410
  const script = RUNTIMES.has(first) ? words[1] ?? "" : words[0] ?? "";
109855
110411
  if (script.includes("/@anthropic-ai/claude-code/")) return "claude-code";
109856
- return AGENTS2[path80.basename(script).replace(/\.(m?js|cjs|exe)$/, "")];
110412
+ return AGENTS2[path83.basename(script).replace(/\.(m?js|cjs|exe)$/, "")];
109857
110413
  }
109858
110414
  function processChain() {
109859
110415
  if (process.platform === "win32") return [];
@@ -109917,8 +110473,8 @@ init_tasks();
109917
110473
  init_read();
109918
110474
  init_rules();
109919
110475
  init_board();
109920
- import fs82 from "node:fs";
109921
- import path83 from "node:path";
110476
+ import fs85 from "node:fs";
110477
+ import path86 from "node:path";
109922
110478
  var FOLLOW_MS = 400;
109923
110479
  async function cmdStartRun(action, args, opts, program2 = "akb") {
109924
110480
  const { req, follow: follow2, print } = readRequest(action, args, opts);
@@ -110005,8 +110561,8 @@ async function approveInCloud(project, id) {
110005
110561
  say(`approved #${id} in Cloud`);
110006
110562
  return { id, task: approved.value.key, approved: true };
110007
110563
  }
110008
- async function cmdReject(id, why, opts) {
110009
- const reason = why.trim();
110564
+ async function cmdReject(id, why2, opts) {
110565
+ const reason = why2.trim();
110010
110566
  const discard = opts.discard === true;
110011
110567
  if (!discard && !reason) die("say why the card is being dropped, or pass --discard to just drop it");
110012
110568
  const res = await rejectCard(id, { reason, discard }, true);
@@ -110166,7 +110722,7 @@ async function cmdSubStart(words, opts) {
110166
110722
  let prompt = words.join(" ");
110167
110723
  if (opts.file) {
110168
110724
  try {
110169
- prompt = fs82.readFileSync(path83.resolve(opts.file), "utf8");
110725
+ prompt = fs85.readFileSync(path86.resolve(opts.file), "utf8");
110170
110726
  } catch {
110171
110727
  die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
110172
110728
  }
@@ -110457,7 +111013,7 @@ function cmdCompleteDelivery(id, options) {
110457
111013
  // ../cli/src/commands/triage.ts
110458
111014
  init_scheduled();
110459
111015
  init_workflows();
110460
- import fs84 from "node:fs";
111016
+ import fs87 from "node:fs";
110461
111017
 
110462
111018
  // ../cli/src/lib/signals/index.ts
110463
111019
  init_cards();
@@ -110467,16 +111023,16 @@ init_yaml();
110467
111023
  // ../cli/src/lib/signals/config.ts
110468
111024
  init_settings2();
110469
111025
  init_paths();
110470
- import fs83 from "node:fs";
110471
- import path84 from "node:path";
111026
+ import fs86 from "node:fs";
111027
+ import path87 from "node:path";
110472
111028
  var TOKEN_KEY = "TRIAGE_ENDPOINT_TOKEN";
110473
111029
  var ENDPOINT_SETTING = "Triage endpoint";
110474
111030
  var LINE2 = /^- \*\*Triage endpoint\*\*\s*[—-]\s*(.+)$/m;
110475
- var boardRel3 = (file) => rel(file).split(path84.sep).join("/");
111031
+ var boardRel3 = (file) => rel(file).split(path87.sep).join("/");
110476
111032
  function signalEndpoint() {
110477
111033
  let text5;
110478
111034
  try {
110479
- text5 = fs83.readFileSync(CONFIG, "utf8");
111035
+ text5 = fs86.readFileSync(CONFIG, "utf8");
110480
111036
  } catch {
110481
111037
  return "";
110482
111038
  }
@@ -110520,7 +111076,7 @@ function readMeta(sent) {
110520
111076
  }
110521
111077
  return pairs;
110522
111078
  }
110523
- function read2(raw) {
111079
+ function read3(raw) {
110524
111080
  const missing = REQUIRED.filter((field2) => !text4(raw[field2]));
110525
111081
  if (missing.length > 0) return { ok: false, why: `missing ${missing.join(", ")}` };
110526
111082
  const sent = text4(raw.collected_at);
@@ -110570,8 +111126,8 @@ async function fetchSignals() {
110570
111126
  });
110571
111127
  } catch (e2) {
110572
111128
  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" });
111129
+ const why2 = late ? `did not answer within ${ANSWER_BY_MS2 / 1e3}s` : `could not be reached: ${e2 instanceof Error ? e2.message : String(e2)}`;
111130
+ die(`${endpoint2} ${why2}`, { kind: "triage-unreachable" });
110575
111131
  }
110576
111132
  if (!response.ok) {
110577
111133
  die(`${endpoint2} answered ${response.status}.`, { kind: "triage-endpoint-refused" });
@@ -110596,7 +111152,7 @@ async function fetchSignals() {
110596
111152
  report3.failed.push({ which: `item ${at2 + 1}`, why: "not an object" });
110597
111153
  return;
110598
111154
  }
110599
- const found2 = read2(raw);
111155
+ const found2 = read3(raw);
110600
111156
  if (!found2.ok) {
110601
111157
  report3.failed.push({ which: text4(raw.source_id) || `item ${at2 + 1}`, why: found2.why });
110602
111158
  return;
@@ -110652,7 +111208,7 @@ async function cmdTriageAdd(opts) {
110652
111208
  let body = opts.text;
110653
111209
  if (opts.file !== void 0) {
110654
111210
  try {
110655
- body = fs84.readFileSync(opts.file, "utf8");
111211
+ body = fs87.readFileSync(opts.file, "utf8");
110656
111212
  } catch {
110657
111213
  die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
110658
111214
  }
@@ -110688,13 +111244,13 @@ function cmdTriageArchive(sourceId, cardId2) {
110688
111244
  function cmdTriageDismiss(sourceId, reason) {
110689
111245
  const said3 = sourceId.trim();
110690
111246
  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" });
111247
+ const why2 = reason.trim();
111248
+ if (!why2) die('say why it is being ignored: --reason "<why>"', { kind: "needs-input" });
110693
111249
  migrateTriage();
110694
- const done2 = dismissInboxItem(said3, "agent", why);
111250
+ const done2 = dismissInboxItem(said3, "agent", why2);
110695
111251
  if (!done2.ok) die(done2.error, { kind: "triage-item-gone" });
110696
111252
  say(`${said3} \u2014 ignored: ${done2.relPath}`);
110697
- return { source_id: said3, reason: why, file: done2.relPath };
111253
+ return { source_id: said3, reason: why2, file: done2.relPath };
110698
111254
  }
110699
111255
  function cmdTriageRestore(sourceId) {
110700
111256
  const said3 = sourceId.trim();
@@ -110904,8 +111460,8 @@ function declareRuns(program2, cli) {
110904
111460
  };
110905
111461
  for (const flow of FLOWS) declareFlow(flow.group ? groups[flow.group] : program2, flow, cli);
110906
111462
  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()));
111463
+ const [id, why2] = positional(vals);
111464
+ await onBoard2(this, cli, () => cmdReject(id, why2.join(" "), this.opts()));
110909
111465
  });
110910
111466
  declareRunning(groups.run, cli);
110911
111467
  declareDelivery(groups.delivery, cli);
@@ -111049,6 +111605,9 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
111049
111605
  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
111606
  await onBoard2(this, cli, () => cmdWorkflowRename(id, name.join(" ")));
111051
111607
  });
111608
+ 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) {
111609
+ await onBoard2(this, cli, () => cmdWorkflowDiagram(id, card));
111610
+ });
111052
111611
  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
111612
  const ctx = ctxOf(this, cli.program);
111054
111613
  useBoard(resolveBoard("components", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint }), ctx.dir !== null);
@@ -111225,8 +111784,8 @@ function declareAgent(program2, cli) {
111225
111784
  }
111226
111785
 
111227
111786
  // ../cli/src/lib/cli/setup.ts
111228
- import fs86 from "node:fs";
111229
- import path86 from "node:path";
111787
+ import fs89 from "node:fs";
111788
+ import path89 from "node:path";
111230
111789
  import { fileURLToPath as fileURLToPath3 } from "node:url";
111231
111790
 
111232
111791
  // ../cli/src/commands/update.ts
@@ -111240,8 +111799,8 @@ init_paths();
111240
111799
  init_memory();
111241
111800
  init_yaml2();
111242
111801
  init_version();
111243
- import fs85 from "node:fs";
111244
- import path85 from "node:path";
111802
+ import fs88 from "node:fs";
111803
+ import path88 from "node:path";
111245
111804
  import { spawnSync as spawnSync6 } from "node:child_process";
111246
111805
  var NAME = "wildcrane";
111247
111806
  var REPO = "https://github.com/ai4kanban/ai4kanban";
@@ -111263,10 +111822,10 @@ var Report = class {
111263
111822
  for (const line of this.notes) say(` ! ${line}`);
111264
111823
  }
111265
111824
  };
111266
- var read3 = (file) => fs85.existsSync(file) ? fs85.readFileSync(file, "utf8") : null;
111825
+ var read4 = (file) => fs88.existsSync(file) ? fs88.readFileSync(file, "utf8") : null;
111267
111826
  function statOf(p2) {
111268
111827
  try {
111269
- return fs85.lstatSync(p2);
111828
+ return fs88.lstatSync(p2);
111270
111829
  } catch {
111271
111830
  return null;
111272
111831
  }
@@ -111291,10 +111850,10 @@ async function cmdUpdate2(ctx) {
111291
111850
  return { updated: ctx.dir, from, to: SKILL_VERSION };
111292
111851
  }
111293
111852
  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)) {
111853
+ const legacy2 = path88.join(root2, "docs", "kanban");
111854
+ const kept2 = path88.join(root2, ".akb", "kanban");
111855
+ const board2 = named2 ?? (fs88.existsSync(legacy2) ? legacy2 : kept2);
111856
+ if (!fs88.existsSync(board2)) {
111298
111857
  report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
111299
111858
  return false;
111300
111859
  }
@@ -111325,20 +111884,20 @@ function moveRuntimes(root2, board2, report3) {
111325
111884
  }
111326
111885
  }
111327
111886
  function moveLegacyMemory(board2, report3) {
111328
- const memory = path85.join(board2, "memory");
111887
+ const memory = path88.join(board2, "memory");
111329
111888
  const moved = [];
111330
111889
  for (const name of MEMORY_FILES) {
111331
- const from = path85.join(board2, name);
111890
+ const from = path88.join(board2, name);
111332
111891
  const st2 = statOf(from);
111333
111892
  if (!st2 || !st2.isFile()) continue;
111334
- fs85.mkdirSync(memory, { recursive: true });
111335
- const to = path85.join(memory, name);
111336
- const there = read3(to);
111893
+ fs88.mkdirSync(memory, { recursive: true });
111894
+ const to = path88.join(memory, name);
111895
+ const there = read4(to);
111337
111896
  if (there === null) {
111338
- fs85.renameSync(from, to);
111897
+ fs88.renameSync(from, to);
111339
111898
  moved.push(name);
111340
- } else if (there === read3(from)) {
111341
- fs85.rmSync(from);
111899
+ } else if (there === read4(from)) {
111900
+ fs88.rmSync(from);
111342
111901
  moved.push(name);
111343
111902
  } else {
111344
111903
  report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
@@ -111347,23 +111906,23 @@ function moveLegacyMemory(board2, report3) {
111347
111906
  if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
111348
111907
  }
111349
111908
  function dropRecordFile(board2) {
111350
- const file = path85.join(board2, "record.csv");
111351
- if (!fs85.existsSync(file)) return null;
111352
- fs85.rmSync(file);
111909
+ const file = path88.join(board2, "record.csv");
111910
+ if (!fs88.existsSync(file)) return null;
111911
+ fs88.rmSync(file);
111353
111912
  return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
111354
111913
  }
111355
111914
  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"));
111915
+ const memory = path88.join(board2, "memory");
111916
+ if (!fs88.existsSync(memory)) return;
111917
+ const root2 = read4(path88.join(memory, "goal.md"));
111359
111918
  let dropped = 0;
111360
- for (const entry of fs85.readdirSync(memory, { withFileTypes: true })) {
111919
+ for (const entry of fs88.readdirSync(memory, { withFileTypes: true })) {
111361
111920
  if (!entry.isDirectory()) continue;
111362
- const file = path85.join(memory, entry.name, "goal.md");
111363
- const text5 = read3(file);
111921
+ const file = path88.join(memory, entry.name, "goal.md");
111922
+ const text5 = read4(file);
111364
111923
  if (text5 === null) continue;
111365
111924
  if (text5 === root2 || text5.includes(UNFILLED) || !goalWords(text5)) {
111366
- fs85.rmSync(file);
111925
+ fs88.rmSync(file);
111367
111926
  dropped++;
111368
111927
  } else {
111369
111928
  report3.notes.push(
@@ -111385,10 +111944,10 @@ var PLAN_LEADS = {
111385
111944
  var GONE_LEADS = ["software-planner", "planner"];
111386
111945
  function planLeads(board2) {
111387
111946
  const leads = { ...PLAN_LEADS };
111388
- const root2 = path85.join(board2, "workflows");
111389
- for (const entry of fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []) {
111947
+ const root2 = path88.join(board2, "workflows");
111948
+ for (const entry of fs88.existsSync(root2) ? fs88.readdirSync(root2, { withFileTypes: true }) : []) {
111390
111949
  if (!entry.isDirectory()) continue;
111391
- const meta = splitFrontmatter(read3(path85.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
111950
+ const meta = splitFrontmatter(read4(path88.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
111392
111951
  const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
111393
111952
  const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
111394
111953
  const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
@@ -111397,30 +111956,30 @@ function planLeads(board2) {
111397
111956
  return leads;
111398
111957
  }
111399
111958
  function movePlanRules(board2, report3) {
111400
- const rules = path85.join(board2, "rules");
111959
+ const rules = path88.join(board2, "rules");
111401
111960
  const moved = [];
111402
111961
  for (const [id, leads] of Object.entries(planLeads(board2))) {
111403
111962
  for (const lead of leads) {
111404
- const from = path85.join(rules, `${lead}.md`);
111405
- const rule = read3(from)?.trim();
111963
+ const from = path88.join(rules, `${lead}.md`);
111964
+ const rule = read4(from)?.trim();
111406
111965
  if (!rule) continue;
111407
- const to = path85.join(rules, "workflows", `${id}.md`);
111408
- const there = read3(to)?.trim() ?? "";
111966
+ const to = path88.join(rules, "workflows", `${id}.md`);
111967
+ const there = read4(to)?.trim() ?? "";
111409
111968
  if (!there.includes(rule)) {
111410
- fs85.mkdirSync(path85.dirname(to), { recursive: true });
111411
- fs85.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
111969
+ fs88.mkdirSync(path88.dirname(to), { recursive: true });
111970
+ fs88.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
111412
111971
  `);
111413
111972
  moved.push(`${lead} \u2192 ${id}`);
111414
111973
  }
111415
111974
  }
111416
111975
  }
111417
- for (const lead of GONE_LEADS) fs85.rmSync(path85.join(rules, `${lead}.md`), { force: true });
111976
+ for (const lead of GONE_LEADS) fs88.rmSync(path88.join(rules, `${lead}.md`), { force: true });
111418
111977
  if (moved.length) report3.did.push(`made each plan agent's rule its workflow's card rule (docs/kanban/rules/workflows/): ${moved.join(", ")}`);
111419
111978
  }
111420
111979
  function noteOldWorkflows(board2, report3) {
111421
111980
  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}`);
111981
+ const root2 = path88.join(board2, dir);
111982
+ 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
111983
  };
111425
111984
  const files2 = [...old("workflows", "WORKFLOW.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
111426
111985
  if (files2.length) {
@@ -111430,7 +111989,7 @@ function noteOldWorkflows(board2, report3) {
111430
111989
  }
111431
111990
  }
111432
111991
  function checkConfig(board2, report3) {
111433
- const current = read3(path85.join(board2, "config.md"));
111992
+ const current = read4(path88.join(board2, "config.md"));
111434
111993
  if (!current) return;
111435
111994
  const added = missingConfigKeys(current);
111436
111995
  if (added.length) {
@@ -111440,7 +111999,7 @@ function checkConfig(board2, report3) {
111440
111999
  }
111441
112000
  }
111442
112001
  function checkModules(board2, report3) {
111443
- const map2 = read3(path85.join(board2, "modules.md"));
112002
+ const map2 = read4(path88.join(board2, "modules.md"));
111444
112003
  if (map2 && map2.includes(UNFILLED)) {
111445
112004
  report3.notes.push(
111446
112005
  "docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
@@ -111494,14 +112053,14 @@ function declareSetup(program2, cli) {
111494
112053
  program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
111495
112054
  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
112055
  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 });
112056
+ const dir = path89.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
112057
+ if (!fs89.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
111499
112058
  return dir;
111500
112059
  };
111501
112060
  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
112061
  const dir = where(this);
111503
112062
  const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
111504
- const board2 = named2 ? path86.resolve(cli.cwd, named2) : null;
112063
+ const board2 = named2 ? path89.resolve(cli.cwd, named2) : null;
111505
112064
  await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
111506
112065
  });
111507
112066
  program2.command("__rules", { hidden: true }).action(function() {
@@ -111546,7 +112105,7 @@ function invokedDirectly() {
111546
112105
  const entry = process.argv[1];
111547
112106
  if (!entry) return false;
111548
112107
  try {
111549
- return fs87.realpathSync(entry) === fs87.realpathSync(SELF2);
112108
+ return fs90.realpathSync(entry) === fs90.realpathSync(SELF2);
111550
112109
  } catch {
111551
112110
  return false;
111552
112111
  }