wildcrane 0.11.28 → 0.11.30

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.
Files changed (2) hide show
  1. package/dist/kanban.mjs +940 -875
  2. package/package.json +1 -1
package/dist/kanban.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // ai4kanban 0.11.28 — built from the CLI's TypeScript sources by cli/scripts/build.mjs.
2
+ // ai4kanban 0.11.30 — built from the CLI's TypeScript sources by cli/scripts/build.mjs.
3
3
  // Do not edit: every change belongs in cli/src/, and a build overwrites this file.
4
4
  import { createRequire as __ai4kanbanRequire } from 'node:module'
5
5
  const require = __ai4kanbanRequire(import.meta.url)
@@ -2552,10 +2552,10 @@ function findRollout(threadId) {
2552
2552
  }
2553
2553
  for (const name of names3) {
2554
2554
  if (!name.startsWith("rollout-") || !name.endsWith(tail2)) continue;
2555
- const path89 = join(dir, name);
2555
+ const path90 = join(dir, name);
2556
2556
  try {
2557
- const at2 = statSync(path89).mtimeMs;
2558
- if (!newest2 || at2 > newest2.at) newest2 = { path: path89, at: at2 };
2557
+ const at2 = statSync(path90).mtimeMs;
2558
+ if (!newest2 || at2 > newest2.at) newest2 = { path: path90, at: at2 };
2559
2559
  } catch {
2560
2560
  }
2561
2561
  }
@@ -2563,11 +2563,11 @@ function findRollout(threadId) {
2563
2563
  return newest2?.path;
2564
2564
  }
2565
2565
  function readCodexRunFacts(threadId) {
2566
- const path89 = findRollout(threadId);
2567
- if (!path89) return void 0;
2566
+ const path90 = findRollout(threadId);
2567
+ if (!path90) return void 0;
2568
2568
  let raw;
2569
2569
  try {
2570
- raw = readFileSync(path89, "utf8");
2570
+ raw = readFileSync(path90, "utf8");
2571
2571
  } catch {
2572
2572
  return void 0;
2573
2573
  }
@@ -2695,8 +2695,8 @@ function renderCompleted(item) {
2695
2695
  const changes = Array.isArray(item.changes) ? item.changes : [];
2696
2696
  return changes.map((raw) => {
2697
2697
  const change2 = obj(raw);
2698
- const path89 = str(change2.path);
2699
- return path89 ? `\u23FA ${str(change2.kind) || "change"}(${path89})
2698
+ const path90 = str(change2.path);
2699
+ return path90 ? `\u23FA ${str(change2.kind) || "change"}(${path90})
2700
2700
  ` : "";
2701
2701
  }).join("");
2702
2702
  }
@@ -2958,10 +2958,10 @@ function readKimiRunFacts(sessionId) {
2958
2958
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
2959
2959
  let model;
2960
2960
  let holding = 0;
2961
- for (const { path: path89, main } of wireFiles(entry.sessionDir)) {
2961
+ for (const { path: path90, main } of wireFiles(entry.sessionDir)) {
2962
2962
  let raw;
2963
2963
  try {
2964
- raw = readFileSync2(path89, "utf8");
2964
+ raw = readFileSync2(path90, "utf8");
2965
2965
  } catch {
2966
2966
  continue;
2967
2967
  }
@@ -3244,7 +3244,7 @@ var init_package = __esm({
3244
3244
  "package.json"() {
3245
3245
  package_default = {
3246
3246
  name: "wildcrane",
3247
- version: "0.11.28",
3247
+ version: "0.11.30",
3248
3248
  akbContract: 7,
3249
3249
  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.",
3250
3250
  keywords: [
@@ -3321,8 +3321,8 @@ var init_version = __esm({
3321
3321
  import fs12 from "node:fs";
3322
3322
  function whereHint(update2, title) {
3323
3323
  const locations = Array.isArray(update2.locations) ? update2.locations : [];
3324
- const path89 = str(obj(locations[0]).path);
3325
- return path89 && !title.includes(path89) ? hint(path89) : "";
3324
+ const path90 = str(obj(locations[0]).path);
3325
+ return path90 && !title.includes(path90) ? hint(path90) : "";
3326
3326
  }
3327
3327
  function saidBy(update2) {
3328
3328
  const content = Array.isArray(update2.content) ? update2.content : [];
@@ -8246,15 +8246,15 @@ var init_roles = __esm({
8246
8246
  });
8247
8247
 
8248
8248
  // src/lib/shared/board-files.ts
8249
- function isBoardPath(path89) {
8250
- if (!path89 || path89.length > 500 || path89.startsWith("/") || path89.includes("\\") || path89.includes("\0")) return false;
8251
- if (path89.split("/").some((part) => !part || part === "." || part === "..")) return false;
8252
- if (path89 === "todo/README.md" || path89.split("/").includes(".sync")) return false;
8253
- if (path89.startsWith("workflows/")) return true;
8254
- if (SETTINGS.includes(path89)) return true;
8255
- if (path89.startsWith("rules/")) return isSettingsPath(path89);
8256
- if (path89.startsWith("assets/")) return path89.endsWith(".json");
8257
- return ROOTS.some((root2) => path89.startsWith(root2)) && path89.endsWith(".md");
8249
+ function isBoardPath(path90) {
8250
+ if (!path90 || path90.length > 500 || path90.startsWith("/") || path90.includes("\\") || path90.includes("\0")) return false;
8251
+ if (path90.split("/").some((part) => !part || part === "." || part === "..")) return false;
8252
+ if (path90 === "todo/README.md" || path90.split("/").includes(".sync")) return false;
8253
+ if (path90.startsWith("workflows/")) return true;
8254
+ if (SETTINGS.includes(path90)) return true;
8255
+ if (path90.startsWith("rules/")) return isSettingsPath(path90);
8256
+ if (path90.startsWith("assets/")) return path90.endsWith(".json");
8257
+ return ROOTS.some((root2) => path90.startsWith(root2)) && path90.endsWith(".md");
8258
8258
  }
8259
8259
  var ROOTS, SETTINGS, isSettingsPath, BOARD_FILE_LIMIT, cardSlug, workflowFolder, workflowName, draftFolder;
8260
8260
  var init_board_files = __esm({
@@ -8262,7 +8262,7 @@ var init_board_files = __esm({
8262
8262
  "use strict";
8263
8263
  ROOTS = ["todo/", ".archive/", "memory/", "workflows/", "triage/", "assets/", "rules/"];
8264
8264
  SETTINGS = ["modules.md", "config.md"];
8265
- isSettingsPath = (path89) => SETTINGS.includes(path89) || /^rules\/(?:workflows\/)?[^/]+\.md$/.test(path89);
8265
+ isSettingsPath = (path90) => SETTINGS.includes(path90) || /^rules\/(?:workflows\/)?[^/]+\.md$/.test(path90);
8266
8266
  BOARD_FILE_LIMIT = 256 * 1024;
8267
8267
  cardSlug = (task) => task.toLowerCase().replace(/_/g, "-");
8268
8268
  workflowFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
@@ -8795,7 +8795,7 @@ function checkWorkflowFiles(value, official = false) {
8795
8795
  }
8796
8796
  return { ok: true, def, files: value };
8797
8797
  }
8798
- var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, landsOf, SEGMENT, isAboutFile, bytes;
8798
+ var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes;
8799
8799
  var init_workflow_files = __esm({
8800
8800
  "src/lib/shared/workflow-files.ts"() {
8801
8801
  "use strict";
@@ -8805,7 +8805,9 @@ var init_workflow_files = __esm({
8805
8805
  WORKFLOW_FILE = "WORKFLOW.md";
8806
8806
  MCP_FILE = "mcp.json";
8807
8807
  KB = 1024;
8808
- FILE_LIMITS = { file: 256 * KB, total: 2 * KB * KB, count: 500, path: 512 };
8808
+ FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
8809
+ officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
8810
+ hashInput = (files2) => JSON.stringify(Object.entries(files2).sort(([a2], [b2]) => a2 < b2 ? -1 : 1));
8809
8811
  landsOf = (def) => ({ lands: def.land.some((h3) => !h3.off) });
8810
8812
  SEGMENT = /^[\w.-]+$/;
8811
8813
  isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
@@ -8813,34 +8815,50 @@ var init_workflow_files = __esm({
8813
8815
  }
8814
8816
  });
8815
8817
 
8816
- // ../official/pack.ts
8817
- import crypto from "node:crypto";
8818
+ // src/lib/agent/workflow-folder.ts
8818
8819
  import fs23 from "node:fs";
8819
8820
  import path27 from "node:path";
8820
- import { fileURLToPath as fileURLToPath2 } from "node:url";
8821
8821
  function filesOf(dir, base = dir) {
8822
- return fs23.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
8822
+ return fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".")).flatMap((e2) => {
8823
8823
  const full = path27.join(dir, e2.name);
8824
8824
  return e2.isDirectory() ? filesOf(full, base) : [path27.relative(base, full).split(path27.sep).join("/")];
8825
8825
  });
8826
8826
  }
8827
+ function readWorkflowFile(dir, file) {
8828
+ const full = path27.join(dir, file);
8829
+ return isAboutFile(file) && !file.endsWith(".md") ? `data:${MIME[path27.extname(file)]};base64,${fs23.readFileSync(full).toString("base64")}` : fs23.readFileSync(full, "utf8");
8830
+ }
8831
+ var MIME, readWorkflowFolder;
8832
+ var init_workflow_folder = __esm({
8833
+ "src/lib/agent/workflow-folder.ts"() {
8834
+ "use strict";
8835
+ init_workflow_files();
8836
+ MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
8837
+ readWorkflowFolder = (dir) => Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, readWorkflowFile(dir, f2)]));
8838
+ }
8839
+ });
8840
+
8841
+ // ../official/pack.ts
8842
+ import crypto from "node:crypto";
8843
+ import fs24 from "node:fs";
8844
+ import path28 from "node:path";
8845
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
8827
8846
  function packOfficial(root2 = OFFICIAL, loose = false) {
8828
- const agentsDir = path27.join(root2, "agents");
8847
+ const agentsDir = path28.join(root2, "agents");
8829
8848
  const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
8830
- const dir = path27.join(agentsDir, name);
8831
- return [name, Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, fs23.readFileSync(path27.join(dir, f2), "utf8")]))];
8849
+ const dir = path28.join(agentsDir, name);
8850
+ return [name, readWorkflowFolder(dir)];
8832
8851
  }));
8833
8852
  for (const [name, own] of Object.entries(loose ? {} : agentFiles)) {
8834
8853
  const read5 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
8835
8854
  if ("problem" in read5) throw new Error(read5.problem);
8836
8855
  }
8837
- const workflowsDir = path27.join(root2, "workflows");
8856
+ const workflowsDir = path28.join(root2, "workflows");
8838
8857
  return dirs(workflowsDir).map((folder) => {
8839
- const dir = path27.join(workflowsDir, folder);
8858
+ const dir = path28.join(workflowsDir, folder);
8840
8859
  const files2 = {};
8841
8860
  for (const f2 of filesOf(dir).sort()) {
8842
- 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");
8843
- else if (isAboutFile(f2)) files2[f2] = `data:${MIME[path27.extname(f2)]};base64,${fs23.readFileSync(path27.join(dir, f2)).toString("base64")}`;
8861
+ if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || isAboutFile(f2)) files2[f2] = readWorkflowFile(dir, f2);
8844
8862
  }
8845
8863
  const read5 = checkWorkflowFiles({ [WORKFLOW_FILE]: files2[WORKFLOW_FILE], ...Object.fromEntries(
8846
8864
  Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f2, t]) => [`agents/${name}/${f2}`, t]))
@@ -8867,24 +8885,23 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
8867
8885
  };
8868
8886
  });
8869
8887
  }
8870
- var OFFICIAL, MIME, dirs, officialId, hashOf;
8888
+ var OFFICIAL, dirs, hashOf;
8871
8889
  var init_pack = __esm({
8872
8890
  "../official/pack.ts"() {
8873
8891
  init_parse();
8874
8892
  init_workflow_def();
8893
+ init_workflow_folder();
8875
8894
  init_workflow_files();
8876
- OFFICIAL = path27.dirname(fileURLToPath2(import.meta.url));
8877
- MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
8878
- dirs = (dir) => fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
8879
- officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
8880
- hashOf = (files2) => crypto.createHash("sha256").update(JSON.stringify(Object.entries(files2).sort(([a2], [b2]) => a2 < b2 ? -1 : 1))).digest("hex");
8895
+ OFFICIAL = path28.dirname(fileURLToPath2(import.meta.url));
8896
+ dirs = (dir) => fs24.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
8897
+ hashOf = (files2) => crypto.createHash("sha256").update(hashInput(files2)).digest("hex");
8881
8898
  }
8882
8899
  });
8883
8900
 
8884
8901
  // src/lib/cloud/tasks.ts
8885
8902
  import crypto2 from "node:crypto";
8886
- import fs24 from "node:fs";
8887
- import path28 from "node:path";
8903
+ import fs25 from "node:fs";
8904
+ import path29 from "node:path";
8888
8905
  function workspaceTask() {
8889
8906
  const id = process.env[TASK_ENV];
8890
8907
  return id && id.trim() ? id.trim() : null;
@@ -8942,15 +8959,15 @@ ${said3.slug?.trim() || said3.title}`).digest("hex").slice(0, 40)}`;
8942
8959
  return { ok: true, value: { task: made.value, number, from: source.value, replayed: made.replayed === true } };
8943
8960
  }
8944
8961
  function runnerProject(board2) {
8945
- if (path28.basename(board2) !== "kanban" || path28.basename(path28.dirname(board2)) !== ".akb") return null;
8946
- const linked = linkedProject(board2, path28.dirname(path28.dirname(board2)));
8962
+ if (path29.basename(board2) !== "kanban" || path29.basename(path29.dirname(board2)) !== ".akb") return null;
8963
+ const linked = linkedProject(board2, path29.dirname(path29.dirname(board2)));
8947
8964
  return linked.ok ? linked.value : null;
8948
8965
  }
8949
8966
  function linkedProject(board2, root2) {
8950
- const file = path28.join(root2, ".akb", "base.json");
8951
- if (!fs24.existsSync(file)) return { ok: true, value: null };
8967
+ const file = path29.join(root2, ".akb", "base.json");
8968
+ if (!fs25.existsSync(file)) return { ok: true, value: null };
8952
8969
  try {
8953
- const base = JSON.parse(fs24.readFileSync(file, "utf8"));
8970
+ const base = JSON.parse(fs25.readFileSync(file, "utf8"));
8954
8971
  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();
8955
8972
  const projects = new Set(Object.keys(base.files ?? {}).flatMap((p2) => /^projects\/([^/]+)\//.exec(p2)?.[1] ?? []));
8956
8973
  if (typeof base.project === "string") projects.add(base.project);
@@ -9017,37 +9034,37 @@ var init_tasks = __esm({
9017
9034
  });
9018
9035
 
9019
9036
  // src/lib/agent/cloud-workflows.ts
9020
- import fs25 from "node:fs";
9021
- import path29 from "node:path";
9037
+ import fs26 from "node:fs";
9038
+ import path30 from "node:path";
9022
9039
  function readJson(file) {
9023
9040
  try {
9024
- return JSON.parse(fs25.readFileSync(file, "utf8"));
9041
+ return JSON.parse(fs26.readFileSync(file, "utf8"));
9025
9042
  } catch {
9026
9043
  return null;
9027
9044
  }
9028
9045
  }
9029
9046
  function writeJson(file, value) {
9030
- fs25.mkdirSync(path29.dirname(file), { recursive: true });
9047
+ fs26.mkdirSync(path30.dirname(file), { recursive: true });
9031
9048
  const tmp = `${file}.${process.pid}.tmp`;
9032
- fs25.writeFileSync(tmp, `${JSON.stringify(value)}
9049
+ fs26.writeFileSync(tmp, `${JSON.stringify(value)}
9033
9050
  `);
9034
- fs25.renameSync(tmp, file);
9051
+ fs26.renameSync(tmp, file);
9035
9052
  }
9036
9053
  function heldWorkflowName(name) {
9037
9054
  let files2;
9038
9055
  try {
9039
- files2 = fs25.readdirSync(path29.join(root(), "versions"));
9056
+ files2 = fs26.readdirSync(path30.join(root(), "versions"));
9040
9057
  } catch {
9041
9058
  return "";
9042
9059
  }
9043
9060
  const held4 = files2.filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, f2.lastIndexOf("@"))).find((id) => workflowName(id) === name);
9044
9061
  if (!held4) return "";
9045
9062
  const file = files2.filter((f2) => f2.startsWith(`${held4}@`)).sort().pop();
9046
- return readJson(path29.join(root(), "versions", file))?.name ?? "";
9063
+ return readJson(path30.join(root(), "versions", file))?.name ?? "";
9047
9064
  }
9048
9065
  function saveVersion(held4) {
9049
9066
  const file = versionFile(held4.id, held4.version);
9050
- if (!fs25.existsSync(file)) writeJson(file, { id: held4.id, version: held4.version, name: held4.name, names: held4.names, files: held4.files });
9067
+ if (!fs26.existsSync(file)) writeJson(file, { id: held4.id, version: held4.version, name: held4.name, names: held4.names, files: held4.files });
9051
9068
  }
9052
9069
  function savePin(task, held4) {
9053
9070
  saveVersion(held4);
@@ -9179,11 +9196,11 @@ var init_cloud_workflows = __esm({
9179
9196
  init_workflow_def();
9180
9197
  DEV = "AI4KANBAN_WORKFLOWS";
9181
9198
  FRESH_MS = 6e4;
9182
- root = () => path29.join(machineHome(), "workflows");
9199
+ root = () => path30.join(machineHome(), "workflows");
9183
9200
  safe = (name) => name.replace(/[^\w.@-]/g, "_");
9184
- versionFile = (id, version) => path29.join(root(), "versions", `${safe(id)}@${version}.json`);
9185
- listFile = (project) => path29.join(root(), "lists", `${safe(project)}.json`);
9186
- pinFile = (task) => path29.join(root(), "tasks", `${safe(task)}.json`);
9201
+ versionFile = (id, version) => path30.join(root(), "versions", `${safe(id)}@${version}.json`);
9202
+ listFile = (project) => path30.join(root(), "lists", `${safe(project)}.json`);
9203
+ pinFile = (task) => path30.join(root(), "tasks", `${safe(task)}.json`);
9187
9204
  readVersion = (id, version) => readJson(versionFile(id, version));
9188
9205
  readPin = (task) => readJson(pinFile(task));
9189
9206
  boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
@@ -9222,8 +9239,8 @@ var init_bundled2 = __esm({
9222
9239
  });
9223
9240
 
9224
9241
  // src/lib/agents/catalog.ts
9225
- import fs26 from "node:fs";
9226
- import path30 from "node:path";
9242
+ import fs27 from "node:fs";
9243
+ import path31 from "node:path";
9227
9244
  function readCatalog() {
9228
9245
  const agents = [];
9229
9246
  const problems = [];
@@ -9273,7 +9290,7 @@ function readCatalog() {
9273
9290
  }
9274
9291
  for (const folder of projectFolders(LEGACY_AGENTS)) {
9275
9292
  take(readProject(LEGACY_AGENTS, folder), folder);
9276
- problems.push(`${rel(path30.join(LEGACY_AGENTS, folder))}: move it to ${rel(path30.join(AGENTS, folder))}/`);
9293
+ problems.push(`${rel(path31.join(LEGACY_AGENTS, folder))}: move it to ${rel(path31.join(AGENTS, folder))}/`);
9277
9294
  }
9278
9295
  return { agents, problems, refused };
9279
9296
  }
@@ -9337,7 +9354,7 @@ function readBundled(folder) {
9337
9354
  function projectFolders(root2) {
9338
9355
  let entries;
9339
9356
  try {
9340
- entries = fs26.readdirSync(root2, { withFileTypes: true });
9357
+ entries = fs27.readdirSync(root2, { withFileTypes: true });
9341
9358
  } catch {
9342
9359
  return [];
9343
9360
  }
@@ -9345,10 +9362,10 @@ function projectFolders(root2) {
9345
9362
  }
9346
9363
  function agentFileReader(dir) {
9347
9364
  return (relative) => {
9348
- const target = path30.resolve(dir, relative);
9349
- if (target !== dir && !target.startsWith(dir + path30.sep)) return null;
9365
+ const target = path31.resolve(dir, relative);
9366
+ if (target !== dir && !target.startsWith(dir + path31.sep)) return null;
9350
9367
  try {
9351
- return fs26.readFileSync(target, "utf8");
9368
+ return fs27.readFileSync(target, "utf8");
9352
9369
  } catch {
9353
9370
  return null;
9354
9371
  }
@@ -9357,22 +9374,22 @@ function agentFileReader(dir) {
9357
9374
  function walkFolder(dir, prefix) {
9358
9375
  let entries;
9359
9376
  try {
9360
- entries = fs26.readdirSync(dir, { withFileTypes: true });
9377
+ entries = fs27.readdirSync(dir, { withFileTypes: true });
9361
9378
  } catch {
9362
9379
  return [];
9363
9380
  }
9364
9381
  return entries.flatMap((e2) => {
9365
9382
  const here = prefix ? `${prefix}/${e2.name}` : e2.name;
9366
- return e2.isDirectory() ? walkFolder(path30.join(dir, e2.name), here) : [here];
9383
+ return e2.isDirectory() ? walkFolder(path31.join(dir, e2.name), here) : [here];
9367
9384
  });
9368
9385
  }
9369
9386
  function readProject(root2, folder) {
9370
- const dir = path30.join(root2, folder);
9387
+ const dir = path31.join(root2, folder);
9371
9388
  const file = agentFileReader(dir);
9372
9389
  const found2 = AGENT_FILES.map((name) => ({ name, text: file(name) })).find((f2) => f2.text !== null);
9373
- const missing = rel(path30.join(dir, AGENT_FILE));
9390
+ const missing = rel(path31.join(dir, AGENT_FILE));
9374
9391
  if (!found2) return { problem: `${missing} is missing`, file: missing, missing: true };
9375
- const from = rel(path30.join(dir, found2.name));
9392
+ const from = rel(path31.join(dir, found2.name));
9376
9393
  const read5 = parseSpecAgent(found2.text, from, file, false, () => ownFiles(walkFolder(dir, "")));
9377
9394
  if ("problem" in read5) return { ...read5, file: from };
9378
9395
  if ("agent" in read5) Object.assign(read5.agent, { dir, text: found2.text });
@@ -9398,8 +9415,8 @@ var init_catalog = __esm({
9398
9415
  });
9399
9416
 
9400
9417
  // src/lib/agent/workflow-file.ts
9401
- import fs27 from "node:fs";
9402
- import path31 from "node:path";
9418
+ import fs28 from "node:fs";
9419
+ import path32 from "node:path";
9403
9420
  function agentLines2(agents, indent2) {
9404
9421
  return agents.flatMap(
9405
9422
  (h3) => !h3.extra && !h3.off ? [`${indent2}- ${scalar(h3.agent)}`] : [
@@ -9435,12 +9452,12 @@ function draftId() {
9435
9452
  const task = workspaceTask();
9436
9453
  if (!task) return null;
9437
9454
  const id = draftFolder(task);
9438
- return fs27.existsSync(fileOf(id)) ? id : null;
9455
+ return fs28.existsSync(fileOf(id)) ? id : null;
9439
9456
  }
9440
9457
  function readFolder(id, problems) {
9441
9458
  let source;
9442
9459
  try {
9443
- source = fs27.readFileSync(fileOf(id), "utf8");
9460
+ source = fs28.readFileSync(fileOf(id), "utf8");
9444
9461
  } catch {
9445
9462
  problems.push(`${rel(fileOf(id))} is missing`);
9446
9463
  return null;
@@ -9461,8 +9478,8 @@ function boardWorkflowDefs() {
9461
9478
  }
9462
9479
  function writeWorkflowDef(def) {
9463
9480
  const file = fileOf(def.id);
9464
- fs27.mkdirSync(path31.dirname(file), { recursive: true });
9465
- fs27.writeFileSync(file, workflowFileText(def));
9481
+ fs28.mkdirSync(path32.dirname(file), { recursive: true });
9482
+ fs28.writeFileSync(file, workflowFileText(def));
9466
9483
  forgetFileMemos();
9467
9484
  }
9468
9485
  var WORKFLOW_FILE2, scalar, plain, flowList, builtinDefs, fileOf;
@@ -9482,13 +9499,13 @@ var init_workflow_file = __esm({
9482
9499
  plain = (agents) => agents.every((h3) => !h3.extra && !h3.off);
9483
9500
  flowList = (agents) => `[${agents.map((h3) => scalar(h3.agent)).join(", ")}]`;
9484
9501
  builtinDefs = () => cloudFlows().filter((f2) => f2.builtIn).map((f2) => f2.def);
9485
- fileOf = (id) => path31.join(WORKFLOWS, id, WORKFLOW_FILE2);
9502
+ fileOf = (id) => path32.join(WORKFLOWS, id, WORKFLOW_FILE2);
9486
9503
  }
9487
9504
  });
9488
9505
 
9489
9506
  // src/lib/agent/workflows.ts
9490
- import fs28 from "node:fs";
9491
- import path32 from "node:path";
9507
+ import fs29 from "node:fs";
9508
+ import path33 from "node:path";
9492
9509
  function workflowPurpose(flow) {
9493
9510
  if (flow.builtIn) return builtinDescription(flow.id) || flow.name;
9494
9511
  return boardWorkflowDefs().defs.find((d2) => d2.id === flow.id)?.description || flow.name;
@@ -9562,7 +9579,7 @@ function previewStages(flow, chosen) {
9562
9579
  }
9563
9580
  function userWorkflowRules(flow) {
9564
9581
  try {
9565
- return fs28.readFileSync(workflowRuleFile(flow.id), "utf8").trim();
9582
+ return fs29.readFileSync(workflowRuleFile(flow.id), "utf8").trim();
9566
9583
  } catch {
9567
9584
  return "";
9568
9585
  }
@@ -9697,8 +9714,8 @@ function cardMeta(id) {
9697
9714
  try {
9698
9715
  const found2 = locate(id) ?? locateArchived(id);
9699
9716
  if (!found2) return null;
9700
- const file = found2.kind === "group" ? path32.join(found2.target, "root.md") : found2.target;
9701
- return parseFrontmatter(fs28.readFileSync(file, "utf8")).meta;
9717
+ const file = found2.kind === "group" ? path33.join(found2.target, "root.md") : found2.target;
9718
+ return parseFrontmatter(fs29.readFileSync(file, "utf8")).meta;
9702
9719
  } catch {
9703
9720
  return null;
9704
9721
  }
@@ -9788,7 +9805,7 @@ var init_workflows = __esm({
9788
9805
  previewAgents = (flow) => previewMembers(flow).filter((h3) => !h3.off);
9789
9806
  landAgents = (flow) => flow.land.filter((h3) => !h3.off);
9790
9807
  archivesOnApproval = (flow) => !!flow && !landAgents(flow).length;
9791
- workflowRuleFile = (id) => path32.join(RULES, "workflows", `${id}.md`);
9808
+ workflowRuleFile = (id) => path33.join(RULES, "workflows", `${id}.md`);
9792
9809
  save2 = (change2) => writeConfig((cfg) => {
9793
9810
  const block = configBlock(cfg.workflows);
9794
9811
  change2(block);
@@ -9811,11 +9828,11 @@ var init_workflows = __esm({
9811
9828
  });
9812
9829
 
9813
9830
  // src/commands/goal.ts
9814
- import fs29 from "node:fs";
9831
+ import fs30 from "node:fs";
9815
9832
  function loadGoals() {
9816
9833
  const file = goalsFile();
9817
9834
  if (!file) die("Goals exist only inside a WildCrane goal discussion.");
9818
- const held4 = JSON.parse(fs29.readFileSync(file, "utf8"));
9835
+ const held4 = JSON.parse(fs30.readFileSync(file, "utf8"));
9819
9836
  if (held4.goals !== void 0 && held4.ideas !== void 0 && JSON.stringify(held4.goals) !== JSON.stringify(held4.ideas)) die("goals and ideas do not match.");
9820
9837
  const goals = held4.goals ?? held4.ideas;
9821
9838
  if (!Array.isArray(goals)) die("The goals array is missing or invalid.");
@@ -9845,7 +9862,7 @@ function splitBody2(text5) {
9845
9862
  }
9846
9863
  function readBody(bodyFile) {
9847
9864
  if (!bodyFile) die("--body-file is required; write the goal in a writable temporary file first.");
9848
- const text5 = fs29.readFileSync(bodyFile, "utf8");
9865
+ const text5 = fs30.readFileSync(bodyFile, "utf8");
9849
9866
  if (!text5.trim()) die("The goal must not be empty.");
9850
9867
  return splitBody2(text5);
9851
9868
  }
@@ -9857,7 +9874,7 @@ function named(held4, id) {
9857
9874
  function cmdGoal(args, opts) {
9858
9875
  const sub = args[0] ?? "";
9859
9876
  const { file, held: held4 } = loadGoals();
9860
- const write2 = () => fs29.writeFileSync(file, `${JSON.stringify({ ...held4, goals: void 0, ideas: held4.goals }, null, 2)}
9877
+ const write2 = () => fs30.writeFileSync(file, `${JSON.stringify({ ...held4, goals: void 0, ideas: held4.goals }, null, 2)}
9861
9878
  `);
9862
9879
  if (sub === "new") {
9863
9880
  const title = opts.title?.trim();
@@ -9945,12 +9962,12 @@ var init_goal = __esm({
9945
9962
  });
9946
9963
 
9947
9964
  // src/commands/goal-cloud.ts
9948
- import fs30 from "node:fs";
9965
+ import fs31 from "node:fs";
9949
9966
  import os4 from "node:os";
9950
- import path33 from "node:path";
9967
+ import path34 from "node:path";
9951
9968
  import crypto3 from "node:crypto";
9952
9969
  async function request(method, route2, body) {
9953
- if (externalGoalSession()) process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path33.join(os4.homedir(), ".wildcrane");
9970
+ if (externalGoalSession()) process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
9954
9971
  const token3 = await accessToken();
9955
9972
  if (!token3.ok) die("Sign in through the WildCrane plugin, then try again.");
9956
9973
  const response = await fetch(`${cloudEndpoints().api}${route2}`, {
@@ -9982,23 +9999,23 @@ function goalsOf(d2) {
9982
9999
  async function discussion() {
9983
10000
  const session = process.env.CLAUDE_CODE_SESSION_ID || process.env.CODEX_THREAD_ID;
9984
10001
  if (!session) die("Goals exist only inside a WildCrane goal discussion.");
9985
- const home3 = process.env.WILDCRANE_HOME || path33.join(os4.homedir(), ".wildcrane");
10002
+ const home3 = process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
9986
10003
  process.env.AI4KANBAN_HOME ??= home3;
9987
- const machineFile2 = path33.join(home3, "machine.json");
10004
+ const machineFile2 = path34.join(home3, "machine.json");
9988
10005
  let machine;
9989
10006
  try {
9990
- machine = JSON.parse(fs30.readFileSync(machineFile2, "utf8")).id;
10007
+ machine = JSON.parse(fs31.readFileSync(machineFile2, "utf8")).id;
9991
10008
  } catch {
9992
10009
  machine = crypto3.randomUUID();
9993
- fs30.mkdirSync(home3, { recursive: true });
9994
- fs30.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
10010
+ fs31.mkdirSync(home3, { recursive: true });
10011
+ fs31.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
9995
10012
  }
9996
10013
  const held4 = await request("GET", `/v1/runner/folders?machine=${encodeURIComponent(machine)}`);
9997
- const cwd = fs30.realpathSync(process.cwd());
10014
+ const cwd = fs31.realpathSync(process.cwd());
9998
10015
  const folder = held4.folders.filter((f2) => {
9999
10016
  try {
10000
- const dir = fs30.realpathSync(f2.path);
10001
- return cwd === dir || cwd.startsWith(dir + path33.sep);
10017
+ const dir = fs31.realpathSync(f2.path);
10018
+ return cwd === dir || cwd.startsWith(dir + path34.sep);
10002
10019
  } catch {
10003
10020
  return false;
10004
10021
  }
@@ -10007,16 +10024,16 @@ async function discussion() {
10007
10024
  }
10008
10025
  async function withGoalDiscussion(action, save3 = false) {
10009
10026
  const d2 = await discussion();
10010
- const dir = fs30.mkdtempSync(path33.join(os4.tmpdir(), "akb-goals-"));
10011
- const file = path33.join(dir, "goals.json");
10027
+ const dir = fs31.mkdtempSync(path34.join(os4.tmpdir(), "akb-goals-"));
10028
+ const file = path34.join(dir, "goals.json");
10012
10029
  const before = process.env.KANBAN_GOALS;
10013
10030
  try {
10014
10031
  const previous = goalsOf(d2);
10015
- 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 })) }));
10032
+ 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 })) }));
10016
10033
  process.env.KANBAN_GOALS = file;
10017
10034
  const result = save3 ? await quietlyAsync(async () => action()) : await action();
10018
10035
  if (save3) {
10019
- const goals = JSON.parse(fs30.readFileSync(file, "utf8")).ideas;
10036
+ const goals = JSON.parse(fs31.readFileSync(file, "utf8")).ideas;
10020
10037
  const saved = await request("PUT", `/v1/discussions/${d2.id}/draft`, { expectedVersion: d2.version, goals: goals.filter((g3) => !g3.dropped) });
10021
10038
  const savedGoals = goalsOf(saved);
10022
10039
  const fresh = goals.filter((g3) => !g3.dropped && !previous.some((p2) => p2.id === g3.id));
@@ -10035,7 +10052,7 @@ async function withGoalDiscussion(action, save3 = false) {
10035
10052
  } finally {
10036
10053
  if (before === void 0) delete process.env.KANBAN_GOALS;
10037
10054
  else process.env.KANBAN_GOALS = before;
10038
- fs30.rmSync(dir, { recursive: true, force: true });
10055
+ fs31.rmSync(dir, { recursive: true, force: true });
10039
10056
  }
10040
10057
  }
10041
10058
  async function queryPreviews(workflow, workspace) {
@@ -11184,8 +11201,8 @@ var require_command = __commonJS({
11184
11201
  "node_modules/commander/lib/command.js"(exports) {
11185
11202
  var EventEmitter = __require("node:events").EventEmitter;
11186
11203
  var childProcess = __require("node:child_process");
11187
- var path89 = __require("node:path");
11188
- var fs91 = __require("node:fs");
11204
+ var path90 = __require("node:path");
11205
+ var fs92 = __require("node:fs");
11189
11206
  var process2 = __require("node:process");
11190
11207
  var { Argument: Argument2, humanReadableArgName } = require_argument();
11191
11208
  var { CommanderError: CommanderError2 } = require_error();
@@ -12166,7 +12183,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
12166
12183
  * @param {string} subcommandName
12167
12184
  */
12168
12185
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
12169
- if (fs91.existsSync(executableFile)) return;
12186
+ if (fs92.existsSync(executableFile)) return;
12170
12187
  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";
12171
12188
  const executableMissing = `'${executableFile}' does not exist
12172
12189
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -12184,11 +12201,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
12184
12201
  let launchWithNode = false;
12185
12202
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
12186
12203
  function findFile(baseDir, baseName) {
12187
- const localBin = path89.resolve(baseDir, baseName);
12188
- if (fs91.existsSync(localBin)) return localBin;
12189
- if (sourceExt.includes(path89.extname(baseName))) return void 0;
12204
+ const localBin = path90.resolve(baseDir, baseName);
12205
+ if (fs92.existsSync(localBin)) return localBin;
12206
+ if (sourceExt.includes(path90.extname(baseName))) return void 0;
12190
12207
  const foundExt = sourceExt.find(
12191
- (ext) => fs91.existsSync(`${localBin}${ext}`)
12208
+ (ext) => fs92.existsSync(`${localBin}${ext}`)
12192
12209
  );
12193
12210
  if (foundExt) return `${localBin}${foundExt}`;
12194
12211
  return void 0;
@@ -12200,21 +12217,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
12200
12217
  if (this._scriptPath) {
12201
12218
  let resolvedScriptPath;
12202
12219
  try {
12203
- resolvedScriptPath = fs91.realpathSync(this._scriptPath);
12220
+ resolvedScriptPath = fs92.realpathSync(this._scriptPath);
12204
12221
  } catch {
12205
12222
  resolvedScriptPath = this._scriptPath;
12206
12223
  }
12207
- executableDir = path89.resolve(
12208
- path89.dirname(resolvedScriptPath),
12224
+ executableDir = path90.resolve(
12225
+ path90.dirname(resolvedScriptPath),
12209
12226
  executableDir
12210
12227
  );
12211
12228
  }
12212
12229
  if (executableDir) {
12213
12230
  let localFile = findFile(executableDir, executableFile);
12214
12231
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
12215
- const legacyName = path89.basename(
12232
+ const legacyName = path90.basename(
12216
12233
  this._scriptPath,
12217
- path89.extname(this._scriptPath)
12234
+ path90.extname(this._scriptPath)
12218
12235
  );
12219
12236
  if (legacyName !== this._name) {
12220
12237
  localFile = findFile(
@@ -12225,7 +12242,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
12225
12242
  }
12226
12243
  executableFile = localFile || executableFile;
12227
12244
  }
12228
- launchWithNode = sourceExt.includes(path89.extname(executableFile));
12245
+ launchWithNode = sourceExt.includes(path90.extname(executableFile));
12229
12246
  let proc;
12230
12247
  if (process2.platform !== "win32") {
12231
12248
  if (launchWithNode) {
@@ -13072,7 +13089,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13072
13089
  * @return {Command}
13073
13090
  */
13074
13091
  nameFromFilename(filename) {
13075
- this._name = path89.basename(filename, path89.extname(filename));
13092
+ this._name = path90.basename(filename, path90.extname(filename));
13076
13093
  return this;
13077
13094
  }
13078
13095
  /**
@@ -13086,9 +13103,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
13086
13103
  * @param {string} [path]
13087
13104
  * @return {(string|null|Command)}
13088
13105
  */
13089
- executableDir(path90) {
13090
- if (path90 === void 0) return this._executableDir;
13091
- this._executableDir = path90;
13106
+ executableDir(path91) {
13107
+ if (path91 === void 0) return this._executableDir;
13108
+ this._executableDir = path91;
13092
13109
  return this;
13093
13110
  }
13094
13111
  /**
@@ -13385,11 +13402,11 @@ var init_esm = __esm({
13385
13402
  });
13386
13403
 
13387
13404
  // src/lib/cloud/pointer.ts
13388
- import fs31 from "node:fs";
13389
- import path34 from "node:path";
13405
+ import fs32 from "node:fs";
13406
+ import path35 from "node:path";
13390
13407
  function hasRetiredPointer(root2) {
13391
13408
  try {
13392
- const held4 = JSON.parse(fs31.readFileSync(path34.join(root2, POINTER_FILE), "utf8"));
13409
+ const held4 = JSON.parse(fs32.readFileSync(path35.join(root2, POINTER_FILE), "utf8"));
13393
13410
  return typeof held4.workspace === "string" && held4.workspace.trim() !== "";
13394
13411
  } catch {
13395
13412
  return false;
@@ -13404,15 +13421,15 @@ var init_pointer = __esm({
13404
13421
  });
13405
13422
 
13406
13423
  // src/lib/card-workflow-backfill.ts
13407
- import fs32 from "node:fs";
13408
- import path35 from "node:path";
13424
+ import fs33 from "node:fs";
13425
+ import path36 from "node:path";
13409
13426
  function backfillCardWorkflows() {
13410
13427
  if (!TODO || !BOARD_STATE) return;
13411
- const mark = path35.join(BOARD_STATE, MARK);
13428
+ const mark = path36.join(BOARD_STATE, MARK);
13412
13429
  try {
13413
- if (fs32.existsSync(mark) || !fs32.existsSync(TODO)) return;
13430
+ if (fs33.existsSync(mark) || !fs33.existsSync(TODO)) return;
13414
13431
  for (const file of walkMd(TODO)) {
13415
- const text5 = fs32.readFileSync(file, "utf8");
13432
+ const text5 = fs33.readFileSync(file, "utf8");
13416
13433
  if (!text5.startsWith("---\n")) continue;
13417
13434
  const end2 = text5.indexOf("\n---", 3);
13418
13435
  if (end2 < 0) continue;
@@ -13420,11 +13437,11 @@ function backfillCardWorkflows() {
13420
13437
  if (!/\ntitle:/.test(head2) || /\nworkflow:/.test(head2)) continue;
13421
13438
  const modules = /\nmodules:[^\n]*/.exec(head2);
13422
13439
  const at2 = modules ? modules.index + modules[0].length : end2;
13423
- fs32.writeFileSync(file, `${text5.slice(0, at2)}
13440
+ fs33.writeFileSync(file, `${text5.slice(0, at2)}
13424
13441
  workflow: coding${text5.slice(at2)}`);
13425
13442
  }
13426
- fs32.mkdirSync(BOARD_STATE, { recursive: true });
13427
- fs32.writeFileSync(mark, "");
13443
+ fs33.mkdirSync(BOARD_STATE, { recursive: true });
13444
+ fs33.writeFileSync(mark, "");
13428
13445
  } catch {
13429
13446
  }
13430
13447
  }
@@ -13439,11 +13456,11 @@ var init_card_workflow_backfill = __esm({
13439
13456
  });
13440
13457
 
13441
13458
  // src/lib/view/stamp.ts
13442
- import fs33 from "node:fs";
13443
- import path36 from "node:path";
13459
+ import fs34 from "node:fs";
13460
+ import path37 from "node:path";
13444
13461
  function boardStamp() {
13445
13462
  const parts = [];
13446
- for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS, path36.join(KANBAN, ".mockups")]) walk(dir, parts, 0);
13463
+ for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS, path37.join(KANBAN, ".mockups")]) walk(dir, parts, 0);
13447
13464
  for (const file of [MODULES_MD, ARCHIVE_MD, CONFIG]) {
13448
13465
  stamp2(file, parts);
13449
13466
  }
@@ -13453,19 +13470,19 @@ function walk(dir, parts, depth3) {
13453
13470
  if (depth3 > MAX_DEPTH) return;
13454
13471
  let entries;
13455
13472
  try {
13456
- entries = fs33.readdirSync(dir, { withFileTypes: true });
13473
+ entries = fs34.readdirSync(dir, { withFileTypes: true });
13457
13474
  } catch {
13458
13475
  return;
13459
13476
  }
13460
13477
  for (const entry of entries.sort((a2, b2) => a2.name.localeCompare(b2.name))) {
13461
- const full = path36.join(dir, entry.name);
13478
+ const full = path37.join(dir, entry.name);
13462
13479
  if (entry.isDirectory()) walk(full, parts, depth3 + 1);
13463
13480
  else stamp2(full, parts);
13464
13481
  }
13465
13482
  }
13466
13483
  function stamp2(file, parts) {
13467
13484
  try {
13468
- const s = fs33.statSync(file);
13485
+ const s = fs34.statSync(file);
13469
13486
  parts.push(`${file}:${s.size}:${Math.round(s.mtimeMs)}`);
13470
13487
  } catch {
13471
13488
  }
@@ -13497,8 +13514,8 @@ var init_contract = __esm({
13497
13514
  });
13498
13515
 
13499
13516
  // src/lib/board/revision.ts
13500
- import fs34 from "node:fs";
13501
- import path37 from "node:path";
13517
+ import fs35 from "node:fs";
13518
+ import path38 from "node:path";
13502
13519
  function revisionOf(text5) {
13503
13520
  let h3 = 2166136261;
13504
13521
  for (let i = 0; i < text5.length; i++) {
@@ -13510,13 +13527,13 @@ function revisionOf(text5) {
13510
13527
  function cardFile(id) {
13511
13528
  const found2 = locate(id);
13512
13529
  if (!found2) return null;
13513
- return found2.kind === "group" ? path37.join(found2.target, "root.md") : found2.target;
13530
+ return found2.kind === "group" ? path38.join(found2.target, "root.md") : found2.target;
13514
13531
  }
13515
13532
  function cardRevision(id) {
13516
13533
  const file = cardFile(id);
13517
13534
  if (!file) return NO_REVISION;
13518
13535
  try {
13519
- return revisionOf(fs34.readFileSync(file, "utf8"));
13536
+ return revisionOf(fs35.readFileSync(file, "utf8"));
13520
13537
  } catch {
13521
13538
  return NO_REVISION;
13522
13539
  }
@@ -13538,14 +13555,14 @@ var init_revision = __esm({
13538
13555
  });
13539
13556
 
13540
13557
  // src/lib/plans.ts
13541
- import fs35 from "node:fs";
13542
- import path38 from "node:path";
13558
+ import fs36 from "node:fs";
13559
+ import path39 from "node:path";
13543
13560
  function planFile(rel2) {
13544
13561
  if (!/^plans\/(archive\/)?[^/\\]+\.md$/.test(rel2)) return null;
13545
13562
  const dir = isArchivedPlan(rel2) ? PLANS_ARCHIVE : PLANS;
13546
13563
  const name = rel2.replace(/^plans\/(archive\/)?/, "");
13547
13564
  if (!name || name.includes("/") || !name.endsWith(".md")) return null;
13548
- return path38.join(dir, name);
13565
+ return path39.join(dir, name);
13549
13566
  }
13550
13567
  function readPlan(rel2) {
13551
13568
  const file = planFile(rel2);
@@ -13553,12 +13570,12 @@ function readPlan(rel2) {
13553
13570
  let text5 = "";
13554
13571
  let found2 = rel2;
13555
13572
  try {
13556
- text5 = fs35.readFileSync(file, "utf8");
13573
+ text5 = fs36.readFileSync(file, "utf8");
13557
13574
  } catch {
13558
13575
  const moved = renamedPlan(rel2);
13559
13576
  if (moved) {
13560
13577
  found2 = moved;
13561
- text5 = fs35.readFileSync(planFile(moved), "utf8");
13578
+ text5 = fs36.readFileSync(planFile(moved), "utf8");
13562
13579
  }
13563
13580
  }
13564
13581
  return { path: found2, text: text5, lines: text5.trim() ? text5.trimEnd().split("\n").length : 0 };
@@ -13573,13 +13590,13 @@ function renamedPlan(rel2) {
13573
13590
  ]) {
13574
13591
  let names3;
13575
13592
  try {
13576
- names3 = fs35.readdirSync(dir);
13593
+ names3 = fs36.readdirSync(dir);
13577
13594
  } catch {
13578
13595
  continue;
13579
13596
  }
13580
13597
  for (const n of names3) {
13581
13598
  if (!n.startsWith(`${id}-`) || !n.endsWith(".md")) continue;
13582
- found2.push({ rel: `${prefix}${n}`, at: fs35.statSync(path38.join(dir, n)).mtimeMs });
13599
+ found2.push({ rel: `${prefix}${n}`, at: fs36.statSync(path39.join(dir, n)).mtimeMs });
13583
13600
  }
13584
13601
  }
13585
13602
  if (!found2.length) return null;
@@ -13588,7 +13605,7 @@ function renamedPlan(rel2) {
13588
13605
  function planFromText(text5) {
13589
13606
  const legacy2 = `${legacyProjectStateDir(KANBAN)}/`;
13590
13607
  if (text5.startsWith(legacy2)) text5 = text5.slice(legacy2.length);
13591
- const local = `${path38.dirname(PLANS)}/`;
13608
+ const local = `${path39.dirname(PLANS)}/`;
13592
13609
  if (text5.startsWith(local)) text5 = text5.slice(local.length);
13593
13610
  if (text5.startsWith(`${KANBAN}/`)) text5 = text5.slice(KANBAN.length + 1);
13594
13611
  const here = `${boardPath()}/`;
@@ -13716,23 +13733,23 @@ var init_telemetry_contract = __esm({
13716
13733
  });
13717
13734
 
13718
13735
  // src/lib/agent/catalog.ts
13719
- import fs36 from "node:fs";
13720
- import path39 from "node:path";
13736
+ import fs37 from "node:fs";
13737
+ import path40 from "node:path";
13721
13738
  function cacheFile() {
13722
- return path39.join(machineHome(), "models-dev.json");
13739
+ return path40.join(machineHome(), "models-dev.json");
13723
13740
  }
13724
13741
  function readCache() {
13725
13742
  const file = cacheFile();
13726
13743
  let stamp4;
13727
13744
  try {
13728
- const stat = fs36.statSync(file);
13745
+ const stat = fs37.statSync(file);
13729
13746
  stamp4 = `${stat.mtimeMs}:${stat.size}`;
13730
13747
  } catch {
13731
13748
  return void 0;
13732
13749
  }
13733
13750
  if (held2?.stamp === stamp4) return held2.cached;
13734
13751
  try {
13735
- const data = JSON.parse(fs36.readFileSync(file, "utf8"));
13752
+ const data = JSON.parse(fs37.readFileSync(file, "utf8"));
13736
13753
  if (!data || typeof data.limits !== "object" || !data.limits) return void 0;
13737
13754
  const cached2 = {
13738
13755
  fetchedAt: typeof data.fetchedAt === "number" ? data.fetchedAt : 0,
@@ -13770,8 +13787,8 @@ function refreshCatalog() {
13770
13787
  const limits = limitsIn(await answer2.json());
13771
13788
  if (Object.keys(limits).length === 0) return;
13772
13789
  const file = cacheFile();
13773
- fs36.mkdirSync(path39.dirname(file), { recursive: true });
13774
- fs36.writeFileSync(file, JSON.stringify({ fetchedAt: Date.now(), limits }));
13790
+ fs37.mkdirSync(path40.dirname(file), { recursive: true });
13791
+ fs37.writeFileSync(file, JSON.stringify({ fetchedAt: Date.now(), limits }));
13775
13792
  } catch {
13776
13793
  }
13777
13794
  })();
@@ -13834,8 +13851,8 @@ var init_catalog2 = __esm({
13834
13851
  });
13835
13852
 
13836
13853
  // src/lib/machine/telemetry.ts
13837
- import fs37 from "node:fs";
13838
- import path40 from "node:path";
13854
+ import fs38 from "node:fs";
13855
+ import path41 from "node:path";
13839
13856
  import { randomUUID as randomUUID2 } from "node:crypto";
13840
13857
  function readUsageReporting() {
13841
13858
  const { unreadable, values } = heldSettings();
@@ -13869,8 +13886,8 @@ function write(on2, disclosed) {
13869
13886
  if (!on2) patch2.usageInstallId = void 0;
13870
13887
  const saved = saveSettings(patch2);
13871
13888
  if (saved.ok && !on2) {
13872
- fs37.rmSync(usageQueueFile(), { force: true });
13873
- fs37.rmSync(usageStateFile(), { force: true });
13889
+ fs38.rmSync(usageQueueFile(), { force: true });
13890
+ fs38.rmSync(usageStateFile(), { force: true });
13874
13891
  }
13875
13892
  return saved;
13876
13893
  }
@@ -13880,14 +13897,14 @@ var init_telemetry = __esm({
13880
13897
  "use strict";
13881
13898
  init_home();
13882
13899
  init_settings2();
13883
- usageQueueFile = () => path40.join(machineHome(), "usage-queue.jsonl");
13884
- usageStateFile = () => path40.join(machineHome(), "usage-state.json");
13900
+ usageQueueFile = () => path41.join(machineHome(), "usage-queue.jsonl");
13901
+ usageStateFile = () => path41.join(machineHome(), "usage-state.json");
13885
13902
  }
13886
13903
  });
13887
13904
 
13888
13905
  // src/lib/machine/usage.ts
13889
- import fs38 from "node:fs";
13890
- import path41 from "node:path";
13906
+ import fs39 from "node:fs";
13907
+ import path42 from "node:path";
13891
13908
  import { randomUUID as randomUUID3 } from "node:crypto";
13892
13909
  function usageSurface() {
13893
13910
  return process.env.KANBAN_DESKTOP === "1" ? "app" : "command";
@@ -13964,15 +13981,15 @@ function endFields({ model, costUsd, ownEndpoint }) {
13964
13981
  }
13965
13982
  function readBoard() {
13966
13983
  try {
13967
- const held4 = JSON.parse(fs38.readFileSync(boardFile(), "utf8"));
13984
+ const held4 = JSON.parse(fs39.readFileSync(boardFile(), "utf8"));
13968
13985
  return held4 && typeof held4 === "object" ? held4 : {};
13969
13986
  } catch {
13970
13987
  return {};
13971
13988
  }
13972
13989
  }
13973
13990
  function writeBoard(state) {
13974
- fs38.mkdirSync(BOARD_STATE, { recursive: true });
13975
- fs38.writeFileSync(boardFile(), `${JSON.stringify(state)}
13991
+ fs39.mkdirSync(BOARD_STATE, { recursive: true });
13992
+ fs39.writeFileSync(boardFile(), `${JSON.stringify(state)}
13976
13993
  `);
13977
13994
  }
13978
13995
  function countBoardEvent(name, n = 1) {
@@ -14016,7 +14033,7 @@ function reportBoardNumbers(customAgentsOn2) {
14016
14033
  function readQueue(day = usageDay()) {
14017
14034
  let text5;
14018
14035
  try {
14019
- text5 = fs38.readFileSync(usageQueueFile(), "utf8");
14036
+ text5 = fs39.readFileSync(usageQueueFile(), "utf8");
14020
14037
  } catch {
14021
14038
  return [];
14022
14039
  }
@@ -14038,8 +14055,8 @@ function readQueue(day = usageDay()) {
14038
14055
  }
14039
14056
  function append(event2) {
14040
14057
  const file = usageQueueFile();
14041
- fs38.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14042
- fs38.appendFileSync(file, `${JSON.stringify(event2)}
14058
+ fs39.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14059
+ fs39.appendFileSync(file, `${JSON.stringify(event2)}
14043
14060
  `);
14044
14061
  const queued = readQueue();
14045
14062
  if (queued.length > QUEUE_MAX) writeQueue(queued.slice(queued.length - QUEUE_MAX));
@@ -14047,14 +14064,14 @@ function append(event2) {
14047
14064
  function writeQueue(events) {
14048
14065
  const file = usageQueueFile();
14049
14066
  if (!events.length) {
14050
- fs38.rmSync(file, { force: true });
14067
+ fs39.rmSync(file, { force: true });
14051
14068
  return;
14052
14069
  }
14053
- fs38.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14070
+ fs39.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14054
14071
  const tmp = `${file}.${process.pid}.tmp`;
14055
- fs38.writeFileSync(tmp, `${events.map((e2) => JSON.stringify(e2)).join("\n")}
14072
+ fs39.writeFileSync(tmp, `${events.map((e2) => JSON.stringify(e2)).join("\n")}
14056
14073
  `);
14057
- fs38.renameSync(tmp, file);
14074
+ fs39.renameSync(tmp, file);
14058
14075
  }
14059
14076
  function shiftDay(day, days) {
14060
14077
  const at2 = Date.parse(`${day}T00:00:00Z`);
@@ -14062,7 +14079,7 @@ function shiftDay(day, days) {
14062
14079
  }
14063
14080
  function readState() {
14064
14081
  try {
14065
- const parsed = JSON.parse(fs38.readFileSync(usageStateFile(), "utf8"));
14082
+ const parsed = JSON.parse(fs39.readFileSync(usageStateFile(), "utf8"));
14066
14083
  return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
14067
14084
  } catch {
14068
14085
  return {};
@@ -14070,12 +14087,12 @@ function readState() {
14070
14087
  }
14071
14088
  function writeState(state) {
14072
14089
  try {
14073
- fs38.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14090
+ fs39.mkdirSync(machineHome(), { recursive: true, mode: 448 });
14074
14091
  const file = usageStateFile();
14075
14092
  const tmp = `${file}.${process.pid}.tmp`;
14076
- fs38.writeFileSync(tmp, `${JSON.stringify(state, null, 2)}
14093
+ fs39.writeFileSync(tmp, `${JSON.stringify(state, null, 2)}
14077
14094
  `);
14078
- fs38.renameSync(tmp, file);
14095
+ fs39.renameSync(tmp, file);
14079
14096
  } catch {
14080
14097
  return;
14081
14098
  }
@@ -14166,7 +14183,7 @@ var init_usage = __esm({
14166
14183
  "decisions_stood",
14167
14184
  "decisions_overruled"
14168
14185
  ];
14169
- boardFile = () => path41.join(BOARD_STATE, "usage-board.json");
14186
+ boardFile = () => path42.join(BOARD_STATE, "usage-board.json");
14170
14187
  countOf = (counts, name) => {
14171
14188
  const n = counts?.[name];
14172
14189
  return typeof n === "number" && Number.isInteger(n) && n > 0 ? n : 0;
@@ -14213,14 +14230,14 @@ var init_candidate = __esm({
14213
14230
  });
14214
14231
 
14215
14232
  // src/lib/agent/outputs.ts
14216
- import fs39 from "node:fs";
14233
+ import fs40 from "node:fs";
14217
14234
  import os5 from "node:os";
14218
- import path42 from "node:path";
14235
+ import path43 from "node:path";
14219
14236
  function cardBody(cardId2) {
14220
14237
  const found2 = locate(cardId2) ?? locateArchived(cardId2);
14221
14238
  if (!found2) return "";
14222
14239
  try {
14223
- return fs39.readFileSync(found2.kind === "group" ? path42.join(found2.target, "root.md") : found2.target, "utf8");
14240
+ return fs40.readFileSync(found2.kind === "group" ? path43.join(found2.target, "root.md") : found2.target, "utf8");
14224
14241
  } catch {
14225
14242
  return "";
14226
14243
  }
@@ -14243,7 +14260,7 @@ function filesStop(delivery) {
14243
14260
  if (!outputs.length) {
14244
14261
  return { reason: "output", why: "the card records no output file", paths: [] };
14245
14262
  }
14246
- const missing = outputs.filter((f2) => !fs39.existsSync(resolveOutput(f2)));
14263
+ const missing = outputs.filter((f2) => !fs40.existsSync(resolveOutput(f2)));
14247
14264
  if (missing.length) {
14248
14265
  return { reason: "output", why: `recorded output files are missing: ${missing.join(", ")}`, paths: missing };
14249
14266
  }
@@ -14263,20 +14280,20 @@ var init_outputs = __esm({
14263
14280
  plannedTodos = (cardId2) => todos(cardId2).map((t) => t.text);
14264
14281
  looksLikePath = (token3) => !/\s/.test(token3) && !token3.includes("://") && !token3.startsWith("-") && token3.includes("/");
14265
14282
  resolveOutput = (file) => {
14266
- if (file.startsWith("~/")) return path42.join(os5.homedir(), file.slice(2));
14267
- if (path42.isAbsolute(file)) return file;
14268
- if (file.startsWith(".assets/")) return path42.join(ASSETS, file.slice(".assets/".length));
14269
- return path42.join(REPO_ROOT, file);
14283
+ if (file.startsWith("~/")) return path43.join(os5.homedir(), file.slice(2));
14284
+ if (path43.isAbsolute(file)) return file;
14285
+ if (file.startsWith(".assets/")) return path43.join(ASSETS, file.slice(".assets/".length));
14286
+ return path43.join(REPO_ROOT, file);
14270
14287
  };
14271
14288
  }
14272
14289
  });
14273
14290
 
14274
14291
  // src/lib/agent/commit-mode.ts
14275
- import fs40 from "node:fs";
14292
+ import fs41 from "node:fs";
14276
14293
  function recordedIds() {
14277
14294
  try {
14278
14295
  return new Set(
14279
- fs40.readdirSync(DELIVERIES).filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, -".json".length))
14296
+ fs41.readdirSync(DELIVERIES).filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, -".json".length))
14280
14297
  );
14281
14298
  } catch {
14282
14299
  return /* @__PURE__ */ new Set();
@@ -14309,7 +14326,7 @@ var init_commit_mode = __esm({
14309
14326
  init_worktree();
14310
14327
  ID_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
14311
14328
  ID_LENGTH2 = 8;
14312
- deliveryCwd = (delivery) => delivery.worktree && fs40.existsSync(worktreeDir(delivery.worktree)) ? worktreeDir(delivery.worktree) : REPO_ROOT;
14329
+ deliveryCwd = (delivery) => delivery.worktree && fs41.existsSync(worktreeDir(delivery.worktree)) ? worktreeDir(delivery.worktree) : REPO_ROOT;
14313
14330
  }
14314
14331
  });
14315
14332
 
@@ -14505,12 +14522,12 @@ var init_runner = __esm({
14505
14522
  });
14506
14523
 
14507
14524
  // src/lib/agent/rules.ts
14508
- import fs41 from "node:fs";
14509
- import path43 from "node:path";
14525
+ import fs42 from "node:fs";
14526
+ import path44 from "node:path";
14510
14527
  function ruleFile(agent) {
14511
14528
  if (!agent || hiddenRole(agent)) return "";
14512
14529
  try {
14513
- return fs41.readFileSync(rulePath(agent), "utf8").trim();
14530
+ return fs42.readFileSync(rulePath(agent), "utf8").trim();
14514
14531
  } catch {
14515
14532
  return "";
14516
14533
  }
@@ -14525,11 +14542,11 @@ function setAgentRule(agent, text5) {
14525
14542
  const rule = String(text5 ?? "").trim();
14526
14543
  try {
14527
14544
  if (!rule) {
14528
- fs41.rmSync(rulePath(agent), { force: true });
14545
+ fs42.rmSync(rulePath(agent), { force: true });
14529
14546
  return { ok: true };
14530
14547
  }
14531
- fs41.mkdirSync(RULES, { recursive: true });
14532
- fs41.writeFileSync(rulePath(agent), `${rule}
14548
+ fs42.mkdirSync(RULES, { recursive: true });
14549
+ fs42.writeFileSync(rulePath(agent), `${rule}
14533
14550
  `);
14534
14551
  return { ok: true };
14535
14552
  } catch (err) {
@@ -14586,7 +14603,7 @@ function migrateFlowRules() {
14586
14603
  adoptRenamedRules();
14587
14604
  let here;
14588
14605
  try {
14589
- here = new Set(fs41.readdirSync(RULES));
14606
+ here = new Set(fs42.readdirSync(RULES));
14590
14607
  } catch {
14591
14608
  return [];
14592
14609
  }
@@ -14600,9 +14617,9 @@ function migrateFlowRules() {
14600
14617
  if (!from.length) continue;
14601
14618
  const parts = [ruleFile(owner.name), ...from.map(ruleFile)].filter(Boolean);
14602
14619
  try {
14603
- if (parts.length) fs41.writeFileSync(rulePath(owner.name), `${parts.join("\n\n")}
14620
+ if (parts.length) fs42.writeFileSync(rulePath(owner.name), `${parts.join("\n\n")}
14604
14621
  `);
14605
- for (const flow of from) fs41.rmSync(rulePath(flow), { force: true });
14622
+ for (const flow of from) fs42.rmSync(rulePath(flow), { force: true });
14606
14623
  } catch (err) {
14607
14624
  notes.push(`could not move the ${from.join(", ")} rule(s) onto \`${owner.name}\`: ${String(err)}`);
14608
14625
  continue;
@@ -14616,7 +14633,7 @@ function migrateFlowRules() {
14616
14633
  function adoptRenamedRules() {
14617
14634
  let here;
14618
14635
  try {
14619
- here = fs41.readdirSync(RULES);
14636
+ here = fs42.readdirSync(RULES);
14620
14637
  } catch {
14621
14638
  return;
14622
14639
  }
@@ -14626,13 +14643,13 @@ function adoptRenamedRules() {
14626
14643
  const now = RENAMED_ROLES[was] ?? canonicalSpecAgent(was);
14627
14644
  if (now === was) continue;
14628
14645
  try {
14629
- if (!fs41.existsSync(rulePath(now))) fs41.renameSync(rulePath(was), rulePath(now));
14646
+ if (!fs42.existsSync(rulePath(now))) fs42.renameSync(rulePath(was), rulePath(now));
14630
14647
  else if (FOLDED_SPEC_AGENTS.has(was)) {
14631
14648
  const kept2 = ruleFile(now);
14632
14649
  const carried = ruleFile(was);
14633
- if (carried && !kept2.includes(carried)) fs41.writeFileSync(rulePath(now), `${[kept2, carried].filter(Boolean).join("\n\n")}
14650
+ if (carried && !kept2.includes(carried)) fs42.writeFileSync(rulePath(now), `${[kept2, carried].filter(Boolean).join("\n\n")}
14634
14651
  `);
14635
- fs41.rmSync(rulePath(was), { force: true });
14652
+ fs42.rmSync(rulePath(was), { force: true });
14636
14653
  }
14637
14654
  } catch {
14638
14655
  }
@@ -14649,7 +14666,7 @@ var init_rules2 = __esm({
14649
14666
  init_runner();
14650
14667
  init_workflows();
14651
14668
  init_types();
14652
- rulePath = (agent) => path43.join(RULES, `${agent}.md`);
14669
+ rulePath = (agent) => path44.join(RULES, `${agent}.md`);
14653
14670
  notOnTheRoster = (name) => `"${name}" is not an agent on this board. It has: ${agentNames().join(", ")}.`;
14654
14671
  flowForRequest = (req) => req.refineRound !== void 0 && REFINE_ACTIONS.has(req.action) ? flowByCommand("refine") : flowByAction(req.action);
14655
14672
  ruleOwnerSays = (owner) => `\`${owner.name}\` agent carries one rule of its own${owner.role ? ", on every flow it runs" : ""}`;
@@ -14662,8 +14679,8 @@ var init_rules2 = __esm({
14662
14679
  });
14663
14680
 
14664
14681
  // src/lib/agent/deliveries.ts
14665
- import fs42 from "node:fs";
14666
- import path44 from "node:path";
14682
+ import fs43 from "node:fs";
14683
+ import path45 from "node:path";
14667
14684
  function writeAudit(delivery, runs) {
14668
14685
  const known2 = new Map(readAudit(delivery.deliveryId)?.sessions.map((s) => [s.sessionId, s]) ?? []);
14669
14686
  const sessions = delivery.sessions.flatMap((id) => {
@@ -14691,10 +14708,10 @@ function writeAudit(delivery, runs) {
14691
14708
  }
14692
14709
  function writeAuditFile(record) {
14693
14710
  try {
14694
- fs42.mkdirSync(DELIVERIES, { recursive: true });
14711
+ fs43.mkdirSync(DELIVERIES, { recursive: true });
14695
14712
  const tmp = `${auditPath(record.deliveryId)}.tmp`;
14696
- fs42.writeFileSync(tmp, JSON.stringify(record, null, 2) + "\n");
14697
- fs42.renameSync(tmp, auditPath(record.deliveryId));
14713
+ fs43.writeFileSync(tmp, JSON.stringify(record, null, 2) + "\n");
14714
+ fs43.renameSync(tmp, auditPath(record.deliveryId));
14698
14715
  return true;
14699
14716
  } catch {
14700
14717
  return false;
@@ -14702,7 +14719,7 @@ function writeAuditFile(record) {
14702
14719
  }
14703
14720
  function readAudit(deliveryId) {
14704
14721
  try {
14705
- const data = JSON.parse(fs42.readFileSync(auditPath(deliveryId), "utf8"));
14722
+ const data = JSON.parse(fs43.readFileSync(auditPath(deliveryId), "utf8"));
14706
14723
  return { sessions: Array.isArray(data?.sessions) ? data.sessions : [] };
14707
14724
  } catch {
14708
14725
  return null;
@@ -14717,7 +14734,7 @@ function syncAudit(deliveryId, just) {
14717
14734
  }
14718
14735
  function wholeAudit(file) {
14719
14736
  try {
14720
- const data = JSON.parse(fs42.readFileSync(file, "utf8"));
14737
+ const data = JSON.parse(fs43.readFileSync(file, "utf8"));
14721
14738
  return typeof data?.deliveryId === "string" && Array.isArray(data.sessions) ? data : null;
14722
14739
  } catch {
14723
14740
  return null;
@@ -14730,14 +14747,14 @@ function activeAudit(file) {
14730
14747
  function allAudits() {
14731
14748
  let names3;
14732
14749
  try {
14733
- names3 = fs42.readdirSync(DELIVERIES);
14750
+ names3 = fs43.readdirSync(DELIVERIES);
14734
14751
  } catch {
14735
14752
  return [];
14736
14753
  }
14737
14754
  const out = [];
14738
14755
  for (const name of names3) {
14739
14756
  if (!name.endsWith(".json")) continue;
14740
- const audit = wholeAudit(path44.join(DELIVERIES, name));
14757
+ const audit = wholeAudit(path45.join(DELIVERIES, name));
14741
14758
  if (audit) out.push(audit);
14742
14759
  }
14743
14760
  return out;
@@ -14910,10 +14927,10 @@ function carryOnFrom(_deliveryId) {
14910
14927
  function approvedRequirements(cardId2) {
14911
14928
  const found2 = locate(cardId2);
14912
14929
  if (!found2) return "";
14913
- const file = found2.kind === "group" ? path44.join(found2.target, "root.md") : found2.target;
14930
+ const file = found2.kind === "group" ? path45.join(found2.target, "root.md") : found2.target;
14914
14931
  let text5;
14915
14932
  try {
14916
- text5 = fs42.readFileSync(file, "utf8");
14933
+ text5 = fs43.readFileSync(file, "utf8");
14917
14934
  } catch {
14918
14935
  return "";
14919
14936
  }
@@ -14943,8 +14960,8 @@ function cardMeta2(cardId2) {
14943
14960
  try {
14944
14961
  const found2 = locate(cardId2);
14945
14962
  if (!found2) return null;
14946
- const file = found2.kind === "group" ? path44.join(found2.target, "root.md") : found2.target;
14947
- return parseFrontmatter(fs42.readFileSync(file, "utf8")).meta;
14963
+ const file = found2.kind === "group" ? path45.join(found2.target, "root.md") : found2.target;
14964
+ return parseFrontmatter(fs43.readFileSync(file, "utf8")).meta;
14948
14965
  } catch {
14949
14966
  return null;
14950
14967
  }
@@ -15116,11 +15133,11 @@ var init_deliveries = __esm({
15116
15133
  init_types();
15117
15134
  init_worktree();
15118
15135
  init_lock();
15119
- auditPath = (deliveryId) => path44.join(DELIVERIES, `${deliveryId}.json`);
15136
+ auditPath = (deliveryId) => path45.join(DELIVERIES, `${deliveryId}.json`);
15120
15137
  activeAudits = () => allAudits().filter((a2) => a2.status === "active");
15121
15138
  auditRow = (audit) => readDeliveryRow({ ...audit, sessions: audit.sessions.map((s) => s.sessionId) });
15122
15139
  lastSessionRunning = (audit) => audit.sessions[audit.sessions.length - 1]?.status === "running";
15123
- localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path44.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs42.existsSync(logPathOf(session.sessionId)));
15140
+ localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path45.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs43.existsSync(logPathOf(session.sessionId)));
15124
15141
  unknownDelivery = (id) => refusal("deliveryNotFound", `no delivery here answers to "${id}"`, { id });
15125
15142
  isResumable = (delivery) => !resumeRefusal(delivery);
15126
15143
  APPROVED = [
@@ -15144,35 +15161,35 @@ var init_deliveries = __esm({
15144
15161
  });
15145
15162
 
15146
15163
  // src/lib/agent/pictures.ts
15147
- import fs43 from "node:fs";
15148
- import path45 from "node:path";
15164
+ import fs44 from "node:fs";
15165
+ import path46 from "node:path";
15149
15166
  function claimRunPictures(box2, sessionId, names3 = []) {
15150
15167
  if (!box2 || !freeBox(box2) || names3.length === 0) return [];
15151
15168
  const from = pictureBox(box2);
15152
15169
  const to = pictureBox(sessionId);
15153
15170
  try {
15154
- fs43.mkdirSync(SESSIONS_DIR, { recursive: true });
15155
- fs43.renameSync(from, to);
15171
+ fs44.mkdirSync(SESSIONS_DIR, { recursive: true });
15172
+ fs44.renameSync(from, to);
15156
15173
  } catch {
15157
15174
  return [];
15158
15175
  }
15159
- return names3.filter(pictureName).map((name) => path45.join(to, name)).filter((file) => fs43.existsSync(file));
15176
+ return names3.filter(pictureName).map((name) => path46.join(to, name)).filter((file) => fs44.existsSync(file));
15160
15177
  }
15161
15178
  function returnRunPictures(sessionId, box2) {
15162
15179
  if (!box2 || !boxId(box2)) return;
15163
15180
  try {
15164
- fs43.renameSync(pictureBox(sessionId), pictureBox(box2));
15181
+ fs44.renameSync(pictureBox(sessionId), pictureBox(box2));
15165
15182
  } catch {
15166
15183
  }
15167
15184
  }
15168
15185
  function moveRunPictures(from, to, files2 = []) {
15169
15186
  if (files2.length === 0) return [];
15170
15187
  try {
15171
- fs43.renameSync(pictureBox(from), pictureBox(to));
15188
+ fs44.renameSync(pictureBox(from), pictureBox(to));
15172
15189
  } catch {
15173
15190
  return files2;
15174
15191
  }
15175
- return files2.map((file) => path45.join(pictureBox(to), path45.basename(file)));
15192
+ return files2.map((file) => path46.join(pictureBox(to), path46.basename(file)));
15176
15193
  }
15177
15194
  var pictureName, boxId, freeBox, pictureBox;
15178
15195
  var init_pictures = __esm({
@@ -15181,8 +15198,8 @@ var init_pictures = __esm({
15181
15198
  init_paths();
15182
15199
  pictureName = (name) => /^[0-9a-f-]{36}\.[a-z0-9]{2,5}$/.test(name);
15183
15200
  boxId = (box2) => /^[0-9a-f-]{36}$/.test(box2);
15184
- freeBox = (box2) => boxId(box2) && !fs43.existsSync(path45.join(SESSIONS_DIR, `${box2}.log`));
15185
- pictureBox = (box2) => path45.join(SESSIONS_DIR, `${box2}.images`);
15201
+ freeBox = (box2) => boxId(box2) && !fs44.existsSync(path46.join(SESSIONS_DIR, `${box2}.log`));
15202
+ pictureBox = (box2) => path46.join(SESSIONS_DIR, `${box2}.images`);
15186
15203
  }
15187
15204
  });
15188
15205
 
@@ -15218,6 +15235,14 @@ var init_Workflow = __esm({
15218
15235
  }
15219
15236
  });
15220
15237
 
15238
+ // src/components/shared.md
15239
+ var shared_default;
15240
+ var init_shared = __esm({
15241
+ "src/components/shared.md"() {
15242
+ shared_default = "Tags draw only in the card body; in any other Markdown file, show pictures as plain Markdown images with paths relative to that file.\n";
15243
+ }
15244
+ });
15245
+
15221
15246
  // src/lib/components.ts
15222
15247
  function agentComponents(names3, documents = DOCUMENTS) {
15223
15248
  const docs = /* @__PURE__ */ new Map();
@@ -15252,18 +15277,19 @@ var init_components = __esm({
15252
15277
  init_Compare();
15253
15278
  init_Storyboard();
15254
15279
  init_Workflow();
15280
+ init_shared();
15255
15281
  init_agents();
15256
15282
  init_io();
15257
15283
  init_paths();
15258
15284
  init_workflows();
15259
15285
  DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default, Workflow: Workflow_default };
15260
- componentDocsText = (docs) => docs.map((doc) => doc.text.trim()).join("\n\n");
15286
+ componentDocsText = (docs) => docs.length ? [shared_default, ...docs.map((doc) => doc.text)].map((text5) => text5.trim()).join("\n\n") : "";
15261
15287
  }
15262
15288
  });
15263
15289
 
15264
15290
  // src/lib/memories.ts
15265
- import fs44 from "node:fs";
15266
- import path46 from "node:path";
15291
+ import fs45 from "node:fs";
15292
+ import path47 from "node:path";
15267
15293
  function readMemory(text5, builtIn, folder) {
15268
15294
  const { meta, body } = splitFrontmatter(text5);
15269
15295
  if (meta === null) return null;
@@ -15283,7 +15309,7 @@ function readMemory(text5, builtIn, folder) {
15283
15309
  rules: body.trim(),
15284
15310
  text: text5,
15285
15311
  builtIn,
15286
- dir: path46.join(MEMORY, folder)
15312
+ dir: path47.join(MEMORY, folder)
15287
15313
  };
15288
15314
  }
15289
15315
  function globalMemories() {
@@ -15294,14 +15320,14 @@ function globalMemories() {
15294
15320
  }
15295
15321
  let folders2 = [];
15296
15322
  try {
15297
- folders2 = fs44.readdirSync(MEMORY, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
15323
+ folders2 = fs45.readdirSync(MEMORY, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
15298
15324
  } catch {
15299
15325
  }
15300
15326
  for (const name of folders2) {
15301
15327
  if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR) continue;
15302
- const file = path46.join(MEMORY, name, GLOBAL_MEMORY_FILE);
15303
- if (!fs44.existsSync(file)) continue;
15304
- const memory = readMemory(fs44.readFileSync(file, "utf8"), false, name);
15328
+ const file = path47.join(MEMORY, name, GLOBAL_MEMORY_FILE);
15329
+ if (!fs45.existsSync(file)) continue;
15330
+ const memory = readMemory(fs45.readFileSync(file, "utf8"), false, name);
15305
15331
  if (memory) out.push(memory);
15306
15332
  }
15307
15333
  return out;
@@ -15357,16 +15383,16 @@ var init_facts = __esm({
15357
15383
  });
15358
15384
 
15359
15385
  // src/lib/view/archive.ts
15360
- import fs45 from "node:fs";
15361
- import path47 from "node:path";
15386
+ import fs46 from "node:fs";
15387
+ import path48 from "node:path";
15362
15388
  function archivedId(file) {
15363
- const own = idPrefix(path47.basename(file));
15364
- return own !== null ? own : idPrefix(path47.basename(path47.dirname(file)));
15389
+ const own = idPrefix(path48.basename(file));
15390
+ return own !== null ? own : idPrefix(path48.basename(path48.dirname(file)));
15365
15391
  }
15366
15392
  function readFile(file) {
15367
15393
  const id = archivedId(file);
15368
15394
  if (id === null) return null;
15369
- const { meta, body } = parseFrontmatter(fs45.readFileSync(file, "utf8"));
15395
+ const { meta, body } = parseFrontmatter(fs46.readFileSync(file, "utf8"));
15370
15396
  if (!meta) return null;
15371
15397
  return {
15372
15398
  row: {
@@ -15374,15 +15400,15 @@ function readFile(file) {
15374
15400
  title: meta.title,
15375
15401
  archived: meta.archived,
15376
15402
  rejected: meta.rejected,
15377
- relPath: rel(file).split(path47.sep).join("/")
15403
+ relPath: rel(file).split(path48.sep).join("/")
15378
15404
  },
15379
15405
  body: body.replace(/^\n+/, "").replace(/\s+$/, ""),
15380
15406
  meta
15381
15407
  };
15382
15408
  }
15383
15409
  function readArchive() {
15384
- const relPath = rel(ARCHIVE).split(path47.sep).join("/");
15385
- if (!fs45.existsSync(ARCHIVE)) return { relPath, cards: [] };
15410
+ const relPath = rel(ARCHIVE).split(path48.sep).join("/");
15411
+ if (!fs46.existsSync(ARCHIVE)) return { relPath, cards: [] };
15386
15412
  const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
15387
15413
  cards.sort((a2, b2) => b2.id - a2.id);
15388
15414
  return { relPath, cards };
@@ -15397,7 +15423,7 @@ var init_archive = __esm({
15397
15423
  });
15398
15424
 
15399
15425
  // src/lib/agent/prompts.ts
15400
- import path48 from "node:path";
15426
+ import path49 from "node:path";
15401
15427
  function stopReason(deliveryId) {
15402
15428
  const delivery = findDelivery(deliveryId);
15403
15429
  if (!delivery) return void 0;
@@ -15460,7 +15486,7 @@ ${text5}` : "";
15460
15486
  }
15461
15487
  function cardFileOf(id) {
15462
15488
  const found2 = id === void 0 ? null : locate(id);
15463
- return found2 ? found2.kind === "group" ? path48.join(found2.target, "root.md") : found2.target : "";
15489
+ return found2 ? found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target : "";
15464
15490
  }
15465
15491
  function realPaths(text5, req) {
15466
15492
  if (req.action !== "scheduled" && req.action !== "sub") return text5;
@@ -15547,7 +15573,7 @@ function frozenRules(req) {
15547
15573
  function archivedCardFile(id) {
15548
15574
  const found2 = locateArchived(id);
15549
15575
  if (!found2) return `${rel(ARCHIVE)}/`;
15550
- return rel(found2.kind === "group" ? path48.join(found2.target, "root.md") : found2.target);
15576
+ return rel(found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target);
15551
15577
  }
15552
15578
  function shippedLines(cardId2) {
15553
15579
  const delivery = endedDelivery(`${cardId2}`);
@@ -15690,7 +15716,7 @@ function actionPrompt(req, command, notes) {
15690
15716
  case "spec": {
15691
15717
  const agent = findSpecAgent(req.specAgent ?? "");
15692
15718
  const found2 = req.id === void 0 ? null : locate(req.id);
15693
- const cardFile3 = found2 ? rel(found2.kind === "group" ? path48.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
15719
+ const cardFile3 = found2 ? rel(found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
15694
15720
  const own = agent ? specAgentInstructions(agent) : null;
15695
15721
  if (own) notes.push(...own.notes);
15696
15722
  const memory = agent ? agentMemoryBlock(agent) : "";
@@ -15871,17 +15897,17 @@ var init_prompts = __esm({
15871
15897
  // src/lib/agent/stop.ts
15872
15898
  import { spawnSync as spawnSync4 } from "node:child_process";
15873
15899
  import { randomUUID as randomUUID4 } from "node:crypto";
15874
- import fs46 from "node:fs";
15900
+ import fs47 from "node:fs";
15875
15901
  import os6 from "node:os";
15876
15902
  function markedInProc(entry, strict = false) {
15877
15903
  const pids = [];
15878
- for (const name of fs46.readdirSync("/proc")) {
15904
+ for (const name of fs47.readdirSync("/proc")) {
15879
15905
  if (!/^\d+$/.test(name)) continue;
15880
15906
  try {
15881
- if (fs46.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
15907
+ if (fs47.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
15882
15908
  } catch (error) {
15883
15909
  if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
15884
- const stat = fs46.statSync(`/proc/${name}`, { throwIfNoEntry: false });
15910
+ const stat = fs47.statSync(`/proc/${name}`, { throwIfNoEntry: false });
15885
15911
  if (stat?.uid === process.getuid?.()) throw error;
15886
15912
  }
15887
15913
  }
@@ -16077,10 +16103,10 @@ var init_stop = __esm({
16077
16103
  });
16078
16104
 
16079
16105
  // src/lib/agent/creation-lock.ts
16080
- import path49 from "node:path";
16106
+ import path50 from "node:path";
16081
16107
  function withCreationLock(fn2) {
16082
16108
  if (depth2) return fn2();
16083
- return withLock(path49.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
16109
+ return withLock(path50.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
16084
16110
  depth2++;
16085
16111
  try {
16086
16112
  return fn2();
@@ -16101,8 +16127,8 @@ var init_creation_lock = __esm({
16101
16127
 
16102
16128
  // src/lib/agent/sessions.ts
16103
16129
  import { randomUUID as randomUUID5 } from "node:crypto";
16104
- import fs47 from "node:fs";
16105
- import path50 from "node:path";
16130
+ import fs48 from "node:fs";
16131
+ import path51 from "node:path";
16106
16132
  function reap(runs, reaped = [], restore = []) {
16107
16133
  let changed = false;
16108
16134
  const now = Date.now();
@@ -16122,7 +16148,7 @@ function reap(runs, reaped = [], restore = []) {
16122
16148
  }
16123
16149
  function stampDuration(run3, endedAt) {
16124
16150
  try {
16125
- fs47.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
16151
+ fs48.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
16126
16152
  } catch {
16127
16153
  }
16128
16154
  }
@@ -16136,7 +16162,7 @@ function cardNow(cardId2) {
16136
16162
  try {
16137
16163
  const file = cardFile(cardId2);
16138
16164
  if (!file) return null;
16139
- const { meta } = parseFrontmatter(fs47.readFileSync(file, "utf8"));
16165
+ const { meta } = parseFrontmatter(fs48.readFileSync(file, "utf8"));
16140
16166
  if (!meta) return null;
16141
16167
  return { status: meta.status || "todo", questions: openOf(meta.questions).length, title: meta.title };
16142
16168
  } catch {
@@ -16268,9 +16294,9 @@ function leftBoardOnLanding(id) {
16268
16294
  function archivedRejected(id) {
16269
16295
  const filed = locateArchived(id);
16270
16296
  if (!filed) return null;
16271
- const file = filed.kind === "group" ? path50.join(filed.target, "root.md") : filed.target;
16297
+ const file = filed.kind === "group" ? path51.join(filed.target, "root.md") : filed.target;
16272
16298
  try {
16273
- return !!parseFrontmatter(fs47.readFileSync(file, "utf8")).meta?.rejected;
16299
+ return !!parseFrontmatter(fs48.readFileSync(file, "utf8")).meta?.rejected;
16274
16300
  } catch {
16275
16301
  return false;
16276
16302
  }
@@ -16521,7 +16547,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID5(), said3) {
16521
16547
  return { run: record, spec };
16522
16548
  }
16523
16549
  function planningSession(cardId2, cwd = REPO_ROOT) {
16524
- const here = (dir) => !dir || path50.resolve(dir) === cwd;
16550
+ const here = (dir) => !dir || path51.resolve(dir) === cwd;
16525
16551
  const planned = readRuns().filter((r2) => r2.status === "done" && r2.cardId === cardId2 && PLANNING.has(r2.action)).sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
16526
16552
  if (!planned) return { none: "unrecorded" };
16527
16553
  if (!here(planned.cwd)) return { none: "elsewhere" };
@@ -16740,8 +16766,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
16740
16766
  if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
16741
16767
  clearAsks(prev.sessionId);
16742
16768
  try {
16743
- fs47.unlinkSync(prev.logPath);
16744
- fs47.rmSync(eventsPathOf(prev.sessionId), { force: true });
16769
+ fs48.unlinkSync(prev.logPath);
16770
+ fs48.rmSync(eventsPathOf(prev.sessionId), { force: true });
16745
16771
  } catch {
16746
16772
  }
16747
16773
  if (retry2 && prev.pictures?.length) {
@@ -16764,8 +16790,8 @@ function forgetRun(sessionId) {
16764
16790
  if (!gone) return;
16765
16791
  clearAsks(sessionId);
16766
16792
  try {
16767
- fs47.unlinkSync(gone.logPath);
16768
- fs47.rmSync(eventsPathOf(gone.sessionId), { force: true });
16793
+ fs48.unlinkSync(gone.logPath);
16794
+ fs48.rmSync(eventsPathOf(gone.sessionId), { force: true });
16769
16795
  } catch {
16770
16796
  }
16771
16797
  }
@@ -16794,14 +16820,14 @@ function noteSpecRefusals(sessionId, refused) {
16794
16820
  }
16795
16821
  function clearAsks(sessionId) {
16796
16822
  try {
16797
- fs47.unlinkSync(asksPathOf(sessionId));
16823
+ fs48.unlinkSync(asksPathOf(sessionId));
16798
16824
  } catch {
16799
16825
  }
16800
16826
  }
16801
16827
  function readAsks(sessionId) {
16802
16828
  let data;
16803
16829
  try {
16804
- data = JSON.parse(fs47.readFileSync(asksPathOf(sessionId), "utf8"));
16830
+ data = JSON.parse(fs48.readFileSync(asksPathOf(sessionId), "utf8"));
16805
16831
  } catch {
16806
16832
  return { asks: [], refines: [], refused: [] };
16807
16833
  }
@@ -16828,10 +16854,10 @@ function readAsks(sessionId) {
16828
16854
  return { asks: asks.filter((a2) => !discarded.has(a2.cardId)), refines: refines.filter((a2) => !discarded.has(a2.cardId)), refused };
16829
16855
  }
16830
16856
  function writeAsks(sessionId, file) {
16831
- fs47.mkdirSync(SESSIONS_DIR, { recursive: true });
16857
+ fs48.mkdirSync(SESSIONS_DIR, { recursive: true });
16832
16858
  const tmp = `${asksPathOf(sessionId)}.tmp`;
16833
- fs47.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
16834
- fs47.renameSync(tmp, asksPathOf(sessionId));
16859
+ fs48.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
16860
+ fs48.renameSync(tmp, asksPathOf(sessionId));
16835
16861
  }
16836
16862
  function markSpawned(sessionId, pid) {
16837
16863
  patch(sessionId, (r2) => {
@@ -16962,12 +16988,12 @@ async function resumeDelivery(id) {
16962
16988
  return { ok: true, deliveryId: delivery.deliveryId, carryOn };
16963
16989
  }
16964
16990
  function writeSpec(spec) {
16965
- fs47.mkdirSync(SESSIONS_DIR, { recursive: true });
16966
- fs47.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
16991
+ fs48.mkdirSync(SESSIONS_DIR, { recursive: true });
16992
+ fs48.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
16967
16993
  }
16968
16994
  function readSpec(sessionId) {
16969
16995
  try {
16970
- const spec = JSON.parse(fs47.readFileSync(specPathOf(sessionId), "utf8"));
16996
+ const spec = JSON.parse(fs48.readFileSync(specPathOf(sessionId), "utf8"));
16971
16997
  return spec && Array.isArray(spec.plan?.argv) ? spec : null;
16972
16998
  } catch {
16973
16999
  return null;
@@ -16975,28 +17001,28 @@ function readSpec(sessionId) {
16975
17001
  }
16976
17002
  function dropSpec(sessionId) {
16977
17003
  try {
16978
- fs47.unlinkSync(specPathOf(sessionId));
17004
+ fs48.unlinkSync(specPathOf(sessionId));
16979
17005
  } catch {
16980
17006
  }
16981
17007
  }
16982
17008
  async function acquireIndexLock(giveUp) {
16983
17009
  const until = Date.now() + INDEX_WAIT_MS;
16984
- const holder = path50.join(INDEX_LOCK2, "holder");
17010
+ const holder = path51.join(INDEX_LOCK2, "holder");
16985
17011
  for (; ; ) {
16986
17012
  if (giveUp()) return null;
16987
17013
  try {
16988
- fs47.mkdirSync(INDEX_LOCK2, { recursive: false });
16989
- fs47.writeFileSync(holder, String(process.pid));
16990
- return () => fs47.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17014
+ fs48.mkdirSync(INDEX_LOCK2, { recursive: false });
17015
+ fs48.writeFileSync(holder, String(process.pid));
17016
+ return () => fs48.rmSync(INDEX_LOCK2, { recursive: true, force: true });
16991
17017
  } catch (err) {
16992
17018
  const code = err.code;
16993
17019
  if (code === "ENOENT") {
16994
- fs47.mkdirSync(path50.dirname(INDEX_LOCK2), { recursive: true });
17020
+ fs48.mkdirSync(path51.dirname(INDEX_LOCK2), { recursive: true });
16995
17021
  continue;
16996
17022
  }
16997
17023
  if (code !== "EEXIST") throw err;
16998
17024
  if (!pidAlive(Number(readHolder(holder)))) {
16999
- fs47.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17025
+ fs48.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17000
17026
  continue;
17001
17027
  }
17002
17028
  if (Date.now() > until) return null;
@@ -17006,7 +17032,7 @@ async function acquireIndexLock(giveUp) {
17006
17032
  }
17007
17033
  function readHolder(file) {
17008
17034
  try {
17009
- return fs47.readFileSync(file, "utf8").trim();
17035
+ return fs48.readFileSync(file, "utf8").trim();
17010
17036
  } catch {
17011
17037
  return String(process.pid);
17012
17038
  }
@@ -17092,8 +17118,8 @@ var init_sessions = __esm({
17092
17118
  implement: "implementing",
17093
17119
  hook: "implementing"
17094
17120
  };
17095
- specPathOf = (sessionId) => path50.join(SESSIONS_DIR, `${sessionId}.plan.json`);
17096
- asksPathOf = (sessionId) => path50.join(SESSIONS_DIR, `${sessionId}.asks.json`);
17121
+ specPathOf = (sessionId) => path51.join(SESSIONS_DIR, `${sessionId}.plan.json`);
17122
+ asksPathOf = (sessionId) => path51.join(SESSIONS_DIR, `${sessionId}.asks.json`);
17097
17123
  carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
17098
17124
  canPickUp = (r2) => r2.status === "error" || r2.status === "interrupted" || r2.status === "stopped";
17099
17125
  neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
@@ -17146,8 +17172,8 @@ var init_sources = __esm({
17146
17172
  });
17147
17173
 
17148
17174
  // src/lib/signals/inbox.ts
17149
- import fs48 from "node:fs";
17150
- import path51 from "node:path";
17175
+ import fs49 from "node:fs";
17176
+ import path52 from "node:path";
17151
17177
  function metaPair(key, value) {
17152
17178
  const name = typeof key === "string" ? key.trim() : "";
17153
17179
  if (!name) return null;
@@ -17178,7 +17204,7 @@ ${signal2.summary.trim()}
17178
17204
  function parse(file, lenient = false) {
17179
17205
  let text5;
17180
17206
  try {
17181
- text5 = fs48.readFileSync(file, "utf8");
17207
+ text5 = fs49.readFileSync(file, "utf8");
17182
17208
  } catch {
17183
17209
  return null;
17184
17210
  }
@@ -17232,20 +17258,20 @@ function parse(file, lenient = false) {
17232
17258
  };
17233
17259
  }
17234
17260
  function freeName(dir, wanted) {
17235
- const ext = path51.extname(wanted);
17261
+ const ext = path52.extname(wanted);
17236
17262
  const stem = wanted.slice(0, wanted.length - ext.length);
17237
17263
  let name = wanted;
17238
- for (let n = 2; fs48.existsSync(path51.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
17264
+ for (let n = 2; fs49.existsSync(path52.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
17239
17265
  return name;
17240
17266
  }
17241
17267
  function readFolder2(dir, lenient = false) {
17242
17268
  let entries;
17243
17269
  try {
17244
- entries = fs48.readdirSync(dir, { withFileTypes: true });
17270
+ entries = fs49.readdirSync(dir, { withFileTypes: true });
17245
17271
  } catch {
17246
17272
  return [];
17247
17273
  }
17248
- return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path51.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
17274
+ return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path52.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
17249
17275
  }
17250
17276
  function readInbox() {
17251
17277
  const signals = readFolder2(TRIAGE);
@@ -17253,7 +17279,7 @@ function readInbox() {
17253
17279
  return signals;
17254
17280
  }
17255
17281
  function writeSignal(incoming, importedAt, slug2 = "") {
17256
- fs48.mkdirSync(TRIAGE, { recursive: true });
17282
+ fs49.mkdirSync(TRIAGE, { recursive: true });
17257
17283
  const signal2 = {
17258
17284
  ...incoming,
17259
17285
  importedAt,
@@ -17265,12 +17291,12 @@ function writeSignal(incoming, importedAt, slug2 = "") {
17265
17291
  contentKept: true,
17266
17292
  relPath: ""
17267
17293
  };
17268
- const file = path51.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
17269
- fs48.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
17294
+ const file = path52.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
17295
+ fs49.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
17270
17296
  return { ...signal2, relPath: boardRel(file) };
17271
17297
  }
17272
17298
  function stamp3(file, fields) {
17273
- const text5 = fs48.readFileSync(file, "utf8");
17299
+ const text5 = fs49.readFileSync(file, "utf8");
17274
17300
  const lines = text5.split("\n");
17275
17301
  const close = lines.indexOf("---", 1);
17276
17302
  if (close < 0) return;
@@ -17279,13 +17305,13 @@ function stamp3(file, fields) {
17279
17305
  return !key || fields[key[1]] === void 0;
17280
17306
  });
17281
17307
  const added = Object.entries(fields).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
17282
- fs48.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
17308
+ fs49.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
17283
17309
  }
17284
17310
  function moveSignal(from, into, fields) {
17285
- if (!fs48.existsSync(from)) return "";
17286
- fs48.mkdirSync(into, { recursive: true });
17287
- const at2 = path51.join(into, freeName(into, path51.basename(from)));
17288
- fs48.renameSync(from, at2);
17311
+ if (!fs49.existsSync(from)) return "";
17312
+ fs49.mkdirSync(into, { recursive: true });
17313
+ const at2 = path52.join(into, freeName(into, path52.basename(from)));
17314
+ fs49.renameSync(from, at2);
17289
17315
  stamp3(at2, fields);
17290
17316
  return boardRel(at2);
17291
17317
  }
@@ -17298,8 +17324,8 @@ function dismissInboxItems(sourceIds, by, reason = "") {
17298
17324
  const found2 = waiting.get(sourceId);
17299
17325
  if (!found2) return missing;
17300
17326
  const already = ignored.get(sourceId);
17301
- if (already) fs48.rmSync(path51.join(SIGNALS_DISMISSED, path51.basename(already.relPath)), { force: true });
17302
- const at2 = moveSignal(path51.join(TRIAGE, path51.basename(found2.relPath)), SIGNALS_DISMISSED, {
17327
+ if (already) fs49.rmSync(path52.join(SIGNALS_DISMISSED, path52.basename(already.relPath)), { force: true });
17328
+ const at2 = moveSignal(path52.join(TRIAGE, path52.basename(found2.relPath)), SIGNALS_DISMISSED, {
17303
17329
  dismissed_at: formatStamp(/* @__PURE__ */ new Date()),
17304
17330
  dismissed_by: by,
17305
17331
  ...why2 ? { dismissed_reason: why2 } : {}
@@ -17315,10 +17341,10 @@ function archiveInboxItem(sourceId, cardId2) {
17315
17341
  if (!found2) {
17316
17342
  const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
17317
17343
  if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
17318
- stamp3(path51.join(SIGNALS_DISMISSED, path51.basename(ignored.relPath)), { card_id: String(cardId2) });
17344
+ stamp3(path52.join(SIGNALS_DISMISSED, path52.basename(ignored.relPath)), { card_id: String(cardId2) });
17319
17345
  return { ok: true, relPath: ignored.relPath, where: "dismissed" };
17320
17346
  }
17321
- const at2 = moveSignal(path51.join(TRIAGE, path51.basename(found2.relPath)), SIGNALS_ARCHIVED, {
17347
+ const at2 = moveSignal(path52.join(TRIAGE, path52.basename(found2.relPath)), SIGNALS_ARCHIVED, {
17322
17348
  card_id: String(cardId2),
17323
17349
  archived_at: formatStamp(/* @__PURE__ */ new Date())
17324
17350
  });
@@ -17336,7 +17362,7 @@ function restoreInboxItems(sourceIds) {
17336
17362
  return refuse3(`${sourceId} was kept without its content, so there is nothing to restore`);
17337
17363
  }
17338
17364
  if (waiting.has(sourceId)) return refuse3(`${sourceId} is already waiting in triage`);
17339
- const at2 = moveSignal(path51.join(SIGNALS_DISMISSED, path51.basename(found2.relPath)), TRIAGE, {
17365
+ const at2 = moveSignal(path52.join(SIGNALS_DISMISSED, path52.basename(found2.relPath)), TRIAGE, {
17340
17366
  dismissed_at: null,
17341
17367
  dismissed_by: null,
17342
17368
  dismissed_reason: null
@@ -17355,7 +17381,7 @@ var init_inbox = __esm({
17355
17381
  init_sources();
17356
17382
  init_paths();
17357
17383
  init_yaml();
17358
- boardRel = (file) => rel(file).split(path51.sep).join("/");
17384
+ boardRel = (file) => rel(file).split(path52.sep).join("/");
17359
17385
  FIELDS = ["source_id", "title", "collected_at", "imported_at"];
17360
17386
  META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
17361
17387
  slugOf = (said3) => said3.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
@@ -17572,12 +17598,12 @@ var init_workflow_cards = __esm({
17572
17598
  });
17573
17599
 
17574
17600
  // src/lib/readme.ts
17575
- import fs49 from "node:fs";
17576
- import path52 from "node:path";
17601
+ import fs50 from "node:fs";
17602
+ import path53 from "node:path";
17577
17603
  function stripReadmeRefs(target) {
17578
- if (!fs49.existsSync(README)) return [];
17604
+ if (!fs50.existsSync(README)) return [];
17579
17605
  const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
17580
- const lines = fs49.readFileSync(README, "utf8").split("\n");
17606
+ const lines = fs50.readFileSync(README, "utf8").split("\n");
17581
17607
  const out = [];
17582
17608
  const removed = [];
17583
17609
  let i = 0;
@@ -17599,20 +17625,20 @@ function stripReadmeRefs(target) {
17599
17625
  out.push(line);
17600
17626
  i++;
17601
17627
  }
17602
- if (removed.length) fs49.writeFileSync(README, out.join("\n"));
17628
+ if (removed.length) fs50.writeFileSync(README, out.join("\n"));
17603
17629
  return removed;
17604
17630
  }
17605
17631
  function addReadmeRef(id, title, relPath) {
17606
- if (!fs49.existsSync(README)) return false;
17607
- const link2 = relPath.split(path52.sep).join("/");
17632
+ if (!fs50.existsSync(README)) return false;
17633
+ const link2 = relPath.split(path53.sep).join("/");
17608
17634
  const bullet = `- [#${id} ${title}](${link2})`;
17609
17635
  const heading = `## ${TASKS_HEADING}`;
17610
- let lines = fs49.readFileSync(README, "utf8").split("\n");
17636
+ let lines = fs50.readFileSync(README, "utf8").split("\n");
17611
17637
  const hi2 = lines.findIndex((l2) => l2.trim().toLowerCase() === heading.toLowerCase());
17612
17638
  if (hi2 === -1) {
17613
17639
  while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
17614
17640
  lines.push("", heading, "", bullet);
17615
- fs49.writeFileSync(README, lines.join("\n") + "\n");
17641
+ fs50.writeFileSync(README, lines.join("\n") + "\n");
17616
17642
  return true;
17617
17643
  }
17618
17644
  let end2 = hi2 + 1;
@@ -17626,15 +17652,15 @@ function addReadmeRef(id, title, relPath) {
17626
17652
  const at2 = lastBullet !== -1 ? lastBullet + 1 : lines[hi2 + 1] === "" ? hi2 + 2 : hi2 + 1;
17627
17653
  lines.splice(at2, 0, bullet);
17628
17654
  }
17629
- fs49.writeFileSync(README, lines.join("\n"));
17655
+ fs50.writeFileSync(README, lines.join("\n"));
17630
17656
  return true;
17631
17657
  }
17632
17658
  function repointReadmeLink(id, oldRel, newRel, title) {
17633
- if (!fs49.existsSync(README)) return false;
17634
- const oldLink = oldRel.split(path52.sep).join("/");
17635
- const newLink = newRel.split(path52.sep).join("/");
17659
+ if (!fs50.existsSync(README)) return false;
17660
+ const oldLink = oldRel.split(path53.sep).join("/");
17661
+ const newLink = newRel.split(path53.sep).join("/");
17636
17662
  const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
17637
- const lines = fs49.readFileSync(README, "utf8").split("\n");
17663
+ const lines = fs50.readFileSync(README, "utf8").split("\n");
17638
17664
  let changed = false;
17639
17665
  for (let i = 0; i < lines.length; i++) {
17640
17666
  if (!lines[i].includes(`](${oldLink})`)) continue;
@@ -17644,7 +17670,7 @@ function repointReadmeLink(id, oldRel, newRel, title) {
17644
17670
  changed = true;
17645
17671
  }
17646
17672
  }
17647
- if (changed) fs49.writeFileSync(README, lines.join("\n"));
17673
+ if (changed) fs50.writeFileSync(README, lines.join("\n"));
17648
17674
  return changed;
17649
17675
  }
17650
17676
  var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex;
@@ -18130,14 +18156,14 @@ function collect(body, card, host2) {
18130
18156
  const active2 = /* @__PURE__ */ new Set();
18131
18157
  const out = [];
18132
18158
  const visit = (src, types, owner) => {
18133
- const path89 = src.replace(/[?#].*$/, "");
18159
+ const path90 = src.replace(/[?#].*$/, "");
18134
18160
  let resolved2;
18135
18161
  try {
18136
- resolved2 = host2.resolve(path89, owner);
18162
+ resolved2 = host2.resolve(path90, owner);
18137
18163
  } catch (error) {
18138
18164
  if (owner !== card) return { key: null, error: why(error) };
18139
18165
  if (!nodes.has(src)) {
18140
- const node2 = { key: src, file: null, kind: kindAt(path89, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18166
+ const node2 = { key: src, file: null, kind: kindAt(path90, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18141
18167
  nodes.set(src, node2);
18142
18168
  out.push(node2);
18143
18169
  }
@@ -18222,16 +18248,16 @@ var init_collect = __esm({
18222
18248
  });
18223
18249
 
18224
18250
  // src/lib/dress-page.ts
18225
- import fs50 from "node:fs";
18226
- import path53 from "node:path";
18251
+ import fs51 from "node:fs";
18252
+ import path54 from "node:path";
18227
18253
  function dressPage(file) {
18228
- const folder = path53.dirname(file);
18229
- const html = fs50.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
18254
+ const folder = path54.dirname(file);
18255
+ const html = fs51.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
18230
18256
  const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
18231
18257
  if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
18232
- const at3 = path53.resolve(folder, href);
18233
- if (!at3.startsWith(folder + path53.sep) || !fs50.existsSync(at3)) return tag;
18234
- 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})`);
18258
+ const at3 = path54.resolve(folder, href);
18259
+ if (!at3.startsWith(folder + path54.sep) || !fs51.existsSync(at3)) return tag;
18260
+ 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})`);
18235
18261
  return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
18236
18262
  });
18237
18263
  const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
@@ -18243,25 +18269,25 @@ var init_dress_page = __esm({
18243
18269
  "use strict";
18244
18270
  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'";
18245
18271
  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>`;
18246
- referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs50.readFileSync(file, "utf8");
18272
+ referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs51.readFileSync(file, "utf8");
18247
18273
  }
18248
18274
  });
18249
18275
 
18250
18276
  // src/lib/preview-files.ts
18251
- import fs51 from "node:fs";
18252
- import path54 from "node:path";
18277
+ import fs52 from "node:fs";
18278
+ import path55 from "node:path";
18253
18279
  function resolver(card, id) {
18254
- const roots = [KANBAN, path54.join(ASSETS, String(id)), path54.join(MOCKUPS, String(id))];
18255
- const real2 = (p2) => fs51.existsSync(p2) ? fs51.realpathSync(p2) : p2;
18256
- const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path54.sep));
18280
+ const roots = [KANBAN, path55.join(ASSETS, String(id)), path55.join(MOCKUPS, String(id))];
18281
+ const real2 = (p2) => fs52.existsSync(p2) ? fs52.realpathSync(p2) : p2;
18282
+ const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path55.sep));
18257
18283
  return (src, owner) => {
18258
18284
  if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
18259
- if (path54.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
18285
+ if (path55.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
18260
18286
  const held4 = /^\.(assets|mockups)\//.exec(src);
18261
- const file = held4 ? path54.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path54.resolve(path54.dirname(owner), src);
18262
- if (!inside2(path54.resolve(file)) || fs51.existsSync(file) && !inside2(fs51.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
18263
- if (!fs51.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
18264
- return { key: fs51.realpathSync(file), file };
18287
+ const file = held4 ? path55.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path55.resolve(path55.dirname(owner), src);
18288
+ if (!inside2(path55.resolve(file)) || fs52.existsSync(file) && !inside2(fs52.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
18289
+ if (!fs52.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
18290
+ return { key: fs52.realpathSync(file), file };
18265
18291
  };
18266
18292
  }
18267
18293
  function validatePreviewFiles(card, id, text5) {
@@ -18296,8 +18322,8 @@ var init_preview_files = __esm({
18296
18322
  });
18297
18323
 
18298
18324
  // src/lib/spec-contract.ts
18299
- import fs52 from "node:fs";
18300
- import path55 from "node:path";
18325
+ import fs53 from "node:fs";
18326
+ import path56 from "node:path";
18301
18327
  function scanCardLines(lines, start = 0) {
18302
18328
  const visible = lines.map(() => "");
18303
18329
  let fence = null;
@@ -18330,18 +18356,18 @@ function scanCardLines(lines, start = 0) {
18330
18356
  }
18331
18357
  function snapshotSpecs() {
18332
18358
  const out = /* @__PURE__ */ new Map();
18333
- if (!fs52.existsSync(TODO)) return out;
18359
+ if (!fs53.existsSync(TODO)) return out;
18334
18360
  for (const file of walkMd(TODO)) {
18335
- if (isLegacyRecurring(path55.relative(TODO, file))) continue;
18336
- const id = idPrefix(path55.basename(file) === "root.md" ? path55.basename(path55.dirname(file)) : path55.basename(file));
18337
- if (id !== null) out.set(file, { id, text: fs52.readFileSync(file, "utf8") });
18361
+ if (isLegacyRecurring(path56.relative(TODO, file))) continue;
18362
+ const id = idPrefix(path56.basename(file) === "root.md" ? path56.basename(path56.dirname(file)) : path56.basename(file));
18363
+ if (id !== null) out.set(file, { id, text: fs53.readFileSync(file, "utf8") });
18338
18364
  }
18339
18365
  return out;
18340
18366
  }
18341
18367
  function enclosingGroups(file) {
18342
18368
  const ids = [];
18343
18369
  for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
18344
- const id = idPrefix(path55.basename(path55.dirname(root2)));
18370
+ const id = idPrefix(path56.basename(path56.dirname(root2)));
18345
18371
  if (id !== null) ids.push(id);
18346
18372
  }
18347
18373
  return ids;
@@ -18499,9 +18525,9 @@ function validateSpec(file, text5, id) {
18499
18525
  }
18500
18526
  function inside(dir, name) {
18501
18527
  try {
18502
- const root2 = fs52.realpathSync(dir);
18503
- const real2 = fs52.realpathSync(path55.join(dir, name));
18504
- return real2.startsWith(root2 + path55.sep) && fs52.statSync(real2).isFile() ? real2 : null;
18528
+ const root2 = fs53.realpathSync(dir);
18529
+ const real2 = fs53.realpathSync(path56.join(dir, name));
18530
+ return real2.startsWith(root2 + path56.sep) && fs53.statSync(real2).isFile() ? real2 : null;
18505
18531
  } catch {
18506
18532
  return null;
18507
18533
  }
@@ -18519,7 +18545,7 @@ function variantsProblem(raw, src, id) {
18519
18545
  if (files2.length < 2 || !files2.every((f2) => typeof f2 === "string" && f2)) return `variants needs at least two labels, each naming a file. ${shape}`;
18520
18546
  if (!files2.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
18521
18547
  if (id === void 0) return null;
18522
- const dir = path55.join(ASSETS, String(id));
18548
+ const dir = path56.join(ASSETS, String(id));
18523
18549
  for (const f2 of files2) {
18524
18550
  const parts = f2.split("/");
18525
18551
  if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
@@ -18529,7 +18555,7 @@ function variantsProblem(raw, src, id) {
18529
18555
  return null;
18530
18556
  }
18531
18557
  function compareProblem(attrs, id) {
18532
- const dir = path55.join(ASSETS, String(id));
18558
+ const dir = path56.join(ASSETS, String(id));
18533
18559
  const src = (message) => ({ rule: "compare-src", message });
18534
18560
  const shots = (message) => ({ rule: "compare-shots", message });
18535
18561
  for (const side of ["a", "b"]) {
@@ -18549,7 +18575,7 @@ function compareProblem(attrs, id) {
18549
18575
  const file = inside(dir, named2.name);
18550
18576
  if (!file) return { message: `Compare shots ${at2} names no file in this card's asset folder. Write the JSON there or fix the path.` };
18551
18577
  try {
18552
- return { data: JSON.parse(fs52.readFileSync(file, "utf8")) };
18578
+ return { data: JSON.parse(fs53.readFileSync(file, "utf8")) };
18553
18579
  } catch {
18554
18580
  return { message: `${at2} is not valid JSON.` };
18555
18581
  }
@@ -18569,7 +18595,7 @@ function compareProblem(attrs, id) {
18569
18595
  }
18570
18596
  function validateStoryboards(file, id, text5) {
18571
18597
  const errors = [];
18572
- const dir = path55.join(ASSETS, String(id));
18598
+ const dir = path56.join(ASSETS, String(id));
18573
18599
  for (const [tag, tagOf, rule, fix] of [
18574
18600
  ["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
18575
18601
  ["Workflow", workflowTag, "workflow-src", "Write it with `akb workflow diagram <workflow id> <card id>` or fix the path."]
@@ -18646,14 +18672,14 @@ var init_spec_contract = __esm({
18646
18672
  });
18647
18673
 
18648
18674
  // src/lib/reconcile.ts
18649
- import fs53 from "node:fs";
18650
- import path56 from "node:path";
18675
+ import fs54 from "node:fs";
18676
+ import path57 from "node:path";
18651
18677
  function liveIds() {
18652
18678
  const ids = /* @__PURE__ */ new Set();
18653
18679
  for (const file of walkMd(TODO)) {
18654
- const base = path56.basename(file);
18680
+ const base = path57.basename(file);
18655
18681
  if (base === "README.md") continue;
18656
- const id = base === "root.md" ? idPrefix(path56.basename(path56.dirname(file))) : idPrefix(base);
18682
+ const id = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
18657
18683
  if (id != null) ids.add(id);
18658
18684
  }
18659
18685
  return ids;
@@ -18661,16 +18687,16 @@ function liveIds() {
18661
18687
  function indexableCards() {
18662
18688
  const out = [];
18663
18689
  for (const dir of walkDirs(TODO)) {
18664
- const id = idPrefix(path56.basename(dir));
18665
- if (id != null && fs53.existsSync(path56.join(dir, "root.md"))) {
18666
- out.push({ id, rel: path56.join(path56.relative(TODO, dir), "root.md").split(path56.sep).join("/") });
18690
+ const id = idPrefix(path57.basename(dir));
18691
+ if (id != null && fs54.existsSync(path57.join(dir, "root.md"))) {
18692
+ out.push({ id, rel: path57.join(path57.relative(TODO, dir), "root.md").split(path57.sep).join("/") });
18667
18693
  }
18668
18694
  }
18669
18695
  for (const file of walkMd(TODO)) {
18670
- const base = path56.basename(file);
18696
+ const base = path57.basename(file);
18671
18697
  if (base === "README.md" || base === "root.md") continue;
18672
- const relTODO = path56.relative(TODO, file);
18673
- const segs = relTODO.split(path56.sep);
18698
+ const relTODO = path57.relative(TODO, file);
18699
+ const segs = relTODO.split(path57.sep);
18674
18700
  if (segs.length !== 1) continue;
18675
18701
  const id = idPrefix(base);
18676
18702
  if (id != null) out.push({ id, rel: segs.join("/") });
@@ -18679,7 +18705,7 @@ function indexableCards() {
18679
18705
  }
18680
18706
  function readmeComplaints(fix) {
18681
18707
  const said3 = [];
18682
- const lines = fs53.readFileSync(README, "utf8").split("\n");
18708
+ const lines = fs54.readFileSync(README, "utf8").split("\n");
18683
18709
  const indexed = /* @__PURE__ */ new Set();
18684
18710
  let fixed = 0;
18685
18711
  for (let i = 0; i < lines.length; i++) {
@@ -18688,13 +18714,13 @@ function readmeComplaints(fix) {
18688
18714
  const id = Number(m[1]);
18689
18715
  const linkPath = m[2];
18690
18716
  indexed.add(id);
18691
- if (fs53.existsSync(path56.join(TODO, linkPath))) continue;
18717
+ if (fs54.existsSync(path57.join(TODO, linkPath))) continue;
18692
18718
  const found2 = locate(id);
18693
18719
  if (!found2) {
18694
18720
  said3.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
18695
18721
  continue;
18696
18722
  }
18697
- const want = (found2.kind === "group" ? path56.join(found2.rel, "root.md") : found2.rel).split(path56.sep).join("/");
18723
+ const want = (found2.kind === "group" ? path57.join(found2.rel, "root.md") : found2.rel).split(path57.sep).join("/");
18698
18724
  if (want === linkPath) continue;
18699
18725
  if (!fix) {
18700
18726
  said3.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
@@ -18704,7 +18730,7 @@ function readmeComplaints(fix) {
18704
18730
  said3.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
18705
18731
  fixed++;
18706
18732
  }
18707
- if (fixed) fs53.writeFileSync(README, lines.join("\n"));
18733
+ if (fixed) fs54.writeFileSync(README, lines.join("\n"));
18708
18734
  for (const c2 of indexableCards()) {
18709
18735
  if (!indexed.has(c2.id)) {
18710
18736
  said3.push(`card ${c2.rel} (#${c2.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
@@ -18716,11 +18742,11 @@ function crossRefComplaints() {
18716
18742
  const said3 = [];
18717
18743
  const live = liveIds();
18718
18744
  for (const file of walkMd(TODO)) {
18719
- const base = path56.basename(file);
18745
+ const base = path57.basename(file);
18720
18746
  if (base === "README.md") continue;
18721
- const ownerId = base === "root.md" ? idPrefix(path56.basename(path56.dirname(file))) : idPrefix(base);
18747
+ const ownerId = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
18722
18748
  if (ownerId == null) continue;
18723
- const { meta } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
18749
+ const { meta } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
18724
18750
  if (!meta) continue;
18725
18751
  for (const field2 of ["blocked_by", "related"]) {
18726
18752
  for (const ref of meta[field2] || []) {
@@ -18733,11 +18759,11 @@ function crossRefComplaints() {
18733
18759
  return said3;
18734
18760
  }
18735
18761
  function reconcileBoard() {
18736
- if (!fs53.existsSync(README)) return;
18762
+ if (!fs54.existsSync(README)) return;
18737
18763
  for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
18738
18764
  }
18739
18765
  function boardComplaints() {
18740
- if (!fs53.existsSync(README)) return [];
18766
+ if (!fs54.existsSync(README)) return [];
18741
18767
  try {
18742
18768
  return [...readmeComplaints(false), ...crossRefComplaints()];
18743
18769
  } catch {
@@ -18757,8 +18783,8 @@ var init_reconcile = __esm({
18757
18783
  });
18758
18784
 
18759
18785
  // src/commands/card.ts
18760
- import fs54 from "node:fs";
18761
- import path57 from "node:path";
18786
+ import fs55 from "node:fs";
18787
+ import path58 from "node:path";
18762
18788
  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>") {
18763
18789
  return [
18764
18790
  summary,
@@ -18784,7 +18810,7 @@ function bodyFromFile(opts) {
18784
18810
  if (opts.body === false) die("pass --body-file or --no-body, not both");
18785
18811
  let text5;
18786
18812
  try {
18787
- text5 = fs54.readFileSync(opts.bodyFile, "utf8");
18813
+ text5 = fs55.readFileSync(opts.bodyFile, "utf8");
18788
18814
  } catch {
18789
18815
  die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
18790
18816
  }
@@ -18864,20 +18890,20 @@ function cmdCreate(opts) {
18864
18890
  const start = opts.id;
18865
18891
  const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
18866
18892
  const fileRel = `${start}-${slug2}.md`;
18867
- const file = path57.join(TODO, fileRel);
18893
+ const file = path58.join(TODO, fileRel);
18868
18894
  const held4 = locate(start) ?? locateArchived(start);
18869
- if (held4 && path57.basename(held4.target) === `${start}-${slug2}.md`) {
18895
+ if (held4 && path58.basename(held4.target) === `${start}-${slug2}.md`) {
18870
18896
  say(start);
18871
18897
  say(` ${rel(held4.target)} was already written`);
18872
18898
  return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
18873
18899
  }
18874
18900
  if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
18875
- if (fs54.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
18901
+ if (fs55.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
18876
18902
  countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
18877
18903
  const meta = { title, priority, status: "todo", blocked_by, related, modules, workflow, previews, stages, triage, source, questions };
18878
18904
  const scaffolded = !written && opts.body !== false;
18879
18905
  const body = written ?? (scaffolded ? defaultBody() : "");
18880
- fs54.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
18906
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
18881
18907
  const indexed = addReadmeRef(start, title, fileRel);
18882
18908
  say(start);
18883
18909
  say(
@@ -18929,8 +18955,8 @@ function cmdUpdate(id, flags) {
18929
18955
  if (creating) die(creating, { kind: "card-being-created", id });
18930
18956
  const found2 = locate(id);
18931
18957
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
18932
- const file = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
18933
- const { meta, body } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
18958
+ const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
18959
+ const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
18934
18960
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
18935
18961
  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");
18936
18962
  if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
@@ -19004,26 +19030,26 @@ function cmdUpdate(id, flags) {
19004
19030
  meta.status = "todo";
19005
19031
  changes.push("status\u2192todo (open questions)");
19006
19032
  }
19007
- const curRel = path57.relative(TODO, file);
19033
+ const curRel = path58.relative(TODO, file);
19008
19034
  const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
19009
- let base = path57.basename(file);
19035
+ let base = path58.basename(file);
19010
19036
  if (flags.slug !== void 0) {
19011
19037
  if (found2.kind === "group") die("renaming a group root by script is not supported");
19012
19038
  base = `${id}-${slugify(flags.slug)}.md`;
19013
19039
  }
19014
- const destRel = path57.join(path57.dirname(curRel), base);
19015
- const dest = path57.join(TODO, destRel);
19040
+ const destRel = path58.join(path58.dirname(curRel), base);
19041
+ const dest = path58.join(TODO, destRel);
19016
19042
  const moving = dest !== file;
19017
- if (moving && fs54.existsSync(dest)) die(`${rel(dest)} already exists`);
19018
- fs54.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19019
- if (moving) fs54.renameSync(file, dest);
19043
+ if (moving && fs55.existsSync(dest)) die(`${rel(dest)} already exists`);
19044
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19045
+ if (moving) fs55.renameSync(file, dest);
19020
19046
  if (isSubtask) {
19021
19047
  if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
19022
- if (moving) changes.push(`renamed \u2192 ${destRel.split(path57.sep).join("/")}`);
19048
+ if (moving) changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
19023
19049
  } else if (moving) {
19024
19050
  stripReadmeRefs({ kind: "file", rel: curRel });
19025
19051
  addReadmeRef(id, meta.title, destRel);
19026
- changes.push(`renamed \u2192 ${destRel.split(path57.sep).join("/")}`);
19052
+ changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
19027
19053
  } else if (changes.includes("title")) {
19028
19054
  stripReadmeRefs({ kind: "file", rel: curRel });
19029
19055
  addReadmeRef(id, meta.title, curRel);
@@ -19035,8 +19061,8 @@ function cmdUpdateQuestions(id, input) {
19035
19061
  const ops = readQuestionOps(input.ops ?? []);
19036
19062
  const found2 = locate(id);
19037
19063
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
19038
- const file = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
19039
- const { meta, body } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
19064
+ const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
19065
+ const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
19040
19066
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
19041
19067
  if (insideRun() && ops.some((op) => op.kind === "skip" || op.kind === "unskip")) {
19042
19068
  die("only the user skips or reopens a question \u2014 a run leaves questions for them to answer");
@@ -19109,7 +19135,7 @@ function cmdUpdateQuestions(id, input) {
19109
19135
  meta.status = "todo";
19110
19136
  changes.push("status\u2192todo (open questions)");
19111
19137
  }
19112
- fs54.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19138
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19113
19139
  for (const kind of closed2) countBoardEvent(kind);
19114
19140
  settleDelivery2(id, skipped, unskipped);
19115
19141
  say(
@@ -19185,13 +19211,13 @@ var init_config_template = __esm({
19185
19211
  });
19186
19212
 
19187
19213
  // src/lib/agent/local.ts
19188
- import fs55 from "node:fs";
19189
- import path58 from "node:path";
19214
+ import fs56 from "node:fs";
19215
+ import path59 from "node:path";
19190
19216
  function takeLocalModels(board2) {
19191
- const file = path58.join(board2, ".local.json");
19217
+ const file = path59.join(board2, ".local.json");
19192
19218
  let held4;
19193
19219
  try {
19194
- held4 = configBlock(JSON.parse(fs55.readFileSync(file, "utf8")));
19220
+ held4 = configBlock(JSON.parse(fs56.readFileSync(file, "utf8")));
19195
19221
  } catch {
19196
19222
  return {};
19197
19223
  }
@@ -19209,7 +19235,7 @@ function takeLocalModels(board2) {
19209
19235
  }
19210
19236
  if (!Object.keys(agents).length) return out;
19211
19237
  delete held4.agents;
19212
- fs55.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19238
+ fs56.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19213
19239
  return out;
19214
19240
  }
19215
19241
  var LOCAL_IGNORE_LINE;
@@ -19270,12 +19296,12 @@ var init_identity2 = __esm({
19270
19296
  });
19271
19297
 
19272
19298
  // src/lib/signals/migrate.ts
19273
- import fs56 from "node:fs";
19274
- import path59 from "node:path";
19299
+ import fs57 from "node:fs";
19300
+ import path60 from "node:path";
19275
19301
  function readHandled() {
19276
19302
  let text5;
19277
19303
  try {
19278
- text5 = fs56.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19304
+ text5 = fs57.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19279
19305
  } catch {
19280
19306
  return [];
19281
19307
  }
@@ -19292,57 +19318,57 @@ function readHandled() {
19292
19318
  return held4;
19293
19319
  }
19294
19320
  function lift(from, into) {
19295
- fs56.mkdirSync(into, { recursive: true });
19296
- fs56.renameSync(from, path59.join(into, freeName(into, path59.basename(from))));
19321
+ fs57.mkdirSync(into, { recursive: true });
19322
+ fs57.renameSync(from, path60.join(into, freeName(into, path60.basename(from))));
19297
19323
  }
19298
19324
  function repoint(dir, from, into) {
19299
19325
  let entries;
19300
19326
  try {
19301
- entries = fs56.readdirSync(dir, { withFileTypes: true });
19327
+ entries = fs57.readdirSync(dir, { withFileTypes: true });
19302
19328
  } catch {
19303
19329
  return;
19304
19330
  }
19305
19331
  for (const entry of entries) {
19306
19332
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
19307
- const file = path59.join(dir, entry.name);
19308
- const text5 = fs56.readFileSync(file, "utf8");
19309
- if (text5.includes(from)) fs56.writeFileSync(file, text5.split(from).join(into));
19333
+ const file = path60.join(dir, entry.name);
19334
+ const text5 = fs57.readFileSync(file, "utf8");
19335
+ if (text5.includes(from)) fs57.writeFileSync(file, text5.split(from).join(into));
19310
19336
  }
19311
19337
  }
19312
19338
  function dropIfEmpty2(dir) {
19313
19339
  try {
19314
- fs56.rmdirSync(dir);
19340
+ fs57.rmdirSync(dir);
19315
19341
  } catch {
19316
19342
  }
19317
19343
  }
19318
19344
  function liftInbox() {
19319
- if (!fs56.existsSync(SIGNALS_OLD_INBOX)) return;
19320
- const oldFiles = path59.join(SIGNALS_OLD_INBOX, "files");
19321
- if (fs56.existsSync(oldFiles)) {
19322
- for (const entry of fs56.readdirSync(oldFiles, { withFileTypes: true })) {
19323
- if (entry.isFile()) lift(path59.join(oldFiles, entry.name), SIGNALS_FILES);
19345
+ if (!fs57.existsSync(SIGNALS_OLD_INBOX)) return;
19346
+ const oldFiles = path60.join(SIGNALS_OLD_INBOX, "files");
19347
+ if (fs57.existsSync(oldFiles)) {
19348
+ for (const entry of fs57.readdirSync(oldFiles, { withFileTypes: true })) {
19349
+ if (entry.isFile()) lift(path60.join(oldFiles, entry.name), SIGNALS_FILES);
19324
19350
  }
19325
19351
  dropIfEmpty2(oldFiles);
19326
19352
  }
19327
19353
  const held4 = new Set(readFolder2(TRIAGE).map((signal2) => signal2.sourceId));
19328
- for (const entry of fs56.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19354
+ for (const entry of fs57.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19329
19355
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
19330
- const from = path59.join(SIGNALS_OLD_INBOX, entry.name);
19356
+ const from = path60.join(SIGNALS_OLD_INBOX, entry.name);
19331
19357
  const item = parse(from);
19332
19358
  if (item && held4.has(item.sourceId)) {
19333
- fs56.rmSync(from, { force: true });
19359
+ fs57.rmSync(from, { force: true });
19334
19360
  continue;
19335
19361
  }
19336
19362
  if (item) held4.add(item.sourceId);
19337
19363
  lift(from, TRIAGE);
19338
19364
  }
19339
- const wasAt = asWritten(path59.join(SIGNALS_OLD_INBOX, "files"));
19365
+ const wasAt = asWritten(path60.join(SIGNALS_OLD_INBOX, "files"));
19340
19366
  const nowAt = asWritten(SIGNALS_FILES);
19341
19367
  for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
19342
19368
  dropIfEmpty2(SIGNALS_OLD_INBOX);
19343
19369
  }
19344
19370
  function liftHandled() {
19345
- if (!fs56.existsSync(SIGNALS_OLD_HANDLED)) return;
19371
+ if (!fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
19346
19372
  const lines = readHandled();
19347
19373
  const held4 = /* @__PURE__ */ new Set([
19348
19374
  ...readFolder2(TRIAGE).map((signal2) => signal2.sourceId),
@@ -19352,7 +19378,7 @@ function liftHandled() {
19352
19378
  for (const { sourceId, when } of lines) {
19353
19379
  if (held4.has(sourceId)) continue;
19354
19380
  held4.add(sourceId);
19355
- fs56.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19381
+ fs57.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19356
19382
  const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
19357
19383
  const front = [
19358
19384
  "---",
@@ -19362,13 +19388,13 @@ function liftHandled() {
19362
19388
  "---",
19363
19389
  ""
19364
19390
  ];
19365
- fs56.writeFileSync(path59.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19391
+ fs57.writeFileSync(path60.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19366
19392
  `);
19367
19393
  }
19368
- fs56.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19394
+ fs57.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19369
19395
  }
19370
19396
  function migrateTriage() {
19371
- if (!fs56.existsSync(SIGNALS_OLD_INBOX) && !fs56.existsSync(SIGNALS_OLD_HANDLED)) return;
19397
+ if (!fs57.existsSync(SIGNALS_OLD_INBOX) && !fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
19372
19398
  try {
19373
19399
  liftInbox();
19374
19400
  liftHandled();
@@ -19383,13 +19409,13 @@ var init_migrate = __esm({
19383
19409
  init_yaml();
19384
19410
  init_inbox();
19385
19411
  HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
19386
- asWritten = (dir) => `${rel(dir).split(path59.sep).join("/")}/`;
19412
+ asWritten = (dir) => `${rel(dir).split(path60.sep).join("/")}/`;
19387
19413
  }
19388
19414
  });
19389
19415
 
19390
19416
  // src/lib/signals/add.ts
19391
- import fs57 from "node:fs";
19392
- import path60 from "node:path";
19417
+ import fs58 from "node:fs";
19418
+ import path61 from "node:path";
19393
19419
  import { createHash as createHash4 } from "node:crypto";
19394
19420
  function linkTitle(url) {
19395
19421
  let at2;
@@ -19402,7 +19428,7 @@ function linkTitle(url) {
19402
19428
  return oneLine(where) || url.slice(0, TITLE_MAX);
19403
19429
  }
19404
19430
  function asText(file) {
19405
- const ext = path60.extname(file.name).toLowerCase();
19431
+ const ext = path61.extname(file.name).toLowerCase();
19406
19432
  if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
19407
19433
  try {
19408
19434
  const text5 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
@@ -19412,9 +19438,9 @@ function asText(file) {
19412
19438
  }
19413
19439
  }
19414
19440
  function fileName2(name, data) {
19415
- const base = path60.basename(name);
19416
- const ext = path60.extname(base).toLowerCase().slice(0, 12);
19417
- const word = path60.basename(base, path60.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
19441
+ const base = path61.basename(name);
19442
+ const ext = path61.extname(base).toLowerCase().slice(0, 12);
19443
+ const word = path61.basename(base, path61.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
19418
19444
  const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
19419
19445
  return `${word}-${hash2}${ext}`;
19420
19446
  }
@@ -19423,9 +19449,9 @@ function addToInbox(drop) {
19423
19449
  const typed = (drop.text ?? "").trim();
19424
19450
  const file = drop.file;
19425
19451
  if (!typed && !file) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
19426
- if (file && file.data.length === 0) return { ok: false, error: `${path60.basename(file.name)} is empty.` };
19452
+ if (file && file.data.length === 0) return { ok: false, error: `${path61.basename(file.name)} is empty.` };
19427
19453
  if (file && file.data.length > MAX_BYTES) {
19428
- return { ok: false, error: `${path60.basename(file.name)} is over ${MAX_BYTES / 1024 / 1024} MB \u2014 too big for the board.` };
19454
+ return { ok: false, error: `${path61.basename(file.name)} is over ${MAX_BYTES / 1024 / 1024} MB \u2014 too big for the board.` };
19429
19455
  }
19430
19456
  const read5 = describe(typed, file);
19431
19457
  const keep2 = read5.keep;
@@ -19447,8 +19473,8 @@ ${incoming.summary}`);
19447
19473
  if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
19448
19474
  try {
19449
19475
  if (keep2) {
19450
- fs57.mkdirSync(SIGNALS_FILES, { recursive: true });
19451
- fs57.writeFileSync(keep2.at, keep2.data);
19476
+ fs58.mkdirSync(SIGNALS_FILES, { recursive: true });
19477
+ fs58.writeFileSync(keep2.at, keep2.data);
19452
19478
  }
19453
19479
  return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
19454
19480
  } catch (e2) {
@@ -19462,7 +19488,7 @@ function describe(typed, file) {
19462
19488
  return only ? [only] : [];
19463
19489
  };
19464
19490
  if (file) {
19465
- const name = path60.basename(file.name);
19491
+ const name = path61.basename(file.name);
19466
19492
  const text5 = asText(file);
19467
19493
  const note = typed ? `
19468
19494
 
@@ -19474,7 +19500,7 @@ ${typed}` : "";
19474
19500
  const at2 = keepAt(file);
19475
19501
  return {
19476
19502
  incoming: {
19477
- title: path60.basename(name, path60.extname(name)) || name,
19503
+ title: path61.basename(name, path61.extname(name)) || name,
19478
19504
  summary: `${name} \u2014 ${boardRel2(at2)}${note}`,
19479
19505
  ...named2
19480
19506
  },
@@ -19512,73 +19538,73 @@ var init_add = __esm({
19512
19538
  MAX_BYTES = 25 * 1024 * 1024;
19513
19539
  TITLE_MAX = 120;
19514
19540
  TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
19515
- boardRel2 = (file) => rel(file).split(path60.sep).join("/");
19541
+ boardRel2 = (file) => rel(file).split(path61.sep).join("/");
19516
19542
  oneLine = (text5) => {
19517
19543
  const first = text5.split("\n").find((line) => line.trim()) ?? "";
19518
19544
  const clean = first.replace(/^#+\s*/, "").trim();
19519
19545
  return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
19520
19546
  };
19521
- keepAt = (file) => path60.join(SIGNALS_FILES, fileName2(file.name, file.data));
19547
+ keepAt = (file) => path61.join(SIGNALS_FILES, fileName2(file.name, file.data));
19522
19548
  }
19523
19549
  });
19524
19550
 
19525
19551
  // src/lib/recurring.ts
19526
- import fs58 from "node:fs";
19527
- import path61 from "node:path";
19552
+ import fs59 from "node:fs";
19553
+ import path62 from "node:path";
19528
19554
  function migratePruneMemoryCard() {
19529
19555
  const dir = recurringDir();
19530
19556
  let names3;
19531
19557
  try {
19532
- names3 = fs58.readdirSync(dir);
19558
+ names3 = fs59.readdirSync(dir);
19533
19559
  } catch {
19534
19560
  return null;
19535
19561
  }
19536
19562
  const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
19537
19563
  if (!name) return null;
19538
- const file = path61.join(dir, name);
19564
+ const file = path62.join(dir, name);
19539
19565
  try {
19540
- const { meta } = parseFrontmatter(fs58.readFileSync(file, "utf8"));
19566
+ const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19541
19567
  const cadence = meta?.cadence;
19542
19568
  if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
19543
19569
  } catch {
19544
19570
  }
19545
- fs58.rmSync(file, { force: true });
19571
+ fs59.rmSync(file, { force: true });
19546
19572
  return rel(file);
19547
19573
  }
19548
19574
  function legacyCards() {
19549
19575
  const dir = recurringDir();
19550
- if (!fs58.existsSync(dir)) return [];
19576
+ if (!fs59.existsSync(dir)) return [];
19551
19577
  const cards = [];
19552
- for (const entry of fs58.readdirSync(dir, { withFileTypes: true })) {
19578
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19553
19579
  const id = idPrefix(entry.name);
19554
19580
  if (id === null) continue;
19555
- const full = path61.join(dir, entry.name);
19581
+ const full = path62.join(dir, entry.name);
19556
19582
  const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
19557
19583
  if (entry.isFile() && entry.name.endsWith(".md")) cards.push({ id, slug: slug2, file: full });
19558
- else if (entry.isDirectory() && fs58.existsSync(path61.join(full, "root.md"))) {
19559
- cards.push({ id, slug: slug2, file: path61.join(full, "root.md"), folder: full });
19584
+ else if (entry.isDirectory() && fs59.existsSync(path62.join(full, "root.md"))) {
19585
+ cards.push({ id, slug: slug2, file: path62.join(full, "root.md"), folder: full });
19560
19586
  }
19561
19587
  }
19562
19588
  return cards.sort((a2, b2) => a2.id - b2.id);
19563
19589
  }
19564
19590
  function mergeInto2(from, to, skip = []) {
19565
- fs58.mkdirSync(to, { recursive: true });
19566
- for (const entry of fs58.readdirSync(from, { withFileTypes: true })) {
19591
+ fs59.mkdirSync(to, { recursive: true });
19592
+ for (const entry of fs59.readdirSync(from, { withFileTypes: true })) {
19567
19593
  if (skip.includes(entry.name)) continue;
19568
- const source = path61.join(from, entry.name);
19569
- const target = path61.join(to, entry.name);
19570
- if (!fs58.existsSync(target)) fs58.renameSync(source, target);
19571
- else if (entry.isDirectory() && fs58.statSync(target).isDirectory()) mergeInto2(source, target);
19594
+ const source = path62.join(from, entry.name);
19595
+ const target = path62.join(to, entry.name);
19596
+ if (!fs59.existsSync(target)) fs59.renameSync(source, target);
19597
+ else if (entry.isDirectory() && fs59.statSync(target).isDirectory()) mergeInto2(source, target);
19572
19598
  }
19573
- if (isEmpty(from)) fs58.rmSync(from, { recursive: true, force: true });
19599
+ if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
19574
19600
  }
19575
19601
  function moveSideFolders() {
19576
19602
  const dir = recurringDir();
19577
- for (const entry of fs58.readdirSync(dir, { withFileTypes: true })) {
19603
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19578
19604
  if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
19579
- const from = path61.join(dir, entry.name);
19580
- if (isEmpty(from)) fs58.rmSync(from, { recursive: true, force: true });
19581
- else mergeInto2(from, path61.join(AGENTS, entry.name));
19605
+ const from = path62.join(dir, entry.name);
19606
+ if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
19607
+ else mergeInto2(from, path62.join(AGENTS, entry.name));
19582
19608
  }
19583
19609
  }
19584
19610
  function sections(body) {
@@ -19628,8 +19654,8 @@ function agentName(card, text5) {
19628
19654
  const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a2) => a2.name), ...ROLE_NAMES]);
19629
19655
  for (const name of [slug2, `${slug2}-${card.id}`]) {
19630
19656
  if (!AGENT_NAME.test(name)) continue;
19631
- const file = path61.join(AGENTS, name, AGENT_FILE2);
19632
- const written = fs58.existsSync(file) ? fs58.readFileSync(file, "utf8") : null;
19657
+ const file = path62.join(AGENTS, name, AGENT_FILE2);
19658
+ const written = fs59.existsSync(file) ? fs59.readFileSync(file, "utf8") : null;
19633
19659
  if (written === text5(name)) return name;
19634
19660
  if (written === null && !known2.has(name)) return name;
19635
19661
  }
@@ -19646,11 +19672,11 @@ ${q3.options.map((o3) => `- ${o3}`).join("\n")}` : "";
19646
19672
  function removeCard(card) {
19647
19673
  dropCrossRefs(card.id);
19648
19674
  const target = card.folder ?? card.file;
19649
- stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path61.relative(TODO, target).split(path61.sep).join("/") });
19650
- fs58.rmSync(target, { recursive: true, force: true });
19675
+ stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path62.relative(TODO, target).split(path62.sep).join("/") });
19676
+ fs59.rmSync(target, { recursive: true, force: true });
19651
19677
  }
19652
19678
  function migrateCard(card) {
19653
- const { meta, body } = parseFrontmatter(fs58.readFileSync(card.file, "utf8"));
19679
+ const { meta, body } = parseFrontmatter(fs59.readFileSync(card.file, "utf8"));
19654
19680
  if (!meta) throw new Error("its frontmatter cannot be read");
19655
19681
  const raw = meta;
19656
19682
  const said3 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
@@ -19660,19 +19686,19 @@ function migrateCard(card) {
19660
19686
  if (!flow) throw new Error(noWorkflowMessage(""));
19661
19687
  const text5 = (name2) => agentText(name2, meta.title || card.slug, body);
19662
19688
  const name = agentName(card, text5);
19663
- const dir = path61.join(AGENTS, name);
19664
- const file = path61.join(dir, AGENT_FILE2);
19665
- const madeDir = !fs58.existsSync(dir);
19666
- const wrote = !fs58.existsSync(file);
19689
+ const dir = path62.join(AGENTS, name);
19690
+ const file = path62.join(dir, AGENT_FILE2);
19691
+ const madeDir = !fs59.existsSync(dir);
19692
+ const wrote = !fs59.existsSync(file);
19667
19693
  try {
19668
- fs58.mkdirSync(dir, { recursive: true });
19669
- if (wrote) fs58.writeFileSync(file, text5(name));
19694
+ fs59.mkdirSync(dir, { recursive: true });
19695
+ if (wrote) fs59.writeFileSync(file, text5(name));
19670
19696
  const adopted = adoptWorkflowScheduled(flow.id, name, { cadence, lastRun });
19671
19697
  if (!adopted.ok) throw new Error(adopted.error);
19672
19698
  questionsToTriage(meta, name);
19673
19699
  } catch (e2) {
19674
- if (madeDir) fs58.rmSync(dir, { recursive: true, force: true });
19675
- else if (wrote) fs58.rmSync(file, { force: true });
19700
+ if (madeDir) fs59.rmSync(dir, { recursive: true, force: true });
19701
+ else if (wrote) fs59.rmSync(file, { force: true });
19676
19702
  throw e2;
19677
19703
  }
19678
19704
  if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
@@ -19682,7 +19708,7 @@ function migrateCard(card) {
19682
19708
  function migrateRecurringCards() {
19683
19709
  const done2 = { agents: [], removed: [], failed: [] };
19684
19710
  const dir = recurringDir();
19685
- if (!fs58.existsSync(dir)) return done2;
19711
+ if (!fs59.existsSync(dir)) return done2;
19686
19712
  migratePruneMemoryCard();
19687
19713
  moveSideFolders();
19688
19714
  for (const card of legacyCards()) {
@@ -19695,7 +19721,7 @@ function migrateRecurringCards() {
19695
19721
  done2.failed.push({ card: rel(card.file), why: e2 instanceof Error ? e2.message : String(e2) });
19696
19722
  }
19697
19723
  }
19698
- if (isEmpty(dir)) fs58.rmSync(dir, { recursive: true, force: true });
19724
+ if (isEmpty(dir)) fs59.rmSync(dir, { recursive: true, force: true });
19699
19725
  return done2;
19700
19726
  }
19701
19727
  function recurringMigrationLines(done2) {
@@ -19728,14 +19754,14 @@ var init_recurring = __esm({
19728
19754
  PRUNE_SLUG = "prune-the-memory";
19729
19755
  FETCH_SLUG = "fetch-triage-items";
19730
19756
  AGENT_FILE2 = "AGENT.md";
19731
- recurringDir = () => path61.join(TODO, LEGACY_RECURRING);
19732
- isEmpty = (dir) => fs58.readdirSync(dir).every((name) => name === ".DS_Store");
19757
+ recurringDir = () => path62.join(TODO, LEGACY_RECURRING);
19758
+ isEmpty = (dir) => fs59.readdirSync(dir).every((name) => name === ".DS_Store");
19733
19759
  SECTION = /^##\s+(.+?)\s*$/;
19734
19760
  }
19735
19761
  });
19736
19762
 
19737
19763
  // src/commands/init.ts
19738
- import fs59 from "node:fs";
19764
+ import fs60 from "node:fs";
19739
19765
  function boardReadme() {
19740
19766
  return `# Board
19741
19767
 
@@ -19748,20 +19774,20 @@ _(none)_
19748
19774
  `;
19749
19775
  }
19750
19776
  function writeConfigIfMissing() {
19751
- if (fs59.existsSync(CONFIG)) return false;
19752
- fs59.mkdirSync(KANBAN, { recursive: true });
19753
- fs59.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19777
+ if (fs60.existsSync(CONFIG)) return false;
19778
+ fs60.mkdirSync(KANBAN, { recursive: true });
19779
+ fs60.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19754
19780
  return true;
19755
19781
  }
19756
19782
  function writeModulesIfMissing() {
19757
- if (fs59.existsSync(MODULES_MD)) return false;
19758
- fs59.mkdirSync(KANBAN, { recursive: true });
19759
- fs59.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
19783
+ if (fs60.existsSync(MODULES_MD)) return false;
19784
+ fs60.mkdirSync(KANBAN, { recursive: true });
19785
+ fs60.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
19760
19786
  return true;
19761
19787
  }
19762
19788
  function writeGitignoreIfMissing() {
19763
- fs59.mkdirSync(KANBAN, { recursive: true });
19764
- const text5 = fs59.existsSync(KANBAN_GITIGNORE) ? fs59.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
19789
+ fs60.mkdirSync(KANBAN, { recursive: true });
19790
+ const text5 = fs60.existsSync(KANBAN_GITIGNORE) ? fs60.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
19765
19791
  const has = (rule) => text5.split("\n").some((line) => line.trim() === rule.line);
19766
19792
  const missing = IGNORE_RULES.filter((rule) => !has(rule));
19767
19793
  if (!missing.length) return false;
@@ -19769,37 +19795,37 @@ function writeGitignoreIfMissing() {
19769
19795
  ${rule.line}
19770
19796
  `).join("");
19771
19797
  const separator = !text5 || text5.endsWith("\n") ? "" : "\n";
19772
- fs59.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19798
+ fs60.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19773
19799
  return true;
19774
19800
  }
19775
19801
  function writeSkeletonIfMissing() {
19776
19802
  const added = [];
19777
- if (!fs59.existsSync(TODO)) {
19778
- fs59.mkdirSync(TODO, { recursive: true });
19803
+ if (!fs60.existsSync(TODO)) {
19804
+ fs60.mkdirSync(TODO, { recursive: true });
19779
19805
  added.push(`${rel(TODO)}/`);
19780
19806
  }
19781
- if (!fs59.existsSync(README)) {
19782
- fs59.writeFileSync(README, boardReadme());
19807
+ if (!fs60.existsSync(README)) {
19808
+ fs60.writeFileSync(README, boardReadme());
19783
19809
  added.push(rel(README));
19784
19810
  }
19785
19811
  return added;
19786
19812
  }
19787
19813
  function retireReleases() {
19788
19814
  const done2 = [];
19789
- if (fs59.existsSync(RELEASES)) {
19790
- fs59.rmSync(RELEASES);
19815
+ if (fs60.existsSync(RELEASES)) {
19816
+ fs60.rmSync(RELEASES);
19791
19817
  done2.push(`deleted ${rel(RELEASES)}`);
19792
19818
  }
19793
19819
  let cards = 0;
19794
19820
  for (const dir of [TODO, ARCHIVE]) {
19795
- if (!fs59.existsSync(dir)) continue;
19821
+ if (!fs60.existsSync(dir)) continue;
19796
19822
  for (const file of walkMd(dir)) {
19797
- const text5 = fs59.readFileSync(file, "utf8");
19823
+ const text5 = fs60.readFileSync(file, "utf8");
19798
19824
  const end2 = text5.startsWith("---\n") ? text5.indexOf("\n---", 3) : -1;
19799
19825
  if (end2 < 0) continue;
19800
19826
  const head2 = text5.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
19801
19827
  if (head2.length === end2) continue;
19802
- fs59.writeFileSync(file, head2 + text5.slice(end2));
19828
+ fs60.writeFileSync(file, head2 + text5.slice(end2));
19803
19829
  cards++;
19804
19830
  }
19805
19831
  }
@@ -19807,7 +19833,7 @@ function retireReleases() {
19807
19833
  return done2.join(", ");
19808
19834
  }
19809
19835
  function cmdInit() {
19810
- if (fs59.existsSync(KANBAN)) {
19836
+ if (fs60.existsSync(KANBAN)) {
19811
19837
  const added = [
19812
19838
  ...writeSkeletonIfMissing(),
19813
19839
  writeConfigIfMissing() && rel(CONFIG),
@@ -19842,8 +19868,8 @@ function cmdInit() {
19842
19868
  }
19843
19869
  return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
19844
19870
  }
19845
- fs59.mkdirSync(TODO, { recursive: true });
19846
- fs59.writeFileSync(README, boardReadme());
19871
+ fs60.mkdirSync(TODO, { recursive: true });
19872
+ fs60.writeFileSync(README, boardReadme());
19847
19873
  writeConfigIfMissing();
19848
19874
  scaffoldProjectMemory();
19849
19875
  writeModulesIfMissing();
@@ -19932,25 +19958,25 @@ var init_scheduled = __esm({
19932
19958
  });
19933
19959
 
19934
19960
  // src/lib/card-age.ts
19935
- import fs60 from "node:fs";
19936
- import path62 from "node:path";
19961
+ import fs61 from "node:fs";
19962
+ import path63 from "node:path";
19937
19963
  function staleAfterIn(config) {
19938
19964
  const days = Number(LINE.exec(config)?.[1]);
19939
19965
  return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
19940
19966
  }
19941
19967
  function staleAfter() {
19942
- if (!fs60.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
19943
- return staleAfterIn(fs60.readFileSync(CONFIG, "utf8"));
19968
+ if (!fs61.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
19969
+ return staleAfterIn(fs61.readFileSync(CONFIG, "utf8"));
19944
19970
  }
19945
19971
  function todoPathspec(top) {
19946
- const from = path62.relative(real(top), real(TODO));
19947
- if (!from || from.startsWith("..") || path62.isAbsolute(from)) return null;
19948
- return from.split(path62.sep).join("/");
19972
+ const from = path63.relative(real(top), real(TODO));
19973
+ if (!from || from.startsWith("..") || path63.isAbsolute(from)) return null;
19974
+ return from.split(path63.sep).join("/");
19949
19975
  }
19950
19976
  function cardFile2(spec, printed) {
19951
19977
  const p2 = unquotePath(printed);
19952
19978
  if (!p2.startsWith(`${spec}/`)) return null;
19953
- return path62.join(TODO, ...p2.slice(spec.length + 1).split("/"));
19979
+ return path63.join(TODO, ...p2.slice(spec.length + 1).split("/"));
19954
19980
  }
19955
19981
  function dirtyCards(top, spec) {
19956
19982
  const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
@@ -19997,9 +20023,9 @@ var init_card_age = __esm({
19997
20023
  gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
19998
20024
  real = (p2) => {
19999
20025
  try {
20000
- return fs60.realpathSync(p2);
20026
+ return fs61.realpathSync(p2);
20001
20027
  } catch {
20002
- return path62.resolve(p2);
20028
+ return path63.resolve(p2);
20003
20029
  }
20004
20030
  };
20005
20031
  unquotePath = (line) => {
@@ -20034,8 +20060,8 @@ var init_card_holds = __esm({
20034
20060
  });
20035
20061
 
20036
20062
  // src/commands/list.ts
20037
- import fs61 from "node:fs";
20038
- import path63 from "node:path";
20063
+ import fs62 from "node:fs";
20064
+ import path64 from "node:path";
20039
20065
  function summaryLine(body) {
20040
20066
  const lines = body.split("\n");
20041
20067
  let i = 0;
@@ -20051,13 +20077,13 @@ function summaryLine(body) {
20051
20077
  function openRows() {
20052
20078
  const rows = [];
20053
20079
  for (const file of walkMd(TODO)) {
20054
- const base = path63.basename(file);
20080
+ const base = path64.basename(file);
20055
20081
  if (base === "README.md") continue;
20056
20082
  const isRoot = base === "root.md";
20057
- const id = isRoot ? idPrefix(path63.basename(path63.dirname(file))) : idPrefix(base);
20083
+ const id = isRoot ? idPrefix(path64.basename(path64.dirname(file))) : idPrefix(base);
20058
20084
  if (id == null) continue;
20059
- if (isLegacyRecurring(path63.relative(TODO, file))) continue;
20060
- const { meta, body } = parseFrontmatter(fs61.readFileSync(file, "utf8"));
20085
+ if (isLegacyRecurring(path64.relative(TODO, file))) continue;
20086
+ const { meta, body } = parseFrontmatter(fs62.readFileSync(file, "utf8"));
20061
20087
  rows.push({
20062
20088
  id,
20063
20089
  file,
@@ -20099,15 +20125,15 @@ function cmdStale(rows, all2, scope, mod) {
20099
20125
  }
20100
20126
  function archivedFiles() {
20101
20127
  const files2 = /* @__PURE__ */ new Map();
20102
- if (!fs61.existsSync(ARCHIVE)) return files2;
20128
+ if (!fs62.existsSync(ARCHIVE)) return files2;
20103
20129
  for (const file of walkMd(ARCHIVE)) {
20104
- const id = idPrefix(path63.basename(file));
20130
+ const id = idPrefix(path64.basename(file));
20105
20131
  if (id !== null) files2.set(id, file);
20106
20132
  }
20107
20133
  for (const dir of walkDirs(ARCHIVE)) {
20108
- const id = idPrefix(path63.basename(dir));
20109
- const root2 = path63.join(dir, "root.md");
20110
- if (id !== null && fs61.existsSync(root2)) files2.set(id, root2);
20134
+ const id = idPrefix(path64.basename(dir));
20135
+ const root2 = path64.join(dir, "root.md");
20136
+ if (id !== null && fs62.existsSync(root2)) files2.set(id, root2);
20111
20137
  }
20112
20138
  return files2;
20113
20139
  }
@@ -20218,14 +20244,14 @@ var init_list = __esm({
20218
20244
  });
20219
20245
 
20220
20246
  // src/commands/misc.ts
20221
- import fs62 from "node:fs";
20222
- import path64 from "node:path";
20247
+ import fs63 from "node:fs";
20248
+ import path65 from "node:path";
20223
20249
  function extractOldMeta(text5, file) {
20224
20250
  const grab = (re3) => {
20225
20251
  const m = text5.match(re3);
20226
20252
  return m ? m[1].trim() : null;
20227
20253
  };
20228
- const title = grab(/^#\s+(.+)$/m) || slugify(path64.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
20254
+ const title = grab(/^#\s+(.+)$/m) || slugify(path65.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
20229
20255
  const norm = (raw) => {
20230
20256
  const v = (raw || "").toLowerCase();
20231
20257
  return LEVELS.includes(v) ? v : "med";
@@ -20252,11 +20278,11 @@ function stripOldHeader(text5) {
20252
20278
  }
20253
20279
  function cmdMigrate(opts) {
20254
20280
  const dry = opts.dryRun === true;
20255
- const files2 = walkMd(TODO).filter((f2) => path64.basename(f2) !== "README.md");
20281
+ const files2 = walkMd(TODO).filter((f2) => path65.basename(f2) !== "README.md");
20256
20282
  let changed = 0;
20257
20283
  let skipped = 0;
20258
20284
  for (const file of files2) {
20259
- const text5 = fs62.readFileSync(file, "utf8");
20285
+ const text5 = fs63.readFileSync(file, "utf8");
20260
20286
  if (text5.trimStart().startsWith("---")) {
20261
20287
  skipped++;
20262
20288
  continue;
@@ -20265,7 +20291,7 @@ function cmdMigrate(opts) {
20265
20291
  const out = serializeFrontmatter(meta) + "\n\n" + stripOldHeader(text5).replace(/^\n+/, "");
20266
20292
  if (dry) say(`would migrate ${rel(file)} (priority=${meta.priority})`);
20267
20293
  else {
20268
- fs62.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
20294
+ fs63.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
20269
20295
  say(`migrated ${rel(file)}`);
20270
20296
  }
20271
20297
  changed++;
@@ -20286,8 +20312,8 @@ var init_misc = __esm({
20286
20312
  });
20287
20313
 
20288
20314
  // src/lib/card-sources.ts
20289
- import fs63 from "node:fs";
20290
- import path65 from "node:path";
20315
+ import fs64 from "node:fs";
20316
+ import path66 from "node:path";
20291
20317
  function planById(id) {
20292
20318
  const found2 = readPlan(`plans/${id}-.md`);
20293
20319
  return found2?.text.trim() ? found2 : null;
@@ -20297,8 +20323,8 @@ function cardLink(id) {
20297
20323
  const found2 = open3 ?? locateArchived(id);
20298
20324
  if (!found2) return null;
20299
20325
  try {
20300
- const file = found2.kind === "group" ? path65.join(found2.target, "root.md") : found2.target;
20301
- const title = parseFrontmatter(fs63.readFileSync(file, "utf8")).meta?.title ?? "";
20326
+ const file = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
20327
+ const title = parseFrontmatter(fs64.readFileSync(file, "utf8")).meta?.title ?? "";
20302
20328
  return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
20303
20329
  } catch {
20304
20330
  return null;
@@ -20323,7 +20349,7 @@ function link(ref, items) {
20323
20349
  if (ref.kind === "plan") return planLink(ref.id);
20324
20350
  if (ref.kind === "card") return cardLink(ref.id);
20325
20351
  if (ref.kind === "url") return urlLink(ref.url);
20326
- const item = items().find((signal2) => path65.basename(signal2.relPath) === ref.file);
20352
+ const item = items().find((signal2) => path66.basename(signal2.relPath) === ref.file);
20327
20353
  return item ? itemLink(item) : null;
20328
20354
  }
20329
20355
  function cardSources(meta, body) {
@@ -20364,12 +20390,12 @@ var init_card_sources = __esm({
20364
20390
  });
20365
20391
 
20366
20392
  // src/lib/view/read.ts
20367
- import fs64 from "node:fs";
20368
- import path66 from "node:path";
20393
+ import fs65 from "node:fs";
20394
+ import path67 from "node:path";
20369
20395
  function readCard(file, relFromTodo) {
20370
- const id = idPrefix(path66.basename(relFromTodo));
20396
+ const id = idPrefix(path67.basename(relFromTodo));
20371
20397
  if (id === null) {
20372
- const parts = relFromTodo.split(path66.sep);
20398
+ const parts = relFromTodo.split(path67.sep);
20373
20399
  const folderId = idPrefix(parts[parts.length - 2] || "");
20374
20400
  if (folderId === null) return null;
20375
20401
  return buildCard(folderId, file, relFromTodo);
@@ -20377,10 +20403,10 @@ function readCard(file, relFromTodo) {
20377
20403
  return buildCard(id, file, relFromTodo);
20378
20404
  }
20379
20405
  function buildCard(id, file, relFromTodo) {
20380
- const text5 = fs64.readFileSync(file, "utf8");
20406
+ const text5 = fs65.readFileSync(file, "utf8");
20381
20407
  const { meta, body } = parseFrontmatter(text5);
20382
20408
  if (!meta) return null;
20383
- const relPath = relFromTodo.split(path66.sep).join("/");
20409
+ const relPath = relFromTodo.split(path67.sep).join("/");
20384
20410
  const flow = workflowFor(meta.workflow);
20385
20411
  const plan = !!meta.workflow && archivesOnApproval(flow);
20386
20412
  const stages = cardStages(meta, flow).length;
@@ -20389,7 +20415,7 @@ function buildCard(id, file, relFromTodo) {
20389
20415
  // Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
20390
20416
  // read here and a card read by the contract agree on what version this is.
20391
20417
  revision: revisionOf(text5),
20392
- updatedAt: fs64.statSync(file).mtime.toISOString(),
20418
+ updatedAt: fs65.statSync(file).mtime.toISOString(),
20393
20419
  relPath,
20394
20420
  title: meta.title,
20395
20421
  priority: meta.priority,
@@ -20410,22 +20436,22 @@ function buildCard(id, file, relFromTodo) {
20410
20436
  };
20411
20437
  }
20412
20438
  function readGroup2(folderName) {
20413
- const groupDir = path66.join(TODO, folderName);
20414
- const rootFile = path66.join(groupDir, "root.md");
20415
- if (!fs64.existsSync(rootFile)) return null;
20416
- const root2 = readCard(rootFile, path66.join(folderName, "root.md"));
20439
+ const groupDir = path67.join(TODO, folderName);
20440
+ const rootFile = path67.join(groupDir, "root.md");
20441
+ if (!fs65.existsSync(rootFile)) return null;
20442
+ const root2 = readCard(rootFile, path67.join(folderName, "root.md"));
20417
20443
  if (!root2) return null;
20418
20444
  root2.isGroup = true;
20419
20445
  const { total, resolved: resolved2 } = subtaskLines(root2.body);
20420
20446
  root2.subtaskLines = { total, resolved: resolved2 };
20421
20447
  const subCards = [];
20422
20448
  const recurse = (dir, relDir) => {
20423
- for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20424
- const childRel = path66.join(relDir, entry.name);
20449
+ for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
20450
+ const childRel = path67.join(relDir, entry.name);
20425
20451
  if (entry.isDirectory()) {
20426
- recurse(path66.join(dir, entry.name), childRel);
20452
+ recurse(path67.join(dir, entry.name), childRel);
20427
20453
  } else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
20428
- const c2 = readCard(path66.join(dir, entry.name), childRel);
20454
+ const c2 = readCard(path67.join(dir, entry.name), childRel);
20429
20455
  if (c2) {
20430
20456
  c2.parent = { id: root2.id, title: root2.title };
20431
20457
  subCards.push(c2);
@@ -20446,12 +20472,12 @@ function readGroup2(folderName) {
20446
20472
  return { root: root2, subCards };
20447
20473
  }
20448
20474
  function standaloneCards(dirRel) {
20449
- const dir = dirRel ? path66.join(TODO, dirRel) : TODO;
20450
- if (!fs64.existsSync(dir)) return [];
20475
+ const dir = dirRel ? path67.join(TODO, dirRel) : TODO;
20476
+ if (!fs65.existsSync(dir)) return [];
20451
20477
  const cards = [];
20452
- for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20478
+ for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
20453
20479
  if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
20454
- const c2 = readCard(path66.join(dir, entry.name), path66.join(dirRel, entry.name));
20480
+ const c2 = readCard(path67.join(dir, entry.name), path67.join(dirRel, entry.name));
20455
20481
  if (c2) cards.push(c2);
20456
20482
  }
20457
20483
  }
@@ -20463,7 +20489,7 @@ function collectCards() {
20463
20489
  const top = standaloneCards("");
20464
20490
  board2.push(...top);
20465
20491
  every.push(...top);
20466
- for (const entry of fs64.readdirSync(TODO, { withFileTypes: true })) {
20492
+ for (const entry of fs65.readdirSync(TODO, { withFileTypes: true })) {
20467
20493
  if (!entry.isDirectory()) continue;
20468
20494
  if (isGroupFolder(entry.name)) {
20469
20495
  const g3 = readGroup2(entry.name);
@@ -20495,7 +20521,7 @@ function findCard(id) {
20495
20521
  }
20496
20522
  function attachSources(card) {
20497
20523
  try {
20498
- const { meta, body } = parseFrontmatter(fs64.readFileSync(path66.join(TODO, card.relPath), "utf8"));
20524
+ const { meta, body } = parseFrontmatter(fs65.readFileSync(path67.join(TODO, card.relPath), "utf8"));
20499
20525
  const sources2 = meta ? cardSources(meta, body) : [];
20500
20526
  if (sources2.length) card.sources = sources2;
20501
20527
  } catch {
@@ -20600,10 +20626,10 @@ var init_read = __esm({
20600
20626
  });
20601
20627
 
20602
20628
  // src/lib/group-close.ts
20603
- import fs65 from "node:fs";
20629
+ import fs66 from "node:fs";
20604
20630
  function groupCloses(rootFile) {
20605
20631
  try {
20606
- return groupCloseOf(fs65.readFileSync(rootFile, "utf8"));
20632
+ return groupCloseOf(fs66.readFileSync(rootFile, "utf8"));
20607
20633
  } catch {
20608
20634
  return false;
20609
20635
  }
@@ -20616,12 +20642,12 @@ var init_group_close = __esm({
20616
20642
  });
20617
20643
 
20618
20644
  // src/commands/remove.ts
20619
- import fs66 from "node:fs";
20620
- import path67 from "node:path";
20645
+ import fs67 from "node:fs";
20646
+ import path68 from "node:path";
20621
20647
  function leavingIds(id, found2) {
20622
20648
  const ids = /* @__PURE__ */ new Set([id]);
20623
20649
  if (found2.kind === "group") {
20624
- const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path67.basename(f2));
20650
+ const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path68.basename(f2));
20625
20651
  for (const name of names3) {
20626
20652
  const n = idPrefix(name);
20627
20653
  if (n !== null) ids.add(n);
@@ -20633,10 +20659,10 @@ function findMentions(ids) {
20633
20659
  const hits = [];
20634
20660
  const re3 = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
20635
20661
  for (const dir of [TODO, MEMORY]) {
20636
- if (!fs66.existsSync(dir)) continue;
20662
+ if (!fs67.existsSync(dir)) continue;
20637
20663
  for (const file of walkMd(dir)) {
20638
- if (path67.basename(file) === "README.md") continue;
20639
- const lines = fs66.readFileSync(file, "utf8").split("\n");
20664
+ if (path68.basename(file) === "README.md") continue;
20665
+ const lines = fs67.readFileSync(file, "utf8").split("\n");
20640
20666
  const fmEnd = frontmatterEnd(lines);
20641
20667
  lines.forEach((line, i) => {
20642
20668
  if (!re3.test(line)) return;
@@ -20652,12 +20678,12 @@ function findMentions(ids) {
20652
20678
  return hits;
20653
20679
  }
20654
20680
  function leavingCards(id, found2) {
20655
- const own = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
20681
+ const own = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20656
20682
  const cards = [{ id, file: own }];
20657
20683
  if (found2.kind !== "group") return cards;
20658
20684
  for (const file of walkMd(found2.target)) {
20659
20685
  if (file === own) continue;
20660
- const n = idPrefix(path67.basename(file));
20686
+ const n = idPrefix(path68.basename(file));
20661
20687
  if (n !== null) cards.push({ id: n, file });
20662
20688
  }
20663
20689
  return cards;
@@ -20666,10 +20692,10 @@ function stampLeaving(cards, rejection) {
20666
20692
  const day = formatDay();
20667
20693
  const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
20668
20694
  for (const card of cards) {
20669
- if (!fs66.existsSync(card.file)) continue;
20670
- const text5 = fs66.readFileSync(card.file, "utf8");
20695
+ if (!fs67.existsSync(card.file)) continue;
20696
+ const text5 = fs67.readFileSync(card.file, "utf8");
20671
20697
  const stamped = stampLeavingIn(text5, day, stamp4);
20672
- if (stamped !== text5) fs66.writeFileSync(card.file, stamped);
20698
+ if (stamped !== text5) fs67.writeFileSync(card.file, stamped);
20673
20699
  }
20674
20700
  }
20675
20701
  function unfinishedDelivery(id) {
@@ -20685,7 +20711,7 @@ function unfinishedDelivery(id) {
20685
20711
  }[gap];
20686
20712
  return `#${id} is not finished: ${what}.`;
20687
20713
  }
20688
- const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs66.existsSync(path67.join(ASSETS, src.slice(".assets/".length))));
20714
+ const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs67.existsSync(path68.join(ASSETS, src.slice(".assets/".length))));
20689
20715
  return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
20690
20716
  }
20691
20717
  function agentDecisions(text5) {
@@ -20716,8 +20742,8 @@ function removeCard2(id, metric, options) {
20716
20742
  const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
20717
20743
  if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
20718
20744
  const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
20719
- const cardFile3 = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
20720
- const cardText = fs66.existsSync(cardFile3) ? fs66.readFileSync(cardFile3, "utf8") : "";
20745
+ const cardFile3 = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20746
+ const cardText = fs67.existsSync(cardFile3) ? fs67.readFileSync(cardFile3, "utf8") : "";
20721
20747
  const { meta: cardMeta3 } = parseFrontmatter(cardText);
20722
20748
  const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f2) => f2 !== cardFile3).map((f2) => rel(f2)).sort() : [];
20723
20749
  const leftIds = leavingIds(id, found2);
@@ -20748,10 +20774,10 @@ function removeCard2(id, metric, options) {
20748
20774
  const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
20749
20775
  if (dest) {
20750
20776
  stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
20751
- fs66.mkdirSync(ARCHIVE, { recursive: true });
20752
- fs66.renameSync(found2.target, dest);
20777
+ fs67.mkdirSync(ARCHIVE, { recursive: true });
20778
+ fs67.renameSync(found2.target, dest);
20753
20779
  } else {
20754
- fs66.rmSync(found2.target, { recursive: true, force: true });
20780
+ fs67.rmSync(found2.target, { recursive: true, force: true });
20755
20781
  }
20756
20782
  const removedRefs = stripReadmeRefs(found2);
20757
20783
  let marked2 = null;
@@ -20800,14 +20826,14 @@ function removeCard2(id, metric, options) {
20800
20826
  };
20801
20827
  }
20802
20828
  function closeGroup(rootFile) {
20803
- const rootId = idPrefix(path67.basename(path67.dirname(rootFile)));
20829
+ const rootId = idPrefix(path68.basename(path68.dirname(rootFile)));
20804
20830
  if (rootId === null) return null;
20805
20831
  if (runnerProject(KANBAN)) return null;
20806
20832
  if (!groupCloses(rootFile)) return null;
20807
20833
  say(`
20808
20834
  every subtask line on #${rootId} is resolved \u2014 closing the group:`);
20809
20835
  try {
20810
- const { meta, body } = parseFrontmatter(fs66.readFileSync(rootFile, "utf8"));
20836
+ const { meta, body } = parseFrontmatter(fs67.readFileSync(rootFile, "utf8"));
20811
20837
  const res = cmdRemove(rootId, "completed", { closing: true });
20812
20838
  return {
20813
20839
  id: rootId,
@@ -20864,7 +20890,7 @@ function cleanupDiscardedCards(sessionId) {
20864
20890
  if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
20865
20891
  while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
20866
20892
  dropCrossRefs(card.id);
20867
- stripReadmeRefs({ kind: "file", rel: path67.relative(TODO, path67.resolve(REPO_ROOT, card.path)).split(path67.sep).join("/") });
20893
+ stripReadmeRefs({ kind: "file", rel: path68.relative(TODO, path68.resolve(REPO_ROOT, card.path)).split(path68.sep).join("/") });
20868
20894
  }
20869
20895
  return discarded.map((c2) => c2.id);
20870
20896
  });
@@ -20872,8 +20898,8 @@ function cleanupDiscardedCards(sessionId) {
20872
20898
  function recoveredArchiveHandoff(id, source) {
20873
20899
  const found2 = locateArchived(id);
20874
20900
  if (!found2) throw new Error(`No archived card #${id} was found.`);
20875
- const file = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
20876
- const { meta } = parseFrontmatter(fs66.readFileSync(file, "utf8"));
20901
+ const file = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
20902
+ const { meta } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
20877
20903
  stripReadmeRefs(source ?? found2);
20878
20904
  const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
20879
20905
  if (root2) markSubtask(root2, id, "tick");
@@ -20971,8 +20997,8 @@ var init_memory_file = __esm({
20971
20997
  });
20972
20998
 
20973
20999
  // src/commands/rule.ts
20974
- import fs67 from "node:fs";
20975
- import path68 from "node:path";
21000
+ import fs68 from "node:fs";
21001
+ import path69 from "node:path";
20976
21002
  function cmdRule(askedName, flags) {
20977
21003
  const agent = askedName.trim();
20978
21004
  if (!agentRoster().some((a2) => a2.name === agent)) {
@@ -20981,7 +21007,7 @@ function cmdRule(askedName, flags) {
20981
21007
  const rule = readRuleText(flags.file, flags.text);
20982
21008
  const res = setAgentRule(agent, rule);
20983
21009
  if (!res.ok) die(res.error);
20984
- const file = rel(path68.join(RULES, `${agent}.md`));
21010
+ const file = rel(path69.join(RULES, `${agent}.md`));
20985
21011
  say(rule ? `wrote the \`${agent}\` rule (${file})` : `cleared the \`${agent}\` rule`);
20986
21012
  return { agent, file, cleared: !rule };
20987
21013
  }
@@ -20989,7 +21015,7 @@ function readRuleText(file, text5) {
20989
21015
  if (file !== void 0 && text5 !== void 0) die("pass --file or --text, not both");
20990
21016
  if (file !== void 0) {
20991
21017
  try {
20992
- return fs67.readFileSync(file, "utf8").trim();
21018
+ return fs68.readFileSync(file, "utf8").trim();
20993
21019
  } catch {
20994
21020
  die(`can't read ${file} \u2014 write the rule to a file, then pass its path`);
20995
21021
  }
@@ -21275,8 +21301,8 @@ var init_created_cards = __esm({
21275
21301
 
21276
21302
  // src/lib/agent/creation.ts
21277
21303
  import crypto4 from "node:crypto";
21278
- import fs68 from "node:fs";
21279
- import path69 from "node:path";
21304
+ import fs69 from "node:fs";
21305
+ import path70 from "node:path";
21280
21306
  function creationError(error, triage) {
21281
21307
  const zh = readLanguage() === "zh";
21282
21308
  const messages = {
@@ -21302,12 +21328,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
21302
21328
  function creationReceipt(request2, slot) {
21303
21329
  const hash2 = crypto4.createHash("sha256").update(`${request2}
21304
21330
  ${slot}`).digest("hex");
21305
- return path69.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21331
+ return path70.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21306
21332
  }
21307
21333
  function readCreation(file, said3) {
21308
21334
  return withCreationLock(() => {
21309
21335
  try {
21310
- const held4 = JSON.parse(fs68.readFileSync(file, "utf8"));
21336
+ const held4 = JSON.parse(fs69.readFileSync(file, "utf8"));
21311
21337
  if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
21312
21338
  return held4;
21313
21339
  } catch (error) {
@@ -21319,10 +21345,10 @@ function readCreation(file, said3) {
21319
21345
  });
21320
21346
  }
21321
21347
  function saveCreation(file, journal) {
21322
- fs68.mkdirSync(path69.dirname(file), { recursive: true });
21348
+ fs69.mkdirSync(path70.dirname(file), { recursive: true });
21323
21349
  const temp = `${file}.${crypto4.randomUUID()}.tmp`;
21324
- fs68.writeFileSync(temp, JSON.stringify(journal));
21325
- fs68.renameSync(temp, file);
21350
+ fs69.writeFileSync(temp, JSON.stringify(journal));
21351
+ fs69.renameSync(temp, file);
21326
21352
  }
21327
21353
  function archiveCreation(source, id) {
21328
21354
  if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
@@ -21336,7 +21362,7 @@ function archiveCreation(source, id) {
21336
21362
  function triageFile(sourceId) {
21337
21363
  const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
21338
21364
  if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
21339
- return path69.basename(found2.relPath, ".md");
21365
+ return path70.basename(found2.relPath, ".md");
21340
21366
  }
21341
21367
  var init_creation = __esm({
21342
21368
  "src/lib/agent/creation.ts"() {
@@ -21482,7 +21508,7 @@ function ordered(into) {
21482
21508
  };
21483
21509
  }
21484
21510
  var HELP_WIDTH, collect2;
21485
- var init_shared = __esm({
21511
+ var init_shared2 = __esm({
21486
21512
  "src/lib/cli/shared.ts"() {
21487
21513
  "use strict";
21488
21514
  init_esm();
@@ -21500,8 +21526,8 @@ __export(board_exports, {
21500
21526
  buildBoardProgram: () => buildBoardProgram
21501
21527
  });
21502
21528
  import crypto5 from "node:crypto";
21503
- import fs69 from "node:fs";
21504
- import path70 from "node:path";
21529
+ import fs70 from "node:fs";
21530
+ import path71 from "node:path";
21505
21531
  async function dispatch(move, cmd, args, opts, cli) {
21506
21532
  const ctx = ctxOf(cmd, cli.program);
21507
21533
  const data = await runAction(ctx, {}, async () => {
@@ -21541,7 +21567,7 @@ async function cloudCard(task, opts) {
21541
21567
  let request2;
21542
21568
  if (typeof opts.bodyFile === "string") {
21543
21569
  try {
21544
- request2 = fs69.readFileSync(opts.bodyFile, "utf8");
21570
+ request2 = fs70.readFileSync(opts.bodyFile, "utf8");
21545
21571
  } catch {
21546
21572
  }
21547
21573
  }
@@ -21571,7 +21597,7 @@ async function cloudCard(task, opts) {
21571
21597
  const file = creationReceipt(`${checked.value}:${requestId}`, slot);
21572
21598
  const journal = readCreation(file, said3);
21573
21599
  if (!journal.made) {
21574
- const key = `akb-${path70.basename(file, ".json").slice(0, 40)}`;
21600
+ const key = `akb-${path71.basename(file, ".json").slice(0, 40)}`;
21575
21601
  const made = await createProjectTask(checked.value, journal.said, key);
21576
21602
  if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
21577
21603
  journal.made = made.value;
@@ -21703,7 +21729,7 @@ var init_board2 = __esm({
21703
21729
  init_board_cli();
21704
21730
  init_cloud_workflows();
21705
21731
  init_validate();
21706
- init_shared();
21732
+ init_shared2();
21707
21733
  init_esm();
21708
21734
  init_tasks();
21709
21735
  init_card();
@@ -21713,17 +21739,17 @@ var init_board2 = __esm({
21713
21739
  });
21714
21740
 
21715
21741
  // src/lib/board-cli.ts
21716
- import fs70 from "node:fs";
21717
- import path71 from "node:path";
21742
+ import fs71 from "node:fs";
21743
+ import path72 from "node:path";
21718
21744
  function useBoard(found2, dirNamed) {
21719
- if (!found2.named && found2.board === path71.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21745
+ if (!found2.named && found2.board === path72.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21720
21746
  else setBoardDir(found2.board, found2.root);
21721
21747
  useProjectState();
21722
21748
  backfillCardWorkflows();
21723
21749
  }
21724
21750
  function whole(found2, move) {
21725
21751
  if (move === MAKES_A_BOARD) return found2;
21726
- if (!fs70.existsSync(path71.join(found2.board, "todo"))) {
21752
+ if (!fs71.existsSync(path72.join(found2.board, "todo"))) {
21727
21753
  die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
21728
21754
  kind: "board-incomplete",
21729
21755
  dir: found2.root
@@ -21732,13 +21758,13 @@ function whole(found2, move) {
21732
21758
  return found2;
21733
21759
  }
21734
21760
  function findBoardUpward(from, move) {
21735
- let dir = path71.resolve(from);
21761
+ let dir = path72.resolve(from);
21736
21762
  for (; ; ) {
21737
- if (hasBoard(dir)) return { root: dir, board: path71.join(dir, "docs", "kanban") };
21763
+ if (hasBoard(dir)) return { root: dir, board: path72.join(dir, "docs", "kanban") };
21738
21764
  if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
21739
- const kept2 = path71.join(dir, ".akb", "kanban");
21740
- if (move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return { root: dir, board: kept2 };
21741
- const up = path71.dirname(dir);
21765
+ const kept2 = path72.join(dir, ".akb", "kanban");
21766
+ if (move !== MAKES_A_BOARD && fs71.existsSync(path72.join(kept2, "todo"))) return { root: dir, board: kept2 };
21767
+ const up = path72.dirname(dir);
21742
21768
  if (up === dir) return null;
21743
21769
  dir = up;
21744
21770
  }
@@ -21746,11 +21772,11 @@ function findBoardUpward(from, move) {
21746
21772
  function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21747
21773
  const named2 = board2 ?? boardFromEnv();
21748
21774
  if (named2) {
21749
- const folder = path71.resolve(cwd, named2);
21750
- if (!fs70.existsSync(folder) && move !== MAKES_A_BOARD) {
21775
+ const folder = path72.resolve(cwd, named2);
21776
+ if (!fs71.existsSync(folder) && move !== MAKES_A_BOARD) {
21751
21777
  die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
21752
21778
  }
21753
- if (fs70.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21779
+ if (fs71.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21754
21780
  die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
21755
21781
  kind: "no-board",
21756
21782
  dir: folder
@@ -21759,24 +21785,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21759
21785
  return { root: projectRootOf(folder), board: folder, named: true };
21760
21786
  }
21761
21787
  if (dir !== null) {
21762
- const root2 = path71.resolve(dir);
21763
- if (!fs70.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
21764
- const kept2 = path71.join(root2, ".akb", "kanban");
21765
- if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
21788
+ const root2 = path72.resolve(dir);
21789
+ if (!fs71.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
21790
+ const kept2 = path72.join(root2, ".akb", "kanban");
21791
+ if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs71.existsSync(path72.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
21766
21792
  if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
21767
21793
  die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
21768
21794
  kind: "no-board",
21769
21795
  dir: root2
21770
21796
  });
21771
21797
  }
21772
- return whole({ root: root2, board: path71.join(root2, "docs", "kanban") }, move);
21798
+ return whole({ root: root2, board: path72.join(root2, "docs", "kanban") }, move);
21773
21799
  }
21774
21800
  const found2 = findBoardUpward(cwd, move);
21775
21801
  if (found2) return whole(found2, move);
21776
- if (move === MAKES_A_BOARD) return { root: path71.resolve(cwd), board: path71.join(path71.resolve(cwd), "docs", "kanban") };
21802
+ if (move === MAKES_A_BOARD) return { root: path72.resolve(cwd), board: path72.join(path72.resolve(cwd), "docs", "kanban") };
21777
21803
  die(
21778
- `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`,
21779
- { kind: "no-board", dir: path71.resolve(cwd) }
21804
+ `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`,
21805
+ { kind: "no-board", dir: path72.resolve(cwd) }
21780
21806
  );
21781
21807
  }
21782
21808
  function editDistance(a2, b2) {
@@ -21805,7 +21831,7 @@ async function runBoard(argv, options = {}) {
21805
21831
  onAnswer
21806
21832
  } = options;
21807
21833
  const { buildBoardProgram: buildBoardProgram2 } = await Promise.resolve().then(() => (init_board2(), board_exports));
21808
- const { runProgram: runProgram2 } = await Promise.resolve().then(() => (init_shared(), shared_exports));
21834
+ const { runProgram: runProgram2 } = await Promise.resolve().then(() => (init_shared2(), shared_exports));
21809
21835
  return runProgram2(buildBoardProgram2({ program: program2, cwd, installHint, version, onAnswer }), argv, program2);
21810
21836
  }
21811
21837
  function rawArgv(argv) {
@@ -21859,8 +21885,8 @@ var init_board_cli = __esm({
21859
21885
  init_pointer();
21860
21886
  init_card_workflow_backfill();
21861
21887
  MAKES_A_BOARD = "init";
21862
- hasBoard = (dir) => fs70.existsSync(path71.join(dir, "docs", "kanban"));
21863
- isBoardDir = (dir) => fs70.existsSync(path71.join(dir, "todo")) && fs70.existsSync(path71.join(dir, "config.md"));
21888
+ hasBoard = (dir) => fs71.existsSync(path72.join(dir, "docs", "kanban"));
21889
+ isBoardDir = (dir) => fs71.existsSync(path72.join(dir, "todo")) && fs71.existsSync(path72.join(dir, "config.md"));
21864
21890
  boardFromEnv = () => {
21865
21891
  const named2 = process.env.AI4KANBAN_BOARD?.trim();
21866
21892
  return named2 ? named2 : null;
@@ -21920,7 +21946,7 @@ var init_discuss_goal = __esm({
21920
21946
  var follow_up_default;
21921
21947
  var init_follow_up = __esm({
21922
21948
  "src/guide/follow-up.md"() {
21923
- follow_up_default = '# Handle follow-up work\n\nUse when planning or implementation discovers additional work.\n\n- **Current task**: finish required work on this card; queue independent follow-ups in triage, then resume the original task.\n- **Drop what was turned down**: queue nothing that\n `docs/kanban/memory/agents/planner/rejected.md` or\n `docs/kanban/memory/agents/planner/*/rejected.md` turns down.\n- **Existing card**: when only another open card needs changing, run `akb card revise <id> "<the change and why>"`.\n- **Queue it**: use the command below; skip an item the command reports as already there.\n- **Workflow**: use the source card\'s `workflow:`, or the id from `akb workflow list` that fits the work when it has none.\n\n```text\nakb triage add --title "<one line>" --slug <short-english-slug> --source "#<id>" --workflow <workflow> --text "<body>"\n```\n\n## Write the item\n\n- **Reader**: someone who has read neither the original card nor the code can decide in ten seconds whether the work is worth doing.\n- **Order**: first explain what happened and what the user runs into, then say what the work would do.\n- **Plain words**: keep file, function and field names, card ids, agent names and evidence trails out of the title and body.\n';
21949
+ follow_up_default = '# Handle follow-up work\n\nUse when planning or implementation discovers additional work.\n\n- **Current task**: finish required work on this card; queue independent follow-ups in triage, then resume the original task.\n- **Drop what was turned down**: queue nothing that\n `docs/kanban/memory/agents/planner/rejected.md` or\n `docs/kanban/memory/agents/planner/*/rejected.md` turns down.\n- **Existing card**: when only another open card needs changing, run `akb card revise <id> "<the change and why>"`.\n- **Queue it**: use the command below; skip an item the command reports as already there.\n- **Workflow**: use the source card\'s `workflow:`, or the id from `akb workflow list` that fits the work when it has none.\n\n```text\nakb triage add --title "<one line>" --slug <short-english-slug> --source "#<id>" --workflow <workflow> --text "<body>"\n```\n\n## Write the item\n\nWrite each item\'s title and body in the **Goal format** of `akb guide discuss-goal`.\n';
21924
21950
  }
21925
21951
  });
21926
21952
 
@@ -21976,7 +22002,7 @@ var init_refine = __esm({
21976
22002
  var reflect_default;
21977
22003
  var init_reflect = __esm({
21978
22004
  "src/guide/reflect.md"() {
21979
- reflect_default = '# Reflect on completed cards\n\n## Read\n\nRead each given `<card>` in full and check its own `shipped` content; keep cards separate.\nFind needs the work left behind or revealed, and verify them in the project. Proposing nothing is fine.\n\n## Filter\n\n- **Duplicates**: check `akb raw list` and `akb triage check <source-id>`; propose shared work only once.\n- **Exclude**: skip unsupported guesses, work covered by `<scheduled-agents>`, work rejected in `docs/kanban/memory/agents/planner/rejected.md` or its module folders, and calls the user reversed, in any `redesign.md` under `docs/kanban/memory/agents/` or under a card\'s `Overruled by the user`.\n- **Existing cards**: when shipped work invalidates an open card\'s plan, run `akb card revise <id> "<the change and why>"` instead of proposing an item.\n\n## Write\n\n- **Reader**: someone who has read neither the original card nor the code can decide in ten seconds whether the work is worth doing.\n- **Order**: first explain what happened and what the user runs into, then say what the work would do.\n- **Plain words**: keep file, function and field names, card ids, agent names and evidence trails out of the title and body.\n\nWrite the body to a temporary Markdown file and end with the source card\'s archive path.\nWrite one triage item per proposal. Exploratory ideas are welcome; identify small chores as such.\nUse the source card\'s `workflow:`, or the id from `akb workflow list` that fits the work when it has none.\n\n```text\nakb triage add --title "<one line>" --slug <short-english-slug> --source "#<id>" --workflow <workflow> --file <body.md>\n```\n\nBriefly report what you proposed and what you skipped, with reasons.\n';
22005
+ reflect_default = '# Reflect on completed cards\n\n## Read\n\nRead each given `<card>` in full and check its own `shipped` content; keep cards separate.\nFind needs the work left behind or revealed, and verify them in the project. Proposing nothing is fine.\n\n## Filter\n\n- **Duplicates**: check `akb raw list` and `akb triage check <source-id>`; propose shared work only once.\n- **Exclude**: skip unsupported guesses, work covered by `<scheduled-agents>`, work rejected in `docs/kanban/memory/agents/planner/rejected.md` or its module folders, and calls the user reversed, in any `redesign.md` under `docs/kanban/memory/agents/` or under a card\'s `Overruled by the user`.\n- **Existing cards**: when shipped work invalidates an open card\'s plan, run `akb card revise <id> "<the change and why>"` instead of proposing an item.\n\n## Write\n\nWrite each item\'s title and body in the **Goal format** of `akb guide discuss-goal`; write the body to a temporary Markdown file and end it with the source card\'s archive path.\nWrite one triage item per proposal. Exploratory ideas are welcome; identify small chores as such.\nUse the source card\'s `workflow:`, or the id from `akb workflow list` that fits the work when it has none.\n\n```text\nakb triage add --title "<one line>" --slug <short-english-slug> --source "#<id>" --workflow <workflow> --file <body.md>\n```\n\nBriefly report what you proposed and what you skipped, with reasons.\n';
21980
22006
  }
21981
22007
  });
21982
22008
 
@@ -22117,8 +22143,8 @@ var init_guide = __esm({
22117
22143
  });
22118
22144
 
22119
22145
  // src/lib/agent/approve.ts
22120
- import fs77 from "node:fs";
22121
- import path78 from "node:path";
22146
+ import fs78 from "node:fs";
22147
+ import path79 from "node:path";
22122
22148
  function approvalRequest(req) {
22123
22149
  const id = req.id;
22124
22150
  const card = id === void 0 ? null : findCard(id);
@@ -22136,12 +22162,12 @@ function advancePhase(id) {
22136
22162
  const card = findCard(id);
22137
22163
  const found2 = locate(id);
22138
22164
  if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
22139
- const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
22140
- const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
22165
+ const file = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
22166
+ const { meta, body } = parseFrontmatter(fs78.readFileSync(file, "utf8"));
22141
22167
  if (!meta) return { error: `#${id} has no frontmatter` };
22142
22168
  meta.phase = card.stage + 1;
22143
22169
  meta.status = "todo";
22144
- fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
22170
+ fs78.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
22145
22171
  return null;
22146
22172
  }
22147
22173
  var init_approve = __esm({
@@ -22264,16 +22290,16 @@ var init_start = __esm({
22264
22290
  });
22265
22291
 
22266
22292
  // src/lib/agent/task-chats.ts
22267
- import fs78 from "node:fs";
22268
- import path79 from "node:path";
22293
+ import fs79 from "node:fs";
22294
+ import path80 from "node:path";
22269
22295
  function taskChatFile(task, home3) {
22270
22296
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
22271
- return path79.join(taskChatsDir(home3), `${task}.jsonl`);
22297
+ return path80.join(taskChatsDir(home3), `${task}.jsonl`);
22272
22298
  }
22273
22299
  function readTaskChat(task, home3) {
22274
22300
  let text5;
22275
22301
  try {
22276
- text5 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
22302
+ text5 = fs79.readFileSync(taskChatFile(task, home3), "utf8");
22277
22303
  } catch {
22278
22304
  return [];
22279
22305
  }
@@ -22294,13 +22320,13 @@ var init_task_chats = __esm({
22294
22320
  "use strict";
22295
22321
  init_home();
22296
22322
  TASK = /^[\w-]{1,100}$/;
22297
- taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
22323
+ taskChatsDir = (home3 = machineHome()) => path80.join(home3, "chats");
22298
22324
  }
22299
22325
  });
22300
22326
 
22301
22327
  // src/lib/agent/memory-review.ts
22302
- import fs79 from "node:fs";
22303
- import path80 from "node:path";
22328
+ import fs80 from "node:fs";
22329
+ import path81 from "node:path";
22304
22330
  function taskChatsToReview(tasks) {
22305
22331
  const out = [];
22306
22332
  for (const ref of [...new Set(tasks)]) {
@@ -22322,8 +22348,8 @@ function readArchived2(id) {
22322
22348
  const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
22323
22349
  if (!found2) return null;
22324
22350
  try {
22325
- const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
22326
- const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
22351
+ const file = found2.kind === "group" ? path81.join(found2.target, "root.md") : found2.target;
22352
+ const { meta, body } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
22327
22353
  if (!meta) return null;
22328
22354
  return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
22329
22355
  } catch {
@@ -22392,17 +22418,17 @@ var init_memory_review = __esm({
22392
22418
  });
22393
22419
 
22394
22420
  // src/lib/agent/dismissal-review.ts
22395
- import fs80 from "node:fs";
22396
- import path81 from "node:path";
22421
+ import fs81 from "node:fs";
22422
+ import path82 from "node:path";
22397
22423
  function rejectionsToReview() {
22398
- const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
22399
- if (!fs80.existsSync(dir)) return [];
22424
+ const dir = path82.join(ARCHIVE, REJECTIONS_TO_REVIEW);
22425
+ if (!fs81.existsSync(dir)) return [];
22400
22426
  const found2 = [];
22401
22427
  for (const file of walkMd(dir)) {
22402
22428
  const id = archivedId(file);
22403
22429
  if (id === null) continue;
22404
22430
  try {
22405
- const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
22431
+ const { meta } = parseFrontmatter(fs81.readFileSync(file, "utf8"));
22406
22432
  if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
22407
22433
  found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
22408
22434
  } catch {
@@ -22432,7 +22458,7 @@ function citedSources(text5) {
22432
22458
  function withdrawnSources() {
22433
22459
  const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
22434
22460
  try {
22435
- return citedSources(fs80.readFileSync(file, "utf8"));
22461
+ return citedSources(fs81.readFileSync(file, "utf8"));
22436
22462
  } catch {
22437
22463
  return [];
22438
22464
  }
@@ -22457,8 +22483,8 @@ var init_dismissal_review = __esm({
22457
22483
  });
22458
22484
 
22459
22485
  // src/lib/agent/flow.ts
22460
- import fs81 from "node:fs";
22461
- import path82 from "node:path";
22486
+ import fs82 from "node:fs";
22487
+ import path83 from "node:path";
22462
22488
  function readCard2(id, home3 = "board") {
22463
22489
  const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
22464
22490
  const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
@@ -22468,10 +22494,10 @@ function readCard2(id, home3 = "board") {
22468
22494
  { kind: "card-not-found", id }
22469
22495
  );
22470
22496
  }
22471
- const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
22497
+ const file = found2.kind === "group" ? path83.join(found2.target, "root.md") : found2.target;
22472
22498
  let text5;
22473
22499
  try {
22474
- text5 = fs81.readFileSync(file, "utf8");
22500
+ text5 = fs82.readFileSync(file, "utf8");
22475
22501
  } catch {
22476
22502
  die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
22477
22503
  }
@@ -64353,8 +64379,8 @@ var require_JSXTransformer = __commonJS({
64353
64379
  }
64354
64380
  if (this.isAutomaticRuntime) {
64355
64381
  if (this.importProcessor) {
64356
- for (const [path89, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
64357
- prefix += `var ${resolvedName} = require("${path89}");`;
64382
+ for (const [path90, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
64383
+ prefix += `var ${resolvedName} = require("${path90}");`;
64358
64384
  }
64359
64385
  } else {
64360
64386
  const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
@@ -64547,11 +64573,11 @@ var require_JSXTransformer = __commonJS({
64547
64573
  }
64548
64574
  claimAutoImportedName(funcName, importPathSuffix) {
64549
64575
  if (this.importProcessor) {
64550
- const path89 = this.jsxImportSource + importPathSuffix;
64551
- if (!this.cjsAutomaticModuleNameResolutions[path89]) {
64552
- this.cjsAutomaticModuleNameResolutions[path89] = this.importProcessor.getFreeIdentifierForPath(path89);
64576
+ const path90 = this.jsxImportSource + importPathSuffix;
64577
+ if (!this.cjsAutomaticModuleNameResolutions[path90]) {
64578
+ this.cjsAutomaticModuleNameResolutions[path90] = this.importProcessor.getFreeIdentifierForPath(path90);
64553
64579
  }
64554
- return `${this.cjsAutomaticModuleNameResolutions[path89]}.${funcName}`;
64580
+ return `${this.cjsAutomaticModuleNameResolutions[path90]}.${funcName}`;
64555
64581
  } else {
64556
64582
  if (!this.esmAutomaticImportNameResolutions[funcName]) {
64557
64583
  this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
@@ -64987,7 +65013,7 @@ var require_CJSImportProcessor = __commonJS({
64987
65013
  */
64988
65014
  pruneTypeOnlyImports() {
64989
65015
  this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
64990
- for (const [path89, importInfo] of this.importInfoByPath.entries()) {
65016
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
64991
65017
  if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
64992
65018
  continue;
64993
65019
  }
@@ -64997,7 +65023,7 @@ var require_CJSImportProcessor = __commonJS({
64997
65023
  ...importInfo.namedImports.map(({ localName }) => localName)
64998
65024
  ];
64999
65025
  if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
65000
- this.importsToReplace.set(path89, "");
65026
+ this.importsToReplace.set(path90, "");
65001
65027
  }
65002
65028
  }
65003
65029
  }
@@ -65005,7 +65031,7 @@ var require_CJSImportProcessor = __commonJS({
65005
65031
  return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
65006
65032
  }
65007
65033
  generateImportReplacements() {
65008
- for (const [path89, importInfo] of this.importInfoByPath.entries()) {
65034
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
65009
65035
  const {
65010
65036
  defaultNames,
65011
65037
  wildcardNames,
@@ -65015,17 +65041,17 @@ var require_CJSImportProcessor = __commonJS({
65015
65041
  hasStarExport
65016
65042
  } = importInfo;
65017
65043
  if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
65018
- this.importsToReplace.set(path89, `require('${path89}');`);
65044
+ this.importsToReplace.set(path90, `require('${path90}');`);
65019
65045
  continue;
65020
65046
  }
65021
- const primaryImportName = this.getFreeIdentifierForPath(path89);
65047
+ const primaryImportName = this.getFreeIdentifierForPath(path90);
65022
65048
  let secondaryImportName;
65023
65049
  if (this.enableLegacyTypeScriptModuleInterop) {
65024
65050
  secondaryImportName = primaryImportName;
65025
65051
  } else {
65026
- secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path89);
65052
+ secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path90);
65027
65053
  }
65028
- let requireCode = `var ${primaryImportName} = require('${path89}');`;
65054
+ let requireCode = `var ${primaryImportName} = require('${path90}');`;
65029
65055
  if (wildcardNames.length > 0) {
65030
65056
  for (const wildcardName of wildcardNames) {
65031
65057
  const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
@@ -65053,7 +65079,7 @@ var require_CJSImportProcessor = __commonJS({
65053
65079
  "createStarExport"
65054
65080
  )}(${primaryImportName});`;
65055
65081
  }
65056
- this.importsToReplace.set(path89, requireCode);
65082
+ this.importsToReplace.set(path90, requireCode);
65057
65083
  for (const defaultName of defaultNames) {
65058
65084
  this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
65059
65085
  }
@@ -65062,8 +65088,8 @@ var require_CJSImportProcessor = __commonJS({
65062
65088
  }
65063
65089
  }
65064
65090
  }
65065
- getFreeIdentifierForPath(path89) {
65066
- const components = path89.split("/");
65091
+ getFreeIdentifierForPath(path90) {
65092
+ const components = path90.split("/");
65067
65093
  const lastComponent = components[components.length - 1];
65068
65094
  const baseName = lastComponent.replace(/\W/g, "");
65069
65095
  return this.nameManager.claimFreeName(`_${baseName}`);
@@ -65108,8 +65134,8 @@ var require_CJSImportProcessor = __commonJS({
65108
65134
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
65109
65135
  throw new Error("Expected string token at the end of import statement.");
65110
65136
  }
65111
- const path89 = this.tokens.stringValueAtIndex(index);
65112
- const importInfo = this.getImportInfo(path89);
65137
+ const path90 = this.tokens.stringValueAtIndex(index);
65138
+ const importInfo = this.getImportInfo(path90);
65113
65139
  importInfo.defaultNames.push(...defaultNames);
65114
65140
  importInfo.wildcardNames.push(...wildcardNames);
65115
65141
  importInfo.namedImports.push(...namedImports);
@@ -65176,8 +65202,8 @@ var require_CJSImportProcessor = __commonJS({
65176
65202
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
65177
65203
  throw new Error("Expected string token at the end of import statement.");
65178
65204
  }
65179
- const path89 = this.tokens.stringValueAtIndex(index);
65180
- const importInfo = this.getImportInfo(path89);
65205
+ const path90 = this.tokens.stringValueAtIndex(index);
65206
+ const importInfo = this.getImportInfo(path90);
65181
65207
  importInfo.namedExports.push(...namedImports);
65182
65208
  }
65183
65209
  preprocessExportStarAtIndex(index) {
@@ -65192,8 +65218,8 @@ var require_CJSImportProcessor = __commonJS({
65192
65218
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
65193
65219
  throw new Error("Expected string token at the end of star export statement.");
65194
65220
  }
65195
- const path89 = this.tokens.stringValueAtIndex(index);
65196
- const importInfo = this.getImportInfo(path89);
65221
+ const path90 = this.tokens.stringValueAtIndex(index);
65222
+ const importInfo = this.getImportInfo(path90);
65197
65223
  if (exportedName !== null) {
65198
65224
  importInfo.exportStarNames.push(exportedName);
65199
65225
  } else {
@@ -65233,8 +65259,8 @@ var require_CJSImportProcessor = __commonJS({
65233
65259
  * Get a mutable import info object for this path, creating one if it doesn't
65234
65260
  * exist yet.
65235
65261
  */
65236
- getImportInfo(path89) {
65237
- const existingInfo = this.importInfoByPath.get(path89);
65262
+ getImportInfo(path90) {
65263
+ const existingInfo = this.importInfoByPath.get(path90);
65238
65264
  if (existingInfo) {
65239
65265
  return existingInfo;
65240
65266
  }
@@ -65247,7 +65273,7 @@ var require_CJSImportProcessor = __commonJS({
65247
65273
  exportStarNames: [],
65248
65274
  hasStarExport: false
65249
65275
  };
65250
- this.importInfoByPath.set(path89, newInfo);
65276
+ this.importInfoByPath.set(path90, newInfo);
65251
65277
  return newInfo;
65252
65278
  }
65253
65279
  addExportBinding(localName, exportedName) {
@@ -65827,16 +65853,16 @@ var require_resolve_uri_umd = __commonJS({
65827
65853
  }
65828
65854
  function parseFileUrl(input) {
65829
65855
  const match = fileRegex.exec(input);
65830
- const path89 = match[2];
65831
- return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path89) ? path89 : "/" + path89, match[3] || "", match[4] || "");
65856
+ const path90 = match[2];
65857
+ return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path90) ? path90 : "/" + path90, match[3] || "", match[4] || "");
65832
65858
  }
65833
- function makeUrl(scheme, user, host2, port, path89, query, hash2) {
65859
+ function makeUrl(scheme, user, host2, port, path90, query, hash2) {
65834
65860
  return {
65835
65861
  scheme,
65836
65862
  user,
65837
65863
  host: host2,
65838
65864
  port,
65839
- path: path89,
65865
+ path: path90,
65840
65866
  query,
65841
65867
  hash: hash2,
65842
65868
  type: 7
@@ -65866,11 +65892,11 @@ var require_resolve_uri_umd = __commonJS({
65866
65892
  url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
65867
65893
  return url;
65868
65894
  }
65869
- function stripPathFilename(path89) {
65870
- if (path89.endsWith("/.."))
65871
- return path89;
65872
- const index = path89.lastIndexOf("/");
65873
- return path89.slice(0, index + 1);
65895
+ function stripPathFilename(path90) {
65896
+ if (path90.endsWith("/.."))
65897
+ return path90;
65898
+ const index = path90.lastIndexOf("/");
65899
+ return path90.slice(0, index + 1);
65874
65900
  }
65875
65901
  function mergePaths(url, base) {
65876
65902
  normalizePath(base, base.type);
@@ -65908,14 +65934,14 @@ var require_resolve_uri_umd = __commonJS({
65908
65934
  pieces[pointer++] = piece;
65909
65935
  positive++;
65910
65936
  }
65911
- let path89 = "";
65937
+ let path90 = "";
65912
65938
  for (let i = 1; i < pointer; i++) {
65913
- path89 += "/" + pieces[i];
65939
+ path90 += "/" + pieces[i];
65914
65940
  }
65915
- if (!path89 || addTrailingSlash && !path89.endsWith("/..")) {
65916
- path89 += "/";
65941
+ if (!path90 || addTrailingSlash && !path90.endsWith("/..")) {
65942
+ path90 += "/";
65917
65943
  }
65918
- url.path = path89;
65944
+ url.path = path90;
65919
65945
  }
65920
65946
  function resolve2(input, base) {
65921
65947
  if (!input && !base)
@@ -65956,13 +65982,13 @@ var require_resolve_uri_umd = __commonJS({
65956
65982
  case 3:
65957
65983
  return queryHash;
65958
65984
  case 4: {
65959
- const path89 = url.path.slice(1);
65960
- if (!path89)
65985
+ const path90 = url.path.slice(1);
65986
+ if (!path90)
65961
65987
  return queryHash || ".";
65962
- if (isRelative(base || input) && !isRelative(path89)) {
65963
- return "./" + path89 + queryHash;
65988
+ if (isRelative(base || input) && !isRelative(path90)) {
65989
+ return "./" + path90 + queryHash;
65964
65990
  }
65965
- return path89 + queryHash;
65991
+ return path90 + queryHash;
65966
65992
  }
65967
65993
  case 5:
65968
65994
  return url.path + queryHash;
@@ -66061,10 +66087,10 @@ var require_trace_mapping_umd = __commonJS({
66061
66087
  module2.exports = __toCommonJS(trace_mapping_exports);
66062
66088
  var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
66063
66089
  var import_resolve_uri = __toESM2(require_resolve_uri());
66064
- function stripFilename(path89) {
66065
- if (!path89) return "";
66066
- const index = path89.lastIndexOf("/");
66067
- return path89.slice(0, index + 1);
66090
+ function stripFilename(path90) {
66091
+ if (!path90) return "";
66092
+ const index = path90.lastIndexOf("/");
66093
+ return path90.slice(0, index + 1);
66068
66094
  }
66069
66095
  function resolver2(mapUrl, sourceRoot) {
66070
66096
  const from = stripFilename(mapUrl);
@@ -67272,9 +67298,9 @@ var require_util2 = __commonJS({
67272
67298
  /** @class */
67273
67299
  (function(_super) {
67274
67300
  __extends(VError2, _super);
67275
- function VError2(path89, message) {
67301
+ function VError2(path90, message) {
67276
67302
  var _this = _super.call(this, message) || this;
67277
- _this.path = path89;
67303
+ _this.path = path90;
67278
67304
  Object.setPrototypeOf(_this, VError2.prototype);
67279
67305
  return _this;
67280
67306
  }
@@ -67334,26 +67360,26 @@ var require_util2 = __commonJS({
67334
67360
  (_b = this._messages).push.apply(_b, best._messages);
67335
67361
  }
67336
67362
  };
67337
- DetailContext2.prototype.getError = function(path89) {
67363
+ DetailContext2.prototype.getError = function(path90) {
67338
67364
  var msgParts = [];
67339
67365
  for (var i = this._propNames.length - 1; i >= 0; i--) {
67340
67366
  var p2 = this._propNames[i];
67341
- path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67367
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67342
67368
  var m = this._messages[i];
67343
67369
  if (m) {
67344
- msgParts.push(path89 + " " + m);
67370
+ msgParts.push(path90 + " " + m);
67345
67371
  }
67346
67372
  }
67347
- return new VError(path89, msgParts.join("; "));
67373
+ return new VError(path90, msgParts.join("; "));
67348
67374
  };
67349
- DetailContext2.prototype.getErrorDetail = function(path89) {
67375
+ DetailContext2.prototype.getErrorDetail = function(path90) {
67350
67376
  var details = [];
67351
67377
  for (var i = this._propNames.length - 1; i >= 0; i--) {
67352
67378
  var p2 = this._propNames[i];
67353
- path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67379
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67354
67380
  var message = this._messages[i];
67355
67381
  if (message) {
67356
- details.push({ path: path89, message });
67382
+ details.push({ path: path90, message });
67357
67383
  }
67358
67384
  }
67359
67385
  var detail = null;
@@ -68166,8 +68192,8 @@ var require_dist = __commonJS({
68166
68192
  this.checkerPlain = this.ttype.getChecker(suite, false);
68167
68193
  this.checkerStrict = this.ttype.getChecker(suite, true);
68168
68194
  }
68169
- Checker2.prototype.setReportedPath = function(path89) {
68170
- this._path = path89;
68195
+ Checker2.prototype.setReportedPath = function(path90) {
68196
+ this._path = path90;
68171
68197
  };
68172
68198
  Checker2.prototype.check = function(value) {
68173
68199
  return this._doCheck(this.checkerPlain, value);
@@ -73600,9 +73626,9 @@ var require_CJSImportTransformer = __commonJS({
73600
73626
  if (shouldElideImport) {
73601
73627
  this.tokens.removeToken();
73602
73628
  } else {
73603
- const path89 = this.tokens.stringValue();
73604
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
73605
- this.tokens.appendCode(this.importProcessor.claimImportCode(path89));
73629
+ const path90 = this.tokens.stringValue();
73630
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
73631
+ this.tokens.appendCode(this.importProcessor.claimImportCode(path90));
73606
73632
  }
73607
73633
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
73608
73634
  if (this.tokens.matches1(_types.TokenType.semi)) {
@@ -74182,8 +74208,8 @@ var require_CJSImportTransformer = __commonJS({
74182
74208
  }
74183
74209
  if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
74184
74210
  this.tokens.removeToken();
74185
- const path89 = this.tokens.stringValue();
74186
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
74211
+ const path90 = this.tokens.stringValue();
74212
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
74187
74213
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
74188
74214
  } else {
74189
74215
  this.tokens.appendCode(exportStatements.join(" "));
@@ -74197,8 +74223,8 @@ var require_CJSImportTransformer = __commonJS({
74197
74223
  while (!this.tokens.matches1(_types.TokenType.string)) {
74198
74224
  this.tokens.removeToken();
74199
74225
  }
74200
- const path89 = this.tokens.stringValue();
74201
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
74226
+ const path90 = this.tokens.stringValue();
74227
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
74202
74228
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
74203
74229
  if (this.tokens.matches1(_types.TokenType.semi)) {
74204
74230
  this.tokens.removeToken();
@@ -104052,9 +104078,9 @@ var init_bundle_mjs = __esm({
104052
104078
  processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
104053
104079
  }
104054
104080
  };
104055
- getPart = (classPartObject, path89) => {
104081
+ getPart = (classPartObject, path90) => {
104056
104082
  let current = classPartObject;
104057
- const parts = path89.split(CLASS_PART_SEPARATOR);
104083
+ const parts = path90.split(CLASS_PART_SEPARATOR);
104058
104084
  const len = parts.length;
104059
104085
  for (let i = 0; i < len; i++) {
104060
104086
  const part = parts[i];
@@ -107304,8 +107330,8 @@ var init_dist = __esm({
107304
107330
  });
107305
107331
 
107306
107332
  // src/lib/draw-mockup.ts
107307
- import fs82 from "node:fs";
107308
- import path83 from "node:path";
107333
+ import fs83 from "node:fs";
107334
+ import path84 from "node:path";
107309
107335
  import vm from "node:vm";
107310
107336
  async function loadPackage(id) {
107311
107337
  if (id === "react") return import_react3.default;
@@ -107318,22 +107344,22 @@ async function loadPackage(id) {
107318
107344
  return { __esModule: true, ...await load() };
107319
107345
  }
107320
107346
  function resolveFile(id, from, folder) {
107321
- const at2 = path83.resolve(path83.dirname(from), id);
107322
- if (at2 !== folder && !at2.startsWith(folder + path83.sep)) throw new Error(`${id} is outside the mockup's folder`);
107323
- const tries = path83.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path83.join(at2, `index${e2}`))];
107324
- const file = tries.find((f2) => fs82.statSync(f2, { throwIfNoEntry: false })?.isFile());
107347
+ const at2 = path84.resolve(path84.dirname(from), id);
107348
+ if (at2 !== folder && !at2.startsWith(folder + path84.sep)) throw new Error(`${id} is outside the mockup's folder`);
107349
+ const tries = path84.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path84.join(at2, `index${e2}`))];
107350
+ const file = tries.find((f2) => fs83.statSync(f2, { throwIfNoEntry: false })?.isFile());
107325
107351
  if (!file) throw new Error(`no such file: ${id}`);
107326
107352
  return file;
107327
107353
  }
107328
107354
  async function readGraph(entry) {
107329
- const folder = path83.dirname(entry);
107355
+ const folder = path84.dirname(entry);
107330
107356
  const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
107331
107357
  const walk3 = async (file) => {
107332
107358
  if (graph.code.has(file)) return;
107333
107359
  if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
107334
107360
  let location = file;
107335
107361
  try {
107336
- const js = (0, import_sucrase.transform)(fs82.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
107362
+ const js = (0, import_sucrase.transform)(fs83.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
107337
107363
  graph.code.set(file, js);
107338
107364
  const link2 = /* @__PURE__ */ new Map();
107339
107365
  graph.links.set(file, link2);
@@ -107347,7 +107373,7 @@ async function readGraph(entry) {
107347
107373
  const target = resolveFile(id, file, folder);
107348
107374
  link2.set(id, target);
107349
107375
  if (!target.endsWith(".css")) await walk3(target);
107350
- else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs82.readFileSync(target, "utf8") });
107376
+ else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs83.readFileSync(target, "utf8") });
107351
107377
  }
107352
107378
  } catch (error) {
107353
107379
  throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
@@ -107364,12 +107390,12 @@ function run2(script, context, name, deadline, lineOffset = 0) {
107364
107390
  async function tailwindFor(markup, sheets) {
107365
107391
  const source = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
107366
107392
  const compiler = await rc(source, {
107367
- base: sheets.length ? path83.dirname(sheets[0].path) : "/",
107393
+ base: sheets.length ? path84.dirname(sheets[0].path) : "/",
107368
107394
  loadStylesheet: async (id, from) => {
107369
107395
  if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
107370
107396
  if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
107371
- const at2 = path83.resolve(from, id);
107372
- return { path: at2, base: path83.dirname(at2), content: fs82.readFileSync(at2, "utf8") };
107397
+ const at2 = path84.resolve(from, id);
107398
+ return { path: at2, base: path84.dirname(at2), content: fs83.readFileSync(at2, "utf8") };
107373
107399
  }
107374
107400
  });
107375
107401
  const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
@@ -107478,8 +107504,8 @@ var init_draw_mockup = __esm({
107478
107504
  });
107479
107505
 
107480
107506
  // src/lib/preview-validation.ts
107481
- import fs83 from "node:fs";
107482
- import path84 from "node:path";
107507
+ import fs84 from "node:fs";
107508
+ import path85 from "node:path";
107483
107509
  function renderError(error) {
107484
107510
  if (!error || typeof error !== "object") return String(error);
107485
107511
  const { message, stack } = error;
@@ -107490,7 +107516,7 @@ function renderError(error) {
107490
107516
  async function validateScreens(files2) {
107491
107517
  const errors = [];
107492
107518
  const entries = /* @__PURE__ */ new Map();
107493
- for (const file of files2) entries.set(fs83.existsSync(file) ? fs83.realpathSync(file) : path84.resolve(file), path84.resolve(file));
107519
+ for (const file of files2) entries.set(fs84.existsSync(file) ? fs84.realpathSync(file) : path85.resolve(file), path85.resolve(file));
107494
107520
  for (const file of entries.values()) {
107495
107521
  try {
107496
107522
  await drawMockup(file);
@@ -107509,7 +107535,7 @@ async function validatePreview(file, text5) {
107509
107535
  if (/^ {0,3}<!--\s*agent\s*-->\s*$/.test(line)) own = false;
107510
107536
  if (own) section.push(line);
107511
107537
  }
107512
- 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));
107538
+ 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));
107513
107539
  return validateScreens(files2);
107514
107540
  }
107515
107541
  var init_preview_validation = __esm({
@@ -107666,7 +107692,7 @@ __export(watch_exports, {
107666
107692
  watchRun: () => watchRun
107667
107693
  });
107668
107694
  import { spawn as spawn4 } from "node:child_process";
107669
- import fs84 from "node:fs";
107695
+ import fs85 from "node:fs";
107670
107696
  async function watchRun(sessionId, resume = startResume) {
107671
107697
  const spec = readSpec(sessionId);
107672
107698
  const run3 = peekRun(sessionId);
@@ -107702,11 +107728,11 @@ async function watchRun(sessionId, resume = startResume) {
107702
107728
  const record = claimed ?? run3;
107703
107729
  const sub = record.action === "sub";
107704
107730
  if (claim) await setCardStatus(claim.cardId, claim.status);
107705
- fs84.mkdirSync(SESSIONS_DIR, { recursive: true });
107706
- const logFile = fs84.createWriteStream(record.logPath, { flags: "a" });
107731
+ fs85.mkdirSync(SESSIONS_DIR, { recursive: true });
107732
+ const logFile = fs85.createWriteStream(record.logPath, { flags: "a" });
107707
107733
  logFile.on("error", () => {
107708
107734
  });
107709
- const eventsFile = fs84.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107735
+ const eventsFile = fs85.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107710
107736
  eventsFile.on("error", () => {
107711
107737
  });
107712
107738
  const event2 = (e2) => eventsFile.write(`${JSON.stringify(e2)}
@@ -108292,7 +108318,7 @@ var init_watch = __esm({
108292
108318
  });
108293
108319
 
108294
108320
  // src/kanban.ts
108295
- import fs90 from "node:fs";
108321
+ import fs91 from "node:fs";
108296
108322
  import { fileURLToPath as fileURLToPath4 } from "node:url";
108297
108323
 
108298
108324
  // src/lib/cli/agent.ts
@@ -108775,8 +108801,8 @@ async function testAgent(args) {
108775
108801
  }
108776
108802
 
108777
108803
  // src/commands/cloud.ts
108778
- import fs72 from "node:fs";
108779
- import path73 from "node:path";
108804
+ import fs73 from "node:fs";
108805
+ import path74 from "node:path";
108780
108806
 
108781
108807
  // src/lib/cloud/avatar.ts
108782
108808
  init_session();
@@ -108824,13 +108850,13 @@ init_config();
108824
108850
  init_home();
108825
108851
  init_config();
108826
108852
  init_session();
108827
- import fs71 from "node:fs";
108828
- import path72 from "node:path";
108853
+ import fs72 from "node:fs";
108854
+ import path73 from "node:path";
108829
108855
  var FRESH_MS2 = 10 * 6e4;
108830
108856
  var GRACE_MS = 7 * 24 * 60 * 6e4;
108831
- var heldFile = () => path72.join(machineHome(), "pro.json");
108857
+ var heldFile = () => path73.join(machineHome(), "pro.json");
108832
108858
  function forgetPro() {
108833
- fs71.rmSync(heldFile(), { force: true });
108859
+ fs72.rmSync(heldFile(), { force: true });
108834
108860
  }
108835
108861
 
108836
108862
  // src/lib/cloud/account.ts
@@ -109007,10 +109033,10 @@ async function cloudImage(opts, program2) {
109007
109033
  const prompt = opts.prompt.trim();
109008
109034
  if (!prompt) usage("Missing the prompt.", line);
109009
109035
  const references = opts.refs.map((file) => {
109010
- const type = REF_TYPES[path73.extname(file).toLowerCase()];
109036
+ const type = REF_TYPES[path74.extname(file).toLowerCase()];
109011
109037
  if (!type) usage(`--ref ${file}: use a PNG, JPEG or WebP file.`, line);
109012
109038
  try {
109013
- return `data:${type};base64,${fs72.readFileSync(file).toString("base64")}`;
109039
+ return `data:${type};base64,${fs73.readFileSync(file).toString("base64")}`;
109014
109040
  } catch (e2) {
109015
109041
  usage(`--ref ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`, line);
109016
109042
  }
@@ -109116,8 +109142,8 @@ async function generate(g3) {
109116
109142
  refuse(g3.failed, g3.fallback);
109117
109143
  }
109118
109144
  const out = g3.outFor?.(res, g3.out) ?? g3.out;
109119
- fs72.mkdirSync(path73.dirname(path73.resolve(out)), { recursive: true });
109120
- fs72.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
109145
+ fs73.mkdirSync(path74.dirname(path74.resolve(out)), { recursive: true });
109146
+ fs73.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
109121
109147
  say(`${out} (${g3.label(res)})`);
109122
109148
  return { out };
109123
109149
  }
@@ -109126,14 +109152,14 @@ async function generate(g3) {
109126
109152
  init_board_files();
109127
109153
  init_workflow_files();
109128
109154
  import crypto6 from "node:crypto";
109129
- import fs74 from "node:fs";
109130
- import path75 from "node:path";
109155
+ import fs75 from "node:fs";
109156
+ import path76 from "node:path";
109131
109157
 
109132
109158
  // src/lib/agents/shared-memory.ts
109133
109159
  init_bundled2();
109134
109160
  init_parse();
109135
- import fs73 from "node:fs";
109136
- import path74 from "node:path";
109161
+ import fs74 from "node:fs";
109162
+ import path75 from "node:path";
109137
109163
  function sharedMemory(board2) {
109138
109164
  const declared = /* @__PURE__ */ new Map();
109139
109165
  const take = (folder, text5, builtIn) => {
@@ -109145,16 +109171,16 @@ function sharedMemory(board2) {
109145
109171
  const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
109146
109172
  if (at2) take(at2[1], text5, officialAgent(at2[1]));
109147
109173
  }
109148
- const root2 = path74.join(board2, "agents");
109174
+ const root2 = path75.join(board2, "agents");
109149
109175
  let folders2 = [];
109150
109176
  try {
109151
- folders2 = fs73.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
109177
+ folders2 = fs74.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
109152
109178
  } catch {
109153
109179
  }
109154
109180
  for (const folder of folders2.sort()) {
109155
109181
  let text5 = null;
109156
109182
  try {
109157
- text5 = fs73.readFileSync(path74.join(root2, folder, "AGENT.md"), "utf8");
109183
+ text5 = fs74.readFileSync(path75.join(root2, folder, "AGENT.md"), "utf8");
109158
109184
  } catch {
109159
109185
  }
109160
109186
  take(folder, text5, false);
@@ -109243,24 +109269,24 @@ async function findProject(asked) {
109243
109269
  }
109244
109270
  throw new Refused(`No project of yours has the id or prefix "${asked}".`, "not_found");
109245
109271
  }
109246
- var read2 = (file) => fs74.readFileSync(file, "utf8");
109272
+ var read2 = (file) => fs75.readFileSync(file, "utf8");
109247
109273
  var bytes2 = (text5) => Buffer.byteLength(text5, "utf8");
109248
109274
  function files(dir) {
109249
- if (!fs74.existsSync(dir)) return [];
109275
+ if (!fs75.existsSync(dir)) return [];
109250
109276
  const out = [];
109251
- for (const entry of fs74.readdirSync(dir, { withFileTypes: true })) {
109277
+ for (const entry of fs75.readdirSync(dir, { withFileTypes: true })) {
109252
109278
  if (entry.name.startsWith(".")) continue;
109253
- const full = path75.join(dir, entry.name);
109279
+ const full = path76.join(dir, entry.name);
109254
109280
  if (entry.isDirectory()) out.push(...files(full));
109255
109281
  else if (entry.isFile()) out.push(full);
109256
109282
  }
109257
109283
  return out;
109258
109284
  }
109259
- var posix = (p2) => p2.split(path75.sep).join("/");
109285
+ var posix = (p2) => p2.split(path76.sep).join("/");
109260
109286
  function openCards() {
109261
109287
  const out = [];
109262
109288
  for (const file of walkMd(TODO)) {
109263
- const rel2 = posix(path75.relative(TODO, file));
109289
+ const rel2 = posix(path76.relative(TODO, file));
109264
109290
  if (rel2 === "README.md") continue;
109265
109291
  const parts = rel2.split("/");
109266
109292
  const text5 = read2(file);
@@ -109347,8 +109373,8 @@ function draftsOf(text5) {
109347
109373
  const at2 = /^\.(assets|mockups)\/(.+)$/.exec(name);
109348
109374
  if (!at2) continue;
109349
109375
  const base = at2[1] === "assets" ? ASSETS : MOCKUPS;
109350
- const file = path75.resolve(base, at2[2]);
109351
- if (file.startsWith(base + path75.sep) && fs74.statSync(file, { throwIfNoEntry: false })?.isFile()) out.set(name, file);
109376
+ const file = path76.resolve(base, at2[2]);
109377
+ if (file.startsWith(base + path76.sep) && fs75.statSync(file, { throwIfNoEntry: false })?.isFile()) out.set(name, file);
109352
109378
  }
109353
109379
  return [...out].map(([name, file]) => ({ name, file }));
109354
109380
  }
@@ -109382,9 +109408,9 @@ async function uploadDrafts(task, drafts) {
109382
109408
  const assets = {};
109383
109409
  for (const { name, file } of drafts) {
109384
109410
  if (!card.body.includes(name)) continue;
109385
- const ext = path75.extname(file).toLowerCase();
109411
+ const ext = path76.extname(file).toLowerCase();
109386
109412
  const type = TYPES2[ext] ?? "application/octet-stream";
109387
- const data = fs74.readFileSync(file);
109413
+ const data = fs75.readFileSync(file);
109388
109414
  const artifact = await api("POST", `/v1/tasks/${task}/artifacts`, { type: kindOf2(ext), name: name.slice(0, 200) });
109389
109415
  const upload = await api("POST", `/v1/artifacts/${artifact.id}/uploads`, { content_type: type, size: Math.max(data.length, 1) });
109390
109416
  await api("PUT", `/v1/uploads/${upload.id}`, void 0, { bytes: data, type });
@@ -109427,7 +109453,7 @@ usage: ${program2} cloud import --project <id or prefix> [--dry-run]`, { kind: "
109427
109453
  function localWorkflowFolders() {
109428
109454
  let folders2;
109429
109455
  try {
109430
- 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 }));
109456
+ 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 }));
109431
109457
  } catch {
109432
109458
  return [];
109433
109459
  }
@@ -109438,19 +109464,19 @@ function localWorkflowFolders() {
109438
109464
  });
109439
109465
  }
109440
109466
  function filesUnder(dir, base = dir) {
109441
- return fs74.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
109442
- const full = path75.join(dir, e2.name);
109443
- return e2.isDirectory() ? filesUnder(full, base) : [posix(path75.relative(base, full))];
109467
+ return fs75.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
109468
+ const full = path76.join(dir, e2.name);
109469
+ return e2.isDirectory() ? filesUnder(full, base) : [posix(path76.relative(base, full))];
109444
109470
  });
109445
109471
  }
109446
109472
  function packLocalWorkflow(id, def, shipped) {
109447
- const dir = path75.join(WORKFLOWS, id);
109448
- const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2, fs74.readFileSync(path75.join(dir, f2), "utf8")]));
109473
+ const dir = path76.join(WORKFLOWS, id);
109474
+ const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2, fs75.readFileSync(path76.join(dir, f2), "utf8")]));
109449
109475
  const named2 = [...def.previews, ...def.land, ...def.scheduled].map((h3) => h3.agent);
109450
109476
  for (const agent of new Set(named2)) {
109451
- const at2 = path75.join(AGENTS, agent);
109452
- if (fs74.existsSync(path75.join(at2, "AGENT.md"))) {
109453
- for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] = fs74.readFileSync(path75.join(at2, file), "utf8");
109477
+ const at2 = path76.join(AGENTS, agent);
109478
+ if (fs75.existsSync(path76.join(at2, "AGENT.md"))) {
109479
+ for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] = fs75.readFileSync(path76.join(at2, file), "utf8");
109454
109480
  continue;
109455
109481
  }
109456
109482
  for (const [key, text5] of Object.entries(shipped)) if (key.startsWith(`${agent}/`)) out[`agents/${key}`] = text5;
@@ -109460,10 +109486,10 @@ function packLocalWorkflow(id, def, shipped) {
109460
109486
  async function run(asked, dryRun) {
109461
109487
  const project = await findProject(asked);
109462
109488
  const cloudFlows2 = await all(`/v1/workflows?workspace=${encodeURIComponent(project.workspace)}`);
109463
- const board2 = crypto6.createHash("sha256").update(fs74.realpathSync(KANBAN)).digest("hex").slice(0, 16);
109489
+ const board2 = crypto6.createHash("sha256").update(fs75.realpathSync(KANBAN)).digest("hex").slice(0, 16);
109464
109490
  const cards = openCards();
109465
109491
  const problems = [];
109466
- const where = (file) => posix(path75.relative(KANBAN, file));
109492
+ const where = (file) => posix(path76.relative(KANBAN, file));
109467
109493
  const own = [];
109468
109494
  for (const f2 of localWorkflowFolders()) {
109469
109495
  if (f2.def) own.push({ id: f2.id, name: f2.def.name, def: f2.def });
@@ -109492,7 +109518,7 @@ async function run(asked, dryRun) {
109492
109518
  const root2 = `projects/${project.id}/`;
109493
109519
  const boardFiles = [];
109494
109520
  for (const file of [...files(MEMORY), ...files(RULES), CONFIG, MODULES_MD]) {
109495
- if (!fs74.existsSync(file)) continue;
109521
+ if (!fs75.existsSync(file)) continue;
109496
109522
  const rel2 = where(file);
109497
109523
  if (!isBoardPath(rel2)) continue;
109498
109524
  const content = read2(file);
@@ -109603,16 +109629,16 @@ async function run(asked, dryRun) {
109603
109629
  }
109604
109630
  function leftLocal(own) {
109605
109631
  const out = [];
109606
- const count4 = (dir) => fs74.existsSync(dir) ? walkMd(dir).length : 0;
109632
+ const count4 = (dir) => fs75.existsSync(dir) ? walkMd(dir).length : 0;
109607
109633
  const archived = count4(ARCHIVE);
109608
109634
  if (archived) out.push(`.archive/ (${archived})`);
109609
109635
  const triage = count4(TRIAGE);
109610
109636
  if (triage) out.push(`triage/ (${triage})`);
109611
- if (fs74.existsSync(DELIVERIES)) out.push("deliveries/");
109612
- if (fs74.existsSync(path75.join(KANBAN, "metrics.csv"))) out.push("metrics.csv");
109637
+ if (fs75.existsSync(DELIVERIES)) out.push("deliveries/");
109638
+ if (fs75.existsSync(path76.join(KANBAN, "metrics.csv"))) out.push("metrics.csv");
109613
109639
  const named2 = new Set(own.flatMap((w2) => [...w2.def.previews, ...w2.def.land, ...w2.def.scheduled].map((h3) => h3.agent)));
109614
- if (fs74.existsSync(AGENTS)) {
109615
- for (const e2 of fs74.readdirSync(AGENTS, { withFileTypes: true })) {
109640
+ if (fs75.existsSync(AGENTS)) {
109641
+ for (const e2 of fs75.readdirSync(AGENTS, { withFileTypes: true })) {
109616
109642
  if (e2.isDirectory() && !e2.name.startsWith(".") && !named2.has(e2.name)) out.push(`agents/${e2.name}/`);
109617
109643
  }
109618
109644
  }
@@ -109630,8 +109656,8 @@ init_session();
109630
109656
  init_io();
109631
109657
  init_paths();
109632
109658
  import { createHash as createHash5 } from "node:crypto";
109633
- import fs75 from "node:fs";
109634
- import path76 from "node:path";
109659
+ import fs76 from "node:fs";
109660
+ import path77 from "node:path";
109635
109661
  var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
109636
109662
  var CAPTURED = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/;
109637
109663
  var MAX_BYTES3 = 50 * 1024 * 1024;
@@ -109730,10 +109756,10 @@ This template has no preview.`);
109730
109756
  const written = [];
109731
109757
  for (const p2 of previews) {
109732
109758
  const bytes3 = Buffer.from(await (await ask(`/${at2}/previews/${route(p2.path)}`, {}, WITHOUT)).arrayBuffer());
109733
- const file = path76.basename(p2.path);
109734
- const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
109735
- fs75.mkdirSync(opts.to, { recursive: true });
109736
- fs75.writeFileSync(out, bytes3);
109759
+ const file = path77.basename(p2.path);
109760
+ const out = path77.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
109761
+ fs76.mkdirSync(opts.to, { recursive: true });
109762
+ fs76.writeFileSync(out, bytes3);
109737
109763
  written.push(out);
109738
109764
  say(out);
109739
109765
  }
@@ -109746,15 +109772,15 @@ async function templateGet(name, opts, program2) {
109746
109772
  const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
109747
109773
  const fetched = [];
109748
109774
  for (const f2 of template.files) {
109749
- const out = path76.resolve(to, f2.path);
109750
- if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse2(T.corrupt, WITHOUT);
109775
+ const out = path77.resolve(to, f2.path);
109776
+ if (!out.startsWith(path77.resolve(to) + path77.sep)) refuse2(T.corrupt, WITHOUT);
109751
109777
  const bytes3 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
109752
109778
  if (bytes3.byteLength !== f2.size || createHash5("sha256").update(bytes3).digest("hex") !== f2.sha256) {
109753
109779
  refuse2(T.corrupt, WITHOUT);
109754
109780
  }
109755
109781
  fetched.push({ out, bytes: bytes3 });
109756
109782
  }
109757
- const taken = fetched.filter((f2) => fs75.existsSync(f2.out)).map((f2) => path76.relative(to, f2.out));
109783
+ const taken = fetched.filter((f2) => fs76.existsSync(f2.out)).map((f2) => path77.relative(to, f2.out));
109758
109784
  if (taken.length > 0) {
109759
109785
  refuse2({
109760
109786
  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`,
@@ -109762,8 +109788,8 @@ async function templateGet(name, opts, program2) {
109762
109788
  });
109763
109789
  }
109764
109790
  for (const f2 of fetched) {
109765
- fs75.mkdirSync(path76.dirname(f2.out), { recursive: true });
109766
- fs75.writeFileSync(f2.out, f2.bytes);
109791
+ fs76.mkdirSync(path77.dirname(f2.out), { recursive: true });
109792
+ fs76.writeFileSync(f2.out, f2.bytes);
109767
109793
  }
109768
109794
  say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
109769
109795
  Fetched ${name}: ${fetched.length} files into ${to}`);
@@ -109781,25 +109807,25 @@ async function templateSource(name, opts) {
109781
109807
  say(`evidence: ${e2.path}`);
109782
109808
  continue;
109783
109809
  }
109784
- const out = path76.join(opts.to, `${name}-${path76.basename(e2.path)}`);
109785
- fs75.mkdirSync(opts.to, { recursive: true });
109786
- fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
109810
+ const out = path77.join(opts.to, `${name}-${path77.basename(e2.path)}`);
109811
+ fs76.mkdirSync(opts.to, { recursive: true });
109812
+ fs76.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
109787
109813
  written.push(out);
109788
109814
  say(out);
109789
109815
  }
109790
109816
  return { name, source, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
109791
109817
  }
109792
109818
  async function templatePublish(dir, opts) {
109793
- const root2 = path76.resolve(dir);
109794
- const manifest = path76.join(root2, "template.md");
109795
- 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.");
109796
- const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
109819
+ const root2 = path77.resolve(dir);
109820
+ const manifest = path77.join(root2, "template.md");
109821
+ 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.");
109822
+ const meta = readTemplateMeta(fs76.readFileSync(manifest, "utf8"));
109797
109823
  const files2 = walk2(root2);
109798
- const total = files2.reduce((sum, f2) => sum + fs75.statSync(path76.join(root2, f2)).size, 0);
109824
+ const total = files2.reduce((sum, f2) => sum + fs76.statSync(path77.join(root2, f2)).size, 0);
109799
109825
  if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
109800
109826
  for (const extra of [...opts.preview, ...opts.evidence]) {
109801
- if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
109802
- if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
109827
+ if (!fs76.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
109828
+ if (path77.resolve(extra).startsWith(root2 + path77.sep)) {
109803
109829
  invalid(
109804
109830
  `${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`,
109805
109831
  `${extra} is inside the template folder; keep previews and evidence outside it.`
@@ -109811,10 +109837,10 @@ async function templatePublish(dir, opts) {
109811
109837
  }
109812
109838
  const form = new FormData();
109813
109839
  form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
109814
- const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
109815
- for (const f2 of files2) add("files", f2, path76.join(root2, f2));
109816
- for (const f2 of opts.preview) add("previews", path76.basename(f2), f2);
109817
- for (const f2 of opts.evidence) add("evidence", path76.basename(f2), f2);
109840
+ const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs76.readFileSync(file)]), path77.basename(name));
109841
+ for (const f2 of files2) add("files", f2, path77.join(root2, f2));
109842
+ for (const f2 of opts.preview) add("previews", path77.basename(f2), f2);
109843
+ for (const f2 of opts.evidence) add("evidence", path77.basename(f2), f2);
109818
109844
  const done2 = await asJson(await ask("", { method: "POST", body: form }));
109819
109845
  say(
109820
109846
  done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files2.length} \u4E2A\u6587\u4EF6\u3002
@@ -109830,11 +109856,11 @@ Deleted ${name} from the catalog.`);
109830
109856
  return { name, deleted: true };
109831
109857
  }
109832
109858
  async function templateShowcase(name, dir) {
109833
- const file = path76.join(dir, "showcase.json");
109834
- if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
109859
+ const file = path77.join(dir, "showcase.json");
109860
+ if (!fs76.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
109835
109861
  let meta;
109836
109862
  try {
109837
- meta = JSON.parse(fs75.readFileSync(file, "utf8"));
109863
+ meta = JSON.parse(fs76.readFileSync(file, "utf8"));
109838
109864
  } catch {
109839
109865
  return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
109840
109866
  }
@@ -109846,9 +109872,9 @@ async function templateShowcase(name, dir) {
109846
109872
  const form = new FormData();
109847
109873
  form.set("meta", JSON.stringify(meta));
109848
109874
  for (const p2 of new Set(named2)) {
109849
- const at2 = path76.join(dir, p2);
109850
- if (!fs75.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
109851
- form.append(`media:${p2}`, new Blob([fs75.readFileSync(at2)]), p2);
109875
+ const at2 = path77.join(dir, p2);
109876
+ if (!fs76.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
109877
+ form.append(`media:${p2}`, new Blob([fs76.readFileSync(at2)]), p2);
109852
109878
  }
109853
109879
  const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
109854
109880
  say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
@@ -109857,7 +109883,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
109857
109883
  }
109858
109884
  function walk2(root2, sub = "") {
109859
109885
  const out = [];
109860
- for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
109886
+ for (const entry of fs76.readdirSync(path77.join(root2, sub), { withFileTypes: true })) {
109861
109887
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
109862
109888
  const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
109863
109889
  if (entry.isDirectory()) out.push(...walk2(root2, rel2));
@@ -110014,8 +110040,12 @@ init_paths();
110014
110040
  init_workflow_diagram();
110015
110041
  init_cloud_workflows();
110016
110042
  init_workflows();
110017
- import fs76 from "node:fs";
110018
- import path77 from "node:path";
110043
+ init_workflow_folder();
110044
+ init_workflow_files();
110045
+ init_config();
110046
+ init_session();
110047
+ import fs77 from "node:fs";
110048
+ import path78 from "node:path";
110019
110049
  var found = (id) => {
110020
110050
  const flow = workflowById(id);
110021
110051
  if (!flow) {
@@ -110071,14 +110101,46 @@ function cmdWorkflowDiagram(id, card) {
110071
110101
  const agent = findSpecAgent(name);
110072
110102
  return agent ? { ...agent, after: agentAfter(name) } : null;
110073
110103
  });
110074
- const file = path77.join(ASSETS, String(cardId2), "workflow.json");
110075
- fs76.mkdirSync(path77.dirname(file), { recursive: true });
110076
- fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
110104
+ const file = path78.join(ASSETS, String(cardId2), "workflow.json");
110105
+ fs77.mkdirSync(path78.dirname(file), { recursive: true });
110106
+ fs77.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
110077
110107
  `);
110078
110108
  const tag = `<Workflow src=".assets/${cardId2}/workflow.json" label="${flow.name.replace(/"/g, "")}" />`;
110079
110109
  say(tag);
110080
110110
  return { file, tag, diagram };
110081
110111
  }
110112
+ var PUBLISH_REFUSED = {
110113
+ not_creator: "only accounts WildCrane has made creators can publish to the marketplace",
110114
+ not_yours: "another creator holds this name, or it is a built-in"
110115
+ };
110116
+ async function cmdWorkflowPublish(folder, opts) {
110117
+ const dir = path78.resolve(folder);
110118
+ if (!fs77.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
110119
+ const slug2 = path78.basename(dir);
110120
+ const files2 = readWorkflowFolder(dir);
110121
+ const checked = checkWorkflowFiles(files2, true);
110122
+ if (!checked.ok) die(`${slug2}: ${checked.file} ${checked.reason}`, "bad-workflow");
110123
+ const token3 = await accessToken();
110124
+ if (!token3.ok) die(SAID[token3.reason].en, "cloud-refused");
110125
+ let res;
110126
+ try {
110127
+ res = await fetch(`${cloudEndpoints().api}/v1/marketplace/workflows`, {
110128
+ method: "POST",
110129
+ headers: { authorization: `Bearer ${token3.token}`, "content-type": "application/json" },
110130
+ body: JSON.stringify({ slug: slug2, files: files2, ...opts.dryRun ? { dry_run: true } : {} })
110131
+ });
110132
+ } catch {
110133
+ die(SAID.unreachable.en, "cloud-refused");
110134
+ }
110135
+ const body = await res.json().catch(() => ({}));
110136
+ if (!res.ok) {
110137
+ if (res.status === 401) die(SAID.expired.en, "cloud-refused");
110138
+ const code = body.error?.code ?? "failed";
110139
+ die(`${slug2}: ${PUBLISH_REFUSED[code] ?? body.error?.message ?? `Cloud answered ${res.status}`}`, code);
110140
+ }
110141
+ say(!body.changed ? `${slug2} is unchanged (v${body.version}).` : opts.dryRun ? `${slug2} would publish v${body.version}.` : `Published ${slug2} v${body.version}.`);
110142
+ return { slug: slug2, id: body.id, version: body.version, changed: body.changed, ...opts.dryRun ? { dryRun: true } : {} };
110143
+ }
110082
110144
 
110083
110145
  // src/commands/run.ts
110084
110146
  init_progress();
@@ -110240,8 +110302,8 @@ init_tasks();
110240
110302
  init_read();
110241
110303
  init_rules();
110242
110304
  init_board();
110243
- import fs85 from "node:fs";
110244
- import path85 from "node:path";
110305
+ import fs86 from "node:fs";
110306
+ import path86 from "node:path";
110245
110307
  var FOLLOW_MS = 400;
110246
110308
  async function cmdStartRun(action, args, opts, program2 = "akb") {
110247
110309
  const { req, follow: follow2, print } = readRequest(action, args, opts);
@@ -110465,7 +110527,7 @@ async function cmdSubStart(words, opts) {
110465
110527
  let prompt = words.join(" ");
110466
110528
  if (opts.file) {
110467
110529
  try {
110468
- prompt = fs85.readFileSync(path85.resolve(opts.file), "utf8");
110530
+ prompt = fs86.readFileSync(path86.resolve(opts.file), "utf8");
110469
110531
  } catch {
110470
110532
  die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
110471
110533
  }
@@ -110756,7 +110818,7 @@ function cmdCompleteDelivery(id, options) {
110756
110818
  // src/commands/triage.ts
110757
110819
  init_scheduled();
110758
110820
  init_workflows();
110759
- import fs87 from "node:fs";
110821
+ import fs88 from "node:fs";
110760
110822
 
110761
110823
  // src/lib/signals/index.ts
110762
110824
  init_cards();
@@ -110766,16 +110828,16 @@ init_yaml();
110766
110828
  // src/lib/signals/config.ts
110767
110829
  init_settings();
110768
110830
  init_paths();
110769
- import fs86 from "node:fs";
110770
- import path86 from "node:path";
110831
+ import fs87 from "node:fs";
110832
+ import path87 from "node:path";
110771
110833
  var TOKEN_KEY = "TRIAGE_ENDPOINT_TOKEN";
110772
110834
  var ENDPOINT_SETTING = "Triage endpoint";
110773
110835
  var LINE2 = /^- \*\*Triage endpoint\*\*\s*[—-]\s*(.+)$/m;
110774
- var boardRel3 = (file) => rel(file).split(path86.sep).join("/");
110836
+ var boardRel3 = (file) => rel(file).split(path87.sep).join("/");
110775
110837
  function signalEndpoint() {
110776
110838
  let text5;
110777
110839
  try {
110778
- text5 = fs86.readFileSync(CONFIG, "utf8");
110840
+ text5 = fs87.readFileSync(CONFIG, "utf8");
110779
110841
  } catch {
110780
110842
  return "";
110781
110843
  }
@@ -110951,7 +111013,7 @@ async function cmdTriageAdd(opts) {
110951
111013
  let body = opts.text;
110952
111014
  if (opts.file !== void 0) {
110953
111015
  try {
110954
- body = fs87.readFileSync(opts.file, "utf8");
111016
+ body = fs88.readFileSync(opts.file, "utf8");
110955
111017
  } catch {
110956
111018
  die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
110957
111019
  }
@@ -111149,7 +111211,7 @@ function cmdTelemetry(args, program2) {
111149
111211
  }
111150
111212
 
111151
111213
  // src/lib/cli/agent.ts
111152
- init_shared();
111214
+ init_shared2();
111153
111215
  async function onBoard2(cmd, cli, work) {
111154
111216
  const ctx = ctxOf(cmd, cli.program);
111155
111217
  await runAction(ctx, {}, async () => {
@@ -111345,6 +111407,9 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
111345
111407
  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) {
111346
111408
  await onBoard2(this, cli, () => cmdWorkflowDiagram(id, card));
111347
111409
  });
111410
+ 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) {
111411
+ await boardless(this, cli, () => cmdWorkflowPublish(folder, this.opts()));
111412
+ });
111348
111413
  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() {
111349
111414
  const ctx = ctxOf(this, cli.program);
111350
111415
  useBoard(resolveBoard("components", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint }), ctx.dir !== null);
@@ -111521,8 +111586,8 @@ function declareAgent(program2, cli) {
111521
111586
  }
111522
111587
 
111523
111588
  // src/lib/cli/setup.ts
111524
- import fs89 from "node:fs";
111525
- import path88 from "node:path";
111589
+ import fs90 from "node:fs";
111590
+ import path89 from "node:path";
111526
111591
  import { fileURLToPath as fileURLToPath3 } from "node:url";
111527
111592
 
111528
111593
  // src/commands/update.ts
@@ -111536,8 +111601,8 @@ init_paths();
111536
111601
  init_memory();
111537
111602
  init_yaml2();
111538
111603
  init_version();
111539
- import fs88 from "node:fs";
111540
- import path87 from "node:path";
111604
+ import fs89 from "node:fs";
111605
+ import path88 from "node:path";
111541
111606
  import { spawnSync as spawnSync5 } from "node:child_process";
111542
111607
  var NAME = "wildcrane";
111543
111608
  var REPO = "https://github.com/wildcrane-ai/wildcrane";
@@ -111559,10 +111624,10 @@ var Report = class {
111559
111624
  for (const line of this.notes) say(` ! ${line}`);
111560
111625
  }
111561
111626
  };
111562
- var read4 = (file) => fs88.existsSync(file) ? fs88.readFileSync(file, "utf8") : null;
111627
+ var read4 = (file) => fs89.existsSync(file) ? fs89.readFileSync(file, "utf8") : null;
111563
111628
  function statOf(p2) {
111564
111629
  try {
111565
- return fs88.lstatSync(p2);
111630
+ return fs89.lstatSync(p2);
111566
111631
  } catch {
111567
111632
  return null;
111568
111633
  }
@@ -111587,10 +111652,10 @@ async function cmdUpdate2(ctx) {
111587
111652
  return { updated: ctx.dir, from, to: SKILL_VERSION };
111588
111653
  }
111589
111654
  async function repairBoard(root2, report3, named2) {
111590
- const legacy2 = path87.join(root2, "docs", "kanban");
111591
- const kept2 = path87.join(root2, ".akb", "kanban");
111592
- const board2 = named2 ?? (fs88.existsSync(legacy2) ? legacy2 : kept2);
111593
- if (!fs88.existsSync(board2)) {
111655
+ const legacy2 = path88.join(root2, "docs", "kanban");
111656
+ const kept2 = path88.join(root2, ".akb", "kanban");
111657
+ const board2 = named2 ?? (fs89.existsSync(legacy2) ? legacy2 : kept2);
111658
+ if (!fs89.existsSync(board2)) {
111594
111659
  report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
111595
111660
  return false;
111596
111661
  }
@@ -111621,20 +111686,20 @@ function moveRuntimes(root2, board2, report3) {
111621
111686
  }
111622
111687
  }
111623
111688
  function moveLegacyMemory(board2, report3) {
111624
- const memory = path87.join(board2, "memory");
111689
+ const memory = path88.join(board2, "memory");
111625
111690
  const moved = [];
111626
111691
  for (const name of MEMORY_FILES) {
111627
- const from = path87.join(board2, name);
111692
+ const from = path88.join(board2, name);
111628
111693
  const st2 = statOf(from);
111629
111694
  if (!st2 || !st2.isFile()) continue;
111630
- fs88.mkdirSync(memory, { recursive: true });
111631
- const to = path87.join(memory, name);
111695
+ fs89.mkdirSync(memory, { recursive: true });
111696
+ const to = path88.join(memory, name);
111632
111697
  const there = read4(to);
111633
111698
  if (there === null) {
111634
- fs88.renameSync(from, to);
111699
+ fs89.renameSync(from, to);
111635
111700
  moved.push(name);
111636
111701
  } else if (there === read4(from)) {
111637
- fs88.rmSync(from);
111702
+ fs89.rmSync(from);
111638
111703
  moved.push(name);
111639
111704
  } else {
111640
111705
  report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
@@ -111643,23 +111708,23 @@ function moveLegacyMemory(board2, report3) {
111643
111708
  if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
111644
111709
  }
111645
111710
  function dropRecordFile(board2) {
111646
- const file = path87.join(board2, "record.csv");
111647
- if (!fs88.existsSync(file)) return null;
111648
- fs88.rmSync(file);
111711
+ const file = path88.join(board2, "record.csv");
111712
+ if (!fs89.existsSync(file)) return null;
111713
+ fs89.rmSync(file);
111649
111714
  return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
111650
111715
  }
111651
111716
  function dropModuleGoals(board2, report3) {
111652
- const memory = path87.join(board2, "memory");
111653
- if (!fs88.existsSync(memory)) return;
111654
- const root2 = read4(path87.join(memory, "goal.md"));
111717
+ const memory = path88.join(board2, "memory");
111718
+ if (!fs89.existsSync(memory)) return;
111719
+ const root2 = read4(path88.join(memory, "goal.md"));
111655
111720
  let dropped = 0;
111656
- for (const entry of fs88.readdirSync(memory, { withFileTypes: true })) {
111721
+ for (const entry of fs89.readdirSync(memory, { withFileTypes: true })) {
111657
111722
  if (!entry.isDirectory()) continue;
111658
- const file = path87.join(memory, entry.name, "goal.md");
111723
+ const file = path88.join(memory, entry.name, "goal.md");
111659
111724
  const text5 = read4(file);
111660
111725
  if (text5 === null) continue;
111661
111726
  if (text5 === root2 || text5.includes(UNFILLED) || !goalWords(text5)) {
111662
- fs88.rmSync(file);
111727
+ fs89.rmSync(file);
111663
111728
  dropped++;
111664
111729
  } else {
111665
111730
  report3.notes.push(
@@ -111681,10 +111746,10 @@ var PLAN_LEADS = {
111681
111746
  var GONE_LEADS = ["software-planner", "planner"];
111682
111747
  function planLeads(board2) {
111683
111748
  const leads = { ...PLAN_LEADS };
111684
- const root2 = path87.join(board2, "workflows");
111685
- for (const entry of fs88.existsSync(root2) ? fs88.readdirSync(root2, { withFileTypes: true }) : []) {
111749
+ const root2 = path88.join(board2, "workflows");
111750
+ for (const entry of fs89.existsSync(root2) ? fs89.readdirSync(root2, { withFileTypes: true }) : []) {
111686
111751
  if (!entry.isDirectory()) continue;
111687
- const meta = splitFrontmatter(read4(path87.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
111752
+ const meta = splitFrontmatter(read4(path88.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
111688
111753
  const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
111689
111754
  const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
111690
111755
  const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
@@ -111693,30 +111758,30 @@ function planLeads(board2) {
111693
111758
  return leads;
111694
111759
  }
111695
111760
  function movePlanRules(board2, report3) {
111696
- const rules = path87.join(board2, "rules");
111761
+ const rules = path88.join(board2, "rules");
111697
111762
  const moved = [];
111698
111763
  for (const [id, leads] of Object.entries(planLeads(board2))) {
111699
111764
  for (const lead of leads) {
111700
- const from = path87.join(rules, `${lead}.md`);
111765
+ const from = path88.join(rules, `${lead}.md`);
111701
111766
  const rule = read4(from)?.trim();
111702
111767
  if (!rule) continue;
111703
- const to = path87.join(rules, "workflows", `${id}.md`);
111768
+ const to = path88.join(rules, "workflows", `${id}.md`);
111704
111769
  const there = read4(to)?.trim() ?? "";
111705
111770
  if (!there.includes(rule)) {
111706
- fs88.mkdirSync(path87.dirname(to), { recursive: true });
111707
- fs88.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
111771
+ fs89.mkdirSync(path88.dirname(to), { recursive: true });
111772
+ fs89.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
111708
111773
  `);
111709
111774
  moved.push(`${lead} \u2192 ${id}`);
111710
111775
  }
111711
111776
  }
111712
111777
  }
111713
- for (const lead of GONE_LEADS) fs88.rmSync(path87.join(rules, `${lead}.md`), { force: true });
111778
+ for (const lead of GONE_LEADS) fs89.rmSync(path88.join(rules, `${lead}.md`), { force: true });
111714
111779
  if (moved.length) report3.did.push(`made each plan agent's rule its workflow's card rule (docs/kanban/rules/workflows/): ${moved.join(", ")}`);
111715
111780
  }
111716
111781
  function noteOldWorkflows(board2, report3) {
111717
111782
  const old = (dir, file, keys) => {
111718
- const root2 = path87.join(board2, dir);
111719
- 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}`);
111783
+ const root2 = path88.join(board2, dir);
111784
+ 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}`);
111720
111785
  };
111721
111786
  const files2 = [...old("workflows", "WORKFLOW.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
111722
111787
  if (files2.length) {
@@ -111726,7 +111791,7 @@ function noteOldWorkflows(board2, report3) {
111726
111791
  }
111727
111792
  }
111728
111793
  function checkConfig(board2, report3) {
111729
- const current = read4(path87.join(board2, "config.md"));
111794
+ const current = read4(path88.join(board2, "config.md"));
111730
111795
  if (!current) return;
111731
111796
  const added = missingConfigKeys(current);
111732
111797
  if (added.length) {
@@ -111736,7 +111801,7 @@ function checkConfig(board2, report3) {
111736
111801
  }
111737
111802
  }
111738
111803
  function checkModules(board2, report3) {
111739
- const map2 = read4(path87.join(board2, "modules.md"));
111804
+ const map2 = read4(path88.join(board2, "modules.md"));
111740
111805
  if (map2 && map2.includes(UNFILLED)) {
111741
111806
  report3.notes.push(
111742
111807
  "docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
@@ -111782,7 +111847,7 @@ function isOlder(a2, b2) {
111782
111847
  // src/lib/cli/setup.ts
111783
111848
  init_io();
111784
111849
  init_version();
111785
- init_shared();
111850
+ init_shared2();
111786
111851
  var spelled = (program2) => program2 === "akb" ? "" : `
111787
111852
  This copy isn't on your PATH as \`akb\` \u2014 every \`akb\` below is \`${program2}\` here.
111788
111853
  `;
@@ -111790,14 +111855,14 @@ function declareSetup(program2, cli) {
111790
111855
  program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
111791
111856
  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");
111792
111857
  const where = (cmd) => {
111793
- const dir = path88.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
111794
- if (!fs89.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
111858
+ const dir = path89.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
111859
+ if (!fs90.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
111795
111860
  return dir;
111796
111861
  };
111797
111862
  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() {
111798
111863
  const dir = where(this);
111799
111864
  const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
111800
- const board2 = named2 ? path88.resolve(cli.cwd, named2) : null;
111865
+ const board2 = named2 ? path89.resolve(cli.cwd, named2) : null;
111801
111866
  await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
111802
111867
  });
111803
111868
  program2.command("__rules", { hidden: true }).action(function() {
@@ -111807,7 +111872,7 @@ function declareSetup(program2, cli) {
111807
111872
 
111808
111873
  // src/lib/cli/akb.ts
111809
111874
  init_io();
111810
- init_shared();
111875
+ init_shared2();
111811
111876
  function buildAkbProgram(cli) {
111812
111877
  const program2 = withShared(newCommand(cli.program));
111813
111878
  program2.description("set up a board, and put an agent to work on it.").helpCommand("help [command]", "this list, or one command in full");
@@ -111824,7 +111889,7 @@ function buildAkbProgram(cli) {
111824
111889
  }
111825
111890
 
111826
111891
  // src/lib/agent-cli.ts
111827
- init_shared();
111892
+ init_shared2();
111828
111893
  init_usage();
111829
111894
  var WATCH = "__watch";
111830
111895
  async function runAgent2(argv, options = {}) {
@@ -111842,7 +111907,7 @@ function invokedDirectly() {
111842
111907
  const entry = process.argv[1];
111843
111908
  if (!entry) return false;
111844
111909
  try {
111845
- return fs90.realpathSync(entry) === fs90.realpathSync(SELF2);
111910
+ return fs91.realpathSync(entry) === fs91.realpathSync(SELF2);
111846
111911
  } catch {
111847
111912
  return false;
111848
111913
  }