wildcrane 0.11.32 → 0.11.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kanban.mjs +334 -300
- package/package.json +1 -1
package/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.33 — built from the CLI's TypeScript sources by cli/scripts/build.mjs.
|
|
3
3
|
// Do not edit: every change belongs in cli/src/, and a build overwrites this file.
|
|
4
4
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
5
5
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
@@ -3211,10 +3211,10 @@ function findRollout(threadId) {
|
|
|
3211
3211
|
}
|
|
3212
3212
|
for (const name of names3) {
|
|
3213
3213
|
if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
|
|
3214
|
-
const
|
|
3214
|
+
const path84 = join(dir, name);
|
|
3215
3215
|
try {
|
|
3216
|
-
const at = statSync(
|
|
3217
|
-
if (!newest2 || at > newest2.at) newest2 = { path:
|
|
3216
|
+
const at = statSync(path84).mtimeMs;
|
|
3217
|
+
if (!newest2 || at > newest2.at) newest2 = { path: path84, at };
|
|
3218
3218
|
} catch {
|
|
3219
3219
|
}
|
|
3220
3220
|
}
|
|
@@ -3222,11 +3222,11 @@ function findRollout(threadId) {
|
|
|
3222
3222
|
return newest2?.path;
|
|
3223
3223
|
}
|
|
3224
3224
|
function readCodexRunFacts(threadId) {
|
|
3225
|
-
const
|
|
3226
|
-
if (!
|
|
3225
|
+
const path84 = findRollout(threadId);
|
|
3226
|
+
if (!path84) return void 0;
|
|
3227
3227
|
let raw;
|
|
3228
3228
|
try {
|
|
3229
|
-
raw = readFileSync(
|
|
3229
|
+
raw = readFileSync(path84, "utf8");
|
|
3230
3230
|
} catch {
|
|
3231
3231
|
return void 0;
|
|
3232
3232
|
}
|
|
@@ -3354,8 +3354,8 @@ function renderCompleted(item) {
|
|
|
3354
3354
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
3355
3355
|
return changes.map((raw) => {
|
|
3356
3356
|
const change2 = obj(raw);
|
|
3357
|
-
const
|
|
3358
|
-
return
|
|
3357
|
+
const path84 = str(change2.path);
|
|
3358
|
+
return path84 ? `\u23FA ${str(change2.kind) || "change"}(${path84})
|
|
3359
3359
|
` : "";
|
|
3360
3360
|
}).join("");
|
|
3361
3361
|
}
|
|
@@ -3617,10 +3617,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
3617
3617
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
3618
3618
|
let model;
|
|
3619
3619
|
let holding = 0;
|
|
3620
|
-
for (const { path:
|
|
3620
|
+
for (const { path: path84, main } of wireFiles(entry.sessionDir)) {
|
|
3621
3621
|
let raw;
|
|
3622
3622
|
try {
|
|
3623
|
-
raw = readFileSync2(
|
|
3623
|
+
raw = readFileSync2(path84, "utf8");
|
|
3624
3624
|
} catch {
|
|
3625
3625
|
continue;
|
|
3626
3626
|
}
|
|
@@ -3903,7 +3903,7 @@ var init_package = __esm({
|
|
|
3903
3903
|
"package.json"() {
|
|
3904
3904
|
package_default = {
|
|
3905
3905
|
name: "wildcrane",
|
|
3906
|
-
version: "0.11.
|
|
3906
|
+
version: "0.11.33",
|
|
3907
3907
|
akbContract: 8,
|
|
3908
3908
|
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.",
|
|
3909
3909
|
keywords: [
|
|
@@ -3980,8 +3980,8 @@ var init_version = __esm({
|
|
|
3980
3980
|
import fs16 from "node:fs";
|
|
3981
3981
|
function whereHint(update2, title) {
|
|
3982
3982
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
3983
|
-
const
|
|
3984
|
-
return
|
|
3983
|
+
const path84 = str(obj(locations[0]).path);
|
|
3984
|
+
return path84 && !title.includes(path84) ? hint(path84) : "";
|
|
3985
3985
|
}
|
|
3986
3986
|
function saidBy(update2) {
|
|
3987
3987
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
@@ -9180,6 +9180,15 @@ var init_parse = __esm({
|
|
|
9180
9180
|
});
|
|
9181
9181
|
|
|
9182
9182
|
// src/lib/agent/workflow-def.ts
|
|
9183
|
+
function agentLines2(agents, indent2) {
|
|
9184
|
+
return agents.flatMap(
|
|
9185
|
+
(h) => !h.extra && !h.off ? [`${indent2}- ${scalar(h.agent)}`] : [
|
|
9186
|
+
`${indent2}- agent: ${scalar(h.agent)}`,
|
|
9187
|
+
...h.extra ? [`${indent2} extra: ${JSON.stringify(h.extra)}`] : [],
|
|
9188
|
+
...h.off ? [`${indent2} off: true`] : []
|
|
9189
|
+
]
|
|
9190
|
+
);
|
|
9191
|
+
}
|
|
9183
9192
|
function readAgent(item) {
|
|
9184
9193
|
const row = typeof item === "string" ? { agent: item } : box(item);
|
|
9185
9194
|
const agent = canonicalSpecAgent(text3(row.agent));
|
|
@@ -9259,13 +9268,18 @@ function parseWorkflowFile(id, source, from) {
|
|
|
9259
9268
|
}
|
|
9260
9269
|
};
|
|
9261
9270
|
}
|
|
9262
|
-
var WORKFLOW_ID, OLD_KEYS, box, text3, readGroup;
|
|
9271
|
+
var scalar, plain, flowList, groupLines, WORKFLOW_ID, OLD_KEYS, box, text3, readGroup;
|
|
9263
9272
|
var init_workflow_def = __esm({
|
|
9264
9273
|
"src/lib/agent/workflow-def.ts"() {
|
|
9265
9274
|
"use strict";
|
|
9266
9275
|
init_icon();
|
|
9267
9276
|
init_yaml2();
|
|
9268
9277
|
init_spec_agent_names();
|
|
9278
|
+
init_yaml();
|
|
9279
|
+
scalar = (value) => /\s#/.test(value) ? JSON.stringify(value) : yamlScalar(value);
|
|
9280
|
+
plain = (agents) => agents.every((h) => !h.extra && !h.off);
|
|
9281
|
+
flowList = (agents) => `[${agents.map((h) => scalar(h.agent)).join(", ")}]`;
|
|
9282
|
+
groupLines = (key, agents) => !agents.length ? [] : plain(agents) ? [`${key}: ${flowList(agents)}`] : [`${key}:`, ...agentLines2(agents, " ")];
|
|
9269
9283
|
WORKFLOW_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
9270
9284
|
OLD_KEYS = ["stages", "delivers", "helpers", "every"];
|
|
9271
9285
|
box = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
@@ -9878,15 +9892,6 @@ var init_catalog = __esm({
|
|
|
9878
9892
|
// src/lib/agent/workflow-file.ts
|
|
9879
9893
|
import fs31 from "node:fs";
|
|
9880
9894
|
import path35 from "node:path";
|
|
9881
|
-
function agentLines2(agents, indent2) {
|
|
9882
|
-
return agents.flatMap(
|
|
9883
|
-
(h) => !h.extra && !h.off ? [`${indent2}- ${scalar(h.agent)}`] : [
|
|
9884
|
-
`${indent2}- agent: ${scalar(h.agent)}`,
|
|
9885
|
-
...h.extra ? [`${indent2} extra: ${JSON.stringify(h.extra)}`] : [],
|
|
9886
|
-
...h.off ? [`${indent2} off: true`] : []
|
|
9887
|
-
]
|
|
9888
|
-
);
|
|
9889
|
-
}
|
|
9890
9895
|
function workflowFileText(def) {
|
|
9891
9896
|
const lines = ["---", `name: ${scalar(def.name)}`];
|
|
9892
9897
|
const names3 = Object.entries(def.names ?? {});
|
|
@@ -9894,8 +9899,7 @@ function workflowFileText(def) {
|
|
|
9894
9899
|
if (def.description) lines.push(`description: ${scalar(def.description)}`);
|
|
9895
9900
|
if (def.when) lines.push(`when: ${scalar(def.when)}`);
|
|
9896
9901
|
lines.push(`needsArtifact: ${def.needsArtifact}`);
|
|
9897
|
-
|
|
9898
|
-
lines.push(...group("previews", def.previews), ...group("land", def.land));
|
|
9902
|
+
lines.push(...groupLines("previews", def.previews), ...groupLines("land", def.land));
|
|
9899
9903
|
if (def.scheduled.length) {
|
|
9900
9904
|
lines.push("scheduled:");
|
|
9901
9905
|
for (const s of def.scheduled) {
|
|
@@ -9943,7 +9947,7 @@ function writeWorkflowDef(def) {
|
|
|
9943
9947
|
fs31.writeFileSync(file, workflowFileText(def));
|
|
9944
9948
|
forgetFileMemos();
|
|
9945
9949
|
}
|
|
9946
|
-
var WORKFLOW_FILE2,
|
|
9950
|
+
var WORKFLOW_FILE2, builtinDefs, fileOf;
|
|
9947
9951
|
var init_workflow_file = __esm({
|
|
9948
9952
|
"src/lib/agent/workflow-file.ts"() {
|
|
9949
9953
|
"use strict";
|
|
@@ -9951,14 +9955,10 @@ var init_workflow_file = __esm({
|
|
|
9951
9955
|
init_board_files();
|
|
9952
9956
|
init_tasks();
|
|
9953
9957
|
init_paths();
|
|
9954
|
-
init_yaml();
|
|
9955
9958
|
init_cloud_workflows();
|
|
9956
9959
|
init_workflow_def();
|
|
9957
9960
|
init_workflow_def();
|
|
9958
9961
|
WORKFLOW_FILE2 = "WORKFLOW.md";
|
|
9959
|
-
scalar = (value) => /\s#/.test(value) ? JSON.stringify(value) : yamlScalar(value);
|
|
9960
|
-
plain = (agents) => agents.every((h) => !h.extra && !h.off);
|
|
9961
|
-
flowList = (agents) => `[${agents.map((h) => scalar(h.agent)).join(", ")}]`;
|
|
9962
9962
|
builtinDefs = () => cloudFlows().filter((f) => f.builtIn).map((f) => f.def);
|
|
9963
9963
|
fileOf = (id) => path35.join(WORKFLOWS, id, WORKFLOW_FILE2);
|
|
9964
9964
|
}
|
|
@@ -10540,9 +10540,9 @@ var init_goal_cloud = __esm({
|
|
|
10540
10540
|
}
|
|
10541
10541
|
});
|
|
10542
10542
|
|
|
10543
|
-
// node_modules/commander/lib/error.js
|
|
10543
|
+
// ../../../../cli/node_modules/commander/lib/error.js
|
|
10544
10544
|
var require_error = __commonJS({
|
|
10545
|
-
"node_modules/commander/lib/error.js"(exports) {
|
|
10545
|
+
"../../../../cli/node_modules/commander/lib/error.js"(exports) {
|
|
10546
10546
|
var CommanderError2 = class extends Error {
|
|
10547
10547
|
/**
|
|
10548
10548
|
* Constructs the CommanderError class
|
|
@@ -10575,9 +10575,9 @@ var require_error = __commonJS({
|
|
|
10575
10575
|
}
|
|
10576
10576
|
});
|
|
10577
10577
|
|
|
10578
|
-
// node_modules/commander/lib/argument.js
|
|
10578
|
+
// ../../../../cli/node_modules/commander/lib/argument.js
|
|
10579
10579
|
var require_argument = __commonJS({
|
|
10580
|
-
"node_modules/commander/lib/argument.js"(exports) {
|
|
10580
|
+
"../../../../cli/node_modules/commander/lib/argument.js"(exports) {
|
|
10581
10581
|
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
10582
10582
|
var Argument2 = class {
|
|
10583
10583
|
/**
|
|
@@ -10702,9 +10702,9 @@ var require_argument = __commonJS({
|
|
|
10702
10702
|
}
|
|
10703
10703
|
});
|
|
10704
10704
|
|
|
10705
|
-
// node_modules/commander/lib/help.js
|
|
10705
|
+
// ../../../../cli/node_modules/commander/lib/help.js
|
|
10706
10706
|
var require_help = __commonJS({
|
|
10707
|
-
"node_modules/commander/lib/help.js"(exports) {
|
|
10707
|
+
"../../../../cli/node_modules/commander/lib/help.js"(exports) {
|
|
10708
10708
|
var { humanReadableArgName } = require_argument();
|
|
10709
10709
|
var Help2 = class {
|
|
10710
10710
|
constructor() {
|
|
@@ -11271,9 +11271,9 @@ ${itemIndentStr}`);
|
|
|
11271
11271
|
}
|
|
11272
11272
|
});
|
|
11273
11273
|
|
|
11274
|
-
// node_modules/commander/lib/option.js
|
|
11274
|
+
// ../../../../cli/node_modules/commander/lib/option.js
|
|
11275
11275
|
var require_option = __commonJS({
|
|
11276
|
-
"node_modules/commander/lib/option.js"(exports) {
|
|
11276
|
+
"../../../../cli/node_modules/commander/lib/option.js"(exports) {
|
|
11277
11277
|
var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
11278
11278
|
var Option2 = class {
|
|
11279
11279
|
/**
|
|
@@ -11572,9 +11572,9 @@ var require_option = __commonJS({
|
|
|
11572
11572
|
}
|
|
11573
11573
|
});
|
|
11574
11574
|
|
|
11575
|
-
// node_modules/commander/lib/suggestSimilar.js
|
|
11575
|
+
// ../../../../cli/node_modules/commander/lib/suggestSimilar.js
|
|
11576
11576
|
var require_suggestSimilar = __commonJS({
|
|
11577
|
-
"node_modules/commander/lib/suggestSimilar.js"(exports) {
|
|
11577
|
+
"../../../../cli/node_modules/commander/lib/suggestSimilar.js"(exports) {
|
|
11578
11578
|
var maxDistance = 3;
|
|
11579
11579
|
function editDistance2(a, b) {
|
|
11580
11580
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -11652,13 +11652,13 @@ var require_suggestSimilar = __commonJS({
|
|
|
11652
11652
|
}
|
|
11653
11653
|
});
|
|
11654
11654
|
|
|
11655
|
-
// node_modules/commander/lib/command.js
|
|
11655
|
+
// ../../../../cli/node_modules/commander/lib/command.js
|
|
11656
11656
|
var require_command = __commonJS({
|
|
11657
|
-
"node_modules/commander/lib/command.js"(exports) {
|
|
11657
|
+
"../../../../cli/node_modules/commander/lib/command.js"(exports) {
|
|
11658
11658
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
11659
11659
|
var childProcess = __require("node:child_process");
|
|
11660
|
-
var
|
|
11661
|
-
var
|
|
11660
|
+
var path84 = __require("node:path");
|
|
11661
|
+
var fs86 = __require("node:fs");
|
|
11662
11662
|
var process2 = __require("node:process");
|
|
11663
11663
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
11664
11664
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -12639,7 +12639,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12639
12639
|
* @param {string} subcommandName
|
|
12640
12640
|
*/
|
|
12641
12641
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
12642
|
-
if (
|
|
12642
|
+
if (fs86.existsSync(executableFile)) return;
|
|
12643
12643
|
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";
|
|
12644
12644
|
const executableMissing = `'${executableFile}' does not exist
|
|
12645
12645
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -12657,11 +12657,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12657
12657
|
let launchWithNode = false;
|
|
12658
12658
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
12659
12659
|
function findFile(baseDir, baseName) {
|
|
12660
|
-
const localBin =
|
|
12661
|
-
if (
|
|
12662
|
-
if (sourceExt.includes(
|
|
12660
|
+
const localBin = path84.resolve(baseDir, baseName);
|
|
12661
|
+
if (fs86.existsSync(localBin)) return localBin;
|
|
12662
|
+
if (sourceExt.includes(path84.extname(baseName))) return void 0;
|
|
12663
12663
|
const foundExt = sourceExt.find(
|
|
12664
|
-
(ext) =>
|
|
12664
|
+
(ext) => fs86.existsSync(`${localBin}${ext}`)
|
|
12665
12665
|
);
|
|
12666
12666
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
12667
12667
|
return void 0;
|
|
@@ -12673,21 +12673,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12673
12673
|
if (this._scriptPath) {
|
|
12674
12674
|
let resolvedScriptPath;
|
|
12675
12675
|
try {
|
|
12676
|
-
resolvedScriptPath =
|
|
12676
|
+
resolvedScriptPath = fs86.realpathSync(this._scriptPath);
|
|
12677
12677
|
} catch {
|
|
12678
12678
|
resolvedScriptPath = this._scriptPath;
|
|
12679
12679
|
}
|
|
12680
|
-
executableDir =
|
|
12681
|
-
|
|
12680
|
+
executableDir = path84.resolve(
|
|
12681
|
+
path84.dirname(resolvedScriptPath),
|
|
12682
12682
|
executableDir
|
|
12683
12683
|
);
|
|
12684
12684
|
}
|
|
12685
12685
|
if (executableDir) {
|
|
12686
12686
|
let localFile = findFile(executableDir, executableFile);
|
|
12687
12687
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
12688
|
-
const legacyName =
|
|
12688
|
+
const legacyName = path84.basename(
|
|
12689
12689
|
this._scriptPath,
|
|
12690
|
-
|
|
12690
|
+
path84.extname(this._scriptPath)
|
|
12691
12691
|
);
|
|
12692
12692
|
if (legacyName !== this._name) {
|
|
12693
12693
|
localFile = findFile(
|
|
@@ -12698,7 +12698,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12698
12698
|
}
|
|
12699
12699
|
executableFile = localFile || executableFile;
|
|
12700
12700
|
}
|
|
12701
|
-
launchWithNode = sourceExt.includes(
|
|
12701
|
+
launchWithNode = sourceExt.includes(path84.extname(executableFile));
|
|
12702
12702
|
let proc;
|
|
12703
12703
|
if (process2.platform !== "win32") {
|
|
12704
12704
|
if (launchWithNode) {
|
|
@@ -13545,7 +13545,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13545
13545
|
* @return {Command}
|
|
13546
13546
|
*/
|
|
13547
13547
|
nameFromFilename(filename) {
|
|
13548
|
-
this._name =
|
|
13548
|
+
this._name = path84.basename(filename, path84.extname(filename));
|
|
13549
13549
|
return this;
|
|
13550
13550
|
}
|
|
13551
13551
|
/**
|
|
@@ -13559,9 +13559,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13559
13559
|
* @param {string} [path]
|
|
13560
13560
|
* @return {(string|null|Command)}
|
|
13561
13561
|
*/
|
|
13562
|
-
executableDir(
|
|
13563
|
-
if (
|
|
13564
|
-
this._executableDir =
|
|
13562
|
+
executableDir(path85) {
|
|
13563
|
+
if (path85 === void 0) return this._executableDir;
|
|
13564
|
+
this._executableDir = path85;
|
|
13565
13565
|
return this;
|
|
13566
13566
|
}
|
|
13567
13567
|
/**
|
|
@@ -13811,9 +13811,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13811
13811
|
}
|
|
13812
13812
|
});
|
|
13813
13813
|
|
|
13814
|
-
// node_modules/commander/index.js
|
|
13814
|
+
// ../../../../cli/node_modules/commander/index.js
|
|
13815
13815
|
var require_commander = __commonJS({
|
|
13816
|
-
"node_modules/commander/index.js"(exports) {
|
|
13816
|
+
"../../../../cli/node_modules/commander/index.js"(exports) {
|
|
13817
13817
|
var { Argument: Argument2 } = require_argument();
|
|
13818
13818
|
var { Command: Command2 } = require_command();
|
|
13819
13819
|
var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
|
|
@@ -13833,10 +13833,10 @@ var require_commander = __commonJS({
|
|
|
13833
13833
|
}
|
|
13834
13834
|
});
|
|
13835
13835
|
|
|
13836
|
-
// node_modules/commander/esm.mjs
|
|
13836
|
+
// ../../../../cli/node_modules/commander/esm.mjs
|
|
13837
13837
|
var import_index, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
|
|
13838
13838
|
var init_esm = __esm({
|
|
13839
|
-
"node_modules/commander/esm.mjs"() {
|
|
13839
|
+
"../../../../cli/node_modules/commander/esm.mjs"() {
|
|
13840
13840
|
import_index = __toESM(require_commander(), 1);
|
|
13841
13841
|
({
|
|
13842
13842
|
program,
|
|
@@ -14986,23 +14986,6 @@ function readRule(agent) {
|
|
|
14986
14986
|
migrateFlowRules();
|
|
14987
14987
|
return ruleFile(agent);
|
|
14988
14988
|
}
|
|
14989
|
-
function setAgentRule(agent, text4) {
|
|
14990
|
-
migrateFlowRules();
|
|
14991
|
-
if (!agentNames().includes(agent)) return { ok: false, error: notOnTheRoster(agent) };
|
|
14992
|
-
const rule = String(text4 ?? "").trim();
|
|
14993
|
-
try {
|
|
14994
|
-
if (!rule) {
|
|
14995
|
-
fs45.rmSync(rulePath(agent), { force: true });
|
|
14996
|
-
return { ok: true };
|
|
14997
|
-
}
|
|
14998
|
-
fs45.mkdirSync(RULES, { recursive: true });
|
|
14999
|
-
fs45.writeFileSync(rulePath(agent), `${rule}
|
|
15000
|
-
`);
|
|
15001
|
-
return { ok: true };
|
|
15002
|
-
} catch (err) {
|
|
15003
|
-
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
15004
|
-
}
|
|
15005
|
-
}
|
|
15006
14989
|
function deliveryRules(workflow) {
|
|
15007
14990
|
migrateFlowRules();
|
|
15008
14991
|
const rules = {};
|
|
@@ -15105,7 +15088,7 @@ function adoptRenamedRules() {
|
|
|
15105
15088
|
}
|
|
15106
15089
|
}
|
|
15107
15090
|
}
|
|
15108
|
-
var rulePath,
|
|
15091
|
+
var rulePath, flowForRequest, ruleOwnerSays, said, RENAMED_ROLES;
|
|
15109
15092
|
var init_rules2 = __esm({
|
|
15110
15093
|
"src/lib/agent/rules.ts"() {
|
|
15111
15094
|
"use strict";
|
|
@@ -15117,7 +15100,6 @@ var init_rules2 = __esm({
|
|
|
15117
15100
|
init_workflows();
|
|
15118
15101
|
init_types();
|
|
15119
15102
|
rulePath = (agent) => path47.join(RULES, `${agent}.md`);
|
|
15120
|
-
notOnTheRoster = (name) => `"${name}" is not an agent on this board. It has: ${agentNames().join(", ")}.`;
|
|
15121
15103
|
flowForRequest = (req) => req.refineRound !== void 0 && REFINE_ACTIONS.has(req.action) ? flowByCommand("refine") : flowByAction(req.action);
|
|
15122
15104
|
ruleOwnerSays = (owner) => `\`${owner.name}\` agent carries one rule of its own${owner.role ? ", on every flow it runs" : ""}`;
|
|
15123
15105
|
said = (owner, rule) => owner && rule ? [
|
|
@@ -15657,7 +15639,7 @@ var init_pictures = __esm({
|
|
|
15657
15639
|
var Asset_default;
|
|
15658
15640
|
var init_Asset = __esm({
|
|
15659
15641
|
"src/components/Asset.md"() {
|
|
15660
|
-
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';
|
|
15642
|
+
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';
|
|
15661
15643
|
}
|
|
15662
15644
|
});
|
|
15663
15645
|
|
|
@@ -15669,6 +15651,14 @@ var init_Compare = __esm({
|
|
|
15669
15651
|
}
|
|
15670
15652
|
});
|
|
15671
15653
|
|
|
15654
|
+
// src/components/Set.md
|
|
15655
|
+
var Set_default;
|
|
15656
|
+
var init_Set = __esm({
|
|
15657
|
+
"src/components/Set.md"() {
|
|
15658
|
+
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';
|
|
15659
|
+
}
|
|
15660
|
+
});
|
|
15661
|
+
|
|
15672
15662
|
// src/components/Storyboard.md
|
|
15673
15663
|
var Storyboard_default;
|
|
15674
15664
|
var init_Storyboard = __esm({
|
|
@@ -15725,6 +15715,7 @@ var init_components = __esm({
|
|
|
15725
15715
|
"use strict";
|
|
15726
15716
|
init_Asset();
|
|
15727
15717
|
init_Compare();
|
|
15718
|
+
init_Set();
|
|
15728
15719
|
init_Storyboard();
|
|
15729
15720
|
init_Workflow();
|
|
15730
15721
|
init_shared();
|
|
@@ -15732,7 +15723,7 @@ var init_components = __esm({
|
|
|
15732
15723
|
init_io();
|
|
15733
15724
|
init_paths();
|
|
15734
15725
|
init_workflows();
|
|
15735
|
-
DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default, Workflow: Workflow_default };
|
|
15726
|
+
DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default, Set: Set_default, Workflow: Workflow_default };
|
|
15736
15727
|
componentDocsText = (docs) => docs.length ? [shared_default, ...docs.map((doc) => doc.text)].map((text4) => text4.trim()).join("\n\n") : "";
|
|
15737
15728
|
}
|
|
15738
15729
|
});
|
|
@@ -18514,14 +18505,14 @@ function collect(body, card, host2) {
|
|
|
18514
18505
|
const active2 = /* @__PURE__ */ new Set();
|
|
18515
18506
|
const out = [];
|
|
18516
18507
|
const visit = (src, types, owner) => {
|
|
18517
|
-
const
|
|
18508
|
+
const path84 = src.replace(/[?#].*$/, "");
|
|
18518
18509
|
let resolved2;
|
|
18519
18510
|
try {
|
|
18520
|
-
resolved2 = host2.resolve(
|
|
18511
|
+
resolved2 = host2.resolve(path84, owner);
|
|
18521
18512
|
} catch (error) {
|
|
18522
18513
|
if (owner !== card) return { key: null, error: why(error) };
|
|
18523
18514
|
if (!nodes.has(src)) {
|
|
18524
|
-
const node2 = { key: src, file: null, kind: kindAt(
|
|
18515
|
+
const node2 = { key: src, file: null, kind: kindAt(path84, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
18525
18516
|
nodes.set(src, node2);
|
|
18526
18517
|
out.push(node2);
|
|
18527
18518
|
}
|
|
@@ -18811,6 +18802,7 @@ function validateSpec(file, text4, id) {
|
|
|
18811
18802
|
const markers = [];
|
|
18812
18803
|
const { visible, fence, comment } = scanCardLines(lines, end2 + 1);
|
|
18813
18804
|
const acceptance = [];
|
|
18805
|
+
const sets = /* @__PURE__ */ new Set();
|
|
18814
18806
|
for (let i = end2 + 1; i < lines.length; i++) {
|
|
18815
18807
|
const line = visible[i];
|
|
18816
18808
|
if (/^\s*<!--\s*agent\s*-->\s*$/.test(line)) {
|
|
@@ -18822,8 +18814,16 @@ function validateSpec(file, text4, id) {
|
|
|
18822
18814
|
const heading = line.match(/^ {0,3}(#{1,2})\s+(.+?)\s*#*\s*$/);
|
|
18823
18815
|
if (heading?.[1] === "#") add(i + 1, "heading", "Do not repeat the card title as an H1. Remove this heading or use ### inside your section.");
|
|
18824
18816
|
if (heading?.[1] === "##") headings.push({ title: heading[2], line: i + 1 });
|
|
18817
|
+
if (/^\s*<\/?Set\b/.test(line) && !sets.has(i)) {
|
|
18818
|
+
const close = /^\s*<Set\b/.test(line) ? setEnd(visible, i) : -1;
|
|
18819
|
+
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.');
|
|
18820
|
+
else {
|
|
18821
|
+
sets.add(i).add(close);
|
|
18822
|
+
if (!/\blabel="[^"]+"/.test(line)) add(i + 1, "set-label", 'Add a non-empty label="..." attribute to the Set tag.');
|
|
18823
|
+
}
|
|
18824
|
+
}
|
|
18825
18825
|
if (/^\s*<(?:Asset|Mockup)\b/.test(line)) {
|
|
18826
|
-
if (!/^\s*<(?:Asset|Mockup)\b[^<>]*\/>\s*$/.test(line) || lines[i - 1]?.trim() &&
|
|
18826
|
+
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])) {
|
|
18827
18827
|
add(i + 1, "mockup-block", "Put the self-closing <Asset ... /> tag on its own line, with blank lines separating it from prose.");
|
|
18828
18828
|
}
|
|
18829
18829
|
if (!/\bsrc="[^"]+"/.test(line) || !/\blabel="[^"]+"/.test(line)) add(i + 1, "mockup-attributes", 'Add non-empty src="..." and label="..." attributes to the Asset tag.');
|
|
@@ -18889,6 +18889,13 @@ function validateSpec(file, text4, id) {
|
|
|
18889
18889
|
if (id !== void 0) errors.push(...validateStoryboards(file, id, text4), ...validatePreviewFiles(file, id, text4));
|
|
18890
18890
|
return errors;
|
|
18891
18891
|
}
|
|
18892
|
+
function setEnd(lines, at) {
|
|
18893
|
+
if (!/^\s*<Set\b[^<>]*>\s*$/.test(lines[at]) || lines[at - 1]?.trim()) return -1;
|
|
18894
|
+
let i = at + 1;
|
|
18895
|
+
while (i < lines.length && ASSET_LINE.test(lines[i])) i++;
|
|
18896
|
+
if (i === at + 1 || !/^\s*<\/Set>\s*$/.test(lines[i] ?? "") || lines[i + 1]?.trim()) return -1;
|
|
18897
|
+
return i;
|
|
18898
|
+
}
|
|
18892
18899
|
function inside(dir, name) {
|
|
18893
18900
|
try {
|
|
18894
18901
|
const root2 = fs56.realpathSync(dir);
|
|
@@ -18986,7 +18993,7 @@ function validateStoryboards(file, id, text4) {
|
|
|
18986
18993
|
function formatContractErrors(errors) {
|
|
18987
18994
|
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");
|
|
18988
18995
|
}
|
|
18989
|
-
var
|
|
18996
|
+
var ASSET_LINE, BLOCK_LINE, boardCheckErrors, boardProblems;
|
|
18990
18997
|
var init_spec_contract = __esm({
|
|
18991
18998
|
"src/lib/spec-contract.ts"() {
|
|
18992
18999
|
"use strict";
|
|
@@ -18997,7 +19004,10 @@ var init_spec_contract = __esm({
|
|
|
18997
19004
|
init_storyboard();
|
|
18998
19005
|
init_preview_files();
|
|
18999
19006
|
init_validate();
|
|
19000
|
-
|
|
19007
|
+
ASSET_LINE = /^\s*<(?:Asset|Mockup)\b[^<>]*\/>\s*$/;
|
|
19008
|
+
BLOCK_LINE = /^\s*<(?:Asset\b|Mockup\b|Set\b|\/Set>)/;
|
|
19009
|
+
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");
|
|
19010
|
+
boardProblems = (errors) => ["Board problems:", ...errors.map((e) => `- ${e.message}`)].join("\n");
|
|
19001
19011
|
}
|
|
19002
19012
|
});
|
|
19003
19013
|
|
|
@@ -21243,43 +21253,6 @@ var init_memory_file = __esm({
|
|
|
21243
21253
|
}
|
|
21244
21254
|
});
|
|
21245
21255
|
|
|
21246
|
-
// src/commands/rule.ts
|
|
21247
|
-
import fs70 from "node:fs";
|
|
21248
|
-
import path71 from "node:path";
|
|
21249
|
-
function cmdRule(askedName, flags) {
|
|
21250
|
-
const agent = askedName.trim();
|
|
21251
|
-
if (!agentRoster().some((a) => a.name === agent)) {
|
|
21252
|
-
die(notOnTheRoster(askedName), { kind: "no-such-agent", agent: askedName });
|
|
21253
|
-
}
|
|
21254
|
-
const rule = readRuleText(flags.file, flags.text);
|
|
21255
|
-
const res = setAgentRule(agent, rule);
|
|
21256
|
-
if (!res.ok) die(res.error);
|
|
21257
|
-
const file = rel(path71.join(RULES, `${agent}.md`));
|
|
21258
|
-
say(rule ? `wrote the \`${agent}\` rule (${file})` : `cleared the \`${agent}\` rule`);
|
|
21259
|
-
return { agent, file, cleared: !rule };
|
|
21260
|
-
}
|
|
21261
|
-
function readRuleText(file, text4) {
|
|
21262
|
-
if (file !== void 0 && text4 !== void 0) die("pass --file or --text, not both");
|
|
21263
|
-
if (file !== void 0) {
|
|
21264
|
-
try {
|
|
21265
|
-
return fs70.readFileSync(file, "utf8").trim();
|
|
21266
|
-
} catch {
|
|
21267
|
-
die(`can't read ${file} \u2014 write the rule to a file, then pass its path`);
|
|
21268
|
-
}
|
|
21269
|
-
}
|
|
21270
|
-
if (text4 !== void 0) return text4.trim();
|
|
21271
|
-
die('the rule has to come from somewhere: --file <path>, --text "..." for a one-liner, or --text "" to clear it');
|
|
21272
|
-
}
|
|
21273
|
-
var init_rule = __esm({
|
|
21274
|
-
"src/commands/rule.ts"() {
|
|
21275
|
-
"use strict";
|
|
21276
|
-
init_io();
|
|
21277
|
-
init_paths();
|
|
21278
|
-
init_roles();
|
|
21279
|
-
init_rules2();
|
|
21280
|
-
}
|
|
21281
|
-
});
|
|
21282
|
-
|
|
21283
21256
|
// src/commands/validate.ts
|
|
21284
21257
|
function cmdValidate(id) {
|
|
21285
21258
|
const cards = [...snapshotSpecs()].filter(([, card]) => id === void 0 || card.id === id);
|
|
@@ -21473,7 +21446,6 @@ var init_local2 = __esm({
|
|
|
21473
21446
|
init_remove();
|
|
21474
21447
|
init_agent_file();
|
|
21475
21448
|
init_memory_file();
|
|
21476
|
-
init_rule();
|
|
21477
21449
|
init_validate2();
|
|
21478
21450
|
init_io();
|
|
21479
21451
|
init_lock();
|
|
@@ -21490,7 +21462,6 @@ var init_local2 = __esm({
|
|
|
21490
21462
|
list: ({ opts }) => cmdList(as(opts)),
|
|
21491
21463
|
archive: ({ args }) => cmdRemove(Number(args[0]), "completed"),
|
|
21492
21464
|
reject: ({ args, opts }) => cmdRemove(Number(args[0]), "rejected", as(opts)),
|
|
21493
|
-
rule: ({ args, opts }) => cmdRule(args[0] ?? "", as(opts)),
|
|
21494
21465
|
"agent-file": ({ args }) => cmdAgentFile(args[0] ?? "", args[1] ?? ""),
|
|
21495
21466
|
"memory-file": ({ args }) => cmdMemoryFile(args[0] ?? "")
|
|
21496
21467
|
};
|
|
@@ -21546,8 +21517,8 @@ var init_created_cards = __esm({
|
|
|
21546
21517
|
|
|
21547
21518
|
// src/lib/agent/creation.ts
|
|
21548
21519
|
import crypto4 from "node:crypto";
|
|
21549
|
-
import
|
|
21550
|
-
import
|
|
21520
|
+
import fs70 from "node:fs";
|
|
21521
|
+
import path71 from "node:path";
|
|
21551
21522
|
function creationError(error, triage) {
|
|
21552
21523
|
const zh = readLanguage() === "zh";
|
|
21553
21524
|
const messages = {
|
|
@@ -21573,12 +21544,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
|
|
|
21573
21544
|
function creationReceipt(request2, slot) {
|
|
21574
21545
|
const hash2 = crypto4.createHash("sha256").update(`${request2}
|
|
21575
21546
|
${slot}`).digest("hex");
|
|
21576
|
-
return
|
|
21547
|
+
return path71.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
|
|
21577
21548
|
}
|
|
21578
21549
|
function readCreation(file, said2) {
|
|
21579
21550
|
return withCreationLock(() => {
|
|
21580
21551
|
try {
|
|
21581
|
-
const held4 = JSON.parse(
|
|
21552
|
+
const held4 = JSON.parse(fs70.readFileSync(file, "utf8"));
|
|
21582
21553
|
if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
|
|
21583
21554
|
return held4;
|
|
21584
21555
|
} catch (error) {
|
|
@@ -21590,10 +21561,10 @@ function readCreation(file, said2) {
|
|
|
21590
21561
|
});
|
|
21591
21562
|
}
|
|
21592
21563
|
function saveCreation(file, journal) {
|
|
21593
|
-
|
|
21564
|
+
fs70.mkdirSync(path71.dirname(file), { recursive: true });
|
|
21594
21565
|
const temp = `${file}.${crypto4.randomUUID()}.tmp`;
|
|
21595
|
-
|
|
21596
|
-
|
|
21566
|
+
fs70.writeFileSync(temp, JSON.stringify(journal));
|
|
21567
|
+
fs70.renameSync(temp, file);
|
|
21597
21568
|
}
|
|
21598
21569
|
function archiveCreation(source, id) {
|
|
21599
21570
|
if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
|
|
@@ -21607,7 +21578,7 @@ function archiveCreation(source, id) {
|
|
|
21607
21578
|
function triageFile(sourceId) {
|
|
21608
21579
|
const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
|
|
21609
21580
|
if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
|
|
21610
|
-
return
|
|
21581
|
+
return path71.basename(found2.relPath, ".md");
|
|
21611
21582
|
}
|
|
21612
21583
|
var init_creation = __esm({
|
|
21613
21584
|
"src/lib/agent/creation.ts"() {
|
|
@@ -21775,8 +21746,8 @@ __export(board_exports, {
|
|
|
21775
21746
|
buildBoardProgram: () => buildBoardProgram
|
|
21776
21747
|
});
|
|
21777
21748
|
import crypto5 from "node:crypto";
|
|
21778
|
-
import
|
|
21779
|
-
import
|
|
21749
|
+
import fs71 from "node:fs";
|
|
21750
|
+
import path72 from "node:path";
|
|
21780
21751
|
async function dispatch(move, cmd, args, opts, cli) {
|
|
21781
21752
|
const ctx = ctxOf(cmd, cli.program);
|
|
21782
21753
|
const data = await runAction(ctx, {}, async () => {
|
|
@@ -21816,7 +21787,7 @@ async function cloudCard(task, opts) {
|
|
|
21816
21787
|
let request2;
|
|
21817
21788
|
if (typeof opts.bodyFile === "string") {
|
|
21818
21789
|
try {
|
|
21819
|
-
request2 =
|
|
21790
|
+
request2 = fs71.readFileSync(opts.bodyFile, "utf8");
|
|
21820
21791
|
} catch {
|
|
21821
21792
|
}
|
|
21822
21793
|
}
|
|
@@ -21846,7 +21817,7 @@ async function cloudCard(task, opts) {
|
|
|
21846
21817
|
const file = creationReceipt(`${checked.value}:${requestId}`, slot);
|
|
21847
21818
|
const journal = readCreation(file, said2);
|
|
21848
21819
|
if (!journal.made) {
|
|
21849
|
-
const key = `akb-${
|
|
21820
|
+
const key = `akb-${path72.basename(file, ".json").slice(0, 40)}`;
|
|
21850
21821
|
const made = await createProjectTask(checked.value, journal.said, key);
|
|
21851
21822
|
if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
|
|
21852
21823
|
journal.made = made.value;
|
|
@@ -21896,11 +21867,6 @@ function buildBoardProgram(cli) {
|
|
|
21896
21867
|
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) {
|
|
21897
21868
|
await dispatch("validate", this, id === void 0 ? [] : [String(id)], this.opts(), cli);
|
|
21898
21869
|
});
|
|
21899
|
-
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(
|
|
21900
|
-
"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."
|
|
21901
|
-
).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) {
|
|
21902
|
-
await dispatch("rule", this, [agent], this.opts(), cli);
|
|
21903
|
-
});
|
|
21904
21870
|
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(
|
|
21905
21871
|
"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."
|
|
21906
21872
|
).action(async function(agent, file) {
|
|
@@ -21979,17 +21945,17 @@ var init_board2 = __esm({
|
|
|
21979
21945
|
});
|
|
21980
21946
|
|
|
21981
21947
|
// src/lib/board-cli.ts
|
|
21982
|
-
import
|
|
21983
|
-
import
|
|
21948
|
+
import fs72 from "node:fs";
|
|
21949
|
+
import path73 from "node:path";
|
|
21984
21950
|
function useBoard(found2, dirNamed) {
|
|
21985
|
-
if (!found2.named && found2.board ===
|
|
21951
|
+
if (!found2.named && found2.board === path73.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
21986
21952
|
else setBoardDir(found2.board, found2.root);
|
|
21987
21953
|
useProjectState();
|
|
21988
21954
|
backfillCardWorkflows();
|
|
21989
21955
|
}
|
|
21990
21956
|
function whole(found2, move) {
|
|
21991
21957
|
if (move === MAKES_A_BOARD) return found2;
|
|
21992
|
-
if (!
|
|
21958
|
+
if (!fs72.existsSync(path73.join(found2.board, "todo"))) {
|
|
21993
21959
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
21994
21960
|
kind: "board-incomplete",
|
|
21995
21961
|
dir: found2.root
|
|
@@ -21998,13 +21964,13 @@ function whole(found2, move) {
|
|
|
21998
21964
|
return found2;
|
|
21999
21965
|
}
|
|
22000
21966
|
function findBoardUpward(from, move) {
|
|
22001
|
-
let dir =
|
|
21967
|
+
let dir = path73.resolve(from);
|
|
22002
21968
|
for (; ; ) {
|
|
22003
|
-
if (hasBoard(dir)) return { root: dir, board:
|
|
21969
|
+
if (hasBoard(dir)) return { root: dir, board: path73.join(dir, "docs", "kanban") };
|
|
22004
21970
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
22005
|
-
const kept2 =
|
|
22006
|
-
if (move !== MAKES_A_BOARD &&
|
|
22007
|
-
const up =
|
|
21971
|
+
const kept2 = path73.join(dir, ".akb", "kanban");
|
|
21972
|
+
if (move !== MAKES_A_BOARD && fs72.existsSync(path73.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
21973
|
+
const up = path73.dirname(dir);
|
|
22008
21974
|
if (up === dir) return null;
|
|
22009
21975
|
dir = up;
|
|
22010
21976
|
}
|
|
@@ -22012,11 +21978,11 @@ function findBoardUpward(from, move) {
|
|
|
22012
21978
|
function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
22013
21979
|
const named2 = board2 ?? boardFromEnv();
|
|
22014
21980
|
if (named2) {
|
|
22015
|
-
const folder =
|
|
22016
|
-
if (!
|
|
21981
|
+
const folder = path73.resolve(cwd, named2);
|
|
21982
|
+
if (!fs72.existsSync(folder) && move !== MAKES_A_BOARD) {
|
|
22017
21983
|
die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
|
|
22018
21984
|
}
|
|
22019
|
-
if (
|
|
21985
|
+
if (fs72.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
|
|
22020
21986
|
die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
|
|
22021
21987
|
kind: "no-board",
|
|
22022
21988
|
dir: folder
|
|
@@ -22025,24 +21991,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
22025
21991
|
return { root: projectRootOf(folder), board: folder, named: true };
|
|
22026
21992
|
}
|
|
22027
21993
|
if (dir !== null) {
|
|
22028
|
-
const root2 =
|
|
22029
|
-
if (!
|
|
22030
|
-
const kept2 =
|
|
22031
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD &&
|
|
21994
|
+
const root2 = path73.resolve(dir);
|
|
21995
|
+
if (!fs72.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
21996
|
+
const kept2 = path73.join(root2, ".akb", "kanban");
|
|
21997
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs72.existsSync(path73.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
22032
21998
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
22033
21999
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
22034
22000
|
kind: "no-board",
|
|
22035
22001
|
dir: root2
|
|
22036
22002
|
});
|
|
22037
22003
|
}
|
|
22038
|
-
return whole({ root: root2, board:
|
|
22004
|
+
return whole({ root: root2, board: path73.join(root2, "docs", "kanban") }, move);
|
|
22039
22005
|
}
|
|
22040
22006
|
const found2 = findBoardUpward(cwd, move);
|
|
22041
22007
|
if (found2) return whole(found2, move);
|
|
22042
|
-
if (move === MAKES_A_BOARD) return { root:
|
|
22008
|
+
if (move === MAKES_A_BOARD) return { root: path73.resolve(cwd), board: path73.join(path73.resolve(cwd), "docs", "kanban") };
|
|
22043
22009
|
die(
|
|
22044
|
-
`no board here. Looked in ${
|
|
22045
|
-
{ kind: "no-board", dir:
|
|
22010
|
+
`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`,
|
|
22011
|
+
{ kind: "no-board", dir: path73.resolve(cwd) }
|
|
22046
22012
|
);
|
|
22047
22013
|
}
|
|
22048
22014
|
function editDistance(a, b) {
|
|
@@ -22125,8 +22091,8 @@ var init_board_cli = __esm({
|
|
|
22125
22091
|
init_pointer();
|
|
22126
22092
|
init_card_workflow_backfill();
|
|
22127
22093
|
MAKES_A_BOARD = "init";
|
|
22128
|
-
hasBoard = (dir) =>
|
|
22129
|
-
isBoardDir = (dir) =>
|
|
22094
|
+
hasBoard = (dir) => fs72.existsSync(path73.join(dir, "docs", "kanban"));
|
|
22095
|
+
isBoardDir = (dir) => fs72.existsSync(path73.join(dir, "todo")) && fs72.existsSync(path73.join(dir, "config.md"));
|
|
22130
22096
|
boardFromEnv = () => {
|
|
22131
22097
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
22132
22098
|
return named2 ? named2 : null;
|
|
@@ -22362,8 +22328,8 @@ var init_agent = __esm({
|
|
|
22362
22328
|
|
|
22363
22329
|
// src/commands/cloud-template.ts
|
|
22364
22330
|
import { createHash as createHash5 } from "node:crypto";
|
|
22365
|
-
import
|
|
22366
|
-
import
|
|
22331
|
+
import fs73 from "node:fs";
|
|
22332
|
+
import path74 from "node:path";
|
|
22367
22333
|
function usage2(problem, line) {
|
|
22368
22334
|
die(`${problem}
|
|
22369
22335
|
usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
|
|
@@ -22440,10 +22406,10 @@ This template has no preview.`);
|
|
|
22440
22406
|
const written = [];
|
|
22441
22407
|
for (const p of previews) {
|
|
22442
22408
|
const bytes2 = Buffer.from(await (await ask(`/${at}/previews/${route(p.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
22443
|
-
const file =
|
|
22444
|
-
const out =
|
|
22445
|
-
|
|
22446
|
-
|
|
22409
|
+
const file = path74.basename(p.path);
|
|
22410
|
+
const out = path74.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
|
|
22411
|
+
fs73.mkdirSync(opts.to, { recursive: true });
|
|
22412
|
+
fs73.writeFileSync(out, bytes2);
|
|
22447
22413
|
written.push(out);
|
|
22448
22414
|
say(out);
|
|
22449
22415
|
}
|
|
@@ -22456,15 +22422,15 @@ async function templateGet(name, opts, program2) {
|
|
|
22456
22422
|
const { template } = await asJson(await ask(`/${at}`, {}, WITHOUT));
|
|
22457
22423
|
const fetched = [];
|
|
22458
22424
|
for (const f of template.files) {
|
|
22459
|
-
const out =
|
|
22460
|
-
if (!out.startsWith(
|
|
22425
|
+
const out = path74.resolve(to, f.path);
|
|
22426
|
+
if (!out.startsWith(path74.resolve(to) + path74.sep)) refuse3(T.corrupt, WITHOUT);
|
|
22461
22427
|
const bytes2 = Buffer.from(await (await ask(`/${at}/files/${route(f.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
22462
22428
|
if (bytes2.byteLength !== f.size || createHash5("sha256").update(bytes2).digest("hex") !== f.sha256) {
|
|
22463
22429
|
refuse3(T.corrupt, WITHOUT);
|
|
22464
22430
|
}
|
|
22465
22431
|
fetched.push({ out, bytes: bytes2 });
|
|
22466
22432
|
}
|
|
22467
|
-
const taken = fetched.filter((f) =>
|
|
22433
|
+
const taken = fetched.filter((f) => fs73.existsSync(f.out)).map((f) => path74.relative(to, f.out));
|
|
22468
22434
|
if (taken.length > 0) {
|
|
22469
22435
|
refuse3({
|
|
22470
22436
|
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`,
|
|
@@ -22472,8 +22438,8 @@ async function templateGet(name, opts, program2) {
|
|
|
22472
22438
|
});
|
|
22473
22439
|
}
|
|
22474
22440
|
for (const f of fetched) {
|
|
22475
|
-
|
|
22476
|
-
|
|
22441
|
+
fs73.mkdirSync(path74.dirname(f.out), { recursive: true });
|
|
22442
|
+
fs73.writeFileSync(f.out, f.bytes);
|
|
22477
22443
|
}
|
|
22478
22444
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
22479
22445
|
Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
@@ -22490,25 +22456,25 @@ async function templateSource(name, opts) {
|
|
|
22490
22456
|
say(`evidence: ${e.path}`);
|
|
22491
22457
|
continue;
|
|
22492
22458
|
}
|
|
22493
|
-
const out =
|
|
22494
|
-
|
|
22495
|
-
|
|
22459
|
+
const out = path74.join(opts.to, `${name}-${path74.basename(e.path)}`);
|
|
22460
|
+
fs73.mkdirSync(opts.to, { recursive: true });
|
|
22461
|
+
fs73.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
|
|
22496
22462
|
written.push(out);
|
|
22497
22463
|
say(out);
|
|
22498
22464
|
}
|
|
22499
22465
|
return { name, source, evidence: written.length > 0 ? written : evidence.map((e) => e.path) };
|
|
22500
22466
|
}
|
|
22501
22467
|
async function templatePublish(dir, opts) {
|
|
22502
|
-
const root2 =
|
|
22503
|
-
const manifest =
|
|
22504
|
-
if (!
|
|
22505
|
-
const meta = readTemplateMeta(
|
|
22468
|
+
const root2 = path74.resolve(dir);
|
|
22469
|
+
const manifest = path74.join(root2, "template.md");
|
|
22470
|
+
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.");
|
|
22471
|
+
const meta = readTemplateMeta(fs73.readFileSync(manifest, "utf8"));
|
|
22506
22472
|
const files = walk2(root2);
|
|
22507
|
-
const total = files.reduce((sum, f) => sum +
|
|
22473
|
+
const total = files.reduce((sum, f) => sum + fs73.statSync(path74.join(root2, f)).size, 0);
|
|
22508
22474
|
if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
22509
22475
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
22510
|
-
if (!
|
|
22511
|
-
if (
|
|
22476
|
+
if (!fs73.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
22477
|
+
if (path74.resolve(extra).startsWith(root2 + path74.sep)) {
|
|
22512
22478
|
invalid(
|
|
22513
22479
|
`${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`,
|
|
22514
22480
|
`${extra} is inside the template folder; keep previews and evidence outside it.`
|
|
@@ -22520,10 +22486,10 @@ async function templatePublish(dir, opts) {
|
|
|
22520
22486
|
}
|
|
22521
22487
|
const form = new FormData();
|
|
22522
22488
|
form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
|
|
22523
|
-
const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([
|
|
22524
|
-
for (const f of files) add("files", f,
|
|
22525
|
-
for (const f of opts.preview) add("previews",
|
|
22526
|
-
for (const f of opts.evidence) add("evidence",
|
|
22489
|
+
const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs73.readFileSync(file)]), path74.basename(name));
|
|
22490
|
+
for (const f of files) add("files", f, path74.join(root2, f));
|
|
22491
|
+
for (const f of opts.preview) add("previews", path74.basename(f), f);
|
|
22492
|
+
for (const f of opts.evidence) add("evidence", path74.basename(f), f);
|
|
22527
22493
|
const done2 = await asJson(await ask("", { method: "POST", body: form }));
|
|
22528
22494
|
say(
|
|
22529
22495
|
done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -22539,11 +22505,11 @@ Deleted ${name} from the catalog.`);
|
|
|
22539
22505
|
return { name, deleted: true };
|
|
22540
22506
|
}
|
|
22541
22507
|
async function templateShowcase(name, dir) {
|
|
22542
|
-
const file =
|
|
22543
|
-
if (!
|
|
22508
|
+
const file = path74.join(dir, "showcase.json");
|
|
22509
|
+
if (!fs73.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
22544
22510
|
let meta;
|
|
22545
22511
|
try {
|
|
22546
|
-
meta = JSON.parse(
|
|
22512
|
+
meta = JSON.parse(fs73.readFileSync(file, "utf8"));
|
|
22547
22513
|
} catch {
|
|
22548
22514
|
return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
|
|
22549
22515
|
}
|
|
@@ -22555,9 +22521,9 @@ async function templateShowcase(name, dir) {
|
|
|
22555
22521
|
const form = new FormData();
|
|
22556
22522
|
form.set("meta", JSON.stringify(meta));
|
|
22557
22523
|
for (const p of new Set(named2)) {
|
|
22558
|
-
const at =
|
|
22559
|
-
if (!
|
|
22560
|
-
form.append(`media:${p}`, new Blob([
|
|
22524
|
+
const at = path74.join(dir, p);
|
|
22525
|
+
if (!fs73.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
|
|
22526
|
+
form.append(`media:${p}`, new Blob([fs73.readFileSync(at)]), p);
|
|
22561
22527
|
}
|
|
22562
22528
|
const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
|
|
22563
22529
|
say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -22566,7 +22532,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
|
|
|
22566
22532
|
}
|
|
22567
22533
|
function walk2(root2, sub = "") {
|
|
22568
22534
|
const out = [];
|
|
22569
|
-
for (const entry of
|
|
22535
|
+
for (const entry of fs73.readdirSync(path74.join(root2, sub), { withFileTypes: true })) {
|
|
22570
22536
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
22571
22537
|
const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
22572
22538
|
if (entry.isDirectory()) out.push(...walk2(root2, rel2));
|
|
@@ -22751,7 +22717,7 @@ var init_archive2 = __esm({
|
|
|
22751
22717
|
var board_default;
|
|
22752
22718
|
var init_board3 = __esm({
|
|
22753
22719
|
"src/guide/board.md"() {
|
|
22754
|
-
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
|
|
22720
|
+
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";
|
|
22755
22721
|
}
|
|
22756
22722
|
});
|
|
22757
22723
|
|
|
@@ -22767,7 +22733,7 @@ var init_card_chat = __esm({
|
|
|
22767
22733
|
var update_workflow_default;
|
|
22768
22734
|
var init_update_workflow = __esm({
|
|
22769
22735
|
"src/guide/update-workflow.md"() {
|
|
22770
|
-
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**:
|
|
22736
|
+
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";
|
|
22771
22737
|
}
|
|
22772
22738
|
});
|
|
22773
22739
|
|
|
@@ -22895,7 +22861,7 @@ var init_troubleshoot = __esm({
|
|
|
22895
22861
|
var write_agent_default;
|
|
22896
22862
|
var init_write_agent = __esm({
|
|
22897
22863
|
"src/guide/write-agent.md"() {
|
|
22898
|
-
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";
|
|
22864
|
+
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";
|
|
22899
22865
|
}
|
|
22900
22866
|
});
|
|
22901
22867
|
|
|
@@ -23018,8 +22984,8 @@ var init_guide2 = __esm({
|
|
|
23018
22984
|
});
|
|
23019
22985
|
|
|
23020
22986
|
// src/commands/workflow.ts
|
|
23021
|
-
import
|
|
23022
|
-
import
|
|
22987
|
+
import fs74 from "node:fs";
|
|
22988
|
+
import path75 from "node:path";
|
|
23023
22989
|
function cmdWorkflowList() {
|
|
23024
22990
|
if (!workflowsReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
|
|
23025
22991
|
const offline2 = workflowsOffline();
|
|
@@ -23060,9 +23026,9 @@ function cmdWorkflowDiagram(id, card) {
|
|
|
23060
23026
|
const agent = findSpecAgent(name);
|
|
23061
23027
|
return agent ? { ...agent, after: agentAfter(name) } : null;
|
|
23062
23028
|
});
|
|
23063
|
-
const file =
|
|
23064
|
-
|
|
23065
|
-
|
|
23029
|
+
const file = path75.join(ASSETS, String(cardId2), "workflow.json");
|
|
23030
|
+
fs74.mkdirSync(path75.dirname(file), { recursive: true });
|
|
23031
|
+
fs74.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
|
|
23066
23032
|
`);
|
|
23067
23033
|
const tag = `<Workflow src=".assets/${cardId2}/workflow.json" label="${flow.name.replace(/"/g, "")}" />`;
|
|
23068
23034
|
say(tag);
|
|
@@ -23071,26 +23037,26 @@ function cmdWorkflowDiagram(id, card) {
|
|
|
23071
23037
|
async function cmdWorkflowPull(id, folder) {
|
|
23072
23038
|
const cloudId = cloudIdOf(id);
|
|
23073
23039
|
if (!cloudId) found(id);
|
|
23074
|
-
const dir =
|
|
23075
|
-
if (
|
|
23040
|
+
const dir = path75.resolve(folder ?? id);
|
|
23041
|
+
if (fs74.existsSync(dir) && fs74.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
|
|
23076
23042
|
const read3 = await call("GET", `/v1/workflows/${encodeURIComponent(cloudId)}`);
|
|
23077
23043
|
if (!read3.ok) die(read3.error, read3.code === "not_found" ? "no-such-workflow" : "cloud-refused");
|
|
23078
23044
|
const { version, files } = read3.value;
|
|
23079
23045
|
for (const [file, text4] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version) })) {
|
|
23080
|
-
const full =
|
|
23081
|
-
|
|
23046
|
+
const full = path75.join(dir, ...file.split("/"));
|
|
23047
|
+
fs74.mkdirSync(path75.dirname(full), { recursive: true });
|
|
23082
23048
|
const data = isAboutFile(file) && !file.endsWith(".md") && /^data:[^;]+;base64,/.exec(text4);
|
|
23083
|
-
|
|
23049
|
+
fs74.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
|
|
23084
23050
|
}
|
|
23085
23051
|
const shown = folder ?? `./${id}`;
|
|
23086
23052
|
say(`Pulled ${id} v${version} into ${shown}.`);
|
|
23087
23053
|
return { id, version, folder: dir };
|
|
23088
23054
|
}
|
|
23089
23055
|
async function cmdWorkflowPush(folder, opts) {
|
|
23090
|
-
const dir =
|
|
23056
|
+
const dir = path75.resolve(folder);
|
|
23091
23057
|
let pulled = null;
|
|
23092
23058
|
try {
|
|
23093
|
-
pulled = JSON.parse(
|
|
23059
|
+
pulled = JSON.parse(fs74.readFileSync(path75.join(dir, VERSION_FILE), "utf8"));
|
|
23094
23060
|
} catch {
|
|
23095
23061
|
}
|
|
23096
23062
|
if (!pulled?.id || !Number.isInteger(pulled.version)) die(`${folder} was not written by \`akb workflow pull\``, "bad-args");
|
|
@@ -23118,11 +23084,69 @@ async function cmdWorkflowPush(folder, opts) {
|
|
|
23118
23084
|
die(res.error, res.code === "bad_request" || res.code === "payload_too_large" ? "bad-workflow" : "cloud-refused");
|
|
23119
23085
|
}
|
|
23120
23086
|
const next = res.value.version;
|
|
23121
|
-
|
|
23087
|
+
fs74.writeFileSync(path75.join(dir, VERSION_FILE), versionText(cloudId, next));
|
|
23122
23088
|
say(`Pushed ${id} v${next}. New tasks take it.`);
|
|
23123
23089
|
return { id, version: next, changed: true };
|
|
23124
23090
|
}
|
|
23125
|
-
|
|
23091
|
+
function noteText(what, { file, text: text4 }) {
|
|
23092
|
+
if (file !== void 0 && text4 !== void 0) die("pass --file or --text, not both", "bad-args");
|
|
23093
|
+
if (file !== void 0) {
|
|
23094
|
+
try {
|
|
23095
|
+
return fs74.readFileSync(file, "utf8").trim();
|
|
23096
|
+
} catch {
|
|
23097
|
+
die(`can't read ${file}`, "bad-args");
|
|
23098
|
+
}
|
|
23099
|
+
}
|
|
23100
|
+
if (text4 !== void 0) return text4.trim();
|
|
23101
|
+
die(`the ${what} have to come from --text or --file`, "bad-args");
|
|
23102
|
+
}
|
|
23103
|
+
function cloudOk(res) {
|
|
23104
|
+
if (!res.ok) die(res.error, res.code === "unauthenticated" ? "needs-cloud" : "cloud-refused");
|
|
23105
|
+
return res.value;
|
|
23106
|
+
}
|
|
23107
|
+
async function cloudScope() {
|
|
23108
|
+
const project2 = boardProject();
|
|
23109
|
+
if (!project2) die("This board is not linked to a Cloud project.", "needs-cloud");
|
|
23110
|
+
const held4 = cloudOk(await call("GET", `/v1/projects/${enc2(project2)}`));
|
|
23111
|
+
return { project: project2, workspace: held4.workspace };
|
|
23112
|
+
}
|
|
23113
|
+
async function cmdWorkflowRule(name, opts) {
|
|
23114
|
+
const rule = noteText("rules", opts);
|
|
23115
|
+
const { workspace: workspace2 } = await cloudScope();
|
|
23116
|
+
const held4 = cloudOk(await call("GET", `/v1/workspaces/${enc2(workspace2)}/workflow-rules`));
|
|
23117
|
+
const flow = held4.workflows.find((w) => workflowName(w.id) === name);
|
|
23118
|
+
if (!flow) {
|
|
23119
|
+
die(`no workflow called "${name}" here. There are: ${held4.workflows.map((w) => workflowName(w.id)).join(", ")}.`, {
|
|
23120
|
+
kind: "no-such-workflow",
|
|
23121
|
+
workflow: name
|
|
23122
|
+
});
|
|
23123
|
+
}
|
|
23124
|
+
cloudOk(await call("PUT", `/v1/workspaces/${enc2(workspace2)}/workflows/${enc2(flow.id)}/rule`, { rule }));
|
|
23125
|
+
say(`${rule ? "saved" : "cleared"} the rules of ${name}`);
|
|
23126
|
+
return { workflow: name, rule };
|
|
23127
|
+
}
|
|
23128
|
+
async function cmdWorkflowInstructions(agent, opts) {
|
|
23129
|
+
const rule = noteText("instructions", opts);
|
|
23130
|
+
const { project: project2, workspace: workspace2 } = await cloudScope();
|
|
23131
|
+
const [shared, own] = await Promise.all([
|
|
23132
|
+
call("GET", `/v1/workspaces/${enc2(workspace2)}/workflow-rules`),
|
|
23133
|
+
call("GET", `/v1/projects/${enc2(project2)}/agents`)
|
|
23134
|
+
]);
|
|
23135
|
+
const flowAgents = cloudOk(shared).data.map((a) => a.agent);
|
|
23136
|
+
const board2 = cloudOk(own).board;
|
|
23137
|
+
const scope = board2.includes(agent) ? "project" : flowAgents.includes(agent) ? "workspace" : null;
|
|
23138
|
+
if (!scope) {
|
|
23139
|
+
die(`no agent called "${agent}" here. There are: ${[.../* @__PURE__ */ new Set([...flowAgents, ...board2])].join(", ")}.`, {
|
|
23140
|
+
kind: "no-such-agent",
|
|
23141
|
+
agent
|
|
23142
|
+
});
|
|
23143
|
+
}
|
|
23144
|
+
const route2 = scope === "project" ? `/v1/projects/${enc2(project2)}/agents/${enc2(agent)}` : `/v1/workspaces/${enc2(workspace2)}/agents/${enc2(agent)}`;
|
|
23145
|
+
cloudOk(await call("PUT", route2, { rule }));
|
|
23146
|
+
say(rule ? `saved ${agent}'s instructions (${scope === "project" ? "this project" : "every project"})` : `cleared ${agent}'s instructions`);
|
|
23147
|
+
return { agent, rule, scope };
|
|
23148
|
+
}
|
|
23149
|
+
var found, done, names2, previewNames, cloudIdOf, enc2;
|
|
23126
23150
|
var init_workflow2 = __esm({
|
|
23127
23151
|
"src/commands/workflow.ts"() {
|
|
23128
23152
|
"use strict";
|
|
@@ -23153,6 +23177,7 @@ var init_workflow2 = __esm({
|
|
|
23153
23177
|
names2 = (rows) => rows.map((h) => `${h.agent}${h.off ? " (off)" : ""}`).join(", ");
|
|
23154
23178
|
previewNames = (rows) => rows.map((h) => `${names2([h])}${agentAfter(h.agent).length ? ` (after ${agentAfter(h.agent).join(", ")})` : ""}`).join(", ");
|
|
23155
23179
|
cloudIdOf = (id) => cloudFlows().find((f) => workflowName(f.cloudId) === id)?.cloudId;
|
|
23180
|
+
enc2 = encodeURIComponent;
|
|
23156
23181
|
}
|
|
23157
23182
|
});
|
|
23158
23183
|
|
|
@@ -23280,8 +23305,8 @@ var init_complete = __esm({
|
|
|
23280
23305
|
});
|
|
23281
23306
|
|
|
23282
23307
|
// src/lib/agent/approve.ts
|
|
23283
|
-
import
|
|
23284
|
-
import
|
|
23308
|
+
import fs75 from "node:fs";
|
|
23309
|
+
import path76 from "node:path";
|
|
23285
23310
|
function approvalRequest(req) {
|
|
23286
23311
|
const id = req.id;
|
|
23287
23312
|
const card = id === void 0 ? null : findCard(id);
|
|
@@ -23299,12 +23324,12 @@ function advancePhase(id) {
|
|
|
23299
23324
|
const card = findCard(id);
|
|
23300
23325
|
const found2 = locate(id);
|
|
23301
23326
|
if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
|
|
23302
|
-
const file = found2.kind === "group" ?
|
|
23303
|
-
const { meta, body } = parseFrontmatter(
|
|
23327
|
+
const file = found2.kind === "group" ? path76.join(found2.target, "root.md") : found2.target;
|
|
23328
|
+
const { meta, body } = parseFrontmatter(fs75.readFileSync(file, "utf8"));
|
|
23304
23329
|
if (!meta) return { error: `#${id} has no frontmatter` };
|
|
23305
23330
|
meta.phase = card.stage + 1;
|
|
23306
23331
|
meta.status = "todo";
|
|
23307
|
-
|
|
23332
|
+
fs75.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
23308
23333
|
return null;
|
|
23309
23334
|
}
|
|
23310
23335
|
var init_approve = __esm({
|
|
@@ -23427,16 +23452,16 @@ var init_start = __esm({
|
|
|
23427
23452
|
});
|
|
23428
23453
|
|
|
23429
23454
|
// src/lib/agent/task-chats.ts
|
|
23430
|
-
import
|
|
23431
|
-
import
|
|
23455
|
+
import fs76 from "node:fs";
|
|
23456
|
+
import path77 from "node:path";
|
|
23432
23457
|
function taskChatFile(task, home3) {
|
|
23433
23458
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
23434
|
-
return
|
|
23459
|
+
return path77.join(taskChatsDir(home3), `${task}.jsonl`);
|
|
23435
23460
|
}
|
|
23436
23461
|
function readTaskChat(task, home3) {
|
|
23437
23462
|
let text4;
|
|
23438
23463
|
try {
|
|
23439
|
-
text4 =
|
|
23464
|
+
text4 = fs76.readFileSync(taskChatFile(task, home3), "utf8");
|
|
23440
23465
|
} catch {
|
|
23441
23466
|
return [];
|
|
23442
23467
|
}
|
|
@@ -23457,13 +23482,13 @@ var init_task_chats = __esm({
|
|
|
23457
23482
|
"use strict";
|
|
23458
23483
|
init_home();
|
|
23459
23484
|
TASK = /^[\w-]{1,100}$/;
|
|
23460
|
-
taskChatsDir = (home3 = machineHome()) =>
|
|
23485
|
+
taskChatsDir = (home3 = machineHome()) => path77.join(home3, "chats");
|
|
23461
23486
|
}
|
|
23462
23487
|
});
|
|
23463
23488
|
|
|
23464
23489
|
// src/lib/agent/memory-review.ts
|
|
23465
|
-
import
|
|
23466
|
-
import
|
|
23490
|
+
import fs77 from "node:fs";
|
|
23491
|
+
import path78 from "node:path";
|
|
23467
23492
|
function taskChatsToReview(tasks) {
|
|
23468
23493
|
const out = [];
|
|
23469
23494
|
for (const ref of [...new Set(tasks)]) {
|
|
@@ -23485,8 +23510,8 @@ function readArchived2(id) {
|
|
|
23485
23510
|
const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
|
|
23486
23511
|
if (!found2) return null;
|
|
23487
23512
|
try {
|
|
23488
|
-
const file = found2.kind === "group" ?
|
|
23489
|
-
const { meta, body } = parseFrontmatter(
|
|
23513
|
+
const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
|
|
23514
|
+
const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
|
|
23490
23515
|
if (!meta) return null;
|
|
23491
23516
|
return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
|
|
23492
23517
|
} catch {
|
|
@@ -23555,17 +23580,17 @@ var init_memory_review = __esm({
|
|
|
23555
23580
|
});
|
|
23556
23581
|
|
|
23557
23582
|
// src/lib/agent/dismissal-review.ts
|
|
23558
|
-
import
|
|
23559
|
-
import
|
|
23583
|
+
import fs78 from "node:fs";
|
|
23584
|
+
import path79 from "node:path";
|
|
23560
23585
|
function rejectionsToReview() {
|
|
23561
|
-
const dir =
|
|
23562
|
-
if (!
|
|
23586
|
+
const dir = path79.join(ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
23587
|
+
if (!fs78.existsSync(dir)) return [];
|
|
23563
23588
|
const found2 = [];
|
|
23564
23589
|
for (const file of walkMd(dir)) {
|
|
23565
23590
|
const id = archivedId(file);
|
|
23566
23591
|
if (id === null) continue;
|
|
23567
23592
|
try {
|
|
23568
|
-
const { meta } = parseFrontmatter(
|
|
23593
|
+
const { meta } = parseFrontmatter(fs78.readFileSync(file, "utf8"));
|
|
23569
23594
|
if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
|
|
23570
23595
|
found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
|
|
23571
23596
|
} catch {
|
|
@@ -23595,7 +23620,7 @@ function citedSources(text4) {
|
|
|
23595
23620
|
function withdrawnSources() {
|
|
23596
23621
|
const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
|
|
23597
23622
|
try {
|
|
23598
|
-
return citedSources(
|
|
23623
|
+
return citedSources(fs78.readFileSync(file, "utf8"));
|
|
23599
23624
|
} catch {
|
|
23600
23625
|
return [];
|
|
23601
23626
|
}
|
|
@@ -23620,8 +23645,8 @@ var init_dismissal_review = __esm({
|
|
|
23620
23645
|
});
|
|
23621
23646
|
|
|
23622
23647
|
// src/lib/agent/flow.ts
|
|
23623
|
-
import
|
|
23624
|
-
import
|
|
23648
|
+
import fs79 from "node:fs";
|
|
23649
|
+
import path80 from "node:path";
|
|
23625
23650
|
function readCard2(id, home3 = "board") {
|
|
23626
23651
|
const pending = activeDelivery(id)?.completions?.some((c) => !c.finished);
|
|
23627
23652
|
const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
|
|
@@ -23631,10 +23656,10 @@ function readCard2(id, home3 = "board") {
|
|
|
23631
23656
|
{ kind: "card-not-found", id }
|
|
23632
23657
|
);
|
|
23633
23658
|
}
|
|
23634
|
-
const file = found2.kind === "group" ?
|
|
23659
|
+
const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
|
|
23635
23660
|
let text4;
|
|
23636
23661
|
try {
|
|
23637
|
-
text4 =
|
|
23662
|
+
text4 = fs79.readFileSync(file, "utf8");
|
|
23638
23663
|
} catch {
|
|
23639
23664
|
die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
|
|
23640
23665
|
}
|
|
@@ -24452,7 +24477,7 @@ __export(watch_exports, {
|
|
|
24452
24477
|
watchRun: () => watchRun
|
|
24453
24478
|
});
|
|
24454
24479
|
import { spawn as spawn3 } from "node:child_process";
|
|
24455
|
-
import
|
|
24480
|
+
import fs80 from "node:fs";
|
|
24456
24481
|
async function watchRun(sessionId, resume = startResume) {
|
|
24457
24482
|
const spec = readSpec(sessionId);
|
|
24458
24483
|
const run = peekRun(sessionId);
|
|
@@ -24488,11 +24513,11 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
24488
24513
|
const record = claimed ?? run;
|
|
24489
24514
|
const sub = record.action === "sub";
|
|
24490
24515
|
if (claim) await setCardStatus(claim.cardId, claim.status);
|
|
24491
|
-
|
|
24492
|
-
const logFile =
|
|
24516
|
+
fs80.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
24517
|
+
const logFile = fs80.createWriteStream(record.logPath, { flags: "a" });
|
|
24493
24518
|
logFile.on("error", () => {
|
|
24494
24519
|
});
|
|
24495
|
-
const eventsFile =
|
|
24520
|
+
const eventsFile = fs80.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
|
|
24496
24521
|
eventsFile.on("error", () => {
|
|
24497
24522
|
});
|
|
24498
24523
|
const event2 = (e) => eventsFile.write(`${JSON.stringify(e)}
|
|
@@ -24766,8 +24791,9 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
24766
24791
|
formatErrors = [{ file: rel(TODO), line: 1, rule: "read-error", message: `Cannot validate the card files: ${String(error)}. Restore readable Markdown files and retry.` }];
|
|
24767
24792
|
}
|
|
24768
24793
|
}
|
|
24769
|
-
const contractError = formatErrors.length ?
|
|
24770
|
-
const
|
|
24794
|
+
const contractError = formatErrors.length ? boardCheckErrors(formatErrors) : void 0;
|
|
24795
|
+
const repairing = !!contractError && repairable && (record.formatRepair?.attempt ?? 0) < MAX_FORMAT_REPAIRS;
|
|
24796
|
+
const problems = formatErrors.length && !repairing ? boardProblems(formatErrors) : void 0;
|
|
24771
24797
|
if (contractError) {
|
|
24772
24798
|
log.write(`
|
|
24773
24799
|
[validation] ${contractError}
|
|
@@ -24809,7 +24835,7 @@ ${result}
|
|
|
24809
24835
|
const noteWhy = status === "done" ? settled?.stalledWhy ?? [] : [];
|
|
24810
24836
|
const saidOurs = !asked && silent && !spawnError;
|
|
24811
24837
|
const errorWhy = [
|
|
24812
|
-
...
|
|
24838
|
+
...problems ? [{ kind: "format" }] : [],
|
|
24813
24839
|
...spawnWhy ? [spawnWhy] : [],
|
|
24814
24840
|
...saidOurs ? [waited ? { kind: "backgroundSilent", args: { n: String(BACKGROUND_WAIT.minutes / 60) } } : { kind: "silent", args: { n: String(silenceFor) } }] : []
|
|
24815
24841
|
];
|
|
@@ -24845,11 +24871,11 @@ ${result}
|
|
|
24845
24871
|
endedAt
|
|
24846
24872
|
});
|
|
24847
24873
|
letGo();
|
|
24848
|
-
if (
|
|
24874
|
+
if (repairing) {
|
|
24849
24875
|
const next = await resume(sessionId);
|
|
24850
24876
|
if ("error" in next) patch(sessionId, (r) => {
|
|
24851
|
-
r.error = `${
|
|
24852
|
-
Cannot resume
|
|
24877
|
+
r.error = `${boardProblems(formatErrors)}
|
|
24878
|
+
Cannot resume board repair: ${next.error}`;
|
|
24853
24879
|
r.errorWhy = [{ kind: "format" }, { kind: "repairUnstarted", refusals: [next] }];
|
|
24854
24880
|
});
|
|
24855
24881
|
}
|
|
@@ -25059,8 +25085,8 @@ var init_watch = __esm({
|
|
|
25059
25085
|
});
|
|
25060
25086
|
|
|
25061
25087
|
// src/commands/run.ts
|
|
25062
|
-
import
|
|
25063
|
-
import
|
|
25088
|
+
import fs81 from "node:fs";
|
|
25089
|
+
import path81 from "node:path";
|
|
25064
25090
|
async function cmdStartRun(action, args, opts, program2 = "akb") {
|
|
25065
25091
|
const { req, follow: follow2, print } = readRequest(action, args, opts);
|
|
25066
25092
|
if (Number.isInteger(req.id)) {
|
|
@@ -25270,7 +25296,7 @@ async function cmdSubStart(words, opts) {
|
|
|
25270
25296
|
let prompt = words.join(" ");
|
|
25271
25297
|
if (opts.file) {
|
|
25272
25298
|
try {
|
|
25273
|
-
prompt =
|
|
25299
|
+
prompt = fs81.readFileSync(path81.resolve(opts.file), "utf8");
|
|
25274
25300
|
} catch {
|
|
25275
25301
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
25276
25302
|
}
|
|
@@ -25636,7 +25662,7 @@ var init_signals = __esm({
|
|
|
25636
25662
|
});
|
|
25637
25663
|
|
|
25638
25664
|
// src/commands/triage.ts
|
|
25639
|
-
import
|
|
25665
|
+
import fs82 from "node:fs";
|
|
25640
25666
|
async function cmdTriageAdd(opts) {
|
|
25641
25667
|
const title = (opts.title ?? "").trim();
|
|
25642
25668
|
if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
|
|
@@ -25646,7 +25672,7 @@ async function cmdTriageAdd(opts) {
|
|
|
25646
25672
|
let body = opts.text;
|
|
25647
25673
|
if (opts.file !== void 0) {
|
|
25648
25674
|
try {
|
|
25649
|
-
body =
|
|
25675
|
+
body = fs82.readFileSync(opts.file, "utf8");
|
|
25650
25676
|
} catch {
|
|
25651
25677
|
die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
|
|
25652
25678
|
}
|
|
@@ -26058,6 +26084,14 @@ function declareRuns(program2, cli) {
|
|
|
26058
26084
|
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) {
|
|
26059
26085
|
await boardless(this, cli, () => cmdWorkflowPush(folder, this.opts()));
|
|
26060
26086
|
});
|
|
26087
|
+
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) {
|
|
26088
|
+
await onBoard2(this, cli, () => cmdWorkflowRule(id, this.opts()));
|
|
26089
|
+
});
|
|
26090
|
+
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(
|
|
26091
|
+
"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."
|
|
26092
|
+
).action(async function(agent) {
|
|
26093
|
+
await onBoard2(this, cli, () => cmdWorkflowInstructions(agent, this.opts()));
|
|
26094
|
+
});
|
|
26061
26095
|
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(
|
|
26062
26096
|
"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."
|
|
26063
26097
|
).action(async function(...vals) {
|
|
@@ -26241,15 +26275,15 @@ var init_agent2 = __esm({
|
|
|
26241
26275
|
});
|
|
26242
26276
|
|
|
26243
26277
|
// src/kanban.ts
|
|
26244
|
-
import
|
|
26278
|
+
import fs85 from "node:fs";
|
|
26245
26279
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
26246
26280
|
|
|
26247
26281
|
// src/lib/cli/akb.ts
|
|
26248
26282
|
init_agent2();
|
|
26249
26283
|
|
|
26250
26284
|
// src/lib/cli/setup.ts
|
|
26251
|
-
import
|
|
26252
|
-
import
|
|
26285
|
+
import fs84 from "node:fs";
|
|
26286
|
+
import path83 from "node:path";
|
|
26253
26287
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
26254
26288
|
|
|
26255
26289
|
// src/commands/update.ts
|
|
@@ -26263,8 +26297,8 @@ init_paths();
|
|
|
26263
26297
|
init_memory();
|
|
26264
26298
|
init_yaml2();
|
|
26265
26299
|
init_version();
|
|
26266
|
-
import
|
|
26267
|
-
import
|
|
26300
|
+
import fs83 from "node:fs";
|
|
26301
|
+
import path82 from "node:path";
|
|
26268
26302
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
26269
26303
|
var NAME = "wildcrane";
|
|
26270
26304
|
var REPO = "https://github.com/wildcrane-ai/wildcrane";
|
|
@@ -26286,10 +26320,10 @@ var Report = class {
|
|
|
26286
26320
|
for (const line of this.notes) say(` ! ${line}`);
|
|
26287
26321
|
}
|
|
26288
26322
|
};
|
|
26289
|
-
var read2 = (file) =>
|
|
26323
|
+
var read2 = (file) => fs83.existsSync(file) ? fs83.readFileSync(file, "utf8") : null;
|
|
26290
26324
|
function statOf(p) {
|
|
26291
26325
|
try {
|
|
26292
|
-
return
|
|
26326
|
+
return fs83.lstatSync(p);
|
|
26293
26327
|
} catch {
|
|
26294
26328
|
return null;
|
|
26295
26329
|
}
|
|
@@ -26314,10 +26348,10 @@ async function cmdUpdate2(ctx) {
|
|
|
26314
26348
|
return { updated: ctx.dir, from, to: SKILL_VERSION };
|
|
26315
26349
|
}
|
|
26316
26350
|
async function repairBoard(root2, report3, named2) {
|
|
26317
|
-
const legacy2 =
|
|
26318
|
-
const kept2 =
|
|
26319
|
-
const board2 = named2 ?? (
|
|
26320
|
-
if (!
|
|
26351
|
+
const legacy2 = path82.join(root2, "docs", "kanban");
|
|
26352
|
+
const kept2 = path82.join(root2, ".akb", "kanban");
|
|
26353
|
+
const board2 = named2 ?? (fs83.existsSync(legacy2) ? legacy2 : kept2);
|
|
26354
|
+
if (!fs83.existsSync(board2)) {
|
|
26321
26355
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
26322
26356
|
return false;
|
|
26323
26357
|
}
|
|
@@ -26348,20 +26382,20 @@ function moveRuntimes(root2, board2, report3) {
|
|
|
26348
26382
|
}
|
|
26349
26383
|
}
|
|
26350
26384
|
function moveLegacyMemory(board2, report3) {
|
|
26351
|
-
const memory =
|
|
26385
|
+
const memory = path82.join(board2, "memory");
|
|
26352
26386
|
const moved = [];
|
|
26353
26387
|
for (const name of MEMORY_FILES) {
|
|
26354
|
-
const from =
|
|
26388
|
+
const from = path82.join(board2, name);
|
|
26355
26389
|
const st = statOf(from);
|
|
26356
26390
|
if (!st || !st.isFile()) continue;
|
|
26357
|
-
|
|
26358
|
-
const to =
|
|
26391
|
+
fs83.mkdirSync(memory, { recursive: true });
|
|
26392
|
+
const to = path82.join(memory, name);
|
|
26359
26393
|
const there = read2(to);
|
|
26360
26394
|
if (there === null) {
|
|
26361
|
-
|
|
26395
|
+
fs83.renameSync(from, to);
|
|
26362
26396
|
moved.push(name);
|
|
26363
26397
|
} else if (there === read2(from)) {
|
|
26364
|
-
|
|
26398
|
+
fs83.rmSync(from);
|
|
26365
26399
|
moved.push(name);
|
|
26366
26400
|
} else {
|
|
26367
26401
|
report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
|
|
@@ -26370,23 +26404,23 @@ function moveLegacyMemory(board2, report3) {
|
|
|
26370
26404
|
if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
|
|
26371
26405
|
}
|
|
26372
26406
|
function dropRecordFile(board2) {
|
|
26373
|
-
const file =
|
|
26374
|
-
if (!
|
|
26375
|
-
|
|
26407
|
+
const file = path82.join(board2, "record.csv");
|
|
26408
|
+
if (!fs83.existsSync(file)) return null;
|
|
26409
|
+
fs83.rmSync(file);
|
|
26376
26410
|
return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
|
|
26377
26411
|
}
|
|
26378
26412
|
function dropModuleGoals(board2, report3) {
|
|
26379
|
-
const memory =
|
|
26380
|
-
if (!
|
|
26381
|
-
const root2 = read2(
|
|
26413
|
+
const memory = path82.join(board2, "memory");
|
|
26414
|
+
if (!fs83.existsSync(memory)) return;
|
|
26415
|
+
const root2 = read2(path82.join(memory, "goal.md"));
|
|
26382
26416
|
let dropped = 0;
|
|
26383
|
-
for (const entry of
|
|
26417
|
+
for (const entry of fs83.readdirSync(memory, { withFileTypes: true })) {
|
|
26384
26418
|
if (!entry.isDirectory()) continue;
|
|
26385
|
-
const file =
|
|
26419
|
+
const file = path82.join(memory, entry.name, "goal.md");
|
|
26386
26420
|
const text4 = read2(file);
|
|
26387
26421
|
if (text4 === null) continue;
|
|
26388
26422
|
if (text4 === root2 || text4.includes(UNFILLED) || !goalWords(text4)) {
|
|
26389
|
-
|
|
26423
|
+
fs83.rmSync(file);
|
|
26390
26424
|
dropped++;
|
|
26391
26425
|
} else {
|
|
26392
26426
|
report3.notes.push(
|
|
@@ -26408,10 +26442,10 @@ var PLAN_LEADS = {
|
|
|
26408
26442
|
var GONE_LEADS = ["software-planner", "planner"];
|
|
26409
26443
|
function planLeads(board2) {
|
|
26410
26444
|
const leads = { ...PLAN_LEADS };
|
|
26411
|
-
const root2 =
|
|
26412
|
-
for (const entry of
|
|
26445
|
+
const root2 = path82.join(board2, "workflows");
|
|
26446
|
+
for (const entry of fs83.existsSync(root2) ? fs83.readdirSync(root2, { withFileTypes: true }) : []) {
|
|
26413
26447
|
if (!entry.isDirectory()) continue;
|
|
26414
|
-
const meta = splitFrontmatter(read2(
|
|
26448
|
+
const meta = splitFrontmatter(read2(path82.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
|
|
26415
26449
|
const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
|
|
26416
26450
|
const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
|
|
26417
26451
|
const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
|
|
@@ -26420,30 +26454,30 @@ function planLeads(board2) {
|
|
|
26420
26454
|
return leads;
|
|
26421
26455
|
}
|
|
26422
26456
|
function movePlanRules(board2, report3) {
|
|
26423
|
-
const rules =
|
|
26457
|
+
const rules = path82.join(board2, "rules");
|
|
26424
26458
|
const moved = [];
|
|
26425
26459
|
for (const [id, leads] of Object.entries(planLeads(board2))) {
|
|
26426
26460
|
for (const lead of leads) {
|
|
26427
|
-
const from =
|
|
26461
|
+
const from = path82.join(rules, `${lead}.md`);
|
|
26428
26462
|
const rule = read2(from)?.trim();
|
|
26429
26463
|
if (!rule) continue;
|
|
26430
|
-
const to =
|
|
26464
|
+
const to = path82.join(rules, "workflows", `${id}.md`);
|
|
26431
26465
|
const there = read2(to)?.trim() ?? "";
|
|
26432
26466
|
if (!there.includes(rule)) {
|
|
26433
|
-
|
|
26434
|
-
|
|
26467
|
+
fs83.mkdirSync(path82.dirname(to), { recursive: true });
|
|
26468
|
+
fs83.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
|
|
26435
26469
|
`);
|
|
26436
26470
|
moved.push(`${lead} \u2192 ${id}`);
|
|
26437
26471
|
}
|
|
26438
26472
|
}
|
|
26439
26473
|
}
|
|
26440
|
-
for (const lead of GONE_LEADS)
|
|
26474
|
+
for (const lead of GONE_LEADS) fs83.rmSync(path82.join(rules, `${lead}.md`), { force: true });
|
|
26441
26475
|
if (moved.length) report3.did.push(`made each plan agent's rule its workflow's card rule (docs/kanban/rules/workflows/): ${moved.join(", ")}`);
|
|
26442
26476
|
}
|
|
26443
26477
|
function noteOldWorkflows(board2, report3) {
|
|
26444
26478
|
const old = (dir, file, keys) => {
|
|
26445
|
-
const root2 =
|
|
26446
|
-
return (
|
|
26479
|
+
const root2 = path82.join(board2, dir);
|
|
26480
|
+
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}`);
|
|
26447
26481
|
};
|
|
26448
26482
|
const files = [...old("workflows", "WORKFLOW.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
|
|
26449
26483
|
if (files.length) {
|
|
@@ -26453,7 +26487,7 @@ function noteOldWorkflows(board2, report3) {
|
|
|
26453
26487
|
}
|
|
26454
26488
|
}
|
|
26455
26489
|
function checkConfig(board2, report3) {
|
|
26456
|
-
const current = read2(
|
|
26490
|
+
const current = read2(path82.join(board2, "config.md"));
|
|
26457
26491
|
if (!current) return;
|
|
26458
26492
|
const added = missingConfigKeys(current);
|
|
26459
26493
|
if (added.length) {
|
|
@@ -26463,7 +26497,7 @@ function checkConfig(board2, report3) {
|
|
|
26463
26497
|
}
|
|
26464
26498
|
}
|
|
26465
26499
|
function checkModules(board2, report3) {
|
|
26466
|
-
const map2 = read2(
|
|
26500
|
+
const map2 = read2(path82.join(board2, "modules.md"));
|
|
26467
26501
|
if (map2 && map2.includes(UNFILLED)) {
|
|
26468
26502
|
report3.notes.push(
|
|
26469
26503
|
"docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
|
|
@@ -26517,14 +26551,14 @@ function declareSetup(program2, cli) {
|
|
|
26517
26551
|
program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
|
|
26518
26552
|
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");
|
|
26519
26553
|
const where = (cmd) => {
|
|
26520
|
-
const dir =
|
|
26521
|
-
if (!
|
|
26554
|
+
const dir = path83.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
26555
|
+
if (!fs84.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
26522
26556
|
return dir;
|
|
26523
26557
|
};
|
|
26524
26558
|
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() {
|
|
26525
26559
|
const dir = where(this);
|
|
26526
26560
|
const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
|
|
26527
|
-
const board2 = named2 ?
|
|
26561
|
+
const board2 = named2 ? path83.resolve(cli.cwd, named2) : null;
|
|
26528
26562
|
await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
|
|
26529
26563
|
});
|
|
26530
26564
|
program2.command("__rules", { hidden: true }).action(function() {
|
|
@@ -26569,7 +26603,7 @@ function invokedDirectly() {
|
|
|
26569
26603
|
const entry = process.argv[1];
|
|
26570
26604
|
if (!entry) return false;
|
|
26571
26605
|
try {
|
|
26572
|
-
return
|
|
26606
|
+
return fs85.realpathSync(entry) === fs85.realpathSync(SELF2);
|
|
26573
26607
|
} catch {
|
|
26574
26608
|
return false;
|
|
26575
26609
|
}
|