wildcrane-runner 0.6.38 → 0.6.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // ai4kanban 0.11.32 — built by runner/scripts/build.mjs. Do not edit.
2
+ // ai4kanban 0.11.33 — built by runner/scripts/build.mjs. Do not edit.
3
3
  import { createRequire as __ai4kanbanRequire } from 'node:module'
4
4
  const require = __ai4kanbanRequire(import.meta.url)
5
5
  var __create = Object.create;
@@ -3210,10 +3210,10 @@ function findRollout(threadId) {
3210
3210
  }
3211
3211
  for (const name of names3) {
3212
3212
  if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
3213
- const path85 = join(dir, name);
3213
+ const path84 = join(dir, name);
3214
3214
  try {
3215
- const at = statSync(path85).mtimeMs;
3216
- if (!newest2 || at > newest2.at) newest2 = { path: path85, at };
3215
+ const at = statSync(path84).mtimeMs;
3216
+ if (!newest2 || at > newest2.at) newest2 = { path: path84, at };
3217
3217
  } catch {
3218
3218
  }
3219
3219
  }
@@ -3221,11 +3221,11 @@ function findRollout(threadId) {
3221
3221
  return newest2?.path;
3222
3222
  }
3223
3223
  function readCodexRunFacts(threadId) {
3224
- const path85 = findRollout(threadId);
3225
- if (!path85) return void 0;
3224
+ const path84 = findRollout(threadId);
3225
+ if (!path84) return void 0;
3226
3226
  let raw;
3227
3227
  try {
3228
- raw = readFileSync(path85, "utf8");
3228
+ raw = readFileSync(path84, "utf8");
3229
3229
  } catch {
3230
3230
  return void 0;
3231
3231
  }
@@ -3353,8 +3353,8 @@ function renderCompleted(item) {
3353
3353
  const changes = Array.isArray(item.changes) ? item.changes : [];
3354
3354
  return changes.map((raw) => {
3355
3355
  const change2 = obj(raw);
3356
- const path85 = str(change2.path);
3357
- return path85 ? `\u23FA ${str(change2.kind) || "change"}(${path85})
3356
+ const path84 = str(change2.path);
3357
+ return path84 ? `\u23FA ${str(change2.kind) || "change"}(${path84})
3358
3358
  ` : "";
3359
3359
  }).join("");
3360
3360
  }
@@ -3616,10 +3616,10 @@ function readKimiRunFacts(sessionId) {
3616
3616
  const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
3617
3617
  let model;
3618
3618
  let holding = 0;
3619
- for (const { path: path85, main } of wireFiles(entry.sessionDir)) {
3619
+ for (const { path: path84, main } of wireFiles(entry.sessionDir)) {
3620
3620
  let raw;
3621
3621
  try {
3622
- raw = readFileSync2(path85, "utf8");
3622
+ raw = readFileSync2(path84, "utf8");
3623
3623
  } catch {
3624
3624
  continue;
3625
3625
  }
@@ -3902,7 +3902,7 @@ var init_package = __esm({
3902
3902
  "../cli/package.json"() {
3903
3903
  package_default = {
3904
3904
  name: "wildcrane",
3905
- version: "0.11.32",
3905
+ version: "0.11.33",
3906
3906
  akbContract: 8,
3907
3907
  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.",
3908
3908
  keywords: [
@@ -3979,8 +3979,8 @@ var init_version = __esm({
3979
3979
  import fs16 from "node:fs";
3980
3980
  function whereHint(update2, title) {
3981
3981
  const locations = Array.isArray(update2.locations) ? update2.locations : [];
3982
- const path85 = str(obj(locations[0]).path);
3983
- return path85 && !title.includes(path85) ? hint(path85) : "";
3982
+ const path84 = str(obj(locations[0]).path);
3983
+ return path84 && !title.includes(path84) ? hint(path84) : "";
3984
3984
  }
3985
3985
  function saidBy(update2) {
3986
3986
  const content = Array.isArray(update2.content) ? update2.content : [];
@@ -9179,6 +9179,15 @@ var init_parse = __esm({
9179
9179
  });
9180
9180
 
9181
9181
  // ../cli/src/lib/agent/workflow-def.ts
9182
+ function agentLines2(agents, indent2) {
9183
+ return agents.flatMap(
9184
+ (h) => !h.extra && !h.off ? [`${indent2}- ${scalar(h.agent)}`] : [
9185
+ `${indent2}- agent: ${scalar(h.agent)}`,
9186
+ ...h.extra ? [`${indent2} extra: ${JSON.stringify(h.extra)}`] : [],
9187
+ ...h.off ? [`${indent2} off: true`] : []
9188
+ ]
9189
+ );
9190
+ }
9182
9191
  function readAgent(item) {
9183
9192
  const row = typeof item === "string" ? { agent: item } : box(item);
9184
9193
  const agent = canonicalSpecAgent(text3(row.agent));
@@ -9258,13 +9267,18 @@ function parseWorkflowFile(id, source, from) {
9258
9267
  }
9259
9268
  };
9260
9269
  }
9261
- var WORKFLOW_ID, OLD_KEYS, box, text3, readGroup;
9270
+ var scalar, plain, flowList, groupLines, WORKFLOW_ID, OLD_KEYS, box, text3, readGroup;
9262
9271
  var init_workflow_def = __esm({
9263
9272
  "../cli/src/lib/agent/workflow-def.ts"() {
9264
9273
  "use strict";
9265
9274
  init_icon();
9266
9275
  init_yaml2();
9267
9276
  init_spec_agent_names();
9277
+ init_yaml();
9278
+ scalar = (value) => /\s#/.test(value) ? JSON.stringify(value) : yamlScalar(value);
9279
+ plain = (agents) => agents.every((h) => !h.extra && !h.off);
9280
+ flowList = (agents) => `[${agents.map((h) => scalar(h.agent)).join(", ")}]`;
9281
+ groupLines = (key, agents) => !agents.length ? [] : plain(agents) ? [`${key}: ${flowList(agents)}`] : [`${key}:`, ...agentLines2(agents, " ")];
9268
9282
  WORKFLOW_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
9269
9283
  OLD_KEYS = ["stages", "delivers", "helpers", "every"];
9270
9284
  box = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -9877,15 +9891,6 @@ var init_catalog = __esm({
9877
9891
  // ../cli/src/lib/agent/workflow-file.ts
9878
9892
  import fs31 from "node:fs";
9879
9893
  import path35 from "node:path";
9880
- function agentLines2(agents, indent2) {
9881
- return agents.flatMap(
9882
- (h) => !h.extra && !h.off ? [`${indent2}- ${scalar(h.agent)}`] : [
9883
- `${indent2}- agent: ${scalar(h.agent)}`,
9884
- ...h.extra ? [`${indent2} extra: ${JSON.stringify(h.extra)}`] : [],
9885
- ...h.off ? [`${indent2} off: true`] : []
9886
- ]
9887
- );
9888
- }
9889
9894
  function workflowFileText(def) {
9890
9895
  const lines = ["---", `name: ${scalar(def.name)}`];
9891
9896
  const names3 = Object.entries(def.names ?? {});
@@ -9893,8 +9898,7 @@ function workflowFileText(def) {
9893
9898
  if (def.description) lines.push(`description: ${scalar(def.description)}`);
9894
9899
  if (def.when) lines.push(`when: ${scalar(def.when)}`);
9895
9900
  lines.push(`needsArtifact: ${def.needsArtifact}`);
9896
- const group = (key, agents) => !agents.length ? [] : plain(agents) ? [`${key}: ${flowList(agents)}`] : [`${key}:`, ...agentLines2(agents, " ")];
9897
- lines.push(...group("previews", def.previews), ...group("land", def.land));
9901
+ lines.push(...groupLines("previews", def.previews), ...groupLines("land", def.land));
9898
9902
  if (def.scheduled.length) {
9899
9903
  lines.push("scheduled:");
9900
9904
  for (const s of def.scheduled) {
@@ -9942,7 +9946,7 @@ function writeWorkflowDef(def) {
9942
9946
  fs31.writeFileSync(file, workflowFileText(def));
9943
9947
  forgetFileMemos();
9944
9948
  }
9945
- var WORKFLOW_FILE2, scalar, plain, flowList, builtinDefs, fileOf;
9949
+ var WORKFLOW_FILE2, builtinDefs, fileOf;
9946
9950
  var init_workflow_file = __esm({
9947
9951
  "../cli/src/lib/agent/workflow-file.ts"() {
9948
9952
  "use strict";
@@ -9950,14 +9954,10 @@ var init_workflow_file = __esm({
9950
9954
  init_board_files();
9951
9955
  init_tasks();
9952
9956
  init_paths();
9953
- init_yaml();
9954
9957
  init_cloud_workflows();
9955
9958
  init_workflow_def();
9956
9959
  init_workflow_def();
9957
9960
  WORKFLOW_FILE2 = "WORKFLOW.md";
9958
- scalar = (value) => /\s#/.test(value) ? JSON.stringify(value) : yamlScalar(value);
9959
- plain = (agents) => agents.every((h) => !h.extra && !h.off);
9960
- flowList = (agents) => `[${agents.map((h) => scalar(h.agent)).join(", ")}]`;
9961
9961
  builtinDefs = () => cloudFlows().filter((f) => f.builtIn).map((f) => f.def);
9962
9962
  fileOf = (id) => path35.join(WORKFLOWS, id, WORKFLOW_FILE2);
9963
9963
  }
@@ -10539,9 +10539,9 @@ var init_goal_cloud = __esm({
10539
10539
  }
10540
10540
  });
10541
10541
 
10542
- // ../cli/node_modules/commander/lib/error.js
10542
+ // ../../../../cli/node_modules/commander/lib/error.js
10543
10543
  var require_error = __commonJS({
10544
- "../cli/node_modules/commander/lib/error.js"(exports) {
10544
+ "../../../../cli/node_modules/commander/lib/error.js"(exports) {
10545
10545
  var CommanderError2 = class extends Error {
10546
10546
  /**
10547
10547
  * Constructs the CommanderError class
@@ -10574,9 +10574,9 @@ var require_error = __commonJS({
10574
10574
  }
10575
10575
  });
10576
10576
 
10577
- // ../cli/node_modules/commander/lib/argument.js
10577
+ // ../../../../cli/node_modules/commander/lib/argument.js
10578
10578
  var require_argument = __commonJS({
10579
- "../cli/node_modules/commander/lib/argument.js"(exports) {
10579
+ "../../../../cli/node_modules/commander/lib/argument.js"(exports) {
10580
10580
  var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
10581
10581
  var Argument2 = class {
10582
10582
  /**
@@ -10701,9 +10701,9 @@ var require_argument = __commonJS({
10701
10701
  }
10702
10702
  });
10703
10703
 
10704
- // ../cli/node_modules/commander/lib/help.js
10704
+ // ../../../../cli/node_modules/commander/lib/help.js
10705
10705
  var require_help = __commonJS({
10706
- "../cli/node_modules/commander/lib/help.js"(exports) {
10706
+ "../../../../cli/node_modules/commander/lib/help.js"(exports) {
10707
10707
  var { humanReadableArgName } = require_argument();
10708
10708
  var Help2 = class {
10709
10709
  constructor() {
@@ -11270,9 +11270,9 @@ ${itemIndentStr}`);
11270
11270
  }
11271
11271
  });
11272
11272
 
11273
- // ../cli/node_modules/commander/lib/option.js
11273
+ // ../../../../cli/node_modules/commander/lib/option.js
11274
11274
  var require_option = __commonJS({
11275
- "../cli/node_modules/commander/lib/option.js"(exports) {
11275
+ "../../../../cli/node_modules/commander/lib/option.js"(exports) {
11276
11276
  var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
11277
11277
  var Option2 = class {
11278
11278
  /**
@@ -11571,9 +11571,9 @@ var require_option = __commonJS({
11571
11571
  }
11572
11572
  });
11573
11573
 
11574
- // ../cli/node_modules/commander/lib/suggestSimilar.js
11574
+ // ../../../../cli/node_modules/commander/lib/suggestSimilar.js
11575
11575
  var require_suggestSimilar = __commonJS({
11576
- "../cli/node_modules/commander/lib/suggestSimilar.js"(exports) {
11576
+ "../../../../cli/node_modules/commander/lib/suggestSimilar.js"(exports) {
11577
11577
  var maxDistance = 3;
11578
11578
  function editDistance2(a, b) {
11579
11579
  if (Math.abs(a.length - b.length) > maxDistance)
@@ -11651,13 +11651,13 @@ var require_suggestSimilar = __commonJS({
11651
11651
  }
11652
11652
  });
11653
11653
 
11654
- // ../cli/node_modules/commander/lib/command.js
11654
+ // ../../../../cli/node_modules/commander/lib/command.js
11655
11655
  var require_command = __commonJS({
11656
- "../cli/node_modules/commander/lib/command.js"(exports) {
11656
+ "../../../../cli/node_modules/commander/lib/command.js"(exports) {
11657
11657
  var EventEmitter = __require("node:events").EventEmitter;
11658
11658
  var childProcess = __require("node:child_process");
11659
- var path85 = __require("node:path");
11660
- var fs87 = __require("node:fs");
11659
+ var path84 = __require("node:path");
11660
+ var fs86 = __require("node:fs");
11661
11661
  var process2 = __require("node:process");
11662
11662
  var { Argument: Argument2, humanReadableArgName } = require_argument();
11663
11663
  var { CommanderError: CommanderError2 } = require_error();
@@ -12638,7 +12638,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
12638
12638
  * @param {string} subcommandName
12639
12639
  */
12640
12640
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
12641
- if (fs87.existsSync(executableFile)) return;
12641
+ if (fs86.existsSync(executableFile)) return;
12642
12642
  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";
12643
12643
  const executableMissing = `'${executableFile}' does not exist
12644
12644
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -12656,11 +12656,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
12656
12656
  let launchWithNode = false;
12657
12657
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
12658
12658
  function findFile(baseDir, baseName) {
12659
- const localBin = path85.resolve(baseDir, baseName);
12660
- if (fs87.existsSync(localBin)) return localBin;
12661
- if (sourceExt.includes(path85.extname(baseName))) return void 0;
12659
+ const localBin = path84.resolve(baseDir, baseName);
12660
+ if (fs86.existsSync(localBin)) return localBin;
12661
+ if (sourceExt.includes(path84.extname(baseName))) return void 0;
12662
12662
  const foundExt = sourceExt.find(
12663
- (ext) => fs87.existsSync(`${localBin}${ext}`)
12663
+ (ext) => fs86.existsSync(`${localBin}${ext}`)
12664
12664
  );
12665
12665
  if (foundExt) return `${localBin}${foundExt}`;
12666
12666
  return void 0;
@@ -12672,21 +12672,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
12672
12672
  if (this._scriptPath) {
12673
12673
  let resolvedScriptPath;
12674
12674
  try {
12675
- resolvedScriptPath = fs87.realpathSync(this._scriptPath);
12675
+ resolvedScriptPath = fs86.realpathSync(this._scriptPath);
12676
12676
  } catch {
12677
12677
  resolvedScriptPath = this._scriptPath;
12678
12678
  }
12679
- executableDir = path85.resolve(
12680
- path85.dirname(resolvedScriptPath),
12679
+ executableDir = path84.resolve(
12680
+ path84.dirname(resolvedScriptPath),
12681
12681
  executableDir
12682
12682
  );
12683
12683
  }
12684
12684
  if (executableDir) {
12685
12685
  let localFile = findFile(executableDir, executableFile);
12686
12686
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
12687
- const legacyName = path85.basename(
12687
+ const legacyName = path84.basename(
12688
12688
  this._scriptPath,
12689
- path85.extname(this._scriptPath)
12689
+ path84.extname(this._scriptPath)
12690
12690
  );
12691
12691
  if (legacyName !== this._name) {
12692
12692
  localFile = findFile(
@@ -12697,7 +12697,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
12697
12697
  }
12698
12698
  executableFile = localFile || executableFile;
12699
12699
  }
12700
- launchWithNode = sourceExt.includes(path85.extname(executableFile));
12700
+ launchWithNode = sourceExt.includes(path84.extname(executableFile));
12701
12701
  let proc;
12702
12702
  if (process2.platform !== "win32") {
12703
12703
  if (launchWithNode) {
@@ -13544,7 +13544,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
13544
13544
  * @return {Command}
13545
13545
  */
13546
13546
  nameFromFilename(filename) {
13547
- this._name = path85.basename(filename, path85.extname(filename));
13547
+ this._name = path84.basename(filename, path84.extname(filename));
13548
13548
  return this;
13549
13549
  }
13550
13550
  /**
@@ -13558,9 +13558,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
13558
13558
  * @param {string} [path]
13559
13559
  * @return {(string|null|Command)}
13560
13560
  */
13561
- executableDir(path86) {
13562
- if (path86 === void 0) return this._executableDir;
13563
- this._executableDir = path86;
13561
+ executableDir(path85) {
13562
+ if (path85 === void 0) return this._executableDir;
13563
+ this._executableDir = path85;
13564
13564
  return this;
13565
13565
  }
13566
13566
  /**
@@ -13810,9 +13810,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
13810
13810
  }
13811
13811
  });
13812
13812
 
13813
- // ../cli/node_modules/commander/index.js
13813
+ // ../../../../cli/node_modules/commander/index.js
13814
13814
  var require_commander = __commonJS({
13815
- "../cli/node_modules/commander/index.js"(exports) {
13815
+ "../../../../cli/node_modules/commander/index.js"(exports) {
13816
13816
  var { Argument: Argument2 } = require_argument();
13817
13817
  var { Command: Command2 } = require_command();
13818
13818
  var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
@@ -13832,10 +13832,10 @@ var require_commander = __commonJS({
13832
13832
  }
13833
13833
  });
13834
13834
 
13835
- // ../cli/node_modules/commander/esm.mjs
13835
+ // ../../../../cli/node_modules/commander/esm.mjs
13836
13836
  var import_index, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
13837
13837
  var init_esm = __esm({
13838
- "../cli/node_modules/commander/esm.mjs"() {
13838
+ "../../../../cli/node_modules/commander/esm.mjs"() {
13839
13839
  import_index = __toESM(require_commander(), 1);
13840
13840
  ({
13841
13841
  program,
@@ -14985,23 +14985,6 @@ function readRule(agent) {
14985
14985
  migrateFlowRules();
14986
14986
  return ruleFile(agent);
14987
14987
  }
14988
- function setAgentRule(agent, text4) {
14989
- migrateFlowRules();
14990
- if (!agentNames().includes(agent)) return { ok: false, error: notOnTheRoster(agent) };
14991
- const rule = String(text4 ?? "").trim();
14992
- try {
14993
- if (!rule) {
14994
- fs45.rmSync(rulePath(agent), { force: true });
14995
- return { ok: true };
14996
- }
14997
- fs45.mkdirSync(RULES, { recursive: true });
14998
- fs45.writeFileSync(rulePath(agent), `${rule}
14999
- `);
15000
- return { ok: true };
15001
- } catch (err) {
15002
- return { ok: false, error: err instanceof Error ? err.message : String(err) };
15003
- }
15004
- }
15005
14988
  function deliveryRules(workflow) {
15006
14989
  migrateFlowRules();
15007
14990
  const rules = {};
@@ -15104,7 +15087,7 @@ function adoptRenamedRules() {
15104
15087
  }
15105
15088
  }
15106
15089
  }
15107
- var rulePath, notOnTheRoster, flowForRequest, ruleOwnerSays, said, RENAMED_ROLES;
15090
+ var rulePath, flowForRequest, ruleOwnerSays, said, RENAMED_ROLES;
15108
15091
  var init_rules2 = __esm({
15109
15092
  "../cli/src/lib/agent/rules.ts"() {
15110
15093
  "use strict";
@@ -15116,7 +15099,6 @@ var init_rules2 = __esm({
15116
15099
  init_workflows();
15117
15100
  init_types();
15118
15101
  rulePath = (agent) => path47.join(RULES, `${agent}.md`);
15119
- notOnTheRoster = (name) => `"${name}" is not an agent on this board. It has: ${agentNames().join(", ")}.`;
15120
15102
  flowForRequest = (req) => req.refineRound !== void 0 && REFINE_ACTIONS.has(req.action) ? flowByCommand("refine") : flowByAction(req.action);
15121
15103
  ruleOwnerSays = (owner) => `\`${owner.name}\` agent carries one rule of its own${owner.role ? ", on every flow it runs" : ""}`;
15122
15104
  said = (owner, rule) => owner && rule ? [
@@ -15656,7 +15638,7 @@ var init_pictures = __esm({
15656
15638
  var Asset_default;
15657
15639
  var init_Asset = __esm({
15658
15640
  "../cli/src/components/Asset.md"() {
15659
- Asset_default = '# Asset\n\nEmbed a file with `<Asset src=".assets/<card id>/<file>" label="..." />` alone in a paragraph.\nInline and fenced examples remain text.\n\n- **Label**: use a few words; an image\'s optional `alt` is its shipped caption and cannot contain `<`, `>` or its enclosing quote.\n- **Device**: use a separate tag for each device view, with `device="mobile"` or `device="desktop"`; both may reference the same responsive page.\n- **Variants**: versions of the same content on the same device share one tag with `variants=\'{"English": ".assets/<card id>/page.en.html", "\u4E2D\u6587": ".assets/<card id>/page.zh.html"}\'`, with `src` shown first; alternatives stay separate tags.\n- **Loop**: add `loop` for muted, looping video without controls.\n- **Tiled map**: a `.tmx` or `.tmj` `src` draws as a map; keep its `.tsx`/`.tsj` tilesets and images beside it, at the relative paths it names.\n- **Sprite animation**: a TexturePacker JSON (Hash or Array) `src` plays as an animation; keep its sheet image beside it, at the relative path `meta.image` names.\n- **Web page**: an `.html` `src` loads only the files its tags and styles name by relative path, never paths that appear only in its scripts.\n';
15641
+ Asset_default = '# Asset\n\nEmbed a file with `<Asset src=".assets/<card id>/<file>" label="..." />` alone in a paragraph.\nInline and fenced examples remain text.\n\n- **Label**: use a few words; an image\'s optional `alt` is its shipped caption and cannot contain `<`, `>` or its enclosing quote.\n- **Device**: use a separate tag for each device view, with `device="mobile"` or `device="desktop"`; both may reference the same responsive page.\n- **Variants**: versions of the same content on the same device share one tag with `variants=\'{"English": ".assets/<card id>/page.en.html", "\u4E2D\u6587": ".assets/<card id>/page.zh.html"}\'`, with `src` shown first; alternatives stay separate tags.\n- **Loop**: add `loop` for muted, looping video without controls.\n- **Tiled map**: a `.tmx` or `.tmj` `src` draws as a map; keep its `.tsx`/`.tsj` tilesets and images beside it, at the relative paths it names.\n- **Sprite animation**: a TexturePacker JSON (Hash or Array) `src` plays as an animation; keep its sheet image beside it, at the relative path `meta.image` names.\n- **Web page**: an `.html` `src` loads only the files its tags and styles name by relative path, never paths that appear only in its scripts.\n- **Text**: code and other text files show as highlighted text; a `.diff` or `.patch` shows its added and removed lines.\n';
15660
15642
  }
15661
15643
  });
15662
15644
 
@@ -15668,6 +15650,14 @@ var init_Compare = __esm({
15668
15650
  }
15669
15651
  });
15670
15652
 
15653
+ // ../cli/src/components/Set.md
15654
+ var Set_default;
15655
+ var init_Set = __esm({
15656
+ "../cli/src/components/Set.md"() {
15657
+ Set_default = '# Set\n\nGroup three or more previews of one purpose: a `<Set label="...">` line, one `<Asset ... />` per line, then `</Set>`, as one paragraph with no blank line inside. Inline and fenced examples remain text.\n\n- **One purpose**: one set per purpose, such as a screen\'s states or the files you changed; keep one or two previews as plain Assets.\n- **One item per label**: Assets sharing a `label` are one item; their `device` views, and a file beside its `.diff` or `.patch`, become switches on it.\n- **Items**: anything an Asset shows, but not a compare or storyboard.\n';
15658
+ }
15659
+ });
15660
+
15671
15661
  // ../cli/src/components/Storyboard.md
15672
15662
  var Storyboard_default;
15673
15663
  var init_Storyboard = __esm({
@@ -15724,6 +15714,7 @@ var init_components = __esm({
15724
15714
  "use strict";
15725
15715
  init_Asset();
15726
15716
  init_Compare();
15717
+ init_Set();
15727
15718
  init_Storyboard();
15728
15719
  init_Workflow();
15729
15720
  init_shared();
@@ -15731,7 +15722,7 @@ var init_components = __esm({
15731
15722
  init_io();
15732
15723
  init_paths();
15733
15724
  init_workflows();
15734
- DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default, Workflow: Workflow_default };
15725
+ DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default, Set: Set_default, Workflow: Workflow_default };
15735
15726
  componentDocsText = (docs) => docs.length ? [shared_default, ...docs.map((doc) => doc.text)].map((text4) => text4.trim()).join("\n\n") : "";
15736
15727
  }
15737
15728
  });
@@ -18513,14 +18504,14 @@ function collect(body, card, host2) {
18513
18504
  const active2 = /* @__PURE__ */ new Set();
18514
18505
  const out = [];
18515
18506
  const visit = (src, types, owner) => {
18516
- const path85 = src.replace(/[?#].*$/, "");
18507
+ const path84 = src.replace(/[?#].*$/, "");
18517
18508
  let resolved2;
18518
18509
  try {
18519
- resolved2 = host2.resolve(path85, owner);
18510
+ resolved2 = host2.resolve(path84, owner);
18520
18511
  } catch (error) {
18521
18512
  if (owner !== card) return { key: null, error: why(error) };
18522
18513
  if (!nodes.has(src)) {
18523
- const node2 = { key: src, file: null, kind: kindAt(path85, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18514
+ const node2 = { key: src, file: null, kind: kindAt(path84, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
18524
18515
  nodes.set(src, node2);
18525
18516
  out.push(node2);
18526
18517
  }
@@ -18810,6 +18801,7 @@ function validateSpec(file, text4, id) {
18810
18801
  const markers = [];
18811
18802
  const { visible, fence, comment } = scanCardLines(lines, end2 + 1);
18812
18803
  const acceptance = [];
18804
+ const sets = /* @__PURE__ */ new Set();
18813
18805
  for (let i = end2 + 1; i < lines.length; i++) {
18814
18806
  const line = visible[i];
18815
18807
  if (/^\s*<!--\s*agent\s*-->\s*$/.test(line)) {
@@ -18821,8 +18813,16 @@ function validateSpec(file, text4, id) {
18821
18813
  const heading = line.match(/^ {0,3}(#{1,2})\s+(.+?)\s*#*\s*$/);
18822
18814
  if (heading?.[1] === "#") add(i + 1, "heading", "Do not repeat the card title as an H1. Remove this heading or use ### inside your section.");
18823
18815
  if (heading?.[1] === "##") headings.push({ title: heading[2], line: i + 1 });
18816
+ if (/^\s*<\/?Set\b/.test(line) && !sets.has(i)) {
18817
+ const close = /^\s*<Set\b/.test(line) ? setEnd(visible, i) : -1;
18818
+ if (close < 0) add(i + 1, "set-block", 'Write <Set label="..."> on its own line after a blank line, then one <Asset ... /> per line, then </Set> followed by a blank line.');
18819
+ else {
18820
+ sets.add(i).add(close);
18821
+ if (!/\blabel="[^"]+"/.test(line)) add(i + 1, "set-label", 'Add a non-empty label="..." attribute to the Set tag.');
18822
+ }
18823
+ }
18824
18824
  if (/^\s*<(?:Asset|Mockup)\b/.test(line)) {
18825
- if (!/^\s*<(?:Asset|Mockup)\b[^<>]*\/>\s*$/.test(line) || lines[i - 1]?.trim() && !/^\s*<(?:Asset|Mockup)\b/.test(lines[i - 1]) || lines[i + 1]?.trim() && !/^\s*<(?:Asset|Mockup)\b/.test(lines[i + 1])) {
18825
+ if (!/^\s*<(?:Asset|Mockup)\b[^<>]*\/>\s*$/.test(line) || lines[i - 1]?.trim() && !BLOCK_LINE.test(lines[i - 1]) || lines[i + 1]?.trim() && !BLOCK_LINE.test(lines[i + 1])) {
18826
18826
  add(i + 1, "mockup-block", "Put the self-closing <Asset ... /> tag on its own line, with blank lines separating it from prose.");
18827
18827
  }
18828
18828
  if (!/\bsrc="[^"]+"/.test(line) || !/\blabel="[^"]+"/.test(line)) add(i + 1, "mockup-attributes", 'Add non-empty src="..." and label="..." attributes to the Asset tag.');
@@ -18888,6 +18888,13 @@ function validateSpec(file, text4, id) {
18888
18888
  if (id !== void 0) errors.push(...validateStoryboards(file, id, text4), ...validatePreviewFiles(file, id, text4));
18889
18889
  return errors;
18890
18890
  }
18891
+ function setEnd(lines, at) {
18892
+ if (!/^\s*<Set\b[^<>]*>\s*$/.test(lines[at]) || lines[at - 1]?.trim()) return -1;
18893
+ let i = at + 1;
18894
+ while (i < lines.length && ASSET_LINE.test(lines[i])) i++;
18895
+ if (i === at + 1 || !/^\s*<\/Set>\s*$/.test(lines[i] ?? "") || lines[i + 1]?.trim()) return -1;
18896
+ return i;
18897
+ }
18891
18898
  function inside(dir, name) {
18892
18899
  try {
18893
18900
  const root2 = fs56.realpathSync(dir);
@@ -18985,7 +18992,7 @@ function validateStoryboards(file, id, text4) {
18985
18992
  function formatContractErrors(errors) {
18986
18993
  return ["Spec format validation failed. Fix these errors without changing the planned behavior:", ...errors.map((e) => `${e.file}:${e.line} [${e.rule}] ${e.message}`)].join("\n");
18987
18994
  }
18988
- var formatProblems;
18995
+ var ASSET_LINE, BLOCK_LINE, boardCheckErrors, boardProblems;
18989
18996
  var init_spec_contract = __esm({
18990
18997
  "../cli/src/lib/spec-contract.ts"() {
18991
18998
  "use strict";
@@ -18996,7 +19003,10 @@ var init_spec_contract = __esm({
18996
19003
  init_storyboard();
18997
19004
  init_preview_files();
18998
19005
  init_validate();
18999
- formatProblems = (errors) => ["Task format problems:", ...errors.map((e) => `- ${e.message}`)].join("\n");
19006
+ ASSET_LINE = /^\s*<(?:Asset|Mockup)\b[^<>]*\/>\s*$/;
19007
+ BLOCK_LINE = /^\s*<(?:Asset\b|Mockup\b|Set\b|\/Set>)/;
19008
+ boardCheckErrors = (errors) => ["Board check failed. Fix these errors without changing the planned behavior:", ...errors.map((e) => `${e.file}:${e.line} [${e.rule}] ${e.message}`)].join("\n");
19009
+ boardProblems = (errors) => ["Board problems:", ...errors.map((e) => `- ${e.message}`)].join("\n");
19000
19010
  }
19001
19011
  });
19002
19012
 
@@ -21242,43 +21252,6 @@ var init_memory_file = __esm({
21242
21252
  }
21243
21253
  });
21244
21254
 
21245
- // ../cli/src/commands/rule.ts
21246
- import fs70 from "node:fs";
21247
- import path71 from "node:path";
21248
- function cmdRule(askedName, flags) {
21249
- const agent = askedName.trim();
21250
- if (!agentRoster().some((a) => a.name === agent)) {
21251
- die(notOnTheRoster(askedName), { kind: "no-such-agent", agent: askedName });
21252
- }
21253
- const rule = readRuleText(flags.file, flags.text);
21254
- const res = setAgentRule(agent, rule);
21255
- if (!res.ok) die(res.error);
21256
- const file = rel(path71.join(RULES, `${agent}.md`));
21257
- say(rule ? `wrote the \`${agent}\` rule (${file})` : `cleared the \`${agent}\` rule`);
21258
- return { agent, file, cleared: !rule };
21259
- }
21260
- function readRuleText(file, text4) {
21261
- if (file !== void 0 && text4 !== void 0) die("pass --file or --text, not both");
21262
- if (file !== void 0) {
21263
- try {
21264
- return fs70.readFileSync(file, "utf8").trim();
21265
- } catch {
21266
- die(`can't read ${file} \u2014 write the rule to a file, then pass its path`);
21267
- }
21268
- }
21269
- if (text4 !== void 0) return text4.trim();
21270
- die('the rule has to come from somewhere: --file <path>, --text "..." for a one-liner, or --text "" to clear it');
21271
- }
21272
- var init_rule = __esm({
21273
- "../cli/src/commands/rule.ts"() {
21274
- "use strict";
21275
- init_io();
21276
- init_paths();
21277
- init_roles();
21278
- init_rules2();
21279
- }
21280
- });
21281
-
21282
21255
  // ../cli/src/commands/validate.ts
21283
21256
  function cmdValidate(id) {
21284
21257
  const cards = [...snapshotSpecs()].filter(([, card]) => id === void 0 || card.id === id);
@@ -21472,7 +21445,6 @@ var init_local2 = __esm({
21472
21445
  init_remove();
21473
21446
  init_agent_file();
21474
21447
  init_memory_file();
21475
- init_rule();
21476
21448
  init_validate2();
21477
21449
  init_io();
21478
21450
  init_lock();
@@ -21489,7 +21461,6 @@ var init_local2 = __esm({
21489
21461
  list: ({ opts }) => cmdList(as(opts)),
21490
21462
  archive: ({ args }) => cmdRemove(Number(args[0]), "completed"),
21491
21463
  reject: ({ args, opts }) => cmdRemove(Number(args[0]), "rejected", as(opts)),
21492
- rule: ({ args, opts }) => cmdRule(args[0] ?? "", as(opts)),
21493
21464
  "agent-file": ({ args }) => cmdAgentFile(args[0] ?? "", args[1] ?? ""),
21494
21465
  "memory-file": ({ args }) => cmdMemoryFile(args[0] ?? "")
21495
21466
  };
@@ -21545,8 +21516,8 @@ var init_created_cards = __esm({
21545
21516
 
21546
21517
  // ../cli/src/lib/agent/creation.ts
21547
21518
  import crypto4 from "node:crypto";
21548
- import fs71 from "node:fs";
21549
- import path72 from "node:path";
21519
+ import fs70 from "node:fs";
21520
+ import path71 from "node:path";
21550
21521
  function creationError(error, triage) {
21551
21522
  const zh = readLanguage() === "zh";
21552
21523
  const messages = {
@@ -21572,12 +21543,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
21572
21543
  function creationReceipt(request2, slot) {
21573
21544
  const hash2 = crypto4.createHash("sha256").update(`${request2}
21574
21545
  ${slot}`).digest("hex");
21575
- return path72.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21546
+ return path71.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
21576
21547
  }
21577
21548
  function readCreation(file, said2) {
21578
21549
  return withCreationLock(() => {
21579
21550
  try {
21580
- const held4 = JSON.parse(fs71.readFileSync(file, "utf8"));
21551
+ const held4 = JSON.parse(fs70.readFileSync(file, "utf8"));
21581
21552
  if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
21582
21553
  return held4;
21583
21554
  } catch (error) {
@@ -21589,10 +21560,10 @@ function readCreation(file, said2) {
21589
21560
  });
21590
21561
  }
21591
21562
  function saveCreation(file, journal) {
21592
- fs71.mkdirSync(path72.dirname(file), { recursive: true });
21563
+ fs70.mkdirSync(path71.dirname(file), { recursive: true });
21593
21564
  const temp = `${file}.${crypto4.randomUUID()}.tmp`;
21594
- fs71.writeFileSync(temp, JSON.stringify(journal));
21595
- fs71.renameSync(temp, file);
21565
+ fs70.writeFileSync(temp, JSON.stringify(journal));
21566
+ fs70.renameSync(temp, file);
21596
21567
  }
21597
21568
  function archiveCreation(source, id) {
21598
21569
  if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
@@ -21606,7 +21577,7 @@ function archiveCreation(source, id) {
21606
21577
  function triageFile(sourceId) {
21607
21578
  const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
21608
21579
  if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
21609
- return path72.basename(found2.relPath, ".md");
21580
+ return path71.basename(found2.relPath, ".md");
21610
21581
  }
21611
21582
  var init_creation = __esm({
21612
21583
  "../cli/src/lib/agent/creation.ts"() {
@@ -21774,8 +21745,8 @@ __export(board_exports, {
21774
21745
  buildBoardProgram: () => buildBoardProgram
21775
21746
  });
21776
21747
  import crypto5 from "node:crypto";
21777
- import fs72 from "node:fs";
21778
- import path73 from "node:path";
21748
+ import fs71 from "node:fs";
21749
+ import path72 from "node:path";
21779
21750
  async function dispatch(move, cmd, args, opts, cli) {
21780
21751
  const ctx = ctxOf(cmd, cli.program);
21781
21752
  const data = await runAction(ctx, {}, async () => {
@@ -21815,7 +21786,7 @@ async function cloudCard(task, opts) {
21815
21786
  let request2;
21816
21787
  if (typeof opts.bodyFile === "string") {
21817
21788
  try {
21818
- request2 = fs72.readFileSync(opts.bodyFile, "utf8");
21789
+ request2 = fs71.readFileSync(opts.bodyFile, "utf8");
21819
21790
  } catch {
21820
21791
  }
21821
21792
  }
@@ -21845,7 +21816,7 @@ async function cloudCard(task, opts) {
21845
21816
  const file = creationReceipt(`${checked.value}:${requestId}`, slot);
21846
21817
  const journal = readCreation(file, said2);
21847
21818
  if (!journal.made) {
21848
- const key = `akb-${path73.basename(file, ".json").slice(0, 40)}`;
21819
+ const key = `akb-${path72.basename(file, ".json").slice(0, 40)}`;
21849
21820
  const made = await createProjectTask(checked.value, journal.said, key);
21850
21821
  if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
21851
21822
  journal.made = made.value;
@@ -21895,11 +21866,6 @@ function buildBoardProgram(cli) {
21895
21866
  move("validate").argument("[id]", ID, cardId).summary("validate card format and report file, line, and repair instructions").description("Check one card, or every open card when no id is given. Reads only; exits non-zero with detailed errors until the format is valid.").action(async function(id) {
21896
21867
  await dispatch("validate", this, id === void 0 ? [] : [String(id)], this.opts(), cli);
21897
21868
  });
21898
- move("rule").argument("<agent>", "the agent the rule is for \u2014 a role the board ships, or one of its specialists").summary("set one agent's rule, in the user's own words").description(
21899
- "The rule is appended to the end of every run that agent does, after everything else the board writes \u2014 so a rule on `builder` reaches `card implement` alike. It replaces whatever that agent carried; an empty rule clears it. The words are the user's: write one only when they ask you to."
21900
- ).option("--file <path>", "the rule, as markdown written to a file first").option("--text <text>", "the rule, for a one-liner; empty clears it").action(async function(agent) {
21901
- await dispatch("rule", this, [agent], this.opts(), cli);
21902
- });
21903
21869
  move("agent-file").argument("<agent>", "the agent whose folder the file is in").argument("<path>", "the file, as the run's own list spells it").summary("print one file from an agent's own folder").description(
21904
21870
  "Every run is told which files its agent's folder holds, and reads one when the work calls for it. `AGENT.md` prints the agent's own rules. A built-in agent ships its files inside the command, so this is the only way to open one; a path the agent does not offer is refused."
21905
21871
  ).action(async function(agent, file) {
@@ -21978,17 +21944,17 @@ var init_board2 = __esm({
21978
21944
  });
21979
21945
 
21980
21946
  // ../cli/src/lib/board-cli.ts
21981
- import fs73 from "node:fs";
21982
- import path74 from "node:path";
21947
+ import fs72 from "node:fs";
21948
+ import path73 from "node:path";
21983
21949
  function useBoard(found2, dirNamed) {
21984
- if (!found2.named && found2.board === path74.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21950
+ if (!found2.named && found2.board === path73.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
21985
21951
  else setBoardDir(found2.board, found2.root);
21986
21952
  useProjectState();
21987
21953
  backfillCardWorkflows();
21988
21954
  }
21989
21955
  function whole(found2, move) {
21990
21956
  if (move === MAKES_A_BOARD) return found2;
21991
- if (!fs73.existsSync(path74.join(found2.board, "todo"))) {
21957
+ if (!fs72.existsSync(path73.join(found2.board, "todo"))) {
21992
21958
  die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
21993
21959
  kind: "board-incomplete",
21994
21960
  dir: found2.root
@@ -21997,13 +21963,13 @@ function whole(found2, move) {
21997
21963
  return found2;
21998
21964
  }
21999
21965
  function findBoardUpward(from, move) {
22000
- let dir = path74.resolve(from);
21966
+ let dir = path73.resolve(from);
22001
21967
  for (; ; ) {
22002
- if (hasBoard(dir)) return { root: dir, board: path74.join(dir, "docs", "kanban") };
21968
+ if (hasBoard(dir)) return { root: dir, board: path73.join(dir, "docs", "kanban") };
22003
21969
  if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
22004
- const kept2 = path74.join(dir, ".akb", "kanban");
22005
- if (move !== MAKES_A_BOARD && fs73.existsSync(path74.join(kept2, "todo"))) return { root: dir, board: kept2 };
22006
- const up = path74.dirname(dir);
21970
+ const kept2 = path73.join(dir, ".akb", "kanban");
21971
+ if (move !== MAKES_A_BOARD && fs72.existsSync(path73.join(kept2, "todo"))) return { root: dir, board: kept2 };
21972
+ const up = path73.dirname(dir);
22007
21973
  if (up === dir) return null;
22008
21974
  dir = up;
22009
21975
  }
@@ -22011,11 +21977,11 @@ function findBoardUpward(from, move) {
22011
21977
  function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
22012
21978
  const named2 = board2 ?? boardFromEnv();
22013
21979
  if (named2) {
22014
- const folder = path74.resolve(cwd, named2);
22015
- if (!fs73.existsSync(folder) && move !== MAKES_A_BOARD) {
21980
+ const folder = path73.resolve(cwd, named2);
21981
+ if (!fs72.existsSync(folder) && move !== MAKES_A_BOARD) {
22016
21982
  die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
22017
21983
  }
22018
- if (fs73.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
21984
+ if (fs72.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
22019
21985
  die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
22020
21986
  kind: "no-board",
22021
21987
  dir: folder
@@ -22024,24 +21990,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
22024
21990
  return { root: projectRootOf(folder), board: folder, named: true };
22025
21991
  }
22026
21992
  if (dir !== null) {
22027
- const root2 = path74.resolve(dir);
22028
- if (!fs73.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
22029
- const kept2 = path74.join(root2, ".akb", "kanban");
22030
- if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs73.existsSync(path74.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
21993
+ const root2 = path73.resolve(dir);
21994
+ if (!fs72.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
21995
+ const kept2 = path73.join(root2, ".akb", "kanban");
21996
+ if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs72.existsSync(path73.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
22031
21997
  if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
22032
21998
  die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
22033
21999
  kind: "no-board",
22034
22000
  dir: root2
22035
22001
  });
22036
22002
  }
22037
- return whole({ root: root2, board: path74.join(root2, "docs", "kanban") }, move);
22003
+ return whole({ root: root2, board: path73.join(root2, "docs", "kanban") }, move);
22038
22004
  }
22039
22005
  const found2 = findBoardUpward(cwd, move);
22040
22006
  if (found2) return whole(found2, move);
22041
- if (move === MAKES_A_BOARD) return { root: path74.resolve(cwd), board: path74.join(path74.resolve(cwd), "docs", "kanban") };
22007
+ if (move === MAKES_A_BOARD) return { root: path73.resolve(cwd), board: path73.join(path73.resolve(cwd), "docs", "kanban") };
22042
22008
  die(
22043
- `no board here. Looked in ${path74.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
22044
- { kind: "no-board", dir: path74.resolve(cwd) }
22009
+ `no board here. Looked in ${path73.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
22010
+ { kind: "no-board", dir: path73.resolve(cwd) }
22045
22011
  );
22046
22012
  }
22047
22013
  function editDistance(a, b) {
@@ -22124,8 +22090,8 @@ var init_board_cli = __esm({
22124
22090
  init_pointer();
22125
22091
  init_card_workflow_backfill();
22126
22092
  MAKES_A_BOARD = "init";
22127
- hasBoard = (dir) => fs73.existsSync(path74.join(dir, "docs", "kanban"));
22128
- isBoardDir = (dir) => fs73.existsSync(path74.join(dir, "todo")) && fs73.existsSync(path74.join(dir, "config.md"));
22093
+ hasBoard = (dir) => fs72.existsSync(path73.join(dir, "docs", "kanban"));
22094
+ isBoardDir = (dir) => fs72.existsSync(path73.join(dir, "todo")) && fs72.existsSync(path73.join(dir, "config.md"));
22129
22095
  boardFromEnv = () => {
22130
22096
  const named2 = process.env.AI4KANBAN_BOARD?.trim();
22131
22097
  return named2 ? named2 : null;
@@ -22361,8 +22327,8 @@ var init_agent = __esm({
22361
22327
 
22362
22328
  // ../cli/src/commands/cloud-template.ts
22363
22329
  import { createHash as createHash5 } from "node:crypto";
22364
- import fs74 from "node:fs";
22365
- import path75 from "node:path";
22330
+ import fs73 from "node:fs";
22331
+ import path74 from "node:path";
22366
22332
  function usage2(problem, line) {
22367
22333
  die(`${problem}
22368
22334
  usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
@@ -22439,10 +22405,10 @@ This template has no preview.`);
22439
22405
  const written = [];
22440
22406
  for (const p of previews) {
22441
22407
  const bytes2 = Buffer.from(await (await ask(`/${at}/previews/${route(p.path)}`, {}, WITHOUT)).arrayBuffer());
22442
- const file = path75.basename(p.path);
22443
- const out = path75.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
22444
- fs74.mkdirSync(opts.to, { recursive: true });
22445
- fs74.writeFileSync(out, bytes2);
22408
+ const file = path74.basename(p.path);
22409
+ const out = path74.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
22410
+ fs73.mkdirSync(opts.to, { recursive: true });
22411
+ fs73.writeFileSync(out, bytes2);
22446
22412
  written.push(out);
22447
22413
  say(out);
22448
22414
  }
@@ -22455,15 +22421,15 @@ async function templateGet(name, opts, program2) {
22455
22421
  const { template } = await asJson(await ask(`/${at}`, {}, WITHOUT));
22456
22422
  const fetched = [];
22457
22423
  for (const f of template.files) {
22458
- const out = path75.resolve(to, f.path);
22459
- if (!out.startsWith(path75.resolve(to) + path75.sep)) refuse3(T.corrupt, WITHOUT);
22424
+ const out = path74.resolve(to, f.path);
22425
+ if (!out.startsWith(path74.resolve(to) + path74.sep)) refuse3(T.corrupt, WITHOUT);
22460
22426
  const bytes2 = Buffer.from(await (await ask(`/${at}/files/${route(f.path)}`, {}, WITHOUT)).arrayBuffer());
22461
22427
  if (bytes2.byteLength !== f.size || createHash5("sha256").update(bytes2).digest("hex") !== f.sha256) {
22462
22428
  refuse3(T.corrupt, WITHOUT);
22463
22429
  }
22464
22430
  fetched.push({ out, bytes: bytes2 });
22465
22431
  }
22466
- const taken = fetched.filter((f) => fs74.existsSync(f.out)).map((f) => path75.relative(to, f.out));
22432
+ const taken = fetched.filter((f) => fs73.existsSync(f.out)).map((f) => path74.relative(to, f.out));
22467
22433
  if (taken.length > 0) {
22468
22434
  refuse3({
22469
22435
  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`,
@@ -22471,8 +22437,8 @@ async function templateGet(name, opts, program2) {
22471
22437
  });
22472
22438
  }
22473
22439
  for (const f of fetched) {
22474
- fs74.mkdirSync(path75.dirname(f.out), { recursive: true });
22475
- fs74.writeFileSync(f.out, f.bytes);
22440
+ fs73.mkdirSync(path74.dirname(f.out), { recursive: true });
22441
+ fs73.writeFileSync(f.out, f.bytes);
22476
22442
  }
22477
22443
  say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
22478
22444
  Fetched ${name}: ${fetched.length} files into ${to}`);
@@ -22489,25 +22455,25 @@ async function templateSource(name, opts) {
22489
22455
  say(`evidence: ${e.path}`);
22490
22456
  continue;
22491
22457
  }
22492
- const out = path75.join(opts.to, `${name}-${path75.basename(e.path)}`);
22493
- fs74.mkdirSync(opts.to, { recursive: true });
22494
- fs74.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
22458
+ const out = path74.join(opts.to, `${name}-${path74.basename(e.path)}`);
22459
+ fs73.mkdirSync(opts.to, { recursive: true });
22460
+ fs73.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
22495
22461
  written.push(out);
22496
22462
  say(out);
22497
22463
  }
22498
22464
  return { name, source, evidence: written.length > 0 ? written : evidence.map((e) => e.path) };
22499
22465
  }
22500
22466
  async function templatePublish(dir, opts) {
22501
- const root2 = path75.resolve(dir);
22502
- const manifest = path75.join(root2, "template.md");
22503
- if (!fs74.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
22504
- const meta = readTemplateMeta(fs74.readFileSync(manifest, "utf8"));
22467
+ const root2 = path74.resolve(dir);
22468
+ const manifest = path74.join(root2, "template.md");
22469
+ if (!fs73.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
22470
+ const meta = readTemplateMeta(fs73.readFileSync(manifest, "utf8"));
22505
22471
  const files = walk2(root2);
22506
- const total = files.reduce((sum, f) => sum + fs74.statSync(path75.join(root2, f)).size, 0);
22472
+ const total = files.reduce((sum, f) => sum + fs73.statSync(path74.join(root2, f)).size, 0);
22507
22473
  if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
22508
22474
  for (const extra of [...opts.preview, ...opts.evidence]) {
22509
- if (!fs74.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
22510
- if (path75.resolve(extra).startsWith(root2 + path75.sep)) {
22475
+ if (!fs73.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
22476
+ if (path74.resolve(extra).startsWith(root2 + path74.sep)) {
22511
22477
  invalid(
22512
22478
  `${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`,
22513
22479
  `${extra} is inside the template folder; keep previews and evidence outside it.`
@@ -22519,10 +22485,10 @@ async function templatePublish(dir, opts) {
22519
22485
  }
22520
22486
  const form = new FormData();
22521
22487
  form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
22522
- const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs74.readFileSync(file)]), path75.basename(name));
22523
- for (const f of files) add("files", f, path75.join(root2, f));
22524
- for (const f of opts.preview) add("previews", path75.basename(f), f);
22525
- for (const f of opts.evidence) add("evidence", path75.basename(f), f);
22488
+ const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs73.readFileSync(file)]), path74.basename(name));
22489
+ for (const f of files) add("files", f, path74.join(root2, f));
22490
+ for (const f of opts.preview) add("previews", path74.basename(f), f);
22491
+ for (const f of opts.evidence) add("evidence", path74.basename(f), f);
22526
22492
  const done2 = await asJson(await ask("", { method: "POST", body: form }));
22527
22493
  say(
22528
22494
  done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
@@ -22538,11 +22504,11 @@ Deleted ${name} from the catalog.`);
22538
22504
  return { name, deleted: true };
22539
22505
  }
22540
22506
  async function templateShowcase(name, dir) {
22541
- const file = path75.join(dir, "showcase.json");
22542
- if (!fs74.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
22507
+ const file = path74.join(dir, "showcase.json");
22508
+ if (!fs73.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
22543
22509
  let meta;
22544
22510
  try {
22545
- meta = JSON.parse(fs74.readFileSync(file, "utf8"));
22511
+ meta = JSON.parse(fs73.readFileSync(file, "utf8"));
22546
22512
  } catch {
22547
22513
  return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
22548
22514
  }
@@ -22554,9 +22520,9 @@ async function templateShowcase(name, dir) {
22554
22520
  const form = new FormData();
22555
22521
  form.set("meta", JSON.stringify(meta));
22556
22522
  for (const p of new Set(named2)) {
22557
- const at = path75.join(dir, p);
22558
- if (!fs74.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
22559
- form.append(`media:${p}`, new Blob([fs74.readFileSync(at)]), p);
22523
+ const at = path74.join(dir, p);
22524
+ if (!fs73.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
22525
+ form.append(`media:${p}`, new Blob([fs73.readFileSync(at)]), p);
22560
22526
  }
22561
22527
  const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
22562
22528
  say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
@@ -22565,7 +22531,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
22565
22531
  }
22566
22532
  function walk2(root2, sub = "") {
22567
22533
  const out = [];
22568
- for (const entry of fs74.readdirSync(path75.join(root2, sub), { withFileTypes: true })) {
22534
+ for (const entry of fs73.readdirSync(path74.join(root2, sub), { withFileTypes: true })) {
22569
22535
  if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
22570
22536
  const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
22571
22537
  if (entry.isDirectory()) out.push(...walk2(root2, rel2));
@@ -22750,7 +22716,7 @@ var init_archive2 = __esm({
22750
22716
  var board_default;
22751
22717
  var init_board3 = __esm({
22752
22718
  "../cli/src/guide/board.md"() {
22753
- board_default = "# How this board works\n\nThese rules apply to every card workflow. Read them once; each workflow's guide covers\nthe remaining details.\n\n## Layout\n\n```\ndocs/kanban/\n\u251C\u2500\u2500 todo/ open tasks\n\u2502 \u251C\u2500\u2500 README.md the index \u2014 read it first\n\u2502 \u2514\u2500\u2500 <id>-<slug>.md\n\u2502 one card per file; a group keeps its cards in one folder\n\u251C\u2500\u2500 memory/ all memory \u2014 see \"Who owns a memory file\"\n\u2502 \u251C\u2500\u2500 readme.md what shipped \u2014 the board's own record\n\u2502 \u251C\u2500\u2500 project.md what the project is today \u2014 written only by `akb raw describe-project`\n\u2502 \u251C\u2500\u2500 <name>/ a global memory: `MEMORY.md` (its rules, unless built in), `README.md`\n\u2502 \u2502 (its index) and its entries\n\u2502 \u2514\u2500\u2500 agents/ one folder per agent that keeps memory, named after it \u2014\n\u2502 `planner/` holds `decisions.md`, `rejected.md`, `redesign.md`\n\u251C\u2500\u2500 rules/ `<agent>.md` \u2014 the user's rule for one agent, appended to every run it\n\u2502 does; written from the board UI or `akb raw rule`\n\u251C\u2500\u2500 triage/ items waiting to be sorted, one file each \u2014 not cards. Only\n\u2502 \u2502 Cloud's sort or Refine idea on the web's Triage page turns one\n\u2502 \u2502 into a card; `akb raw triage check <source-id>` finds an existing one\n\u2502 \u251C\u2500\u2500 archived/ items a card was made of\n\u2502 \u251C\u2500\u2500 dismissed/ items ignored, with the reason\n\u2502 \u2514\u2500\u2500 files/ dropped-in files\n\u2514\u2500\u2500 modules.md one line per module \u2014 `akb guide module-map` writes it\n```\n\n## Task ID\n\nEvery task's id is the number at the front of its filename (`04-plan-cap-enforcement.md` \u2192\nid 4): its Cloud task's number (`WC-4`). Only Cloud assigns one; `akb raw create` takes it.\n\n## Never hand-write a card's frontmatter\n\n`akb raw create`, `update`, and `update-questions` manage all of a card's frontmatter,\nincluding its `previews`. Edit only the card's **body** by hand. `akb raw help`\nlists all operations; `akb raw help <move>` explains one operation.\n\n## Inside a board run\n\nA board run carries `KANBAN_RUN` in its environment. Never unset or bypass it (for example\n`env -u KANBAN_RUN`): when a command only prints a flow, follow the printed flow.\n\n## Group task\n\nA group lives in `todo/<id>-<slug>/`: `root.md` tracks the whole job and each subtask is its\nown card beside it; `akb guide add-task` says how to build one. The root's `## Todo` lists the\nsubtasks, one line each ending in `#<subid>`: archiving a subtask ticks its line, rejecting\none strikes it through, and resolving the last line archives the root in the same run, with\nany open question or unticked todo of its own. A board a Runner keeps leaves that close to\nCloud, which waits for the root to be queued with no step on it. A root listing no subtasks is\nonly closed by hand.\n\n## Who owns a memory file\n\n**A memory file belongs to whoever reads and writes it.**\n\n- **`memory/readme.md`**: the board's record of shipped user-facing work.\n- **`memory/project.md`**: what the project is today, from its users' side, and the\n direction every judgement serves. Only `akb raw describe-project` writes it.\n- **`memory/agents/planner/`**: `decisions.md` holds user-facing answers that guide future\n planning and `redesign.md` design mistakes to avoid, both written by the memory review (`akb\n guide review-memory`); `rejected.md` holds what the user turned down and why, written only\n by the rejection and dismissal review (`akb guide review-rejections`). Other flows only read\n them, `akb raw memory prune` aside.\n- **`memory/<name>/`**: a global memory, kept by every agent listing it under `akb.memory`\n by the rules each run is given. Only the user changes its `MEMORY.md`, from the board UI.\n- **`memory/agents/<agent>/`**: an agent keeps only the files and split paths its own AGENT.md\n declares, plus the `redesign.md` the memory review writes there. An agent whose instructions\n name none keeps none.\n\nFile a planning note about one module in that module's folder,\n`memory/agents/planner/<module>/`, under the same file name, creating it if missing. A note\nspanning modules, or from a card with none, stays in `memory/agents/planner/`.\n\n### What earns a note\n\nOnly what changes a future planning choice. Writing nothing is a complete outcome.\n\n- **Honor an opt-out**: told not to record, write no memory and finish the requested action.\n- **A conversation writes none**: a card chat, a discussion, a feedback conversation, and\n any flow started in it write no memory and say nothing about it.\n- **Require lasting value**: a durable preference, constraint, decision, or lesson.\n- **Skip housekeeping**: duplicates, routine status changes, and facts recorded elsewhere.\n A rejected duplicate is not a rejected feature.\n- **Merge, don't repeat**: rewrite an equivalent entry in place.\n\n`readme.md` is not planning memory.\n";
22719
+ board_default = "# How this board works\n\nThese rules apply to every card workflow. Read them once; each workflow's guide covers\nthe remaining details.\n\n## Layout\n\n```\ndocs/kanban/\n\u251C\u2500\u2500 todo/ open tasks\n\u2502 \u251C\u2500\u2500 README.md the index \u2014 read it first\n\u2502 \u2514\u2500\u2500 <id>-<slug>.md\n\u2502 one card per file; a group keeps its cards in one folder\n\u251C\u2500\u2500 memory/ all memory \u2014 see \"Who owns a memory file\"\n\u2502 \u251C\u2500\u2500 readme.md what shipped \u2014 the board's own record\n\u2502 \u251C\u2500\u2500 project.md what the project is today \u2014 written only by `akb raw describe-project`\n\u2502 \u251C\u2500\u2500 <name>/ a global memory: `MEMORY.md` (its rules, unless built in), `README.md`\n\u2502 \u2502 (its index) and its entries\n\u2502 \u2514\u2500\u2500 agents/ one folder per agent that keeps memory, named after it \u2014\n\u2502 `planner/` holds `decisions.md`, `rejected.md`, `redesign.md`\n\u251C\u2500\u2500 rules/ `<agent>.md` \u2014 the user's rule for one agent, appended to every run it\n\u2502 does; written from the web or `akb workflow instructions`\n\u251C\u2500\u2500 triage/ items waiting to be sorted, one file each \u2014 not cards. Only\n\u2502 \u2502 Cloud's sort or Refine idea on the web's Triage page turns one\n\u2502 \u2502 into a card; `akb raw triage check <source-id>` finds an existing one\n\u2502 \u251C\u2500\u2500 archived/ items a card was made of\n\u2502 \u251C\u2500\u2500 dismissed/ items ignored, with the reason\n\u2502 \u2514\u2500\u2500 files/ dropped-in files\n\u2514\u2500\u2500 modules.md one line per module \u2014 `akb guide module-map` writes it\n```\n\n## Task ID\n\nEvery task's id is the number at the front of its filename (`04-plan-cap-enforcement.md` \u2192\nid 4): its Cloud task's number (`WC-4`). Only Cloud assigns one; `akb raw create` takes it.\n\n## Never hand-write a card's frontmatter\n\n`akb raw create`, `update`, and `update-questions` manage all of a card's frontmatter,\nincluding its `previews`. Edit only the card's **body** by hand. `akb raw help`\nlists all operations; `akb raw help <move>` explains one operation.\n\n## Inside a board run\n\nA board run carries `KANBAN_RUN` in its environment. Never unset or bypass it (for example\n`env -u KANBAN_RUN`): when a command only prints a flow, follow the printed flow.\n\n## Group task\n\nA group lives in `todo/<id>-<slug>/`: `root.md` tracks the whole job and each subtask is its\nown card beside it; `akb guide add-task` says how to build one. The root's `## Todo` lists the\nsubtasks, one line each ending in `#<subid>`: archiving a subtask ticks its line, rejecting\none strikes it through, and resolving the last line archives the root in the same run, with\nany open question or unticked todo of its own. A board a Runner keeps leaves that close to\nCloud, which waits for the root to be queued with no step on it. A root listing no subtasks is\nonly closed by hand.\n\n## Who owns a memory file\n\n**A memory file belongs to whoever reads and writes it.**\n\n- **`memory/readme.md`**: the board's record of shipped user-facing work.\n- **`memory/project.md`**: what the project is today, from its users' side, and the\n direction every judgement serves. Only `akb raw describe-project` writes it.\n- **`memory/agents/planner/`**: `decisions.md` holds user-facing answers that guide future\n planning and `redesign.md` design mistakes to avoid, both written by the memory review (`akb\n guide review-memory`); `rejected.md` holds what the user turned down and why, written only\n by the rejection and dismissal review (`akb guide review-rejections`). Other flows only read\n them, `akb raw memory prune` aside.\n- **`memory/<name>/`**: a global memory, kept by every agent listing it under `akb.memory`\n by the rules each run is given. Only the user changes its `MEMORY.md`, from the board UI.\n- **`memory/agents/<agent>/`**: an agent keeps only the files and split paths its own AGENT.md\n declares, plus the `redesign.md` the memory review writes there. An agent whose instructions\n name none keeps none.\n\nFile a planning note about one module in that module's folder,\n`memory/agents/planner/<module>/`, under the same file name, creating it if missing. A note\nspanning modules, or from a card with none, stays in `memory/agents/planner/`.\n\n### What earns a note\n\nOnly what changes a future planning choice. Writing nothing is a complete outcome.\n\n- **Honor an opt-out**: told not to record, write no memory and finish the requested action.\n- **A conversation writes none**: a card chat, a discussion, a feedback conversation, and\n any flow started in it write no memory and say nothing about it.\n- **Require lasting value**: a durable preference, constraint, decision, or lesson.\n- **Skip housekeeping**: duplicates, routine status changes, and facts recorded elsewhere.\n A rejected duplicate is not a rejected feature.\n- **Merge, don't repeat**: rewrite an equivalent entry in place.\n\n`readme.md` is not planning memory.\n";
22754
22720
  }
22755
22721
  });
22756
22722
 
@@ -22766,7 +22732,7 @@ var init_card_chat = __esm({
22766
22732
  var update_workflow_default;
22767
22733
  var init_update_workflow = __esm({
22768
22734
  "../cli/src/guide/update-workflow.md"() {
22769
- update_workflow_default = "# Update a workflow\n\nChange one of this workspace's workflows so new tasks run the new version.\n\n## How a workflow works\n\nA workflow is steerable: agents do the work, and a person reviews and fine-tunes only the parts where precision matters most, so the result stays reliable.\n\n- **Previews**: give a part its own preview agent only when it needs precision and a mistake there is costly, such as a developer tool's screens, whose experience drives retention. Each shows only what the person decides on, without overlapping another.\n- **Stages**: previews are approved together in one stage by default. Add `after` only when a draft is too costly to make before another is approved, such as a video's storyboard, which waits for its script.\n- **Land**: everything else runs unattended after the last approval and follows the approved drafts, such as building and merging a change; leave `land` empty when the last approved preview is the deliverable.\n- **Scheduled**: repeating work runs as a scheduled agent without previews; a workflow may hold only scheduled agents.\n- **`WORKFLOW.md`**: list its agents under `previews`, `land` and `scheduled`; `description` says in one sentence what it does; `when` tells an agent which requests it is for, exceptions included; the body is how a card of this kind is written.\n- **Agents**: write each as `akb guide write-agent` says.\n\n## Versions\n\n- **Pinned**: a workflow and the agents it holds live in Cloud as numbered versions; a task\n keeps the version it started with, and only tasks started after a push take the new one.\n- **Project agents**: agents under the board's `agents/` folder are the project's own; a\n workflow may name them, but they are not part of its versions and an edit there applies to\n every card at once.\n- **Own workflows only**: built-in and marketplace workflows are read-only; ask the user to copy\n one on the web first.\n\n## Change it\n\n- **Direct or task**: push directly a change the user spelled out; start a Workflow builder task\n instead when the change adds, removes or restages agents, or when the user wants to see it\n work before it applies.\n- **Steps**: `akb workflow pull <id> <folder>`, edit the files there and keep what the request\n leaves alone, fix every problem `akb workflow list` reports, then `akb workflow push <folder>`.\n- **Moved on**: when push says Cloud has a newer version, pull again and redo the change.\n";
22735
+ update_workflow_default = "# Update a workflow\n\nChange one of this workspace's workflows so new tasks run the new version.\n\n## How a workflow works\n\nA workflow is steerable: agents do the work, and a person reviews and fine-tunes only the parts where precision matters most, so the result stays reliable.\n\n- **Previews**: usually one preview agent shows the first draft; add another only when a part needs precision and a mistake there is costly, such as a developer tool's screens. Each shows only what the person decides on, without overlapping another. With none, the card the `WORKFLOW.md` body writes is the only review.\n- **Unreviewable previews**: when the user finds a preview unneeded or cannot judge it, remove it; a land agent checks that part instead, or nobody does.\n- **Stages**: one stage by default. Add `after` only when a draft is too costly to make before another is approved, such as a video's storyboard, which waits for its script.\n- **Minimal**: when the user outlines the workflow, keep it that simple or simpler; add no review point or constraint they did not ask for, and let the trial show what else needs review.\n- **Land**: everything else runs unattended after the last approval and follows the approved drafts, such as building and merging a change; leave `land` empty when the last approved preview is the deliverable.\n- **Scheduled**: repeating work runs as a scheduled agent without previews; a workflow may hold only scheduled agents.\n- **`WORKFLOW.md`**: list its agents under `previews`, `land` and `scheduled`; `description` says in one sentence what it does; `when` tells an agent which requests it is for, exceptions included; the body is how a card of this kind is written.\n- **Agents**: write each as `akb guide write-agent` says.\n\n## Versions\n\n- **Pinned**: a workflow and the agents it holds live in Cloud as numbered versions; a task\n keeps the version it started with, and only tasks started after a push take the new one.\n- **Project agents**: agents under the board's `agents/` folder are the project's own; a\n workflow may name them, but they are not part of its versions and an edit there applies to\n every card at once.\n- **Own workflows only**: built-in and marketplace workflows are read-only; ask the user to copy\n one on the web first.\n\n## Change it\n\n- **Direct or task**: push directly a change the user spelled out; start a Workflow builder task\n instead when the change adds, removes or restages agents, or when the user wants to see it\n work before it applies.\n- **Steps**: `akb workflow pull <id> <folder>`, edit the files there and keep what the request\n leaves alone, fix every problem `akb workflow list` reports, then `akb workflow push <folder>`.\n- **Moved on**: when push says Cloud has a newer version, pull again and redo the change.\n";
22770
22736
  }
22771
22737
  });
22772
22738
 
@@ -22894,7 +22860,7 @@ var init_troubleshoot = __esm({
22894
22860
  var write_agent_default;
22895
22861
  var init_write_agent = __esm({
22896
22862
  "../cli/src/guide/write-agent.md"() {
22897
- write_agent_default = "# Write an agent\n\nAn agent is one folder: `docs/kanban/agents/<name>/AGENT.md`. The folder name is the agent's\nname and the word every flow asks for it by \u2014 lower-case words joined by `-`, matching the\n`name` in its frontmatter. It cannot be a name the board already answers to: one of the\nboard's roles, an agent the command ships, or a folder already in `docs/kanban/agents/`.\n\n## The file\n\n```yaml\n---\n# Required; matches the folder name.\nname: ux-writer\n# Required: one sentence saying what it does.\ndescription: Writes the words a screen shows.\n# Optional.\nakb:\n # Optional, for a preview agent: when to request it, exceptions included. Without it, it\n # always runs.\n when: A card changes what the product says to the user; not a typo.\n # Optional, for a preview agent: it runs only after these agents' previews are approved,\n # when the card requests them too; it never makes them run.\n after: [ui-designer]\n # Optional, for a preview agent: `new` runs it in a session of its own.\n session: new\n # Preview components this agent uses; an empty list loads no component documentation.\n components: [Asset]\n # Optional: a sticker of its deliverable, by glyph name (the Workflow builder lists them),\n # or 1 to 12 parts `{ d, f?, o?: true, s?, w? }`. Without it, a generic file is drawn.\n icon: text\n---\n\nYou write the words a screen shows.\n```\n\nIts workflow, not the agent, sets its role: `WORKFLOW.md` lists it under `previews`, `land`\nor `scheduled`.\n\nA scheduled agent can also name the new input it works on; it then runs only when there is some:\n\n```yaml\nakb:\n # archived-cards | chats | dismissals; omit to run on its cadence alone.\n reads: archived-cards\n```\n\nA land agent that merges code into the target branch declares it; completing its step then\nrequires the merged commit and branch:\n\n```yaml\nakb:\n merges: true\n```\n\nAn agent that shares material with others names the global memories it keeps:\n\n```yaml\nakb:\n # Optional; global memories under `docs/kanban/memory/<name>/`, by name.\n memory: [competitors]\n # Optional; its own memory files, or folders ending in `/`, that hold in any of the user's\n # projects. Everything else is this project's.\n memoryFiles:\n workspace: [style.md]\n```\n\nEverything under the frontmatter is the agent's instructions, read fresh on every run \u2014\na file with none is refused.\n\nAn agent declares no options of its own. Two ways of working is two agents, each with its own\n`AGENT.md` \u2014 a switch that changes how one agent works costs more than it buys.\n\n## Translations\n\n```yaml\nakb:\n # Optional; UI text only. Runs use English; omitted text falls back to English.\n i18n:\n # Language tag; every field below is optional.\n en:\n # Display name, shown as the stage name: name the output, not the role; at most\n # 3 English words or 4 Chinese characters. Does not change the agent's name.\n title: UI copy\n zh:\n title: \u754C\u9762\u6587\u6848\n description: \u64B0\u5199\u754C\u9762\u4E0A\u7684\u6587\u5B57\u3002\n when: \u5361\u7247\u65B0\u589E\u6216\u4FEE\u6539\u754C\u9762\u6587\u5B57\u65F6\u3002\n```\n\n## Files\n\nEvery file beside `AGENT.md`, in any subfolder, is named to the run by its path and opened only\nwhen the work calls for it. Put long material there and keep `AGENT.md` short.\n\n- **Scripts**: every agent owns its task scripts in its own folder, including built-in agents.\n Keep business validation there, outside the CLI's board logic. Document the runtime, inputs\n and invocation beside the script; consumers use the owner's script. Built-in files can be\n saved through `akb raw agent-file <agent> <path>` and run locally with their relative layout\n intact; custom agents use their existing folders.\n\n## Imported skills\n\nAn agent may carry several skills, each whole in its own `skills/<skill>/` folder.\n\n- **Keep the capability**: copy the skill's instructions, scripts, resources and license\n unchanged; never reduce it to rewritten instructions. Leave out installed packages and caches,\n and name any file it refers to that you could not get.\n- **Record the source**: list each in a `## Skills` section of `AGENT.md` as\n `- **<skill>**: <when to use it>. Source: <URL or pasted> @ <commit, tag or snapshot date>`.\n- **Adapt outside it**: say in `AGENT.md` when to use each skill and how its result becomes\n this agent's output; paths inside a skill resolve from its folder. Keep the skill folder\n untouched so an update can replace it whole.\n- **Runtime needs**: check every command, package and credential the skill needs on this\n machine. Name what is missing under its bullet and tell the user; never call the agent usable\n while anything is missing, and never copy a key into the folder.\n- **Update and remove**: update only when the user asks \u2014 replace the folder, show the diff and\n change the version. Remove a skill with its folder and bullet. Each agent owns its copies, so\n no change reaches another agent.\n\n## Memory\n\n`docs/kanban/memory/agents/<name>/` is read into every run. Keep none unless a user's\ncorrection should change the agent's next output. Otherwise say in `AGENT.md`:\n\n- **Files**: each file and what it holds; `## General` for what always holds, and a heading per\n situation (a format, a recipe, a channel) for what holds only there.\n- **When**: which file to apply before which step, and which answers or corrections to record.\n- **What goes in**: lasting preferences, decisions and corrections only \u2014 never raw feedback,\n run history, or what the instructions already say.\n- **Shared material**: what other agents also use goes in a global memory under `akb.memory`;\n its rules arrive with every run, so `AGENT.md` never restates them.\n\n## Output\n\nDeclare the preview components the agent uses in `akb.components` (Asset, Compare, Storyboard).\nTheir usage documentation is supplied with the run; omitted declarations default to Asset.\nUse `akb raw components --agent <name> --docs` or `--workflow <id> --docs` to read it.\n\nChoose the form the reader takes in fastest and say it in `AGENT.md`: an image for a look, a\nstoryboard for a sequence over time, readable Markdown for everything else.\n\n## Dependencies\n\n- **In `after`**: name the agents whose approved previews this one needs; it waits for those\n approvals and never requests the agents.\n- **In the instructions**: say what to do when the section it needs is missing or still\n carries an open question \u2014 normally draw nothing and write one line naming what is missing.\n A preview agent never asks for another.\n\n## Instructions\n\nSay what the agent owns, what it produces, and what it leaves alone. Don't repeat the contract\nevery run is pointed to (`akb guide preview-agent`): where the section goes, how to validate,\nhow to keep memory, and how to defer to the user. A scheduled agent says what one run does,\nnever when it runs.\n\n## Work with the user\n\n- **Ask little**: settle what the request, the skill and the board already answer; ask the rest\n as `akb guide update-questions` does, and never ask again what is answered.\n- **State between runs**: ask how a scheduled agent should keep what its next run needs, and\n write the answer into `AGENT.md`; assume no file or format.\n- **Important choices**: give a recommendation and its tradeoff, and accept a free answer.\n- **Show each edit**: when changing an existing agent, show every changed file as a unified\n diff with context, followed by one sentence of reason.\n\n## Check it\n\n- **Validate before finishing**: after creating or editing an agent, run `akb raw previews`. Read all trigger conditions with `akb raw previews --triggers`.\n Fix every problem reported for its file under \"Problems on this board\", then run it again.\n Do not finish until the agent is accepted with no problems reported for it.\n- **`akb raw previews <name> <id> --print`** on a real card prints the whole prompt the agent will get:\n its instructions, the reference for each chosen setting, its files and its memory. Read it, and cut whatever the run does not need.\n- **Workflow**: a new agent belongs to the workflow it was created in and starts switched on;\n a preview agent joins the end of that workflow's `previews`. `akb raw previews` refuses it while it is off.\n Switch it in that workflow's `WORKFLOW.md`.\n- **Schedule**: set `reads` from what the agent works on; it runs automatically by default.\n For a fixed cadence, add `cadence: 1d` to its entry in the workflow's `scheduled`.\n";
22863
+ write_agent_default = "# Write an agent\n\nAn agent is one folder: `docs/kanban/agents/<name>/AGENT.md`. The folder name is the agent's\nname and the word every flow asks for it by \u2014 lower-case words joined by `-`, matching the\n`name` in its frontmatter. It cannot be a name the board already answers to: one of the\nboard's roles, an agent the command ships, or a folder already in `docs/kanban/agents/`.\n\n## The file\n\n```yaml\n---\n# Required; matches the folder name.\nname: ux-writer\n# Required: one sentence saying what it does.\ndescription: Writes the words a screen shows.\n# Optional.\nakb:\n # Optional, for a preview agent: when to request it, exceptions included. Without it, it\n # always runs.\n when: A card changes what the product says to the user; not a typo.\n # Optional, for a preview agent: it runs only after these agents' previews are approved,\n # when the card requests them too; it never makes them run.\n after: [ui-designer]\n # Optional, for a preview agent: `new` runs it in a session of its own.\n session: new\n # Preview components this agent uses; an empty list loads no component documentation.\n components: [Asset]\n # Optional: a sticker of its deliverable, by glyph name (the Workflow builder lists them),\n # or 1 to 12 parts `{ d, f?, o?: true, s?, w? }`. Without it, a generic file is drawn.\n icon: text\n---\n\nYou write the words a screen shows.\n```\n\nIts workflow, not the agent, sets its role: `WORKFLOW.md` lists it under `previews`, `land`\nor `scheduled`.\n\nA scheduled agent can also name the new input it works on; it then runs only when there is some:\n\n```yaml\nakb:\n # archived-cards | chats | dismissals; omit to run on its cadence alone.\n reads: archived-cards\n```\n\nA land agent that merges code into the target branch declares it; completing its step then\nrequires the merged commit and branch:\n\n```yaml\nakb:\n merges: true\n```\n\nAn agent that shares material with others names the global memories it keeps:\n\n```yaml\nakb:\n # Optional; global memories under `docs/kanban/memory/<name>/`, by name.\n memory: [competitors]\n # Optional; its own memory files, or folders ending in `/`, that hold in any of the user's\n # projects. Everything else is this project's.\n memoryFiles:\n workspace: [style.md]\n```\n\nEverything under the frontmatter is the agent's instructions, read fresh on every run \u2014\na file with none is refused.\n\nAn agent declares no options of its own. Two ways of working is two agents, each with its own\n`AGENT.md` \u2014 a switch that changes how one agent works costs more than it buys.\n\n## Translations\n\n```yaml\nakb:\n # Optional; UI text only. Runs use English; omitted text falls back to English.\n i18n:\n # Language tag; every field below is optional.\n en:\n # Display name, shown as the stage name: name the output, not the role; at most\n # 3 English words or 4 Chinese characters. Does not change the agent's name.\n title: UI copy\n zh:\n title: \u754C\u9762\u6587\u6848\n description: \u64B0\u5199\u754C\u9762\u4E0A\u7684\u6587\u5B57\u3002\n when: \u5361\u7247\u65B0\u589E\u6216\u4FEE\u6539\u754C\u9762\u6587\u5B57\u65F6\u3002\n```\n\n## Files\n\nEvery file beside `AGENT.md`, in any subfolder, is named to the run by its path and opened only\nwhen the work calls for it. Put long material there and keep `AGENT.md` short.\n\n- **Scripts**: every agent owns its task scripts in its own folder, including built-in agents.\n Keep business validation there, outside the CLI's board logic. Document the runtime, inputs\n and invocation beside the script; consumers use the owner's script. Built-in files can be\n saved through `akb raw agent-file <agent> <path>` and run locally with their relative layout\n intact; custom agents use their existing folders.\n\n## Imported skills\n\nAn agent may carry several skills, each whole in its own `skills/<skill>/` folder.\n\n- **Keep the capability**: copy the skill's instructions, scripts, resources and license\n unchanged; never reduce it to rewritten instructions. Leave out installed packages and caches,\n and name any file it refers to that you could not get.\n- **Record the source**: list each in a `## Skills` section of `AGENT.md` as\n `- **<skill>**: <when to use it>. Source: <URL or pasted> @ <commit, tag or snapshot date>`.\n- **Adapt outside it**: say in `AGENT.md` when to use each skill and how its result becomes\n this agent's output; paths inside a skill resolve from its folder. Keep the skill folder\n untouched so an update can replace it whole.\n- **Runtime needs**: check every command, package and credential the skill needs on this\n machine. Name what is missing under its bullet and tell the user; never call the agent usable\n while anything is missing, and never copy a key into the folder.\n- **Update and remove**: update only when the user asks \u2014 replace the folder, show the diff and\n change the version. Remove a skill with its folder and bullet. Each agent owns its copies, so\n no change reaches another agent.\n\n## Memory\n\n`docs/kanban/memory/agents/<name>/` is read into every run. Keep none unless a user's\ncorrection should change the agent's next output. Otherwise say in `AGENT.md`:\n\n- **Files**: each file and what it holds; `## General` for what always holds, and a heading per\n situation (a format, a recipe, a channel) for what holds only there.\n- **When**: which file to apply before which step, and which answers or corrections to record.\n- **What goes in**: lasting preferences, decisions and corrections only \u2014 never raw feedback,\n run history, or what the instructions already say.\n- **Shared material**: what other agents also use goes in a global memory under `akb.memory`;\n its rules arrive with every run, so `AGENT.md` never restates them.\n\n## Output\n\nDeclare the preview components the agent uses in `akb.components` (Asset, Compare, Storyboard, Set).\nTheir usage documentation is supplied with the run; omitted declarations default to Asset.\nUse `akb raw components --agent <name> --docs` or `--workflow <id> --docs` to read it.\n\nChoose the form the reader takes in fastest and say it in `AGENT.md`: an image for a look, a\nstoryboard for a sequence over time, readable Markdown for everything else.\n\n## Dependencies\n\n- **In `after`**: name the agents whose approved previews this one needs; it waits for those\n approvals and never requests the agents.\n- **In the instructions**: say what to do when the section it needs is missing or still\n carries an open question \u2014 normally draw nothing and write one line naming what is missing.\n A preview agent never asks for another.\n\n## Instructions\n\nSay what the agent owns, what it produces, and what it leaves alone. Don't repeat the contract\nevery run is pointed to (`akb guide preview-agent`): where the section goes, how to validate,\nhow to keep memory, and how to defer to the user. A scheduled agent says what one run does,\nnever when it runs.\n\n## Work with the user\n\n- **Ask little**: settle what the request, the skill and the board already answer; ask the rest\n as `akb guide update-questions` does, and never ask again what is answered.\n- **State between runs**: ask how a scheduled agent should keep what its next run needs, and\n write the answer into `AGENT.md`; assume no file or format.\n- **Important choices**: give a recommendation and its tradeoff, and accept a free answer.\n- **Show each edit**: when changing an existing agent, show every changed file as a unified\n diff with context, followed by one sentence of reason.\n\n## Check it\n\n- **Validate before finishing**: after creating or editing an agent, run `akb raw previews`. Read all trigger conditions with `akb raw previews --triggers`.\n Fix every problem reported for its file under \"Problems on this board\", then run it again.\n Do not finish until the agent is accepted with no problems reported for it.\n- **`akb raw previews <name> <id> --print`** on a real card prints the whole prompt the agent will get:\n its instructions, the reference for each chosen setting, its files and its memory. Read it, and cut whatever the run does not need.\n- **Workflow**: a new agent belongs to the workflow it was created in and starts switched on;\n a preview agent joins the end of that workflow's `previews`. `akb raw previews` refuses it while it is off.\n Switch it in that workflow's `WORKFLOW.md`.\n- **Schedule**: set `reads` from what the agent works on; it runs automatically by default.\n For a fixed cadence, add `cadence: 1d` to its entry in the workflow's `scheduled`.\n";
22898
22864
  }
22899
22865
  });
22900
22866
 
@@ -23017,8 +22983,8 @@ var init_guide2 = __esm({
23017
22983
  });
23018
22984
 
23019
22985
  // ../cli/src/commands/workflow.ts
23020
- import fs75 from "node:fs";
23021
- import path76 from "node:path";
22986
+ import fs74 from "node:fs";
22987
+ import path75 from "node:path";
23022
22988
  function cmdWorkflowList() {
23023
22989
  if (!workflowsReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
23024
22990
  const offline2 = workflowsOffline();
@@ -23059,9 +23025,9 @@ function cmdWorkflowDiagram(id, card) {
23059
23025
  const agent = findSpecAgent(name);
23060
23026
  return agent ? { ...agent, after: agentAfter(name) } : null;
23061
23027
  });
23062
- const file = path76.join(ASSETS, String(cardId2), "workflow.json");
23063
- fs75.mkdirSync(path76.dirname(file), { recursive: true });
23064
- fs75.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
23028
+ const file = path75.join(ASSETS, String(cardId2), "workflow.json");
23029
+ fs74.mkdirSync(path75.dirname(file), { recursive: true });
23030
+ fs74.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
23065
23031
  `);
23066
23032
  const tag = `<Workflow src=".assets/${cardId2}/workflow.json" label="${flow.name.replace(/"/g, "")}" />`;
23067
23033
  say(tag);
@@ -23070,26 +23036,26 @@ function cmdWorkflowDiagram(id, card) {
23070
23036
  async function cmdWorkflowPull(id, folder) {
23071
23037
  const cloudId = cloudIdOf(id);
23072
23038
  if (!cloudId) found(id);
23073
- const dir = path76.resolve(folder ?? id);
23074
- if (fs75.existsSync(dir) && fs75.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
23039
+ const dir = path75.resolve(folder ?? id);
23040
+ if (fs74.existsSync(dir) && fs74.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
23075
23041
  const read3 = await call("GET", `/v1/workflows/${encodeURIComponent(cloudId)}`);
23076
23042
  if (!read3.ok) die(read3.error, read3.code === "not_found" ? "no-such-workflow" : "cloud-refused");
23077
23043
  const { version, files } = read3.value;
23078
23044
  for (const [file, text4] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version) })) {
23079
- const full = path76.join(dir, ...file.split("/"));
23080
- fs75.mkdirSync(path76.dirname(full), { recursive: true });
23045
+ const full = path75.join(dir, ...file.split("/"));
23046
+ fs74.mkdirSync(path75.dirname(full), { recursive: true });
23081
23047
  const data = isAboutFile(file) && !file.endsWith(".md") && /^data:[^;]+;base64,/.exec(text4);
23082
- fs75.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
23048
+ fs74.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
23083
23049
  }
23084
23050
  const shown = folder ?? `./${id}`;
23085
23051
  say(`Pulled ${id} v${version} into ${shown}.`);
23086
23052
  return { id, version, folder: dir };
23087
23053
  }
23088
23054
  async function cmdWorkflowPush(folder, opts) {
23089
- const dir = path76.resolve(folder);
23055
+ const dir = path75.resolve(folder);
23090
23056
  let pulled = null;
23091
23057
  try {
23092
- pulled = JSON.parse(fs75.readFileSync(path76.join(dir, VERSION_FILE), "utf8"));
23058
+ pulled = JSON.parse(fs74.readFileSync(path75.join(dir, VERSION_FILE), "utf8"));
23093
23059
  } catch {
23094
23060
  }
23095
23061
  if (!pulled?.id || !Number.isInteger(pulled.version)) die(`${folder} was not written by \`akb workflow pull\``, "bad-args");
@@ -23117,11 +23083,69 @@ async function cmdWorkflowPush(folder, opts) {
23117
23083
  die(res.error, res.code === "bad_request" || res.code === "payload_too_large" ? "bad-workflow" : "cloud-refused");
23118
23084
  }
23119
23085
  const next = res.value.version;
23120
- fs75.writeFileSync(path76.join(dir, VERSION_FILE), versionText(cloudId, next));
23086
+ fs74.writeFileSync(path75.join(dir, VERSION_FILE), versionText(cloudId, next));
23121
23087
  say(`Pushed ${id} v${next}. New tasks take it.`);
23122
23088
  return { id, version: next, changed: true };
23123
23089
  }
23124
- var found, done, names2, previewNames, cloudIdOf;
23090
+ function noteText(what, { file, text: text4 }) {
23091
+ if (file !== void 0 && text4 !== void 0) die("pass --file or --text, not both", "bad-args");
23092
+ if (file !== void 0) {
23093
+ try {
23094
+ return fs74.readFileSync(file, "utf8").trim();
23095
+ } catch {
23096
+ die(`can't read ${file}`, "bad-args");
23097
+ }
23098
+ }
23099
+ if (text4 !== void 0) return text4.trim();
23100
+ die(`the ${what} have to come from --text or --file`, "bad-args");
23101
+ }
23102
+ function cloudOk(res) {
23103
+ if (!res.ok) die(res.error, res.code === "unauthenticated" ? "needs-cloud" : "cloud-refused");
23104
+ return res.value;
23105
+ }
23106
+ async function cloudScope() {
23107
+ const project2 = boardProject();
23108
+ if (!project2) die("This board is not linked to a Cloud project.", "needs-cloud");
23109
+ const held4 = cloudOk(await call("GET", `/v1/projects/${enc2(project2)}`));
23110
+ return { project: project2, workspace: held4.workspace };
23111
+ }
23112
+ async function cmdWorkflowRule(name, opts) {
23113
+ const rule = noteText("rules", opts);
23114
+ const { workspace: workspace2 } = await cloudScope();
23115
+ const held4 = cloudOk(await call("GET", `/v1/workspaces/${enc2(workspace2)}/workflow-rules`));
23116
+ const flow = held4.workflows.find((w) => workflowName(w.id) === name);
23117
+ if (!flow) {
23118
+ die(`no workflow called "${name}" here. There are: ${held4.workflows.map((w) => workflowName(w.id)).join(", ")}.`, {
23119
+ kind: "no-such-workflow",
23120
+ workflow: name
23121
+ });
23122
+ }
23123
+ cloudOk(await call("PUT", `/v1/workspaces/${enc2(workspace2)}/workflows/${enc2(flow.id)}/rule`, { rule }));
23124
+ say(`${rule ? "saved" : "cleared"} the rules of ${name}`);
23125
+ return { workflow: name, rule };
23126
+ }
23127
+ async function cmdWorkflowInstructions(agent, opts) {
23128
+ const rule = noteText("instructions", opts);
23129
+ const { project: project2, workspace: workspace2 } = await cloudScope();
23130
+ const [shared, own] = await Promise.all([
23131
+ call("GET", `/v1/workspaces/${enc2(workspace2)}/workflow-rules`),
23132
+ call("GET", `/v1/projects/${enc2(project2)}/agents`)
23133
+ ]);
23134
+ const flowAgents = cloudOk(shared).data.map((a) => a.agent);
23135
+ const board2 = cloudOk(own).board;
23136
+ const scope = board2.includes(agent) ? "project" : flowAgents.includes(agent) ? "workspace" : null;
23137
+ if (!scope) {
23138
+ die(`no agent called "${agent}" here. There are: ${[.../* @__PURE__ */ new Set([...flowAgents, ...board2])].join(", ")}.`, {
23139
+ kind: "no-such-agent",
23140
+ agent
23141
+ });
23142
+ }
23143
+ const route2 = scope === "project" ? `/v1/projects/${enc2(project2)}/agents/${enc2(agent)}` : `/v1/workspaces/${enc2(workspace2)}/agents/${enc2(agent)}`;
23144
+ cloudOk(await call("PUT", route2, { rule }));
23145
+ say(rule ? `saved ${agent}'s instructions (${scope === "project" ? "this project" : "every project"})` : `cleared ${agent}'s instructions`);
23146
+ return { agent, rule, scope };
23147
+ }
23148
+ var found, done, names2, previewNames, cloudIdOf, enc2;
23125
23149
  var init_workflow2 = __esm({
23126
23150
  "../cli/src/commands/workflow.ts"() {
23127
23151
  "use strict";
@@ -23152,6 +23176,7 @@ var init_workflow2 = __esm({
23152
23176
  names2 = (rows) => rows.map((h) => `${h.agent}${h.off ? " (off)" : ""}`).join(", ");
23153
23177
  previewNames = (rows) => rows.map((h) => `${names2([h])}${agentAfter(h.agent).length ? ` (after ${agentAfter(h.agent).join(", ")})` : ""}`).join(", ");
23154
23178
  cloudIdOf = (id) => cloudFlows().find((f) => workflowName(f.cloudId) === id)?.cloudId;
23179
+ enc2 = encodeURIComponent;
23155
23180
  }
23156
23181
  });
23157
23182
 
@@ -23279,8 +23304,8 @@ var init_complete = __esm({
23279
23304
  });
23280
23305
 
23281
23306
  // ../cli/src/lib/agent/approve.ts
23282
- import fs76 from "node:fs";
23283
- import path77 from "node:path";
23307
+ import fs75 from "node:fs";
23308
+ import path76 from "node:path";
23284
23309
  function approvalRequest(req) {
23285
23310
  const id = req.id;
23286
23311
  const card = id === void 0 ? null : findCard(id);
@@ -23298,12 +23323,12 @@ function advancePhase(id) {
23298
23323
  const card = findCard(id);
23299
23324
  const found2 = locate(id);
23300
23325
  if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
23301
- const file = found2.kind === "group" ? path77.join(found2.target, "root.md") : found2.target;
23302
- const { meta, body } = parseFrontmatter(fs76.readFileSync(file, "utf8"));
23326
+ const file = found2.kind === "group" ? path76.join(found2.target, "root.md") : found2.target;
23327
+ const { meta, body } = parseFrontmatter(fs75.readFileSync(file, "utf8"));
23303
23328
  if (!meta) return { error: `#${id} has no frontmatter` };
23304
23329
  meta.phase = card.stage + 1;
23305
23330
  meta.status = "todo";
23306
- fs76.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
23331
+ fs75.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
23307
23332
  return null;
23308
23333
  }
23309
23334
  var init_approve = __esm({
@@ -23426,16 +23451,16 @@ var init_start = __esm({
23426
23451
  });
23427
23452
 
23428
23453
  // ../cli/src/lib/agent/task-chats.ts
23429
- import fs77 from "node:fs";
23430
- import path78 from "node:path";
23454
+ import fs76 from "node:fs";
23455
+ import path77 from "node:path";
23431
23456
  function taskChatFile(task, home3) {
23432
23457
  if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
23433
- return path78.join(taskChatsDir(home3), `${task}.jsonl`);
23458
+ return path77.join(taskChatsDir(home3), `${task}.jsonl`);
23434
23459
  }
23435
23460
  function readTaskChat(task, home3) {
23436
23461
  let text4;
23437
23462
  try {
23438
- text4 = fs77.readFileSync(taskChatFile(task, home3), "utf8");
23463
+ text4 = fs76.readFileSync(taskChatFile(task, home3), "utf8");
23439
23464
  } catch {
23440
23465
  return [];
23441
23466
  }
@@ -23456,13 +23481,13 @@ var init_task_chats = __esm({
23456
23481
  "use strict";
23457
23482
  init_home();
23458
23483
  TASK = /^[\w-]{1,100}$/;
23459
- taskChatsDir = (home3 = machineHome()) => path78.join(home3, "chats");
23484
+ taskChatsDir = (home3 = machineHome()) => path77.join(home3, "chats");
23460
23485
  }
23461
23486
  });
23462
23487
 
23463
23488
  // ../cli/src/lib/agent/memory-review.ts
23464
- import fs78 from "node:fs";
23465
- import path79 from "node:path";
23489
+ import fs77 from "node:fs";
23490
+ import path78 from "node:path";
23466
23491
  function taskChatsToReview(tasks) {
23467
23492
  const out = [];
23468
23493
  for (const ref of [...new Set(tasks)]) {
@@ -23484,8 +23509,8 @@ function readArchived2(id) {
23484
23509
  const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
23485
23510
  if (!found2) return null;
23486
23511
  try {
23487
- const file = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
23488
- const { meta, body } = parseFrontmatter(fs78.readFileSync(file, "utf8"));
23512
+ const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
23513
+ const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
23489
23514
  if (!meta) return null;
23490
23515
  return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
23491
23516
  } catch {
@@ -23554,17 +23579,17 @@ var init_memory_review = __esm({
23554
23579
  });
23555
23580
 
23556
23581
  // ../cli/src/lib/agent/dismissal-review.ts
23557
- import fs79 from "node:fs";
23558
- import path80 from "node:path";
23582
+ import fs78 from "node:fs";
23583
+ import path79 from "node:path";
23559
23584
  function rejectionsToReview() {
23560
- const dir = path80.join(ARCHIVE, REJECTIONS_TO_REVIEW);
23561
- if (!fs79.existsSync(dir)) return [];
23585
+ const dir = path79.join(ARCHIVE, REJECTIONS_TO_REVIEW);
23586
+ if (!fs78.existsSync(dir)) return [];
23562
23587
  const found2 = [];
23563
23588
  for (const file of walkMd(dir)) {
23564
23589
  const id = archivedId(file);
23565
23590
  if (id === null) continue;
23566
23591
  try {
23567
- const { meta } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
23592
+ const { meta } = parseFrontmatter(fs78.readFileSync(file, "utf8"));
23568
23593
  if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
23569
23594
  found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
23570
23595
  } catch {
@@ -23594,7 +23619,7 @@ function citedSources(text4) {
23594
23619
  function withdrawnSources() {
23595
23620
  const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
23596
23621
  try {
23597
- return citedSources(fs79.readFileSync(file, "utf8"));
23622
+ return citedSources(fs78.readFileSync(file, "utf8"));
23598
23623
  } catch {
23599
23624
  return [];
23600
23625
  }
@@ -23619,8 +23644,8 @@ var init_dismissal_review = __esm({
23619
23644
  });
23620
23645
 
23621
23646
  // ../cli/src/lib/agent/flow.ts
23622
- import fs80 from "node:fs";
23623
- import path81 from "node:path";
23647
+ import fs79 from "node:fs";
23648
+ import path80 from "node:path";
23624
23649
  function readCard2(id, home3 = "board") {
23625
23650
  const pending = activeDelivery(id)?.completions?.some((c) => !c.finished);
23626
23651
  const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
@@ -23630,10 +23655,10 @@ function readCard2(id, home3 = "board") {
23630
23655
  { kind: "card-not-found", id }
23631
23656
  );
23632
23657
  }
23633
- const file = found2.kind === "group" ? path81.join(found2.target, "root.md") : found2.target;
23658
+ const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
23634
23659
  let text4;
23635
23660
  try {
23636
- text4 = fs80.readFileSync(file, "utf8");
23661
+ text4 = fs79.readFileSync(file, "utf8");
23637
23662
  } catch {
23638
23663
  die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
23639
23664
  }
@@ -24451,7 +24476,7 @@ __export(watch_exports, {
24451
24476
  watchRun: () => watchRun
24452
24477
  });
24453
24478
  import { spawn as spawn3 } from "node:child_process";
24454
- import fs81 from "node:fs";
24479
+ import fs80 from "node:fs";
24455
24480
  async function watchRun(sessionId, resume = startResume) {
24456
24481
  const spec = readSpec(sessionId);
24457
24482
  const run = peekRun(sessionId);
@@ -24487,11 +24512,11 @@ async function watchRun(sessionId, resume = startResume) {
24487
24512
  const record = claimed ?? run;
24488
24513
  const sub = record.action === "sub";
24489
24514
  if (claim) await setCardStatus(claim.cardId, claim.status);
24490
- fs81.mkdirSync(SESSIONS_DIR, { recursive: true });
24491
- const logFile = fs81.createWriteStream(record.logPath, { flags: "a" });
24515
+ fs80.mkdirSync(SESSIONS_DIR, { recursive: true });
24516
+ const logFile = fs80.createWriteStream(record.logPath, { flags: "a" });
24492
24517
  logFile.on("error", () => {
24493
24518
  });
24494
- const eventsFile = fs81.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
24519
+ const eventsFile = fs80.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
24495
24520
  eventsFile.on("error", () => {
24496
24521
  });
24497
24522
  const event2 = (e) => eventsFile.write(`${JSON.stringify(e)}
@@ -24765,8 +24790,9 @@ async function watchRun(sessionId, resume = startResume) {
24765
24790
  formatErrors = [{ file: rel(TODO), line: 1, rule: "read-error", message: `Cannot validate the card files: ${String(error)}. Restore readable Markdown files and retry.` }];
24766
24791
  }
24767
24792
  }
24768
- const contractError = formatErrors.length ? formatContractErrors(formatErrors) : void 0;
24769
- const problems = formatErrors.length ? formatProblems(formatErrors) : void 0;
24793
+ const contractError = formatErrors.length ? boardCheckErrors(formatErrors) : void 0;
24794
+ const repairing = !!contractError && repairable && (record.formatRepair?.attempt ?? 0) < MAX_FORMAT_REPAIRS;
24795
+ const problems = formatErrors.length && !repairing ? boardProblems(formatErrors) : void 0;
24770
24796
  if (contractError) {
24771
24797
  log.write(`
24772
24798
  [validation] ${contractError}
@@ -24808,7 +24834,7 @@ ${result}
24808
24834
  const noteWhy = status === "done" ? settled?.stalledWhy ?? [] : [];
24809
24835
  const saidOurs = !asked && silent && !spawnError;
24810
24836
  const errorWhy = [
24811
- ...contractError ? [{ kind: "format" }] : [],
24837
+ ...problems ? [{ kind: "format" }] : [],
24812
24838
  ...spawnWhy ? [spawnWhy] : [],
24813
24839
  ...saidOurs ? [waited ? { kind: "backgroundSilent", args: { n: String(BACKGROUND_WAIT.minutes / 60) } } : { kind: "silent", args: { n: String(silenceFor) } }] : []
24814
24840
  ];
@@ -24844,11 +24870,11 @@ ${result}
24844
24870
  endedAt
24845
24871
  });
24846
24872
  letGo();
24847
- if (contractError && repairable && (record.formatRepair?.attempt ?? 0) < MAX_FORMAT_REPAIRS) {
24873
+ if (repairing) {
24848
24874
  const next = await resume(sessionId);
24849
24875
  if ("error" in next) patch(sessionId, (r) => {
24850
- r.error = `${problems}
24851
- Cannot resume format repair: ${next.error}`;
24876
+ r.error = `${boardProblems(formatErrors)}
24877
+ Cannot resume board repair: ${next.error}`;
24852
24878
  r.errorWhy = [{ kind: "format" }, { kind: "repairUnstarted", refusals: [next] }];
24853
24879
  });
24854
24880
  }
@@ -25058,8 +25084,8 @@ var init_watch = __esm({
25058
25084
  });
25059
25085
 
25060
25086
  // ../cli/src/commands/run.ts
25061
- import fs82 from "node:fs";
25062
- import path82 from "node:path";
25087
+ import fs81 from "node:fs";
25088
+ import path81 from "node:path";
25063
25089
  async function cmdStartRun(action, args, opts, program2 = "akb") {
25064
25090
  const { req, follow: follow2, print } = readRequest(action, args, opts);
25065
25091
  if (Number.isInteger(req.id)) {
@@ -25269,7 +25295,7 @@ async function cmdSubStart(words, opts) {
25269
25295
  let prompt = words.join(" ");
25270
25296
  if (opts.file) {
25271
25297
  try {
25272
- prompt = fs82.readFileSync(path82.resolve(opts.file), "utf8");
25298
+ prompt = fs81.readFileSync(path81.resolve(opts.file), "utf8");
25273
25299
  } catch {
25274
25300
  die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
25275
25301
  }
@@ -25635,7 +25661,7 @@ var init_signals = __esm({
25635
25661
  });
25636
25662
 
25637
25663
  // ../cli/src/commands/triage.ts
25638
- import fs83 from "node:fs";
25664
+ import fs82 from "node:fs";
25639
25665
  async function cmdTriageAdd(opts) {
25640
25666
  const title = (opts.title ?? "").trim();
25641
25667
  if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
@@ -25645,7 +25671,7 @@ async function cmdTriageAdd(opts) {
25645
25671
  let body = opts.text;
25646
25672
  if (opts.file !== void 0) {
25647
25673
  try {
25648
- body = fs83.readFileSync(opts.file, "utf8");
25674
+ body = fs82.readFileSync(opts.file, "utf8");
25649
25675
  } catch {
25650
25676
  die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
25651
25677
  }
@@ -26057,6 +26083,14 @@ function declareRuns(program2, cli) {
26057
26083
  flowWord("push").argument("<folder>", "a folder `workflow pull` wrote").option("--dry-run", "check the folder and print what would happen, saving nothing").summary("save the edited folder as the workflow's next version, which new tasks take").action(async function(folder) {
26058
26084
  await boardless(this, cli, () => cmdWorkflowPush(folder, this.opts()));
26059
26085
  });
26086
+ flowWord("rule").argument("<workflow>", "a workflow id from `akb workflow list`").option("--text <text>", "the rules, for a one-liner; empty clears them").option("--file <path>", "the rules, as markdown written to a file first").summary("set a workflow's rules \u2014 what every card on it follows \u2014 in the user's own words").description("Saved to Cloud for every project in the workspace; empty clears them.").action(async function(id) {
26087
+ await onBoard2(this, cli, () => cmdWorkflowRule(id, this.opts()));
26088
+ });
26089
+ flowWord("instructions").argument("<agent>", "an agent `akb workflow list` names").option("--text <text>", "the instructions, for a one-liner; empty clears them").option("--file <path>", "the instructions, as markdown written to a file first").summary("set one agent's instructions \u2014 appended to every run it does \u2014 in the user's own words").description(
26090
+ "A workflow's agent is the workspace's, shared by every workflow listing it; a board's scheduled agent is this project's. Saved to Cloud; empty clears them."
26091
+ ).action(async function(agent) {
26092
+ await onBoard2(this, cli, () => cmdWorkflowInstructions(agent, this.opts()));
26093
+ });
26060
26094
  withShared(program2.command("guide")).argument("[topic]", "one flow in full; left off, every flow is listed one line each").summary("the flows the board works by, shipped with this command").description(
26061
26095
  "A printed flow already carries the flows its action is done by, so this is for the rest: how the board works at all, the module map, updating, the local UI. `guide board` is the card format, the layout and the memory set."
26062
26096
  ).action(async function(...vals) {
@@ -26240,15 +26274,15 @@ var init_agent2 = __esm({
26240
26274
  });
26241
26275
 
26242
26276
  // ../cli/src/kanban.ts
26243
- import fs86 from "node:fs";
26277
+ import fs85 from "node:fs";
26244
26278
  import { fileURLToPath as fileURLToPath4 } from "node:url";
26245
26279
 
26246
26280
  // ../cli/src/lib/cli/akb.ts
26247
26281
  init_agent2();
26248
26282
 
26249
26283
  // ../cli/src/lib/cli/setup.ts
26250
- import fs85 from "node:fs";
26251
- import path84 from "node:path";
26284
+ import fs84 from "node:fs";
26285
+ import path83 from "node:path";
26252
26286
  import { fileURLToPath as fileURLToPath3 } from "node:url";
26253
26287
 
26254
26288
  // ../cli/src/commands/update.ts
@@ -26262,8 +26296,8 @@ init_paths();
26262
26296
  init_memory();
26263
26297
  init_yaml2();
26264
26298
  init_version();
26265
- import fs84 from "node:fs";
26266
- import path83 from "node:path";
26299
+ import fs83 from "node:fs";
26300
+ import path82 from "node:path";
26267
26301
  import { spawnSync as spawnSync5 } from "node:child_process";
26268
26302
  var NAME = "wildcrane";
26269
26303
  var REPO = "https://github.com/wildcrane-ai/wildcrane";
@@ -26285,10 +26319,10 @@ var Report = class {
26285
26319
  for (const line of this.notes) say(` ! ${line}`);
26286
26320
  }
26287
26321
  };
26288
- var read2 = (file) => fs84.existsSync(file) ? fs84.readFileSync(file, "utf8") : null;
26322
+ var read2 = (file) => fs83.existsSync(file) ? fs83.readFileSync(file, "utf8") : null;
26289
26323
  function statOf(p) {
26290
26324
  try {
26291
- return fs84.lstatSync(p);
26325
+ return fs83.lstatSync(p);
26292
26326
  } catch {
26293
26327
  return null;
26294
26328
  }
@@ -26313,10 +26347,10 @@ async function cmdUpdate2(ctx) {
26313
26347
  return { updated: ctx.dir, from, to: SKILL_VERSION };
26314
26348
  }
26315
26349
  async function repairBoard(root2, report3, named2) {
26316
- const legacy2 = path83.join(root2, "docs", "kanban");
26317
- const kept2 = path83.join(root2, ".akb", "kanban");
26318
- const board2 = named2 ?? (fs84.existsSync(legacy2) ? legacy2 : kept2);
26319
- if (!fs84.existsSync(board2)) {
26350
+ const legacy2 = path82.join(root2, "docs", "kanban");
26351
+ const kept2 = path82.join(root2, ".akb", "kanban");
26352
+ const board2 = named2 ?? (fs83.existsSync(legacy2) ? legacy2 : kept2);
26353
+ if (!fs83.existsSync(board2)) {
26320
26354
  report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
26321
26355
  return false;
26322
26356
  }
@@ -26347,20 +26381,20 @@ function moveRuntimes(root2, board2, report3) {
26347
26381
  }
26348
26382
  }
26349
26383
  function moveLegacyMemory(board2, report3) {
26350
- const memory = path83.join(board2, "memory");
26384
+ const memory = path82.join(board2, "memory");
26351
26385
  const moved = [];
26352
26386
  for (const name of MEMORY_FILES) {
26353
- const from = path83.join(board2, name);
26387
+ const from = path82.join(board2, name);
26354
26388
  const st = statOf(from);
26355
26389
  if (!st || !st.isFile()) continue;
26356
- fs84.mkdirSync(memory, { recursive: true });
26357
- const to = path83.join(memory, name);
26390
+ fs83.mkdirSync(memory, { recursive: true });
26391
+ const to = path82.join(memory, name);
26358
26392
  const there = read2(to);
26359
26393
  if (there === null) {
26360
- fs84.renameSync(from, to);
26394
+ fs83.renameSync(from, to);
26361
26395
  moved.push(name);
26362
26396
  } else if (there === read2(from)) {
26363
- fs84.rmSync(from);
26397
+ fs83.rmSync(from);
26364
26398
  moved.push(name);
26365
26399
  } else {
26366
26400
  report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
@@ -26369,23 +26403,23 @@ function moveLegacyMemory(board2, report3) {
26369
26403
  if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
26370
26404
  }
26371
26405
  function dropRecordFile(board2) {
26372
- const file = path83.join(board2, "record.csv");
26373
- if (!fs84.existsSync(file)) return null;
26374
- fs84.rmSync(file);
26406
+ const file = path82.join(board2, "record.csv");
26407
+ if (!fs83.existsSync(file)) return null;
26408
+ fs83.rmSync(file);
26375
26409
  return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
26376
26410
  }
26377
26411
  function dropModuleGoals(board2, report3) {
26378
- const memory = path83.join(board2, "memory");
26379
- if (!fs84.existsSync(memory)) return;
26380
- const root2 = read2(path83.join(memory, "goal.md"));
26412
+ const memory = path82.join(board2, "memory");
26413
+ if (!fs83.existsSync(memory)) return;
26414
+ const root2 = read2(path82.join(memory, "goal.md"));
26381
26415
  let dropped = 0;
26382
- for (const entry of fs84.readdirSync(memory, { withFileTypes: true })) {
26416
+ for (const entry of fs83.readdirSync(memory, { withFileTypes: true })) {
26383
26417
  if (!entry.isDirectory()) continue;
26384
- const file = path83.join(memory, entry.name, "goal.md");
26418
+ const file = path82.join(memory, entry.name, "goal.md");
26385
26419
  const text4 = read2(file);
26386
26420
  if (text4 === null) continue;
26387
26421
  if (text4 === root2 || text4.includes(UNFILLED) || !goalWords(text4)) {
26388
- fs84.rmSync(file);
26422
+ fs83.rmSync(file);
26389
26423
  dropped++;
26390
26424
  } else {
26391
26425
  report3.notes.push(
@@ -26407,10 +26441,10 @@ var PLAN_LEADS = {
26407
26441
  var GONE_LEADS = ["software-planner", "planner"];
26408
26442
  function planLeads(board2) {
26409
26443
  const leads = { ...PLAN_LEADS };
26410
- const root2 = path83.join(board2, "workflows");
26411
- for (const entry of fs84.existsSync(root2) ? fs84.readdirSync(root2, { withFileTypes: true }) : []) {
26444
+ const root2 = path82.join(board2, "workflows");
26445
+ for (const entry of fs83.existsSync(root2) ? fs83.readdirSync(root2, { withFileTypes: true }) : []) {
26412
26446
  if (!entry.isDirectory()) continue;
26413
- const meta = splitFrontmatter(read2(path83.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
26447
+ const meta = splitFrontmatter(read2(path82.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
26414
26448
  const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
26415
26449
  const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
26416
26450
  const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
@@ -26419,30 +26453,30 @@ function planLeads(board2) {
26419
26453
  return leads;
26420
26454
  }
26421
26455
  function movePlanRules(board2, report3) {
26422
- const rules = path83.join(board2, "rules");
26456
+ const rules = path82.join(board2, "rules");
26423
26457
  const moved = [];
26424
26458
  for (const [id, leads] of Object.entries(planLeads(board2))) {
26425
26459
  for (const lead of leads) {
26426
- const from = path83.join(rules, `${lead}.md`);
26460
+ const from = path82.join(rules, `${lead}.md`);
26427
26461
  const rule = read2(from)?.trim();
26428
26462
  if (!rule) continue;
26429
- const to = path83.join(rules, "workflows", `${id}.md`);
26463
+ const to = path82.join(rules, "workflows", `${id}.md`);
26430
26464
  const there = read2(to)?.trim() ?? "";
26431
26465
  if (!there.includes(rule)) {
26432
- fs84.mkdirSync(path83.dirname(to), { recursive: true });
26433
- fs84.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
26466
+ fs83.mkdirSync(path82.dirname(to), { recursive: true });
26467
+ fs83.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
26434
26468
  `);
26435
26469
  moved.push(`${lead} \u2192 ${id}`);
26436
26470
  }
26437
26471
  }
26438
26472
  }
26439
- for (const lead of GONE_LEADS) fs84.rmSync(path83.join(rules, `${lead}.md`), { force: true });
26473
+ for (const lead of GONE_LEADS) fs83.rmSync(path82.join(rules, `${lead}.md`), { force: true });
26440
26474
  if (moved.length) report3.did.push(`made each plan agent's rule its workflow's card rule (docs/kanban/rules/workflows/): ${moved.join(", ")}`);
26441
26475
  }
26442
26476
  function noteOldWorkflows(board2, report3) {
26443
26477
  const old = (dir, file, keys) => {
26444
- const root2 = path83.join(board2, dir);
26445
- return (fs84.existsSync(root2) ? fs84.readdirSync(root2, { withFileTypes: true }) : []).filter((e) => e.isDirectory() && keys.test(splitFrontmatter(read2(path83.join(root2, e.name, file)) ?? "").meta ?? "")).map((e) => `docs/kanban/${dir}/${e.name}/${file}`);
26478
+ const root2 = path82.join(board2, dir);
26479
+ return (fs83.existsSync(root2) ? fs83.readdirSync(root2, { withFileTypes: true }) : []).filter((e) => e.isDirectory() && keys.test(splitFrontmatter(read2(path82.join(root2, e.name, file)) ?? "").meta ?? "")).map((e) => `docs/kanban/${dir}/${e.name}/${file}`);
26446
26480
  };
26447
26481
  const files = [...old("workflows", "WORKFLOW.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
26448
26482
  if (files.length) {
@@ -26452,7 +26486,7 @@ function noteOldWorkflows(board2, report3) {
26452
26486
  }
26453
26487
  }
26454
26488
  function checkConfig(board2, report3) {
26455
- const current = read2(path83.join(board2, "config.md"));
26489
+ const current = read2(path82.join(board2, "config.md"));
26456
26490
  if (!current) return;
26457
26491
  const added = missingConfigKeys(current);
26458
26492
  if (added.length) {
@@ -26462,7 +26496,7 @@ function checkConfig(board2, report3) {
26462
26496
  }
26463
26497
  }
26464
26498
  function checkModules(board2, report3) {
26465
- const map2 = read2(path83.join(board2, "modules.md"));
26499
+ const map2 = read2(path82.join(board2, "modules.md"));
26466
26500
  if (map2 && map2.includes(UNFILLED)) {
26467
26501
  report3.notes.push(
26468
26502
  "docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
@@ -26516,14 +26550,14 @@ function declareSetup(program2, cli) {
26516
26550
  program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
26517
26551
  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");
26518
26552
  const where = (cmd) => {
26519
- const dir = path84.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
26520
- if (!fs85.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
26553
+ const dir = path83.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
26554
+ if (!fs84.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
26521
26555
  return dir;
26522
26556
  };
26523
26557
  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() {
26524
26558
  const dir = where(this);
26525
26559
  const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
26526
- const board2 = named2 ? path84.resolve(cli.cwd, named2) : null;
26560
+ const board2 = named2 ? path83.resolve(cli.cwd, named2) : null;
26527
26561
  await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
26528
26562
  });
26529
26563
  program2.command("__rules", { hidden: true }).action(function() {
@@ -26568,7 +26602,7 @@ function invokedDirectly() {
26568
26602
  const entry = process.argv[1];
26569
26603
  if (!entry) return false;
26570
26604
  try {
26571
- return fs86.realpathSync(entry) === fs86.realpathSync(SELF2);
26605
+ return fs85.realpathSync(entry) === fs85.realpathSync(SELF2);
26572
26606
  } catch {
26573
26607
  return false;
26574
26608
  }