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