wildcrane 0.11.29 → 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 +921 -865
  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.29 — 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.29",
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
 
@@ -15271,8 +15288,8 @@ var init_components = __esm({
15271
15288
  });
15272
15289
 
15273
15290
  // src/lib/memories.ts
15274
- import fs44 from "node:fs";
15275
- import path46 from "node:path";
15291
+ import fs45 from "node:fs";
15292
+ import path47 from "node:path";
15276
15293
  function readMemory(text5, builtIn, folder) {
15277
15294
  const { meta, body } = splitFrontmatter(text5);
15278
15295
  if (meta === null) return null;
@@ -15292,7 +15309,7 @@ function readMemory(text5, builtIn, folder) {
15292
15309
  rules: body.trim(),
15293
15310
  text: text5,
15294
15311
  builtIn,
15295
- dir: path46.join(MEMORY, folder)
15312
+ dir: path47.join(MEMORY, folder)
15296
15313
  };
15297
15314
  }
15298
15315
  function globalMemories() {
@@ -15303,14 +15320,14 @@ function globalMemories() {
15303
15320
  }
15304
15321
  let folders2 = [];
15305
15322
  try {
15306
- 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();
15307
15324
  } catch {
15308
15325
  }
15309
15326
  for (const name of folders2) {
15310
15327
  if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR) continue;
15311
- const file = path46.join(MEMORY, name, GLOBAL_MEMORY_FILE);
15312
- if (!fs44.existsSync(file)) continue;
15313
- 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);
15314
15331
  if (memory) out.push(memory);
15315
15332
  }
15316
15333
  return out;
@@ -15366,16 +15383,16 @@ var init_facts = __esm({
15366
15383
  });
15367
15384
 
15368
15385
  // src/lib/view/archive.ts
15369
- import fs45 from "node:fs";
15370
- import path47 from "node:path";
15386
+ import fs46 from "node:fs";
15387
+ import path48 from "node:path";
15371
15388
  function archivedId(file) {
15372
- const own = idPrefix(path47.basename(file));
15373
- 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)));
15374
15391
  }
15375
15392
  function readFile(file) {
15376
15393
  const id = archivedId(file);
15377
15394
  if (id === null) return null;
15378
- const { meta, body } = parseFrontmatter(fs45.readFileSync(file, "utf8"));
15395
+ const { meta, body } = parseFrontmatter(fs46.readFileSync(file, "utf8"));
15379
15396
  if (!meta) return null;
15380
15397
  return {
15381
15398
  row: {
@@ -15383,15 +15400,15 @@ function readFile(file) {
15383
15400
  title: meta.title,
15384
15401
  archived: meta.archived,
15385
15402
  rejected: meta.rejected,
15386
- relPath: rel(file).split(path47.sep).join("/")
15403
+ relPath: rel(file).split(path48.sep).join("/")
15387
15404
  },
15388
15405
  body: body.replace(/^\n+/, "").replace(/\s+$/, ""),
15389
15406
  meta
15390
15407
  };
15391
15408
  }
15392
15409
  function readArchive() {
15393
- const relPath = rel(ARCHIVE).split(path47.sep).join("/");
15394
- if (!fs45.existsSync(ARCHIVE)) return { relPath, cards: [] };
15410
+ const relPath = rel(ARCHIVE).split(path48.sep).join("/");
15411
+ if (!fs46.existsSync(ARCHIVE)) return { relPath, cards: [] };
15395
15412
  const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
15396
15413
  cards.sort((a2, b2) => b2.id - a2.id);
15397
15414
  return { relPath, cards };
@@ -15406,7 +15423,7 @@ var init_archive = __esm({
15406
15423
  });
15407
15424
 
15408
15425
  // src/lib/agent/prompts.ts
15409
- import path48 from "node:path";
15426
+ import path49 from "node:path";
15410
15427
  function stopReason(deliveryId) {
15411
15428
  const delivery = findDelivery(deliveryId);
15412
15429
  if (!delivery) return void 0;
@@ -15469,7 +15486,7 @@ ${text5}` : "";
15469
15486
  }
15470
15487
  function cardFileOf(id) {
15471
15488
  const found2 = id === void 0 ? null : locate(id);
15472
- 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 : "";
15473
15490
  }
15474
15491
  function realPaths(text5, req) {
15475
15492
  if (req.action !== "scheduled" && req.action !== "sub") return text5;
@@ -15556,7 +15573,7 @@ function frozenRules(req) {
15556
15573
  function archivedCardFile(id) {
15557
15574
  const found2 = locateArchived(id);
15558
15575
  if (!found2) return `${rel(ARCHIVE)}/`;
15559
- 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);
15560
15577
  }
15561
15578
  function shippedLines(cardId2) {
15562
15579
  const delivery = endedDelivery(`${cardId2}`);
@@ -15699,7 +15716,7 @@ function actionPrompt(req, command, notes) {
15699
15716
  case "spec": {
15700
15717
  const agent = findSpecAgent(req.specAgent ?? "");
15701
15718
  const found2 = req.id === void 0 ? null : locate(req.id);
15702
- 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}`;
15703
15720
  const own = agent ? specAgentInstructions(agent) : null;
15704
15721
  if (own) notes.push(...own.notes);
15705
15722
  const memory = agent ? agentMemoryBlock(agent) : "";
@@ -15880,17 +15897,17 @@ var init_prompts = __esm({
15880
15897
  // src/lib/agent/stop.ts
15881
15898
  import { spawnSync as spawnSync4 } from "node:child_process";
15882
15899
  import { randomUUID as randomUUID4 } from "node:crypto";
15883
- import fs46 from "node:fs";
15900
+ import fs47 from "node:fs";
15884
15901
  import os6 from "node:os";
15885
15902
  function markedInProc(entry, strict = false) {
15886
15903
  const pids = [];
15887
- for (const name of fs46.readdirSync("/proc")) {
15904
+ for (const name of fs47.readdirSync("/proc")) {
15888
15905
  if (!/^\d+$/.test(name)) continue;
15889
15906
  try {
15890
- 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));
15891
15908
  } catch (error) {
15892
15909
  if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
15893
- const stat = fs46.statSync(`/proc/${name}`, { throwIfNoEntry: false });
15910
+ const stat = fs47.statSync(`/proc/${name}`, { throwIfNoEntry: false });
15894
15911
  if (stat?.uid === process.getuid?.()) throw error;
15895
15912
  }
15896
15913
  }
@@ -16086,10 +16103,10 @@ var init_stop = __esm({
16086
16103
  });
16087
16104
 
16088
16105
  // src/lib/agent/creation-lock.ts
16089
- import path49 from "node:path";
16106
+ import path50 from "node:path";
16090
16107
  function withCreationLock(fn2) {
16091
16108
  if (depth2) return fn2();
16092
- return withLock(path49.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
16109
+ return withLock(path50.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
16093
16110
  depth2++;
16094
16111
  try {
16095
16112
  return fn2();
@@ -16110,8 +16127,8 @@ var init_creation_lock = __esm({
16110
16127
 
16111
16128
  // src/lib/agent/sessions.ts
16112
16129
  import { randomUUID as randomUUID5 } from "node:crypto";
16113
- import fs47 from "node:fs";
16114
- import path50 from "node:path";
16130
+ import fs48 from "node:fs";
16131
+ import path51 from "node:path";
16115
16132
  function reap(runs, reaped = [], restore = []) {
16116
16133
  let changed = false;
16117
16134
  const now = Date.now();
@@ -16131,7 +16148,7 @@ function reap(runs, reaped = [], restore = []) {
16131
16148
  }
16132
16149
  function stampDuration(run3, endedAt) {
16133
16150
  try {
16134
- fs47.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
16151
+ fs48.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
16135
16152
  } catch {
16136
16153
  }
16137
16154
  }
@@ -16145,7 +16162,7 @@ function cardNow(cardId2) {
16145
16162
  try {
16146
16163
  const file = cardFile(cardId2);
16147
16164
  if (!file) return null;
16148
- const { meta } = parseFrontmatter(fs47.readFileSync(file, "utf8"));
16165
+ const { meta } = parseFrontmatter(fs48.readFileSync(file, "utf8"));
16149
16166
  if (!meta) return null;
16150
16167
  return { status: meta.status || "todo", questions: openOf(meta.questions).length, title: meta.title };
16151
16168
  } catch {
@@ -16277,9 +16294,9 @@ function leftBoardOnLanding(id) {
16277
16294
  function archivedRejected(id) {
16278
16295
  const filed = locateArchived(id);
16279
16296
  if (!filed) return null;
16280
- 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;
16281
16298
  try {
16282
- return !!parseFrontmatter(fs47.readFileSync(file, "utf8")).meta?.rejected;
16299
+ return !!parseFrontmatter(fs48.readFileSync(file, "utf8")).meta?.rejected;
16283
16300
  } catch {
16284
16301
  return false;
16285
16302
  }
@@ -16530,7 +16547,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID5(), said3) {
16530
16547
  return { run: record, spec };
16531
16548
  }
16532
16549
  function planningSession(cardId2, cwd = REPO_ROOT) {
16533
- const here = (dir) => !dir || path50.resolve(dir) === cwd;
16550
+ const here = (dir) => !dir || path51.resolve(dir) === cwd;
16534
16551
  const planned = readRuns().filter((r2) => r2.status === "done" && r2.cardId === cardId2 && PLANNING.has(r2.action)).sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
16535
16552
  if (!planned) return { none: "unrecorded" };
16536
16553
  if (!here(planned.cwd)) return { none: "elsewhere" };
@@ -16749,8 +16766,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
16749
16766
  if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
16750
16767
  clearAsks(prev.sessionId);
16751
16768
  try {
16752
- fs47.unlinkSync(prev.logPath);
16753
- fs47.rmSync(eventsPathOf(prev.sessionId), { force: true });
16769
+ fs48.unlinkSync(prev.logPath);
16770
+ fs48.rmSync(eventsPathOf(prev.sessionId), { force: true });
16754
16771
  } catch {
16755
16772
  }
16756
16773
  if (retry2 && prev.pictures?.length) {
@@ -16773,8 +16790,8 @@ function forgetRun(sessionId) {
16773
16790
  if (!gone) return;
16774
16791
  clearAsks(sessionId);
16775
16792
  try {
16776
- fs47.unlinkSync(gone.logPath);
16777
- fs47.rmSync(eventsPathOf(gone.sessionId), { force: true });
16793
+ fs48.unlinkSync(gone.logPath);
16794
+ fs48.rmSync(eventsPathOf(gone.sessionId), { force: true });
16778
16795
  } catch {
16779
16796
  }
16780
16797
  }
@@ -16803,14 +16820,14 @@ function noteSpecRefusals(sessionId, refused) {
16803
16820
  }
16804
16821
  function clearAsks(sessionId) {
16805
16822
  try {
16806
- fs47.unlinkSync(asksPathOf(sessionId));
16823
+ fs48.unlinkSync(asksPathOf(sessionId));
16807
16824
  } catch {
16808
16825
  }
16809
16826
  }
16810
16827
  function readAsks(sessionId) {
16811
16828
  let data;
16812
16829
  try {
16813
- data = JSON.parse(fs47.readFileSync(asksPathOf(sessionId), "utf8"));
16830
+ data = JSON.parse(fs48.readFileSync(asksPathOf(sessionId), "utf8"));
16814
16831
  } catch {
16815
16832
  return { asks: [], refines: [], refused: [] };
16816
16833
  }
@@ -16837,10 +16854,10 @@ function readAsks(sessionId) {
16837
16854
  return { asks: asks.filter((a2) => !discarded.has(a2.cardId)), refines: refines.filter((a2) => !discarded.has(a2.cardId)), refused };
16838
16855
  }
16839
16856
  function writeAsks(sessionId, file) {
16840
- fs47.mkdirSync(SESSIONS_DIR, { recursive: true });
16857
+ fs48.mkdirSync(SESSIONS_DIR, { recursive: true });
16841
16858
  const tmp = `${asksPathOf(sessionId)}.tmp`;
16842
- fs47.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
16843
- fs47.renameSync(tmp, asksPathOf(sessionId));
16859
+ fs48.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
16860
+ fs48.renameSync(tmp, asksPathOf(sessionId));
16844
16861
  }
16845
16862
  function markSpawned(sessionId, pid) {
16846
16863
  patch(sessionId, (r2) => {
@@ -16971,12 +16988,12 @@ async function resumeDelivery(id) {
16971
16988
  return { ok: true, deliveryId: delivery.deliveryId, carryOn };
16972
16989
  }
16973
16990
  function writeSpec(spec) {
16974
- fs47.mkdirSync(SESSIONS_DIR, { recursive: true });
16975
- 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");
16976
16993
  }
16977
16994
  function readSpec(sessionId) {
16978
16995
  try {
16979
- const spec = JSON.parse(fs47.readFileSync(specPathOf(sessionId), "utf8"));
16996
+ const spec = JSON.parse(fs48.readFileSync(specPathOf(sessionId), "utf8"));
16980
16997
  return spec && Array.isArray(spec.plan?.argv) ? spec : null;
16981
16998
  } catch {
16982
16999
  return null;
@@ -16984,28 +17001,28 @@ function readSpec(sessionId) {
16984
17001
  }
16985
17002
  function dropSpec(sessionId) {
16986
17003
  try {
16987
- fs47.unlinkSync(specPathOf(sessionId));
17004
+ fs48.unlinkSync(specPathOf(sessionId));
16988
17005
  } catch {
16989
17006
  }
16990
17007
  }
16991
17008
  async function acquireIndexLock(giveUp) {
16992
17009
  const until = Date.now() + INDEX_WAIT_MS;
16993
- const holder = path50.join(INDEX_LOCK2, "holder");
17010
+ const holder = path51.join(INDEX_LOCK2, "holder");
16994
17011
  for (; ; ) {
16995
17012
  if (giveUp()) return null;
16996
17013
  try {
16997
- fs47.mkdirSync(INDEX_LOCK2, { recursive: false });
16998
- fs47.writeFileSync(holder, String(process.pid));
16999
- 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 });
17000
17017
  } catch (err) {
17001
17018
  const code = err.code;
17002
17019
  if (code === "ENOENT") {
17003
- fs47.mkdirSync(path50.dirname(INDEX_LOCK2), { recursive: true });
17020
+ fs48.mkdirSync(path51.dirname(INDEX_LOCK2), { recursive: true });
17004
17021
  continue;
17005
17022
  }
17006
17023
  if (code !== "EEXIST") throw err;
17007
17024
  if (!pidAlive(Number(readHolder(holder)))) {
17008
- fs47.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17025
+ fs48.rmSync(INDEX_LOCK2, { recursive: true, force: true });
17009
17026
  continue;
17010
17027
  }
17011
17028
  if (Date.now() > until) return null;
@@ -17015,7 +17032,7 @@ async function acquireIndexLock(giveUp) {
17015
17032
  }
17016
17033
  function readHolder(file) {
17017
17034
  try {
17018
- return fs47.readFileSync(file, "utf8").trim();
17035
+ return fs48.readFileSync(file, "utf8").trim();
17019
17036
  } catch {
17020
17037
  return String(process.pid);
17021
17038
  }
@@ -17101,8 +17118,8 @@ var init_sessions = __esm({
17101
17118
  implement: "implementing",
17102
17119
  hook: "implementing"
17103
17120
  };
17104
- specPathOf = (sessionId) => path50.join(SESSIONS_DIR, `${sessionId}.plan.json`);
17105
- 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`);
17106
17123
  carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
17107
17124
  canPickUp = (r2) => r2.status === "error" || r2.status === "interrupted" || r2.status === "stopped";
17108
17125
  neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
@@ -17155,8 +17172,8 @@ var init_sources = __esm({
17155
17172
  });
17156
17173
 
17157
17174
  // src/lib/signals/inbox.ts
17158
- import fs48 from "node:fs";
17159
- import path51 from "node:path";
17175
+ import fs49 from "node:fs";
17176
+ import path52 from "node:path";
17160
17177
  function metaPair(key, value) {
17161
17178
  const name = typeof key === "string" ? key.trim() : "";
17162
17179
  if (!name) return null;
@@ -17187,7 +17204,7 @@ ${signal2.summary.trim()}
17187
17204
  function parse(file, lenient = false) {
17188
17205
  let text5;
17189
17206
  try {
17190
- text5 = fs48.readFileSync(file, "utf8");
17207
+ text5 = fs49.readFileSync(file, "utf8");
17191
17208
  } catch {
17192
17209
  return null;
17193
17210
  }
@@ -17241,20 +17258,20 @@ function parse(file, lenient = false) {
17241
17258
  };
17242
17259
  }
17243
17260
  function freeName(dir, wanted) {
17244
- const ext = path51.extname(wanted);
17261
+ const ext = path52.extname(wanted);
17245
17262
  const stem = wanted.slice(0, wanted.length - ext.length);
17246
17263
  let name = wanted;
17247
- 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}`;
17248
17265
  return name;
17249
17266
  }
17250
17267
  function readFolder2(dir, lenient = false) {
17251
17268
  let entries;
17252
17269
  try {
17253
- entries = fs48.readdirSync(dir, { withFileTypes: true });
17270
+ entries = fs49.readdirSync(dir, { withFileTypes: true });
17254
17271
  } catch {
17255
17272
  return [];
17256
17273
  }
17257
- 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);
17258
17275
  }
17259
17276
  function readInbox() {
17260
17277
  const signals = readFolder2(TRIAGE);
@@ -17262,7 +17279,7 @@ function readInbox() {
17262
17279
  return signals;
17263
17280
  }
17264
17281
  function writeSignal(incoming, importedAt, slug2 = "") {
17265
- fs48.mkdirSync(TRIAGE, { recursive: true });
17282
+ fs49.mkdirSync(TRIAGE, { recursive: true });
17266
17283
  const signal2 = {
17267
17284
  ...incoming,
17268
17285
  importedAt,
@@ -17274,12 +17291,12 @@ function writeSignal(incoming, importedAt, slug2 = "") {
17274
17291
  contentKept: true,
17275
17292
  relPath: ""
17276
17293
  };
17277
- const file = path51.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
17278
- 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) }));
17279
17296
  return { ...signal2, relPath: boardRel(file) };
17280
17297
  }
17281
17298
  function stamp3(file, fields) {
17282
- const text5 = fs48.readFileSync(file, "utf8");
17299
+ const text5 = fs49.readFileSync(file, "utf8");
17283
17300
  const lines = text5.split("\n");
17284
17301
  const close = lines.indexOf("---", 1);
17285
17302
  if (close < 0) return;
@@ -17288,13 +17305,13 @@ function stamp3(file, fields) {
17288
17305
  return !key || fields[key[1]] === void 0;
17289
17306
  });
17290
17307
  const added = Object.entries(fields).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
17291
- fs48.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
17308
+ fs49.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
17292
17309
  }
17293
17310
  function moveSignal(from, into, fields) {
17294
- if (!fs48.existsSync(from)) return "";
17295
- fs48.mkdirSync(into, { recursive: true });
17296
- const at2 = path51.join(into, freeName(into, path51.basename(from)));
17297
- 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);
17298
17315
  stamp3(at2, fields);
17299
17316
  return boardRel(at2);
17300
17317
  }
@@ -17307,8 +17324,8 @@ function dismissInboxItems(sourceIds, by, reason = "") {
17307
17324
  const found2 = waiting.get(sourceId);
17308
17325
  if (!found2) return missing;
17309
17326
  const already = ignored.get(sourceId);
17310
- if (already) fs48.rmSync(path51.join(SIGNALS_DISMISSED, path51.basename(already.relPath)), { force: true });
17311
- 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, {
17312
17329
  dismissed_at: formatStamp(/* @__PURE__ */ new Date()),
17313
17330
  dismissed_by: by,
17314
17331
  ...why2 ? { dismissed_reason: why2 } : {}
@@ -17324,10 +17341,10 @@ function archiveInboxItem(sourceId, cardId2) {
17324
17341
  if (!found2) {
17325
17342
  const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
17326
17343
  if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
17327
- 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) });
17328
17345
  return { ok: true, relPath: ignored.relPath, where: "dismissed" };
17329
17346
  }
17330
- 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, {
17331
17348
  card_id: String(cardId2),
17332
17349
  archived_at: formatStamp(/* @__PURE__ */ new Date())
17333
17350
  });
@@ -17345,7 +17362,7 @@ function restoreInboxItems(sourceIds) {
17345
17362
  return refuse3(`${sourceId} was kept without its content, so there is nothing to restore`);
17346
17363
  }
17347
17364
  if (waiting.has(sourceId)) return refuse3(`${sourceId} is already waiting in triage`);
17348
- 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, {
17349
17366
  dismissed_at: null,
17350
17367
  dismissed_by: null,
17351
17368
  dismissed_reason: null
@@ -17364,7 +17381,7 @@ var init_inbox = __esm({
17364
17381
  init_sources();
17365
17382
  init_paths();
17366
17383
  init_yaml();
17367
- boardRel = (file) => rel(file).split(path51.sep).join("/");
17384
+ boardRel = (file) => rel(file).split(path52.sep).join("/");
17368
17385
  FIELDS = ["source_id", "title", "collected_at", "imported_at"];
17369
17386
  META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
17370
17387
  slugOf = (said3) => said3.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
@@ -17581,12 +17598,12 @@ var init_workflow_cards = __esm({
17581
17598
  });
17582
17599
 
17583
17600
  // src/lib/readme.ts
17584
- import fs49 from "node:fs";
17585
- import path52 from "node:path";
17601
+ import fs50 from "node:fs";
17602
+ import path53 from "node:path";
17586
17603
  function stripReadmeRefs(target) {
17587
- if (!fs49.existsSync(README)) return [];
17604
+ if (!fs50.existsSync(README)) return [];
17588
17605
  const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
17589
- const lines = fs49.readFileSync(README, "utf8").split("\n");
17606
+ const lines = fs50.readFileSync(README, "utf8").split("\n");
17590
17607
  const out = [];
17591
17608
  const removed = [];
17592
17609
  let i = 0;
@@ -17608,20 +17625,20 @@ function stripReadmeRefs(target) {
17608
17625
  out.push(line);
17609
17626
  i++;
17610
17627
  }
17611
- if (removed.length) fs49.writeFileSync(README, out.join("\n"));
17628
+ if (removed.length) fs50.writeFileSync(README, out.join("\n"));
17612
17629
  return removed;
17613
17630
  }
17614
17631
  function addReadmeRef(id, title, relPath) {
17615
- if (!fs49.existsSync(README)) return false;
17616
- const link2 = relPath.split(path52.sep).join("/");
17632
+ if (!fs50.existsSync(README)) return false;
17633
+ const link2 = relPath.split(path53.sep).join("/");
17617
17634
  const bullet = `- [#${id} ${title}](${link2})`;
17618
17635
  const heading = `## ${TASKS_HEADING}`;
17619
- let lines = fs49.readFileSync(README, "utf8").split("\n");
17636
+ let lines = fs50.readFileSync(README, "utf8").split("\n");
17620
17637
  const hi2 = lines.findIndex((l2) => l2.trim().toLowerCase() === heading.toLowerCase());
17621
17638
  if (hi2 === -1) {
17622
17639
  while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
17623
17640
  lines.push("", heading, "", bullet);
17624
- fs49.writeFileSync(README, lines.join("\n") + "\n");
17641
+ fs50.writeFileSync(README, lines.join("\n") + "\n");
17625
17642
  return true;
17626
17643
  }
17627
17644
  let end2 = hi2 + 1;
@@ -17635,15 +17652,15 @@ function addReadmeRef(id, title, relPath) {
17635
17652
  const at2 = lastBullet !== -1 ? lastBullet + 1 : lines[hi2 + 1] === "" ? hi2 + 2 : hi2 + 1;
17636
17653
  lines.splice(at2, 0, bullet);
17637
17654
  }
17638
- fs49.writeFileSync(README, lines.join("\n"));
17655
+ fs50.writeFileSync(README, lines.join("\n"));
17639
17656
  return true;
17640
17657
  }
17641
17658
  function repointReadmeLink(id, oldRel, newRel, title) {
17642
- if (!fs49.existsSync(README)) return false;
17643
- const oldLink = oldRel.split(path52.sep).join("/");
17644
- 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("/");
17645
17662
  const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
17646
- const lines = fs49.readFileSync(README, "utf8").split("\n");
17663
+ const lines = fs50.readFileSync(README, "utf8").split("\n");
17647
17664
  let changed = false;
17648
17665
  for (let i = 0; i < lines.length; i++) {
17649
17666
  if (!lines[i].includes(`](${oldLink})`)) continue;
@@ -17653,7 +17670,7 @@ function repointReadmeLink(id, oldRel, newRel, title) {
17653
17670
  changed = true;
17654
17671
  }
17655
17672
  }
17656
- if (changed) fs49.writeFileSync(README, lines.join("\n"));
17673
+ if (changed) fs50.writeFileSync(README, lines.join("\n"));
17657
17674
  return changed;
17658
17675
  }
17659
17676
  var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex;
@@ -18139,14 +18156,14 @@ function collect(body, card, host2) {
18139
18156
  const active2 = /* @__PURE__ */ new Set();
18140
18157
  const out = [];
18141
18158
  const visit = (src, types, owner) => {
18142
- const path89 = src.replace(/[?#].*$/, "");
18159
+ const path90 = src.replace(/[?#].*$/, "");
18143
18160
  let resolved2;
18144
18161
  try {
18145
- resolved2 = host2.resolve(path89, owner);
18162
+ resolved2 = host2.resolve(path90, owner);
18146
18163
  } catch (error) {
18147
18164
  if (owner !== card) return { key: null, error: why(error) };
18148
18165
  if (!nodes.has(src)) {
18149
- 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]) };
18150
18167
  nodes.set(src, node2);
18151
18168
  out.push(node2);
18152
18169
  }
@@ -18231,16 +18248,16 @@ var init_collect = __esm({
18231
18248
  });
18232
18249
 
18233
18250
  // src/lib/dress-page.ts
18234
- import fs50 from "node:fs";
18235
- import path53 from "node:path";
18251
+ import fs51 from "node:fs";
18252
+ import path54 from "node:path";
18236
18253
  function dressPage(file) {
18237
- const folder = path53.dirname(file);
18238
- 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) => {
18239
18256
  const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
18240
18257
  if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
18241
- const at3 = path53.resolve(folder, href);
18242
- if (!at3.startsWith(folder + path53.sep) || !fs50.existsSync(at3)) return tag;
18243
- 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})`);
18244
18261
  return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
18245
18262
  });
18246
18263
  const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
@@ -18252,25 +18269,25 @@ var init_dress_page = __esm({
18252
18269
  "use strict";
18253
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'";
18254
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>`;
18255
- 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");
18256
18273
  }
18257
18274
  });
18258
18275
 
18259
18276
  // src/lib/preview-files.ts
18260
- import fs51 from "node:fs";
18261
- import path54 from "node:path";
18277
+ import fs52 from "node:fs";
18278
+ import path55 from "node:path";
18262
18279
  function resolver(card, id) {
18263
- const roots = [KANBAN, path54.join(ASSETS, String(id)), path54.join(MOCKUPS, String(id))];
18264
- const real2 = (p2) => fs51.existsSync(p2) ? fs51.realpathSync(p2) : p2;
18265
- 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));
18266
18283
  return (src, owner) => {
18267
18284
  if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
18268
- 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");
18269
18286
  const held4 = /^\.(assets|mockups)\//.exec(src);
18270
- const file = held4 ? path54.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path54.resolve(path54.dirname(owner), src);
18271
- if (!inside2(path54.resolve(file)) || fs51.existsSync(file) && !inside2(fs51.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
18272
- if (!fs51.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
18273
- 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 };
18274
18291
  };
18275
18292
  }
18276
18293
  function validatePreviewFiles(card, id, text5) {
@@ -18305,8 +18322,8 @@ var init_preview_files = __esm({
18305
18322
  });
18306
18323
 
18307
18324
  // src/lib/spec-contract.ts
18308
- import fs52 from "node:fs";
18309
- import path55 from "node:path";
18325
+ import fs53 from "node:fs";
18326
+ import path56 from "node:path";
18310
18327
  function scanCardLines(lines, start = 0) {
18311
18328
  const visible = lines.map(() => "");
18312
18329
  let fence = null;
@@ -18339,18 +18356,18 @@ function scanCardLines(lines, start = 0) {
18339
18356
  }
18340
18357
  function snapshotSpecs() {
18341
18358
  const out = /* @__PURE__ */ new Map();
18342
- if (!fs52.existsSync(TODO)) return out;
18359
+ if (!fs53.existsSync(TODO)) return out;
18343
18360
  for (const file of walkMd(TODO)) {
18344
- if (isLegacyRecurring(path55.relative(TODO, file))) continue;
18345
- const id = idPrefix(path55.basename(file) === "root.md" ? path55.basename(path55.dirname(file)) : path55.basename(file));
18346
- 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") });
18347
18364
  }
18348
18365
  return out;
18349
18366
  }
18350
18367
  function enclosingGroups(file) {
18351
18368
  const ids = [];
18352
18369
  for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
18353
- const id = idPrefix(path55.basename(path55.dirname(root2)));
18370
+ const id = idPrefix(path56.basename(path56.dirname(root2)));
18354
18371
  if (id !== null) ids.push(id);
18355
18372
  }
18356
18373
  return ids;
@@ -18508,9 +18525,9 @@ function validateSpec(file, text5, id) {
18508
18525
  }
18509
18526
  function inside(dir, name) {
18510
18527
  try {
18511
- const root2 = fs52.realpathSync(dir);
18512
- const real2 = fs52.realpathSync(path55.join(dir, name));
18513
- 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;
18514
18531
  } catch {
18515
18532
  return null;
18516
18533
  }
@@ -18528,7 +18545,7 @@ function variantsProblem(raw, src, id) {
18528
18545
  if (files2.length < 2 || !files2.every((f2) => typeof f2 === "string" && f2)) return `variants needs at least two labels, each naming a file. ${shape}`;
18529
18546
  if (!files2.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
18530
18547
  if (id === void 0) return null;
18531
- const dir = path55.join(ASSETS, String(id));
18548
+ const dir = path56.join(ASSETS, String(id));
18532
18549
  for (const f2 of files2) {
18533
18550
  const parts = f2.split("/");
18534
18551
  if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
@@ -18538,7 +18555,7 @@ function variantsProblem(raw, src, id) {
18538
18555
  return null;
18539
18556
  }
18540
18557
  function compareProblem(attrs, id) {
18541
- const dir = path55.join(ASSETS, String(id));
18558
+ const dir = path56.join(ASSETS, String(id));
18542
18559
  const src = (message) => ({ rule: "compare-src", message });
18543
18560
  const shots = (message) => ({ rule: "compare-shots", message });
18544
18561
  for (const side of ["a", "b"]) {
@@ -18558,7 +18575,7 @@ function compareProblem(attrs, id) {
18558
18575
  const file = inside(dir, named2.name);
18559
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.` };
18560
18577
  try {
18561
- return { data: JSON.parse(fs52.readFileSync(file, "utf8")) };
18578
+ return { data: JSON.parse(fs53.readFileSync(file, "utf8")) };
18562
18579
  } catch {
18563
18580
  return { message: `${at2} is not valid JSON.` };
18564
18581
  }
@@ -18578,7 +18595,7 @@ function compareProblem(attrs, id) {
18578
18595
  }
18579
18596
  function validateStoryboards(file, id, text5) {
18580
18597
  const errors = [];
18581
- const dir = path55.join(ASSETS, String(id));
18598
+ const dir = path56.join(ASSETS, String(id));
18582
18599
  for (const [tag, tagOf, rule, fix] of [
18583
18600
  ["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
18584
18601
  ["Workflow", workflowTag, "workflow-src", "Write it with `akb workflow diagram <workflow id> <card id>` or fix the path."]
@@ -18655,14 +18672,14 @@ var init_spec_contract = __esm({
18655
18672
  });
18656
18673
 
18657
18674
  // src/lib/reconcile.ts
18658
- import fs53 from "node:fs";
18659
- import path56 from "node:path";
18675
+ import fs54 from "node:fs";
18676
+ import path57 from "node:path";
18660
18677
  function liveIds() {
18661
18678
  const ids = /* @__PURE__ */ new Set();
18662
18679
  for (const file of walkMd(TODO)) {
18663
- const base = path56.basename(file);
18680
+ const base = path57.basename(file);
18664
18681
  if (base === "README.md") continue;
18665
- 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);
18666
18683
  if (id != null) ids.add(id);
18667
18684
  }
18668
18685
  return ids;
@@ -18670,16 +18687,16 @@ function liveIds() {
18670
18687
  function indexableCards() {
18671
18688
  const out = [];
18672
18689
  for (const dir of walkDirs(TODO)) {
18673
- const id = idPrefix(path56.basename(dir));
18674
- if (id != null && fs53.existsSync(path56.join(dir, "root.md"))) {
18675
- 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("/") });
18676
18693
  }
18677
18694
  }
18678
18695
  for (const file of walkMd(TODO)) {
18679
- const base = path56.basename(file);
18696
+ const base = path57.basename(file);
18680
18697
  if (base === "README.md" || base === "root.md") continue;
18681
- const relTODO = path56.relative(TODO, file);
18682
- const segs = relTODO.split(path56.sep);
18698
+ const relTODO = path57.relative(TODO, file);
18699
+ const segs = relTODO.split(path57.sep);
18683
18700
  if (segs.length !== 1) continue;
18684
18701
  const id = idPrefix(base);
18685
18702
  if (id != null) out.push({ id, rel: segs.join("/") });
@@ -18688,7 +18705,7 @@ function indexableCards() {
18688
18705
  }
18689
18706
  function readmeComplaints(fix) {
18690
18707
  const said3 = [];
18691
- const lines = fs53.readFileSync(README, "utf8").split("\n");
18708
+ const lines = fs54.readFileSync(README, "utf8").split("\n");
18692
18709
  const indexed = /* @__PURE__ */ new Set();
18693
18710
  let fixed = 0;
18694
18711
  for (let i = 0; i < lines.length; i++) {
@@ -18697,13 +18714,13 @@ function readmeComplaints(fix) {
18697
18714
  const id = Number(m[1]);
18698
18715
  const linkPath = m[2];
18699
18716
  indexed.add(id);
18700
- if (fs53.existsSync(path56.join(TODO, linkPath))) continue;
18717
+ if (fs54.existsSync(path57.join(TODO, linkPath))) continue;
18701
18718
  const found2 = locate(id);
18702
18719
  if (!found2) {
18703
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.`);
18704
18721
  continue;
18705
18722
  }
18706
- 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("/");
18707
18724
  if (want === linkPath) continue;
18708
18725
  if (!fix) {
18709
18726
  said3.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
@@ -18713,7 +18730,7 @@ function readmeComplaints(fix) {
18713
18730
  said3.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
18714
18731
  fixed++;
18715
18732
  }
18716
- if (fixed) fs53.writeFileSync(README, lines.join("\n"));
18733
+ if (fixed) fs54.writeFileSync(README, lines.join("\n"));
18717
18734
  for (const c2 of indexableCards()) {
18718
18735
  if (!indexed.has(c2.id)) {
18719
18736
  said3.push(`card ${c2.rel} (#${c2.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
@@ -18725,11 +18742,11 @@ function crossRefComplaints() {
18725
18742
  const said3 = [];
18726
18743
  const live = liveIds();
18727
18744
  for (const file of walkMd(TODO)) {
18728
- const base = path56.basename(file);
18745
+ const base = path57.basename(file);
18729
18746
  if (base === "README.md") continue;
18730
- 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);
18731
18748
  if (ownerId == null) continue;
18732
- const { meta } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
18749
+ const { meta } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
18733
18750
  if (!meta) continue;
18734
18751
  for (const field2 of ["blocked_by", "related"]) {
18735
18752
  for (const ref of meta[field2] || []) {
@@ -18742,11 +18759,11 @@ function crossRefComplaints() {
18742
18759
  return said3;
18743
18760
  }
18744
18761
  function reconcileBoard() {
18745
- if (!fs53.existsSync(README)) return;
18762
+ if (!fs54.existsSync(README)) return;
18746
18763
  for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
18747
18764
  }
18748
18765
  function boardComplaints() {
18749
- if (!fs53.existsSync(README)) return [];
18766
+ if (!fs54.existsSync(README)) return [];
18750
18767
  try {
18751
18768
  return [...readmeComplaints(false), ...crossRefComplaints()];
18752
18769
  } catch {
@@ -18766,8 +18783,8 @@ var init_reconcile = __esm({
18766
18783
  });
18767
18784
 
18768
18785
  // src/commands/card.ts
18769
- import fs54 from "node:fs";
18770
- import path57 from "node:path";
18786
+ import fs55 from "node:fs";
18787
+ import path58 from "node:path";
18771
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>") {
18772
18789
  return [
18773
18790
  summary,
@@ -18793,7 +18810,7 @@ function bodyFromFile(opts) {
18793
18810
  if (opts.body === false) die("pass --body-file or --no-body, not both");
18794
18811
  let text5;
18795
18812
  try {
18796
- text5 = fs54.readFileSync(opts.bodyFile, "utf8");
18813
+ text5 = fs55.readFileSync(opts.bodyFile, "utf8");
18797
18814
  } catch {
18798
18815
  die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
18799
18816
  }
@@ -18873,20 +18890,20 @@ function cmdCreate(opts) {
18873
18890
  const start = opts.id;
18874
18891
  const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
18875
18892
  const fileRel = `${start}-${slug2}.md`;
18876
- const file = path57.join(TODO, fileRel);
18893
+ const file = path58.join(TODO, fileRel);
18877
18894
  const held4 = locate(start) ?? locateArchived(start);
18878
- if (held4 && path57.basename(held4.target) === `${start}-${slug2}.md`) {
18895
+ if (held4 && path58.basename(held4.target) === `${start}-${slug2}.md`) {
18879
18896
  say(start);
18880
18897
  say(` ${rel(held4.target)} was already written`);
18881
18898
  return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
18882
18899
  }
18883
18900
  if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
18884
- 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`);
18885
18902
  countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
18886
18903
  const meta = { title, priority, status: "todo", blocked_by, related, modules, workflow, previews, stages, triage, source, questions };
18887
18904
  const scaffolded = !written && opts.body !== false;
18888
18905
  const body = written ?? (scaffolded ? defaultBody() : "");
18889
- fs54.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
18906
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
18890
18907
  const indexed = addReadmeRef(start, title, fileRel);
18891
18908
  say(start);
18892
18909
  say(
@@ -18938,8 +18955,8 @@ function cmdUpdate(id, flags) {
18938
18955
  if (creating) die(creating, { kind: "card-being-created", id });
18939
18956
  const found2 = locate(id);
18940
18957
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
18941
- const file = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
18942
- 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"));
18943
18960
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
18944
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");
18945
18962
  if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
@@ -19013,26 +19030,26 @@ function cmdUpdate(id, flags) {
19013
19030
  meta.status = "todo";
19014
19031
  changes.push("status\u2192todo (open questions)");
19015
19032
  }
19016
- const curRel = path57.relative(TODO, file);
19033
+ const curRel = path58.relative(TODO, file);
19017
19034
  const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
19018
- let base = path57.basename(file);
19035
+ let base = path58.basename(file);
19019
19036
  if (flags.slug !== void 0) {
19020
19037
  if (found2.kind === "group") die("renaming a group root by script is not supported");
19021
19038
  base = `${id}-${slugify(flags.slug)}.md`;
19022
19039
  }
19023
- const destRel = path57.join(path57.dirname(curRel), base);
19024
- const dest = path57.join(TODO, destRel);
19040
+ const destRel = path58.join(path58.dirname(curRel), base);
19041
+ const dest = path58.join(TODO, destRel);
19025
19042
  const moving = dest !== file;
19026
- if (moving && fs54.existsSync(dest)) die(`${rel(dest)} already exists`);
19027
- fs54.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19028
- 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);
19029
19046
  if (isSubtask) {
19030
19047
  if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
19031
- if (moving) changes.push(`renamed \u2192 ${destRel.split(path57.sep).join("/")}`);
19048
+ if (moving) changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
19032
19049
  } else if (moving) {
19033
19050
  stripReadmeRefs({ kind: "file", rel: curRel });
19034
19051
  addReadmeRef(id, meta.title, destRel);
19035
- changes.push(`renamed \u2192 ${destRel.split(path57.sep).join("/")}`);
19052
+ changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
19036
19053
  } else if (changes.includes("title")) {
19037
19054
  stripReadmeRefs({ kind: "file", rel: curRel });
19038
19055
  addReadmeRef(id, meta.title, curRel);
@@ -19044,8 +19061,8 @@ function cmdUpdateQuestions(id, input) {
19044
19061
  const ops = readQuestionOps(input.ops ?? []);
19045
19062
  const found2 = locate(id);
19046
19063
  if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
19047
- const file = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
19048
- 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"));
19049
19066
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
19050
19067
  if (insideRun() && ops.some((op) => op.kind === "skip" || op.kind === "unskip")) {
19051
19068
  die("only the user skips or reopens a question \u2014 a run leaves questions for them to answer");
@@ -19118,7 +19135,7 @@ function cmdUpdateQuestions(id, input) {
19118
19135
  meta.status = "todo";
19119
19136
  changes.push("status\u2192todo (open questions)");
19120
19137
  }
19121
- fs54.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19138
+ fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19122
19139
  for (const kind of closed2) countBoardEvent(kind);
19123
19140
  settleDelivery2(id, skipped, unskipped);
19124
19141
  say(
@@ -19194,13 +19211,13 @@ var init_config_template = __esm({
19194
19211
  });
19195
19212
 
19196
19213
  // src/lib/agent/local.ts
19197
- import fs55 from "node:fs";
19198
- import path58 from "node:path";
19214
+ import fs56 from "node:fs";
19215
+ import path59 from "node:path";
19199
19216
  function takeLocalModels(board2) {
19200
- const file = path58.join(board2, ".local.json");
19217
+ const file = path59.join(board2, ".local.json");
19201
19218
  let held4;
19202
19219
  try {
19203
- held4 = configBlock(JSON.parse(fs55.readFileSync(file, "utf8")));
19220
+ held4 = configBlock(JSON.parse(fs56.readFileSync(file, "utf8")));
19204
19221
  } catch {
19205
19222
  return {};
19206
19223
  }
@@ -19218,7 +19235,7 @@ function takeLocalModels(board2) {
19218
19235
  }
19219
19236
  if (!Object.keys(agents).length) return out;
19220
19237
  delete held4.agents;
19221
- fs55.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19238
+ fs56.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
19222
19239
  return out;
19223
19240
  }
19224
19241
  var LOCAL_IGNORE_LINE;
@@ -19279,12 +19296,12 @@ var init_identity2 = __esm({
19279
19296
  });
19280
19297
 
19281
19298
  // src/lib/signals/migrate.ts
19282
- import fs56 from "node:fs";
19283
- import path59 from "node:path";
19299
+ import fs57 from "node:fs";
19300
+ import path60 from "node:path";
19284
19301
  function readHandled() {
19285
19302
  let text5;
19286
19303
  try {
19287
- text5 = fs56.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19304
+ text5 = fs57.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
19288
19305
  } catch {
19289
19306
  return [];
19290
19307
  }
@@ -19301,57 +19318,57 @@ function readHandled() {
19301
19318
  return held4;
19302
19319
  }
19303
19320
  function lift(from, into) {
19304
- fs56.mkdirSync(into, { recursive: true });
19305
- 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))));
19306
19323
  }
19307
19324
  function repoint(dir, from, into) {
19308
19325
  let entries;
19309
19326
  try {
19310
- entries = fs56.readdirSync(dir, { withFileTypes: true });
19327
+ entries = fs57.readdirSync(dir, { withFileTypes: true });
19311
19328
  } catch {
19312
19329
  return;
19313
19330
  }
19314
19331
  for (const entry of entries) {
19315
19332
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
19316
- const file = path59.join(dir, entry.name);
19317
- const text5 = fs56.readFileSync(file, "utf8");
19318
- 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));
19319
19336
  }
19320
19337
  }
19321
19338
  function dropIfEmpty2(dir) {
19322
19339
  try {
19323
- fs56.rmdirSync(dir);
19340
+ fs57.rmdirSync(dir);
19324
19341
  } catch {
19325
19342
  }
19326
19343
  }
19327
19344
  function liftInbox() {
19328
- if (!fs56.existsSync(SIGNALS_OLD_INBOX)) return;
19329
- const oldFiles = path59.join(SIGNALS_OLD_INBOX, "files");
19330
- if (fs56.existsSync(oldFiles)) {
19331
- for (const entry of fs56.readdirSync(oldFiles, { withFileTypes: true })) {
19332
- 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);
19333
19350
  }
19334
19351
  dropIfEmpty2(oldFiles);
19335
19352
  }
19336
19353
  const held4 = new Set(readFolder2(TRIAGE).map((signal2) => signal2.sourceId));
19337
- for (const entry of fs56.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19354
+ for (const entry of fs57.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
19338
19355
  if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
19339
- const from = path59.join(SIGNALS_OLD_INBOX, entry.name);
19356
+ const from = path60.join(SIGNALS_OLD_INBOX, entry.name);
19340
19357
  const item = parse(from);
19341
19358
  if (item && held4.has(item.sourceId)) {
19342
- fs56.rmSync(from, { force: true });
19359
+ fs57.rmSync(from, { force: true });
19343
19360
  continue;
19344
19361
  }
19345
19362
  if (item) held4.add(item.sourceId);
19346
19363
  lift(from, TRIAGE);
19347
19364
  }
19348
- const wasAt = asWritten(path59.join(SIGNALS_OLD_INBOX, "files"));
19365
+ const wasAt = asWritten(path60.join(SIGNALS_OLD_INBOX, "files"));
19349
19366
  const nowAt = asWritten(SIGNALS_FILES);
19350
19367
  for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
19351
19368
  dropIfEmpty2(SIGNALS_OLD_INBOX);
19352
19369
  }
19353
19370
  function liftHandled() {
19354
- if (!fs56.existsSync(SIGNALS_OLD_HANDLED)) return;
19371
+ if (!fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
19355
19372
  const lines = readHandled();
19356
19373
  const held4 = /* @__PURE__ */ new Set([
19357
19374
  ...readFolder2(TRIAGE).map((signal2) => signal2.sourceId),
@@ -19361,7 +19378,7 @@ function liftHandled() {
19361
19378
  for (const { sourceId, when } of lines) {
19362
19379
  if (held4.has(sourceId)) continue;
19363
19380
  held4.add(sourceId);
19364
- fs56.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19381
+ fs57.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
19365
19382
  const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
19366
19383
  const front = [
19367
19384
  "---",
@@ -19371,13 +19388,13 @@ function liftHandled() {
19371
19388
  "---",
19372
19389
  ""
19373
19390
  ];
19374
- fs56.writeFileSync(path59.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19391
+ fs57.writeFileSync(path60.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
19375
19392
  `);
19376
19393
  }
19377
- fs56.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19394
+ fs57.rmSync(SIGNALS_OLD_HANDLED, { force: true });
19378
19395
  }
19379
19396
  function migrateTriage() {
19380
- 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;
19381
19398
  try {
19382
19399
  liftInbox();
19383
19400
  liftHandled();
@@ -19392,13 +19409,13 @@ var init_migrate = __esm({
19392
19409
  init_yaml();
19393
19410
  init_inbox();
19394
19411
  HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
19395
- asWritten = (dir) => `${rel(dir).split(path59.sep).join("/")}/`;
19412
+ asWritten = (dir) => `${rel(dir).split(path60.sep).join("/")}/`;
19396
19413
  }
19397
19414
  });
19398
19415
 
19399
19416
  // src/lib/signals/add.ts
19400
- import fs57 from "node:fs";
19401
- import path60 from "node:path";
19417
+ import fs58 from "node:fs";
19418
+ import path61 from "node:path";
19402
19419
  import { createHash as createHash4 } from "node:crypto";
19403
19420
  function linkTitle(url) {
19404
19421
  let at2;
@@ -19411,7 +19428,7 @@ function linkTitle(url) {
19411
19428
  return oneLine(where) || url.slice(0, TITLE_MAX);
19412
19429
  }
19413
19430
  function asText(file) {
19414
- const ext = path60.extname(file.name).toLowerCase();
19431
+ const ext = path61.extname(file.name).toLowerCase();
19415
19432
  if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
19416
19433
  try {
19417
19434
  const text5 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
@@ -19421,9 +19438,9 @@ function asText(file) {
19421
19438
  }
19422
19439
  }
19423
19440
  function fileName2(name, data) {
19424
- const base = path60.basename(name);
19425
- const ext = path60.extname(base).toLowerCase().slice(0, 12);
19426
- 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";
19427
19444
  const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
19428
19445
  return `${word}-${hash2}${ext}`;
19429
19446
  }
@@ -19432,9 +19449,9 @@ function addToInbox(drop) {
19432
19449
  const typed = (drop.text ?? "").trim();
19433
19450
  const file = drop.file;
19434
19451
  if (!typed && !file) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
19435
- 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.` };
19436
19453
  if (file && file.data.length > MAX_BYTES) {
19437
- 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.` };
19438
19455
  }
19439
19456
  const read5 = describe(typed, file);
19440
19457
  const keep2 = read5.keep;
@@ -19456,8 +19473,8 @@ ${incoming.summary}`);
19456
19473
  if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
19457
19474
  try {
19458
19475
  if (keep2) {
19459
- fs57.mkdirSync(SIGNALS_FILES, { recursive: true });
19460
- fs57.writeFileSync(keep2.at, keep2.data);
19476
+ fs58.mkdirSync(SIGNALS_FILES, { recursive: true });
19477
+ fs58.writeFileSync(keep2.at, keep2.data);
19461
19478
  }
19462
19479
  return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
19463
19480
  } catch (e2) {
@@ -19471,7 +19488,7 @@ function describe(typed, file) {
19471
19488
  return only ? [only] : [];
19472
19489
  };
19473
19490
  if (file) {
19474
- const name = path60.basename(file.name);
19491
+ const name = path61.basename(file.name);
19475
19492
  const text5 = asText(file);
19476
19493
  const note = typed ? `
19477
19494
 
@@ -19483,7 +19500,7 @@ ${typed}` : "";
19483
19500
  const at2 = keepAt(file);
19484
19501
  return {
19485
19502
  incoming: {
19486
- title: path60.basename(name, path60.extname(name)) || name,
19503
+ title: path61.basename(name, path61.extname(name)) || name,
19487
19504
  summary: `${name} \u2014 ${boardRel2(at2)}${note}`,
19488
19505
  ...named2
19489
19506
  },
@@ -19521,73 +19538,73 @@ var init_add = __esm({
19521
19538
  MAX_BYTES = 25 * 1024 * 1024;
19522
19539
  TITLE_MAX = 120;
19523
19540
  TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
19524
- boardRel2 = (file) => rel(file).split(path60.sep).join("/");
19541
+ boardRel2 = (file) => rel(file).split(path61.sep).join("/");
19525
19542
  oneLine = (text5) => {
19526
19543
  const first = text5.split("\n").find((line) => line.trim()) ?? "";
19527
19544
  const clean = first.replace(/^#+\s*/, "").trim();
19528
19545
  return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
19529
19546
  };
19530
- keepAt = (file) => path60.join(SIGNALS_FILES, fileName2(file.name, file.data));
19547
+ keepAt = (file) => path61.join(SIGNALS_FILES, fileName2(file.name, file.data));
19531
19548
  }
19532
19549
  });
19533
19550
 
19534
19551
  // src/lib/recurring.ts
19535
- import fs58 from "node:fs";
19536
- import path61 from "node:path";
19552
+ import fs59 from "node:fs";
19553
+ import path62 from "node:path";
19537
19554
  function migratePruneMemoryCard() {
19538
19555
  const dir = recurringDir();
19539
19556
  let names3;
19540
19557
  try {
19541
- names3 = fs58.readdirSync(dir);
19558
+ names3 = fs59.readdirSync(dir);
19542
19559
  } catch {
19543
19560
  return null;
19544
19561
  }
19545
19562
  const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
19546
19563
  if (!name) return null;
19547
- const file = path61.join(dir, name);
19564
+ const file = path62.join(dir, name);
19548
19565
  try {
19549
- const { meta } = parseFrontmatter(fs58.readFileSync(file, "utf8"));
19566
+ const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19550
19567
  const cadence = meta?.cadence;
19551
19568
  if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
19552
19569
  } catch {
19553
19570
  }
19554
- fs58.rmSync(file, { force: true });
19571
+ fs59.rmSync(file, { force: true });
19555
19572
  return rel(file);
19556
19573
  }
19557
19574
  function legacyCards() {
19558
19575
  const dir = recurringDir();
19559
- if (!fs58.existsSync(dir)) return [];
19576
+ if (!fs59.existsSync(dir)) return [];
19560
19577
  const cards = [];
19561
- for (const entry of fs58.readdirSync(dir, { withFileTypes: true })) {
19578
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19562
19579
  const id = idPrefix(entry.name);
19563
19580
  if (id === null) continue;
19564
- const full = path61.join(dir, entry.name);
19581
+ const full = path62.join(dir, entry.name);
19565
19582
  const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
19566
19583
  if (entry.isFile() && entry.name.endsWith(".md")) cards.push({ id, slug: slug2, file: full });
19567
- else if (entry.isDirectory() && fs58.existsSync(path61.join(full, "root.md"))) {
19568
- 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 });
19569
19586
  }
19570
19587
  }
19571
19588
  return cards.sort((a2, b2) => a2.id - b2.id);
19572
19589
  }
19573
19590
  function mergeInto2(from, to, skip = []) {
19574
- fs58.mkdirSync(to, { recursive: true });
19575
- 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 })) {
19576
19593
  if (skip.includes(entry.name)) continue;
19577
- const source = path61.join(from, entry.name);
19578
- const target = path61.join(to, entry.name);
19579
- if (!fs58.existsSync(target)) fs58.renameSync(source, target);
19580
- 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);
19581
19598
  }
19582
- if (isEmpty(from)) fs58.rmSync(from, { recursive: true, force: true });
19599
+ if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
19583
19600
  }
19584
19601
  function moveSideFolders() {
19585
19602
  const dir = recurringDir();
19586
- for (const entry of fs58.readdirSync(dir, { withFileTypes: true })) {
19603
+ for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
19587
19604
  if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
19588
- const from = path61.join(dir, entry.name);
19589
- if (isEmpty(from)) fs58.rmSync(from, { recursive: true, force: true });
19590
- 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));
19591
19608
  }
19592
19609
  }
19593
19610
  function sections(body) {
@@ -19637,8 +19654,8 @@ function agentName(card, text5) {
19637
19654
  const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a2) => a2.name), ...ROLE_NAMES]);
19638
19655
  for (const name of [slug2, `${slug2}-${card.id}`]) {
19639
19656
  if (!AGENT_NAME.test(name)) continue;
19640
- const file = path61.join(AGENTS, name, AGENT_FILE2);
19641
- 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;
19642
19659
  if (written === text5(name)) return name;
19643
19660
  if (written === null && !known2.has(name)) return name;
19644
19661
  }
@@ -19655,11 +19672,11 @@ ${q3.options.map((o3) => `- ${o3}`).join("\n")}` : "";
19655
19672
  function removeCard(card) {
19656
19673
  dropCrossRefs(card.id);
19657
19674
  const target = card.folder ?? card.file;
19658
- stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path61.relative(TODO, target).split(path61.sep).join("/") });
19659
- 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 });
19660
19677
  }
19661
19678
  function migrateCard(card) {
19662
- const { meta, body } = parseFrontmatter(fs58.readFileSync(card.file, "utf8"));
19679
+ const { meta, body } = parseFrontmatter(fs59.readFileSync(card.file, "utf8"));
19663
19680
  if (!meta) throw new Error("its frontmatter cannot be read");
19664
19681
  const raw = meta;
19665
19682
  const said3 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
@@ -19669,19 +19686,19 @@ function migrateCard(card) {
19669
19686
  if (!flow) throw new Error(noWorkflowMessage(""));
19670
19687
  const text5 = (name2) => agentText(name2, meta.title || card.slug, body);
19671
19688
  const name = agentName(card, text5);
19672
- const dir = path61.join(AGENTS, name);
19673
- const file = path61.join(dir, AGENT_FILE2);
19674
- const madeDir = !fs58.existsSync(dir);
19675
- 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);
19676
19693
  try {
19677
- fs58.mkdirSync(dir, { recursive: true });
19678
- if (wrote) fs58.writeFileSync(file, text5(name));
19694
+ fs59.mkdirSync(dir, { recursive: true });
19695
+ if (wrote) fs59.writeFileSync(file, text5(name));
19679
19696
  const adopted = adoptWorkflowScheduled(flow.id, name, { cadence, lastRun });
19680
19697
  if (!adopted.ok) throw new Error(adopted.error);
19681
19698
  questionsToTriage(meta, name);
19682
19699
  } catch (e2) {
19683
- if (madeDir) fs58.rmSync(dir, { recursive: true, force: true });
19684
- 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 });
19685
19702
  throw e2;
19686
19703
  }
19687
19704
  if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
@@ -19691,7 +19708,7 @@ function migrateCard(card) {
19691
19708
  function migrateRecurringCards() {
19692
19709
  const done2 = { agents: [], removed: [], failed: [] };
19693
19710
  const dir = recurringDir();
19694
- if (!fs58.existsSync(dir)) return done2;
19711
+ if (!fs59.existsSync(dir)) return done2;
19695
19712
  migratePruneMemoryCard();
19696
19713
  moveSideFolders();
19697
19714
  for (const card of legacyCards()) {
@@ -19704,7 +19721,7 @@ function migrateRecurringCards() {
19704
19721
  done2.failed.push({ card: rel(card.file), why: e2 instanceof Error ? e2.message : String(e2) });
19705
19722
  }
19706
19723
  }
19707
- if (isEmpty(dir)) fs58.rmSync(dir, { recursive: true, force: true });
19724
+ if (isEmpty(dir)) fs59.rmSync(dir, { recursive: true, force: true });
19708
19725
  return done2;
19709
19726
  }
19710
19727
  function recurringMigrationLines(done2) {
@@ -19737,14 +19754,14 @@ var init_recurring = __esm({
19737
19754
  PRUNE_SLUG = "prune-the-memory";
19738
19755
  FETCH_SLUG = "fetch-triage-items";
19739
19756
  AGENT_FILE2 = "AGENT.md";
19740
- recurringDir = () => path61.join(TODO, LEGACY_RECURRING);
19741
- 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");
19742
19759
  SECTION = /^##\s+(.+?)\s*$/;
19743
19760
  }
19744
19761
  });
19745
19762
 
19746
19763
  // src/commands/init.ts
19747
- import fs59 from "node:fs";
19764
+ import fs60 from "node:fs";
19748
19765
  function boardReadme() {
19749
19766
  return `# Board
19750
19767
 
@@ -19757,20 +19774,20 @@ _(none)_
19757
19774
  `;
19758
19775
  }
19759
19776
  function writeConfigIfMissing() {
19760
- if (fs59.existsSync(CONFIG)) return false;
19761
- fs59.mkdirSync(KANBAN, { recursive: true });
19762
- fs59.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19777
+ if (fs60.existsSync(CONFIG)) return false;
19778
+ fs60.mkdirSync(KANBAN, { recursive: true });
19779
+ fs60.writeFileSync(CONFIG, CONFIG_TEMPLATE);
19763
19780
  return true;
19764
19781
  }
19765
19782
  function writeModulesIfMissing() {
19766
- if (fs59.existsSync(MODULES_MD)) return false;
19767
- fs59.mkdirSync(KANBAN, { recursive: true });
19768
- 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);
19769
19786
  return true;
19770
19787
  }
19771
19788
  function writeGitignoreIfMissing() {
19772
- fs59.mkdirSync(KANBAN, { recursive: true });
19773
- 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") : "";
19774
19791
  const has = (rule) => text5.split("\n").some((line) => line.trim() === rule.line);
19775
19792
  const missing = IGNORE_RULES.filter((rule) => !has(rule));
19776
19793
  if (!missing.length) return false;
@@ -19778,37 +19795,37 @@ function writeGitignoreIfMissing() {
19778
19795
  ${rule.line}
19779
19796
  `).join("");
19780
19797
  const separator = !text5 || text5.endsWith("\n") ? "" : "\n";
19781
- fs59.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19798
+ fs60.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
19782
19799
  return true;
19783
19800
  }
19784
19801
  function writeSkeletonIfMissing() {
19785
19802
  const added = [];
19786
- if (!fs59.existsSync(TODO)) {
19787
- fs59.mkdirSync(TODO, { recursive: true });
19803
+ if (!fs60.existsSync(TODO)) {
19804
+ fs60.mkdirSync(TODO, { recursive: true });
19788
19805
  added.push(`${rel(TODO)}/`);
19789
19806
  }
19790
- if (!fs59.existsSync(README)) {
19791
- fs59.writeFileSync(README, boardReadme());
19807
+ if (!fs60.existsSync(README)) {
19808
+ fs60.writeFileSync(README, boardReadme());
19792
19809
  added.push(rel(README));
19793
19810
  }
19794
19811
  return added;
19795
19812
  }
19796
19813
  function retireReleases() {
19797
19814
  const done2 = [];
19798
- if (fs59.existsSync(RELEASES)) {
19799
- fs59.rmSync(RELEASES);
19815
+ if (fs60.existsSync(RELEASES)) {
19816
+ fs60.rmSync(RELEASES);
19800
19817
  done2.push(`deleted ${rel(RELEASES)}`);
19801
19818
  }
19802
19819
  let cards = 0;
19803
19820
  for (const dir of [TODO, ARCHIVE]) {
19804
- if (!fs59.existsSync(dir)) continue;
19821
+ if (!fs60.existsSync(dir)) continue;
19805
19822
  for (const file of walkMd(dir)) {
19806
- const text5 = fs59.readFileSync(file, "utf8");
19823
+ const text5 = fs60.readFileSync(file, "utf8");
19807
19824
  const end2 = text5.startsWith("---\n") ? text5.indexOf("\n---", 3) : -1;
19808
19825
  if (end2 < 0) continue;
19809
19826
  const head2 = text5.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
19810
19827
  if (head2.length === end2) continue;
19811
- fs59.writeFileSync(file, head2 + text5.slice(end2));
19828
+ fs60.writeFileSync(file, head2 + text5.slice(end2));
19812
19829
  cards++;
19813
19830
  }
19814
19831
  }
@@ -19816,7 +19833,7 @@ function retireReleases() {
19816
19833
  return done2.join(", ");
19817
19834
  }
19818
19835
  function cmdInit() {
19819
- if (fs59.existsSync(KANBAN)) {
19836
+ if (fs60.existsSync(KANBAN)) {
19820
19837
  const added = [
19821
19838
  ...writeSkeletonIfMissing(),
19822
19839
  writeConfigIfMissing() && rel(CONFIG),
@@ -19851,8 +19868,8 @@ function cmdInit() {
19851
19868
  }
19852
19869
  return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
19853
19870
  }
19854
- fs59.mkdirSync(TODO, { recursive: true });
19855
- fs59.writeFileSync(README, boardReadme());
19871
+ fs60.mkdirSync(TODO, { recursive: true });
19872
+ fs60.writeFileSync(README, boardReadme());
19856
19873
  writeConfigIfMissing();
19857
19874
  scaffoldProjectMemory();
19858
19875
  writeModulesIfMissing();
@@ -19941,25 +19958,25 @@ var init_scheduled = __esm({
19941
19958
  });
19942
19959
 
19943
19960
  // src/lib/card-age.ts
19944
- import fs60 from "node:fs";
19945
- import path62 from "node:path";
19961
+ import fs61 from "node:fs";
19962
+ import path63 from "node:path";
19946
19963
  function staleAfterIn(config) {
19947
19964
  const days = Number(LINE.exec(config)?.[1]);
19948
19965
  return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
19949
19966
  }
19950
19967
  function staleAfter() {
19951
- if (!fs60.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
19952
- return staleAfterIn(fs60.readFileSync(CONFIG, "utf8"));
19968
+ if (!fs61.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
19969
+ return staleAfterIn(fs61.readFileSync(CONFIG, "utf8"));
19953
19970
  }
19954
19971
  function todoPathspec(top) {
19955
- const from = path62.relative(real(top), real(TODO));
19956
- if (!from || from.startsWith("..") || path62.isAbsolute(from)) return null;
19957
- 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("/");
19958
19975
  }
19959
19976
  function cardFile2(spec, printed) {
19960
19977
  const p2 = unquotePath(printed);
19961
19978
  if (!p2.startsWith(`${spec}/`)) return null;
19962
- return path62.join(TODO, ...p2.slice(spec.length + 1).split("/"));
19979
+ return path63.join(TODO, ...p2.slice(spec.length + 1).split("/"));
19963
19980
  }
19964
19981
  function dirtyCards(top, spec) {
19965
19982
  const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
@@ -20006,9 +20023,9 @@ var init_card_age = __esm({
20006
20023
  gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
20007
20024
  real = (p2) => {
20008
20025
  try {
20009
- return fs60.realpathSync(p2);
20026
+ return fs61.realpathSync(p2);
20010
20027
  } catch {
20011
- return path62.resolve(p2);
20028
+ return path63.resolve(p2);
20012
20029
  }
20013
20030
  };
20014
20031
  unquotePath = (line) => {
@@ -20043,8 +20060,8 @@ var init_card_holds = __esm({
20043
20060
  });
20044
20061
 
20045
20062
  // src/commands/list.ts
20046
- import fs61 from "node:fs";
20047
- import path63 from "node:path";
20063
+ import fs62 from "node:fs";
20064
+ import path64 from "node:path";
20048
20065
  function summaryLine(body) {
20049
20066
  const lines = body.split("\n");
20050
20067
  let i = 0;
@@ -20060,13 +20077,13 @@ function summaryLine(body) {
20060
20077
  function openRows() {
20061
20078
  const rows = [];
20062
20079
  for (const file of walkMd(TODO)) {
20063
- const base = path63.basename(file);
20080
+ const base = path64.basename(file);
20064
20081
  if (base === "README.md") continue;
20065
20082
  const isRoot = base === "root.md";
20066
- const id = isRoot ? idPrefix(path63.basename(path63.dirname(file))) : idPrefix(base);
20083
+ const id = isRoot ? idPrefix(path64.basename(path64.dirname(file))) : idPrefix(base);
20067
20084
  if (id == null) continue;
20068
- if (isLegacyRecurring(path63.relative(TODO, file))) continue;
20069
- 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"));
20070
20087
  rows.push({
20071
20088
  id,
20072
20089
  file,
@@ -20108,15 +20125,15 @@ function cmdStale(rows, all2, scope, mod) {
20108
20125
  }
20109
20126
  function archivedFiles() {
20110
20127
  const files2 = /* @__PURE__ */ new Map();
20111
- if (!fs61.existsSync(ARCHIVE)) return files2;
20128
+ if (!fs62.existsSync(ARCHIVE)) return files2;
20112
20129
  for (const file of walkMd(ARCHIVE)) {
20113
- const id = idPrefix(path63.basename(file));
20130
+ const id = idPrefix(path64.basename(file));
20114
20131
  if (id !== null) files2.set(id, file);
20115
20132
  }
20116
20133
  for (const dir of walkDirs(ARCHIVE)) {
20117
- const id = idPrefix(path63.basename(dir));
20118
- const root2 = path63.join(dir, "root.md");
20119
- 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);
20120
20137
  }
20121
20138
  return files2;
20122
20139
  }
@@ -20227,14 +20244,14 @@ var init_list = __esm({
20227
20244
  });
20228
20245
 
20229
20246
  // src/commands/misc.ts
20230
- import fs62 from "node:fs";
20231
- import path64 from "node:path";
20247
+ import fs63 from "node:fs";
20248
+ import path65 from "node:path";
20232
20249
  function extractOldMeta(text5, file) {
20233
20250
  const grab = (re3) => {
20234
20251
  const m = text5.match(re3);
20235
20252
  return m ? m[1].trim() : null;
20236
20253
  };
20237
- 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, " ");
20238
20255
  const norm = (raw) => {
20239
20256
  const v = (raw || "").toLowerCase();
20240
20257
  return LEVELS.includes(v) ? v : "med";
@@ -20261,11 +20278,11 @@ function stripOldHeader(text5) {
20261
20278
  }
20262
20279
  function cmdMigrate(opts) {
20263
20280
  const dry = opts.dryRun === true;
20264
- const files2 = walkMd(TODO).filter((f2) => path64.basename(f2) !== "README.md");
20281
+ const files2 = walkMd(TODO).filter((f2) => path65.basename(f2) !== "README.md");
20265
20282
  let changed = 0;
20266
20283
  let skipped = 0;
20267
20284
  for (const file of files2) {
20268
- const text5 = fs62.readFileSync(file, "utf8");
20285
+ const text5 = fs63.readFileSync(file, "utf8");
20269
20286
  if (text5.trimStart().startsWith("---")) {
20270
20287
  skipped++;
20271
20288
  continue;
@@ -20274,7 +20291,7 @@ function cmdMigrate(opts) {
20274
20291
  const out = serializeFrontmatter(meta) + "\n\n" + stripOldHeader(text5).replace(/^\n+/, "");
20275
20292
  if (dry) say(`would migrate ${rel(file)} (priority=${meta.priority})`);
20276
20293
  else {
20277
- fs62.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
20294
+ fs63.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
20278
20295
  say(`migrated ${rel(file)}`);
20279
20296
  }
20280
20297
  changed++;
@@ -20295,8 +20312,8 @@ var init_misc = __esm({
20295
20312
  });
20296
20313
 
20297
20314
  // src/lib/card-sources.ts
20298
- import fs63 from "node:fs";
20299
- import path65 from "node:path";
20315
+ import fs64 from "node:fs";
20316
+ import path66 from "node:path";
20300
20317
  function planById(id) {
20301
20318
  const found2 = readPlan(`plans/${id}-.md`);
20302
20319
  return found2?.text.trim() ? found2 : null;
@@ -20306,8 +20323,8 @@ function cardLink(id) {
20306
20323
  const found2 = open3 ?? locateArchived(id);
20307
20324
  if (!found2) return null;
20308
20325
  try {
20309
- const file = found2.kind === "group" ? path65.join(found2.target, "root.md") : found2.target;
20310
- 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 ?? "";
20311
20328
  return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
20312
20329
  } catch {
20313
20330
  return null;
@@ -20332,7 +20349,7 @@ function link(ref, items) {
20332
20349
  if (ref.kind === "plan") return planLink(ref.id);
20333
20350
  if (ref.kind === "card") return cardLink(ref.id);
20334
20351
  if (ref.kind === "url") return urlLink(ref.url);
20335
- const item = items().find((signal2) => path65.basename(signal2.relPath) === ref.file);
20352
+ const item = items().find((signal2) => path66.basename(signal2.relPath) === ref.file);
20336
20353
  return item ? itemLink(item) : null;
20337
20354
  }
20338
20355
  function cardSources(meta, body) {
@@ -20373,12 +20390,12 @@ var init_card_sources = __esm({
20373
20390
  });
20374
20391
 
20375
20392
  // src/lib/view/read.ts
20376
- import fs64 from "node:fs";
20377
- import path66 from "node:path";
20393
+ import fs65 from "node:fs";
20394
+ import path67 from "node:path";
20378
20395
  function readCard(file, relFromTodo) {
20379
- const id = idPrefix(path66.basename(relFromTodo));
20396
+ const id = idPrefix(path67.basename(relFromTodo));
20380
20397
  if (id === null) {
20381
- const parts = relFromTodo.split(path66.sep);
20398
+ const parts = relFromTodo.split(path67.sep);
20382
20399
  const folderId = idPrefix(parts[parts.length - 2] || "");
20383
20400
  if (folderId === null) return null;
20384
20401
  return buildCard(folderId, file, relFromTodo);
@@ -20386,10 +20403,10 @@ function readCard(file, relFromTodo) {
20386
20403
  return buildCard(id, file, relFromTodo);
20387
20404
  }
20388
20405
  function buildCard(id, file, relFromTodo) {
20389
- const text5 = fs64.readFileSync(file, "utf8");
20406
+ const text5 = fs65.readFileSync(file, "utf8");
20390
20407
  const { meta, body } = parseFrontmatter(text5);
20391
20408
  if (!meta) return null;
20392
- const relPath = relFromTodo.split(path66.sep).join("/");
20409
+ const relPath = relFromTodo.split(path67.sep).join("/");
20393
20410
  const flow = workflowFor(meta.workflow);
20394
20411
  const plan = !!meta.workflow && archivesOnApproval(flow);
20395
20412
  const stages = cardStages(meta, flow).length;
@@ -20398,7 +20415,7 @@ function buildCard(id, file, relFromTodo) {
20398
20415
  // Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
20399
20416
  // read here and a card read by the contract agree on what version this is.
20400
20417
  revision: revisionOf(text5),
20401
- updatedAt: fs64.statSync(file).mtime.toISOString(),
20418
+ updatedAt: fs65.statSync(file).mtime.toISOString(),
20402
20419
  relPath,
20403
20420
  title: meta.title,
20404
20421
  priority: meta.priority,
@@ -20419,22 +20436,22 @@ function buildCard(id, file, relFromTodo) {
20419
20436
  };
20420
20437
  }
20421
20438
  function readGroup2(folderName) {
20422
- const groupDir = path66.join(TODO, folderName);
20423
- const rootFile = path66.join(groupDir, "root.md");
20424
- if (!fs64.existsSync(rootFile)) return null;
20425
- 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"));
20426
20443
  if (!root2) return null;
20427
20444
  root2.isGroup = true;
20428
20445
  const { total, resolved: resolved2 } = subtaskLines(root2.body);
20429
20446
  root2.subtaskLines = { total, resolved: resolved2 };
20430
20447
  const subCards = [];
20431
20448
  const recurse = (dir, relDir) => {
20432
- for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20433
- 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);
20434
20451
  if (entry.isDirectory()) {
20435
- recurse(path66.join(dir, entry.name), childRel);
20452
+ recurse(path67.join(dir, entry.name), childRel);
20436
20453
  } else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
20437
- const c2 = readCard(path66.join(dir, entry.name), childRel);
20454
+ const c2 = readCard(path67.join(dir, entry.name), childRel);
20438
20455
  if (c2) {
20439
20456
  c2.parent = { id: root2.id, title: root2.title };
20440
20457
  subCards.push(c2);
@@ -20455,12 +20472,12 @@ function readGroup2(folderName) {
20455
20472
  return { root: root2, subCards };
20456
20473
  }
20457
20474
  function standaloneCards(dirRel) {
20458
- const dir = dirRel ? path66.join(TODO, dirRel) : TODO;
20459
- if (!fs64.existsSync(dir)) return [];
20475
+ const dir = dirRel ? path67.join(TODO, dirRel) : TODO;
20476
+ if (!fs65.existsSync(dir)) return [];
20460
20477
  const cards = [];
20461
- for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
20478
+ for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
20462
20479
  if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
20463
- 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));
20464
20481
  if (c2) cards.push(c2);
20465
20482
  }
20466
20483
  }
@@ -20472,7 +20489,7 @@ function collectCards() {
20472
20489
  const top = standaloneCards("");
20473
20490
  board2.push(...top);
20474
20491
  every.push(...top);
20475
- for (const entry of fs64.readdirSync(TODO, { withFileTypes: true })) {
20492
+ for (const entry of fs65.readdirSync(TODO, { withFileTypes: true })) {
20476
20493
  if (!entry.isDirectory()) continue;
20477
20494
  if (isGroupFolder(entry.name)) {
20478
20495
  const g3 = readGroup2(entry.name);
@@ -20504,7 +20521,7 @@ function findCard(id) {
20504
20521
  }
20505
20522
  function attachSources(card) {
20506
20523
  try {
20507
- 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"));
20508
20525
  const sources2 = meta ? cardSources(meta, body) : [];
20509
20526
  if (sources2.length) card.sources = sources2;
20510
20527
  } catch {
@@ -20609,10 +20626,10 @@ var init_read = __esm({
20609
20626
  });
20610
20627
 
20611
20628
  // src/lib/group-close.ts
20612
- import fs65 from "node:fs";
20629
+ import fs66 from "node:fs";
20613
20630
  function groupCloses(rootFile) {
20614
20631
  try {
20615
- return groupCloseOf(fs65.readFileSync(rootFile, "utf8"));
20632
+ return groupCloseOf(fs66.readFileSync(rootFile, "utf8"));
20616
20633
  } catch {
20617
20634
  return false;
20618
20635
  }
@@ -20625,12 +20642,12 @@ var init_group_close = __esm({
20625
20642
  });
20626
20643
 
20627
20644
  // src/commands/remove.ts
20628
- import fs66 from "node:fs";
20629
- import path67 from "node:path";
20645
+ import fs67 from "node:fs";
20646
+ import path68 from "node:path";
20630
20647
  function leavingIds(id, found2) {
20631
20648
  const ids = /* @__PURE__ */ new Set([id]);
20632
20649
  if (found2.kind === "group") {
20633
- 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));
20634
20651
  for (const name of names3) {
20635
20652
  const n = idPrefix(name);
20636
20653
  if (n !== null) ids.add(n);
@@ -20642,10 +20659,10 @@ function findMentions(ids) {
20642
20659
  const hits = [];
20643
20660
  const re3 = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
20644
20661
  for (const dir of [TODO, MEMORY]) {
20645
- if (!fs66.existsSync(dir)) continue;
20662
+ if (!fs67.existsSync(dir)) continue;
20646
20663
  for (const file of walkMd(dir)) {
20647
- if (path67.basename(file) === "README.md") continue;
20648
- 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");
20649
20666
  const fmEnd = frontmatterEnd(lines);
20650
20667
  lines.forEach((line, i) => {
20651
20668
  if (!re3.test(line)) return;
@@ -20661,12 +20678,12 @@ function findMentions(ids) {
20661
20678
  return hits;
20662
20679
  }
20663
20680
  function leavingCards(id, found2) {
20664
- 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;
20665
20682
  const cards = [{ id, file: own }];
20666
20683
  if (found2.kind !== "group") return cards;
20667
20684
  for (const file of walkMd(found2.target)) {
20668
20685
  if (file === own) continue;
20669
- const n = idPrefix(path67.basename(file));
20686
+ const n = idPrefix(path68.basename(file));
20670
20687
  if (n !== null) cards.push({ id: n, file });
20671
20688
  }
20672
20689
  return cards;
@@ -20675,10 +20692,10 @@ function stampLeaving(cards, rejection) {
20675
20692
  const day = formatDay();
20676
20693
  const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
20677
20694
  for (const card of cards) {
20678
- if (!fs66.existsSync(card.file)) continue;
20679
- const text5 = fs66.readFileSync(card.file, "utf8");
20695
+ if (!fs67.existsSync(card.file)) continue;
20696
+ const text5 = fs67.readFileSync(card.file, "utf8");
20680
20697
  const stamped = stampLeavingIn(text5, day, stamp4);
20681
- if (stamped !== text5) fs66.writeFileSync(card.file, stamped);
20698
+ if (stamped !== text5) fs67.writeFileSync(card.file, stamped);
20682
20699
  }
20683
20700
  }
20684
20701
  function unfinishedDelivery(id) {
@@ -20694,7 +20711,7 @@ function unfinishedDelivery(id) {
20694
20711
  }[gap];
20695
20712
  return `#${id} is not finished: ${what}.`;
20696
20713
  }
20697
- 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))));
20698
20715
  return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
20699
20716
  }
20700
20717
  function agentDecisions(text5) {
@@ -20725,8 +20742,8 @@ function removeCard2(id, metric, options) {
20725
20742
  const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
20726
20743
  if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
20727
20744
  const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
20728
- const cardFile3 = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
20729
- 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") : "";
20730
20747
  const { meta: cardMeta3 } = parseFrontmatter(cardText);
20731
20748
  const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f2) => f2 !== cardFile3).map((f2) => rel(f2)).sort() : [];
20732
20749
  const leftIds = leavingIds(id, found2);
@@ -20757,10 +20774,10 @@ function removeCard2(id, metric, options) {
20757
20774
  const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
20758
20775
  if (dest) {
20759
20776
  stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
20760
- fs66.mkdirSync(ARCHIVE, { recursive: true });
20761
- fs66.renameSync(found2.target, dest);
20777
+ fs67.mkdirSync(ARCHIVE, { recursive: true });
20778
+ fs67.renameSync(found2.target, dest);
20762
20779
  } else {
20763
- fs66.rmSync(found2.target, { recursive: true, force: true });
20780
+ fs67.rmSync(found2.target, { recursive: true, force: true });
20764
20781
  }
20765
20782
  const removedRefs = stripReadmeRefs(found2);
20766
20783
  let marked2 = null;
@@ -20809,14 +20826,14 @@ function removeCard2(id, metric, options) {
20809
20826
  };
20810
20827
  }
20811
20828
  function closeGroup(rootFile) {
20812
- const rootId = idPrefix(path67.basename(path67.dirname(rootFile)));
20829
+ const rootId = idPrefix(path68.basename(path68.dirname(rootFile)));
20813
20830
  if (rootId === null) return null;
20814
20831
  if (runnerProject(KANBAN)) return null;
20815
20832
  if (!groupCloses(rootFile)) return null;
20816
20833
  say(`
20817
20834
  every subtask line on #${rootId} is resolved \u2014 closing the group:`);
20818
20835
  try {
20819
- const { meta, body } = parseFrontmatter(fs66.readFileSync(rootFile, "utf8"));
20836
+ const { meta, body } = parseFrontmatter(fs67.readFileSync(rootFile, "utf8"));
20820
20837
  const res = cmdRemove(rootId, "completed", { closing: true });
20821
20838
  return {
20822
20839
  id: rootId,
@@ -20873,7 +20890,7 @@ function cleanupDiscardedCards(sessionId) {
20873
20890
  if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
20874
20891
  while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
20875
20892
  dropCrossRefs(card.id);
20876
- 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("/") });
20877
20894
  }
20878
20895
  return discarded.map((c2) => c2.id);
20879
20896
  });
@@ -20881,8 +20898,8 @@ function cleanupDiscardedCards(sessionId) {
20881
20898
  function recoveredArchiveHandoff(id, source) {
20882
20899
  const found2 = locateArchived(id);
20883
20900
  if (!found2) throw new Error(`No archived card #${id} was found.`);
20884
- const file = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
20885
- 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"));
20886
20903
  stripReadmeRefs(source ?? found2);
20887
20904
  const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
20888
20905
  if (root2) markSubtask(root2, id, "tick");
@@ -20980,8 +20997,8 @@ var init_memory_file = __esm({
20980
20997
  });
20981
20998
 
20982
20999
  // src/commands/rule.ts
20983
- import fs67 from "node:fs";
20984
- import path68 from "node:path";
21000
+ import fs68 from "node:fs";
21001
+ import path69 from "node:path";
20985
21002
  function cmdRule(askedName, flags) {
20986
21003
  const agent = askedName.trim();
20987
21004
  if (!agentRoster().some((a2) => a2.name === agent)) {
@@ -20990,7 +21007,7 @@ function cmdRule(askedName, flags) {
20990
21007
  const rule = readRuleText(flags.file, flags.text);
20991
21008
  const res = setAgentRule(agent, rule);
20992
21009
  if (!res.ok) die(res.error);
20993
- const file = rel(path68.join(RULES, `${agent}.md`));
21010
+ const file = rel(path69.join(RULES, `${agent}.md`));
20994
21011
  say(rule ? `wrote the \`${agent}\` rule (${file})` : `cleared the \`${agent}\` rule`);
20995
21012
  return { agent, file, cleared: !rule };
20996
21013
  }
@@ -20998,7 +21015,7 @@ function readRuleText(file, text5) {
20998
21015
  if (file !== void 0 && text5 !== void 0) die("pass --file or --text, not both");
20999
21016
  if (file !== void 0) {
21000
21017
  try {
21001
- return fs67.readFileSync(file, "utf8").trim();
21018
+ return fs68.readFileSync(file, "utf8").trim();
21002
21019
  } catch {
21003
21020
  die(`can't read ${file} \u2014 write the rule to a file, then pass its path`);
21004
21021
  }
@@ -21284,8 +21301,8 @@ var init_created_cards = __esm({
21284
21301
 
21285
21302
  // src/lib/agent/creation.ts
21286
21303
  import crypto4 from "node:crypto";
21287
- import fs68 from "node:fs";
21288
- import path69 from "node:path";
21304
+ import fs69 from "node:fs";
21305
+ import path70 from "node:path";
21289
21306
  function creationError(error, triage) {
21290
21307
  const zh = readLanguage() === "zh";
21291
21308
  const messages = {
@@ -21311,12 +21328,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
21311
21328
  function creationReceipt(request2, slot) {
21312
21329
  const hash2 = crypto4.createHash("sha256").update(`${request2}
21313
21330
  ${slot}`).digest("hex");
21314
- return path69.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21331
+ return path70.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21315
21332
  }
21316
21333
  function readCreation(file, said3) {
21317
21334
  return withCreationLock(() => {
21318
21335
  try {
21319
- const held4 = JSON.parse(fs68.readFileSync(file, "utf8"));
21336
+ const held4 = JSON.parse(fs69.readFileSync(file, "utf8"));
21320
21337
  if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
21321
21338
  return held4;
21322
21339
  } catch (error) {
@@ -21328,10 +21345,10 @@ function readCreation(file, said3) {
21328
21345
  });
21329
21346
  }
21330
21347
  function saveCreation(file, journal) {
21331
- fs68.mkdirSync(path69.dirname(file), { recursive: true });
21348
+ fs69.mkdirSync(path70.dirname(file), { recursive: true });
21332
21349
  const temp = `${file}.${crypto4.randomUUID()}.tmp`;
21333
- fs68.writeFileSync(temp, JSON.stringify(journal));
21334
- fs68.renameSync(temp, file);
21350
+ fs69.writeFileSync(temp, JSON.stringify(journal));
21351
+ fs69.renameSync(temp, file);
21335
21352
  }
21336
21353
  function archiveCreation(source, id) {
21337
21354
  if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
@@ -21345,7 +21362,7 @@ function archiveCreation(source, id) {
21345
21362
  function triageFile(sourceId) {
21346
21363
  const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
21347
21364
  if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
21348
- return path69.basename(found2.relPath, ".md");
21365
+ return path70.basename(found2.relPath, ".md");
21349
21366
  }
21350
21367
  var init_creation = __esm({
21351
21368
  "src/lib/agent/creation.ts"() {
@@ -21509,8 +21526,8 @@ __export(board_exports, {
21509
21526
  buildBoardProgram: () => buildBoardProgram
21510
21527
  });
21511
21528
  import crypto5 from "node:crypto";
21512
- import fs69 from "node:fs";
21513
- import path70 from "node:path";
21529
+ import fs70 from "node:fs";
21530
+ import path71 from "node:path";
21514
21531
  async function dispatch(move, cmd, args, opts, cli) {
21515
21532
  const ctx = ctxOf(cmd, cli.program);
21516
21533
  const data = await runAction(ctx, {}, async () => {
@@ -21550,7 +21567,7 @@ async function cloudCard(task, opts) {
21550
21567
  let request2;
21551
21568
  if (typeof opts.bodyFile === "string") {
21552
21569
  try {
21553
- request2 = fs69.readFileSync(opts.bodyFile, "utf8");
21570
+ request2 = fs70.readFileSync(opts.bodyFile, "utf8");
21554
21571
  } catch {
21555
21572
  }
21556
21573
  }
@@ -21580,7 +21597,7 @@ async function cloudCard(task, opts) {
21580
21597
  const file = creationReceipt(`${checked.value}:${requestId}`, slot);
21581
21598
  const journal = readCreation(file, said3);
21582
21599
  if (!journal.made) {
21583
- const key = `akb-${path70.basename(file, ".json").slice(0, 40)}`;
21600
+ const key = `akb-${path71.basename(file, ".json").slice(0, 40)}`;
21584
21601
  const made = await createProjectTask(checked.value, journal.said, key);
21585
21602
  if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
21586
21603
  journal.made = made.value;
@@ -21722,17 +21739,17 @@ var init_board2 = __esm({
21722
21739
  });
21723
21740
 
21724
21741
  // src/lib/board-cli.ts
21725
- import fs70 from "node:fs";
21726
- import path71 from "node:path";
21742
+ import fs71 from "node:fs";
21743
+ import path72 from "node:path";
21727
21744
  function useBoard(found2, dirNamed) {
21728
- 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);
21729
21746
  else setBoardDir(found2.board, found2.root);
21730
21747
  useProjectState();
21731
21748
  backfillCardWorkflows();
21732
21749
  }
21733
21750
  function whole(found2, move) {
21734
21751
  if (move === MAKES_A_BOARD) return found2;
21735
- if (!fs70.existsSync(path71.join(found2.board, "todo"))) {
21752
+ if (!fs71.existsSync(path72.join(found2.board, "todo"))) {
21736
21753
  die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
21737
21754
  kind: "board-incomplete",
21738
21755
  dir: found2.root
@@ -21741,13 +21758,13 @@ function whole(found2, move) {
21741
21758
  return found2;
21742
21759
  }
21743
21760
  function findBoardUpward(from, move) {
21744
- let dir = path71.resolve(from);
21761
+ let dir = path72.resolve(from);
21745
21762
  for (; ; ) {
21746
- 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") };
21747
21764
  if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
21748
- const kept2 = path71.join(dir, ".akb", "kanban");
21749
- if (move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return { root: dir, board: kept2 };
21750
- 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);
21751
21768
  if (up === dir) return null;
21752
21769
  dir = up;
21753
21770
  }
@@ -21755,11 +21772,11 @@ function findBoardUpward(from, move) {
21755
21772
  function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21756
21773
  const named2 = board2 ?? boardFromEnv();
21757
21774
  if (named2) {
21758
- const folder = path71.resolve(cwd, named2);
21759
- if (!fs70.existsSync(folder) && move !== MAKES_A_BOARD) {
21775
+ const folder = path72.resolve(cwd, named2);
21776
+ if (!fs71.existsSync(folder) && move !== MAKES_A_BOARD) {
21760
21777
  die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
21761
21778
  }
21762
- if (fs70.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21779
+ if (fs71.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21763
21780
  die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
21764
21781
  kind: "no-board",
21765
21782
  dir: folder
@@ -21768,24 +21785,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
21768
21785
  return { root: projectRootOf(folder), board: folder, named: true };
21769
21786
  }
21770
21787
  if (dir !== null) {
21771
- const root2 = path71.resolve(dir);
21772
- if (!fs70.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
21773
- const kept2 = path71.join(root2, ".akb", "kanban");
21774
- 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);
21775
21792
  if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
21776
21793
  die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
21777
21794
  kind: "no-board",
21778
21795
  dir: root2
21779
21796
  });
21780
21797
  }
21781
- return whole({ root: root2, board: path71.join(root2, "docs", "kanban") }, move);
21798
+ return whole({ root: root2, board: path72.join(root2, "docs", "kanban") }, move);
21782
21799
  }
21783
21800
  const found2 = findBoardUpward(cwd, move);
21784
21801
  if (found2) return whole(found2, move);
21785
- 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") };
21786
21803
  die(
21787
- `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`,
21788
- { 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) }
21789
21806
  );
21790
21807
  }
21791
21808
  function editDistance(a2, b2) {
@@ -21868,8 +21885,8 @@ var init_board_cli = __esm({
21868
21885
  init_pointer();
21869
21886
  init_card_workflow_backfill();
21870
21887
  MAKES_A_BOARD = "init";
21871
- hasBoard = (dir) => fs70.existsSync(path71.join(dir, "docs", "kanban"));
21872
- 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"));
21873
21890
  boardFromEnv = () => {
21874
21891
  const named2 = process.env.AI4KANBAN_BOARD?.trim();
21875
21892
  return named2 ? named2 : null;
@@ -22126,8 +22143,8 @@ var init_guide = __esm({
22126
22143
  });
22127
22144
 
22128
22145
  // src/lib/agent/approve.ts
22129
- import fs77 from "node:fs";
22130
- import path78 from "node:path";
22146
+ import fs78 from "node:fs";
22147
+ import path79 from "node:path";
22131
22148
  function approvalRequest(req) {
22132
22149
  const id = req.id;
22133
22150
  const card = id === void 0 ? null : findCard(id);
@@ -22145,12 +22162,12 @@ function advancePhase(id) {
22145
22162
  const card = findCard(id);
22146
22163
  const found2 = locate(id);
22147
22164
  if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
22148
- const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
22149
- 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"));
22150
22167
  if (!meta) return { error: `#${id} has no frontmatter` };
22151
22168
  meta.phase = card.stage + 1;
22152
22169
  meta.status = "todo";
22153
- fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
22170
+ fs78.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
22154
22171
  return null;
22155
22172
  }
22156
22173
  var init_approve = __esm({
@@ -22273,16 +22290,16 @@ var init_start = __esm({
22273
22290
  });
22274
22291
 
22275
22292
  // src/lib/agent/task-chats.ts
22276
- import fs78 from "node:fs";
22277
- import path79 from "node:path";
22293
+ import fs79 from "node:fs";
22294
+ import path80 from "node:path";
22278
22295
  function taskChatFile(task, home3) {
22279
22296
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
22280
- return path79.join(taskChatsDir(home3), `${task}.jsonl`);
22297
+ return path80.join(taskChatsDir(home3), `${task}.jsonl`);
22281
22298
  }
22282
22299
  function readTaskChat(task, home3) {
22283
22300
  let text5;
22284
22301
  try {
22285
- text5 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
22302
+ text5 = fs79.readFileSync(taskChatFile(task, home3), "utf8");
22286
22303
  } catch {
22287
22304
  return [];
22288
22305
  }
@@ -22303,13 +22320,13 @@ var init_task_chats = __esm({
22303
22320
  "use strict";
22304
22321
  init_home();
22305
22322
  TASK = /^[\w-]{1,100}$/;
22306
- taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
22323
+ taskChatsDir = (home3 = machineHome()) => path80.join(home3, "chats");
22307
22324
  }
22308
22325
  });
22309
22326
 
22310
22327
  // src/lib/agent/memory-review.ts
22311
- import fs79 from "node:fs";
22312
- import path80 from "node:path";
22328
+ import fs80 from "node:fs";
22329
+ import path81 from "node:path";
22313
22330
  function taskChatsToReview(tasks) {
22314
22331
  const out = [];
22315
22332
  for (const ref of [...new Set(tasks)]) {
@@ -22331,8 +22348,8 @@ function readArchived2(id) {
22331
22348
  const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
22332
22349
  if (!found2) return null;
22333
22350
  try {
22334
- const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
22335
- 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"));
22336
22353
  if (!meta) return null;
22337
22354
  return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
22338
22355
  } catch {
@@ -22401,17 +22418,17 @@ var init_memory_review = __esm({
22401
22418
  });
22402
22419
 
22403
22420
  // src/lib/agent/dismissal-review.ts
22404
- import fs80 from "node:fs";
22405
- import path81 from "node:path";
22421
+ import fs81 from "node:fs";
22422
+ import path82 from "node:path";
22406
22423
  function rejectionsToReview() {
22407
- const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
22408
- if (!fs80.existsSync(dir)) return [];
22424
+ const dir = path82.join(ARCHIVE, REJECTIONS_TO_REVIEW);
22425
+ if (!fs81.existsSync(dir)) return [];
22409
22426
  const found2 = [];
22410
22427
  for (const file of walkMd(dir)) {
22411
22428
  const id = archivedId(file);
22412
22429
  if (id === null) continue;
22413
22430
  try {
22414
- const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
22431
+ const { meta } = parseFrontmatter(fs81.readFileSync(file, "utf8"));
22415
22432
  if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
22416
22433
  found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
22417
22434
  } catch {
@@ -22441,7 +22458,7 @@ function citedSources(text5) {
22441
22458
  function withdrawnSources() {
22442
22459
  const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
22443
22460
  try {
22444
- return citedSources(fs80.readFileSync(file, "utf8"));
22461
+ return citedSources(fs81.readFileSync(file, "utf8"));
22445
22462
  } catch {
22446
22463
  return [];
22447
22464
  }
@@ -22466,8 +22483,8 @@ var init_dismissal_review = __esm({
22466
22483
  });
22467
22484
 
22468
22485
  // src/lib/agent/flow.ts
22469
- import fs81 from "node:fs";
22470
- import path82 from "node:path";
22486
+ import fs82 from "node:fs";
22487
+ import path83 from "node:path";
22471
22488
  function readCard2(id, home3 = "board") {
22472
22489
  const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
22473
22490
  const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
@@ -22477,10 +22494,10 @@ function readCard2(id, home3 = "board") {
22477
22494
  { kind: "card-not-found", id }
22478
22495
  );
22479
22496
  }
22480
- 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;
22481
22498
  let text5;
22482
22499
  try {
22483
- text5 = fs81.readFileSync(file, "utf8");
22500
+ text5 = fs82.readFileSync(file, "utf8");
22484
22501
  } catch {
22485
22502
  die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
22486
22503
  }
@@ -64362,8 +64379,8 @@ var require_JSXTransformer = __commonJS({
64362
64379
  }
64363
64380
  if (this.isAutomaticRuntime) {
64364
64381
  if (this.importProcessor) {
64365
- for (const [path89, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
64366
- prefix += `var ${resolvedName} = require("${path89}");`;
64382
+ for (const [path90, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
64383
+ prefix += `var ${resolvedName} = require("${path90}");`;
64367
64384
  }
64368
64385
  } else {
64369
64386
  const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
@@ -64556,11 +64573,11 @@ var require_JSXTransformer = __commonJS({
64556
64573
  }
64557
64574
  claimAutoImportedName(funcName, importPathSuffix) {
64558
64575
  if (this.importProcessor) {
64559
- const path89 = this.jsxImportSource + importPathSuffix;
64560
- if (!this.cjsAutomaticModuleNameResolutions[path89]) {
64561
- 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);
64562
64579
  }
64563
- return `${this.cjsAutomaticModuleNameResolutions[path89]}.${funcName}`;
64580
+ return `${this.cjsAutomaticModuleNameResolutions[path90]}.${funcName}`;
64564
64581
  } else {
64565
64582
  if (!this.esmAutomaticImportNameResolutions[funcName]) {
64566
64583
  this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
@@ -64996,7 +65013,7 @@ var require_CJSImportProcessor = __commonJS({
64996
65013
  */
64997
65014
  pruneTypeOnlyImports() {
64998
65015
  this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
64999
- for (const [path89, importInfo] of this.importInfoByPath.entries()) {
65016
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
65000
65017
  if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
65001
65018
  continue;
65002
65019
  }
@@ -65006,7 +65023,7 @@ var require_CJSImportProcessor = __commonJS({
65006
65023
  ...importInfo.namedImports.map(({ localName }) => localName)
65007
65024
  ];
65008
65025
  if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
65009
- this.importsToReplace.set(path89, "");
65026
+ this.importsToReplace.set(path90, "");
65010
65027
  }
65011
65028
  }
65012
65029
  }
@@ -65014,7 +65031,7 @@ var require_CJSImportProcessor = __commonJS({
65014
65031
  return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
65015
65032
  }
65016
65033
  generateImportReplacements() {
65017
- for (const [path89, importInfo] of this.importInfoByPath.entries()) {
65034
+ for (const [path90, importInfo] of this.importInfoByPath.entries()) {
65018
65035
  const {
65019
65036
  defaultNames,
65020
65037
  wildcardNames,
@@ -65024,17 +65041,17 @@ var require_CJSImportProcessor = __commonJS({
65024
65041
  hasStarExport
65025
65042
  } = importInfo;
65026
65043
  if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
65027
- this.importsToReplace.set(path89, `require('${path89}');`);
65044
+ this.importsToReplace.set(path90, `require('${path90}');`);
65028
65045
  continue;
65029
65046
  }
65030
- const primaryImportName = this.getFreeIdentifierForPath(path89);
65047
+ const primaryImportName = this.getFreeIdentifierForPath(path90);
65031
65048
  let secondaryImportName;
65032
65049
  if (this.enableLegacyTypeScriptModuleInterop) {
65033
65050
  secondaryImportName = primaryImportName;
65034
65051
  } else {
65035
- secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path89);
65052
+ secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path90);
65036
65053
  }
65037
- let requireCode = `var ${primaryImportName} = require('${path89}');`;
65054
+ let requireCode = `var ${primaryImportName} = require('${path90}');`;
65038
65055
  if (wildcardNames.length > 0) {
65039
65056
  for (const wildcardName of wildcardNames) {
65040
65057
  const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
@@ -65062,7 +65079,7 @@ var require_CJSImportProcessor = __commonJS({
65062
65079
  "createStarExport"
65063
65080
  )}(${primaryImportName});`;
65064
65081
  }
65065
- this.importsToReplace.set(path89, requireCode);
65082
+ this.importsToReplace.set(path90, requireCode);
65066
65083
  for (const defaultName of defaultNames) {
65067
65084
  this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
65068
65085
  }
@@ -65071,8 +65088,8 @@ var require_CJSImportProcessor = __commonJS({
65071
65088
  }
65072
65089
  }
65073
65090
  }
65074
- getFreeIdentifierForPath(path89) {
65075
- const components = path89.split("/");
65091
+ getFreeIdentifierForPath(path90) {
65092
+ const components = path90.split("/");
65076
65093
  const lastComponent = components[components.length - 1];
65077
65094
  const baseName = lastComponent.replace(/\W/g, "");
65078
65095
  return this.nameManager.claimFreeName(`_${baseName}`);
@@ -65117,8 +65134,8 @@ var require_CJSImportProcessor = __commonJS({
65117
65134
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
65118
65135
  throw new Error("Expected string token at the end of import statement.");
65119
65136
  }
65120
- const path89 = this.tokens.stringValueAtIndex(index);
65121
- const importInfo = this.getImportInfo(path89);
65137
+ const path90 = this.tokens.stringValueAtIndex(index);
65138
+ const importInfo = this.getImportInfo(path90);
65122
65139
  importInfo.defaultNames.push(...defaultNames);
65123
65140
  importInfo.wildcardNames.push(...wildcardNames);
65124
65141
  importInfo.namedImports.push(...namedImports);
@@ -65185,8 +65202,8 @@ var require_CJSImportProcessor = __commonJS({
65185
65202
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
65186
65203
  throw new Error("Expected string token at the end of import statement.");
65187
65204
  }
65188
- const path89 = this.tokens.stringValueAtIndex(index);
65189
- const importInfo = this.getImportInfo(path89);
65205
+ const path90 = this.tokens.stringValueAtIndex(index);
65206
+ const importInfo = this.getImportInfo(path90);
65190
65207
  importInfo.namedExports.push(...namedImports);
65191
65208
  }
65192
65209
  preprocessExportStarAtIndex(index) {
@@ -65201,8 +65218,8 @@ var require_CJSImportProcessor = __commonJS({
65201
65218
  if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
65202
65219
  throw new Error("Expected string token at the end of star export statement.");
65203
65220
  }
65204
- const path89 = this.tokens.stringValueAtIndex(index);
65205
- const importInfo = this.getImportInfo(path89);
65221
+ const path90 = this.tokens.stringValueAtIndex(index);
65222
+ const importInfo = this.getImportInfo(path90);
65206
65223
  if (exportedName !== null) {
65207
65224
  importInfo.exportStarNames.push(exportedName);
65208
65225
  } else {
@@ -65242,8 +65259,8 @@ var require_CJSImportProcessor = __commonJS({
65242
65259
  * Get a mutable import info object for this path, creating one if it doesn't
65243
65260
  * exist yet.
65244
65261
  */
65245
- getImportInfo(path89) {
65246
- const existingInfo = this.importInfoByPath.get(path89);
65262
+ getImportInfo(path90) {
65263
+ const existingInfo = this.importInfoByPath.get(path90);
65247
65264
  if (existingInfo) {
65248
65265
  return existingInfo;
65249
65266
  }
@@ -65256,7 +65273,7 @@ var require_CJSImportProcessor = __commonJS({
65256
65273
  exportStarNames: [],
65257
65274
  hasStarExport: false
65258
65275
  };
65259
- this.importInfoByPath.set(path89, newInfo);
65276
+ this.importInfoByPath.set(path90, newInfo);
65260
65277
  return newInfo;
65261
65278
  }
65262
65279
  addExportBinding(localName, exportedName) {
@@ -65836,16 +65853,16 @@ var require_resolve_uri_umd = __commonJS({
65836
65853
  }
65837
65854
  function parseFileUrl(input) {
65838
65855
  const match = fileRegex.exec(input);
65839
- const path89 = match[2];
65840
- 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] || "");
65841
65858
  }
65842
- function makeUrl(scheme, user, host2, port, path89, query, hash2) {
65859
+ function makeUrl(scheme, user, host2, port, path90, query, hash2) {
65843
65860
  return {
65844
65861
  scheme,
65845
65862
  user,
65846
65863
  host: host2,
65847
65864
  port,
65848
- path: path89,
65865
+ path: path90,
65849
65866
  query,
65850
65867
  hash: hash2,
65851
65868
  type: 7
@@ -65875,11 +65892,11 @@ var require_resolve_uri_umd = __commonJS({
65875
65892
  url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
65876
65893
  return url;
65877
65894
  }
65878
- function stripPathFilename(path89) {
65879
- if (path89.endsWith("/.."))
65880
- return path89;
65881
- const index = path89.lastIndexOf("/");
65882
- 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);
65883
65900
  }
65884
65901
  function mergePaths(url, base) {
65885
65902
  normalizePath(base, base.type);
@@ -65917,14 +65934,14 @@ var require_resolve_uri_umd = __commonJS({
65917
65934
  pieces[pointer++] = piece;
65918
65935
  positive++;
65919
65936
  }
65920
- let path89 = "";
65937
+ let path90 = "";
65921
65938
  for (let i = 1; i < pointer; i++) {
65922
- path89 += "/" + pieces[i];
65939
+ path90 += "/" + pieces[i];
65923
65940
  }
65924
- if (!path89 || addTrailingSlash && !path89.endsWith("/..")) {
65925
- path89 += "/";
65941
+ if (!path90 || addTrailingSlash && !path90.endsWith("/..")) {
65942
+ path90 += "/";
65926
65943
  }
65927
- url.path = path89;
65944
+ url.path = path90;
65928
65945
  }
65929
65946
  function resolve2(input, base) {
65930
65947
  if (!input && !base)
@@ -65965,13 +65982,13 @@ var require_resolve_uri_umd = __commonJS({
65965
65982
  case 3:
65966
65983
  return queryHash;
65967
65984
  case 4: {
65968
- const path89 = url.path.slice(1);
65969
- if (!path89)
65985
+ const path90 = url.path.slice(1);
65986
+ if (!path90)
65970
65987
  return queryHash || ".";
65971
- if (isRelative(base || input) && !isRelative(path89)) {
65972
- return "./" + path89 + queryHash;
65988
+ if (isRelative(base || input) && !isRelative(path90)) {
65989
+ return "./" + path90 + queryHash;
65973
65990
  }
65974
- return path89 + queryHash;
65991
+ return path90 + queryHash;
65975
65992
  }
65976
65993
  case 5:
65977
65994
  return url.path + queryHash;
@@ -66070,10 +66087,10 @@ var require_trace_mapping_umd = __commonJS({
66070
66087
  module2.exports = __toCommonJS(trace_mapping_exports);
66071
66088
  var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
66072
66089
  var import_resolve_uri = __toESM2(require_resolve_uri());
66073
- function stripFilename(path89) {
66074
- if (!path89) return "";
66075
- const index = path89.lastIndexOf("/");
66076
- 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);
66077
66094
  }
66078
66095
  function resolver2(mapUrl, sourceRoot) {
66079
66096
  const from = stripFilename(mapUrl);
@@ -67281,9 +67298,9 @@ var require_util2 = __commonJS({
67281
67298
  /** @class */
67282
67299
  (function(_super) {
67283
67300
  __extends(VError2, _super);
67284
- function VError2(path89, message) {
67301
+ function VError2(path90, message) {
67285
67302
  var _this = _super.call(this, message) || this;
67286
- _this.path = path89;
67303
+ _this.path = path90;
67287
67304
  Object.setPrototypeOf(_this, VError2.prototype);
67288
67305
  return _this;
67289
67306
  }
@@ -67343,26 +67360,26 @@ var require_util2 = __commonJS({
67343
67360
  (_b = this._messages).push.apply(_b, best._messages);
67344
67361
  }
67345
67362
  };
67346
- DetailContext2.prototype.getError = function(path89) {
67363
+ DetailContext2.prototype.getError = function(path90) {
67347
67364
  var msgParts = [];
67348
67365
  for (var i = this._propNames.length - 1; i >= 0; i--) {
67349
67366
  var p2 = this._propNames[i];
67350
- path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67367
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67351
67368
  var m = this._messages[i];
67352
67369
  if (m) {
67353
- msgParts.push(path89 + " " + m);
67370
+ msgParts.push(path90 + " " + m);
67354
67371
  }
67355
67372
  }
67356
- return new VError(path89, msgParts.join("; "));
67373
+ return new VError(path90, msgParts.join("; "));
67357
67374
  };
67358
- DetailContext2.prototype.getErrorDetail = function(path89) {
67375
+ DetailContext2.prototype.getErrorDetail = function(path90) {
67359
67376
  var details = [];
67360
67377
  for (var i = this._propNames.length - 1; i >= 0; i--) {
67361
67378
  var p2 = this._propNames[i];
67362
- path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67379
+ path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
67363
67380
  var message = this._messages[i];
67364
67381
  if (message) {
67365
- details.push({ path: path89, message });
67382
+ details.push({ path: path90, message });
67366
67383
  }
67367
67384
  }
67368
67385
  var detail = null;
@@ -68175,8 +68192,8 @@ var require_dist = __commonJS({
68175
68192
  this.checkerPlain = this.ttype.getChecker(suite, false);
68176
68193
  this.checkerStrict = this.ttype.getChecker(suite, true);
68177
68194
  }
68178
- Checker2.prototype.setReportedPath = function(path89) {
68179
- this._path = path89;
68195
+ Checker2.prototype.setReportedPath = function(path90) {
68196
+ this._path = path90;
68180
68197
  };
68181
68198
  Checker2.prototype.check = function(value) {
68182
68199
  return this._doCheck(this.checkerPlain, value);
@@ -73609,9 +73626,9 @@ var require_CJSImportTransformer = __commonJS({
73609
73626
  if (shouldElideImport) {
73610
73627
  this.tokens.removeToken();
73611
73628
  } else {
73612
- const path89 = this.tokens.stringValue();
73613
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
73614
- 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));
73615
73632
  }
73616
73633
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
73617
73634
  if (this.tokens.matches1(_types.TokenType.semi)) {
@@ -74191,8 +74208,8 @@ var require_CJSImportTransformer = __commonJS({
74191
74208
  }
74192
74209
  if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
74193
74210
  this.tokens.removeToken();
74194
- const path89 = this.tokens.stringValue();
74195
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
74211
+ const path90 = this.tokens.stringValue();
74212
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
74196
74213
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
74197
74214
  } else {
74198
74215
  this.tokens.appendCode(exportStatements.join(" "));
@@ -74206,8 +74223,8 @@ var require_CJSImportTransformer = __commonJS({
74206
74223
  while (!this.tokens.matches1(_types.TokenType.string)) {
74207
74224
  this.tokens.removeToken();
74208
74225
  }
74209
- const path89 = this.tokens.stringValue();
74210
- this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
74226
+ const path90 = this.tokens.stringValue();
74227
+ this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
74211
74228
  _removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
74212
74229
  if (this.tokens.matches1(_types.TokenType.semi)) {
74213
74230
  this.tokens.removeToken();
@@ -104061,9 +104078,9 @@ var init_bundle_mjs = __esm({
104061
104078
  processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
104062
104079
  }
104063
104080
  };
104064
- getPart = (classPartObject, path89) => {
104081
+ getPart = (classPartObject, path90) => {
104065
104082
  let current = classPartObject;
104066
- const parts = path89.split(CLASS_PART_SEPARATOR);
104083
+ const parts = path90.split(CLASS_PART_SEPARATOR);
104067
104084
  const len = parts.length;
104068
104085
  for (let i = 0; i < len; i++) {
104069
104086
  const part = parts[i];
@@ -107313,8 +107330,8 @@ var init_dist = __esm({
107313
107330
  });
107314
107331
 
107315
107332
  // src/lib/draw-mockup.ts
107316
- import fs82 from "node:fs";
107317
- import path83 from "node:path";
107333
+ import fs83 from "node:fs";
107334
+ import path84 from "node:path";
107318
107335
  import vm from "node:vm";
107319
107336
  async function loadPackage(id) {
107320
107337
  if (id === "react") return import_react3.default;
@@ -107327,22 +107344,22 @@ async function loadPackage(id) {
107327
107344
  return { __esModule: true, ...await load() };
107328
107345
  }
107329
107346
  function resolveFile(id, from, folder) {
107330
- const at2 = path83.resolve(path83.dirname(from), id);
107331
- if (at2 !== folder && !at2.startsWith(folder + path83.sep)) throw new Error(`${id} is outside the mockup's folder`);
107332
- const tries = path83.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path83.join(at2, `index${e2}`))];
107333
- 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());
107334
107351
  if (!file) throw new Error(`no such file: ${id}`);
107335
107352
  return file;
107336
107353
  }
107337
107354
  async function readGraph(entry) {
107338
- const folder = path83.dirname(entry);
107355
+ const folder = path84.dirname(entry);
107339
107356
  const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
107340
107357
  const walk3 = async (file) => {
107341
107358
  if (graph.code.has(file)) return;
107342
107359
  if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
107343
107360
  let location = file;
107344
107361
  try {
107345
- 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;
107346
107363
  graph.code.set(file, js);
107347
107364
  const link2 = /* @__PURE__ */ new Map();
107348
107365
  graph.links.set(file, link2);
@@ -107356,7 +107373,7 @@ async function readGraph(entry) {
107356
107373
  const target = resolveFile(id, file, folder);
107357
107374
  link2.set(id, target);
107358
107375
  if (!target.endsWith(".css")) await walk3(target);
107359
- 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") });
107360
107377
  }
107361
107378
  } catch (error) {
107362
107379
  throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
@@ -107373,12 +107390,12 @@ function run2(script, context, name, deadline, lineOffset = 0) {
107373
107390
  async function tailwindFor(markup, sheets) {
107374
107391
  const source = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
107375
107392
  const compiler = await rc(source, {
107376
- base: sheets.length ? path83.dirname(sheets[0].path) : "/",
107393
+ base: sheets.length ? path84.dirname(sheets[0].path) : "/",
107377
107394
  loadStylesheet: async (id, from) => {
107378
107395
  if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
107379
107396
  if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
107380
- const at2 = path83.resolve(from, id);
107381
- 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") };
107382
107399
  }
107383
107400
  });
107384
107401
  const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
@@ -107487,8 +107504,8 @@ var init_draw_mockup = __esm({
107487
107504
  });
107488
107505
 
107489
107506
  // src/lib/preview-validation.ts
107490
- import fs83 from "node:fs";
107491
- import path84 from "node:path";
107507
+ import fs84 from "node:fs";
107508
+ import path85 from "node:path";
107492
107509
  function renderError(error) {
107493
107510
  if (!error || typeof error !== "object") return String(error);
107494
107511
  const { message, stack } = error;
@@ -107499,7 +107516,7 @@ function renderError(error) {
107499
107516
  async function validateScreens(files2) {
107500
107517
  const errors = [];
107501
107518
  const entries = /* @__PURE__ */ new Map();
107502
- 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));
107503
107520
  for (const file of entries.values()) {
107504
107521
  try {
107505
107522
  await drawMockup(file);
@@ -107518,7 +107535,7 @@ async function validatePreview(file, text5) {
107518
107535
  if (/^ {0,3}<!--\s*agent\s*-->\s*$/.test(line)) own = false;
107519
107536
  if (own) section.push(line);
107520
107537
  }
107521
- 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));
107522
107539
  return validateScreens(files2);
107523
107540
  }
107524
107541
  var init_preview_validation = __esm({
@@ -107675,7 +107692,7 @@ __export(watch_exports, {
107675
107692
  watchRun: () => watchRun
107676
107693
  });
107677
107694
  import { spawn as spawn4 } from "node:child_process";
107678
- import fs84 from "node:fs";
107695
+ import fs85 from "node:fs";
107679
107696
  async function watchRun(sessionId, resume = startResume) {
107680
107697
  const spec = readSpec(sessionId);
107681
107698
  const run3 = peekRun(sessionId);
@@ -107711,11 +107728,11 @@ async function watchRun(sessionId, resume = startResume) {
107711
107728
  const record = claimed ?? run3;
107712
107729
  const sub = record.action === "sub";
107713
107730
  if (claim) await setCardStatus(claim.cardId, claim.status);
107714
- fs84.mkdirSync(SESSIONS_DIR, { recursive: true });
107715
- const logFile = fs84.createWriteStream(record.logPath, { flags: "a" });
107731
+ fs85.mkdirSync(SESSIONS_DIR, { recursive: true });
107732
+ const logFile = fs85.createWriteStream(record.logPath, { flags: "a" });
107716
107733
  logFile.on("error", () => {
107717
107734
  });
107718
- const eventsFile = fs84.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107735
+ const eventsFile = fs85.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
107719
107736
  eventsFile.on("error", () => {
107720
107737
  });
107721
107738
  const event2 = (e2) => eventsFile.write(`${JSON.stringify(e2)}
@@ -108301,7 +108318,7 @@ var init_watch = __esm({
108301
108318
  });
108302
108319
 
108303
108320
  // src/kanban.ts
108304
- import fs90 from "node:fs";
108321
+ import fs91 from "node:fs";
108305
108322
  import { fileURLToPath as fileURLToPath4 } from "node:url";
108306
108323
 
108307
108324
  // src/lib/cli/agent.ts
@@ -108784,8 +108801,8 @@ async function testAgent(args) {
108784
108801
  }
108785
108802
 
108786
108803
  // src/commands/cloud.ts
108787
- import fs72 from "node:fs";
108788
- import path73 from "node:path";
108804
+ import fs73 from "node:fs";
108805
+ import path74 from "node:path";
108789
108806
 
108790
108807
  // src/lib/cloud/avatar.ts
108791
108808
  init_session();
@@ -108833,13 +108850,13 @@ init_config();
108833
108850
  init_home();
108834
108851
  init_config();
108835
108852
  init_session();
108836
- import fs71 from "node:fs";
108837
- import path72 from "node:path";
108853
+ import fs72 from "node:fs";
108854
+ import path73 from "node:path";
108838
108855
  var FRESH_MS2 = 10 * 6e4;
108839
108856
  var GRACE_MS = 7 * 24 * 60 * 6e4;
108840
- var heldFile = () => path72.join(machineHome(), "pro.json");
108857
+ var heldFile = () => path73.join(machineHome(), "pro.json");
108841
108858
  function forgetPro() {
108842
- fs71.rmSync(heldFile(), { force: true });
108859
+ fs72.rmSync(heldFile(), { force: true });
108843
108860
  }
108844
108861
 
108845
108862
  // src/lib/cloud/account.ts
@@ -109016,10 +109033,10 @@ async function cloudImage(opts, program2) {
109016
109033
  const prompt = opts.prompt.trim();
109017
109034
  if (!prompt) usage("Missing the prompt.", line);
109018
109035
  const references = opts.refs.map((file) => {
109019
- const type = REF_TYPES[path73.extname(file).toLowerCase()];
109036
+ const type = REF_TYPES[path74.extname(file).toLowerCase()];
109020
109037
  if (!type) usage(`--ref ${file}: use a PNG, JPEG or WebP file.`, line);
109021
109038
  try {
109022
- return `data:${type};base64,${fs72.readFileSync(file).toString("base64")}`;
109039
+ return `data:${type};base64,${fs73.readFileSync(file).toString("base64")}`;
109023
109040
  } catch (e2) {
109024
109041
  usage(`--ref ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`, line);
109025
109042
  }
@@ -109125,8 +109142,8 @@ async function generate(g3) {
109125
109142
  refuse(g3.failed, g3.fallback);
109126
109143
  }
109127
109144
  const out = g3.outFor?.(res, g3.out) ?? g3.out;
109128
- fs72.mkdirSync(path73.dirname(path73.resolve(out)), { recursive: true });
109129
- 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()));
109130
109147
  say(`${out} (${g3.label(res)})`);
109131
109148
  return { out };
109132
109149
  }
@@ -109135,14 +109152,14 @@ async function generate(g3) {
109135
109152
  init_board_files();
109136
109153
  init_workflow_files();
109137
109154
  import crypto6 from "node:crypto";
109138
- import fs74 from "node:fs";
109139
- import path75 from "node:path";
109155
+ import fs75 from "node:fs";
109156
+ import path76 from "node:path";
109140
109157
 
109141
109158
  // src/lib/agents/shared-memory.ts
109142
109159
  init_bundled2();
109143
109160
  init_parse();
109144
- import fs73 from "node:fs";
109145
- import path74 from "node:path";
109161
+ import fs74 from "node:fs";
109162
+ import path75 from "node:path";
109146
109163
  function sharedMemory(board2) {
109147
109164
  const declared = /* @__PURE__ */ new Map();
109148
109165
  const take = (folder, text5, builtIn) => {
@@ -109154,16 +109171,16 @@ function sharedMemory(board2) {
109154
109171
  const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
109155
109172
  if (at2) take(at2[1], text5, officialAgent(at2[1]));
109156
109173
  }
109157
- const root2 = path74.join(board2, "agents");
109174
+ const root2 = path75.join(board2, "agents");
109158
109175
  let folders2 = [];
109159
109176
  try {
109160
- 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);
109161
109178
  } catch {
109162
109179
  }
109163
109180
  for (const folder of folders2.sort()) {
109164
109181
  let text5 = null;
109165
109182
  try {
109166
- text5 = fs73.readFileSync(path74.join(root2, folder, "AGENT.md"), "utf8");
109183
+ text5 = fs74.readFileSync(path75.join(root2, folder, "AGENT.md"), "utf8");
109167
109184
  } catch {
109168
109185
  }
109169
109186
  take(folder, text5, false);
@@ -109252,24 +109269,24 @@ async function findProject(asked) {
109252
109269
  }
109253
109270
  throw new Refused(`No project of yours has the id or prefix "${asked}".`, "not_found");
109254
109271
  }
109255
- var read2 = (file) => fs74.readFileSync(file, "utf8");
109272
+ var read2 = (file) => fs75.readFileSync(file, "utf8");
109256
109273
  var bytes2 = (text5) => Buffer.byteLength(text5, "utf8");
109257
109274
  function files(dir) {
109258
- if (!fs74.existsSync(dir)) return [];
109275
+ if (!fs75.existsSync(dir)) return [];
109259
109276
  const out = [];
109260
- for (const entry of fs74.readdirSync(dir, { withFileTypes: true })) {
109277
+ for (const entry of fs75.readdirSync(dir, { withFileTypes: true })) {
109261
109278
  if (entry.name.startsWith(".")) continue;
109262
- const full = path75.join(dir, entry.name);
109279
+ const full = path76.join(dir, entry.name);
109263
109280
  if (entry.isDirectory()) out.push(...files(full));
109264
109281
  else if (entry.isFile()) out.push(full);
109265
109282
  }
109266
109283
  return out;
109267
109284
  }
109268
- var posix = (p2) => p2.split(path75.sep).join("/");
109285
+ var posix = (p2) => p2.split(path76.sep).join("/");
109269
109286
  function openCards() {
109270
109287
  const out = [];
109271
109288
  for (const file of walkMd(TODO)) {
109272
- const rel2 = posix(path75.relative(TODO, file));
109289
+ const rel2 = posix(path76.relative(TODO, file));
109273
109290
  if (rel2 === "README.md") continue;
109274
109291
  const parts = rel2.split("/");
109275
109292
  const text5 = read2(file);
@@ -109356,8 +109373,8 @@ function draftsOf(text5) {
109356
109373
  const at2 = /^\.(assets|mockups)\/(.+)$/.exec(name);
109357
109374
  if (!at2) continue;
109358
109375
  const base = at2[1] === "assets" ? ASSETS : MOCKUPS;
109359
- const file = path75.resolve(base, at2[2]);
109360
- 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);
109361
109378
  }
109362
109379
  return [...out].map(([name, file]) => ({ name, file }));
109363
109380
  }
@@ -109391,9 +109408,9 @@ async function uploadDrafts(task, drafts) {
109391
109408
  const assets = {};
109392
109409
  for (const { name, file } of drafts) {
109393
109410
  if (!card.body.includes(name)) continue;
109394
- const ext = path75.extname(file).toLowerCase();
109411
+ const ext = path76.extname(file).toLowerCase();
109395
109412
  const type = TYPES2[ext] ?? "application/octet-stream";
109396
- const data = fs74.readFileSync(file);
109413
+ const data = fs75.readFileSync(file);
109397
109414
  const artifact = await api("POST", `/v1/tasks/${task}/artifacts`, { type: kindOf2(ext), name: name.slice(0, 200) });
109398
109415
  const upload = await api("POST", `/v1/artifacts/${artifact.id}/uploads`, { content_type: type, size: Math.max(data.length, 1) });
109399
109416
  await api("PUT", `/v1/uploads/${upload.id}`, void 0, { bytes: data, type });
@@ -109436,7 +109453,7 @@ usage: ${program2} cloud import --project <id or prefix> [--dry-run]`, { kind: "
109436
109453
  function localWorkflowFolders() {
109437
109454
  let folders2;
109438
109455
  try {
109439
- 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 }));
109440
109457
  } catch {
109441
109458
  return [];
109442
109459
  }
@@ -109447,19 +109464,19 @@ function localWorkflowFolders() {
109447
109464
  });
109448
109465
  }
109449
109466
  function filesUnder(dir, base = dir) {
109450
- return fs74.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
109451
- const full = path75.join(dir, e2.name);
109452
- 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))];
109453
109470
  });
109454
109471
  }
109455
109472
  function packLocalWorkflow(id, def, shipped) {
109456
- const dir = path75.join(WORKFLOWS, id);
109457
- 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")]));
109458
109475
  const named2 = [...def.previews, ...def.land, ...def.scheduled].map((h3) => h3.agent);
109459
109476
  for (const agent of new Set(named2)) {
109460
- const at2 = path75.join(AGENTS, agent);
109461
- if (fs74.existsSync(path75.join(at2, "AGENT.md"))) {
109462
- 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");
109463
109480
  continue;
109464
109481
  }
109465
109482
  for (const [key, text5] of Object.entries(shipped)) if (key.startsWith(`${agent}/`)) out[`agents/${key}`] = text5;
@@ -109469,10 +109486,10 @@ function packLocalWorkflow(id, def, shipped) {
109469
109486
  async function run(asked, dryRun) {
109470
109487
  const project = await findProject(asked);
109471
109488
  const cloudFlows2 = await all(`/v1/workflows?workspace=${encodeURIComponent(project.workspace)}`);
109472
- 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);
109473
109490
  const cards = openCards();
109474
109491
  const problems = [];
109475
- const where = (file) => posix(path75.relative(KANBAN, file));
109492
+ const where = (file) => posix(path76.relative(KANBAN, file));
109476
109493
  const own = [];
109477
109494
  for (const f2 of localWorkflowFolders()) {
109478
109495
  if (f2.def) own.push({ id: f2.id, name: f2.def.name, def: f2.def });
@@ -109501,7 +109518,7 @@ async function run(asked, dryRun) {
109501
109518
  const root2 = `projects/${project.id}/`;
109502
109519
  const boardFiles = [];
109503
109520
  for (const file of [...files(MEMORY), ...files(RULES), CONFIG, MODULES_MD]) {
109504
- if (!fs74.existsSync(file)) continue;
109521
+ if (!fs75.existsSync(file)) continue;
109505
109522
  const rel2 = where(file);
109506
109523
  if (!isBoardPath(rel2)) continue;
109507
109524
  const content = read2(file);
@@ -109612,16 +109629,16 @@ async function run(asked, dryRun) {
109612
109629
  }
109613
109630
  function leftLocal(own) {
109614
109631
  const out = [];
109615
- const count4 = (dir) => fs74.existsSync(dir) ? walkMd(dir).length : 0;
109632
+ const count4 = (dir) => fs75.existsSync(dir) ? walkMd(dir).length : 0;
109616
109633
  const archived = count4(ARCHIVE);
109617
109634
  if (archived) out.push(`.archive/ (${archived})`);
109618
109635
  const triage = count4(TRIAGE);
109619
109636
  if (triage) out.push(`triage/ (${triage})`);
109620
- if (fs74.existsSync(DELIVERIES)) out.push("deliveries/");
109621
- 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");
109622
109639
  const named2 = new Set(own.flatMap((w2) => [...w2.def.previews, ...w2.def.land, ...w2.def.scheduled].map((h3) => h3.agent)));
109623
- if (fs74.existsSync(AGENTS)) {
109624
- for (const e2 of fs74.readdirSync(AGENTS, { withFileTypes: true })) {
109640
+ if (fs75.existsSync(AGENTS)) {
109641
+ for (const e2 of fs75.readdirSync(AGENTS, { withFileTypes: true })) {
109625
109642
  if (e2.isDirectory() && !e2.name.startsWith(".") && !named2.has(e2.name)) out.push(`agents/${e2.name}/`);
109626
109643
  }
109627
109644
  }
@@ -109639,8 +109656,8 @@ init_session();
109639
109656
  init_io();
109640
109657
  init_paths();
109641
109658
  import { createHash as createHash5 } from "node:crypto";
109642
- import fs75 from "node:fs";
109643
- import path76 from "node:path";
109659
+ import fs76 from "node:fs";
109660
+ import path77 from "node:path";
109644
109661
  var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
109645
109662
  var CAPTURED = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/;
109646
109663
  var MAX_BYTES3 = 50 * 1024 * 1024;
@@ -109739,10 +109756,10 @@ This template has no preview.`);
109739
109756
  const written = [];
109740
109757
  for (const p2 of previews) {
109741
109758
  const bytes3 = Buffer.from(await (await ask(`/${at2}/previews/${route(p2.path)}`, {}, WITHOUT)).arrayBuffer());
109742
- const file = path76.basename(p2.path);
109743
- const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
109744
- fs75.mkdirSync(opts.to, { recursive: true });
109745
- 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);
109746
109763
  written.push(out);
109747
109764
  say(out);
109748
109765
  }
@@ -109755,15 +109772,15 @@ async function templateGet(name, opts, program2) {
109755
109772
  const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
109756
109773
  const fetched = [];
109757
109774
  for (const f2 of template.files) {
109758
- const out = path76.resolve(to, f2.path);
109759
- 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);
109760
109777
  const bytes3 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
109761
109778
  if (bytes3.byteLength !== f2.size || createHash5("sha256").update(bytes3).digest("hex") !== f2.sha256) {
109762
109779
  refuse2(T.corrupt, WITHOUT);
109763
109780
  }
109764
109781
  fetched.push({ out, bytes: bytes3 });
109765
109782
  }
109766
- 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));
109767
109784
  if (taken.length > 0) {
109768
109785
  refuse2({
109769
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`,
@@ -109771,8 +109788,8 @@ async function templateGet(name, opts, program2) {
109771
109788
  });
109772
109789
  }
109773
109790
  for (const f2 of fetched) {
109774
- fs75.mkdirSync(path76.dirname(f2.out), { recursive: true });
109775
- fs75.writeFileSync(f2.out, f2.bytes);
109791
+ fs76.mkdirSync(path77.dirname(f2.out), { recursive: true });
109792
+ fs76.writeFileSync(f2.out, f2.bytes);
109776
109793
  }
109777
109794
  say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
109778
109795
  Fetched ${name}: ${fetched.length} files into ${to}`);
@@ -109790,25 +109807,25 @@ async function templateSource(name, opts) {
109790
109807
  say(`evidence: ${e2.path}`);
109791
109808
  continue;
109792
109809
  }
109793
- const out = path76.join(opts.to, `${name}-${path76.basename(e2.path)}`);
109794
- fs75.mkdirSync(opts.to, { recursive: true });
109795
- 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()));
109796
109813
  written.push(out);
109797
109814
  say(out);
109798
109815
  }
109799
109816
  return { name, source, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
109800
109817
  }
109801
109818
  async function templatePublish(dir, opts) {
109802
- const root2 = path76.resolve(dir);
109803
- const manifest = path76.join(root2, "template.md");
109804
- 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.");
109805
- 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"));
109806
109823
  const files2 = walk2(root2);
109807
- 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);
109808
109825
  if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
109809
109826
  for (const extra of [...opts.preview, ...opts.evidence]) {
109810
- if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
109811
- 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)) {
109812
109829
  invalid(
109813
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`,
109814
109831
  `${extra} is inside the template folder; keep previews and evidence outside it.`
@@ -109820,10 +109837,10 @@ async function templatePublish(dir, opts) {
109820
109837
  }
109821
109838
  const form = new FormData();
109822
109839
  form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
109823
- const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
109824
- for (const f2 of files2) add("files", f2, path76.join(root2, f2));
109825
- for (const f2 of opts.preview) add("previews", path76.basename(f2), f2);
109826
- 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);
109827
109844
  const done2 = await asJson(await ask("", { method: "POST", body: form }));
109828
109845
  say(
109829
109846
  done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files2.length} \u4E2A\u6587\u4EF6\u3002
@@ -109839,11 +109856,11 @@ Deleted ${name} from the catalog.`);
109839
109856
  return { name, deleted: true };
109840
109857
  }
109841
109858
  async function templateShowcase(name, dir) {
109842
- const file = path76.join(dir, "showcase.json");
109843
- 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}.`);
109844
109861
  let meta;
109845
109862
  try {
109846
- meta = JSON.parse(fs75.readFileSync(file, "utf8"));
109863
+ meta = JSON.parse(fs76.readFileSync(file, "utf8"));
109847
109864
  } catch {
109848
109865
  return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
109849
109866
  }
@@ -109855,9 +109872,9 @@ async function templateShowcase(name, dir) {
109855
109872
  const form = new FormData();
109856
109873
  form.set("meta", JSON.stringify(meta));
109857
109874
  for (const p2 of new Set(named2)) {
109858
- const at2 = path76.join(dir, p2);
109859
- if (!fs75.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
109860
- 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);
109861
109878
  }
109862
109879
  const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
109863
109880
  say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
@@ -109866,7 +109883,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
109866
109883
  }
109867
109884
  function walk2(root2, sub = "") {
109868
109885
  const out = [];
109869
- 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 })) {
109870
109887
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
109871
109888
  const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
109872
109889
  if (entry.isDirectory()) out.push(...walk2(root2, rel2));
@@ -110023,8 +110040,12 @@ init_paths();
110023
110040
  init_workflow_diagram();
110024
110041
  init_cloud_workflows();
110025
110042
  init_workflows();
110026
- import fs76 from "node:fs";
110027
- 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";
110028
110049
  var found = (id) => {
110029
110050
  const flow = workflowById(id);
110030
110051
  if (!flow) {
@@ -110080,14 +110101,46 @@ function cmdWorkflowDiagram(id, card) {
110080
110101
  const agent = findSpecAgent(name);
110081
110102
  return agent ? { ...agent, after: agentAfter(name) } : null;
110082
110103
  });
110083
- const file = path77.join(ASSETS, String(cardId2), "workflow.json");
110084
- fs76.mkdirSync(path77.dirname(file), { recursive: true });
110085
- 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)}
110086
110107
  `);
110087
110108
  const tag = `<Workflow src=".assets/${cardId2}/workflow.json" label="${flow.name.replace(/"/g, "")}" />`;
110088
110109
  say(tag);
110089
110110
  return { file, tag, diagram };
110090
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
+ }
110091
110144
 
110092
110145
  // src/commands/run.ts
110093
110146
  init_progress();
@@ -110249,8 +110302,8 @@ init_tasks();
110249
110302
  init_read();
110250
110303
  init_rules();
110251
110304
  init_board();
110252
- import fs85 from "node:fs";
110253
- import path85 from "node:path";
110305
+ import fs86 from "node:fs";
110306
+ import path86 from "node:path";
110254
110307
  var FOLLOW_MS = 400;
110255
110308
  async function cmdStartRun(action, args, opts, program2 = "akb") {
110256
110309
  const { req, follow: follow2, print } = readRequest(action, args, opts);
@@ -110474,7 +110527,7 @@ async function cmdSubStart(words, opts) {
110474
110527
  let prompt = words.join(" ");
110475
110528
  if (opts.file) {
110476
110529
  try {
110477
- prompt = fs85.readFileSync(path85.resolve(opts.file), "utf8");
110530
+ prompt = fs86.readFileSync(path86.resolve(opts.file), "utf8");
110478
110531
  } catch {
110479
110532
  die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
110480
110533
  }
@@ -110765,7 +110818,7 @@ function cmdCompleteDelivery(id, options) {
110765
110818
  // src/commands/triage.ts
110766
110819
  init_scheduled();
110767
110820
  init_workflows();
110768
- import fs87 from "node:fs";
110821
+ import fs88 from "node:fs";
110769
110822
 
110770
110823
  // src/lib/signals/index.ts
110771
110824
  init_cards();
@@ -110775,16 +110828,16 @@ init_yaml();
110775
110828
  // src/lib/signals/config.ts
110776
110829
  init_settings();
110777
110830
  init_paths();
110778
- import fs86 from "node:fs";
110779
- import path86 from "node:path";
110831
+ import fs87 from "node:fs";
110832
+ import path87 from "node:path";
110780
110833
  var TOKEN_KEY = "TRIAGE_ENDPOINT_TOKEN";
110781
110834
  var ENDPOINT_SETTING = "Triage endpoint";
110782
110835
  var LINE2 = /^- \*\*Triage endpoint\*\*\s*[—-]\s*(.+)$/m;
110783
- var boardRel3 = (file) => rel(file).split(path86.sep).join("/");
110836
+ var boardRel3 = (file) => rel(file).split(path87.sep).join("/");
110784
110837
  function signalEndpoint() {
110785
110838
  let text5;
110786
110839
  try {
110787
- text5 = fs86.readFileSync(CONFIG, "utf8");
110840
+ text5 = fs87.readFileSync(CONFIG, "utf8");
110788
110841
  } catch {
110789
110842
  return "";
110790
110843
  }
@@ -110960,7 +111013,7 @@ async function cmdTriageAdd(opts) {
110960
111013
  let body = opts.text;
110961
111014
  if (opts.file !== void 0) {
110962
111015
  try {
110963
- body = fs87.readFileSync(opts.file, "utf8");
111016
+ body = fs88.readFileSync(opts.file, "utf8");
110964
111017
  } catch {
110965
111018
  die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
110966
111019
  }
@@ -111354,6 +111407,9 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
111354
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) {
111355
111408
  await onBoard2(this, cli, () => cmdWorkflowDiagram(id, card));
111356
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
+ });
111357
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() {
111358
111414
  const ctx = ctxOf(this, cli.program);
111359
111415
  useBoard(resolveBoard("components", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint }), ctx.dir !== null);
@@ -111530,8 +111586,8 @@ function declareAgent(program2, cli) {
111530
111586
  }
111531
111587
 
111532
111588
  // src/lib/cli/setup.ts
111533
- import fs89 from "node:fs";
111534
- import path88 from "node:path";
111589
+ import fs90 from "node:fs";
111590
+ import path89 from "node:path";
111535
111591
  import { fileURLToPath as fileURLToPath3 } from "node:url";
111536
111592
 
111537
111593
  // src/commands/update.ts
@@ -111545,8 +111601,8 @@ init_paths();
111545
111601
  init_memory();
111546
111602
  init_yaml2();
111547
111603
  init_version();
111548
- import fs88 from "node:fs";
111549
- import path87 from "node:path";
111604
+ import fs89 from "node:fs";
111605
+ import path88 from "node:path";
111550
111606
  import { spawnSync as spawnSync5 } from "node:child_process";
111551
111607
  var NAME = "wildcrane";
111552
111608
  var REPO = "https://github.com/wildcrane-ai/wildcrane";
@@ -111568,10 +111624,10 @@ var Report = class {
111568
111624
  for (const line of this.notes) say(` ! ${line}`);
111569
111625
  }
111570
111626
  };
111571
- var read4 = (file) => fs88.existsSync(file) ? fs88.readFileSync(file, "utf8") : null;
111627
+ var read4 = (file) => fs89.existsSync(file) ? fs89.readFileSync(file, "utf8") : null;
111572
111628
  function statOf(p2) {
111573
111629
  try {
111574
- return fs88.lstatSync(p2);
111630
+ return fs89.lstatSync(p2);
111575
111631
  } catch {
111576
111632
  return null;
111577
111633
  }
@@ -111596,10 +111652,10 @@ async function cmdUpdate2(ctx) {
111596
111652
  return { updated: ctx.dir, from, to: SKILL_VERSION };
111597
111653
  }
111598
111654
  async function repairBoard(root2, report3, named2) {
111599
- const legacy2 = path87.join(root2, "docs", "kanban");
111600
- const kept2 = path87.join(root2, ".akb", "kanban");
111601
- const board2 = named2 ?? (fs88.existsSync(legacy2) ? legacy2 : kept2);
111602
- 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)) {
111603
111659
  report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
111604
111660
  return false;
111605
111661
  }
@@ -111630,20 +111686,20 @@ function moveRuntimes(root2, board2, report3) {
111630
111686
  }
111631
111687
  }
111632
111688
  function moveLegacyMemory(board2, report3) {
111633
- const memory = path87.join(board2, "memory");
111689
+ const memory = path88.join(board2, "memory");
111634
111690
  const moved = [];
111635
111691
  for (const name of MEMORY_FILES) {
111636
- const from = path87.join(board2, name);
111692
+ const from = path88.join(board2, name);
111637
111693
  const st2 = statOf(from);
111638
111694
  if (!st2 || !st2.isFile()) continue;
111639
- fs88.mkdirSync(memory, { recursive: true });
111640
- const to = path87.join(memory, name);
111695
+ fs89.mkdirSync(memory, { recursive: true });
111696
+ const to = path88.join(memory, name);
111641
111697
  const there = read4(to);
111642
111698
  if (there === null) {
111643
- fs88.renameSync(from, to);
111699
+ fs89.renameSync(from, to);
111644
111700
  moved.push(name);
111645
111701
  } else if (there === read4(from)) {
111646
- fs88.rmSync(from);
111702
+ fs89.rmSync(from);
111647
111703
  moved.push(name);
111648
111704
  } else {
111649
111705
  report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
@@ -111652,23 +111708,23 @@ function moveLegacyMemory(board2, report3) {
111652
111708
  if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
111653
111709
  }
111654
111710
  function dropRecordFile(board2) {
111655
- const file = path87.join(board2, "record.csv");
111656
- if (!fs88.existsSync(file)) return null;
111657
- fs88.rmSync(file);
111711
+ const file = path88.join(board2, "record.csv");
111712
+ if (!fs89.existsSync(file)) return null;
111713
+ fs89.rmSync(file);
111658
111714
  return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
111659
111715
  }
111660
111716
  function dropModuleGoals(board2, report3) {
111661
- const memory = path87.join(board2, "memory");
111662
- if (!fs88.existsSync(memory)) return;
111663
- 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"));
111664
111720
  let dropped = 0;
111665
- for (const entry of fs88.readdirSync(memory, { withFileTypes: true })) {
111721
+ for (const entry of fs89.readdirSync(memory, { withFileTypes: true })) {
111666
111722
  if (!entry.isDirectory()) continue;
111667
- const file = path87.join(memory, entry.name, "goal.md");
111723
+ const file = path88.join(memory, entry.name, "goal.md");
111668
111724
  const text5 = read4(file);
111669
111725
  if (text5 === null) continue;
111670
111726
  if (text5 === root2 || text5.includes(UNFILLED) || !goalWords(text5)) {
111671
- fs88.rmSync(file);
111727
+ fs89.rmSync(file);
111672
111728
  dropped++;
111673
111729
  } else {
111674
111730
  report3.notes.push(
@@ -111690,10 +111746,10 @@ var PLAN_LEADS = {
111690
111746
  var GONE_LEADS = ["software-planner", "planner"];
111691
111747
  function planLeads(board2) {
111692
111748
  const leads = { ...PLAN_LEADS };
111693
- const root2 = path87.join(board2, "workflows");
111694
- 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 }) : []) {
111695
111751
  if (!entry.isDirectory()) continue;
111696
- 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;
111697
111753
  const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
111698
111754
  const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
111699
111755
  const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
@@ -111702,30 +111758,30 @@ function planLeads(board2) {
111702
111758
  return leads;
111703
111759
  }
111704
111760
  function movePlanRules(board2, report3) {
111705
- const rules = path87.join(board2, "rules");
111761
+ const rules = path88.join(board2, "rules");
111706
111762
  const moved = [];
111707
111763
  for (const [id, leads] of Object.entries(planLeads(board2))) {
111708
111764
  for (const lead of leads) {
111709
- const from = path87.join(rules, `${lead}.md`);
111765
+ const from = path88.join(rules, `${lead}.md`);
111710
111766
  const rule = read4(from)?.trim();
111711
111767
  if (!rule) continue;
111712
- const to = path87.join(rules, "workflows", `${id}.md`);
111768
+ const to = path88.join(rules, "workflows", `${id}.md`);
111713
111769
  const there = read4(to)?.trim() ?? "";
111714
111770
  if (!there.includes(rule)) {
111715
- fs88.mkdirSync(path87.dirname(to), { recursive: true });
111716
- 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")}
111717
111773
  `);
111718
111774
  moved.push(`${lead} \u2192 ${id}`);
111719
111775
  }
111720
111776
  }
111721
111777
  }
111722
- 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 });
111723
111779
  if (moved.length) report3.did.push(`made each plan agent's rule its workflow's card rule (docs/kanban/rules/workflows/): ${moved.join(", ")}`);
111724
111780
  }
111725
111781
  function noteOldWorkflows(board2, report3) {
111726
111782
  const old = (dir, file, keys) => {
111727
- const root2 = path87.join(board2, dir);
111728
- 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}`);
111729
111785
  };
111730
111786
  const files2 = [...old("workflows", "WORKFLOW.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
111731
111787
  if (files2.length) {
@@ -111735,7 +111791,7 @@ function noteOldWorkflows(board2, report3) {
111735
111791
  }
111736
111792
  }
111737
111793
  function checkConfig(board2, report3) {
111738
- const current = read4(path87.join(board2, "config.md"));
111794
+ const current = read4(path88.join(board2, "config.md"));
111739
111795
  if (!current) return;
111740
111796
  const added = missingConfigKeys(current);
111741
111797
  if (added.length) {
@@ -111745,7 +111801,7 @@ function checkConfig(board2, report3) {
111745
111801
  }
111746
111802
  }
111747
111803
  function checkModules(board2, report3) {
111748
- const map2 = read4(path87.join(board2, "modules.md"));
111804
+ const map2 = read4(path88.join(board2, "modules.md"));
111749
111805
  if (map2 && map2.includes(UNFILLED)) {
111750
111806
  report3.notes.push(
111751
111807
  "docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
@@ -111799,14 +111855,14 @@ function declareSetup(program2, cli) {
111799
111855
  program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
111800
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");
111801
111857
  const where = (cmd) => {
111802
- const dir = path88.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
111803
- 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 });
111804
111860
  return dir;
111805
111861
  };
111806
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() {
111807
111863
  const dir = where(this);
111808
111864
  const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
111809
- const board2 = named2 ? path88.resolve(cli.cwd, named2) : null;
111865
+ const board2 = named2 ? path89.resolve(cli.cwd, named2) : null;
111810
111866
  await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
111811
111867
  });
111812
111868
  program2.command("__rules", { hidden: true }).action(function() {
@@ -111851,7 +111907,7 @@ function invokedDirectly() {
111851
111907
  const entry = process.argv[1];
111852
111908
  if (!entry) return false;
111853
111909
  try {
111854
- return fs90.realpathSync(entry) === fs90.realpathSync(SELF2);
111910
+ return fs91.realpathSync(entry) === fs91.realpathSync(SELF2);
111855
111911
  } catch {
111856
111912
  return false;
111857
111913
  }