wildcrane-runner 0.6.32 → 0.6.33

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.29 — built by runner/scripts/build.mjs. Do not edit.
2
+ // ai4kanban 0.11.30 — 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;
@@ -2551,10 +2551,10 @@ function findRollout(threadId) {
2551
2551
  }
2552
2552
  for (const name of names3) {
2553
2553
  if (!name.startsWith("rollout-") || !name.endsWith(tail2)) continue;
2554
- const path89 = join(dir, name);
2554
+ const path90 = join(dir, name);
2555
2555
  try {
2556
- const at2 = statSync(path89).mtimeMs;
2557
- if (!newest2 || at2 > newest2.at) newest2 = { path: path89, at: at2 };
2556
+ const at2 = statSync(path90).mtimeMs;
2557
+ if (!newest2 || at2 > newest2.at) newest2 = { path: path90, at: at2 };
2558
2558
  } catch {
2559
2559
  }
2560
2560
  }
@@ -2562,11 +2562,11 @@ function findRollout(threadId) {
2562
2562
  return newest2?.path;
2563
2563
  }
2564
2564
  function readCodexRunFacts(threadId) {
2565
- const path89 = findRollout(threadId);
2566
- if (!path89) return void 0;
2565
+ const path90 = findRollout(threadId);
2566
+ if (!path90) return void 0;
2567
2567
  let raw;
2568
2568
  try {
2569
- raw = readFileSync(path89, "utf8");
2569
+ raw = readFileSync(path90, "utf8");
2570
2570
  } catch {
2571
2571
  return void 0;
2572
2572
  }
@@ -2694,8 +2694,8 @@ function renderCompleted(item) {
2694
2694
  const changes = Array.isArray(item.changes) ? item.changes : [];
2695
2695
  return changes.map((raw) => {
2696
2696
  const change2 = obj(raw);
2697
- const path89 = str(change2.path);
2698
- return path89 ? `\u23FA ${str(change2.kind) || "change"}(${path89})
2697
+ const path90 = str(change2.path);
2698
+ return path90 ? `\u23FA ${str(change2.kind) || "change"}(${path90})
2699
2699
  ` : "";
2700
2700
  }).join("");
2701
2701
  }
@@ -2957,10 +2957,10 @@ function readKimiRunFacts(sessionId) {
2957
2957
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
2958
2958
  let model;
2959
2959
  let holding = 0;
2960
- for (const { path: path89, main } of wireFiles(entry.sessionDir)) {
2960
+ for (const { path: path90, main } of wireFiles(entry.sessionDir)) {
2961
2961
  let raw;
2962
2962
  try {
2963
- raw = readFileSync2(path89, "utf8");
2963
+ raw = readFileSync2(path90, "utf8");
2964
2964
  } catch {
2965
2965
  continue;
2966
2966
  }
@@ -3243,7 +3243,7 @@ var init_package = __esm({
3243
3243
  "../cli/package.json"() {
3244
3244
  package_default = {
3245
3245
  name: "wildcrane",
3246
- version: "0.11.29",
3246
+ version: "0.11.30",
3247
3247
  akbContract: 7,
3248
3248
  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.",
3249
3249
  keywords: [
@@ -3320,8 +3320,8 @@ var init_version = __esm({
3320
3320
  import fs12 from "node:fs";
3321
3321
  function whereHint(update2, title) {
3322
3322
  const locations = Array.isArray(update2.locations) ? update2.locations : [];
3323
- const path89 = str(obj(locations[0]).path);
3324
- return path89 && !title.includes(path89) ? hint(path89) : "";
3323
+ const path90 = str(obj(locations[0]).path);
3324
+ return path90 && !title.includes(path90) ? hint(path90) : "";
3325
3325
  }
3326
3326
  function saidBy(update2) {
3327
3327
  const content = Array.isArray(update2.content) ? update2.content : [];
@@ -8245,15 +8245,15 @@ var init_roles = __esm({
8245
8245
  });
8246
8246
 
8247
8247
  // ../cli/src/lib/shared/board-files.ts
8248
- function isBoardPath(path89) {
8249
- if (!path89 || path89.length > 500 || path89.startsWith("/") || path89.includes("\\") || path89.includes("\0")) return false;
8250
- if (path89.split("/").some((part) => !part || part === "." || part === "..")) return false;
8251
- if (path89 === "todo/README.md" || path89.split("/").includes(".sync")) return false;
8252
- if (path89.startsWith("workflows/")) return true;
8253
- if (SETTINGS.includes(path89)) return true;
8254
- if (path89.startsWith("rules/")) return isSettingsPath(path89);
8255
- if (path89.startsWith("assets/")) return path89.endsWith(".json");
8256
- return ROOTS.some((root2) => path89.startsWith(root2)) && path89.endsWith(".md");
8248
+ function isBoardPath(path90) {
8249
+ if (!path90 || path90.length > 500 || path90.startsWith("/") || path90.includes("\\") || path90.includes("\0")) return false;
8250
+ if (path90.split("/").some((part) => !part || part === "." || part === "..")) return false;
8251
+ if (path90 === "todo/README.md" || path90.split("/").includes(".sync")) return false;
8252
+ if (path90.startsWith("workflows/")) return true;
8253
+ if (SETTINGS.includes(path90)) return true;
8254
+ if (path90.startsWith("rules/")) return isSettingsPath(path90);
8255
+ if (path90.startsWith("assets/")) return path90.endsWith(".json");
8256
+ return ROOTS.some((root2) => path90.startsWith(root2)) && path90.endsWith(".md");
8257
8257
  }
8258
8258
  var ROOTS, SETTINGS, isSettingsPath, BOARD_FILE_LIMIT, cardSlug, workflowFolder, workflowName, draftFolder;
8259
8259
  var init_board_files = __esm({
@@ -8261,7 +8261,7 @@ var init_board_files = __esm({
8261
8261
  "use strict";
8262
8262
  ROOTS = ["todo/", ".archive/", "memory/", "workflows/", "triage/", "assets/", "rules/"];
8263
8263
  SETTINGS = ["modules.md", "config.md"];
8264
- isSettingsPath = (path89) => SETTINGS.includes(path89) || /^rules\/(?:workflows\/)?[^/]+\.md$/.test(path89);
8264
+ isSettingsPath = (path90) => SETTINGS.includes(path90) || /^rules\/(?:workflows\/)?[^/]+\.md$/.test(path90);
8265
8265
  BOARD_FILE_LIMIT = 256 * 1024;
8266
8266
  cardSlug = (task) => task.toLowerCase().replace(/_/g, "-");
8267
8267
  workflowFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
@@ -8794,7 +8794,7 @@ function checkWorkflowFiles(value, official = false) {
8794
8794
  }
8795
8795
  return { ok: true, def, files: value };
8796
8796
  }
8797
- var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, landsOf, SEGMENT, isAboutFile, bytes;
8797
+ var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes;
8798
8798
  var init_workflow_files = __esm({
8799
8799
  "../cli/src/lib/shared/workflow-files.ts"() {
8800
8800
  "use strict";
@@ -8804,7 +8804,9 @@ var init_workflow_files = __esm({
8804
8804
  WORKFLOW_FILE = "WORKFLOW.md";
8805
8805
  MCP_FILE = "mcp.json";
8806
8806
  KB = 1024;
8807
- FILE_LIMITS = { file: 256 * KB, total: 2 * KB * KB, count: 500, path: 512 };
8807
+ FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
8808
+ officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
8809
+ hashInput = (files2) => JSON.stringify(Object.entries(files2).sort(([a2], [b2]) => a2 < b2 ? -1 : 1));
8808
8810
  landsOf = (def) => ({ lands: def.land.some((h3) => !h3.off) });
8809
8811
  SEGMENT = /^[\w.-]+$/;
8810
8812
  isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
@@ -8812,34 +8814,50 @@ var init_workflow_files = __esm({
8812
8814
  }
8813
8815
  });
8814
8816
 
8815
- // ../official/pack.ts
8816
- import crypto from "node:crypto";
8817
+ // ../cli/src/lib/agent/workflow-folder.ts
8817
8818
  import fs23 from "node:fs";
8818
8819
  import path27 from "node:path";
8819
- import { fileURLToPath as fileURLToPath2 } from "node:url";
8820
8820
  function filesOf(dir, base = dir) {
8821
- return fs23.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
8821
+ return fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".")).flatMap((e2) => {
8822
8822
  const full = path27.join(dir, e2.name);
8823
8823
  return e2.isDirectory() ? filesOf(full, base) : [path27.relative(base, full).split(path27.sep).join("/")];
8824
8824
  });
8825
8825
  }
8826
+ function readWorkflowFile(dir, file) {
8827
+ const full = path27.join(dir, file);
8828
+ return isAboutFile(file) && !file.endsWith(".md") ? `data:${MIME[path27.extname(file)]};base64,${fs23.readFileSync(full).toString("base64")}` : fs23.readFileSync(full, "utf8");
8829
+ }
8830
+ var MIME, readWorkflowFolder;
8831
+ var init_workflow_folder = __esm({
8832
+ "../cli/src/lib/agent/workflow-folder.ts"() {
8833
+ "use strict";
8834
+ init_workflow_files();
8835
+ MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
8836
+ readWorkflowFolder = (dir) => Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, readWorkflowFile(dir, f2)]));
8837
+ }
8838
+ });
8839
+
8840
+ // ../official/pack.ts
8841
+ import crypto from "node:crypto";
8842
+ import fs24 from "node:fs";
8843
+ import path28 from "node:path";
8844
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
8826
8845
  function packOfficial(root2 = OFFICIAL, loose = false) {
8827
- const agentsDir = path27.join(root2, "agents");
8846
+ const agentsDir = path28.join(root2, "agents");
8828
8847
  const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
8829
- const dir = path27.join(agentsDir, name);
8830
- return [name, Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, fs23.readFileSync(path27.join(dir, f2), "utf8")]))];
8848
+ const dir = path28.join(agentsDir, name);
8849
+ return [name, readWorkflowFolder(dir)];
8831
8850
  }));
8832
8851
  for (const [name, own] of Object.entries(loose ? {} : agentFiles)) {
8833
8852
  const read5 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
8834
8853
  if ("problem" in read5) throw new Error(read5.problem);
8835
8854
  }
8836
- const workflowsDir = path27.join(root2, "workflows");
8855
+ const workflowsDir = path28.join(root2, "workflows");
8837
8856
  return dirs(workflowsDir).map((folder) => {
8838
- const dir = path27.join(workflowsDir, folder);
8857
+ const dir = path28.join(workflowsDir, folder);
8839
8858
  const files2 = {};
8840
8859
  for (const f2 of filesOf(dir).sort()) {
8841
- if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || /^ABOUT(\.[a-z]{2})?\.md$/.test(f2)) files2[f2] = fs23.readFileSync(path27.join(dir, f2), "utf8");
8842
- else if (isAboutFile(f2)) files2[f2] = `data:${MIME[path27.extname(f2)]};base64,${fs23.readFileSync(path27.join(dir, f2)).toString("base64")}`;
8860
+ if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || isAboutFile(f2)) files2[f2] = readWorkflowFile(dir, f2);
8843
8861
  }
8844
8862
  const read5 = checkWorkflowFiles({ [WORKFLOW_FILE]: files2[WORKFLOW_FILE], ...Object.fromEntries(
8845
8863
  Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f2, t]) => [`agents/${name}/${f2}`, t]))
@@ -8866,24 +8884,23 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
8866
8884
  };
8867
8885
  });
8868
8886
  }
8869
- var OFFICIAL, MIME, dirs, officialId, hashOf;
8887
+ var OFFICIAL, dirs, hashOf;
8870
8888
  var init_pack = __esm({
8871
8889
  "../official/pack.ts"() {
8872
8890
  init_parse();
8873
8891
  init_workflow_def();
8892
+ init_workflow_folder();
8874
8893
  init_workflow_files();
8875
- OFFICIAL = path27.dirname(fileURLToPath2(import.meta.url));
8876
- MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
8877
- dirs = (dir) => fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
8878
- officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
8879
- hashOf = (files2) => crypto.createHash("sha256").update(JSON.stringify(Object.entries(files2).sort(([a2], [b2]) => a2 < b2 ? -1 : 1))).digest("hex");
8894
+ OFFICIAL = path28.dirname(fileURLToPath2(import.meta.url));
8895
+ dirs = (dir) => fs24.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
8896
+ hashOf = (files2) => crypto.createHash("sha256").update(hashInput(files2)).digest("hex");
8880
8897
  }
8881
8898
  });
8882
8899
 
8883
8900
  // ../cli/src/lib/cloud/tasks.ts
8884
8901
  import crypto2 from "node:crypto";
8885
- import fs24 from "node:fs";
8886
- import path28 from "node:path";
8902
+ import fs25 from "node:fs";
8903
+ import path29 from "node:path";
8887
8904
  function workspaceTask() {
8888
8905
  const id = process.env[TASK_ENV];
8889
8906
  return id && id.trim() ? id.trim() : null;
@@ -8941,15 +8958,15 @@ ${said3.slug?.trim() || said3.title}`).digest("hex").slice(0, 40)}`;
8941
8958
  return { ok: true, value: { task: made.value, number, from: source.value, replayed: made.replayed === true } };
8942
8959
  }
8943
8960
  function runnerProject(board2) {
8944
- if (path28.basename(board2) !== "kanban" || path28.basename(path28.dirname(board2)) !== ".akb") return null;
8945
- const linked = linkedProject(board2, path28.dirname(path28.dirname(board2)));
8961
+ if (path29.basename(board2) !== "kanban" || path29.basename(path29.dirname(board2)) !== ".akb") return null;
8962
+ const linked = linkedProject(board2, path29.dirname(path29.dirname(board2)));
8946
8963
  return linked.ok ? linked.value : null;
8947
8964
  }
8948
8965
  function linkedProject(board2, root2) {
8949
- const file = path28.join(root2, ".akb", "base.json");
8950
- if (!fs24.existsSync(file)) return { ok: true, value: null };
8966
+ const file = path29.join(root2, ".akb", "base.json");
8967
+ if (!fs25.existsSync(file)) return { ok: true, value: null };
8951
8968
  try {
8952
- const base = JSON.parse(fs24.readFileSync(file, "utf8"));
8969
+ const base = JSON.parse(fs25.readFileSync(file, "utf8"));
8953
8970
  if (!base || typeof base !== "object" || base.project !== void 0 && (typeof base.project !== "string" || !base.project.trim()) || base.files !== void 0 && (!base.files || typeof base.files !== "object" || Array.isArray(base.files))) throw new Error();
8954
8971
  const projects = new Set(Object.keys(base.files ?? {}).flatMap((p2) => /^projects\/([^/]+)\//.exec(p2)?.[1] ?? []));
8955
8972
  if (typeof base.project === "string") projects.add(base.project);
@@ -9016,37 +9033,37 @@ var init_tasks = __esm({
9016
9033
  });
9017
9034
 
9018
9035
  // ../cli/src/lib/agent/cloud-workflows.ts
9019
- import fs25 from "node:fs";
9020
- import path29 from "node:path";
9036
+ import fs26 from "node:fs";
9037
+ import path30 from "node:path";
9021
9038
  function readJson(file) {
9022
9039
  try {
9023
- return JSON.parse(fs25.readFileSync(file, "utf8"));
9040
+ return JSON.parse(fs26.readFileSync(file, "utf8"));
9024
9041
  } catch {
9025
9042
  return null;
9026
9043
  }
9027
9044
  }
9028
9045
  function writeJson(file, value) {
9029
- fs25.mkdirSync(path29.dirname(file), { recursive: true });
9046
+ fs26.mkdirSync(path30.dirname(file), { recursive: true });
9030
9047
  const tmp = `${file}.${process.pid}.tmp`;
9031
- fs25.writeFileSync(tmp, `${JSON.stringify(value)}
9048
+ fs26.writeFileSync(tmp, `${JSON.stringify(value)}
9032
9049
  `);
9033
- fs25.renameSync(tmp, file);
9050
+ fs26.renameSync(tmp, file);
9034
9051
  }
9035
9052
  function heldWorkflowName(name) {
9036
9053
  let files2;
9037
9054
  try {
9038
- files2 = fs25.readdirSync(path29.join(root(), "versions"));
9055
+ files2 = fs26.readdirSync(path30.join(root(), "versions"));
9039
9056
  } catch {
9040
9057
  return "";
9041
9058
  }
9042
9059
  const held4 = files2.filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, f2.lastIndexOf("@"))).find((id) => workflowName(id) === name);
9043
9060
  if (!held4) return "";
9044
9061
  const file = files2.filter((f2) => f2.startsWith(`${held4}@`)).sort().pop();
9045
- return readJson(path29.join(root(), "versions", file))?.name ?? "";
9062
+ return readJson(path30.join(root(), "versions", file))?.name ?? "";
9046
9063
  }
9047
9064
  function saveVersion(held4) {
9048
9065
  const file = versionFile(held4.id, held4.version);
9049
- if (!fs25.existsSync(file)) writeJson(file, { id: held4.id, version: held4.version, name: held4.name, names: held4.names, files: held4.files });
9066
+ if (!fs26.existsSync(file)) writeJson(file, { id: held4.id, version: held4.version, name: held4.name, names: held4.names, files: held4.files });
9050
9067
  }
9051
9068
  function savePin(task, held4) {
9052
9069
  saveVersion(held4);
@@ -9178,11 +9195,11 @@ var init_cloud_workflows = __esm({
9178
9195
  init_workflow_def();
9179
9196
  DEV = "AI4KANBAN_WORKFLOWS";
9180
9197
  FRESH_MS = 6e4;
9181
- root = () => path29.join(machineHome(), "workflows");
9198
+ root = () => path30.join(machineHome(), "workflows");
9182
9199
  safe = (name) => name.replace(/[^\w.@-]/g, "_");
9183
- versionFile = (id, version) => path29.join(root(), "versions", `${safe(id)}@${version}.json`);
9184
- listFile = (project) => path29.join(root(), "lists", `${safe(project)}.json`);
9185
- pinFile = (task) => path29.join(root(), "tasks", `${safe(task)}.json`);
9200
+ versionFile = (id, version) => path30.join(root(), "versions", `${safe(id)}@${version}.json`);
9201
+ listFile = (project) => path30.join(root(), "lists", `${safe(project)}.json`);
9202
+ pinFile = (task) => path30.join(root(), "tasks", `${safe(task)}.json`);
9186
9203
  readVersion = (id, version) => readJson(versionFile(id, version));
9187
9204
  readPin = (task) => readJson(pinFile(task));
9188
9205
  boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
@@ -9221,8 +9238,8 @@ var init_bundled2 = __esm({
9221
9238
  });
9222
9239
 
9223
9240
  // ../cli/src/lib/agents/catalog.ts
9224
- import fs26 from "node:fs";
9225
- import path30 from "node:path";
9241
+ import fs27 from "node:fs";
9242
+ import path31 from "node:path";
9226
9243
  function readCatalog() {
9227
9244
  const agents = [];
9228
9245
  const problems = [];
@@ -9272,7 +9289,7 @@ function readCatalog() {
9272
9289
  }
9273
9290
  for (const folder of projectFolders(LEGACY_AGENTS)) {
9274
9291
  take(readProject(LEGACY_AGENTS, folder), folder);
9275
- problems.push(`${rel(path30.join(LEGACY_AGENTS, folder))}: move it to ${rel(path30.join(AGENTS, folder))}/`);
9292
+ problems.push(`${rel(path31.join(LEGACY_AGENTS, folder))}: move it to ${rel(path31.join(AGENTS, folder))}/`);
9276
9293
  }
9277
9294
  return { agents, problems, refused };
9278
9295
  }
@@ -9336,7 +9353,7 @@ function readBundled(folder) {
9336
9353
  function projectFolders(root2) {
9337
9354
  let entries;
9338
9355
  try {
9339
- entries = fs26.readdirSync(root2, { withFileTypes: true });
9356
+ entries = fs27.readdirSync(root2, { withFileTypes: true });
9340
9357
  } catch {
9341
9358
  return [];
9342
9359
  }
@@ -9344,10 +9361,10 @@ function projectFolders(root2) {
9344
9361
  }
9345
9362
  function agentFileReader(dir) {
9346
9363
  return (relative) => {
9347
- const target = path30.resolve(dir, relative);
9348
- if (target !== dir && !target.startsWith(dir + path30.sep)) return null;
9364
+ const target = path31.resolve(dir, relative);
9365
+ if (target !== dir && !target.startsWith(dir + path31.sep)) return null;
9349
9366
  try {
9350
- return fs26.readFileSync(target, "utf8");
9367
+ return fs27.readFileSync(target, "utf8");
9351
9368
  } catch {
9352
9369
  return null;
9353
9370
  }
@@ -9356,22 +9373,22 @@ function agentFileReader(dir) {
9356
9373
  function walkFolder(dir, prefix) {
9357
9374
  let entries;
9358
9375
  try {
9359
- entries = fs26.readdirSync(dir, { withFileTypes: true });
9376
+ entries = fs27.readdirSync(dir, { withFileTypes: true });
9360
9377
  } catch {
9361
9378
  return [];
9362
9379
  }
9363
9380
  return entries.flatMap((e2) => {
9364
9381
  const here = prefix ? `${prefix}/${e2.name}` : e2.name;
9365
- return e2.isDirectory() ? walkFolder(path30.join(dir, e2.name), here) : [here];
9382
+ return e2.isDirectory() ? walkFolder(path31.join(dir, e2.name), here) : [here];
9366
9383
  });
9367
9384
  }
9368
9385
  function readProject(root2, folder) {
9369
- const dir = path30.join(root2, folder);
9386
+ const dir = path31.join(root2, folder);
9370
9387
  const file = agentFileReader(dir);
9371
9388
  const found2 = AGENT_FILES.map((name) => ({ name, text: file(name) })).find((f2) => f2.text !== null);
9372
- const missing = rel(path30.join(dir, AGENT_FILE));
9389
+ const missing = rel(path31.join(dir, AGENT_FILE));
9373
9390
  if (!found2) return { problem: `${missing} is missing`, file: missing, missing: true };
9374
- const from = rel(path30.join(dir, found2.name));
9391
+ const from = rel(path31.join(dir, found2.name));
9375
9392
  const read5 = parseSpecAgent(found2.text, from, file, false, () => ownFiles(walkFolder(dir, "")));
9376
9393
  if ("problem" in read5) return { ...read5, file: from };
9377
9394
  if ("agent" in read5) Object.assign(read5.agent, { dir, text: found2.text });
@@ -9397,8 +9414,8 @@ var init_catalog = __esm({
9397
9414
  });
9398
9415
 
9399
9416
  // ../cli/src/lib/agent/workflow-file.ts
9400
- import fs27 from "node:fs";
9401
- import path31 from "node:path";
9417
+ import fs28 from "node:fs";
9418
+ import path32 from "node:path";
9402
9419
  function agentLines2(agents, indent2) {
9403
9420
  return agents.flatMap(
9404
9421
  (h3) => !h3.extra && !h3.off ? [`${indent2}- ${scalar(h3.agent)}`] : [
@@ -9434,12 +9451,12 @@ function draftId() {
9434
9451
  const task = workspaceTask();
9435
9452
  if (!task) return null;
9436
9453
  const id = draftFolder(task);
9437
- return fs27.existsSync(fileOf(id)) ? id : null;
9454
+ return fs28.existsSync(fileOf(id)) ? id : null;
9438
9455
  }
9439
9456
  function readFolder(id, problems) {
9440
9457
  let source;
9441
9458
  try {
9442
- source = fs27.readFileSync(fileOf(id), "utf8");
9459
+ source = fs28.readFileSync(fileOf(id), "utf8");
9443
9460
  } catch {
9444
9461
  problems.push(`${rel(fileOf(id))} is missing`);
9445
9462
  return null;
@@ -9460,8 +9477,8 @@ function boardWorkflowDefs() {
9460
9477
  }
9461
9478
  function writeWorkflowDef(def) {
9462
9479
  const file = fileOf(def.id);
9463
- fs27.mkdirSync(path31.dirname(file), { recursive: true });
9464
- fs27.writeFileSync(file, workflowFileText(def));
9480
+ fs28.mkdirSync(path32.dirname(file), { recursive: true });
9481
+ fs28.writeFileSync(file, workflowFileText(def));
9465
9482
  forgetFileMemos();
9466
9483
  }
9467
9484
  var WORKFLOW_FILE2, scalar, plain, flowList, builtinDefs, fileOf;
@@ -9481,13 +9498,13 @@ var init_workflow_file = __esm({
9481
9498
  plain = (agents) => agents.every((h3) => !h3.extra && !h3.off);
9482
9499
  flowList = (agents) => `[${agents.map((h3) => scalar(h3.agent)).join(", ")}]`;
9483
9500
  builtinDefs = () => cloudFlows().filter((f2) => f2.builtIn).map((f2) => f2.def);
9484
- fileOf = (id) => path31.join(WORKFLOWS, id, WORKFLOW_FILE2);
9501
+ fileOf = (id) => path32.join(WORKFLOWS, id, WORKFLOW_FILE2);
9485
9502
  }
9486
9503
  });
9487
9504
 
9488
9505
  // ../cli/src/lib/agent/workflows.ts
9489
- import fs28 from "node:fs";
9490
- import path32 from "node:path";
9506
+ import fs29 from "node:fs";
9507
+ import path33 from "node:path";
9491
9508
  function workflowPurpose(flow) {
9492
9509
  if (flow.builtIn) return builtinDescription(flow.id) || flow.name;
9493
9510
  return boardWorkflowDefs().defs.find((d2) => d2.id === flow.id)?.description || flow.name;
@@ -9561,7 +9578,7 @@ function previewStages(flow, chosen) {
9561
9578
  }
9562
9579
  function userWorkflowRules(flow) {
9563
9580
  try {
9564
- return fs28.readFileSync(workflowRuleFile(flow.id), "utf8").trim();
9581
+ return fs29.readFileSync(workflowRuleFile(flow.id), "utf8").trim();
9565
9582
  } catch {
9566
9583
  return "";
9567
9584
  }
@@ -9696,8 +9713,8 @@ function cardMeta(id) {
9696
9713
  try {
9697
9714
  const found2 = locate(id) ?? locateArchived(id);
9698
9715
  if (!found2) return null;
9699
- const file = found2.kind === "group" ? path32.join(found2.target, "root.md") : found2.target;
9700
- return parseFrontmatter(fs28.readFileSync(file, "utf8")).meta;
9716
+ const file = found2.kind === "group" ? path33.join(found2.target, "root.md") : found2.target;
9717
+ return parseFrontmatter(fs29.readFileSync(file, "utf8")).meta;
9701
9718
  } catch {
9702
9719
  return null;
9703
9720
  }
@@ -9787,7 +9804,7 @@ var init_workflows = __esm({
9787
9804
  previewAgents = (flow) => previewMembers(flow).filter((h3) => !h3.off);
9788
9805
  landAgents = (flow) => flow.land.filter((h3) => !h3.off);
9789
9806
  archivesOnApproval = (flow) => !!flow && !landAgents(flow).length;
9790
- workflowRuleFile = (id) => path32.join(RULES, "workflows", `${id}.md`);
9807
+ workflowRuleFile = (id) => path33.join(RULES, "workflows", `${id}.md`);
9791
9808
  save2 = (change2) => writeConfig((cfg) => {
9792
9809
  const block = configBlock(cfg.workflows);
9793
9810
  change2(block);
@@ -9810,11 +9827,11 @@ var init_workflows = __esm({
9810
9827
  });
9811
9828
 
9812
9829
  // ../cli/src/commands/goal.ts
9813
- import fs29 from "node:fs";
9830
+ import fs30 from "node:fs";
9814
9831
  function loadGoals() {
9815
9832
  const file = goalsFile();
9816
9833
  if (!file) die("Goals exist only inside a WildCrane goal discussion.");
9817
- const held4 = JSON.parse(fs29.readFileSync(file, "utf8"));
9834
+ const held4 = JSON.parse(fs30.readFileSync(file, "utf8"));
9818
9835
  if (held4.goals !== void 0 && held4.ideas !== void 0 && JSON.stringify(held4.goals) !== JSON.stringify(held4.ideas)) die("goals and ideas do not match.");
9819
9836
  const goals = held4.goals ?? held4.ideas;
9820
9837
  if (!Array.isArray(goals)) die("The goals array is missing or invalid.");
@@ -9844,7 +9861,7 @@ function splitBody2(text5) {
9844
9861
  }
9845
9862
  function readBody(bodyFile) {
9846
9863
  if (!bodyFile) die("--body-file is required; write the goal in a writable temporary file first.");
9847
- const text5 = fs29.readFileSync(bodyFile, "utf8");
9864
+ const text5 = fs30.readFileSync(bodyFile, "utf8");
9848
9865
  if (!text5.trim()) die("The goal must not be empty.");
9849
9866
  return splitBody2(text5);
9850
9867
  }
@@ -9856,7 +9873,7 @@ function named(held4, id) {
9856
9873
  function cmdGoal(args, opts) {
9857
9874
  const sub = args[0] ?? "";
9858
9875
  const { file, held: held4 } = loadGoals();
9859
- const write2 = () => fs29.writeFileSync(file, `${JSON.stringify({ ...held4, goals: void 0, ideas: held4.goals }, null, 2)}
9876
+ const write2 = () => fs30.writeFileSync(file, `${JSON.stringify({ ...held4, goals: void 0, ideas: held4.goals }, null, 2)}
9860
9877
  `);
9861
9878
  if (sub === "new") {
9862
9879
  const title = opts.title?.trim();
@@ -9944,12 +9961,12 @@ var init_goal = __esm({
9944
9961
  });
9945
9962
 
9946
9963
  // ../cli/src/commands/goal-cloud.ts
9947
- import fs30 from "node:fs";
9964
+ import fs31 from "node:fs";
9948
9965
  import os4 from "node:os";
9949
- import path33 from "node:path";
9966
+ import path34 from "node:path";
9950
9967
  import crypto3 from "node:crypto";
9951
9968
  async function request(method, route2, body) {
9952
- if (externalGoalSession()) process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path33.join(os4.homedir(), ".wildcrane");
9969
+ if (externalGoalSession()) process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
9953
9970
  const token3 = await accessToken();
9954
9971
  if (!token3.ok) die("Sign in through the WildCrane plugin, then try again.");
9955
9972
  const response = await fetch(`${cloudEndpoints().api}${route2}`, {
@@ -9981,23 +9998,23 @@ function goalsOf(d2) {
9981
9998
  async function discussion() {
9982
9999
  const session = process.env.CLAUDE_CODE_SESSION_ID || process.env.CODEX_THREAD_ID;
9983
10000
  if (!session) die("Goals exist only inside a WildCrane goal discussion.");
9984
- const home3 = process.env.WILDCRANE_HOME || path33.join(os4.homedir(), ".wildcrane");
10001
+ const home3 = process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
9985
10002
  process.env.AI4KANBAN_HOME ??= home3;
9986
- const machineFile2 = path33.join(home3, "machine.json");
10003
+ const machineFile2 = path34.join(home3, "machine.json");
9987
10004
  let machine;
9988
10005
  try {
9989
- machine = JSON.parse(fs30.readFileSync(machineFile2, "utf8")).id;
10006
+ machine = JSON.parse(fs31.readFileSync(machineFile2, "utf8")).id;
9990
10007
  } catch {
9991
10008
  machine = crypto3.randomUUID();
9992
- fs30.mkdirSync(home3, { recursive: true });
9993
- fs30.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
10009
+ fs31.mkdirSync(home3, { recursive: true });
10010
+ fs31.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
9994
10011
  }
9995
10012
  const held4 = await request("GET", `/v1/runner/folders?machine=${encodeURIComponent(machine)}`);
9996
- const cwd = fs30.realpathSync(process.cwd());
10013
+ const cwd = fs31.realpathSync(process.cwd());
9997
10014
  const folder = held4.folders.filter((f2) => {
9998
10015
  try {
9999
- const dir = fs30.realpathSync(f2.path);
10000
- return cwd === dir || cwd.startsWith(dir + path33.sep);
10016
+ const dir = fs31.realpathSync(f2.path);
10017
+ return cwd === dir || cwd.startsWith(dir + path34.sep);
10001
10018
  } catch {
10002
10019
  return false;
10003
10020
  }
@@ -10006,16 +10023,16 @@ async function discussion() {
10006
10023
  }
10007
10024
  async function withGoalDiscussion(action, save3 = false) {
10008
10025
  const d2 = await discussion();
10009
- const dir = fs30.mkdtempSync(path33.join(os4.tmpdir(), "akb-goals-"));
10010
- const file = path33.join(dir, "goals.json");
10026
+ const dir = fs31.mkdtempSync(path34.join(os4.tmpdir(), "akb-goals-"));
10027
+ const file = path34.join(dir, "goals.json");
10011
10028
  const before = process.env.KANBAN_GOALS;
10012
10029
  try {
10013
10030
  const previous = goalsOf(d2);
10014
- fs30.writeFileSync(file, JSON.stringify({ workspace: d2.workspace, workflows: await workflows2(d2.workspace), ideas: previous.map((g3) => ({ ...g3, task: typeof g3.task === "object" && g3.task ? g3.task.id : g3.task })) }));
10031
+ fs31.writeFileSync(file, JSON.stringify({ workspace: d2.workspace, workflows: await workflows2(d2.workspace), ideas: previous.map((g3) => ({ ...g3, task: typeof g3.task === "object" && g3.task ? g3.task.id : g3.task })) }));
10015
10032
  process.env.KANBAN_GOALS = file;
10016
10033
  const result = save3 ? await quietlyAsync(async () => action()) : await action();
10017
10034
  if (save3) {
10018
- const goals = JSON.parse(fs30.readFileSync(file, "utf8")).ideas;
10035
+ const goals = JSON.parse(fs31.readFileSync(file, "utf8")).ideas;
10019
10036
  const saved = await request("PUT", `/v1/discussions/${d2.id}/draft`, { expectedVersion: d2.version, goals: goals.filter((g3) => !g3.dropped) });
10020
10037
  const savedGoals = goalsOf(saved);
10021
10038
  const fresh = goals.filter((g3) => !g3.dropped && !previous.some((p2) => p2.id === g3.id));
@@ -10034,7 +10051,7 @@ async function withGoalDiscussion(action, save3 = false) {
10034
10051
  } finally {
10035
10052
  if (before === void 0) delete process.env.KANBAN_GOALS;
10036
10053
  else process.env.KANBAN_GOALS = before;
10037
- fs30.rmSync(dir, { recursive: true, force: true });
10054
+ fs31.rmSync(dir, { recursive: true, force: true });
10038
10055
  }
10039
10056
  }
10040
10057
  async function queryPreviews(workflow, workspace) {
@@ -11183,8 +11200,8 @@ var require_command = __commonJS({
11183
11200
  "../cli/node_modules/commander/lib/command.js"(exports) {
11184
11201
  var EventEmitter = __require("node:events").EventEmitter;
11185
11202
  var childProcess = __require("node:child_process");
11186
- var path89 = __require("node:path");
11187
- var fs91 = __require("node:fs");
11203
+ var path90 = __require("node:path");
11204
+ var fs92 = __require("node:fs");
11188
11205
  var process2 = __require("node:process");
11189
11206
  var { Argument: Argument2, humanReadableArgName } = require_argument();
11190
11207
  var { CommanderError: CommanderError2 } = require_error();
@@ -12165,7 +12182,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
12165
12182
  * @param {string} subcommandName
12166
12183
  */
12167
12184
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
12168
- if (fs91.existsSync(executableFile)) return;
12185
+ if (fs92.existsSync(executableFile)) return;
12169
12186
  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";
12170
12187
  const executableMissing = `'${executableFile}' does not exist
12171
12188
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -12183,11 +12200,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
12183
12200
  let launchWithNode = false;
12184
12201
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
12185
12202
  function findFile(baseDir, baseName) {
12186
- const localBin = path89.resolve(baseDir, baseName);
12187
- if (fs91.existsSync(localBin)) return localBin;
12188
- if (sourceExt.includes(path89.extname(baseName))) return void 0;
12203
+ const localBin = path90.resolve(baseDir, baseName);
12204
+ if (fs92.existsSync(localBin)) return localBin;
12205
+ if (sourceExt.includes(path90.extname(baseName))) return void 0;
12189
12206
  const foundExt = sourceExt.find(
12190
- (ext) => fs91.existsSync(`${localBin}${ext}`)
12207
+ (ext) => fs92.existsSync(`${localBin}${ext}`)
12191
12208
  );
12192
12209
  if (foundExt) return `${localBin}${foundExt}`;
12193
12210
  return void 0;
@@ -12199,21 +12216,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
12199
12216
  if (this._scriptPath) {
12200
12217
  let resolvedScriptPath;
12201
12218
  try {
12202
- resolvedScriptPath = fs91.realpathSync(this._scriptPath);
12219
+ resolvedScriptPath = fs92.realpathSync(this._scriptPath);
12203
12220
  } catch {
12204
12221
  resolvedScriptPath = this._scriptPath;
12205
12222
  }
12206
- executableDir = path89.resolve(
12207
- path89.dirname(resolvedScriptPath),
12223
+ executableDir = path90.resolve(
12224
+ path90.dirname(resolvedScriptPath),
12208
12225
  executableDir
12209
12226
  );
12210
12227
  }
12211
12228
  if (executableDir) {
12212
12229
  let localFile = findFile(executableDir, executableFile);
12213
12230
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
12214
- const legacyName = path89.basename(
12231
+ const legacyName = path90.basename(
12215
12232
  this._scriptPath,
12216
- path89.extname(this._scriptPath)
12233
+ path90.extname(this._scriptPath)
12217
12234
  );
12218
12235
  if (legacyName !== this._name) {
12219
12236
  localFile = findFile(
@@ -12224,7 +12241,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
12224
12241
  }
12225
12242
  executableFile = localFile || executableFile;
12226
12243
  }
12227
- launchWithNode = sourceExt.includes(path89.extname(executableFile));
12244
+ launchWithNode = sourceExt.includes(path90.extname(executableFile));
12228
12245
  let proc;
12229
12246
  if (process2.platform !== "win32") {
12230
12247
  if (launchWithNode) {
@@ -13071,7 +13088,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13071
13088
  * @return {Command}
13072
13089
  */
13073
13090
  nameFromFilename(filename) {
13074
- this._name = path89.basename(filename, path89.extname(filename));
13091
+ this._name = path90.basename(filename, path90.extname(filename));
13075
13092
  return this;
13076
13093
  }
13077
13094
  /**
@@ -13085,9 +13102,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
13085
13102
  * @param {string} [path]
13086
13103
  * @return {(string|null|Command)}
13087
13104
  */
13088
- executableDir(path90) {
13089
- if (path90 === void 0) return this._executableDir;
13090
- this._executableDir = path90;
13105
+ executableDir(path91) {
13106
+ if (path91 === void 0) return this._executableDir;
13107
+ this._executableDir = path91;
13091
13108
  return this;
13092
13109
  }
13093
13110
  /**
@@ -13384,11 +13401,11 @@ var init_esm = __esm({
13384
13401
  });
13385
13402
 
13386
13403
  // ../cli/src/lib/cloud/pointer.ts
13387
- import fs31 from "node:fs";
13388
- import path34 from "node:path";
13404
+ import fs32 from "node:fs";
13405
+ import path35 from "node:path";
13389
13406
  function hasRetiredPointer(root2) {
13390
13407
  try {
13391
- const held4 = JSON.parse(fs31.readFileSync(path34.join(root2, POINTER_FILE), "utf8"));
13408
+ const held4 = JSON.parse(fs32.readFileSync(path35.join(root2, POINTER_FILE), "utf8"));
13392
13409
  return typeof held4.workspace === "string" && held4.workspace.trim() !== "";
13393
13410
  } catch {
13394
13411
  return false;
@@ -13403,15 +13420,15 @@ var init_pointer = __esm({
13403
13420
  });
13404
13421
 
13405
13422
  // ../cli/src/lib/card-workflow-backfill.ts
13406
- import fs32 from "node:fs";
13407
- import path35 from "node:path";
13423
+ import fs33 from "node:fs";
13424
+ import path36 from "node:path";
13408
13425
  function backfillCardWorkflows() {
13409
13426
  if (!TODO || !BOARD_STATE) return;
13410
- const mark = path35.join(BOARD_STATE, MARK);
13427
+ const mark = path36.join(BOARD_STATE, MARK);
13411
13428
  try {
13412
- if (fs32.existsSync(mark) || !fs32.existsSync(TODO)) return;
13429
+ if (fs33.existsSync(mark) || !fs33.existsSync(TODO)) return;
13413
13430
  for (const file of walkMd(TODO)) {
13414
- const text5 = fs32.readFileSync(file, "utf8");
13431
+ const text5 = fs33.readFileSync(file, "utf8");
13415
13432
  if (!text5.startsWith("---\n")) continue;
13416
13433
  const end2 = text5.indexOf("\n---", 3);
13417
13434
  if (end2 < 0) continue;
@@ -13419,11 +13436,11 @@ function backfillCardWorkflows() {
13419
13436
  if (!/\ntitle:/.test(head2) || /\nworkflow:/.test(head2)) continue;
13420
13437
  const modules = /\nmodules:[^\n]*/.exec(head2);
13421
13438
  const at2 = modules ? modules.index + modules[0].length : end2;
13422
- fs32.writeFileSync(file, `${text5.slice(0, at2)}
13439
+ fs33.writeFileSync(file, `${text5.slice(0, at2)}
13423
13440
  workflow: coding${text5.slice(at2)}`);
13424
13441
  }
13425
- fs32.mkdirSync(BOARD_STATE, { recursive: true });
13426
- fs32.writeFileSync(mark, "");
13442
+ fs33.mkdirSync(BOARD_STATE, { recursive: true });
13443
+ fs33.writeFileSync(mark, "");
13427
13444
  } catch {
13428
13445
  }
13429
13446
  }
@@ -13438,11 +13455,11 @@ var init_card_workflow_backfill = __esm({
13438
13455
  });
13439
13456
 
13440
13457
  // ../cli/src/lib/view/stamp.ts
13441
- import fs33 from "node:fs";
13442
- import path36 from "node:path";
13458
+ import fs34 from "node:fs";
13459
+ import path37 from "node:path";
13443
13460
  function boardStamp() {
13444
13461
  const parts = [];
13445
- for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS, path36.join(KANBAN, ".mockups")]) walk(dir, parts, 0);
13462
+ for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS, path37.join(KANBAN, ".mockups")]) walk(dir, parts, 0);
13446
13463
  for (const file of [MODULES_MD, ARCHIVE_MD, CONFIG]) {
13447
13464
  stamp2(file, parts);
13448
13465
  }
@@ -13452,19 +13469,19 @@ function walk(dir, parts, depth3) {
13452
13469
  if (depth3 > MAX_DEPTH) return;
13453
13470
  let entries;
13454
13471
  try {
13455
- entries = fs33.readdirSync(dir, { withFileTypes: true });
13472
+ entries = fs34.readdirSync(dir, { withFileTypes: true });
13456
13473
  } catch {
13457
13474
  return;
13458
13475
  }
13459
13476
  for (const entry of entries.sort((a2, b2) => a2.name.localeCompare(b2.name))) {
13460
- const full = path36.join(dir, entry.name);
13477
+ const full = path37.join(dir, entry.name);
13461
13478
  if (entry.isDirectory()) walk(full, parts, depth3 + 1);
13462
13479
  else stamp2(full, parts);
13463
13480
  }
13464
13481
  }
13465
13482
  function stamp2(file, parts) {
13466
13483
  try {
13467
- const s = fs33.statSync(file);
13484
+ const s = fs34.statSync(file);
13468
13485
  parts.push(`${file}:${s.size}:${Math.round(s.mtimeMs)}`);
13469
13486
  } catch {
13470
13487
  }
@@ -13496,8 +13513,8 @@ var init_contract = __esm({
13496
13513
  });
13497
13514
 
13498
13515
  // ../cli/src/lib/board/revision.ts
13499
- import fs34 from "node:fs";
13500
- import path37 from "node:path";
13516
+ import fs35 from "node:fs";
13517
+ import path38 from "node:path";
13501
13518
  function revisionOf(text5) {
13502
13519
  let h3 = 2166136261;
13503
13520
  for (let i = 0; i < text5.length; i++) {
@@ -13509,13 +13526,13 @@ function revisionOf(text5) {
13509
13526
  function cardFile(id) {
13510
13527
  const found2 = locate(id);
13511
13528
  if (!found2) return null;
13512
- return found2.kind === "group" ? path37.join(found2.target, "root.md") : found2.target;
13529
+ return found2.kind === "group" ? path38.join(found2.target, "root.md") : found2.target;
13513
13530
  }
13514
13531
  function cardRevision(id) {
13515
13532
  const file = cardFile(id);
13516
13533
  if (!file) return NO_REVISION;
13517
13534
  try {
13518
- return revisionOf(fs34.readFileSync(file, "utf8"));
13535
+ return revisionOf(fs35.readFileSync(file, "utf8"));
13519
13536
  } catch {
13520
13537
  return NO_REVISION;
13521
13538
  }
@@ -13537,14 +13554,14 @@ var init_revision = __esm({
13537
13554
  });
13538
13555
 
13539
13556
  // ../cli/src/lib/plans.ts
13540
- import fs35 from "node:fs";
13541
- import path38 from "node:path";
13557
+ import fs36 from "node:fs";
13558
+ import path39 from "node:path";
13542
13559
  function planFile(rel2) {
13543
13560
  if (!/^plans\/(archive\/)?[^/\\]+\.md$/.test(rel2)) return null;
13544
13561
  const dir = isArchivedPlan(rel2) ? PLANS_ARCHIVE : PLANS;
13545
13562
  const name = rel2.replace(/^plans\/(archive\/)?/, "");
13546
13563
  if (!name || name.includes("/") || !name.endsWith(".md")) return null;
13547
- return path38.join(dir, name);
13564
+ return path39.join(dir, name);
13548
13565
  }
13549
13566
  function readPlan(rel2) {
13550
13567
  const file = planFile(rel2);
@@ -13552,12 +13569,12 @@ function readPlan(rel2) {
13552
13569
  let text5 = "";
13553
13570
  let found2 = rel2;
13554
13571
  try {
13555
- text5 = fs35.readFileSync(file, "utf8");
13572
+ text5 = fs36.readFileSync(file, "utf8");
13556
13573
  } catch {
13557
13574
  const moved = renamedPlan(rel2);
13558
13575
  if (moved) {
13559
13576
  found2 = moved;
13560
- text5 = fs35.readFileSync(planFile(moved), "utf8");
13577
+ text5 = fs36.readFileSync(planFile(moved), "utf8");
13561
13578
  }
13562
13579
  }
13563
13580
  return { path: found2, text: text5, lines: text5.trim() ? text5.trimEnd().split("\n").length : 0 };
@@ -13572,13 +13589,13 @@ function renamedPlan(rel2) {
13572
13589
  ]) {
13573
13590
  let names3;
13574
13591
  try {
13575
- names3 = fs35.readdirSync(dir);
13592
+ names3 = fs36.readdirSync(dir);
13576
13593
  } catch {
13577
13594
  continue;
13578
13595
  }
13579
13596
  for (const n of names3) {
13580
13597
  if (!n.startsWith(`${id}-`) || !n.endsWith(".md")) continue;
13581
- found2.push({ rel: `${prefix}${n}`, at: fs35.statSync(path38.join(dir, n)).mtimeMs });
13598
+ found2.push({ rel: `${prefix}${n}`, at: fs36.statSync(path39.join(dir, n)).mtimeMs });
13582
13599
  }
13583
13600
  }
13584
13601
  if (!found2.length) return null;
@@ -13587,7 +13604,7 @@ function renamedPlan(rel2) {
13587
13604
  function planFromText(text5) {
13588
13605
  const legacy2 = `${legacyProjectStateDir(KANBAN)}/`;
13589
13606
  if (text5.startsWith(legacy2)) text5 = text5.slice(legacy2.length);
13590
- const local = `${path38.dirname(PLANS)}/`;
13607
+ const local = `${path39.dirname(PLANS)}/`;
13591
13608
  if (text5.startsWith(local)) text5 = text5.slice(local.length);
13592
13609
  if (text5.startsWith(`${KANBAN}/`)) text5 = text5.slice(KANBAN.length + 1);
13593
13610
  const here = `${boardPath()}/`;
@@ -13715,23 +13732,23 @@ var init_telemetry_contract = __esm({
13715
13732
  });
13716
13733
 
13717
13734
  // ../cli/src/lib/agent/catalog.ts
13718
- import fs36 from "node:fs";
13719
- import path39 from "node:path";
13735
+ import fs37 from "node:fs";
13736
+ import path40 from "node:path";
13720
13737
  function cacheFile() {
13721
- return path39.join(machineHome(), "models-dev.json");
13738
+ return path40.join(machineHome(), "models-dev.json");
13722
13739
  }
13723
13740
  function readCache() {
13724
13741
  const file = cacheFile();
13725
13742
  let stamp4;
13726
13743
  try {
13727
- const stat = fs36.statSync(file);
13744
+ const stat = fs37.statSync(file);
13728
13745
  stamp4 = `${stat.mtimeMs}:${stat.size}`;
13729
13746
  } catch {
13730
13747
  return void 0;
13731
13748
  }
13732
13749
  if (held2?.stamp === stamp4) return held2.cached;
13733
13750
  try {
13734
- const data = JSON.parse(fs36.readFileSync(file, "utf8"));
13751
+ const data = JSON.parse(fs37.readFileSync(file, "utf8"));
13735
13752
  if (!data || typeof data.limits !== "object" || !data.limits) return void 0;
13736
13753
  const cached2 = {
13737
13754
  fetchedAt: typeof data.fetchedAt === "number" ? data.fetchedAt : 0,
@@ -13769,8 +13786,8 @@ function refreshCatalog() {
13769
13786
  const limits = limitsIn(await answer2.json());
13770
13787
  if (Object.keys(limits).length === 0) return;
13771
13788
  const file = cacheFile();
13772
- fs36.mkdirSync(path39.dirname(file), { recursive: true });
13773
- fs36.writeFileSync(file, JSON.stringify({ fetchedAt: Date.now(), limits }));
13789
+ fs37.mkdirSync(path40.dirname(file), { recursive: true });
13790
+ fs37.writeFileSync(file, JSON.stringify({ fetchedAt: Date.now(), limits }));
13774
13791
  } catch {
13775
13792
  }
13776
13793
  })();
@@ -13833,8 +13850,8 @@ var init_catalog2 = __esm({
13833
13850
  });
13834
13851
 
13835
13852
  // ../cli/src/lib/machine/telemetry.ts
13836
- import fs37 from "node:fs";
13837
- import path40 from "node:path";
13853
+ import fs38 from "node:fs";
13854
+ import path41 from "node:path";
13838
13855
  import { randomUUID as randomUUID2 } from "node:crypto";
13839
13856
  function readUsageReporting() {
13840
13857
  const { unreadable, values } = heldSettings();
@@ -13868,8 +13885,8 @@ function write(on2, disclosed) {
13868
13885
  if (!on2) patch2.usageInstallId = void 0;
13869
13886
  const saved = saveSettings(patch2);
13870
13887
  if (saved.ok && !on2) {
13871
- fs37.rmSync(usageQueueFile(), { force: true });
13872
- fs37.rmSync(usageStateFile(), { force: true });
13888
+ fs38.rmSync(usageQueueFile(), { force: true });
13889
+ fs38.rmSync(usageStateFile(), { force: true });
13873
13890
  }
13874
13891
  return saved;
13875
13892
  }
@@ -13879,14 +13896,14 @@ var init_telemetry = __esm({
13879
13896
  "use strict";
13880
13897
  init_home();
13881
13898
  init_settings2();
13882
- usageQueueFile = () => path40.join(machineHome(), "usage-queue.jsonl");
13883
- usageStateFile = () => path40.join(machineHome(), "usage-state.json");
13899
+ usageQueueFile = () => path41.join(machineHome(), "usage-queue.jsonl");
13900
+ usageStateFile = () => path41.join(machineHome(), "usage-state.json");
13884
13901
  }
13885
13902
  });
13886
13903
 
13887
13904
  // ../cli/src/lib/machine/usage.ts
13888
- import fs38 from "node:fs";
13889
- import path41 from "node:path";
13905
+ import fs39 from "node:fs";
13906
+ import path42 from "node:path";
13890
13907
  import { randomUUID as randomUUID3 } from "node:crypto";
13891
13908
  function usageSurface() {
13892
13909
  return process.env.KANBAN_DESKTOP === "1" ? "app" : "command";
@@ -13963,15 +13980,15 @@ function endFields({ model, costUsd, ownEndpoint }) {
13963
13980
  }
13964
13981
  function readBoard() {
13965
13982
  try {
13966
- const held4 = JSON.parse(fs38.readFileSync(boardFile(), "utf8"));
13983
+ const held4 = JSON.parse(fs39.readFileSync(boardFile(), "utf8"));
13967
13984
  return held4 && typeof held4 === "object" ? held4 : {};
13968
13985
  } catch {
13969
13986
  return {};
13970
13987
  }
13971
13988
  }
13972
13989
  function writeBoard(state) {
13973
- fs38.mkdirSync(BOARD_STATE, { recursive: true });
13974
- fs38.writeFileSync(boardFile(), `${JSON.stringify(state)}
13990
+ fs39.mkdirSync(BOARD_STATE, { recursive: true });
13991
+ fs39.writeFileSync(boardFile(), `${JSON.stringify(state)}
13975
13992
  `);
13976
13993
  }
13977
13994
  function countBoardEvent(name, n = 1) {
@@ -14015,7 +14032,7 @@ function reportBoardNumbers(customAgentsOn2) {
14015
14032
  function readQueue(day = usageDay()) {
14016
14033
  let text5;
14017
14034
  try {
14018
- text5 = fs38.readFileSync(usageQueueFile(), "utf8");
14035
+ text5 = fs39.readFileSync(usageQueueFile(), "utf8");
14019
14036
  } catch {
14020
14037
  return [];
14021
14038
  }
@@ -14037,8 +14054,8 @@ function readQueue(day = usageDay()) {
14037
14054
  }
14038
14055
  function append(event2) {
14039
14056
  const file = usageQueueFile();
14040
- fs38.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14041
- fs38.appendFileSync(file, `${JSON.stringify(event2)}
14057
+ fs39.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14058
+ fs39.appendFileSync(file, `${JSON.stringify(event2)}
14042
14059
  `);
14043
14060
  const queued = readQueue();
14044
14061
  if (queued.length > QUEUE_MAX) writeQueue(queued.slice(queued.length - QUEUE_MAX));
@@ -14046,14 +14063,14 @@ function append(event2) {
14046
14063
  function writeQueue(events) {
14047
14064
  const file = usageQueueFile();
14048
14065
  if (!events.length) {
14049
- fs38.rmSync(file, { force: true });
14066
+ fs39.rmSync(file, { force: true });
14050
14067
  return;
14051
14068
  }
14052
- fs38.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14069
+ fs39.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14053
14070
  const tmp = `${file}.${process.pid}.tmp`;
14054
- fs38.writeFileSync(tmp, `${events.map((e2) => JSON.stringify(e2)).join("\n")}
14071
+ fs39.writeFileSync(tmp, `${events.map((e2) => JSON.stringify(e2)).join("\n")}
14055
14072
  `);
14056
- fs38.renameSync(tmp, file);
14073
+ fs39.renameSync(tmp, file);
14057
14074
  }
14058
14075
  function shiftDay(day, days) {
14059
14076
  const at2 = Date.parse(`${day}T00:00:00Z`);
@@ -14061,7 +14078,7 @@ function shiftDay(day, days) {
14061
14078
  }
14062
14079
  function readState() {
14063
14080
  try {
14064
- const parsed = JSON.parse(fs38.readFileSync(usageStateFile(), "utf8"));
14081
+ const parsed = JSON.parse(fs39.readFileSync(usageStateFile(), "utf8"));
14065
14082
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
14066
14083
  } catch {
14067
14084
  return {};
@@ -14069,12 +14086,12 @@ function readState() {
14069
14086
  }
14070
14087
  function writeState(state) {
14071
14088
  try {
14072
- fs38.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14089
+ fs39.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14073
14090
  const file = usageStateFile();
14074
14091
  const tmp = `${file}.${process.pid}.tmp`;
14075
- fs38.writeFileSync(tmp, `${JSON.stringify(state, null, 2)}
14092
+ fs39.writeFileSync(tmp, `${JSON.stringify(state, null, 2)}
14076
14093
  `);
14077
- fs38.renameSync(tmp, file);
14094
+ fs39.renameSync(tmp, file);
14078
14095
  } catch {
14079
14096
  return;
14080
14097
  }
@@ -14165,7 +14182,7 @@ var init_usage = __esm({
14165
14182
  "decisions_stood",
14166
14183
  "decisions_overruled"
14167
14184
  ];
14168
- boardFile = () => path41.join(BOARD_STATE, "usage-board.json");
14185
+ boardFile = () => path42.join(BOARD_STATE, "usage-board.json");
14169
14186
  countOf = (counts, name) => {
14170
14187
  const n = counts?.[name];
14171
14188
  return typeof n === "number" && Number.isInteger(n) && n > 0 ? n : 0;
@@ -14212,14 +14229,14 @@ var init_candidate = __esm({
14212
14229
  });
14213
14230
 
14214
14231
  // ../cli/src/lib/agent/outputs.ts
14215
- import fs39 from "node:fs";
14232
+ import fs40 from "node:fs";
14216
14233
  import os5 from "node:os";
14217
- import path42 from "node:path";
14234
+ import path43 from "node:path";
14218
14235
  function cardBody(cardId2) {
14219
14236
  const found2 = locate(cardId2) ?? locateArchived(cardId2);
14220
14237
  if (!found2) return "";
14221
14238
  try {
14222
- return fs39.readFileSync(found2.kind === "group" ? path42.join(found2.target, "root.md") : found2.target, "utf8");
14239
+ return fs40.readFileSync(found2.kind === "group" ? path43.join(found2.target, "root.md") : found2.target, "utf8");
14223
14240
  } catch {
14224
14241
  return "";
14225
14242
  }
@@ -14242,7 +14259,7 @@ function filesStop(delivery) {
14242
14259
  if (!outputs.length) {
14243
14260
  return { reason: "output", why: "the card records no output file", paths: [] };
14244
14261
  }
14245
- const missing = outputs.filter((f2) => !fs39.existsSync(resolveOutput(f2)));
14262
+ const missing = outputs.filter((f2) => !fs40.existsSync(resolveOutput(f2)));
14246
14263
  if (missing.length) {
14247
14264
  return { reason: "output", why: `recorded output files are missing: ${missing.join(", ")}`, paths: missing };
14248
14265
  }
@@ -14262,20 +14279,20 @@ var init_outputs = __esm({
14262
14279
  plannedTodos = (cardId2) => todos(cardId2).map((t) => t.text);
14263
14280
  looksLikePath = (token3) => !/\s/.test(token3) && !token3.includes("://") && !token3.startsWith("-") && token3.includes("/");
14264
14281
  resolveOutput = (file) => {
14265
- if (file.startsWith("~/")) return path42.join(os5.homedir(), file.slice(2));
14266
- if (path42.isAbsolute(file)) return file;
14267
- if (file.startsWith(".assets/")) return path42.join(ASSETS, file.slice(".assets/".length));
14268
- return path42.join(REPO_ROOT, file);
14282
+ if (file.startsWith("~/")) return path43.join(os5.homedir(), file.slice(2));
14283
+ if (path43.isAbsolute(file)) return file;
14284
+ if (file.startsWith(".assets/")) return path43.join(ASSETS, file.slice(".assets/".length));
14285
+ return path43.join(REPO_ROOT, file);
14269
14286
  };
14270
14287
  }
14271
14288
  });
14272
14289
 
14273
14290
  // ../cli/src/lib/agent/commit-mode.ts
14274
- import fs40 from "node:fs";
14291
+ import fs41 from "node:fs";
14275
14292
  function recordedIds() {
14276
14293
  try {
14277
14294
  return new Set(
14278
- fs40.readdirSync(DELIVERIES).filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, -".json".length))
14295
+ fs41.readdirSync(DELIVERIES).filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, -".json".length))
14279
14296
  );
14280
14297
  } catch {
14281
14298
  return /* @__PURE__ */ new Set();
@@ -14308,7 +14325,7 @@ var init_commit_mode = __esm({
14308
14325
  init_worktree();
14309
14326
  ID_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
14310
14327
  ID_LENGTH2 = 8;
14311
- deliveryCwd = (delivery) => delivery.worktree && fs40.existsSync(worktreeDir(delivery.worktree)) ? worktreeDir(delivery.worktree) : REPO_ROOT;
14328
+ deliveryCwd = (delivery) => delivery.worktree && fs41.existsSync(worktreeDir(delivery.worktree)) ? worktreeDir(delivery.worktree) : REPO_ROOT;
14312
14329
  }
14313
14330
  });
14314
14331
 
@@ -14504,12 +14521,12 @@ var init_runner = __esm({
14504
14521
  });
14505
14522
 
14506
14523
  // ../cli/src/lib/agent/rules.ts
14507
- import fs41 from "node:fs";
14508
- import path43 from "node:path";
14524
+ import fs42 from "node:fs";
14525
+ import path44 from "node:path";
14509
14526
  function ruleFile(agent) {
14510
14527
  if (!agent || hiddenRole(agent)) return "";
14511
14528
  try {
14512
- return fs41.readFileSync(rulePath(agent), "utf8").trim();
14529
+ return fs42.readFileSync(rulePath(agent), "utf8").trim();
14513
14530
  } catch {
14514
14531
  return "";
14515
14532
  }
@@ -14524,11 +14541,11 @@ function setAgentRule(agent, text5) {
14524
14541
  const rule = String(text5 ?? "").trim();
14525
14542
  try {
14526
14543
  if (!rule) {
14527
- fs41.rmSync(rulePath(agent), { force: true });
14544
+ fs42.rmSync(rulePath(agent), { force: true });
14528
14545
  return { ok: true };
14529
14546
  }
14530
- fs41.mkdirSync(RULES, { recursive: true });
14531
- fs41.writeFileSync(rulePath(agent), `${rule}
14547
+ fs42.mkdirSync(RULES, { recursive: true });
14548
+ fs42.writeFileSync(rulePath(agent), `${rule}
14532
14549
  `);
14533
14550
  return { ok: true };
14534
14551
  } catch (err) {
@@ -14585,7 +14602,7 @@ function migrateFlowRules() {
14585
14602
  adoptRenamedRules();
14586
14603
  let here;
14587
14604
  try {
14588
- here = new Set(fs41.readdirSync(RULES));
14605
+ here = new Set(fs42.readdirSync(RULES));
14589
14606
  } catch {
14590
14607
  return [];
14591
14608
  }
@@ -14599,9 +14616,9 @@ function migrateFlowRules() {
14599
14616
  if (!from.length) continue;
14600
14617
  const parts = [ruleFile(owner.name), ...from.map(ruleFile)].filter(Boolean);
14601
14618
  try {
14602
- if (parts.length) fs41.writeFileSync(rulePath(owner.name), `${parts.join("\n\n")}
14619
+ if (parts.length) fs42.writeFileSync(rulePath(owner.name), `${parts.join("\n\n")}
14603
14620
  `);
14604
- for (const flow of from) fs41.rmSync(rulePath(flow), { force: true });
14621
+ for (const flow of from) fs42.rmSync(rulePath(flow), { force: true });
14605
14622
  } catch (err) {
14606
14623
  notes.push(`could not move the ${from.join(", ")} rule(s) onto \`${owner.name}\`: ${String(err)}`);
14607
14624
  continue;
@@ -14615,7 +14632,7 @@ function migrateFlowRules() {
14615
14632
  function adoptRenamedRules() {
14616
14633
  let here;
14617
14634
  try {
14618
- here = fs41.readdirSync(RULES);
14635
+ here = fs42.readdirSync(RULES);
14619
14636
  } catch {
14620
14637
  return;
14621
14638
  }
@@ -14625,13 +14642,13 @@ function adoptRenamedRules() {
14625
14642
  const now = RENAMED_ROLES[was] ?? canonicalSpecAgent(was);
14626
14643
  if (now === was) continue;
14627
14644
  try {
14628
- if (!fs41.existsSync(rulePath(now))) fs41.renameSync(rulePath(was), rulePath(now));
14645
+ if (!fs42.existsSync(rulePath(now))) fs42.renameSync(rulePath(was), rulePath(now));
14629
14646
  else if (FOLDED_SPEC_AGENTS.has(was)) {
14630
14647
  const kept2 = ruleFile(now);
14631
14648
  const carried = ruleFile(was);
14632
- if (carried && !kept2.includes(carried)) fs41.writeFileSync(rulePath(now), `${[kept2, carried].filter(Boolean).join("\n\n")}
14649
+ if (carried && !kept2.includes(carried)) fs42.writeFileSync(rulePath(now), `${[kept2, carried].filter(Boolean).join("\n\n")}
14633
14650
  `);
14634
- fs41.rmSync(rulePath(was), { force: true });
14651
+ fs42.rmSync(rulePath(was), { force: true });
14635
14652
  }
14636
14653
  } catch {
14637
14654
  }
@@ -14648,7 +14665,7 @@ var init_rules2 = __esm({
14648
14665
  init_runner();
14649
14666
  init_workflows();
14650
14667
  init_types();
14651
- rulePath = (agent) => path43.join(RULES, `${agent}.md`);
14668
+ rulePath = (agent) => path44.join(RULES, `${agent}.md`);
14652
14669
  notOnTheRoster = (name) => `"${name}" is not an agent on this board. It has: ${agentNames().join(", ")}.`;
14653
14670
  flowForRequest = (req) => req.refineRound !== void 0 && REFINE_ACTIONS.has(req.action) ? flowByCommand("refine") : flowByAction(req.action);
14654
14671
  ruleOwnerSays = (owner) => `\`${owner.name}\` agent carries one rule of its own${owner.role ? ", on every flow it runs" : ""}`;
@@ -14661,8 +14678,8 @@ var init_rules2 = __esm({
14661
14678
  });
14662
14679
 
14663
14680
  // ../cli/src/lib/agent/deliveries.ts
14664
- import fs42 from "node:fs";
14665
- import path44 from "node:path";
14681
+ import fs43 from "node:fs";
14682
+ import path45 from "node:path";
14666
14683
  function writeAudit(delivery, runs) {
14667
14684
  const known2 = new Map(readAudit(delivery.deliveryId)?.sessions.map((s) => [s.sessionId, s]) ?? []);
14668
14685
  const sessions = delivery.sessions.flatMap((id) => {
@@ -14690,10 +14707,10 @@ function writeAudit(delivery, runs) {
14690
14707
  }
14691
14708
  function writeAuditFile(record) {
14692
14709
  try {
14693
- fs42.mkdirSync(DELIVERIES, { recursive: true });
14710
+ fs43.mkdirSync(DELIVERIES, { recursive: true });
14694
14711
  const tmp = `${auditPath(record.deliveryId)}.tmp`;
14695
- fs42.writeFileSync(tmp, JSON.stringify(record, null, 2) + "\n");
14696
- fs42.renameSync(tmp, auditPath(record.deliveryId));
14712
+ fs43.writeFileSync(tmp, JSON.stringify(record, null, 2) + "\n");
14713
+ fs43.renameSync(tmp, auditPath(record.deliveryId));
14697
14714
  return true;
14698
14715
  } catch {
14699
14716
  return false;
@@ -14701,7 +14718,7 @@ function writeAuditFile(record) {
14701
14718
  }
14702
14719
  function readAudit(deliveryId) {
14703
14720
  try {
14704
- const data = JSON.parse(fs42.readFileSync(auditPath(deliveryId), "utf8"));
14721
+ const data = JSON.parse(fs43.readFileSync(auditPath(deliveryId), "utf8"));
14705
14722
  return { sessions: Array.isArray(data?.sessions) ? data.sessions : [] };
14706
14723
  } catch {
14707
14724
  return null;
@@ -14716,7 +14733,7 @@ function syncAudit(deliveryId, just) {
14716
14733
  }
14717
14734
  function wholeAudit(file) {
14718
14735
  try {
14719
- const data = JSON.parse(fs42.readFileSync(file, "utf8"));
14736
+ const data = JSON.parse(fs43.readFileSync(file, "utf8"));
14720
14737
  return typeof data?.deliveryId === "string" && Array.isArray(data.sessions) ? data : null;
14721
14738
  } catch {
14722
14739
  return null;
@@ -14729,14 +14746,14 @@ function activeAudit(file) {
14729
14746
  function allAudits() {
14730
14747
  let names3;
14731
14748
  try {
14732
- names3 = fs42.readdirSync(DELIVERIES);
14749
+ names3 = fs43.readdirSync(DELIVERIES);
14733
14750
  } catch {
14734
14751
  return [];
14735
14752
  }
14736
14753
  const out = [];
14737
14754
  for (const name of names3) {
14738
14755
  if (!name.endsWith(".json")) continue;
14739
- const audit = wholeAudit(path44.join(DELIVERIES, name));
14756
+ const audit = wholeAudit(path45.join(DELIVERIES, name));
14740
14757
  if (audit) out.push(audit);
14741
14758
  }
14742
14759
  return out;
@@ -14909,10 +14926,10 @@ function carryOnFrom(_deliveryId) {
14909
14926
  function approvedRequirements(cardId2) {
14910
14927
  const found2 = locate(cardId2);
14911
14928
  if (!found2) return "";
14912
- const file = found2.kind === "group" ? path44.join(found2.target, "root.md") : found2.target;
14929
+ const file = found2.kind === "group" ? path45.join(found2.target, "root.md") : found2.target;
14913
14930
  let text5;
14914
14931
  try {
14915
- text5 = fs42.readFileSync(file, "utf8");
14932
+ text5 = fs43.readFileSync(file, "utf8");
14916
14933
  } catch {
14917
14934
  return "";
14918
14935
  }
@@ -14942,8 +14959,8 @@ function cardMeta2(cardId2) {
14942
14959
  try {
14943
14960
  const found2 = locate(cardId2);
14944
14961
  if (!found2) return null;
14945
- const file = found2.kind === "group" ? path44.join(found2.target, "root.md") : found2.target;
14946
- return parseFrontmatter(fs42.readFileSync(file, "utf8")).meta;
14962
+ const file = found2.kind === "group" ? path45.join(found2.target, "root.md") : found2.target;
14963
+ return parseFrontmatter(fs43.readFileSync(file, "utf8")).meta;
14947
14964
  } catch {
14948
14965
  return null;
14949
14966
  }
@@ -15115,11 +15132,11 @@ var init_deliveries = __esm({
15115
15132
  init_types();
15116
15133
  init_worktree();
15117
15134
  init_lock();
15118
- auditPath = (deliveryId) => path44.join(DELIVERIES, `${deliveryId}.json`);
15135
+ auditPath = (deliveryId) => path45.join(DELIVERIES, `${deliveryId}.json`);
15119
15136
  activeAudits = () => allAudits().filter((a2) => a2.status === "active");
15120
15137
  auditRow = (audit) => readDeliveryRow({ ...audit, sessions: audit.sessions.map((s) => s.sessionId) });
15121
15138
  lastSessionRunning = (audit) => audit.sessions[audit.sessions.length - 1]?.status === "running";
15122
- localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path44.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs42.existsSync(logPathOf(session.sessionId)));
15139
+ localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path45.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs43.existsSync(logPathOf(session.sessionId)));
15123
15140
  unknownDelivery = (id) => refusal("deliveryNotFound", `no delivery here answers to "${id}"`, { id });
15124
15141
  isResumable = (delivery) => !resumeRefusal(delivery);
15125
15142
  APPROVED = [
@@ -15143,35 +15160,35 @@ var init_deliveries = __esm({
15143
15160
  });
15144
15161
 
15145
15162
  // ../cli/src/lib/agent/pictures.ts
15146
- import fs43 from "node:fs";
15147
- import path45 from "node:path";
15163
+ import fs44 from "node:fs";
15164
+ import path46 from "node:path";
15148
15165
  function claimRunPictures(box2, sessionId, names3 = []) {
15149
15166
  if (!box2 || !freeBox(box2) || names3.length === 0) return [];
15150
15167
  const from = pictureBox(box2);
15151
15168
  const to = pictureBox(sessionId);
15152
15169
  try {
15153
- fs43.mkdirSync(SESSIONS_DIR, { recursive: true });
15154
- fs43.renameSync(from, to);
15170
+ fs44.mkdirSync(SESSIONS_DIR, { recursive: true });
15171
+ fs44.renameSync(from, to);
15155
15172
  } catch {
15156
15173
  return [];
15157
15174
  }
15158
- return names3.filter(pictureName).map((name) => path45.join(to, name)).filter((file) => fs43.existsSync(file));
15175
+ return names3.filter(pictureName).map((name) => path46.join(to, name)).filter((file) => fs44.existsSync(file));
15159
15176
  }
15160
15177
  function returnRunPictures(sessionId, box2) {
15161
15178
  if (!box2 || !boxId(box2)) return;
15162
15179
  try {
15163
- fs43.renameSync(pictureBox(sessionId), pictureBox(box2));
15180
+ fs44.renameSync(pictureBox(sessionId), pictureBox(box2));
15164
15181
  } catch {
15165
15182
  }
15166
15183
  }
15167
15184
  function moveRunPictures(from, to, files2 = []) {
15168
15185
  if (files2.length === 0) return [];
15169
15186
  try {
15170
- fs43.renameSync(pictureBox(from), pictureBox(to));
15187
+ fs44.renameSync(pictureBox(from), pictureBox(to));
15171
15188
  } catch {
15172
15189
  return files2;
15173
15190
  }
15174
- return files2.map((file) => path45.join(pictureBox(to), path45.basename(file)));
15191
+ return files2.map((file) => path46.join(pictureBox(to), path46.basename(file)));
15175
15192
  }
15176
15193
  var pictureName, boxId, freeBox, pictureBox;
15177
15194
  var init_pictures = __esm({
@@ -15180,8 +15197,8 @@ var init_pictures = __esm({
15180
15197
  init_paths();
15181
15198
  pictureName = (name) => /^[0-9a-f-]{36}\.[a-z0-9]{2,5}$/.test(name);
15182
15199
  boxId = (box2) => /^[0-9a-f-]{36}$/.test(box2);
15183
- freeBox = (box2) => boxId(box2) && !fs43.existsSync(path45.join(SESSIONS_DIR, `${box2}.log`));
15184
- pictureBox = (box2) => path45.join(SESSIONS_DIR, `${box2}.images`);
15200
+ freeBox = (box2) => boxId(box2) && !fs44.existsSync(path46.join(SESSIONS_DIR, `${box2}.log`));
15201
+ pictureBox = (box2) => path46.join(SESSIONS_DIR, `${box2}.images`);
15185
15202
  }
15186
15203
  });
15187
15204
 
@@ -15270,8 +15287,8 @@ var init_components = __esm({
15270
15287
  });
15271
15288
 
15272
15289
  // ../cli/src/lib/memories.ts
15273
- import fs44 from "node:fs";
15274
- import path46 from "node:path";
15290
+ import fs45 from "node:fs";
15291
+ import path47 from "node:path";
15275
15292
  function readMemory(text5, builtIn, folder) {
15276
15293
  const { meta, body } = splitFrontmatter(text5);
15277
15294
  if (meta === null) return null;
@@ -15291,7 +15308,7 @@ function readMemory(text5, builtIn, folder) {
15291
15308
  rules: body.trim(),
15292
15309
  text: text5,
15293
15310
  builtIn,
15294
- dir: path46.join(MEMORY, folder)
15311
+ dir: path47.join(MEMORY, folder)
15295
15312
  };
15296
15313
  }
15297
15314
  function globalMemories() {
@@ -15302,14 +15319,14 @@ function globalMemories() {
15302
15319
  }
15303
15320
  let folders2 = [];
15304
15321
  try {
15305
- folders2 = fs44.readdirSync(MEMORY, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
15322
+ folders2 = fs45.readdirSync(MEMORY, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
15306
15323
  } catch {
15307
15324
  }
15308
15325
  for (const name of folders2) {
15309
15326
  if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR) continue;
15310
- const file = path46.join(MEMORY, name, GLOBAL_MEMORY_FILE);
15311
- if (!fs44.existsSync(file)) continue;
15312
- const memory = readMemory(fs44.readFileSync(file, "utf8"), false, name);
15327
+ const file = path47.join(MEMORY, name, GLOBAL_MEMORY_FILE);
15328
+ if (!fs45.existsSync(file)) continue;
15329
+ const memory = readMemory(fs45.readFileSync(file, "utf8"), false, name);
15313
15330
  if (memory) out.push(memory);
15314
15331
  }
15315
15332
  return out;
@@ -15365,16 +15382,16 @@ var init_facts = __esm({
15365
15382
  });
15366
15383
 
15367
15384
  // ../cli/src/lib/view/archive.ts
15368
- import fs45 from "node:fs";
15369
- import path47 from "node:path";
15385
+ import fs46 from "node:fs";
15386
+ import path48 from "node:path";
15370
15387
  function archivedId(file) {
15371
- const own = idPrefix(path47.basename(file));
15372
- return own !== null ? own : idPrefix(path47.basename(path47.dirname(file)));
15388
+ const own = idPrefix(path48.basename(file));
15389
+ return own !== null ? own : idPrefix(path48.basename(path48.dirname(file)));
15373
15390
  }
15374
15391
  function readFile(file) {
15375
15392
  const id = archivedId(file);
15376
15393
  if (id === null) return null;
15377
- const { meta, body } = parseFrontmatter(fs45.readFileSync(file, "utf8"));
15394
+ const { meta, body } = parseFrontmatter(fs46.readFileSync(file, "utf8"));
15378
15395
  if (!meta) return null;
15379
15396
  return {
15380
15397
  row: {
@@ -15382,15 +15399,15 @@ function readFile(file) {
15382
15399
  title: meta.title,
15383
15400
  archived: meta.archived,
15384
15401
  rejected: meta.rejected,
15385
- relPath: rel(file).split(path47.sep).join("/")
15402
+ relPath: rel(file).split(path48.sep).join("/")
15386
15403
  },
15387
15404
  body: body.replace(/^\n+/, "").replace(/\s+$/, ""),
15388
15405
  meta
15389
15406
  };
15390
15407
  }
15391
15408
  function readArchive() {
15392
- const relPath = rel(ARCHIVE).split(path47.sep).join("/");
15393
- if (!fs45.existsSync(ARCHIVE)) return { relPath, cards: [] };
15409
+ const relPath = rel(ARCHIVE).split(path48.sep).join("/");
15410
+ if (!fs46.existsSync(ARCHIVE)) return { relPath, cards: [] };
15394
15411
  const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
15395
15412
  cards.sort((a2, b2) => b2.id - a2.id);
15396
15413
  return { relPath, cards };
@@ -15405,7 +15422,7 @@ var init_archive = __esm({
15405
15422
  });
15406
15423
 
15407
15424
  // ../cli/src/lib/agent/prompts.ts
15408
- import path48 from "node:path";
15425
+ import path49 from "node:path";
15409
15426
  function stopReason(deliveryId) {
15410
15427
  const delivery = findDelivery(deliveryId);
15411
15428
  if (!delivery) return void 0;
@@ -15468,7 +15485,7 @@ ${text5}` : "";
15468
15485
  }
15469
15486
  function cardFileOf(id) {
15470
15487
  const found2 = id === void 0 ? null : locate(id);
15471
- return found2 ? found2.kind === "group" ? path48.join(found2.target, "root.md") : found2.target : "";
15488
+ return found2 ? found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target : "";
15472
15489
  }
15473
15490
  function realPaths(text5, req) {
15474
15491
  if (req.action !== "scheduled" && req.action !== "sub") return text5;
@@ -15555,7 +15572,7 @@ function frozenRules(req) {
15555
15572
  function archivedCardFile(id) {
15556
15573
  const found2 = locateArchived(id);
15557
15574
  if (!found2) return `${rel(ARCHIVE)}/`;
15558
- return rel(found2.kind === "group" ? path48.join(found2.target, "root.md") : found2.target);
15575
+ return rel(found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target);
15559
15576
  }
15560
15577
  function shippedLines(cardId2) {
15561
15578
  const delivery = endedDelivery(`${cardId2}`);
@@ -15698,7 +15715,7 @@ function actionPrompt(req, command, notes) {
15698
15715
  case "spec": {
15699
15716
  const agent = findSpecAgent(req.specAgent ?? "");
15700
15717
  const found2 = req.id === void 0 ? null : locate(req.id);
15701
- const cardFile3 = found2 ? rel(found2.kind === "group" ? path48.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
15718
+ const cardFile3 = found2 ? rel(found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
15702
15719
  const own = agent ? specAgentInstructions(agent) : null;
15703
15720
  if (own) notes.push(...own.notes);
15704
15721
  const memory = agent ? agentMemoryBlock(agent) : "";
@@ -15879,17 +15896,17 @@ var init_prompts = __esm({
15879
15896
  // ../cli/src/lib/agent/stop.ts
15880
15897
  import { spawnSync as spawnSync4 } from "node:child_process";
15881
15898
  import { randomUUID as randomUUID4 } from "node:crypto";
15882
- import fs46 from "node:fs";
15899
+ import fs47 from "node:fs";
15883
15900
  import os6 from "node:os";
15884
15901
  function markedInProc(entry, strict = false) {
15885
15902
  const pids = [];
15886
- for (const name of fs46.readdirSync("/proc")) {
15903
+ for (const name of fs47.readdirSync("/proc")) {
15887
15904
  if (!/^\d+$/.test(name)) continue;
15888
15905
  try {
15889
- if (fs46.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
15906
+ if (fs47.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
15890
15907
  } catch (error) {
15891
15908
  if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
15892
- const stat = fs46.statSync(`/proc/${name}`, { throwIfNoEntry: false });
15909
+ const stat = fs47.statSync(`/proc/${name}`, { throwIfNoEntry: false });
15893
15910
  if (stat?.uid === process.getuid?.()) throw error;
15894
15911
  }
15895
15912
  }
@@ -16085,10 +16102,10 @@ var init_stop = __esm({
16085
16102
  });
16086
16103
 
16087
16104
  // ../cli/src/lib/agent/creation-lock.ts
16088
- import path49 from "node:path";
16105
+ import path50 from "node:path";
16089
16106
  function withCreationLock(fn2) {
16090
16107
  if (depth2) return fn2();
16091
- return withLock(path49.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
16108
+ return withLock(path50.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
16092
16109
  depth2++;
16093
16110
  try {
16094
16111
  return fn2();
@@ -16109,8 +16126,8 @@ var init_creation_lock = __esm({
16109
16126
 
16110
16127
  // ../cli/src/lib/agent/sessions.ts
16111
16128
  import { randomUUID as randomUUID5 } from "node:crypto";
16112
- import fs47 from "node:fs";
16113
- import path50 from "node:path";
16129
+ import fs48 from "node:fs";
16130
+ import path51 from "node:path";
16114
16131
  function reap(runs, reaped = [], restore = []) {
16115
16132
  let changed = false;
16116
16133
  const now = Date.now();
@@ -16130,7 +16147,7 @@ function reap(runs, reaped = [], restore = []) {
16130
16147
  }
16131
16148
  function stampDuration(run3, endedAt) {
16132
16149
  try {
16133
- fs47.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
16150
+ fs48.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
16134
16151
  } catch {
16135
16152
  }
16136
16153
  }
@@ -16144,7 +16161,7 @@ function cardNow(cardId2) {
16144
16161
  try {
16145
16162
  const file = cardFile(cardId2);
16146
16163
  if (!file) return null;
16147
- const { meta } = parseFrontmatter(fs47.readFileSync(file, "utf8"));
16164
+ const { meta } = parseFrontmatter(fs48.readFileSync(file, "utf8"));
16148
16165
  if (!meta) return null;
16149
16166
  return { status: meta.status || "todo", questions: openOf(meta.questions).length, title: meta.title };
16150
16167
  } catch {
@@ -16276,9 +16293,9 @@ function leftBoardOnLanding(id) {
16276
16293
  function archivedRejected(id) {
16277
16294
  const filed = locateArchived(id);
16278
16295
  if (!filed) return null;
16279
- const file = filed.kind === "group" ? path50.join(filed.target, "root.md") : filed.target;
16296
+ const file = filed.kind === "group" ? path51.join(filed.target, "root.md") : filed.target;
16280
16297
  try {
16281
- return !!parseFrontmatter(fs47.readFileSync(file, "utf8")).meta?.rejected;
16298
+ return !!parseFrontmatter(fs48.readFileSync(file, "utf8")).meta?.rejected;
16282
16299
  } catch {
16283
16300
  return false;
16284
16301
  }
@@ -16529,7 +16546,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID5(), said3) {
16529
16546
  return { run: record, spec };
16530
16547
  }
16531
16548
  function planningSession(cardId2, cwd = REPO_ROOT) {
16532
- const here = (dir) => !dir || path50.resolve(dir) === cwd;
16549
+ const here = (dir) => !dir || path51.resolve(dir) === cwd;
16533
16550
  const planned = readRuns().filter((r2) => r2.status === "done" && r2.cardId === cardId2 && PLANNING.has(r2.action)).sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
16534
16551
  if (!planned) return { none: "unrecorded" };
16535
16552
  if (!here(planned.cwd)) return { none: "elsewhere" };
@@ -16748,8 +16765,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
16748
16765
  if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
16749
16766
  clearAsks(prev.sessionId);
16750
16767
  try {
16751
- fs47.unlinkSync(prev.logPath);
16752
- fs47.rmSync(eventsPathOf(prev.sessionId), { force: true });
16768
+ fs48.unlinkSync(prev.logPath);
16769
+ fs48.rmSync(eventsPathOf(prev.sessionId), { force: true });
16753
16770
  } catch {
16754
16771
  }
16755
16772
  if (retry2 && prev.pictures?.length) {
@@ -16772,8 +16789,8 @@ function forgetRun(sessionId) {
16772
16789
  if (!gone) return;
16773
16790
  clearAsks(sessionId);
16774
16791
  try {
16775
- fs47.unlinkSync(gone.logPath);
16776
- fs47.rmSync(eventsPathOf(gone.sessionId), { force: true });
16792
+ fs48.unlinkSync(gone.logPath);
16793
+ fs48.rmSync(eventsPathOf(gone.sessionId), { force: true });
16777
16794
  } catch {
16778
16795
  }
16779
16796
  }
@@ -16802,14 +16819,14 @@ function noteSpecRefusals(sessionId, refused) {
16802
16819
  }
16803
16820
  function clearAsks(sessionId) {
16804
16821
  try {
16805
- fs47.unlinkSync(asksPathOf(sessionId));
16822
+ fs48.unlinkSync(asksPathOf(sessionId));
16806
16823
  } catch {
16807
16824
  }
16808
16825
  }
16809
16826
  function readAsks(sessionId) {
16810
16827
  let data;
16811
16828
  try {
16812
- data = JSON.parse(fs47.readFileSync(asksPathOf(sessionId), "utf8"));
16829
+ data = JSON.parse(fs48.readFileSync(asksPathOf(sessionId), "utf8"));
16813
16830
  } catch {
16814
16831
  return { asks: [], refines: [], refused: [] };
16815
16832
  }
@@ -16836,10 +16853,10 @@ function readAsks(sessionId) {
16836
16853
  return { asks: asks.filter((a2) => !discarded.has(a2.cardId)), refines: refines.filter((a2) => !discarded.has(a2.cardId)), refused };
16837
16854
  }
16838
16855
  function writeAsks(sessionId, file) {
16839
- fs47.mkdirSync(SESSIONS_DIR, { recursive: true });
16856
+ fs48.mkdirSync(SESSIONS_DIR, { recursive: true });
16840
16857
  const tmp = `${asksPathOf(sessionId)}.tmp`;
16841
- fs47.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
16842
- fs47.renameSync(tmp, asksPathOf(sessionId));
16858
+ fs48.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
16859
+ fs48.renameSync(tmp, asksPathOf(sessionId));
16843
16860
  }
16844
16861
  function markSpawned(sessionId, pid) {
16845
16862
  patch(sessionId, (r2) => {
@@ -16970,12 +16987,12 @@ async function resumeDelivery(id) {
16970
16987
  return { ok: true, deliveryId: delivery.deliveryId, carryOn };
16971
16988
  }
16972
16989
  function writeSpec(spec) {
16973
- fs47.mkdirSync(SESSIONS_DIR, { recursive: true });
16974
- fs47.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
16990
+ fs48.mkdirSync(SESSIONS_DIR, { recursive: true });
16991
+ fs48.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
16975
16992
  }
16976
16993
  function readSpec(sessionId) {
16977
16994
  try {
16978
- const spec = JSON.parse(fs47.readFileSync(specPathOf(sessionId), "utf8"));
16995
+ const spec = JSON.parse(fs48.readFileSync(specPathOf(sessionId), "utf8"));
16979
16996
  return spec && Array.isArray(spec.plan?.argv) ? spec : null;
16980
16997
  } catch {
16981
16998
  return null;
@@ -16983,28 +17000,28 @@ function readSpec(sessionId) {
16983
17000
  }
16984
17001
  function dropSpec(sessionId) {
16985
17002
  try {
16986
- fs47.unlinkSync(specPathOf(sessionId));
17003
+ fs48.unlinkSync(specPathOf(sessionId));
16987
17004
  } catch {
16988
17005
  }
16989
17006
  }
16990
17007
  async function acquireIndexLock(giveUp) {
16991
17008
  const until = Date.now() + INDEX_WAIT_MS;
16992
- const holder = path50.join(INDEX_LOCK2, "holder");
17009
+ const holder = path51.join(INDEX_LOCK2, "holder");
16993
17010
  for (; ; ) {
16994
17011
  if (giveUp()) return null;
16995
17012
  try {
16996
- fs47.mkdirSync(INDEX_LOCK2, { recursive: false });
16997
- fs47.writeFileSync(holder, String(process.pid));
16998
- return () => fs47.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17013
+ fs48.mkdirSync(INDEX_LOCK2, { recursive: false });
17014
+ fs48.writeFileSync(holder, String(process.pid));
17015
+ return () => fs48.rmSync(INDEX_LOCK2, { recursive: true, force: true });
16999
17016
  } catch (err) {
17000
17017
  const code = err.code;
17001
17018
  if (code === "ENOENT") {
17002
- fs47.mkdirSync(path50.dirname(INDEX_LOCK2), { recursive: true });
17019
+ fs48.mkdirSync(path51.dirname(INDEX_LOCK2), { recursive: true });
17003
17020
  continue;
17004
17021
  }
17005
17022
  if (code !== "EEXIST") throw err;
17006
17023
  if (!pidAlive(Number(readHolder(holder)))) {
17007
- fs47.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17024
+ fs48.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17008
17025
  continue;
17009
17026
  }
17010
17027
  if (Date.now() > until) return null;
@@ -17014,7 +17031,7 @@ async function acquireIndexLock(giveUp) {
17014
17031
  }
17015
17032
  function readHolder(file) {
17016
17033
  try {
17017
- return fs47.readFileSync(file, "utf8").trim();
17034
+ return fs48.readFileSync(file, "utf8").trim();
17018
17035
  } catch {
17019
17036
  return String(process.pid);
17020
17037
  }
@@ -17100,8 +17117,8 @@ var init_sessions = __esm({
17100
17117
  implement: "implementing",
17101
17118
  hook: "implementing"
17102
17119
  };
17103
- specPathOf = (sessionId) => path50.join(SESSIONS_DIR, `${sessionId}.plan.json`);
17104
- asksPathOf = (sessionId) => path50.join(SESSIONS_DIR, `${sessionId}.asks.json`);
17120
+ specPathOf = (sessionId) => path51.join(SESSIONS_DIR, `${sessionId}.plan.json`);
17121
+ asksPathOf = (sessionId) => path51.join(SESSIONS_DIR, `${sessionId}.asks.json`);
17105
17122
  carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
17106
17123
  canPickUp = (r2) => r2.status === "error" || r2.status === "interrupted" || r2.status === "stopped";
17107
17124
  neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
@@ -17154,8 +17171,8 @@ var init_sources = __esm({
17154
17171
  });
17155
17172
 
17156
17173
  // ../cli/src/lib/signals/inbox.ts
17157
- import fs48 from "node:fs";
17158
- import path51 from "node:path";
17174
+ import fs49 from "node:fs";
17175
+ import path52 from "node:path";
17159
17176
  function metaPair(key, value) {
17160
17177
  const name = typeof key === "string" ? key.trim() : "";
17161
17178
  if (!name) return null;
@@ -17186,7 +17203,7 @@ ${signal2.summary.trim()}
17186
17203
  function parse(file, lenient = false) {
17187
17204
  let text5;
17188
17205
  try {
17189
- text5 = fs48.readFileSync(file, "utf8");
17206
+ text5 = fs49.readFileSync(file, "utf8");
17190
17207
  } catch {
17191
17208
  return null;
17192
17209
  }
@@ -17240,20 +17257,20 @@ function parse(file, lenient = false) {
17240
17257
  };
17241
17258
  }
17242
17259
  function freeName(dir, wanted) {
17243
- const ext = path51.extname(wanted);
17260
+ const ext = path52.extname(wanted);
17244
17261
  const stem = wanted.slice(0, wanted.length - ext.length);
17245
17262
  let name = wanted;
17246
- for (let n = 2; fs48.existsSync(path51.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
17263
+ for (let n = 2; fs49.existsSync(path52.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
17247
17264
  return name;
17248
17265
  }
17249
17266
  function readFolder2(dir, lenient = false) {
17250
17267
  let entries;
17251
17268
  try {
17252
- entries = fs48.readdirSync(dir, { withFileTypes: true });
17269
+ entries = fs49.readdirSync(dir, { withFileTypes: true });
17253
17270
  } catch {
17254
17271
  return [];
17255
17272
  }
17256
- return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path51.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
17273
+ return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path52.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
17257
17274
  }
17258
17275
  function readInbox() {
17259
17276
  const signals = readFolder2(TRIAGE);
@@ -17261,7 +17278,7 @@ function readInbox() {
17261
17278
  return signals;
17262
17279
  }
17263
17280
  function writeSignal(incoming, importedAt, slug2 = "") {
17264
- fs48.mkdirSync(TRIAGE, { recursive: true });
17281
+ fs49.mkdirSync(TRIAGE, { recursive: true });
17265
17282
  const signal2 = {
17266
17283
  ...incoming,
17267
17284
  importedAt,
@@ -17273,12 +17290,12 @@ function writeSignal(incoming, importedAt, slug2 = "") {
17273
17290
  contentKept: true,
17274
17291
  relPath: ""
17275
17292
  };
17276
- const file = path51.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
17277
- fs48.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
17293
+ const file = path52.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
17294
+ fs49.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
17278
17295
  return { ...signal2, relPath: boardRel(file) };
17279
17296
  }
17280
17297
  function stamp3(file, fields) {
17281
- const text5 = fs48.readFileSync(file, "utf8");
17298
+ const text5 = fs49.readFileSync(file, "utf8");
17282
17299
  const lines = text5.split("\n");
17283
17300
  const close = lines.indexOf("---", 1);
17284
17301
  if (close < 0) return;
@@ -17287,13 +17304,13 @@ function stamp3(file, fields) {
17287
17304
  return !key || fields[key[1]] === void 0;
17288
17305
  });
17289
17306
  const added = Object.entries(fields).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
17290
- fs48.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
17307
+ fs49.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
17291
17308
  }
17292
17309
  function moveSignal(from, into, fields) {
17293
- if (!fs48.existsSync(from)) return "";
17294
- fs48.mkdirSync(into, { recursive: true });
17295
- const at2 = path51.join(into, freeName(into, path51.basename(from)));
17296
- fs48.renameSync(from, at2);
17310
+ if (!fs49.existsSync(from)) return "";
17311
+ fs49.mkdirSync(into, { recursive: true });
17312
+ const at2 = path52.join(into, freeName(into, path52.basename(from)));
17313
+ fs49.renameSync(from, at2);
17297
17314
  stamp3(at2, fields);
17298
17315
  return boardRel(at2);
17299
17316
  }
@@ -17306,8 +17323,8 @@ function dismissInboxItems(sourceIds, by, reason = "") {
17306
17323
  const found2 = waiting.get(sourceId);
17307
17324
  if (!found2) return missing;
17308
17325
  const already = ignored.get(sourceId);
17309
- if (already) fs48.rmSync(path51.join(SIGNALS_DISMISSED, path51.basename(already.relPath)), { force: true });
17310
- const at2 = moveSignal(path51.join(TRIAGE, path51.basename(found2.relPath)), SIGNALS_DISMISSED, {
17326
+ if (already) fs49.rmSync(path52.join(SIGNALS_DISMISSED, path52.basename(already.relPath)), { force: true });
17327
+ const at2 = moveSignal(path52.join(TRIAGE, path52.basename(found2.relPath)), SIGNALS_DISMISSED, {
17311
17328
  dismissed_at: formatStamp(/* @__PURE__ */ new Date()),
17312
17329
  dismissed_by: by,
17313
17330
  ...why2 ? { dismissed_reason: why2 } : {}
@@ -17323,10 +17340,10 @@ function archiveInboxItem(sourceId, cardId2) {
17323
17340
  if (!found2) {
17324
17341
  const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
17325
17342
  if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
17326
- stamp3(path51.join(SIGNALS_DISMISSED, path51.basename(ignored.relPath)), { card_id: String(cardId2) });
17343
+ stamp3(path52.join(SIGNALS_DISMISSED, path52.basename(ignored.relPath)), { card_id: String(cardId2) });
17327
17344
  return { ok: true, relPath: ignored.relPath, where: "dismissed" };
17328
17345
  }
17329
- const at2 = moveSignal(path51.join(TRIAGE, path51.basename(found2.relPath)), SIGNALS_ARCHIVED, {
17346
+ const at2 = moveSignal(path52.join(TRIAGE, path52.basename(found2.relPath)), SIGNALS_ARCHIVED, {
17330
17347
  card_id: String(cardId2),
17331
17348
  archived_at: formatStamp(/* @__PURE__ */ new Date())
17332
17349
  });
@@ -17344,7 +17361,7 @@ function restoreInboxItems(sourceIds) {
17344
17361
  return refuse3(`${sourceId} was kept without its content, so there is nothing to restore`);
17345
17362
  }
17346
17363
  if (waiting.has(sourceId)) return refuse3(`${sourceId} is already waiting in triage`);
17347
- const at2 = moveSignal(path51.join(SIGNALS_DISMISSED, path51.basename(found2.relPath)), TRIAGE, {
17364
+ const at2 = moveSignal(path52.join(SIGNALS_DISMISSED, path52.basename(found2.relPath)), TRIAGE, {
17348
17365
  dismissed_at: null,
17349
17366
  dismissed_by: null,
17350
17367
  dismissed_reason: null
@@ -17363,7 +17380,7 @@ var init_inbox = __esm({
17363
17380
  init_sources();
17364
17381
  init_paths();
17365
17382
  init_yaml();
17366
- boardRel = (file) => rel(file).split(path51.sep).join("/");
17383
+ boardRel = (file) => rel(file).split(path52.sep).join("/");
17367
17384
  FIELDS = ["source_id", "title", "collected_at", "imported_at"];
17368
17385
  META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
17369
17386
  slugOf = (said3) => said3.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
@@ -17580,12 +17597,12 @@ var init_workflow_cards = __esm({
17580
17597
  });
17581
17598
 
17582
17599
  // ../cli/src/lib/readme.ts
17583
- import fs49 from "node:fs";
17584
- import path52 from "node:path";
17600
+ import fs50 from "node:fs";
17601
+ import path53 from "node:path";
17585
17602
  function stripReadmeRefs(target) {
17586
- if (!fs49.existsSync(README)) return [];
17603
+ if (!fs50.existsSync(README)) return [];
17587
17604
  const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
17588
- const lines = fs49.readFileSync(README, "utf8").split("\n");
17605
+ const lines = fs50.readFileSync(README, "utf8").split("\n");
17589
17606
  const out = [];
17590
17607
  const removed = [];
17591
17608
  let i = 0;
@@ -17607,20 +17624,20 @@ function stripReadmeRefs(target) {
17607
17624
  out.push(line);
17608
17625
  i++;
17609
17626
  }
17610
- if (removed.length) fs49.writeFileSync(README, out.join("\n"));
17627
+ if (removed.length) fs50.writeFileSync(README, out.join("\n"));
17611
17628
  return removed;
17612
17629
  }
17613
17630
  function addReadmeRef(id, title, relPath) {
17614
- if (!fs49.existsSync(README)) return false;
17615
- const link2 = relPath.split(path52.sep).join("/");
17631
+ if (!fs50.existsSync(README)) return false;
17632
+ const link2 = relPath.split(path53.sep).join("/");
17616
17633
  const bullet = `- [#${id} ${title}](${link2})`;
17617
17634
  const heading = `## ${TASKS_HEADING}`;
17618
- let lines = fs49.readFileSync(README, "utf8").split("\n");
17635
+ let lines = fs50.readFileSync(README, "utf8").split("\n");
17619
17636
  const hi2 = lines.findIndex((l2) => l2.trim().toLowerCase() === heading.toLowerCase());
17620
17637
  if (hi2 === -1) {
17621
17638
  while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
17622
17639
  lines.push("", heading, "", bullet);
17623
- fs49.writeFileSync(README, lines.join("\n") + "\n");
17640
+ fs50.writeFileSync(README, lines.join("\n") + "\n");
17624
17641
  return true;
17625
17642
  }
17626
17643
  let end2 = hi2 + 1;
@@ -17634,15 +17651,15 @@ function addReadmeRef(id, title, relPath) {
17634
17651
  const at2 = lastBullet !== -1 ? lastBullet + 1 : lines[hi2 + 1] === "" ? hi2 + 2 : hi2 + 1;
17635
17652
  lines.splice(at2, 0, bullet);
17636
17653
  }
17637
- fs49.writeFileSync(README, lines.join("\n"));
17654
+ fs50.writeFileSync(README, lines.join("\n"));
17638
17655
  return true;
17639
17656
  }
17640
17657
  function repointReadmeLink(id, oldRel, newRel, title) {
17641
- if (!fs49.existsSync(README)) return false;
17642
- const oldLink = oldRel.split(path52.sep).join("/");
17643
- const newLink = newRel.split(path52.sep).join("/");
17658
+ if (!fs50.existsSync(README)) return false;
17659
+ const oldLink = oldRel.split(path53.sep).join("/");
17660
+ const newLink = newRel.split(path53.sep).join("/");
17644
17661
  const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
17645
- const lines = fs49.readFileSync(README, "utf8").split("\n");
17662
+ const lines = fs50.readFileSync(README, "utf8").split("\n");
17646
17663
  let changed = false;
17647
17664
  for (let i = 0; i < lines.length; i++) {
17648
17665
  if (!lines[i].includes(`](${oldLink})`)) continue;
@@ -17652,7 +17669,7 @@ function repointReadmeLink(id, oldRel, newRel, title) {
17652
17669
  changed = true;
17653
17670
  }
17654
17671
  }
17655
- if (changed) fs49.writeFileSync(README, lines.join("\n"));
17672
+ if (changed) fs50.writeFileSync(README, lines.join("\n"));
17656
17673
  return changed;
17657
17674
  }
17658
17675
  var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex;
@@ -18138,14 +18155,14 @@ function collect(body, card, host2) {
18138
18155
  const active2 = /* @__PURE__ */ new Set();
18139
18156
  const out = [];
18140
18157
  const visit = (src, types, owner) => {
18141
- const path89 = src.replace(/[?#].*$/, "");
18158
+ const path90 = src.replace(/[?#].*$/, "");
18142
18159
  let resolved2;
18143
18160
  try {
18144
- resolved2 = host2.resolve(path89, owner);
18161
+ resolved2 = host2.resolve(path90, owner);
18145
18162
  } catch (error) {
18146
18163
  if (owner !== card) return { key: null, error: why(error) };
18147
18164
  if (!nodes.has(src)) {
18148
- const node2 = { key: src, file: null, kind: kindAt(path89, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18165
+ const node2 = { key: src, file: null, kind: kindAt(path90, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18149
18166
  nodes.set(src, node2);
18150
18167
  out.push(node2);
18151
18168
  }
@@ -18230,16 +18247,16 @@ var init_collect = __esm({
18230
18247
  });
18231
18248
 
18232
18249
  // ../cli/src/lib/dress-page.ts
18233
- import fs50 from "node:fs";
18234
- import path53 from "node:path";
18250
+ import fs51 from "node:fs";
18251
+ import path54 from "node:path";
18235
18252
  function dressPage(file) {
18236
- const folder = path53.dirname(file);
18237
- const html = fs50.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
18253
+ const folder = path54.dirname(file);
18254
+ const html = fs51.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
18238
18255
  const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
18239
18256
  if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
18240
- const at3 = path53.resolve(folder, href);
18241
- if (!at3.startsWith(folder + path53.sep) || !fs50.existsSync(at3)) return tag;
18242
- const css = fs50.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${path53.relative(folder, path53.resolve(path53.dirname(at3), src)).split(path53.sep).join("/")}${quote})`);
18257
+ const at3 = path54.resolve(folder, href);
18258
+ if (!at3.startsWith(folder + path54.sep) || !fs51.existsSync(at3)) return tag;
18259
+ 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})`);
18243
18260
  return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
18244
18261
  });
18245
18262
  const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
@@ -18251,25 +18268,25 @@ var init_dress_page = __esm({
18251
18268
  "use strict";
18252
18269
  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'";
18253
18270
  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>`;
18254
- referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs50.readFileSync(file, "utf8");
18271
+ referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs51.readFileSync(file, "utf8");
18255
18272
  }
18256
18273
  });
18257
18274
 
18258
18275
  // ../cli/src/lib/preview-files.ts
18259
- import fs51 from "node:fs";
18260
- import path54 from "node:path";
18276
+ import fs52 from "node:fs";
18277
+ import path55 from "node:path";
18261
18278
  function resolver(card, id) {
18262
- const roots = [KANBAN, path54.join(ASSETS, String(id)), path54.join(MOCKUPS, String(id))];
18263
- const real2 = (p2) => fs51.existsSync(p2) ? fs51.realpathSync(p2) : p2;
18264
- const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path54.sep));
18279
+ const roots = [KANBAN, path55.join(ASSETS, String(id)), path55.join(MOCKUPS, String(id))];
18280
+ const real2 = (p2) => fs52.existsSync(p2) ? fs52.realpathSync(p2) : p2;
18281
+ const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path55.sep));
18265
18282
  return (src, owner) => {
18266
18283
  if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
18267
- if (path54.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
18284
+ if (path55.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
18268
18285
  const held4 = /^\.(assets|mockups)\//.exec(src);
18269
- const file = held4 ? path54.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path54.resolve(path54.dirname(owner), src);
18270
- if (!inside2(path54.resolve(file)) || fs51.existsSync(file) && !inside2(fs51.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
18271
- if (!fs51.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
18272
- return { key: fs51.realpathSync(file), file };
18286
+ const file = held4 ? path55.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path55.resolve(path55.dirname(owner), src);
18287
+ if (!inside2(path55.resolve(file)) || fs52.existsSync(file) && !inside2(fs52.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
18288
+ if (!fs52.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
18289
+ return { key: fs52.realpathSync(file), file };
18273
18290
  };
18274
18291
  }
18275
18292
  function validatePreviewFiles(card, id, text5) {
@@ -18304,8 +18321,8 @@ var init_preview_files = __esm({
18304
18321
  });
18305
18322
 
18306
18323
  // ../cli/src/lib/spec-contract.ts
18307
- import fs52 from "node:fs";
18308
- import path55 from "node:path";
18324
+ import fs53 from "node:fs";
18325
+ import path56 from "node:path";
18309
18326
  function scanCardLines(lines, start = 0) {
18310
18327
  const visible = lines.map(() => "");
18311
18328
  let fence = null;
@@ -18338,18 +18355,18 @@ function scanCardLines(lines, start = 0) {
18338
18355
  }
18339
18356
  function snapshotSpecs() {
18340
18357
  const out = /* @__PURE__ */ new Map();
18341
- if (!fs52.existsSync(TODO)) return out;
18358
+ if (!fs53.existsSync(TODO)) return out;
18342
18359
  for (const file of walkMd(TODO)) {
18343
- if (isLegacyRecurring(path55.relative(TODO, file))) continue;
18344
- const id = idPrefix(path55.basename(file) === "root.md" ? path55.basename(path55.dirname(file)) : path55.basename(file));
18345
- if (id !== null) out.set(file, { id, text: fs52.readFileSync(file, "utf8") });
18360
+ if (isLegacyRecurring(path56.relative(TODO, file))) continue;
18361
+ const id = idPrefix(path56.basename(file) === "root.md" ? path56.basename(path56.dirname(file)) : path56.basename(file));
18362
+ if (id !== null) out.set(file, { id, text: fs53.readFileSync(file, "utf8") });
18346
18363
  }
18347
18364
  return out;
18348
18365
  }
18349
18366
  function enclosingGroups(file) {
18350
18367
  const ids = [];
18351
18368
  for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
18352
- const id = idPrefix(path55.basename(path55.dirname(root2)));
18369
+ const id = idPrefix(path56.basename(path56.dirname(root2)));
18353
18370
  if (id !== null) ids.push(id);
18354
18371
  }
18355
18372
  return ids;
@@ -18507,9 +18524,9 @@ function validateSpec(file, text5, id) {
18507
18524
  }
18508
18525
  function inside(dir, name) {
18509
18526
  try {
18510
- const root2 = fs52.realpathSync(dir);
18511
- const real2 = fs52.realpathSync(path55.join(dir, name));
18512
- return real2.startsWith(root2 + path55.sep) && fs52.statSync(real2).isFile() ? real2 : null;
18527
+ const root2 = fs53.realpathSync(dir);
18528
+ const real2 = fs53.realpathSync(path56.join(dir, name));
18529
+ return real2.startsWith(root2 + path56.sep) && fs53.statSync(real2).isFile() ? real2 : null;
18513
18530
  } catch {
18514
18531
  return null;
18515
18532
  }
@@ -18527,7 +18544,7 @@ function variantsProblem(raw, src, id) {
18527
18544
  if (files2.length < 2 || !files2.every((f2) => typeof f2 === "string" && f2)) return `variants needs at least two labels, each naming a file. ${shape}`;
18528
18545
  if (!files2.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
18529
18546
  if (id === void 0) return null;
18530
- const dir = path55.join(ASSETS, String(id));
18547
+ const dir = path56.join(ASSETS, String(id));
18531
18548
  for (const f2 of files2) {
18532
18549
  const parts = f2.split("/");
18533
18550
  if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
@@ -18537,7 +18554,7 @@ function variantsProblem(raw, src, id) {
18537
18554
  return null;
18538
18555
  }
18539
18556
  function compareProblem(attrs, id) {
18540
- const dir = path55.join(ASSETS, String(id));
18557
+ const dir = path56.join(ASSETS, String(id));
18541
18558
  const src = (message) => ({ rule: "compare-src", message });
18542
18559
  const shots = (message) => ({ rule: "compare-shots", message });
18543
18560
  for (const side of ["a", "b"]) {
@@ -18557,7 +18574,7 @@ function compareProblem(attrs, id) {
18557
18574
  const file = inside(dir, named2.name);
18558
18575
  if (!file) return { message: `Compare shots ${at2} names no file in this card's asset folder. Write the JSON there or fix the path.` };
18559
18576
  try {
18560
- return { data: JSON.parse(fs52.readFileSync(file, "utf8")) };
18577
+ return { data: JSON.parse(fs53.readFileSync(file, "utf8")) };
18561
18578
  } catch {
18562
18579
  return { message: `${at2} is not valid JSON.` };
18563
18580
  }
@@ -18577,7 +18594,7 @@ function compareProblem(attrs, id) {
18577
18594
  }
18578
18595
  function validateStoryboards(file, id, text5) {
18579
18596
  const errors = [];
18580
- const dir = path55.join(ASSETS, String(id));
18597
+ const dir = path56.join(ASSETS, String(id));
18581
18598
  for (const [tag, tagOf, rule, fix] of [
18582
18599
  ["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
18583
18600
  ["Workflow", workflowTag, "workflow-src", "Write it with `akb workflow diagram <workflow id> <card id>` or fix the path."]
@@ -18654,14 +18671,14 @@ var init_spec_contract = __esm({
18654
18671
  });
18655
18672
 
18656
18673
  // ../cli/src/lib/reconcile.ts
18657
- import fs53 from "node:fs";
18658
- import path56 from "node:path";
18674
+ import fs54 from "node:fs";
18675
+ import path57 from "node:path";
18659
18676
  function liveIds() {
18660
18677
  const ids = /* @__PURE__ */ new Set();
18661
18678
  for (const file of walkMd(TODO)) {
18662
- const base = path56.basename(file);
18679
+ const base = path57.basename(file);
18663
18680
  if (base === "README.md") continue;
18664
- const id = base === "root.md" ? idPrefix(path56.basename(path56.dirname(file))) : idPrefix(base);
18681
+ const id = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
18665
18682
  if (id != null) ids.add(id);
18666
18683
  }
18667
18684
  return ids;
@@ -18669,16 +18686,16 @@ function liveIds() {
18669
18686
  function indexableCards() {
18670
18687
  const out = [];
18671
18688
  for (const dir of walkDirs(TODO)) {
18672
- const id = idPrefix(path56.basename(dir));
18673
- if (id != null && fs53.existsSync(path56.join(dir, "root.md"))) {
18674
- out.push({ id, rel: path56.join(path56.relative(TODO, dir), "root.md").split(path56.sep).join("/") });
18689
+ const id = idPrefix(path57.basename(dir));
18690
+ if (id != null && fs54.existsSync(path57.join(dir, "root.md"))) {
18691
+ out.push({ id, rel: path57.join(path57.relative(TODO, dir), "root.md").split(path57.sep).join("/") });
18675
18692
  }
18676
18693
  }
18677
18694
  for (const file of walkMd(TODO)) {
18678
- const base = path56.basename(file);
18695
+ const base = path57.basename(file);
18679
18696
  if (base === "README.md" || base === "root.md") continue;
18680
- const relTODO = path56.relative(TODO, file);
18681
- const segs = relTODO.split(path56.sep);
18697
+ const relTODO = path57.relative(TODO, file);
18698
+ const segs = relTODO.split(path57.sep);
18682
18699
  if (segs.length !== 1) continue;
18683
18700
  const id = idPrefix(base);
18684
18701
  if (id != null) out.push({ id, rel: segs.join("/") });
@@ -18687,7 +18704,7 @@ function indexableCards() {
18687
18704
  }
18688
18705
  function readmeComplaints(fix) {
18689
18706
  const said3 = [];
18690
- const lines = fs53.readFileSync(README, "utf8").split("\n");
18707
+ const lines = fs54.readFileSync(README, "utf8").split("\n");
18691
18708
  const indexed = /* @__PURE__ */ new Set();
18692
18709
  let fixed = 0;
18693
18710
  for (let i = 0; i < lines.length; i++) {
@@ -18696,13 +18713,13 @@ function readmeComplaints(fix) {
18696
18713
  const id = Number(m[1]);
18697
18714
  const linkPath = m[2];
18698
18715
  indexed.add(id);
18699
- if (fs53.existsSync(path56.join(TODO, linkPath))) continue;
18716
+ if (fs54.existsSync(path57.join(TODO, linkPath))) continue;
18700
18717
  const found2 = locate(id);
18701
18718
  if (!found2) {
18702
18719
  said3.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
18703
18720
  continue;
18704
18721
  }
18705
- const want = (found2.kind === "group" ? path56.join(found2.rel, "root.md") : found2.rel).split(path56.sep).join("/");
18722
+ const want = (found2.kind === "group" ? path57.join(found2.rel, "root.md") : found2.rel).split(path57.sep).join("/");
18706
18723
  if (want === linkPath) continue;
18707
18724
  if (!fix) {
18708
18725
  said3.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
@@ -18712,7 +18729,7 @@ function readmeComplaints(fix) {
18712
18729
  said3.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
18713
18730
  fixed++;
18714
18731
  }
18715
- if (fixed) fs53.writeFileSync(README, lines.join("\n"));
18732
+ if (fixed) fs54.writeFileSync(README, lines.join("\n"));
18716
18733
  for (const c2 of indexableCards()) {
18717
18734
  if (!indexed.has(c2.id)) {
18718
18735
  said3.push(`card ${c2.rel} (#${c2.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
@@ -18724,11 +18741,11 @@ function crossRefComplaints() {
18724
18741
  const said3 = [];
18725
18742
  const live = liveIds();
18726
18743
  for (const file of walkMd(TODO)) {
18727
- const base = path56.basename(file);
18744
+ const base = path57.basename(file);
18728
18745
  if (base === "README.md") continue;
18729
- const ownerId = base === "root.md" ? idPrefix(path56.basename(path56.dirname(file))) : idPrefix(base);
18746
+ const ownerId = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
18730
18747
  if (ownerId == null) continue;
18731
- const { meta } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
18748
+ const { meta } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
18732
18749
  if (!meta) continue;
18733
18750
  for (const field2 of ["blocked_by", "related"]) {
18734
18751
  for (const ref of meta[field2] || []) {
@@ -18741,11 +18758,11 @@ function crossRefComplaints() {
18741
18758
  return said3;
18742
18759
  }
18743
18760
  function reconcileBoard() {
18744
- if (!fs53.existsSync(README)) return;
18761
+ if (!fs54.existsSync(README)) return;
18745
18762
  for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
18746
18763
  }
18747
18764
  function boardComplaints() {
18748
- if (!fs53.existsSync(README)) return [];
18765
+ if (!fs54.existsSync(README)) return [];
18749
18766
  try {
18750
18767
  return [...readmeComplaints(false), ...crossRefComplaints()];
18751
18768
  } catch {
@@ -18765,8 +18782,8 @@ var init_reconcile = __esm({
18765
18782
  });
18766
18783
 
18767
18784
  // ../cli/src/commands/card.ts
18768
- import fs54 from "node:fs";
18769
- import path57 from "node:path";
18785
+ import fs55 from "node:fs";
18786
+ import path58 from "node:path";
18770
18787
  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>") {
18771
18788
  return [
18772
18789
  summary,
@@ -18792,7 +18809,7 @@ function bodyFromFile(opts) {
18792
18809
  if (opts.body === false) die("pass --body-file or --no-body, not both");
18793
18810
  let text5;
18794
18811
  try {
18795
- text5 = fs54.readFileSync(opts.bodyFile, "utf8");
18812
+ text5 = fs55.readFileSync(opts.bodyFile, "utf8");
18796
18813
  } catch {
18797
18814
  die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
18798
18815
  }
@@ -18872,20 +18889,20 @@ function cmdCreate(opts) {
18872
18889
  const start = opts.id;
18873
18890
  const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
18874
18891
  const fileRel = `${start}-${slug2}.md`;
18875
- const file = path57.join(TODO, fileRel);
18892
+ const file = path58.join(TODO, fileRel);
18876
18893
  const held4 = locate(start) ?? locateArchived(start);
18877
- if (held4 && path57.basename(held4.target) === `${start}-${slug2}.md`) {
18894
+ if (held4 && path58.basename(held4.target) === `${start}-${slug2}.md`) {
18878
18895
  say(start);
18879
18896
  say(` ${rel(held4.target)} was already written`);
18880
18897
  return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
18881
18898
  }
18882
18899
  if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
18883
- if (fs54.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
18900
+ if (fs55.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
18884
18901
  countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
18885
18902
  const meta = { title, priority, status: "todo", blocked_by, related, modules, workflow, previews, stages, triage, source, questions };
18886
18903
  const scaffolded = !written && opts.body !== false;
18887
18904
  const body = written ?? (scaffolded ? defaultBody() : "");
18888
- fs54.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
18905
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
18889
18906
  const indexed = addReadmeRef(start, title, fileRel);
18890
18907
  say(start);
18891
18908
  say(
@@ -18937,8 +18954,8 @@ function cmdUpdate(id, flags) {
18937
18954
  if (creating) die(creating, { kind: "card-being-created", id });
18938
18955
  const found2 = locate(id);
18939
18956
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
18940
- const file = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
18941
- const { meta, body } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
18957
+ const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
18958
+ const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
18942
18959
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
18943
18960
  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");
18944
18961
  if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
@@ -19012,26 +19029,26 @@ function cmdUpdate(id, flags) {
19012
19029
  meta.status = "todo";
19013
19030
  changes.push("status\u2192todo (open questions)");
19014
19031
  }
19015
- const curRel = path57.relative(TODO, file);
19032
+ const curRel = path58.relative(TODO, file);
19016
19033
  const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
19017
- let base = path57.basename(file);
19034
+ let base = path58.basename(file);
19018
19035
  if (flags.slug !== void 0) {
19019
19036
  if (found2.kind === "group") die("renaming a group root by script is not supported");
19020
19037
  base = `${id}-${slugify(flags.slug)}.md`;
19021
19038
  }
19022
- const destRel = path57.join(path57.dirname(curRel), base);
19023
- const dest = path57.join(TODO, destRel);
19039
+ const destRel = path58.join(path58.dirname(curRel), base);
19040
+ const dest = path58.join(TODO, destRel);
19024
19041
  const moving = dest !== file;
19025
- if (moving && fs54.existsSync(dest)) die(`${rel(dest)} already exists`);
19026
- fs54.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19027
- if (moving) fs54.renameSync(file, dest);
19042
+ if (moving && fs55.existsSync(dest)) die(`${rel(dest)} already exists`);
19043
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19044
+ if (moving) fs55.renameSync(file, dest);
19028
19045
  if (isSubtask) {
19029
19046
  if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
19030
- if (moving) changes.push(`renamed \u2192 ${destRel.split(path57.sep).join("/")}`);
19047
+ if (moving) changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
19031
19048
  } else if (moving) {
19032
19049
  stripReadmeRefs({ kind: "file", rel: curRel });
19033
19050
  addReadmeRef(id, meta.title, destRel);
19034
- changes.push(`renamed \u2192 ${destRel.split(path57.sep).join("/")}`);
19051
+ changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
19035
19052
  } else if (changes.includes("title")) {
19036
19053
  stripReadmeRefs({ kind: "file", rel: curRel });
19037
19054
  addReadmeRef(id, meta.title, curRel);
@@ -19043,8 +19060,8 @@ function cmdUpdateQuestions(id, input) {
19043
19060
  const ops = readQuestionOps(input.ops ?? []);
19044
19061
  const found2 = locate(id);
19045
19062
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
19046
- const file = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
19047
- const { meta, body } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
19063
+ const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
19064
+ const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
19048
19065
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
19049
19066
  if (insideRun() && ops.some((op) => op.kind === "skip" || op.kind === "unskip")) {
19050
19067
  die("only the user skips or reopens a question \u2014 a run leaves questions for them to answer");
@@ -19117,7 +19134,7 @@ function cmdUpdateQuestions(id, input) {
19117
19134
  meta.status = "todo";
19118
19135
  changes.push("status\u2192todo (open questions)");
19119
19136
  }
19120
- fs54.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19137
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19121
19138
  for (const kind of closed2) countBoardEvent(kind);
19122
19139
  settleDelivery2(id, skipped, unskipped);
19123
19140
  say(
@@ -19193,13 +19210,13 @@ var init_config_template = __esm({
19193
19210
  });
19194
19211
 
19195
19212
  // ../cli/src/lib/agent/local.ts
19196
- import fs55 from "node:fs";
19197
- import path58 from "node:path";
19213
+ import fs56 from "node:fs";
19214
+ import path59 from "node:path";
19198
19215
  function takeLocalModels(board2) {
19199
- const file = path58.join(board2, ".local.json");
19216
+ const file = path59.join(board2, ".local.json");
19200
19217
  let held4;
19201
19218
  try {
19202
- held4 = configBlock(JSON.parse(fs55.readFileSync(file, "utf8")));
19219
+ held4 = configBlock(JSON.parse(fs56.readFileSync(file, "utf8")));
19203
19220
  } catch {
19204
19221
  return {};
19205
19222
  }
@@ -19217,7 +19234,7 @@ function takeLocalModels(board2) {
19217
19234
  }
19218
19235
  if (!Object.keys(agents).length) return out;
19219
19236
  delete held4.agents;
19220
- fs55.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19237
+ fs56.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19221
19238
  return out;
19222
19239
  }
19223
19240
  var LOCAL_IGNORE_LINE;
@@ -19278,12 +19295,12 @@ var init_identity2 = __esm({
19278
19295
  });
19279
19296
 
19280
19297
  // ../cli/src/lib/signals/migrate.ts
19281
- import fs56 from "node:fs";
19282
- import path59 from "node:path";
19298
+ import fs57 from "node:fs";
19299
+ import path60 from "node:path";
19283
19300
  function readHandled() {
19284
19301
  let text5;
19285
19302
  try {
19286
- text5 = fs56.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19303
+ text5 = fs57.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19287
19304
  } catch {
19288
19305
  return [];
19289
19306
  }
@@ -19300,57 +19317,57 @@ function readHandled() {
19300
19317
  return held4;
19301
19318
  }
19302
19319
  function lift(from, into) {
19303
- fs56.mkdirSync(into, { recursive: true });
19304
- fs56.renameSync(from, path59.join(into, freeName(into, path59.basename(from))));
19320
+ fs57.mkdirSync(into, { recursive: true });
19321
+ fs57.renameSync(from, path60.join(into, freeName(into, path60.basename(from))));
19305
19322
  }
19306
19323
  function repoint(dir, from, into) {
19307
19324
  let entries;
19308
19325
  try {
19309
- entries = fs56.readdirSync(dir, { withFileTypes: true });
19326
+ entries = fs57.readdirSync(dir, { withFileTypes: true });
19310
19327
  } catch {
19311
19328
  return;
19312
19329
  }
19313
19330
  for (const entry of entries) {
19314
19331
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
19315
- const file = path59.join(dir, entry.name);
19316
- const text5 = fs56.readFileSync(file, "utf8");
19317
- if (text5.includes(from)) fs56.writeFileSync(file, text5.split(from).join(into));
19332
+ const file = path60.join(dir, entry.name);
19333
+ const text5 = fs57.readFileSync(file, "utf8");
19334
+ if (text5.includes(from)) fs57.writeFileSync(file, text5.split(from).join(into));
19318
19335
  }
19319
19336
  }
19320
19337
  function dropIfEmpty2(dir) {
19321
19338
  try {
19322
- fs56.rmdirSync(dir);
19339
+ fs57.rmdirSync(dir);
19323
19340
  } catch {
19324
19341
  }
19325
19342
  }
19326
19343
  function liftInbox() {
19327
- if (!fs56.existsSync(SIGNALS_OLD_INBOX)) return;
19328
- const oldFiles = path59.join(SIGNALS_OLD_INBOX, "files");
19329
- if (fs56.existsSync(oldFiles)) {
19330
- for (const entry of fs56.readdirSync(oldFiles, { withFileTypes: true })) {
19331
- if (entry.isFile()) lift(path59.join(oldFiles, entry.name), SIGNALS_FILES);
19344
+ if (!fs57.existsSync(SIGNALS_OLD_INBOX)) return;
19345
+ const oldFiles = path60.join(SIGNALS_OLD_INBOX, "files");
19346
+ if (fs57.existsSync(oldFiles)) {
19347
+ for (const entry of fs57.readdirSync(oldFiles, { withFileTypes: true })) {
19348
+ if (entry.isFile()) lift(path60.join(oldFiles, entry.name), SIGNALS_FILES);
19332
19349
  }
19333
19350
  dropIfEmpty2(oldFiles);
19334
19351
  }
19335
19352
  const held4 = new Set(readFolder2(TRIAGE).map((signal2) => signal2.sourceId));
19336
- for (const entry of fs56.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19353
+ for (const entry of fs57.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19337
19354
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
19338
- const from = path59.join(SIGNALS_OLD_INBOX, entry.name);
19355
+ const from = path60.join(SIGNALS_OLD_INBOX, entry.name);
19339
19356
  const item = parse(from);
19340
19357
  if (item && held4.has(item.sourceId)) {
19341
- fs56.rmSync(from, { force: true });
19358
+ fs57.rmSync(from, { force: true });
19342
19359
  continue;
19343
19360
  }
19344
19361
  if (item) held4.add(item.sourceId);
19345
19362
  lift(from, TRIAGE);
19346
19363
  }
19347
- const wasAt = asWritten(path59.join(SIGNALS_OLD_INBOX, "files"));
19364
+ const wasAt = asWritten(path60.join(SIGNALS_OLD_INBOX, "files"));
19348
19365
  const nowAt = asWritten(SIGNALS_FILES);
19349
19366
  for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
19350
19367
  dropIfEmpty2(SIGNALS_OLD_INBOX);
19351
19368
  }
19352
19369
  function liftHandled() {
19353
- if (!fs56.existsSync(SIGNALS_OLD_HANDLED)) return;
19370
+ if (!fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
19354
19371
  const lines = readHandled();
19355
19372
  const held4 = /* @__PURE__ */ new Set([
19356
19373
  ...readFolder2(TRIAGE).map((signal2) => signal2.sourceId),
@@ -19360,7 +19377,7 @@ function liftHandled() {
19360
19377
  for (const { sourceId, when } of lines) {
19361
19378
  if (held4.has(sourceId)) continue;
19362
19379
  held4.add(sourceId);
19363
- fs56.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19380
+ fs57.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19364
19381
  const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
19365
19382
  const front = [
19366
19383
  "---",
@@ -19370,13 +19387,13 @@ function liftHandled() {
19370
19387
  "---",
19371
19388
  ""
19372
19389
  ];
19373
- fs56.writeFileSync(path59.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19390
+ fs57.writeFileSync(path60.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19374
19391
  `);
19375
19392
  }
19376
- fs56.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19393
+ fs57.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19377
19394
  }
19378
19395
  function migrateTriage() {
19379
- if (!fs56.existsSync(SIGNALS_OLD_INBOX) && !fs56.existsSync(SIGNALS_OLD_HANDLED)) return;
19396
+ if (!fs57.existsSync(SIGNALS_OLD_INBOX) && !fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
19380
19397
  try {
19381
19398
  liftInbox();
19382
19399
  liftHandled();
@@ -19391,13 +19408,13 @@ var init_migrate = __esm({
19391
19408
  init_yaml();
19392
19409
  init_inbox();
19393
19410
  HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
19394
- asWritten = (dir) => `${rel(dir).split(path59.sep).join("/")}/`;
19411
+ asWritten = (dir) => `${rel(dir).split(path60.sep).join("/")}/`;
19395
19412
  }
19396
19413
  });
19397
19414
 
19398
19415
  // ../cli/src/lib/signals/add.ts
19399
- import fs57 from "node:fs";
19400
- import path60 from "node:path";
19416
+ import fs58 from "node:fs";
19417
+ import path61 from "node:path";
19401
19418
  import { createHash as createHash4 } from "node:crypto";
19402
19419
  function linkTitle(url) {
19403
19420
  let at2;
@@ -19410,7 +19427,7 @@ function linkTitle(url) {
19410
19427
  return oneLine(where) || url.slice(0, TITLE_MAX);
19411
19428
  }
19412
19429
  function asText(file) {
19413
- const ext = path60.extname(file.name).toLowerCase();
19430
+ const ext = path61.extname(file.name).toLowerCase();
19414
19431
  if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
19415
19432
  try {
19416
19433
  const text5 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
@@ -19420,9 +19437,9 @@ function asText(file) {
19420
19437
  }
19421
19438
  }
19422
19439
  function fileName2(name, data) {
19423
- const base = path60.basename(name);
19424
- const ext = path60.extname(base).toLowerCase().slice(0, 12);
19425
- const word = path60.basename(base, path60.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
19440
+ const base = path61.basename(name);
19441
+ const ext = path61.extname(base).toLowerCase().slice(0, 12);
19442
+ const word = path61.basename(base, path61.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
19426
19443
  const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
19427
19444
  return `${word}-${hash2}${ext}`;
19428
19445
  }
@@ -19431,9 +19448,9 @@ function addToInbox(drop) {
19431
19448
  const typed = (drop.text ?? "").trim();
19432
19449
  const file = drop.file;
19433
19450
  if (!typed && !file) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
19434
- if (file && file.data.length === 0) return { ok: false, error: `${path60.basename(file.name)} is empty.` };
19451
+ if (file && file.data.length === 0) return { ok: false, error: `${path61.basename(file.name)} is empty.` };
19435
19452
  if (file && file.data.length > MAX_BYTES) {
19436
- return { ok: false, error: `${path60.basename(file.name)} is over ${MAX_BYTES / 1024 / 1024} MB \u2014 too big for the board.` };
19453
+ return { ok: false, error: `${path61.basename(file.name)} is over ${MAX_BYTES / 1024 / 1024} MB \u2014 too big for the board.` };
19437
19454
  }
19438
19455
  const read5 = describe(typed, file);
19439
19456
  const keep2 = read5.keep;
@@ -19455,8 +19472,8 @@ ${incoming.summary}`);
19455
19472
  if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
19456
19473
  try {
19457
19474
  if (keep2) {
19458
- fs57.mkdirSync(SIGNALS_FILES, { recursive: true });
19459
- fs57.writeFileSync(keep2.at, keep2.data);
19475
+ fs58.mkdirSync(SIGNALS_FILES, { recursive: true });
19476
+ fs58.writeFileSync(keep2.at, keep2.data);
19460
19477
  }
19461
19478
  return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
19462
19479
  } catch (e2) {
@@ -19470,7 +19487,7 @@ function describe(typed, file) {
19470
19487
  return only ? [only] : [];
19471
19488
  };
19472
19489
  if (file) {
19473
- const name = path60.basename(file.name);
19490
+ const name = path61.basename(file.name);
19474
19491
  const text5 = asText(file);
19475
19492
  const note = typed ? `
19476
19493
 
@@ -19482,7 +19499,7 @@ ${typed}` : "";
19482
19499
  const at2 = keepAt(file);
19483
19500
  return {
19484
19501
  incoming: {
19485
- title: path60.basename(name, path60.extname(name)) || name,
19502
+ title: path61.basename(name, path61.extname(name)) || name,
19486
19503
  summary: `${name} \u2014 ${boardRel2(at2)}${note}`,
19487
19504
  ...named2
19488
19505
  },
@@ -19520,73 +19537,73 @@ var init_add = __esm({
19520
19537
  MAX_BYTES = 25 * 1024 * 1024;
19521
19538
  TITLE_MAX = 120;
19522
19539
  TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
19523
- boardRel2 = (file) => rel(file).split(path60.sep).join("/");
19540
+ boardRel2 = (file) => rel(file).split(path61.sep).join("/");
19524
19541
  oneLine = (text5) => {
19525
19542
  const first = text5.split("\n").find((line) => line.trim()) ?? "";
19526
19543
  const clean = first.replace(/^#+\s*/, "").trim();
19527
19544
  return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
19528
19545
  };
19529
- keepAt = (file) => path60.join(SIGNALS_FILES, fileName2(file.name, file.data));
19546
+ keepAt = (file) => path61.join(SIGNALS_FILES, fileName2(file.name, file.data));
19530
19547
  }
19531
19548
  });
19532
19549
 
19533
19550
  // ../cli/src/lib/recurring.ts
19534
- import fs58 from "node:fs";
19535
- import path61 from "node:path";
19551
+ import fs59 from "node:fs";
19552
+ import path62 from "node:path";
19536
19553
  function migratePruneMemoryCard() {
19537
19554
  const dir = recurringDir();
19538
19555
  let names3;
19539
19556
  try {
19540
- names3 = fs58.readdirSync(dir);
19557
+ names3 = fs59.readdirSync(dir);
19541
19558
  } catch {
19542
19559
  return null;
19543
19560
  }
19544
19561
  const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
19545
19562
  if (!name) return null;
19546
- const file = path61.join(dir, name);
19563
+ const file = path62.join(dir, name);
19547
19564
  try {
19548
- const { meta } = parseFrontmatter(fs58.readFileSync(file, "utf8"));
19565
+ const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19549
19566
  const cadence = meta?.cadence;
19550
19567
  if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
19551
19568
  } catch {
19552
19569
  }
19553
- fs58.rmSync(file, { force: true });
19570
+ fs59.rmSync(file, { force: true });
19554
19571
  return rel(file);
19555
19572
  }
19556
19573
  function legacyCards() {
19557
19574
  const dir = recurringDir();
19558
- if (!fs58.existsSync(dir)) return [];
19575
+ if (!fs59.existsSync(dir)) return [];
19559
19576
  const cards = [];
19560
- for (const entry of fs58.readdirSync(dir, { withFileTypes: true })) {
19577
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19561
19578
  const id = idPrefix(entry.name);
19562
19579
  if (id === null) continue;
19563
- const full = path61.join(dir, entry.name);
19580
+ const full = path62.join(dir, entry.name);
19564
19581
  const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
19565
19582
  if (entry.isFile() && entry.name.endsWith(".md")) cards.push({ id, slug: slug2, file: full });
19566
- else if (entry.isDirectory() && fs58.existsSync(path61.join(full, "root.md"))) {
19567
- cards.push({ id, slug: slug2, file: path61.join(full, "root.md"), folder: full });
19583
+ else if (entry.isDirectory() && fs59.existsSync(path62.join(full, "root.md"))) {
19584
+ cards.push({ id, slug: slug2, file: path62.join(full, "root.md"), folder: full });
19568
19585
  }
19569
19586
  }
19570
19587
  return cards.sort((a2, b2) => a2.id - b2.id);
19571
19588
  }
19572
19589
  function mergeInto2(from, to, skip = []) {
19573
- fs58.mkdirSync(to, { recursive: true });
19574
- for (const entry of fs58.readdirSync(from, { withFileTypes: true })) {
19590
+ fs59.mkdirSync(to, { recursive: true });
19591
+ for (const entry of fs59.readdirSync(from, { withFileTypes: true })) {
19575
19592
  if (skip.includes(entry.name)) continue;
19576
- const source = path61.join(from, entry.name);
19577
- const target = path61.join(to, entry.name);
19578
- if (!fs58.existsSync(target)) fs58.renameSync(source, target);
19579
- else if (entry.isDirectory() && fs58.statSync(target).isDirectory()) mergeInto2(source, target);
19593
+ const source = path62.join(from, entry.name);
19594
+ const target = path62.join(to, entry.name);
19595
+ if (!fs59.existsSync(target)) fs59.renameSync(source, target);
19596
+ else if (entry.isDirectory() && fs59.statSync(target).isDirectory()) mergeInto2(source, target);
19580
19597
  }
19581
- if (isEmpty(from)) fs58.rmSync(from, { recursive: true, force: true });
19598
+ if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
19582
19599
  }
19583
19600
  function moveSideFolders() {
19584
19601
  const dir = recurringDir();
19585
- for (const entry of fs58.readdirSync(dir, { withFileTypes: true })) {
19602
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19586
19603
  if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
19587
- const from = path61.join(dir, entry.name);
19588
- if (isEmpty(from)) fs58.rmSync(from, { recursive: true, force: true });
19589
- else mergeInto2(from, path61.join(AGENTS, entry.name));
19604
+ const from = path62.join(dir, entry.name);
19605
+ if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
19606
+ else mergeInto2(from, path62.join(AGENTS, entry.name));
19590
19607
  }
19591
19608
  }
19592
19609
  function sections(body) {
@@ -19636,8 +19653,8 @@ function agentName(card, text5) {
19636
19653
  const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a2) => a2.name), ...ROLE_NAMES]);
19637
19654
  for (const name of [slug2, `${slug2}-${card.id}`]) {
19638
19655
  if (!AGENT_NAME.test(name)) continue;
19639
- const file = path61.join(AGENTS, name, AGENT_FILE2);
19640
- const written = fs58.existsSync(file) ? fs58.readFileSync(file, "utf8") : null;
19656
+ const file = path62.join(AGENTS, name, AGENT_FILE2);
19657
+ const written = fs59.existsSync(file) ? fs59.readFileSync(file, "utf8") : null;
19641
19658
  if (written === text5(name)) return name;
19642
19659
  if (written === null && !known2.has(name)) return name;
19643
19660
  }
@@ -19654,11 +19671,11 @@ ${q3.options.map((o3) => `- ${o3}`).join("\n")}` : "";
19654
19671
  function removeCard(card) {
19655
19672
  dropCrossRefs(card.id);
19656
19673
  const target = card.folder ?? card.file;
19657
- stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path61.relative(TODO, target).split(path61.sep).join("/") });
19658
- fs58.rmSync(target, { recursive: true, force: true });
19674
+ stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path62.relative(TODO, target).split(path62.sep).join("/") });
19675
+ fs59.rmSync(target, { recursive: true, force: true });
19659
19676
  }
19660
19677
  function migrateCard(card) {
19661
- const { meta, body } = parseFrontmatter(fs58.readFileSync(card.file, "utf8"));
19678
+ const { meta, body } = parseFrontmatter(fs59.readFileSync(card.file, "utf8"));
19662
19679
  if (!meta) throw new Error("its frontmatter cannot be read");
19663
19680
  const raw = meta;
19664
19681
  const said3 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
@@ -19668,19 +19685,19 @@ function migrateCard(card) {
19668
19685
  if (!flow) throw new Error(noWorkflowMessage(""));
19669
19686
  const text5 = (name2) => agentText(name2, meta.title || card.slug, body);
19670
19687
  const name = agentName(card, text5);
19671
- const dir = path61.join(AGENTS, name);
19672
- const file = path61.join(dir, AGENT_FILE2);
19673
- const madeDir = !fs58.existsSync(dir);
19674
- const wrote = !fs58.existsSync(file);
19688
+ const dir = path62.join(AGENTS, name);
19689
+ const file = path62.join(dir, AGENT_FILE2);
19690
+ const madeDir = !fs59.existsSync(dir);
19691
+ const wrote = !fs59.existsSync(file);
19675
19692
  try {
19676
- fs58.mkdirSync(dir, { recursive: true });
19677
- if (wrote) fs58.writeFileSync(file, text5(name));
19693
+ fs59.mkdirSync(dir, { recursive: true });
19694
+ if (wrote) fs59.writeFileSync(file, text5(name));
19678
19695
  const adopted = adoptWorkflowScheduled(flow.id, name, { cadence, lastRun });
19679
19696
  if (!adopted.ok) throw new Error(adopted.error);
19680
19697
  questionsToTriage(meta, name);
19681
19698
  } catch (e2) {
19682
- if (madeDir) fs58.rmSync(dir, { recursive: true, force: true });
19683
- else if (wrote) fs58.rmSync(file, { force: true });
19699
+ if (madeDir) fs59.rmSync(dir, { recursive: true, force: true });
19700
+ else if (wrote) fs59.rmSync(file, { force: true });
19684
19701
  throw e2;
19685
19702
  }
19686
19703
  if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
@@ -19690,7 +19707,7 @@ function migrateCard(card) {
19690
19707
  function migrateRecurringCards() {
19691
19708
  const done2 = { agents: [], removed: [], failed: [] };
19692
19709
  const dir = recurringDir();
19693
- if (!fs58.existsSync(dir)) return done2;
19710
+ if (!fs59.existsSync(dir)) return done2;
19694
19711
  migratePruneMemoryCard();
19695
19712
  moveSideFolders();
19696
19713
  for (const card of legacyCards()) {
@@ -19703,7 +19720,7 @@ function migrateRecurringCards() {
19703
19720
  done2.failed.push({ card: rel(card.file), why: e2 instanceof Error ? e2.message : String(e2) });
19704
19721
  }
19705
19722
  }
19706
- if (isEmpty(dir)) fs58.rmSync(dir, { recursive: true, force: true });
19723
+ if (isEmpty(dir)) fs59.rmSync(dir, { recursive: true, force: true });
19707
19724
  return done2;
19708
19725
  }
19709
19726
  function recurringMigrationLines(done2) {
@@ -19736,14 +19753,14 @@ var init_recurring = __esm({
19736
19753
  PRUNE_SLUG = "prune-the-memory";
19737
19754
  FETCH_SLUG = "fetch-triage-items";
19738
19755
  AGENT_FILE2 = "AGENT.md";
19739
- recurringDir = () => path61.join(TODO, LEGACY_RECURRING);
19740
- isEmpty = (dir) => fs58.readdirSync(dir).every((name) => name === ".DS_Store");
19756
+ recurringDir = () => path62.join(TODO, LEGACY_RECURRING);
19757
+ isEmpty = (dir) => fs59.readdirSync(dir).every((name) => name === ".DS_Store");
19741
19758
  SECTION = /^##\s+(.+?)\s*$/;
19742
19759
  }
19743
19760
  });
19744
19761
 
19745
19762
  // ../cli/src/commands/init.ts
19746
- import fs59 from "node:fs";
19763
+ import fs60 from "node:fs";
19747
19764
  function boardReadme() {
19748
19765
  return `# Board
19749
19766
 
@@ -19756,20 +19773,20 @@ _(none)_
19756
19773
  `;
19757
19774
  }
19758
19775
  function writeConfigIfMissing() {
19759
- if (fs59.existsSync(CONFIG)) return false;
19760
- fs59.mkdirSync(KANBAN, { recursive: true });
19761
- fs59.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19776
+ if (fs60.existsSync(CONFIG)) return false;
19777
+ fs60.mkdirSync(KANBAN, { recursive: true });
19778
+ fs60.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19762
19779
  return true;
19763
19780
  }
19764
19781
  function writeModulesIfMissing() {
19765
- if (fs59.existsSync(MODULES_MD)) return false;
19766
- fs59.mkdirSync(KANBAN, { recursive: true });
19767
- fs59.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
19782
+ if (fs60.existsSync(MODULES_MD)) return false;
19783
+ fs60.mkdirSync(KANBAN, { recursive: true });
19784
+ fs60.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
19768
19785
  return true;
19769
19786
  }
19770
19787
  function writeGitignoreIfMissing() {
19771
- fs59.mkdirSync(KANBAN, { recursive: true });
19772
- const text5 = fs59.existsSync(KANBAN_GITIGNORE) ? fs59.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
19788
+ fs60.mkdirSync(KANBAN, { recursive: true });
19789
+ const text5 = fs60.existsSync(KANBAN_GITIGNORE) ? fs60.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
19773
19790
  const has = (rule) => text5.split("\n").some((line) => line.trim() === rule.line);
19774
19791
  const missing = IGNORE_RULES.filter((rule) => !has(rule));
19775
19792
  if (!missing.length) return false;
@@ -19777,37 +19794,37 @@ function writeGitignoreIfMissing() {
19777
19794
  ${rule.line}
19778
19795
  `).join("");
19779
19796
  const separator = !text5 || text5.endsWith("\n") ? "" : "\n";
19780
- fs59.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19797
+ fs60.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19781
19798
  return true;
19782
19799
  }
19783
19800
  function writeSkeletonIfMissing() {
19784
19801
  const added = [];
19785
- if (!fs59.existsSync(TODO)) {
19786
- fs59.mkdirSync(TODO, { recursive: true });
19802
+ if (!fs60.existsSync(TODO)) {
19803
+ fs60.mkdirSync(TODO, { recursive: true });
19787
19804
  added.push(`${rel(TODO)}/`);
19788
19805
  }
19789
- if (!fs59.existsSync(README)) {
19790
- fs59.writeFileSync(README, boardReadme());
19806
+ if (!fs60.existsSync(README)) {
19807
+ fs60.writeFileSync(README, boardReadme());
19791
19808
  added.push(rel(README));
19792
19809
  }
19793
19810
  return added;
19794
19811
  }
19795
19812
  function retireReleases() {
19796
19813
  const done2 = [];
19797
- if (fs59.existsSync(RELEASES)) {
19798
- fs59.rmSync(RELEASES);
19814
+ if (fs60.existsSync(RELEASES)) {
19815
+ fs60.rmSync(RELEASES);
19799
19816
  done2.push(`deleted ${rel(RELEASES)}`);
19800
19817
  }
19801
19818
  let cards = 0;
19802
19819
  for (const dir of [TODO, ARCHIVE]) {
19803
- if (!fs59.existsSync(dir)) continue;
19820
+ if (!fs60.existsSync(dir)) continue;
19804
19821
  for (const file of walkMd(dir)) {
19805
- const text5 = fs59.readFileSync(file, "utf8");
19822
+ const text5 = fs60.readFileSync(file, "utf8");
19806
19823
  const end2 = text5.startsWith("---\n") ? text5.indexOf("\n---", 3) : -1;
19807
19824
  if (end2 < 0) continue;
19808
19825
  const head2 = text5.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
19809
19826
  if (head2.length === end2) continue;
19810
- fs59.writeFileSync(file, head2 + text5.slice(end2));
19827
+ fs60.writeFileSync(file, head2 + text5.slice(end2));
19811
19828
  cards++;
19812
19829
  }
19813
19830
  }
@@ -19815,7 +19832,7 @@ function retireReleases() {
19815
19832
  return done2.join(", ");
19816
19833
  }
19817
19834
  function cmdInit() {
19818
- if (fs59.existsSync(KANBAN)) {
19835
+ if (fs60.existsSync(KANBAN)) {
19819
19836
  const added = [
19820
19837
  ...writeSkeletonIfMissing(),
19821
19838
  writeConfigIfMissing() && rel(CONFIG),
@@ -19850,8 +19867,8 @@ function cmdInit() {
19850
19867
  }
19851
19868
  return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
19852
19869
  }
19853
- fs59.mkdirSync(TODO, { recursive: true });
19854
- fs59.writeFileSync(README, boardReadme());
19870
+ fs60.mkdirSync(TODO, { recursive: true });
19871
+ fs60.writeFileSync(README, boardReadme());
19855
19872
  writeConfigIfMissing();
19856
19873
  scaffoldProjectMemory();
19857
19874
  writeModulesIfMissing();
@@ -19940,25 +19957,25 @@ var init_scheduled = __esm({
19940
19957
  });
19941
19958
 
19942
19959
  // ../cli/src/lib/card-age.ts
19943
- import fs60 from "node:fs";
19944
- import path62 from "node:path";
19960
+ import fs61 from "node:fs";
19961
+ import path63 from "node:path";
19945
19962
  function staleAfterIn(config) {
19946
19963
  const days = Number(LINE.exec(config)?.[1]);
19947
19964
  return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
19948
19965
  }
19949
19966
  function staleAfter() {
19950
- if (!fs60.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
19951
- return staleAfterIn(fs60.readFileSync(CONFIG, "utf8"));
19967
+ if (!fs61.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
19968
+ return staleAfterIn(fs61.readFileSync(CONFIG, "utf8"));
19952
19969
  }
19953
19970
  function todoPathspec(top) {
19954
- const from = path62.relative(real(top), real(TODO));
19955
- if (!from || from.startsWith("..") || path62.isAbsolute(from)) return null;
19956
- return from.split(path62.sep).join("/");
19971
+ const from = path63.relative(real(top), real(TODO));
19972
+ if (!from || from.startsWith("..") || path63.isAbsolute(from)) return null;
19973
+ return from.split(path63.sep).join("/");
19957
19974
  }
19958
19975
  function cardFile2(spec, printed) {
19959
19976
  const p2 = unquotePath(printed);
19960
19977
  if (!p2.startsWith(`${spec}/`)) return null;
19961
- return path62.join(TODO, ...p2.slice(spec.length + 1).split("/"));
19978
+ return path63.join(TODO, ...p2.slice(spec.length + 1).split("/"));
19962
19979
  }
19963
19980
  function dirtyCards(top, spec) {
19964
19981
  const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
@@ -20005,9 +20022,9 @@ var init_card_age = __esm({
20005
20022
  gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
20006
20023
  real = (p2) => {
20007
20024
  try {
20008
- return fs60.realpathSync(p2);
20025
+ return fs61.realpathSync(p2);
20009
20026
  } catch {
20010
- return path62.resolve(p2);
20027
+ return path63.resolve(p2);
20011
20028
  }
20012
20029
  };
20013
20030
  unquotePath = (line) => {
@@ -20042,8 +20059,8 @@ var init_card_holds = __esm({
20042
20059
  });
20043
20060
 
20044
20061
  // ../cli/src/commands/list.ts
20045
- import fs61 from "node:fs";
20046
- import path63 from "node:path";
20062
+ import fs62 from "node:fs";
20063
+ import path64 from "node:path";
20047
20064
  function summaryLine(body) {
20048
20065
  const lines = body.split("\n");
20049
20066
  let i = 0;
@@ -20059,13 +20076,13 @@ function summaryLine(body) {
20059
20076
  function openRows() {
20060
20077
  const rows = [];
20061
20078
  for (const file of walkMd(TODO)) {
20062
- const base = path63.basename(file);
20079
+ const base = path64.basename(file);
20063
20080
  if (base === "README.md") continue;
20064
20081
  const isRoot = base === "root.md";
20065
- const id = isRoot ? idPrefix(path63.basename(path63.dirname(file))) : idPrefix(base);
20082
+ const id = isRoot ? idPrefix(path64.basename(path64.dirname(file))) : idPrefix(base);
20066
20083
  if (id == null) continue;
20067
- if (isLegacyRecurring(path63.relative(TODO, file))) continue;
20068
- const { meta, body } = parseFrontmatter(fs61.readFileSync(file, "utf8"));
20084
+ if (isLegacyRecurring(path64.relative(TODO, file))) continue;
20085
+ const { meta, body } = parseFrontmatter(fs62.readFileSync(file, "utf8"));
20069
20086
  rows.push({
20070
20087
  id,
20071
20088
  file,
@@ -20107,15 +20124,15 @@ function cmdStale(rows, all2, scope, mod) {
20107
20124
  }
20108
20125
  function archivedFiles() {
20109
20126
  const files2 = /* @__PURE__ */ new Map();
20110
- if (!fs61.existsSync(ARCHIVE)) return files2;
20127
+ if (!fs62.existsSync(ARCHIVE)) return files2;
20111
20128
  for (const file of walkMd(ARCHIVE)) {
20112
- const id = idPrefix(path63.basename(file));
20129
+ const id = idPrefix(path64.basename(file));
20113
20130
  if (id !== null) files2.set(id, file);
20114
20131
  }
20115
20132
  for (const dir of walkDirs(ARCHIVE)) {
20116
- const id = idPrefix(path63.basename(dir));
20117
- const root2 = path63.join(dir, "root.md");
20118
- if (id !== null && fs61.existsSync(root2)) files2.set(id, root2);
20133
+ const id = idPrefix(path64.basename(dir));
20134
+ const root2 = path64.join(dir, "root.md");
20135
+ if (id !== null && fs62.existsSync(root2)) files2.set(id, root2);
20119
20136
  }
20120
20137
  return files2;
20121
20138
  }
@@ -20226,14 +20243,14 @@ var init_list = __esm({
20226
20243
  });
20227
20244
 
20228
20245
  // ../cli/src/commands/misc.ts
20229
- import fs62 from "node:fs";
20230
- import path64 from "node:path";
20246
+ import fs63 from "node:fs";
20247
+ import path65 from "node:path";
20231
20248
  function extractOldMeta(text5, file) {
20232
20249
  const grab = (re3) => {
20233
20250
  const m = text5.match(re3);
20234
20251
  return m ? m[1].trim() : null;
20235
20252
  };
20236
- const title = grab(/^#\s+(.+)$/m) || slugify(path64.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
20253
+ const title = grab(/^#\s+(.+)$/m) || slugify(path65.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
20237
20254
  const norm = (raw) => {
20238
20255
  const v = (raw || "").toLowerCase();
20239
20256
  return LEVELS.includes(v) ? v : "med";
@@ -20260,11 +20277,11 @@ function stripOldHeader(text5) {
20260
20277
  }
20261
20278
  function cmdMigrate(opts) {
20262
20279
  const dry = opts.dryRun === true;
20263
- const files2 = walkMd(TODO).filter((f2) => path64.basename(f2) !== "README.md");
20280
+ const files2 = walkMd(TODO).filter((f2) => path65.basename(f2) !== "README.md");
20264
20281
  let changed = 0;
20265
20282
  let skipped = 0;
20266
20283
  for (const file of files2) {
20267
- const text5 = fs62.readFileSync(file, "utf8");
20284
+ const text5 = fs63.readFileSync(file, "utf8");
20268
20285
  if (text5.trimStart().startsWith("---")) {
20269
20286
  skipped++;
20270
20287
  continue;
@@ -20273,7 +20290,7 @@ function cmdMigrate(opts) {
20273
20290
  const out = serializeFrontmatter(meta) + "\n\n" + stripOldHeader(text5).replace(/^\n+/, "");
20274
20291
  if (dry) say(`would migrate ${rel(file)} (priority=${meta.priority})`);
20275
20292
  else {
20276
- fs62.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
20293
+ fs63.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
20277
20294
  say(`migrated ${rel(file)}`);
20278
20295
  }
20279
20296
  changed++;
@@ -20294,8 +20311,8 @@ var init_misc = __esm({
20294
20311
  });
20295
20312
 
20296
20313
  // ../cli/src/lib/card-sources.ts
20297
- import fs63 from "node:fs";
20298
- import path65 from "node:path";
20314
+ import fs64 from "node:fs";
20315
+ import path66 from "node:path";
20299
20316
  function planById(id) {
20300
20317
  const found2 = readPlan(`plans/${id}-.md`);
20301
20318
  return found2?.text.trim() ? found2 : null;
@@ -20305,8 +20322,8 @@ function cardLink(id) {
20305
20322
  const found2 = open3 ?? locateArchived(id);
20306
20323
  if (!found2) return null;
20307
20324
  try {
20308
- const file = found2.kind === "group" ? path65.join(found2.target, "root.md") : found2.target;
20309
- const title = parseFrontmatter(fs63.readFileSync(file, "utf8")).meta?.title ?? "";
20325
+ const file = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
20326
+ const title = parseFrontmatter(fs64.readFileSync(file, "utf8")).meta?.title ?? "";
20310
20327
  return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
20311
20328
  } catch {
20312
20329
  return null;
@@ -20331,7 +20348,7 @@ function link(ref, items) {
20331
20348
  if (ref.kind === "plan") return planLink(ref.id);
20332
20349
  if (ref.kind === "card") return cardLink(ref.id);
20333
20350
  if (ref.kind === "url") return urlLink(ref.url);
20334
- const item = items().find((signal2) => path65.basename(signal2.relPath) === ref.file);
20351
+ const item = items().find((signal2) => path66.basename(signal2.relPath) === ref.file);
20335
20352
  return item ? itemLink(item) : null;
20336
20353
  }
20337
20354
  function cardSources(meta, body) {
@@ -20372,12 +20389,12 @@ var init_card_sources = __esm({
20372
20389
  });
20373
20390
 
20374
20391
  // ../cli/src/lib/view/read.ts
20375
- import fs64 from "node:fs";
20376
- import path66 from "node:path";
20392
+ import fs65 from "node:fs";
20393
+ import path67 from "node:path";
20377
20394
  function readCard(file, relFromTodo) {
20378
- const id = idPrefix(path66.basename(relFromTodo));
20395
+ const id = idPrefix(path67.basename(relFromTodo));
20379
20396
  if (id === null) {
20380
- const parts = relFromTodo.split(path66.sep);
20397
+ const parts = relFromTodo.split(path67.sep);
20381
20398
  const folderId = idPrefix(parts[parts.length - 2] || "");
20382
20399
  if (folderId === null) return null;
20383
20400
  return buildCard(folderId, file, relFromTodo);
@@ -20385,10 +20402,10 @@ function readCard(file, relFromTodo) {
20385
20402
  return buildCard(id, file, relFromTodo);
20386
20403
  }
20387
20404
  function buildCard(id, file, relFromTodo) {
20388
- const text5 = fs64.readFileSync(file, "utf8");
20405
+ const text5 = fs65.readFileSync(file, "utf8");
20389
20406
  const { meta, body } = parseFrontmatter(text5);
20390
20407
  if (!meta) return null;
20391
- const relPath = relFromTodo.split(path66.sep).join("/");
20408
+ const relPath = relFromTodo.split(path67.sep).join("/");
20392
20409
  const flow = workflowFor(meta.workflow);
20393
20410
  const plan = !!meta.workflow && archivesOnApproval(flow);
20394
20411
  const stages = cardStages(meta, flow).length;
@@ -20397,7 +20414,7 @@ function buildCard(id, file, relFromTodo) {
20397
20414
  // Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
20398
20415
  // read here and a card read by the contract agree on what version this is.
20399
20416
  revision: revisionOf(text5),
20400
- updatedAt: fs64.statSync(file).mtime.toISOString(),
20417
+ updatedAt: fs65.statSync(file).mtime.toISOString(),
20401
20418
  relPath,
20402
20419
  title: meta.title,
20403
20420
  priority: meta.priority,
@@ -20418,22 +20435,22 @@ function buildCard(id, file, relFromTodo) {
20418
20435
  };
20419
20436
  }
20420
20437
  function readGroup2(folderName) {
20421
- const groupDir = path66.join(TODO, folderName);
20422
- const rootFile = path66.join(groupDir, "root.md");
20423
- if (!fs64.existsSync(rootFile)) return null;
20424
- const root2 = readCard(rootFile, path66.join(folderName, "root.md"));
20438
+ const groupDir = path67.join(TODO, folderName);
20439
+ const rootFile = path67.join(groupDir, "root.md");
20440
+ if (!fs65.existsSync(rootFile)) return null;
20441
+ const root2 = readCard(rootFile, path67.join(folderName, "root.md"));
20425
20442
  if (!root2) return null;
20426
20443
  root2.isGroup = true;
20427
20444
  const { total, resolved: resolved2 } = subtaskLines(root2.body);
20428
20445
  root2.subtaskLines = { total, resolved: resolved2 };
20429
20446
  const subCards = [];
20430
20447
  const recurse = (dir, relDir) => {
20431
- for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20432
- const childRel = path66.join(relDir, entry.name);
20448
+ for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
20449
+ const childRel = path67.join(relDir, entry.name);
20433
20450
  if (entry.isDirectory()) {
20434
- recurse(path66.join(dir, entry.name), childRel);
20451
+ recurse(path67.join(dir, entry.name), childRel);
20435
20452
  } else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
20436
- const c2 = readCard(path66.join(dir, entry.name), childRel);
20453
+ const c2 = readCard(path67.join(dir, entry.name), childRel);
20437
20454
  if (c2) {
20438
20455
  c2.parent = { id: root2.id, title: root2.title };
20439
20456
  subCards.push(c2);
@@ -20454,12 +20471,12 @@ function readGroup2(folderName) {
20454
20471
  return { root: root2, subCards };
20455
20472
  }
20456
20473
  function standaloneCards(dirRel) {
20457
- const dir = dirRel ? path66.join(TODO, dirRel) : TODO;
20458
- if (!fs64.existsSync(dir)) return [];
20474
+ const dir = dirRel ? path67.join(TODO, dirRel) : TODO;
20475
+ if (!fs65.existsSync(dir)) return [];
20459
20476
  const cards = [];
20460
- for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20477
+ for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
20461
20478
  if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
20462
- const c2 = readCard(path66.join(dir, entry.name), path66.join(dirRel, entry.name));
20479
+ const c2 = readCard(path67.join(dir, entry.name), path67.join(dirRel, entry.name));
20463
20480
  if (c2) cards.push(c2);
20464
20481
  }
20465
20482
  }
@@ -20471,7 +20488,7 @@ function collectCards() {
20471
20488
  const top = standaloneCards("");
20472
20489
  board2.push(...top);
20473
20490
  every.push(...top);
20474
- for (const entry of fs64.readdirSync(TODO, { withFileTypes: true })) {
20491
+ for (const entry of fs65.readdirSync(TODO, { withFileTypes: true })) {
20475
20492
  if (!entry.isDirectory()) continue;
20476
20493
  if (isGroupFolder(entry.name)) {
20477
20494
  const g3 = readGroup2(entry.name);
@@ -20503,7 +20520,7 @@ function findCard(id) {
20503
20520
  }
20504
20521
  function attachSources(card) {
20505
20522
  try {
20506
- const { meta, body } = parseFrontmatter(fs64.readFileSync(path66.join(TODO, card.relPath), "utf8"));
20523
+ const { meta, body } = parseFrontmatter(fs65.readFileSync(path67.join(TODO, card.relPath), "utf8"));
20507
20524
  const sources2 = meta ? cardSources(meta, body) : [];
20508
20525
  if (sources2.length) card.sources = sources2;
20509
20526
  } catch {
@@ -20608,10 +20625,10 @@ var init_read = __esm({
20608
20625
  });
20609
20626
 
20610
20627
  // ../cli/src/lib/group-close.ts
20611
- import fs65 from "node:fs";
20628
+ import fs66 from "node:fs";
20612
20629
  function groupCloses(rootFile) {
20613
20630
  try {
20614
- return groupCloseOf(fs65.readFileSync(rootFile, "utf8"));
20631
+ return groupCloseOf(fs66.readFileSync(rootFile, "utf8"));
20615
20632
  } catch {
20616
20633
  return false;
20617
20634
  }
@@ -20624,12 +20641,12 @@ var init_group_close = __esm({
20624
20641
  });
20625
20642
 
20626
20643
  // ../cli/src/commands/remove.ts
20627
- import fs66 from "node:fs";
20628
- import path67 from "node:path";
20644
+ import fs67 from "node:fs";
20645
+ import path68 from "node:path";
20629
20646
  function leavingIds(id, found2) {
20630
20647
  const ids = /* @__PURE__ */ new Set([id]);
20631
20648
  if (found2.kind === "group") {
20632
- const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path67.basename(f2));
20649
+ const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path68.basename(f2));
20633
20650
  for (const name of names3) {
20634
20651
  const n = idPrefix(name);
20635
20652
  if (n !== null) ids.add(n);
@@ -20641,10 +20658,10 @@ function findMentions(ids) {
20641
20658
  const hits = [];
20642
20659
  const re3 = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
20643
20660
  for (const dir of [TODO, MEMORY]) {
20644
- if (!fs66.existsSync(dir)) continue;
20661
+ if (!fs67.existsSync(dir)) continue;
20645
20662
  for (const file of walkMd(dir)) {
20646
- if (path67.basename(file) === "README.md") continue;
20647
- const lines = fs66.readFileSync(file, "utf8").split("\n");
20663
+ if (path68.basename(file) === "README.md") continue;
20664
+ const lines = fs67.readFileSync(file, "utf8").split("\n");
20648
20665
  const fmEnd = frontmatterEnd(lines);
20649
20666
  lines.forEach((line, i) => {
20650
20667
  if (!re3.test(line)) return;
@@ -20660,12 +20677,12 @@ function findMentions(ids) {
20660
20677
  return hits;
20661
20678
  }
20662
20679
  function leavingCards(id, found2) {
20663
- const own = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
20680
+ const own = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20664
20681
  const cards = [{ id, file: own }];
20665
20682
  if (found2.kind !== "group") return cards;
20666
20683
  for (const file of walkMd(found2.target)) {
20667
20684
  if (file === own) continue;
20668
- const n = idPrefix(path67.basename(file));
20685
+ const n = idPrefix(path68.basename(file));
20669
20686
  if (n !== null) cards.push({ id: n, file });
20670
20687
  }
20671
20688
  return cards;
@@ -20674,10 +20691,10 @@ function stampLeaving(cards, rejection) {
20674
20691
  const day = formatDay();
20675
20692
  const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
20676
20693
  for (const card of cards) {
20677
- if (!fs66.existsSync(card.file)) continue;
20678
- const text5 = fs66.readFileSync(card.file, "utf8");
20694
+ if (!fs67.existsSync(card.file)) continue;
20695
+ const text5 = fs67.readFileSync(card.file, "utf8");
20679
20696
  const stamped = stampLeavingIn(text5, day, stamp4);
20680
- if (stamped !== text5) fs66.writeFileSync(card.file, stamped);
20697
+ if (stamped !== text5) fs67.writeFileSync(card.file, stamped);
20681
20698
  }
20682
20699
  }
20683
20700
  function unfinishedDelivery(id) {
@@ -20693,7 +20710,7 @@ function unfinishedDelivery(id) {
20693
20710
  }[gap];
20694
20711
  return `#${id} is not finished: ${what}.`;
20695
20712
  }
20696
- const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs66.existsSync(path67.join(ASSETS, src.slice(".assets/".length))));
20713
+ const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs67.existsSync(path68.join(ASSETS, src.slice(".assets/".length))));
20697
20714
  return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
20698
20715
  }
20699
20716
  function agentDecisions(text5) {
@@ -20724,8 +20741,8 @@ function removeCard2(id, metric, options) {
20724
20741
  const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
20725
20742
  if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
20726
20743
  const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
20727
- const cardFile3 = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
20728
- const cardText = fs66.existsSync(cardFile3) ? fs66.readFileSync(cardFile3, "utf8") : "";
20744
+ const cardFile3 = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20745
+ const cardText = fs67.existsSync(cardFile3) ? fs67.readFileSync(cardFile3, "utf8") : "";
20729
20746
  const { meta: cardMeta3 } = parseFrontmatter(cardText);
20730
20747
  const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f2) => f2 !== cardFile3).map((f2) => rel(f2)).sort() : [];
20731
20748
  const leftIds = leavingIds(id, found2);
@@ -20756,10 +20773,10 @@ function removeCard2(id, metric, options) {
20756
20773
  const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
20757
20774
  if (dest) {
20758
20775
  stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
20759
- fs66.mkdirSync(ARCHIVE, { recursive: true });
20760
- fs66.renameSync(found2.target, dest);
20776
+ fs67.mkdirSync(ARCHIVE, { recursive: true });
20777
+ fs67.renameSync(found2.target, dest);
20761
20778
  } else {
20762
- fs66.rmSync(found2.target, { recursive: true, force: true });
20779
+ fs67.rmSync(found2.target, { recursive: true, force: true });
20763
20780
  }
20764
20781
  const removedRefs = stripReadmeRefs(found2);
20765
20782
  let marked2 = null;
@@ -20808,14 +20825,14 @@ function removeCard2(id, metric, options) {
20808
20825
  };
20809
20826
  }
20810
20827
  function closeGroup(rootFile) {
20811
- const rootId = idPrefix(path67.basename(path67.dirname(rootFile)));
20828
+ const rootId = idPrefix(path68.basename(path68.dirname(rootFile)));
20812
20829
  if (rootId === null) return null;
20813
20830
  if (runnerProject(KANBAN)) return null;
20814
20831
  if (!groupCloses(rootFile)) return null;
20815
20832
  say(`
20816
20833
  every subtask line on #${rootId} is resolved \u2014 closing the group:`);
20817
20834
  try {
20818
- const { meta, body } = parseFrontmatter(fs66.readFileSync(rootFile, "utf8"));
20835
+ const { meta, body } = parseFrontmatter(fs67.readFileSync(rootFile, "utf8"));
20819
20836
  const res = cmdRemove(rootId, "completed", { closing: true });
20820
20837
  return {
20821
20838
  id: rootId,
@@ -20872,7 +20889,7 @@ function cleanupDiscardedCards(sessionId) {
20872
20889
  if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
20873
20890
  while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
20874
20891
  dropCrossRefs(card.id);
20875
- stripReadmeRefs({ kind: "file", rel: path67.relative(TODO, path67.resolve(REPO_ROOT, card.path)).split(path67.sep).join("/") });
20892
+ stripReadmeRefs({ kind: "file", rel: path68.relative(TODO, path68.resolve(REPO_ROOT, card.path)).split(path68.sep).join("/") });
20876
20893
  }
20877
20894
  return discarded.map((c2) => c2.id);
20878
20895
  });
@@ -20880,8 +20897,8 @@ function cleanupDiscardedCards(sessionId) {
20880
20897
  function recoveredArchiveHandoff(id, source) {
20881
20898
  const found2 = locateArchived(id);
20882
20899
  if (!found2) throw new Error(`No archived card #${id} was found.`);
20883
- const file = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
20884
- const { meta } = parseFrontmatter(fs66.readFileSync(file, "utf8"));
20900
+ const file = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20901
+ const { meta } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
20885
20902
  stripReadmeRefs(source ?? found2);
20886
20903
  const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
20887
20904
  if (root2) markSubtask(root2, id, "tick");
@@ -20979,8 +20996,8 @@ var init_memory_file = __esm({
20979
20996
  });
20980
20997
 
20981
20998
  // ../cli/src/commands/rule.ts
20982
- import fs67 from "node:fs";
20983
- import path68 from "node:path";
20999
+ import fs68 from "node:fs";
21000
+ import path69 from "node:path";
20984
21001
  function cmdRule(askedName, flags) {
20985
21002
  const agent = askedName.trim();
20986
21003
  if (!agentRoster().some((a2) => a2.name === agent)) {
@@ -20989,7 +21006,7 @@ function cmdRule(askedName, flags) {
20989
21006
  const rule = readRuleText(flags.file, flags.text);
20990
21007
  const res = setAgentRule(agent, rule);
20991
21008
  if (!res.ok) die(res.error);
20992
- const file = rel(path68.join(RULES, `${agent}.md`));
21009
+ const file = rel(path69.join(RULES, `${agent}.md`));
20993
21010
  say(rule ? `wrote the \`${agent}\` rule (${file})` : `cleared the \`${agent}\` rule`);
20994
21011
  return { agent, file, cleared: !rule };
20995
21012
  }
@@ -20997,7 +21014,7 @@ function readRuleText(file, text5) {
20997
21014
  if (file !== void 0 && text5 !== void 0) die("pass --file or --text, not both");
20998
21015
  if (file !== void 0) {
20999
21016
  try {
21000
- return fs67.readFileSync(file, "utf8").trim();
21017
+ return fs68.readFileSync(file, "utf8").trim();
21001
21018
  } catch {
21002
21019
  die(`can't read ${file} \u2014 write the rule to a file, then pass its path`);
21003
21020
  }
@@ -21283,8 +21300,8 @@ var init_created_cards = __esm({
21283
21300
 
21284
21301
  // ../cli/src/lib/agent/creation.ts
21285
21302
  import crypto4 from "node:crypto";
21286
- import fs68 from "node:fs";
21287
- import path69 from "node:path";
21303
+ import fs69 from "node:fs";
21304
+ import path70 from "node:path";
21288
21305
  function creationError(error, triage) {
21289
21306
  const zh = readLanguage() === "zh";
21290
21307
  const messages = {
@@ -21310,12 +21327,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
21310
21327
  function creationReceipt(request2, slot) {
21311
21328
  const hash2 = crypto4.createHash("sha256").update(`${request2}
21312
21329
  ${slot}`).digest("hex");
21313
- return path69.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21330
+ return path70.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21314
21331
  }
21315
21332
  function readCreation(file, said3) {
21316
21333
  return withCreationLock(() => {
21317
21334
  try {
21318
- const held4 = JSON.parse(fs68.readFileSync(file, "utf8"));
21335
+ const held4 = JSON.parse(fs69.readFileSync(file, "utf8"));
21319
21336
  if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
21320
21337
  return held4;
21321
21338
  } catch (error) {
@@ -21327,10 +21344,10 @@ function readCreation(file, said3) {
21327
21344
  });
21328
21345
  }
21329
21346
  function saveCreation(file, journal) {
21330
- fs68.mkdirSync(path69.dirname(file), { recursive: true });
21347
+ fs69.mkdirSync(path70.dirname(file), { recursive: true });
21331
21348
  const temp = `${file}.${crypto4.randomUUID()}.tmp`;
21332
- fs68.writeFileSync(temp, JSON.stringify(journal));
21333
- fs68.renameSync(temp, file);
21349
+ fs69.writeFileSync(temp, JSON.stringify(journal));
21350
+ fs69.renameSync(temp, file);
21334
21351
  }
21335
21352
  function archiveCreation(source, id) {
21336
21353
  if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
@@ -21344,7 +21361,7 @@ function archiveCreation(source, id) {
21344
21361
  function triageFile(sourceId) {
21345
21362
  const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
21346
21363
  if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
21347
- return path69.basename(found2.relPath, ".md");
21364
+ return path70.basename(found2.relPath, ".md");
21348
21365
  }
21349
21366
  var init_creation = __esm({
21350
21367
  "../cli/src/lib/agent/creation.ts"() {
@@ -21508,8 +21525,8 @@ __export(board_exports, {
21508
21525
  buildBoardProgram: () => buildBoardProgram
21509
21526
  });
21510
21527
  import crypto5 from "node:crypto";
21511
- import fs69 from "node:fs";
21512
- import path70 from "node:path";
21528
+ import fs70 from "node:fs";
21529
+ import path71 from "node:path";
21513
21530
  async function dispatch(move, cmd, args, opts, cli) {
21514
21531
  const ctx = ctxOf(cmd, cli.program);
21515
21532
  const data = await runAction(ctx, {}, async () => {
@@ -21549,7 +21566,7 @@ async function cloudCard(task, opts) {
21549
21566
  let request2;
21550
21567
  if (typeof opts.bodyFile === "string") {
21551
21568
  try {
21552
- request2 = fs69.readFileSync(opts.bodyFile, "utf8");
21569
+ request2 = fs70.readFileSync(opts.bodyFile, "utf8");
21553
21570
  } catch {
21554
21571
  }
21555
21572
  }
@@ -21579,7 +21596,7 @@ async function cloudCard(task, opts) {
21579
21596
  const file = creationReceipt(`${checked.value}:${requestId}`, slot);
21580
21597
  const journal = readCreation(file, said3);
21581
21598
  if (!journal.made) {
21582
- const key = `akb-${path70.basename(file, ".json").slice(0, 40)}`;
21599
+ const key = `akb-${path71.basename(file, ".json").slice(0, 40)}`;
21583
21600
  const made = await createProjectTask(checked.value, journal.said, key);
21584
21601
  if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
21585
21602
  journal.made = made.value;
@@ -21721,17 +21738,17 @@ var init_board2 = __esm({
21721
21738
  });
21722
21739
 
21723
21740
  // ../cli/src/lib/board-cli.ts
21724
- import fs70 from "node:fs";
21725
- import path71 from "node:path";
21741
+ import fs71 from "node:fs";
21742
+ import path72 from "node:path";
21726
21743
  function useBoard(found2, dirNamed) {
21727
- if (!found2.named && found2.board === path71.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21744
+ if (!found2.named && found2.board === path72.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21728
21745
  else setBoardDir(found2.board, found2.root);
21729
21746
  useProjectState();
21730
21747
  backfillCardWorkflows();
21731
21748
  }
21732
21749
  function whole(found2, move) {
21733
21750
  if (move === MAKES_A_BOARD) return found2;
21734
- if (!fs70.existsSync(path71.join(found2.board, "todo"))) {
21751
+ if (!fs71.existsSync(path72.join(found2.board, "todo"))) {
21735
21752
  die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
21736
21753
  kind: "board-incomplete",
21737
21754
  dir: found2.root
@@ -21740,13 +21757,13 @@ function whole(found2, move) {
21740
21757
  return found2;
21741
21758
  }
21742
21759
  function findBoardUpward(from, move) {
21743
- let dir = path71.resolve(from);
21760
+ let dir = path72.resolve(from);
21744
21761
  for (; ; ) {
21745
- if (hasBoard(dir)) return { root: dir, board: path71.join(dir, "docs", "kanban") };
21762
+ if (hasBoard(dir)) return { root: dir, board: path72.join(dir, "docs", "kanban") };
21746
21763
  if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
21747
- const kept2 = path71.join(dir, ".akb", "kanban");
21748
- if (move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return { root: dir, board: kept2 };
21749
- const up = path71.dirname(dir);
21764
+ const kept2 = path72.join(dir, ".akb", "kanban");
21765
+ if (move !== MAKES_A_BOARD && fs71.existsSync(path72.join(kept2, "todo"))) return { root: dir, board: kept2 };
21766
+ const up = path72.dirname(dir);
21750
21767
  if (up === dir) return null;
21751
21768
  dir = up;
21752
21769
  }
@@ -21754,11 +21771,11 @@ function findBoardUpward(from, move) {
21754
21771
  function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21755
21772
  const named2 = board2 ?? boardFromEnv();
21756
21773
  if (named2) {
21757
- const folder = path71.resolve(cwd, named2);
21758
- if (!fs70.existsSync(folder) && move !== MAKES_A_BOARD) {
21774
+ const folder = path72.resolve(cwd, named2);
21775
+ if (!fs71.existsSync(folder) && move !== MAKES_A_BOARD) {
21759
21776
  die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
21760
21777
  }
21761
- if (fs70.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21778
+ if (fs71.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21762
21779
  die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
21763
21780
  kind: "no-board",
21764
21781
  dir: folder
@@ -21767,24 +21784,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21767
21784
  return { root: projectRootOf(folder), board: folder, named: true };
21768
21785
  }
21769
21786
  if (dir !== null) {
21770
- const root2 = path71.resolve(dir);
21771
- if (!fs70.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
21772
- const kept2 = path71.join(root2, ".akb", "kanban");
21773
- if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
21787
+ const root2 = path72.resolve(dir);
21788
+ if (!fs71.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
21789
+ const kept2 = path72.join(root2, ".akb", "kanban");
21790
+ if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs71.existsSync(path72.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
21774
21791
  if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
21775
21792
  die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
21776
21793
  kind: "no-board",
21777
21794
  dir: root2
21778
21795
  });
21779
21796
  }
21780
- return whole({ root: root2, board: path71.join(root2, "docs", "kanban") }, move);
21797
+ return whole({ root: root2, board: path72.join(root2, "docs", "kanban") }, move);
21781
21798
  }
21782
21799
  const found2 = findBoardUpward(cwd, move);
21783
21800
  if (found2) return whole(found2, move);
21784
- if (move === MAKES_A_BOARD) return { root: path71.resolve(cwd), board: path71.join(path71.resolve(cwd), "docs", "kanban") };
21801
+ if (move === MAKES_A_BOARD) return { root: path72.resolve(cwd), board: path72.join(path72.resolve(cwd), "docs", "kanban") };
21785
21802
  die(
21786
- `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`,
21787
- { kind: "no-board", dir: path71.resolve(cwd) }
21803
+ `no board here. Looked in ${path72.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
21804
+ { kind: "no-board", dir: path72.resolve(cwd) }
21788
21805
  );
21789
21806
  }
21790
21807
  function editDistance(a2, b2) {
@@ -21867,8 +21884,8 @@ var init_board_cli = __esm({
21867
21884
  init_pointer();
21868
21885
  init_card_workflow_backfill();
21869
21886
  MAKES_A_BOARD = "init";
21870
- hasBoard = (dir) => fs70.existsSync(path71.join(dir, "docs", "kanban"));
21871
- isBoardDir = (dir) => fs70.existsSync(path71.join(dir, "todo")) && fs70.existsSync(path71.join(dir, "config.md"));
21887
+ hasBoard = (dir) => fs71.existsSync(path72.join(dir, "docs", "kanban"));
21888
+ isBoardDir = (dir) => fs71.existsSync(path72.join(dir, "todo")) && fs71.existsSync(path72.join(dir, "config.md"));
21872
21889
  boardFromEnv = () => {
21873
21890
  const named2 = process.env.AI4KANBAN_BOARD?.trim();
21874
21891
  return named2 ? named2 : null;
@@ -22125,8 +22142,8 @@ var init_guide = __esm({
22125
22142
  });
22126
22143
 
22127
22144
  // ../cli/src/lib/agent/approve.ts
22128
- import fs77 from "node:fs";
22129
- import path78 from "node:path";
22145
+ import fs78 from "node:fs";
22146
+ import path79 from "node:path";
22130
22147
  function approvalRequest(req) {
22131
22148
  const id = req.id;
22132
22149
  const card = id === void 0 ? null : findCard(id);
@@ -22144,12 +22161,12 @@ function advancePhase(id) {
22144
22161
  const card = findCard(id);
22145
22162
  const found2 = locate(id);
22146
22163
  if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
22147
- const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
22148
- const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
22164
+ const file = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
22165
+ const { meta, body } = parseFrontmatter(fs78.readFileSync(file, "utf8"));
22149
22166
  if (!meta) return { error: `#${id} has no frontmatter` };
22150
22167
  meta.phase = card.stage + 1;
22151
22168
  meta.status = "todo";
22152
- fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
22169
+ fs78.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
22153
22170
  return null;
22154
22171
  }
22155
22172
  var init_approve = __esm({
@@ -22272,16 +22289,16 @@ var init_start = __esm({
22272
22289
  });
22273
22290
 
22274
22291
  // ../cli/src/lib/agent/task-chats.ts
22275
- import fs78 from "node:fs";
22276
- import path79 from "node:path";
22292
+ import fs79 from "node:fs";
22293
+ import path80 from "node:path";
22277
22294
  function taskChatFile(task, home3) {
22278
22295
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
22279
- return path79.join(taskChatsDir(home3), `${task}.jsonl`);
22296
+ return path80.join(taskChatsDir(home3), `${task}.jsonl`);
22280
22297
  }
22281
22298
  function readTaskChat(task, home3) {
22282
22299
  let text5;
22283
22300
  try {
22284
- text5 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
22301
+ text5 = fs79.readFileSync(taskChatFile(task, home3), "utf8");
22285
22302
  } catch {
22286
22303
  return [];
22287
22304
  }
@@ -22302,13 +22319,13 @@ var init_task_chats = __esm({
22302
22319
  "use strict";
22303
22320
  init_home();
22304
22321
  TASK = /^[\w-]{1,100}$/;
22305
- taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
22322
+ taskChatsDir = (home3 = machineHome()) => path80.join(home3, "chats");
22306
22323
  }
22307
22324
  });
22308
22325
 
22309
22326
  // ../cli/src/lib/agent/memory-review.ts
22310
- import fs79 from "node:fs";
22311
- import path80 from "node:path";
22327
+ import fs80 from "node:fs";
22328
+ import path81 from "node:path";
22312
22329
  function taskChatsToReview(tasks) {
22313
22330
  const out = [];
22314
22331
  for (const ref of [...new Set(tasks)]) {
@@ -22330,8 +22347,8 @@ function readArchived2(id) {
22330
22347
  const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
22331
22348
  if (!found2) return null;
22332
22349
  try {
22333
- const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
22334
- const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
22350
+ const file = found2.kind === "group" ? path81.join(found2.target, "root.md") : found2.target;
22351
+ const { meta, body } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
22335
22352
  if (!meta) return null;
22336
22353
  return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
22337
22354
  } catch {
@@ -22400,17 +22417,17 @@ var init_memory_review = __esm({
22400
22417
  });
22401
22418
 
22402
22419
  // ../cli/src/lib/agent/dismissal-review.ts
22403
- import fs80 from "node:fs";
22404
- import path81 from "node:path";
22420
+ import fs81 from "node:fs";
22421
+ import path82 from "node:path";
22405
22422
  function rejectionsToReview() {
22406
- const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
22407
- if (!fs80.existsSync(dir)) return [];
22423
+ const dir = path82.join(ARCHIVE, REJECTIONS_TO_REVIEW);
22424
+ if (!fs81.existsSync(dir)) return [];
22408
22425
  const found2 = [];
22409
22426
  for (const file of walkMd(dir)) {
22410
22427
  const id = archivedId(file);
22411
22428
  if (id === null) continue;
22412
22429
  try {
22413
- const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
22430
+ const { meta } = parseFrontmatter(fs81.readFileSync(file, "utf8"));
22414
22431
  if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
22415
22432
  found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
22416
22433
  } catch {
@@ -22440,7 +22457,7 @@ function citedSources(text5) {
22440
22457
  function withdrawnSources() {
22441
22458
  const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
22442
22459
  try {
22443
- return citedSources(fs80.readFileSync(file, "utf8"));
22460
+ return citedSources(fs81.readFileSync(file, "utf8"));
22444
22461
  } catch {
22445
22462
  return [];
22446
22463
  }
@@ -22465,8 +22482,8 @@ var init_dismissal_review = __esm({
22465
22482
  });
22466
22483
 
22467
22484
  // ../cli/src/lib/agent/flow.ts
22468
- import fs81 from "node:fs";
22469
- import path82 from "node:path";
22485
+ import fs82 from "node:fs";
22486
+ import path83 from "node:path";
22470
22487
  function readCard2(id, home3 = "board") {
22471
22488
  const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
22472
22489
  const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
@@ -22476,10 +22493,10 @@ function readCard2(id, home3 = "board") {
22476
22493
  { kind: "card-not-found", id }
22477
22494
  );
22478
22495
  }
22479
- const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
22496
+ const file = found2.kind === "group" ? path83.join(found2.target, "root.md") : found2.target;
22480
22497
  let text5;
22481
22498
  try {
22482
- text5 = fs81.readFileSync(file, "utf8");
22499
+ text5 = fs82.readFileSync(file, "utf8");
22483
22500
  } catch {
22484
22501
  die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
22485
22502
  }
@@ -64361,8 +64378,8 @@ var require_JSXTransformer = __commonJS({
64361
64378
  }
64362
64379
  if (this.isAutomaticRuntime) {
64363
64380
  if (this.importProcessor) {
64364
- for (const [path89, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
64365
- prefix += `var ${resolvedName} = require("${path89}");`;
64381
+ for (const [path90, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
64382
+ prefix += `var ${resolvedName} = require("${path90}");`;
64366
64383
  }
64367
64384
  } else {
64368
64385
  const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
@@ -64555,11 +64572,11 @@ var require_JSXTransformer = __commonJS({
64555
64572
  }
64556
64573
  claimAutoImportedName(funcName, importPathSuffix) {
64557
64574
  if (this.importProcessor) {
64558
- const path89 = this.jsxImportSource + importPathSuffix;
64559
- if (!this.cjsAutomaticModuleNameResolutions[path89]) {
64560
- this.cjsAutomaticModuleNameResolutions[path89] = this.importProcessor.getFreeIdentifierForPath(path89);
64575
+ const path90 = this.jsxImportSource + importPathSuffix;
64576
+ if (!this.cjsAutomaticModuleNameResolutions[path90]) {
64577
+ this.cjsAutomaticModuleNameResolutions[path90] = this.importProcessor.getFreeIdentifierForPath(path90);
64561
64578
  }
64562
- return `${this.cjsAutomaticModuleNameResolutions[path89]}.${funcName}`;
64579
+ return `${this.cjsAutomaticModuleNameResolutions[path90]}.${funcName}`;
64563
64580
  } else {
64564
64581
  if (!this.esmAutomaticImportNameResolutions[funcName]) {
64565
64582
  this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
@@ -64995,7 +65012,7 @@ var require_CJSImportProcessor = __commonJS({
64995
65012
  */
64996
65013
  pruneTypeOnlyImports() {
64997
65014
  this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
64998
- for (const [path89, importInfo] of this.importInfoByPath.entries()) {
65015
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
64999
65016
  if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
65000
65017
  continue;
65001
65018
  }
@@ -65005,7 +65022,7 @@ var require_CJSImportProcessor = __commonJS({
65005
65022
  ...importInfo.namedImports.map(({ localName }) => localName)
65006
65023
  ];
65007
65024
  if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
65008
- this.importsToReplace.set(path89, "");
65025
+ this.importsToReplace.set(path90, "");
65009
65026
  }
65010
65027
  }
65011
65028
  }
@@ -65013,7 +65030,7 @@ var require_CJSImportProcessor = __commonJS({
65013
65030
  return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
65014
65031
  }
65015
65032
  generateImportReplacements() {
65016
- for (const [path89, importInfo] of this.importInfoByPath.entries()) {
65033
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
65017
65034
  const {
65018
65035
  defaultNames,
65019
65036
  wildcardNames,
@@ -65023,17 +65040,17 @@ var require_CJSImportProcessor = __commonJS({
65023
65040
  hasStarExport
65024
65041
  } = importInfo;
65025
65042
  if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
65026
- this.importsToReplace.set(path89, `require('${path89}');`);
65043
+ this.importsToReplace.set(path90, `require('${path90}');`);
65027
65044
  continue;
65028
65045
  }
65029
- const primaryImportName = this.getFreeIdentifierForPath(path89);
65046
+ const primaryImportName = this.getFreeIdentifierForPath(path90);
65030
65047
  let secondaryImportName;
65031
65048
  if (this.enableLegacyTypeScriptModuleInterop) {
65032
65049
  secondaryImportName = primaryImportName;
65033
65050
  } else {
65034
- secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path89);
65051
+ secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path90);
65035
65052
  }
65036
- let requireCode = `var ${primaryImportName} = require('${path89}');`;
65053
+ let requireCode = `var ${primaryImportName} = require('${path90}');`;
65037
65054
  if (wildcardNames.length > 0) {
65038
65055
  for (const wildcardName of wildcardNames) {
65039
65056
  const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
@@ -65061,7 +65078,7 @@ var require_CJSImportProcessor = __commonJS({
65061
65078
  "createStarExport"
65062
65079
  )}(${primaryImportName});`;
65063
65080
  }
65064
- this.importsToReplace.set(path89, requireCode);
65081
+ this.importsToReplace.set(path90, requireCode);
65065
65082
  for (const defaultName of defaultNames) {
65066
65083
  this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
65067
65084
  }
@@ -65070,8 +65087,8 @@ var require_CJSImportProcessor = __commonJS({
65070
65087
  }
65071
65088
  }
65072
65089
  }
65073
- getFreeIdentifierForPath(path89) {
65074
- const components = path89.split("/");
65090
+ getFreeIdentifierForPath(path90) {
65091
+ const components = path90.split("/");
65075
65092
  const lastComponent = components[components.length - 1];
65076
65093
  const baseName = lastComponent.replace(/\W/g, "");
65077
65094
  return this.nameManager.claimFreeName(`_${baseName}`);
@@ -65116,8 +65133,8 @@ var require_CJSImportProcessor = __commonJS({
65116
65133
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
65117
65134
  throw new Error("Expected string token at the end of import statement.");
65118
65135
  }
65119
- const path89 = this.tokens.stringValueAtIndex(index);
65120
- const importInfo = this.getImportInfo(path89);
65136
+ const path90 = this.tokens.stringValueAtIndex(index);
65137
+ const importInfo = this.getImportInfo(path90);
65121
65138
  importInfo.defaultNames.push(...defaultNames);
65122
65139
  importInfo.wildcardNames.push(...wildcardNames);
65123
65140
  importInfo.namedImports.push(...namedImports);
@@ -65184,8 +65201,8 @@ var require_CJSImportProcessor = __commonJS({
65184
65201
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
65185
65202
  throw new Error("Expected string token at the end of import statement.");
65186
65203
  }
65187
- const path89 = this.tokens.stringValueAtIndex(index);
65188
- const importInfo = this.getImportInfo(path89);
65204
+ const path90 = this.tokens.stringValueAtIndex(index);
65205
+ const importInfo = this.getImportInfo(path90);
65189
65206
  importInfo.namedExports.push(...namedImports);
65190
65207
  }
65191
65208
  preprocessExportStarAtIndex(index) {
@@ -65200,8 +65217,8 @@ var require_CJSImportProcessor = __commonJS({
65200
65217
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
65201
65218
  throw new Error("Expected string token at the end of star export statement.");
65202
65219
  }
65203
- const path89 = this.tokens.stringValueAtIndex(index);
65204
- const importInfo = this.getImportInfo(path89);
65220
+ const path90 = this.tokens.stringValueAtIndex(index);
65221
+ const importInfo = this.getImportInfo(path90);
65205
65222
  if (exportedName !== null) {
65206
65223
  importInfo.exportStarNames.push(exportedName);
65207
65224
  } else {
@@ -65241,8 +65258,8 @@ var require_CJSImportProcessor = __commonJS({
65241
65258
  * Get a mutable import info object for this path, creating one if it doesn't
65242
65259
  * exist yet.
65243
65260
  */
65244
- getImportInfo(path89) {
65245
- const existingInfo = this.importInfoByPath.get(path89);
65261
+ getImportInfo(path90) {
65262
+ const existingInfo = this.importInfoByPath.get(path90);
65246
65263
  if (existingInfo) {
65247
65264
  return existingInfo;
65248
65265
  }
@@ -65255,7 +65272,7 @@ var require_CJSImportProcessor = __commonJS({
65255
65272
  exportStarNames: [],
65256
65273
  hasStarExport: false
65257
65274
  };
65258
- this.importInfoByPath.set(path89, newInfo);
65275
+ this.importInfoByPath.set(path90, newInfo);
65259
65276
  return newInfo;
65260
65277
  }
65261
65278
  addExportBinding(localName, exportedName) {
@@ -65835,16 +65852,16 @@ var require_resolve_uri_umd = __commonJS({
65835
65852
  }
65836
65853
  function parseFileUrl(input) {
65837
65854
  const match = fileRegex.exec(input);
65838
- const path89 = match[2];
65839
- return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path89) ? path89 : "/" + path89, match[3] || "", match[4] || "");
65855
+ const path90 = match[2];
65856
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path90) ? path90 : "/" + path90, match[3] || "", match[4] || "");
65840
65857
  }
65841
- function makeUrl(scheme, user, host2, port, path89, query, hash2) {
65858
+ function makeUrl(scheme, user, host2, port, path90, query, hash2) {
65842
65859
  return {
65843
65860
  scheme,
65844
65861
  user,
65845
65862
  host: host2,
65846
65863
  port,
65847
- path: path89,
65864
+ path: path90,
65848
65865
  query,
65849
65866
  hash: hash2,
65850
65867
  type: 7
@@ -65874,11 +65891,11 @@ var require_resolve_uri_umd = __commonJS({
65874
65891
  url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
65875
65892
  return url;
65876
65893
  }
65877
- function stripPathFilename(path89) {
65878
- if (path89.endsWith("/.."))
65879
- return path89;
65880
- const index = path89.lastIndexOf("/");
65881
- return path89.slice(0, index + 1);
65894
+ function stripPathFilename(path90) {
65895
+ if (path90.endsWith("/.."))
65896
+ return path90;
65897
+ const index = path90.lastIndexOf("/");
65898
+ return path90.slice(0, index + 1);
65882
65899
  }
65883
65900
  function mergePaths(url, base) {
65884
65901
  normalizePath(base, base.type);
@@ -65916,14 +65933,14 @@ var require_resolve_uri_umd = __commonJS({
65916
65933
  pieces[pointer++] = piece;
65917
65934
  positive++;
65918
65935
  }
65919
- let path89 = "";
65936
+ let path90 = "";
65920
65937
  for (let i = 1; i < pointer; i++) {
65921
- path89 += "/" + pieces[i];
65938
+ path90 += "/" + pieces[i];
65922
65939
  }
65923
- if (!path89 || addTrailingSlash && !path89.endsWith("/..")) {
65924
- path89 += "/";
65940
+ if (!path90 || addTrailingSlash && !path90.endsWith("/..")) {
65941
+ path90 += "/";
65925
65942
  }
65926
- url.path = path89;
65943
+ url.path = path90;
65927
65944
  }
65928
65945
  function resolve2(input, base) {
65929
65946
  if (!input && !base)
@@ -65964,13 +65981,13 @@ var require_resolve_uri_umd = __commonJS({
65964
65981
  case 3:
65965
65982
  return queryHash;
65966
65983
  case 4: {
65967
- const path89 = url.path.slice(1);
65968
- if (!path89)
65984
+ const path90 = url.path.slice(1);
65985
+ if (!path90)
65969
65986
  return queryHash || ".";
65970
- if (isRelative(base || input) && !isRelative(path89)) {
65971
- return "./" + path89 + queryHash;
65987
+ if (isRelative(base || input) && !isRelative(path90)) {
65988
+ return "./" + path90 + queryHash;
65972
65989
  }
65973
- return path89 + queryHash;
65990
+ return path90 + queryHash;
65974
65991
  }
65975
65992
  case 5:
65976
65993
  return url.path + queryHash;
@@ -66069,10 +66086,10 @@ var require_trace_mapping_umd = __commonJS({
66069
66086
  module2.exports = __toCommonJS(trace_mapping_exports);
66070
66087
  var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
66071
66088
  var import_resolve_uri = __toESM2(require_resolve_uri());
66072
- function stripFilename(path89) {
66073
- if (!path89) return "";
66074
- const index = path89.lastIndexOf("/");
66075
- return path89.slice(0, index + 1);
66089
+ function stripFilename(path90) {
66090
+ if (!path90) return "";
66091
+ const index = path90.lastIndexOf("/");
66092
+ return path90.slice(0, index + 1);
66076
66093
  }
66077
66094
  function resolver2(mapUrl, sourceRoot) {
66078
66095
  const from = stripFilename(mapUrl);
@@ -67280,9 +67297,9 @@ var require_util2 = __commonJS({
67280
67297
  /** @class */
67281
67298
  (function(_super) {
67282
67299
  __extends(VError2, _super);
67283
- function VError2(path89, message) {
67300
+ function VError2(path90, message) {
67284
67301
  var _this = _super.call(this, message) || this;
67285
- _this.path = path89;
67302
+ _this.path = path90;
67286
67303
  Object.setPrototypeOf(_this, VError2.prototype);
67287
67304
  return _this;
67288
67305
  }
@@ -67342,26 +67359,26 @@ var require_util2 = __commonJS({
67342
67359
  (_b = this._messages).push.apply(_b, best._messages);
67343
67360
  }
67344
67361
  };
67345
- DetailContext2.prototype.getError = function(path89) {
67362
+ DetailContext2.prototype.getError = function(path90) {
67346
67363
  var msgParts = [];
67347
67364
  for (var i = this._propNames.length - 1; i >= 0; i--) {
67348
67365
  var p2 = this._propNames[i];
67349
- path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67366
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67350
67367
  var m = this._messages[i];
67351
67368
  if (m) {
67352
- msgParts.push(path89 + " " + m);
67369
+ msgParts.push(path90 + " " + m);
67353
67370
  }
67354
67371
  }
67355
- return new VError(path89, msgParts.join("; "));
67372
+ return new VError(path90, msgParts.join("; "));
67356
67373
  };
67357
- DetailContext2.prototype.getErrorDetail = function(path89) {
67374
+ DetailContext2.prototype.getErrorDetail = function(path90) {
67358
67375
  var details = [];
67359
67376
  for (var i = this._propNames.length - 1; i >= 0; i--) {
67360
67377
  var p2 = this._propNames[i];
67361
- path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67378
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67362
67379
  var message = this._messages[i];
67363
67380
  if (message) {
67364
- details.push({ path: path89, message });
67381
+ details.push({ path: path90, message });
67365
67382
  }
67366
67383
  }
67367
67384
  var detail = null;
@@ -68174,8 +68191,8 @@ var require_dist = __commonJS({
68174
68191
  this.checkerPlain = this.ttype.getChecker(suite, false);
68175
68192
  this.checkerStrict = this.ttype.getChecker(suite, true);
68176
68193
  }
68177
- Checker2.prototype.setReportedPath = function(path89) {
68178
- this._path = path89;
68194
+ Checker2.prototype.setReportedPath = function(path90) {
68195
+ this._path = path90;
68179
68196
  };
68180
68197
  Checker2.prototype.check = function(value) {
68181
68198
  return this._doCheck(this.checkerPlain, value);
@@ -73608,9 +73625,9 @@ var require_CJSImportTransformer = __commonJS({
73608
73625
  if (shouldElideImport) {
73609
73626
  this.tokens.removeToken();
73610
73627
  } else {
73611
- const path89 = this.tokens.stringValue();
73612
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
73613
- this.tokens.appendCode(this.importProcessor.claimImportCode(path89));
73628
+ const path90 = this.tokens.stringValue();
73629
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
73630
+ this.tokens.appendCode(this.importProcessor.claimImportCode(path90));
73614
73631
  }
73615
73632
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
73616
73633
  if (this.tokens.matches1(_types.TokenType.semi)) {
@@ -74190,8 +74207,8 @@ var require_CJSImportTransformer = __commonJS({
74190
74207
  }
74191
74208
  if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
74192
74209
  this.tokens.removeToken();
74193
- const path89 = this.tokens.stringValue();
74194
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
74210
+ const path90 = this.tokens.stringValue();
74211
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
74195
74212
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
74196
74213
  } else {
74197
74214
  this.tokens.appendCode(exportStatements.join(" "));
@@ -74205,8 +74222,8 @@ var require_CJSImportTransformer = __commonJS({
74205
74222
  while (!this.tokens.matches1(_types.TokenType.string)) {
74206
74223
  this.tokens.removeToken();
74207
74224
  }
74208
- const path89 = this.tokens.stringValue();
74209
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
74225
+ const path90 = this.tokens.stringValue();
74226
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
74210
74227
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
74211
74228
  if (this.tokens.matches1(_types.TokenType.semi)) {
74212
74229
  this.tokens.removeToken();
@@ -104060,9 +104077,9 @@ var init_bundle_mjs = __esm({
104060
104077
  processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
104061
104078
  }
104062
104079
  };
104063
- getPart = (classPartObject, path89) => {
104080
+ getPart = (classPartObject, path90) => {
104064
104081
  let current = classPartObject;
104065
- const parts = path89.split(CLASS_PART_SEPARATOR);
104082
+ const parts = path90.split(CLASS_PART_SEPARATOR);
104066
104083
  const len = parts.length;
104067
104084
  for (let i = 0; i < len; i++) {
104068
104085
  const part = parts[i];
@@ -107312,8 +107329,8 @@ var init_dist = __esm({
107312
107329
  });
107313
107330
 
107314
107331
  // ../cli/src/lib/draw-mockup.ts
107315
- import fs82 from "node:fs";
107316
- import path83 from "node:path";
107332
+ import fs83 from "node:fs";
107333
+ import path84 from "node:path";
107317
107334
  import vm from "node:vm";
107318
107335
  async function loadPackage(id) {
107319
107336
  if (id === "react") return import_react3.default;
@@ -107326,22 +107343,22 @@ async function loadPackage(id) {
107326
107343
  return { __esModule: true, ...await load() };
107327
107344
  }
107328
107345
  function resolveFile(id, from, folder) {
107329
- const at2 = path83.resolve(path83.dirname(from), id);
107330
- if (at2 !== folder && !at2.startsWith(folder + path83.sep)) throw new Error(`${id} is outside the mockup's folder`);
107331
- const tries = path83.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path83.join(at2, `index${e2}`))];
107332
- const file = tries.find((f2) => fs82.statSync(f2, { throwIfNoEntry: false })?.isFile());
107346
+ const at2 = path84.resolve(path84.dirname(from), id);
107347
+ if (at2 !== folder && !at2.startsWith(folder + path84.sep)) throw new Error(`${id} is outside the mockup's folder`);
107348
+ const tries = path84.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path84.join(at2, `index${e2}`))];
107349
+ const file = tries.find((f2) => fs83.statSync(f2, { throwIfNoEntry: false })?.isFile());
107333
107350
  if (!file) throw new Error(`no such file: ${id}`);
107334
107351
  return file;
107335
107352
  }
107336
107353
  async function readGraph(entry) {
107337
- const folder = path83.dirname(entry);
107354
+ const folder = path84.dirname(entry);
107338
107355
  const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
107339
107356
  const walk3 = async (file) => {
107340
107357
  if (graph.code.has(file)) return;
107341
107358
  if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
107342
107359
  let location = file;
107343
107360
  try {
107344
- const js = (0, import_sucrase.transform)(fs82.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
107361
+ const js = (0, import_sucrase.transform)(fs83.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
107345
107362
  graph.code.set(file, js);
107346
107363
  const link2 = /* @__PURE__ */ new Map();
107347
107364
  graph.links.set(file, link2);
@@ -107355,7 +107372,7 @@ async function readGraph(entry) {
107355
107372
  const target = resolveFile(id, file, folder);
107356
107373
  link2.set(id, target);
107357
107374
  if (!target.endsWith(".css")) await walk3(target);
107358
- else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs82.readFileSync(target, "utf8") });
107375
+ else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs83.readFileSync(target, "utf8") });
107359
107376
  }
107360
107377
  } catch (error) {
107361
107378
  throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
@@ -107372,12 +107389,12 @@ function run2(script, context, name, deadline, lineOffset = 0) {
107372
107389
  async function tailwindFor(markup, sheets) {
107373
107390
  const source = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
107374
107391
  const compiler = await rc(source, {
107375
- base: sheets.length ? path83.dirname(sheets[0].path) : "/",
107392
+ base: sheets.length ? path84.dirname(sheets[0].path) : "/",
107376
107393
  loadStylesheet: async (id, from) => {
107377
107394
  if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
107378
107395
  if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
107379
- const at2 = path83.resolve(from, id);
107380
- return { path: at2, base: path83.dirname(at2), content: fs82.readFileSync(at2, "utf8") };
107396
+ const at2 = path84.resolve(from, id);
107397
+ return { path: at2, base: path84.dirname(at2), content: fs83.readFileSync(at2, "utf8") };
107381
107398
  }
107382
107399
  });
107383
107400
  const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
@@ -107486,8 +107503,8 @@ var init_draw_mockup = __esm({
107486
107503
  });
107487
107504
 
107488
107505
  // ../cli/src/lib/preview-validation.ts
107489
- import fs83 from "node:fs";
107490
- import path84 from "node:path";
107506
+ import fs84 from "node:fs";
107507
+ import path85 from "node:path";
107491
107508
  function renderError(error) {
107492
107509
  if (!error || typeof error !== "object") return String(error);
107493
107510
  const { message, stack } = error;
@@ -107498,7 +107515,7 @@ function renderError(error) {
107498
107515
  async function validateScreens(files2) {
107499
107516
  const errors = [];
107500
107517
  const entries = /* @__PURE__ */ new Map();
107501
- for (const file of files2) entries.set(fs83.existsSync(file) ? fs83.realpathSync(file) : path84.resolve(file), path84.resolve(file));
107518
+ for (const file of files2) entries.set(fs84.existsSync(file) ? fs84.realpathSync(file) : path85.resolve(file), path85.resolve(file));
107502
107519
  for (const file of entries.values()) {
107503
107520
  try {
107504
107521
  await drawMockup(file);
@@ -107517,7 +107534,7 @@ async function validatePreview(file, text5) {
107517
107534
  if (/^ {0,3}<!--\s*agent\s*-->\s*$/.test(line)) own = false;
107518
107535
  if (own) section.push(line);
107519
107536
  }
107520
- const files2 = bodySources(section.join("\n")).filter((src) => !/^[a-z][\w+.-]*:|^#|^\/\//i.test(src) && kindOf(path84.extname(src).toLowerCase()) === "html").map((src) => src.startsWith(".assets/") ? path84.join(ASSETS, src.slice(8)) : src.startsWith(".mockups/") ? path84.join(MOCKUPS, src.slice(9)) : path84.resolve(path84.dirname(file), src));
107537
+ 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));
107521
107538
  return validateScreens(files2);
107522
107539
  }
107523
107540
  var init_preview_validation = __esm({
@@ -107674,7 +107691,7 @@ __export(watch_exports, {
107674
107691
  watchRun: () => watchRun
107675
107692
  });
107676
107693
  import { spawn as spawn4 } from "node:child_process";
107677
- import fs84 from "node:fs";
107694
+ import fs85 from "node:fs";
107678
107695
  async function watchRun(sessionId, resume = startResume) {
107679
107696
  const spec = readSpec(sessionId);
107680
107697
  const run3 = peekRun(sessionId);
@@ -107710,11 +107727,11 @@ async function watchRun(sessionId, resume = startResume) {
107710
107727
  const record = claimed ?? run3;
107711
107728
  const sub = record.action === "sub";
107712
107729
  if (claim) await setCardStatus(claim.cardId, claim.status);
107713
- fs84.mkdirSync(SESSIONS_DIR, { recursive: true });
107714
- const logFile = fs84.createWriteStream(record.logPath, { flags: "a" });
107730
+ fs85.mkdirSync(SESSIONS_DIR, { recursive: true });
107731
+ const logFile = fs85.createWriteStream(record.logPath, { flags: "a" });
107715
107732
  logFile.on("error", () => {
107716
107733
  });
107717
- const eventsFile = fs84.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107734
+ const eventsFile = fs85.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107718
107735
  eventsFile.on("error", () => {
107719
107736
  });
107720
107737
  const event2 = (e2) => eventsFile.write(`${JSON.stringify(e2)}
@@ -108300,7 +108317,7 @@ var init_watch = __esm({
108300
108317
  });
108301
108318
 
108302
108319
  // ../cli/src/kanban.ts
108303
- import fs90 from "node:fs";
108320
+ import fs91 from "node:fs";
108304
108321
  import { fileURLToPath as fileURLToPath4 } from "node:url";
108305
108322
 
108306
108323
  // ../cli/src/lib/cli/agent.ts
@@ -108783,8 +108800,8 @@ async function testAgent(args) {
108783
108800
  }
108784
108801
 
108785
108802
  // ../cli/src/commands/cloud.ts
108786
- import fs72 from "node:fs";
108787
- import path73 from "node:path";
108803
+ import fs73 from "node:fs";
108804
+ import path74 from "node:path";
108788
108805
 
108789
108806
  // ../cli/src/lib/cloud/avatar.ts
108790
108807
  init_session();
@@ -108832,13 +108849,13 @@ init_config();
108832
108849
  init_home();
108833
108850
  init_config();
108834
108851
  init_session();
108835
- import fs71 from "node:fs";
108836
- import path72 from "node:path";
108852
+ import fs72 from "node:fs";
108853
+ import path73 from "node:path";
108837
108854
  var FRESH_MS2 = 10 * 6e4;
108838
108855
  var GRACE_MS = 7 * 24 * 60 * 6e4;
108839
- var heldFile = () => path72.join(machineHome(), "pro.json");
108856
+ var heldFile = () => path73.join(machineHome(), "pro.json");
108840
108857
  function forgetPro() {
108841
- fs71.rmSync(heldFile(), { force: true });
108858
+ fs72.rmSync(heldFile(), { force: true });
108842
108859
  }
108843
108860
 
108844
108861
  // ../cli/src/lib/cloud/account.ts
@@ -109015,10 +109032,10 @@ async function cloudImage(opts, program2) {
109015
109032
  const prompt = opts.prompt.trim();
109016
109033
  if (!prompt) usage("Missing the prompt.", line);
109017
109034
  const references = opts.refs.map((file) => {
109018
- const type = REF_TYPES[path73.extname(file).toLowerCase()];
109035
+ const type = REF_TYPES[path74.extname(file).toLowerCase()];
109019
109036
  if (!type) usage(`--ref ${file}: use a PNG, JPEG or WebP file.`, line);
109020
109037
  try {
109021
- return `data:${type};base64,${fs72.readFileSync(file).toString("base64")}`;
109038
+ return `data:${type};base64,${fs73.readFileSync(file).toString("base64")}`;
109022
109039
  } catch (e2) {
109023
109040
  usage(`--ref ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`, line);
109024
109041
  }
@@ -109124,8 +109141,8 @@ async function generate(g3) {
109124
109141
  refuse(g3.failed, g3.fallback);
109125
109142
  }
109126
109143
  const out = g3.outFor?.(res, g3.out) ?? g3.out;
109127
- fs72.mkdirSync(path73.dirname(path73.resolve(out)), { recursive: true });
109128
- fs72.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
109144
+ fs73.mkdirSync(path74.dirname(path74.resolve(out)), { recursive: true });
109145
+ fs73.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
109129
109146
  say(`${out} (${g3.label(res)})`);
109130
109147
  return { out };
109131
109148
  }
@@ -109134,14 +109151,14 @@ async function generate(g3) {
109134
109151
  init_board_files();
109135
109152
  init_workflow_files();
109136
109153
  import crypto6 from "node:crypto";
109137
- import fs74 from "node:fs";
109138
- import path75 from "node:path";
109154
+ import fs75 from "node:fs";
109155
+ import path76 from "node:path";
109139
109156
 
109140
109157
  // ../cli/src/lib/agents/shared-memory.ts
109141
109158
  init_bundled2();
109142
109159
  init_parse();
109143
- import fs73 from "node:fs";
109144
- import path74 from "node:path";
109160
+ import fs74 from "node:fs";
109161
+ import path75 from "node:path";
109145
109162
  function sharedMemory(board2) {
109146
109163
  const declared = /* @__PURE__ */ new Map();
109147
109164
  const take = (folder, text5, builtIn) => {
@@ -109153,16 +109170,16 @@ function sharedMemory(board2) {
109153
109170
  const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
109154
109171
  if (at2) take(at2[1], text5, officialAgent(at2[1]));
109155
109172
  }
109156
- const root2 = path74.join(board2, "agents");
109173
+ const root2 = path75.join(board2, "agents");
109157
109174
  let folders2 = [];
109158
109175
  try {
109159
- folders2 = fs73.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
109176
+ folders2 = fs74.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
109160
109177
  } catch {
109161
109178
  }
109162
109179
  for (const folder of folders2.sort()) {
109163
109180
  let text5 = null;
109164
109181
  try {
109165
- text5 = fs73.readFileSync(path74.join(root2, folder, "AGENT.md"), "utf8");
109182
+ text5 = fs74.readFileSync(path75.join(root2, folder, "AGENT.md"), "utf8");
109166
109183
  } catch {
109167
109184
  }
109168
109185
  take(folder, text5, false);
@@ -109251,24 +109268,24 @@ async function findProject(asked) {
109251
109268
  }
109252
109269
  throw new Refused(`No project of yours has the id or prefix "${asked}".`, "not_found");
109253
109270
  }
109254
- var read2 = (file) => fs74.readFileSync(file, "utf8");
109271
+ var read2 = (file) => fs75.readFileSync(file, "utf8");
109255
109272
  var bytes2 = (text5) => Buffer.byteLength(text5, "utf8");
109256
109273
  function files(dir) {
109257
- if (!fs74.existsSync(dir)) return [];
109274
+ if (!fs75.existsSync(dir)) return [];
109258
109275
  const out = [];
109259
- for (const entry of fs74.readdirSync(dir, { withFileTypes: true })) {
109276
+ for (const entry of fs75.readdirSync(dir, { withFileTypes: true })) {
109260
109277
  if (entry.name.startsWith(".")) continue;
109261
- const full = path75.join(dir, entry.name);
109278
+ const full = path76.join(dir, entry.name);
109262
109279
  if (entry.isDirectory()) out.push(...files(full));
109263
109280
  else if (entry.isFile()) out.push(full);
109264
109281
  }
109265
109282
  return out;
109266
109283
  }
109267
- var posix = (p2) => p2.split(path75.sep).join("/");
109284
+ var posix = (p2) => p2.split(path76.sep).join("/");
109268
109285
  function openCards() {
109269
109286
  const out = [];
109270
109287
  for (const file of walkMd(TODO)) {
109271
- const rel2 = posix(path75.relative(TODO, file));
109288
+ const rel2 = posix(path76.relative(TODO, file));
109272
109289
  if (rel2 === "README.md") continue;
109273
109290
  const parts = rel2.split("/");
109274
109291
  const text5 = read2(file);
@@ -109355,8 +109372,8 @@ function draftsOf(text5) {
109355
109372
  const at2 = /^\.(assets|mockups)\/(.+)$/.exec(name);
109356
109373
  if (!at2) continue;
109357
109374
  const base = at2[1] === "assets" ? ASSETS : MOCKUPS;
109358
- const file = path75.resolve(base, at2[2]);
109359
- if (file.startsWith(base + path75.sep) && fs74.statSync(file, { throwIfNoEntry: false })?.isFile()) out.set(name, file);
109375
+ const file = path76.resolve(base, at2[2]);
109376
+ if (file.startsWith(base + path76.sep) && fs75.statSync(file, { throwIfNoEntry: false })?.isFile()) out.set(name, file);
109360
109377
  }
109361
109378
  return [...out].map(([name, file]) => ({ name, file }));
109362
109379
  }
@@ -109390,9 +109407,9 @@ async function uploadDrafts(task, drafts) {
109390
109407
  const assets = {};
109391
109408
  for (const { name, file } of drafts) {
109392
109409
  if (!card.body.includes(name)) continue;
109393
- const ext = path75.extname(file).toLowerCase();
109410
+ const ext = path76.extname(file).toLowerCase();
109394
109411
  const type = TYPES2[ext] ?? "application/octet-stream";
109395
- const data = fs74.readFileSync(file);
109412
+ const data = fs75.readFileSync(file);
109396
109413
  const artifact = await api("POST", `/v1/tasks/${task}/artifacts`, { type: kindOf2(ext), name: name.slice(0, 200) });
109397
109414
  const upload = await api("POST", `/v1/artifacts/${artifact.id}/uploads`, { content_type: type, size: Math.max(data.length, 1) });
109398
109415
  await api("PUT", `/v1/uploads/${upload.id}`, void 0, { bytes: data, type });
@@ -109435,7 +109452,7 @@ usage: ${program2} cloud import --project <id or prefix> [--dry-run]`, { kind: "
109435
109452
  function localWorkflowFolders() {
109436
109453
  let folders2;
109437
109454
  try {
109438
- 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 }));
109455
+ folders2 = fs75.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 }));
109439
109456
  } catch {
109440
109457
  return [];
109441
109458
  }
@@ -109446,19 +109463,19 @@ function localWorkflowFolders() {
109446
109463
  });
109447
109464
  }
109448
109465
  function filesUnder(dir, base = dir) {
109449
- return fs74.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
109450
- const full = path75.join(dir, e2.name);
109451
- return e2.isDirectory() ? filesUnder(full, base) : [posix(path75.relative(base, full))];
109466
+ return fs75.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
109467
+ const full = path76.join(dir, e2.name);
109468
+ return e2.isDirectory() ? filesUnder(full, base) : [posix(path76.relative(base, full))];
109452
109469
  });
109453
109470
  }
109454
109471
  function packLocalWorkflow(id, def, shipped) {
109455
- const dir = path75.join(WORKFLOWS, id);
109456
- const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2, fs74.readFileSync(path75.join(dir, f2), "utf8")]));
109472
+ const dir = path76.join(WORKFLOWS, id);
109473
+ const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2, fs75.readFileSync(path76.join(dir, f2), "utf8")]));
109457
109474
  const named2 = [...def.previews, ...def.land, ...def.scheduled].map((h3) => h3.agent);
109458
109475
  for (const agent of new Set(named2)) {
109459
- const at2 = path75.join(AGENTS, agent);
109460
- if (fs74.existsSync(path75.join(at2, "AGENT.md"))) {
109461
- for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] = fs74.readFileSync(path75.join(at2, file), "utf8");
109476
+ const at2 = path76.join(AGENTS, agent);
109477
+ if (fs75.existsSync(path76.join(at2, "AGENT.md"))) {
109478
+ for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] = fs75.readFileSync(path76.join(at2, file), "utf8");
109462
109479
  continue;
109463
109480
  }
109464
109481
  for (const [key, text5] of Object.entries(shipped)) if (key.startsWith(`${agent}/`)) out[`agents/${key}`] = text5;
@@ -109468,10 +109485,10 @@ function packLocalWorkflow(id, def, shipped) {
109468
109485
  async function run(asked, dryRun) {
109469
109486
  const project = await findProject(asked);
109470
109487
  const cloudFlows2 = await all(`/v1/workflows?workspace=${encodeURIComponent(project.workspace)}`);
109471
- const board2 = crypto6.createHash("sha256").update(fs74.realpathSync(KANBAN)).digest("hex").slice(0, 16);
109488
+ const board2 = crypto6.createHash("sha256").update(fs75.realpathSync(KANBAN)).digest("hex").slice(0, 16);
109472
109489
  const cards = openCards();
109473
109490
  const problems = [];
109474
- const where = (file) => posix(path75.relative(KANBAN, file));
109491
+ const where = (file) => posix(path76.relative(KANBAN, file));
109475
109492
  const own = [];
109476
109493
  for (const f2 of localWorkflowFolders()) {
109477
109494
  if (f2.def) own.push({ id: f2.id, name: f2.def.name, def: f2.def });
@@ -109500,7 +109517,7 @@ async function run(asked, dryRun) {
109500
109517
  const root2 = `projects/${project.id}/`;
109501
109518
  const boardFiles = [];
109502
109519
  for (const file of [...files(MEMORY), ...files(RULES), CONFIG, MODULES_MD]) {
109503
- if (!fs74.existsSync(file)) continue;
109520
+ if (!fs75.existsSync(file)) continue;
109504
109521
  const rel2 = where(file);
109505
109522
  if (!isBoardPath(rel2)) continue;
109506
109523
  const content = read2(file);
@@ -109611,16 +109628,16 @@ async function run(asked, dryRun) {
109611
109628
  }
109612
109629
  function leftLocal(own) {
109613
109630
  const out = [];
109614
- const count4 = (dir) => fs74.existsSync(dir) ? walkMd(dir).length : 0;
109631
+ const count4 = (dir) => fs75.existsSync(dir) ? walkMd(dir).length : 0;
109615
109632
  const archived = count4(ARCHIVE);
109616
109633
  if (archived) out.push(`.archive/ (${archived})`);
109617
109634
  const triage = count4(TRIAGE);
109618
109635
  if (triage) out.push(`triage/ (${triage})`);
109619
- if (fs74.existsSync(DELIVERIES)) out.push("deliveries/");
109620
- if (fs74.existsSync(path75.join(KANBAN, "metrics.csv"))) out.push("metrics.csv");
109636
+ if (fs75.existsSync(DELIVERIES)) out.push("deliveries/");
109637
+ if (fs75.existsSync(path76.join(KANBAN, "metrics.csv"))) out.push("metrics.csv");
109621
109638
  const named2 = new Set(own.flatMap((w2) => [...w2.def.previews, ...w2.def.land, ...w2.def.scheduled].map((h3) => h3.agent)));
109622
- if (fs74.existsSync(AGENTS)) {
109623
- for (const e2 of fs74.readdirSync(AGENTS, { withFileTypes: true })) {
109639
+ if (fs75.existsSync(AGENTS)) {
109640
+ for (const e2 of fs75.readdirSync(AGENTS, { withFileTypes: true })) {
109624
109641
  if (e2.isDirectory() && !e2.name.startsWith(".") && !named2.has(e2.name)) out.push(`agents/${e2.name}/`);
109625
109642
  }
109626
109643
  }
@@ -109638,8 +109655,8 @@ init_session();
109638
109655
  init_io();
109639
109656
  init_paths();
109640
109657
  import { createHash as createHash5 } from "node:crypto";
109641
- import fs75 from "node:fs";
109642
- import path76 from "node:path";
109658
+ import fs76 from "node:fs";
109659
+ import path77 from "node:path";
109643
109660
  var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
109644
109661
  var CAPTURED = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/;
109645
109662
  var MAX_BYTES3 = 50 * 1024 * 1024;
@@ -109738,10 +109755,10 @@ This template has no preview.`);
109738
109755
  const written = [];
109739
109756
  for (const p2 of previews) {
109740
109757
  const bytes3 = Buffer.from(await (await ask(`/${at2}/previews/${route(p2.path)}`, {}, WITHOUT)).arrayBuffer());
109741
- const file = path76.basename(p2.path);
109742
- const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
109743
- fs75.mkdirSync(opts.to, { recursive: true });
109744
- fs75.writeFileSync(out, bytes3);
109758
+ const file = path77.basename(p2.path);
109759
+ const out = path77.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
109760
+ fs76.mkdirSync(opts.to, { recursive: true });
109761
+ fs76.writeFileSync(out, bytes3);
109745
109762
  written.push(out);
109746
109763
  say(out);
109747
109764
  }
@@ -109754,15 +109771,15 @@ async function templateGet(name, opts, program2) {
109754
109771
  const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
109755
109772
  const fetched = [];
109756
109773
  for (const f2 of template.files) {
109757
- const out = path76.resolve(to, f2.path);
109758
- if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse2(T.corrupt, WITHOUT);
109774
+ const out = path77.resolve(to, f2.path);
109775
+ if (!out.startsWith(path77.resolve(to) + path77.sep)) refuse2(T.corrupt, WITHOUT);
109759
109776
  const bytes3 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
109760
109777
  if (bytes3.byteLength !== f2.size || createHash5("sha256").update(bytes3).digest("hex") !== f2.sha256) {
109761
109778
  refuse2(T.corrupt, WITHOUT);
109762
109779
  }
109763
109780
  fetched.push({ out, bytes: bytes3 });
109764
109781
  }
109765
- const taken = fetched.filter((f2) => fs75.existsSync(f2.out)).map((f2) => path76.relative(to, f2.out));
109782
+ const taken = fetched.filter((f2) => fs76.existsSync(f2.out)).map((f2) => path77.relative(to, f2.out));
109766
109783
  if (taken.length > 0) {
109767
109784
  refuse2({
109768
109785
  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`,
@@ -109770,8 +109787,8 @@ async function templateGet(name, opts, program2) {
109770
109787
  });
109771
109788
  }
109772
109789
  for (const f2 of fetched) {
109773
- fs75.mkdirSync(path76.dirname(f2.out), { recursive: true });
109774
- fs75.writeFileSync(f2.out, f2.bytes);
109790
+ fs76.mkdirSync(path77.dirname(f2.out), { recursive: true });
109791
+ fs76.writeFileSync(f2.out, f2.bytes);
109775
109792
  }
109776
109793
  say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
109777
109794
  Fetched ${name}: ${fetched.length} files into ${to}`);
@@ -109789,25 +109806,25 @@ async function templateSource(name, opts) {
109789
109806
  say(`evidence: ${e2.path}`);
109790
109807
  continue;
109791
109808
  }
109792
- const out = path76.join(opts.to, `${name}-${path76.basename(e2.path)}`);
109793
- fs75.mkdirSync(opts.to, { recursive: true });
109794
- fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
109809
+ const out = path77.join(opts.to, `${name}-${path77.basename(e2.path)}`);
109810
+ fs76.mkdirSync(opts.to, { recursive: true });
109811
+ fs76.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
109795
109812
  written.push(out);
109796
109813
  say(out);
109797
109814
  }
109798
109815
  return { name, source, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
109799
109816
  }
109800
109817
  async function templatePublish(dir, opts) {
109801
- const root2 = path76.resolve(dir);
109802
- const manifest = path76.join(root2, "template.md");
109803
- 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.");
109804
- const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
109818
+ const root2 = path77.resolve(dir);
109819
+ const manifest = path77.join(root2, "template.md");
109820
+ if (!fs76.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
109821
+ const meta = readTemplateMeta(fs76.readFileSync(manifest, "utf8"));
109805
109822
  const files2 = walk2(root2);
109806
- const total = files2.reduce((sum, f2) => sum + fs75.statSync(path76.join(root2, f2)).size, 0);
109823
+ const total = files2.reduce((sum, f2) => sum + fs76.statSync(path77.join(root2, f2)).size, 0);
109807
109824
  if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
109808
109825
  for (const extra of [...opts.preview, ...opts.evidence]) {
109809
- if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
109810
- if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
109826
+ if (!fs76.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
109827
+ if (path77.resolve(extra).startsWith(root2 + path77.sep)) {
109811
109828
  invalid(
109812
109829
  `${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`,
109813
109830
  `${extra} is inside the template folder; keep previews and evidence outside it.`
@@ -109819,10 +109836,10 @@ async function templatePublish(dir, opts) {
109819
109836
  }
109820
109837
  const form = new FormData();
109821
109838
  form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
109822
- const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
109823
- for (const f2 of files2) add("files", f2, path76.join(root2, f2));
109824
- for (const f2 of opts.preview) add("previews", path76.basename(f2), f2);
109825
- for (const f2 of opts.evidence) add("evidence", path76.basename(f2), f2);
109839
+ const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs76.readFileSync(file)]), path77.basename(name));
109840
+ for (const f2 of files2) add("files", f2, path77.join(root2, f2));
109841
+ for (const f2 of opts.preview) add("previews", path77.basename(f2), f2);
109842
+ for (const f2 of opts.evidence) add("evidence", path77.basename(f2), f2);
109826
109843
  const done2 = await asJson(await ask("", { method: "POST", body: form }));
109827
109844
  say(
109828
109845
  done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files2.length} \u4E2A\u6587\u4EF6\u3002
@@ -109838,11 +109855,11 @@ Deleted ${name} from the catalog.`);
109838
109855
  return { name, deleted: true };
109839
109856
  }
109840
109857
  async function templateShowcase(name, dir) {
109841
- const file = path76.join(dir, "showcase.json");
109842
- if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
109858
+ const file = path77.join(dir, "showcase.json");
109859
+ if (!fs76.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
109843
109860
  let meta;
109844
109861
  try {
109845
- meta = JSON.parse(fs75.readFileSync(file, "utf8"));
109862
+ meta = JSON.parse(fs76.readFileSync(file, "utf8"));
109846
109863
  } catch {
109847
109864
  return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
109848
109865
  }
@@ -109854,9 +109871,9 @@ async function templateShowcase(name, dir) {
109854
109871
  const form = new FormData();
109855
109872
  form.set("meta", JSON.stringify(meta));
109856
109873
  for (const p2 of new Set(named2)) {
109857
- const at2 = path76.join(dir, p2);
109858
- if (!fs75.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
109859
- form.append(`media:${p2}`, new Blob([fs75.readFileSync(at2)]), p2);
109874
+ const at2 = path77.join(dir, p2);
109875
+ if (!fs76.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
109876
+ form.append(`media:${p2}`, new Blob([fs76.readFileSync(at2)]), p2);
109860
109877
  }
109861
109878
  const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
109862
109879
  say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
@@ -109865,7 +109882,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
109865
109882
  }
109866
109883
  function walk2(root2, sub = "") {
109867
109884
  const out = [];
109868
- for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
109885
+ for (const entry of fs76.readdirSync(path77.join(root2, sub), { withFileTypes: true })) {
109869
109886
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
109870
109887
  const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
109871
109888
  if (entry.isDirectory()) out.push(...walk2(root2, rel2));
@@ -110022,8 +110039,12 @@ init_paths();
110022
110039
  init_workflow_diagram();
110023
110040
  init_cloud_workflows();
110024
110041
  init_workflows();
110025
- import fs76 from "node:fs";
110026
- import path77 from "node:path";
110042
+ init_workflow_folder();
110043
+ init_workflow_files();
110044
+ init_config();
110045
+ init_session();
110046
+ import fs77 from "node:fs";
110047
+ import path78 from "node:path";
110027
110048
  var found = (id) => {
110028
110049
  const flow = workflowById(id);
110029
110050
  if (!flow) {
@@ -110079,14 +110100,46 @@ function cmdWorkflowDiagram(id, card) {
110079
110100
  const agent = findSpecAgent(name);
110080
110101
  return agent ? { ...agent, after: agentAfter(name) } : null;
110081
110102
  });
110082
- const file = path77.join(ASSETS, String(cardId2), "workflow.json");
110083
- fs76.mkdirSync(path77.dirname(file), { recursive: true });
110084
- fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
110103
+ const file = path78.join(ASSETS, String(cardId2), "workflow.json");
110104
+ fs77.mkdirSync(path78.dirname(file), { recursive: true });
110105
+ fs77.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
110085
110106
  `);
110086
110107
  const tag = `<Workflow src=".assets/${cardId2}/workflow.json" label="${flow.name.replace(/"/g, "")}" />`;
110087
110108
  say(tag);
110088
110109
  return { file, tag, diagram };
110089
110110
  }
110111
+ var PUBLISH_REFUSED = {
110112
+ not_creator: "only accounts WildCrane has made creators can publish to the marketplace",
110113
+ not_yours: "another creator holds this name, or it is a built-in"
110114
+ };
110115
+ async function cmdWorkflowPublish(folder, opts) {
110116
+ const dir = path78.resolve(folder);
110117
+ if (!fs77.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
110118
+ const slug2 = path78.basename(dir);
110119
+ const files2 = readWorkflowFolder(dir);
110120
+ const checked = checkWorkflowFiles(files2, true);
110121
+ if (!checked.ok) die(`${slug2}: ${checked.file} ${checked.reason}`, "bad-workflow");
110122
+ const token3 = await accessToken();
110123
+ if (!token3.ok) die(SAID[token3.reason].en, "cloud-refused");
110124
+ let res;
110125
+ try {
110126
+ res = await fetch(`${cloudEndpoints().api}/v1/marketplace/workflows`, {
110127
+ method: "POST",
110128
+ headers: { authorization: `Bearer ${token3.token}`, "content-type": "application/json" },
110129
+ body: JSON.stringify({ slug: slug2, files: files2, ...opts.dryRun ? { dry_run: true } : {} })
110130
+ });
110131
+ } catch {
110132
+ die(SAID.unreachable.en, "cloud-refused");
110133
+ }
110134
+ const body = await res.json().catch(() => ({}));
110135
+ if (!res.ok) {
110136
+ if (res.status === 401) die(SAID.expired.en, "cloud-refused");
110137
+ const code = body.error?.code ?? "failed";
110138
+ die(`${slug2}: ${PUBLISH_REFUSED[code] ?? body.error?.message ?? `Cloud answered ${res.status}`}`, code);
110139
+ }
110140
+ say(!body.changed ? `${slug2} is unchanged (v${body.version}).` : opts.dryRun ? `${slug2} would publish v${body.version}.` : `Published ${slug2} v${body.version}.`);
110141
+ return { slug: slug2, id: body.id, version: body.version, changed: body.changed, ...opts.dryRun ? { dryRun: true } : {} };
110142
+ }
110090
110143
 
110091
110144
  // ../cli/src/commands/run.ts
110092
110145
  init_progress();
@@ -110248,8 +110301,8 @@ init_tasks();
110248
110301
  init_read();
110249
110302
  init_rules();
110250
110303
  init_board();
110251
- import fs85 from "node:fs";
110252
- import path85 from "node:path";
110304
+ import fs86 from "node:fs";
110305
+ import path86 from "node:path";
110253
110306
  var FOLLOW_MS = 400;
110254
110307
  async function cmdStartRun(action, args, opts, program2 = "akb") {
110255
110308
  const { req, follow: follow2, print } = readRequest(action, args, opts);
@@ -110473,7 +110526,7 @@ async function cmdSubStart(words, opts) {
110473
110526
  let prompt = words.join(" ");
110474
110527
  if (opts.file) {
110475
110528
  try {
110476
- prompt = fs85.readFileSync(path85.resolve(opts.file), "utf8");
110529
+ prompt = fs86.readFileSync(path86.resolve(opts.file), "utf8");
110477
110530
  } catch {
110478
110531
  die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
110479
110532
  }
@@ -110764,7 +110817,7 @@ function cmdCompleteDelivery(id, options) {
110764
110817
  // ../cli/src/commands/triage.ts
110765
110818
  init_scheduled();
110766
110819
  init_workflows();
110767
- import fs87 from "node:fs";
110820
+ import fs88 from "node:fs";
110768
110821
 
110769
110822
  // ../cli/src/lib/signals/index.ts
110770
110823
  init_cards();
@@ -110774,16 +110827,16 @@ init_yaml();
110774
110827
  // ../cli/src/lib/signals/config.ts
110775
110828
  init_settings();
110776
110829
  init_paths();
110777
- import fs86 from "node:fs";
110778
- import path86 from "node:path";
110830
+ import fs87 from "node:fs";
110831
+ import path87 from "node:path";
110779
110832
  var TOKEN_KEY = "TRIAGE_ENDPOINT_TOKEN";
110780
110833
  var ENDPOINT_SETTING = "Triage endpoint";
110781
110834
  var LINE2 = /^- \*\*Triage endpoint\*\*\s*[—-]\s*(.+)$/m;
110782
- var boardRel3 = (file) => rel(file).split(path86.sep).join("/");
110835
+ var boardRel3 = (file) => rel(file).split(path87.sep).join("/");
110783
110836
  function signalEndpoint() {
110784
110837
  let text5;
110785
110838
  try {
110786
- text5 = fs86.readFileSync(CONFIG, "utf8");
110839
+ text5 = fs87.readFileSync(CONFIG, "utf8");
110787
110840
  } catch {
110788
110841
  return "";
110789
110842
  }
@@ -110959,7 +111012,7 @@ async function cmdTriageAdd(opts) {
110959
111012
  let body = opts.text;
110960
111013
  if (opts.file !== void 0) {
110961
111014
  try {
110962
- body = fs87.readFileSync(opts.file, "utf8");
111015
+ body = fs88.readFileSync(opts.file, "utf8");
110963
111016
  } catch {
110964
111017
  die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
110965
111018
  }
@@ -111353,6 +111406,9 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
111353
111406
  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) {
111354
111407
  await onBoard2(this, cli, () => cmdWorkflowDiagram(id, card));
111355
111408
  });
111409
+ flowWord("publish").argument("<folder>", "the workflow folder; its name is the slug").option("--dry-run", "check the folder and print what would happen, publishing nothing").summary("publish a workflow folder to the marketplace as the signed-in account. Prints the version new tasks take, or that nothing changed.").action(async function(folder) {
111410
+ await boardless(this, cli, () => cmdWorkflowPublish(folder, this.opts()));
111411
+ });
111356
111412
  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() {
111357
111413
  const ctx = ctxOf(this, cli.program);
111358
111414
  useBoard(resolveBoard("components", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint }), ctx.dir !== null);
@@ -111529,8 +111585,8 @@ function declareAgent(program2, cli) {
111529
111585
  }
111530
111586
 
111531
111587
  // ../cli/src/lib/cli/setup.ts
111532
- import fs89 from "node:fs";
111533
- import path88 from "node:path";
111588
+ import fs90 from "node:fs";
111589
+ import path89 from "node:path";
111534
111590
  import { fileURLToPath as fileURLToPath3 } from "node:url";
111535
111591
 
111536
111592
  // ../cli/src/commands/update.ts
@@ -111544,8 +111600,8 @@ init_paths();
111544
111600
  init_memory();
111545
111601
  init_yaml2();
111546
111602
  init_version();
111547
- import fs88 from "node:fs";
111548
- import path87 from "node:path";
111603
+ import fs89 from "node:fs";
111604
+ import path88 from "node:path";
111549
111605
  import { spawnSync as spawnSync5 } from "node:child_process";
111550
111606
  var NAME = "wildcrane";
111551
111607
  var REPO = "https://github.com/wildcrane-ai/wildcrane";
@@ -111567,10 +111623,10 @@ var Report = class {
111567
111623
  for (const line of this.notes) say(` ! ${line}`);
111568
111624
  }
111569
111625
  };
111570
- var read4 = (file) => fs88.existsSync(file) ? fs88.readFileSync(file, "utf8") : null;
111626
+ var read4 = (file) => fs89.existsSync(file) ? fs89.readFileSync(file, "utf8") : null;
111571
111627
  function statOf(p2) {
111572
111628
  try {
111573
- return fs88.lstatSync(p2);
111629
+ return fs89.lstatSync(p2);
111574
111630
  } catch {
111575
111631
  return null;
111576
111632
  }
@@ -111595,10 +111651,10 @@ async function cmdUpdate2(ctx) {
111595
111651
  return { updated: ctx.dir, from, to: SKILL_VERSION };
111596
111652
  }
111597
111653
  async function repairBoard(root2, report3, named2) {
111598
- const legacy2 = path87.join(root2, "docs", "kanban");
111599
- const kept2 = path87.join(root2, ".akb", "kanban");
111600
- const board2 = named2 ?? (fs88.existsSync(legacy2) ? legacy2 : kept2);
111601
- if (!fs88.existsSync(board2)) {
111654
+ const legacy2 = path88.join(root2, "docs", "kanban");
111655
+ const kept2 = path88.join(root2, ".akb", "kanban");
111656
+ const board2 = named2 ?? (fs89.existsSync(legacy2) ? legacy2 : kept2);
111657
+ if (!fs89.existsSync(board2)) {
111602
111658
  report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
111603
111659
  return false;
111604
111660
  }
@@ -111629,20 +111685,20 @@ function moveRuntimes(root2, board2, report3) {
111629
111685
  }
111630
111686
  }
111631
111687
  function moveLegacyMemory(board2, report3) {
111632
- const memory = path87.join(board2, "memory");
111688
+ const memory = path88.join(board2, "memory");
111633
111689
  const moved = [];
111634
111690
  for (const name of MEMORY_FILES) {
111635
- const from = path87.join(board2, name);
111691
+ const from = path88.join(board2, name);
111636
111692
  const st2 = statOf(from);
111637
111693
  if (!st2 || !st2.isFile()) continue;
111638
- fs88.mkdirSync(memory, { recursive: true });
111639
- const to = path87.join(memory, name);
111694
+ fs89.mkdirSync(memory, { recursive: true });
111695
+ const to = path88.join(memory, name);
111640
111696
  const there = read4(to);
111641
111697
  if (there === null) {
111642
- fs88.renameSync(from, to);
111698
+ fs89.renameSync(from, to);
111643
111699
  moved.push(name);
111644
111700
  } else if (there === read4(from)) {
111645
- fs88.rmSync(from);
111701
+ fs89.rmSync(from);
111646
111702
  moved.push(name);
111647
111703
  } else {
111648
111704
  report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
@@ -111651,23 +111707,23 @@ function moveLegacyMemory(board2, report3) {
111651
111707
  if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
111652
111708
  }
111653
111709
  function dropRecordFile(board2) {
111654
- const file = path87.join(board2, "record.csv");
111655
- if (!fs88.existsSync(file)) return null;
111656
- fs88.rmSync(file);
111710
+ const file = path88.join(board2, "record.csv");
111711
+ if (!fs89.existsSync(file)) return null;
111712
+ fs89.rmSync(file);
111657
111713
  return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
111658
111714
  }
111659
111715
  function dropModuleGoals(board2, report3) {
111660
- const memory = path87.join(board2, "memory");
111661
- if (!fs88.existsSync(memory)) return;
111662
- const root2 = read4(path87.join(memory, "goal.md"));
111716
+ const memory = path88.join(board2, "memory");
111717
+ if (!fs89.existsSync(memory)) return;
111718
+ const root2 = read4(path88.join(memory, "goal.md"));
111663
111719
  let dropped = 0;
111664
- for (const entry of fs88.readdirSync(memory, { withFileTypes: true })) {
111720
+ for (const entry of fs89.readdirSync(memory, { withFileTypes: true })) {
111665
111721
  if (!entry.isDirectory()) continue;
111666
- const file = path87.join(memory, entry.name, "goal.md");
111722
+ const file = path88.join(memory, entry.name, "goal.md");
111667
111723
  const text5 = read4(file);
111668
111724
  if (text5 === null) continue;
111669
111725
  if (text5 === root2 || text5.includes(UNFILLED) || !goalWords(text5)) {
111670
- fs88.rmSync(file);
111726
+ fs89.rmSync(file);
111671
111727
  dropped++;
111672
111728
  } else {
111673
111729
  report3.notes.push(
@@ -111689,10 +111745,10 @@ var PLAN_LEADS = {
111689
111745
  var GONE_LEADS = ["software-planner", "planner"];
111690
111746
  function planLeads(board2) {
111691
111747
  const leads = { ...PLAN_LEADS };
111692
- const root2 = path87.join(board2, "workflows");
111693
- for (const entry of fs88.existsSync(root2) ? fs88.readdirSync(root2, { withFileTypes: true }) : []) {
111748
+ const root2 = path88.join(board2, "workflows");
111749
+ for (const entry of fs89.existsSync(root2) ? fs89.readdirSync(root2, { withFileTypes: true }) : []) {
111694
111750
  if (!entry.isDirectory()) continue;
111695
- const meta = splitFrontmatter(read4(path87.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
111751
+ const meta = splitFrontmatter(read4(path88.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
111696
111752
  const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
111697
111753
  const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
111698
111754
  const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
@@ -111701,30 +111757,30 @@ function planLeads(board2) {
111701
111757
  return leads;
111702
111758
  }
111703
111759
  function movePlanRules(board2, report3) {
111704
- const rules = path87.join(board2, "rules");
111760
+ const rules = path88.join(board2, "rules");
111705
111761
  const moved = [];
111706
111762
  for (const [id, leads] of Object.entries(planLeads(board2))) {
111707
111763
  for (const lead of leads) {
111708
- const from = path87.join(rules, `${lead}.md`);
111764
+ const from = path88.join(rules, `${lead}.md`);
111709
111765
  const rule = read4(from)?.trim();
111710
111766
  if (!rule) continue;
111711
- const to = path87.join(rules, "workflows", `${id}.md`);
111767
+ const to = path88.join(rules, "workflows", `${id}.md`);
111712
111768
  const there = read4(to)?.trim() ?? "";
111713
111769
  if (!there.includes(rule)) {
111714
- fs88.mkdirSync(path87.dirname(to), { recursive: true });
111715
- fs88.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
111770
+ fs89.mkdirSync(path88.dirname(to), { recursive: true });
111771
+ fs89.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
111716
111772
  `);
111717
111773
  moved.push(`${lead} \u2192 ${id}`);
111718
111774
  }
111719
111775
  }
111720
111776
  }
111721
- for (const lead of GONE_LEADS) fs88.rmSync(path87.join(rules, `${lead}.md`), { force: true });
111777
+ for (const lead of GONE_LEADS) fs89.rmSync(path88.join(rules, `${lead}.md`), { force: true });
111722
111778
  if (moved.length) report3.did.push(`made each plan agent's rule its workflow's card rule (docs/kanban/rules/workflows/): ${moved.join(", ")}`);
111723
111779
  }
111724
111780
  function noteOldWorkflows(board2, report3) {
111725
111781
  const old = (dir, file, keys) => {
111726
- const root2 = path87.join(board2, dir);
111727
- return (fs88.existsSync(root2) ? fs88.readdirSync(root2, { withFileTypes: true }) : []).filter((e2) => e2.isDirectory() && keys.test(splitFrontmatter(read4(path87.join(root2, e2.name, file)) ?? "").meta ?? "")).map((e2) => `docs/kanban/${dir}/${e2.name}/${file}`);
111782
+ const root2 = path88.join(board2, dir);
111783
+ return (fs89.existsSync(root2) ? fs89.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}`);
111728
111784
  };
111729
111785
  const files2 = [...old("workflows", "WORKFLOW.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
111730
111786
  if (files2.length) {
@@ -111734,7 +111790,7 @@ function noteOldWorkflows(board2, report3) {
111734
111790
  }
111735
111791
  }
111736
111792
  function checkConfig(board2, report3) {
111737
- const current = read4(path87.join(board2, "config.md"));
111793
+ const current = read4(path88.join(board2, "config.md"));
111738
111794
  if (!current) return;
111739
111795
  const added = missingConfigKeys(current);
111740
111796
  if (added.length) {
@@ -111744,7 +111800,7 @@ function checkConfig(board2, report3) {
111744
111800
  }
111745
111801
  }
111746
111802
  function checkModules(board2, report3) {
111747
- const map2 = read4(path87.join(board2, "modules.md"));
111803
+ const map2 = read4(path88.join(board2, "modules.md"));
111748
111804
  if (map2 && map2.includes(UNFILLED)) {
111749
111805
  report3.notes.push(
111750
111806
  "docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
@@ -111798,14 +111854,14 @@ function declareSetup(program2, cli) {
111798
111854
  program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
111799
111855
  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");
111800
111856
  const where = (cmd) => {
111801
- const dir = path88.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
111802
- if (!fs89.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
111857
+ const dir = path89.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
111858
+ if (!fs90.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
111803
111859
  return dir;
111804
111860
  };
111805
111861
  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() {
111806
111862
  const dir = where(this);
111807
111863
  const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
111808
- const board2 = named2 ? path88.resolve(cli.cwd, named2) : null;
111864
+ const board2 = named2 ? path89.resolve(cli.cwd, named2) : null;
111809
111865
  await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
111810
111866
  });
111811
111867
  program2.command("__rules", { hidden: true }).action(function() {
@@ -111850,7 +111906,7 @@ function invokedDirectly() {
111850
111906
  const entry = process.argv[1];
111851
111907
  if (!entry) return false;
111852
111908
  try {
111853
- return fs90.realpathSync(entry) === fs90.realpathSync(SELF2);
111909
+ return fs91.realpathSync(entry) === fs91.realpathSync(SELF2);
111854
111910
  } catch {
111855
111911
  return false;
111856
111912
  }